documentation.d.ts 3.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. private static _LogCache;
  333. /**
  334. * Gets a value indicating the number of loading errors
  335. * @ignorenaming
  336. */
  337. static errorsCount: number;
  338. /**
  339. * Callback called when a new log is added
  340. */
  341. static OnNewCacheEntry: (entry: string) => void;
  342. private static _AddLogEntry;
  343. private static _FormatMessage;
  344. private static _LogDisabled;
  345. private static _LogEnabled;
  346. private static _WarnDisabled;
  347. private static _WarnEnabled;
  348. private static _ErrorDisabled;
  349. private static _ErrorEnabled;
  350. /**
  351. * Log a message to the console
  352. */
  353. static Log: (message: string) => void;
  354. /**
  355. * Write a warning message to the console
  356. */
  357. static Warn: (message: string) => void;
  358. /**
  359. * Write an error message to the console
  360. */
  361. static Error: (message: string) => void;
  362. /**
  363. * Gets current log cache (list of logs)
  364. */
  365. static get LogCache(): string;
  366. /**
  367. * Clears the log cache
  368. */
  369. static ClearLogCache(): void;
  370. /**
  371. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  372. */
  373. static set LogLevels(level: number);
  374. }
  375. }
  376. declare module BABYLON {
  377. /** @hidden */
  378. export class _TypeStore {
  379. /** @hidden */
  380. static RegisteredTypes: {
  381. [key: string]: Object;
  382. };
  383. /** @hidden */
  384. static GetClass(fqdn: string): any;
  385. }
  386. }
  387. declare module BABYLON {
  388. /**
  389. * Helper to manipulate strings
  390. */
  391. export class StringTools {
  392. /**
  393. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  394. * @param str Source string
  395. * @param suffix Suffix to search for in the source string
  396. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  397. */
  398. static EndsWith(str: string, suffix: string): boolean;
  399. /**
  400. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static StartsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Decodes a buffer into a string
  408. * @param buffer The buffer to decode
  409. * @returns The decoded string
  410. */
  411. static Decode(buffer: Uint8Array | Uint16Array): string;
  412. /**
  413. * Encode a buffer to a base64 string
  414. * @param buffer defines the buffer to encode
  415. * @returns the encoded string
  416. */
  417. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  418. /**
  419. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  420. * @param num the number to convert and pad
  421. * @param length the expected length of the string
  422. * @returns the padded string
  423. */
  424. static PadNumber(num: number, length: number): string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Class containing a set of static utilities functions for deep copy.
  430. */
  431. export class DeepCopier {
  432. /**
  433. * Tries to copy an object by duplicating every property
  434. * @param source defines the source object
  435. * @param destination defines the target object
  436. * @param doNotCopyList defines a list of properties to avoid
  437. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  438. */
  439. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  440. }
  441. }
  442. declare module BABYLON {
  443. /**
  444. * Class containing a set of static utilities functions for precision date
  445. */
  446. export class PrecisionDate {
  447. /**
  448. * Gets either window.performance.now() if supported or Date.now() else
  449. */
  450. static get Now(): number;
  451. }
  452. }
  453. declare module BABYLON {
  454. /** @hidden */
  455. export class _DevTools {
  456. static WarnImport(name: string): string;
  457. }
  458. }
  459. declare module BABYLON {
  460. /**
  461. * Interface used to define the mechanism to get data from the network
  462. */
  463. export interface IWebRequest {
  464. /**
  465. * Returns client's response url
  466. */
  467. responseURL: string;
  468. /**
  469. * Returns client's status
  470. */
  471. status: number;
  472. /**
  473. * Returns client's status as a text
  474. */
  475. statusText: string;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  481. */
  482. export class WebRequest implements IWebRequest {
  483. private readonly _xhr;
  484. /**
  485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  486. * i.e. when loading files, where the server/service expects an Authorization header
  487. */
  488. static CustomRequestHeaders: {
  489. [key: string]: string;
  490. };
  491. /**
  492. * Add callback functions in this array to update all the requests before they get sent to the network
  493. */
  494. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  495. private _injectCustomRequestHeaders;
  496. /**
  497. * Gets or sets a function to be called when loading progress changes
  498. */
  499. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  500. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  501. /**
  502. * Returns client's state
  503. */
  504. get readyState(): number;
  505. /**
  506. * Returns client's status
  507. */
  508. get status(): number;
  509. /**
  510. * Returns client's status as a text
  511. */
  512. get statusText(): string;
  513. /**
  514. * Returns client's response
  515. */
  516. get response(): any;
  517. /**
  518. * Returns client's response url
  519. */
  520. get responseURL(): string;
  521. /**
  522. * Returns client's response as text
  523. */
  524. get responseText(): string;
  525. /**
  526. * Gets or sets the expected response type
  527. */
  528. get responseType(): XMLHttpRequestResponseType;
  529. set responseType(value: XMLHttpRequestResponseType);
  530. /** @hidden */
  531. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  532. /** @hidden */
  533. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  534. /**
  535. * Cancels any network activity
  536. */
  537. abort(): void;
  538. /**
  539. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  540. * @param body defines an optional request body
  541. */
  542. send(body?: Document | BodyInit | null): void;
  543. /**
  544. * Sets the request method, request URL
  545. * @param method defines the method to use (GET, POST, etc..)
  546. * @param url defines the url to connect with
  547. */
  548. open(method: string, url: string): void;
  549. /**
  550. * Sets the value of a request header.
  551. * @param name The name of the header whose value is to be set
  552. * @param value The value to set as the body of the header
  553. */
  554. setRequestHeader(name: string, value: string): void;
  555. /**
  556. * Get the string containing the text of a particular header's value.
  557. * @param name The name of the header
  558. * @returns The string containing the text of the given header name
  559. */
  560. getResponseHeader(name: string): Nullable<string>;
  561. }
  562. }
  563. declare module BABYLON {
  564. /**
  565. * File request interface
  566. */
  567. export interface IFileRequest {
  568. /**
  569. * Raised when the request is complete (success or error).
  570. */
  571. onCompleteObservable: Observable<IFileRequest>;
  572. /**
  573. * Aborts the request for a file.
  574. */
  575. abort: () => void;
  576. }
  577. }
  578. declare module BABYLON {
  579. /**
  580. * Define options used to create a render target texture
  581. */
  582. export class RenderTargetCreationOptions {
  583. /**
  584. * Specifies is mipmaps must be generated
  585. */
  586. generateMipMaps?: boolean;
  587. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  588. generateDepthBuffer?: boolean;
  589. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  590. generateStencilBuffer?: boolean;
  591. /** Defines texture type (int by default) */
  592. type?: number;
  593. /** Defines sampling mode (trilinear by default) */
  594. samplingMode?: number;
  595. /** Defines format (RGBA by default) */
  596. format?: number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /** Defines the cross module used constants to avoid circular dependncies */
  601. export class Constants {
  602. /** Defines that alpha blending is disabled */
  603. static readonly ALPHA_DISABLE: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  605. static readonly ALPHA_ADD: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  607. static readonly ALPHA_COMBINE: number;
  608. /** Defines that alpha blending is DEST - SRC * DEST */
  609. static readonly ALPHA_SUBTRACT: number;
  610. /** Defines that alpha blending is SRC * DEST */
  611. static readonly ALPHA_MULTIPLY: number;
  612. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  613. static readonly ALPHA_MAXIMIZED: number;
  614. /** Defines that alpha blending is SRC + DEST */
  615. static readonly ALPHA_ONEONE: number;
  616. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  617. static readonly ALPHA_PREMULTIPLIED: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  620. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  623. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  624. static readonly ALPHA_INTERPOLATE: number;
  625. /**
  626. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  627. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  628. */
  629. static readonly ALPHA_SCREENMODE: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST
  632. * Alpha will be set to SRC ALPHA + DST ALPHA
  633. */
  634. static readonly ALPHA_ONEONE_ONEONE: number;
  635. /**
  636. * Defines that alpha blending is SRC * DST ALPHA + DST
  637. * Alpha will be set to 0
  638. */
  639. static readonly ALPHA_ALPHATOCOLOR: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. */
  643. static readonly ALPHA_REVERSEONEMINUS: number;
  644. /**
  645. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  646. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  647. */
  648. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  649. /**
  650. * Defines that alpha blending is SRC + DST
  651. * Alpha will be set to SRC ALPHA
  652. */
  653. static readonly ALPHA_ONEONE_ONEZERO: number;
  654. /**
  655. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  656. * Alpha will be set to DST ALPHA
  657. */
  658. static readonly ALPHA_EXCLUSION: number;
  659. /** Defines that alpha blending equation a SUM */
  660. static readonly ALPHA_EQUATION_ADD: number;
  661. /** Defines that alpha blending equation a SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  663. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  664. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  665. /** Defines that alpha blending equation a MAX operation */
  666. static readonly ALPHA_EQUATION_MAX: number;
  667. /** Defines that alpha blending equation a MIN operation */
  668. static readonly ALPHA_EQUATION_MIN: number;
  669. /**
  670. * Defines that alpha blending equation a DARKEN operation:
  671. * It takes the min of the src and sums the alpha channels.
  672. */
  673. static readonly ALPHA_EQUATION_DARKEN: number;
  674. /** Defines that the ressource is not delayed*/
  675. static readonly DELAYLOADSTATE_NONE: number;
  676. /** Defines that the ressource was successfully delay loaded */
  677. static readonly DELAYLOADSTATE_LOADED: number;
  678. /** Defines that the ressource is currently delay loading */
  679. static readonly DELAYLOADSTATE_LOADING: number;
  680. /** Defines that the ressource is delayed and has not started loading */
  681. static readonly DELAYLOADSTATE_NOTLOADED: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  683. static readonly NEVER: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  685. static readonly ALWAYS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  687. static readonly LESS: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  689. static readonly EQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  691. static readonly LEQUAL: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  693. static readonly GREATER: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  695. static readonly GEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  697. static readonly NOTEQUAL: number;
  698. /** Passed to stencilOperation to specify that stencil value must be kept */
  699. static readonly KEEP: number;
  700. /** Passed to stencilOperation to specify that stencil value must be replaced */
  701. static readonly REPLACE: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented */
  703. static readonly INCR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented */
  705. static readonly DECR: number;
  706. /** Passed to stencilOperation to specify that stencil value must be inverted */
  707. static readonly INVERT: number;
  708. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  709. static readonly INCR_WRAP: number;
  710. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  711. static readonly DECR_WRAP: number;
  712. /** Texture is not repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  714. /** Texture is repeating outside of 0..1 UVs */
  715. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  716. /** Texture is repeating and mirrored */
  717. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  718. /** ALPHA */
  719. static readonly TEXTUREFORMAT_ALPHA: number;
  720. /** LUMINANCE */
  721. static readonly TEXTUREFORMAT_LUMINANCE: number;
  722. /** LUMINANCE_ALPHA */
  723. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  724. /** RGB */
  725. static readonly TEXTUREFORMAT_RGB: number;
  726. /** RGBA */
  727. static readonly TEXTUREFORMAT_RGBA: number;
  728. /** RED */
  729. static readonly TEXTUREFORMAT_RED: number;
  730. /** RED (2nd reference) */
  731. static readonly TEXTUREFORMAT_R: number;
  732. /** RG */
  733. static readonly TEXTUREFORMAT_RG: number;
  734. /** RED_INTEGER */
  735. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  736. /** RED_INTEGER (2nd reference) */
  737. static readonly TEXTUREFORMAT_R_INTEGER: number;
  738. /** RG_INTEGER */
  739. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  740. /** RGB_INTEGER */
  741. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  742. /** RGBA_INTEGER */
  743. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  744. /** UNSIGNED_BYTE */
  745. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  746. /** UNSIGNED_BYTE (2nd reference) */
  747. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  748. /** FLOAT */
  749. static readonly TEXTURETYPE_FLOAT: number;
  750. /** HALF_FLOAT */
  751. static readonly TEXTURETYPE_HALF_FLOAT: number;
  752. /** BYTE */
  753. static readonly TEXTURETYPE_BYTE: number;
  754. /** SHORT */
  755. static readonly TEXTURETYPE_SHORT: number;
  756. /** UNSIGNED_SHORT */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  758. /** INT */
  759. static readonly TEXTURETYPE_INT: number;
  760. /** UNSIGNED_INT */
  761. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  762. /** UNSIGNED_SHORT_4_4_4_4 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  764. /** UNSIGNED_SHORT_5_5_5_1 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  766. /** UNSIGNED_SHORT_5_6_5 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  768. /** UNSIGNED_INT_2_10_10_10_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  770. /** UNSIGNED_INT_24_8 */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  772. /** UNSIGNED_INT_10F_11F_11F_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  774. /** UNSIGNED_INT_5_9_9_9_REV */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  776. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  777. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  778. /** nearest is mag = nearest and min = nearest and no mip */
  779. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  780. /** mag = nearest and min = nearest and mip = none */
  781. static readonly TEXTURE_NEAREST_NEAREST: number;
  782. /** Bilinear is mag = linear and min = linear and no mip */
  783. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  784. /** mag = linear and min = linear and mip = none */
  785. static readonly TEXTURE_LINEAR_LINEAR: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  788. /** Trilinear is mag = linear and min = linear and mip = linear */
  789. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = nearest and mip = nearest */
  791. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = nearest */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  794. /** mag = nearest and min = linear and mip = linear */
  795. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  796. /** mag = nearest and min = linear and mip = none */
  797. static readonly TEXTURE_NEAREST_LINEAR: number;
  798. /** nearest is mag = nearest and min = nearest and mip = linear */
  799. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = nearest and mip = nearest */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  802. /** mag = linear and min = nearest and mip = linear */
  803. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  804. /** Bilinear is mag = linear and min = linear and mip = nearest */
  805. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = none */
  807. static readonly TEXTURE_LINEAR_NEAREST: number;
  808. /** Explicit coordinates mode */
  809. static readonly TEXTURE_EXPLICIT_MODE: number;
  810. /** Spherical coordinates mode */
  811. static readonly TEXTURE_SPHERICAL_MODE: number;
  812. /** Planar coordinates mode */
  813. static readonly TEXTURE_PLANAR_MODE: number;
  814. /** Cubic coordinates mode */
  815. static readonly TEXTURE_CUBIC_MODE: number;
  816. /** Projection coordinates mode */
  817. static readonly TEXTURE_PROJECTION_MODE: number;
  818. /** Skybox coordinates mode */
  819. static readonly TEXTURE_SKYBOX_MODE: number;
  820. /** Inverse Cubic coordinates mode */
  821. static readonly TEXTURE_INVCUBIC_MODE: number;
  822. /** Equirectangular coordinates mode */
  823. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  826. /** Equirectangular Fixed Mirrored coordinates mode */
  827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  828. /** Offline (baking) quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  830. /** High quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  832. /** Medium quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  834. /** Low quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  836. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  837. static readonly SCALEMODE_FLOOR: number;
  838. /** Defines that texture rescaling will look for the nearest power of 2 size */
  839. static readonly SCALEMODE_NEAREST: number;
  840. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  841. static readonly SCALEMODE_CEILING: number;
  842. /**
  843. * The dirty texture flag value
  844. */
  845. static readonly MATERIAL_TextureDirtyFlag: number;
  846. /**
  847. * The dirty light flag value
  848. */
  849. static readonly MATERIAL_LightDirtyFlag: number;
  850. /**
  851. * The dirty fresnel flag value
  852. */
  853. static readonly MATERIAL_FresnelDirtyFlag: number;
  854. /**
  855. * The dirty attribute flag value
  856. */
  857. static readonly MATERIAL_AttributesDirtyFlag: number;
  858. /**
  859. * The dirty misc flag value
  860. */
  861. static readonly MATERIAL_MiscDirtyFlag: number;
  862. /**
  863. * The dirty prepass flag value
  864. */
  865. static readonly MATERIAL_PrePassDirtyFlag: number;
  866. /**
  867. * The all dirty flag value
  868. */
  869. static readonly MATERIAL_AllDirtyFlag: number;
  870. /**
  871. * Returns the triangle fill mode
  872. */
  873. static readonly MATERIAL_TriangleFillMode: number;
  874. /**
  875. * Returns the wireframe mode
  876. */
  877. static readonly MATERIAL_WireFrameFillMode: number;
  878. /**
  879. * Returns the point fill mode
  880. */
  881. static readonly MATERIAL_PointFillMode: number;
  882. /**
  883. * Returns the point list draw mode
  884. */
  885. static readonly MATERIAL_PointListDrawMode: number;
  886. /**
  887. * Returns the line list draw mode
  888. */
  889. static readonly MATERIAL_LineListDrawMode: number;
  890. /**
  891. * Returns the line loop draw mode
  892. */
  893. static readonly MATERIAL_LineLoopDrawMode: number;
  894. /**
  895. * Returns the line strip draw mode
  896. */
  897. static readonly MATERIAL_LineStripDrawMode: number;
  898. /**
  899. * Returns the triangle strip draw mode
  900. */
  901. static readonly MATERIAL_TriangleStripDrawMode: number;
  902. /**
  903. * Returns the triangle fan draw mode
  904. */
  905. static readonly MATERIAL_TriangleFanDrawMode: number;
  906. /**
  907. * Stores the clock-wise side orientation
  908. */
  909. static readonly MATERIAL_ClockWiseSideOrientation: number;
  910. /**
  911. * Stores the counter clock-wise side orientation
  912. */
  913. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  914. /**
  915. * Nothing
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_NothingTrigger: number;
  919. /**
  920. * On pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickTrigger: number;
  924. /**
  925. * On left pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnLeftPickTrigger: number;
  929. /**
  930. * On right pick
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnRightPickTrigger: number;
  934. /**
  935. * On center pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnCenterPickTrigger: number;
  939. /**
  940. * On pick down
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickDownTrigger: number;
  944. /**
  945. * On double pick
  946. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnDoublePickTrigger: number;
  949. /**
  950. * On pick up
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickUpTrigger: number;
  954. /**
  955. * On pick out.
  956. * This trigger will only be raised if you also declared a OnPickDown
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPickOutTrigger: number;
  960. /**
  961. * On long press
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnLongPressTrigger: number;
  965. /**
  966. * On pointer over
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnPointerOverTrigger: number;
  970. /**
  971. * On pointer out
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnPointerOutTrigger: number;
  975. /**
  976. * On every frame
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnEveryFrameTrigger: number;
  980. /**
  981. * On intersection enter
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnIntersectionEnterTrigger: number;
  985. /**
  986. * On intersection exit
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnIntersectionExitTrigger: number;
  990. /**
  991. * On key down
  992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  993. */
  994. static readonly ACTION_OnKeyDownTrigger: number;
  995. /**
  996. * On key up
  997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  998. */
  999. static readonly ACTION_OnKeyUpTrigger: number;
  1000. /**
  1001. * Billboard mode will only apply to Y axis
  1002. */
  1003. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1004. /**
  1005. * Billboard mode will apply to all axes
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1008. /**
  1009. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1012. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1013. * Test order :
  1014. * Is the bounding sphere outside the frustum ?
  1015. * If not, are the bounding box vertices outside the frustum ?
  1016. * It not, then the cullable object is in the frustum.
  1017. */
  1018. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1019. /** Culling strategy : Bounding Sphere Only.
  1020. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1021. * It's also less accurate than the standard because some not visible objects can still be selected.
  1022. * Test : is the bounding sphere outside the frustum ?
  1023. * If not, then the cullable object is in the frustum.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1026. /** Culling strategy : Optimistic Inclusion.
  1027. * This in an inclusion test first, then the standard exclusion test.
  1028. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1030. * Anyway, it's as accurate as the standard strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the default culling strategy.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1036. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1037. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1038. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1039. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1040. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1041. * Test :
  1042. * Is the cullable object bounding sphere center in the frustum ?
  1043. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1044. */
  1045. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1046. /**
  1047. * No logging while loading
  1048. */
  1049. static readonly SCENELOADER_NO_LOGGING: number;
  1050. /**
  1051. * Minimal logging while loading
  1052. */
  1053. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1054. /**
  1055. * Summary logging while loading
  1056. */
  1057. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1058. /**
  1059. * Detailled logging while loading
  1060. */
  1061. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1062. /**
  1063. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1064. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1065. */
  1066. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1067. /**
  1068. * Constant used to retrieve the position texture index in the textures array in the prepass
  1069. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1070. */
  1071. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1072. /**
  1073. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1074. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1075. */
  1076. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1077. /**
  1078. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1079. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1080. */
  1081. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1082. /**
  1083. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1084. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1085. */
  1086. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1087. /**
  1088. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1089. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1090. */
  1091. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1092. /**
  1093. * Constant used to retrieve albedo index in the textures array in the prepass
  1094. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1095. */
  1096. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1097. }
  1098. }
  1099. declare module BABYLON {
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. * @param options options to be passed to the loader
  1123. */
  1124. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1125. /**
  1126. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1127. * @param data contains the texture data
  1128. * @param texture defines the BabylonJS internal texture
  1129. * @param callback defines the method to call once ready to upload
  1130. * @param options options to be passed to the loader
  1131. */
  1132. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1133. }
  1134. }
  1135. declare module BABYLON {
  1136. /**
  1137. * Class used to store and describe the pipeline context associated with an effect
  1138. */
  1139. export interface IPipelineContext {
  1140. /**
  1141. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1142. */
  1143. isAsync: boolean;
  1144. /**
  1145. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1146. */
  1147. isReady: boolean;
  1148. /** @hidden */
  1149. _getVertexShaderCode(): string | null;
  1150. /** @hidden */
  1151. _getFragmentShaderCode(): string | null;
  1152. /** @hidden */
  1153. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1154. }
  1155. }
  1156. declare module BABYLON {
  1157. /**
  1158. * Class used to store gfx data (like WebGLBuffer)
  1159. */
  1160. export class DataBuffer {
  1161. /**
  1162. * Gets or sets the number of objects referencing this buffer
  1163. */
  1164. references: number;
  1165. /** Gets or sets the size of the underlying buffer */
  1166. capacity: number;
  1167. /**
  1168. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1169. */
  1170. is32Bits: boolean;
  1171. /**
  1172. * Gets the underlying buffer
  1173. */
  1174. get underlyingResource(): any;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export interface IShaderProcessor {
  1180. attributeProcessor?: (attribute: string) => string;
  1181. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1182. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1183. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1184. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1185. lineProcessor?: (line: string, isFragment: boolean) => string;
  1186. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1187. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export interface ProcessingOptions {
  1193. defines: string[];
  1194. indexParameters: any;
  1195. isFragment: boolean;
  1196. shouldUseHighPrecisionShader: boolean;
  1197. supportsUniformBuffers: boolean;
  1198. shadersRepository: string;
  1199. includesShadersStore: {
  1200. [key: string]: string;
  1201. };
  1202. processor?: IShaderProcessor;
  1203. version: string;
  1204. platformName: string;
  1205. lookForClosingBracketForUniformBuffer?: boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderCodeNode {
  1211. line: string;
  1212. children: ShaderCodeNode[];
  1213. additionalDefineKey?: string;
  1214. additionalDefineValue?: string;
  1215. isValid(preprocessors: {
  1216. [key: string]: string;
  1217. }): boolean;
  1218. process(preprocessors: {
  1219. [key: string]: string;
  1220. }, options: ProcessingOptions): string;
  1221. }
  1222. }
  1223. declare module BABYLON {
  1224. /** @hidden */
  1225. export class ShaderCodeCursor {
  1226. private _lines;
  1227. lineIndex: number;
  1228. get currentLine(): string;
  1229. get canRead(): boolean;
  1230. set lines(value: string[]);
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /** @hidden */
  1235. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1236. process(preprocessors: {
  1237. [key: string]: string;
  1238. }, options: ProcessingOptions): string;
  1239. }
  1240. }
  1241. declare module BABYLON {
  1242. /** @hidden */
  1243. export class ShaderDefineExpression {
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. private static _OperatorPriority;
  1248. private static _Stack;
  1249. static postfixToInfix(postfix: string[]): string;
  1250. static infixToPostfix(infix: string): string[];
  1251. }
  1252. }
  1253. declare module BABYLON {
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. not: boolean;
  1267. constructor(define: string, not?: boolean);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module BABYLON {
  1274. /** @hidden */
  1275. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1276. leftOperand: ShaderDefineExpression;
  1277. rightOperand: ShaderDefineExpression;
  1278. isTrue(preprocessors: {
  1279. [key: string]: string;
  1280. }): boolean;
  1281. }
  1282. }
  1283. declare module BABYLON {
  1284. /** @hidden */
  1285. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1286. leftOperand: ShaderDefineExpression;
  1287. rightOperand: ShaderDefineExpression;
  1288. isTrue(preprocessors: {
  1289. [key: string]: string;
  1290. }): boolean;
  1291. }
  1292. }
  1293. declare module BABYLON {
  1294. /** @hidden */
  1295. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1296. define: string;
  1297. operand: string;
  1298. testValue: string;
  1299. constructor(define: string, operand: string, testValue: string);
  1300. isTrue(preprocessors: {
  1301. [key: string]: string;
  1302. }): boolean;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * Class used to enable access to offline support
  1308. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1309. */
  1310. export interface IOfflineProvider {
  1311. /**
  1312. * Gets a boolean indicating if scene must be saved in the database
  1313. */
  1314. enableSceneOffline: boolean;
  1315. /**
  1316. * Gets a boolean indicating if textures must be saved in the database
  1317. */
  1318. enableTexturesOffline: boolean;
  1319. /**
  1320. * Open the offline support and make it available
  1321. * @param successCallback defines the callback to call on success
  1322. * @param errorCallback defines the callback to call on error
  1323. */
  1324. open(successCallback: () => void, errorCallback: () => void): void;
  1325. /**
  1326. * Loads an image from the offline support
  1327. * @param url defines the url to load from
  1328. * @param image defines the target DOM image
  1329. */
  1330. loadImage(url: string, image: HTMLImageElement): void;
  1331. /**
  1332. * Loads a file from offline support
  1333. * @param url defines the URL to load from
  1334. * @param sceneLoaded defines a callback to call on success
  1335. * @param progressCallBack defines a callback to call when progress changed
  1336. * @param errorCallback defines a callback to call on error
  1337. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1338. */
  1339. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1340. }
  1341. }
  1342. declare module BABYLON {
  1343. /**
  1344. * Class used to help managing file picking and drag'n'drop
  1345. * File Storage
  1346. */
  1347. export class FilesInputStore {
  1348. /**
  1349. * List of files ready to be loaded
  1350. */
  1351. static FilesToLoad: {
  1352. [key: string]: File;
  1353. };
  1354. }
  1355. }
  1356. declare module BABYLON {
  1357. /**
  1358. * Class used to define a retry strategy when error happens while loading assets
  1359. */
  1360. export class RetryStrategy {
  1361. /**
  1362. * Function used to defines an exponential back off strategy
  1363. * @param maxRetries defines the maximum number of retries (3 by default)
  1364. * @param baseInterval defines the interval between retries
  1365. * @returns the strategy function to use
  1366. */
  1367. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1368. }
  1369. }
  1370. declare module BABYLON {
  1371. /**
  1372. * @ignore
  1373. * Application error to support additional information when loading a file
  1374. */
  1375. export abstract class BaseError extends Error {
  1376. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1377. }
  1378. }
  1379. declare module BABYLON {
  1380. /** @ignore */
  1381. export class LoadFileError extends BaseError {
  1382. request?: WebRequest;
  1383. file?: File;
  1384. /**
  1385. * Creates a new LoadFileError
  1386. * @param message defines the message of the error
  1387. * @param request defines the optional web request
  1388. * @param file defines the optional file
  1389. */
  1390. constructor(message: string, object?: WebRequest | File);
  1391. }
  1392. /** @ignore */
  1393. export class RequestFileError extends BaseError {
  1394. request: WebRequest;
  1395. /**
  1396. * Creates a new LoadFileError
  1397. * @param message defines the message of the error
  1398. * @param request defines the optional web request
  1399. */
  1400. constructor(message: string, request: WebRequest);
  1401. }
  1402. /** @ignore */
  1403. export class ReadFileError extends BaseError {
  1404. file: File;
  1405. /**
  1406. * Creates a new ReadFileError
  1407. * @param message defines the message of the error
  1408. * @param file defines the optional file
  1409. */
  1410. constructor(message: string, file: File);
  1411. }
  1412. /**
  1413. * @hidden
  1414. */
  1415. export class FileTools {
  1416. /**
  1417. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1418. */
  1419. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1420. /**
  1421. * Gets or sets the base URL to use to load assets
  1422. */
  1423. static BaseUrl: string;
  1424. /**
  1425. * Default behaviour for cors in the application.
  1426. * It can be a string if the expected behavior is identical in the entire app.
  1427. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1428. */
  1429. static CorsBehavior: string | ((url: string | string[]) => string);
  1430. /**
  1431. * Gets or sets a function used to pre-process url before using them to load assets
  1432. */
  1433. static PreprocessUrl: (url: string) => string;
  1434. /**
  1435. * Removes unwanted characters from an url
  1436. * @param url defines the url to clean
  1437. * @returns the cleaned url
  1438. */
  1439. private static _CleanUrl;
  1440. /**
  1441. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1442. * @param url define the url we are trying
  1443. * @param element define the dom element where to configure the cors policy
  1444. */
  1445. static SetCorsBehavior(url: string | string[], element: {
  1446. crossOrigin: string | null;
  1447. }): void;
  1448. /**
  1449. * Loads an image as an HTMLImageElement.
  1450. * @param input url string, ArrayBuffer, or Blob to load
  1451. * @param onLoad callback called when the image successfully loads
  1452. * @param onError callback called when the image fails to load
  1453. * @param offlineProvider offline provider for caching
  1454. * @param mimeType optional mime type
  1455. * @returns the HTMLImageElement of the loaded image
  1456. */
  1457. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1458. /**
  1459. * Reads a file from a File object
  1460. * @param file defines the file to load
  1461. * @param onSuccess defines the callback to call when data is loaded
  1462. * @param onProgress defines the callback to call during loading process
  1463. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1464. * @param onError defines the callback to call when an error occurs
  1465. * @returns a file request object
  1466. */
  1467. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1468. /**
  1469. * Loads a file from a url
  1470. * @param url url to load
  1471. * @param onSuccess callback called when the file successfully loads
  1472. * @param onProgress callback called while file is loading (if the server supports this mode)
  1473. * @param offlineProvider defines the offline provider for caching
  1474. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1475. * @param onError callback called when the file fails to load
  1476. * @returns a file request object
  1477. */
  1478. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1479. /**
  1480. * Loads a file
  1481. * @param url url to load
  1482. * @param onSuccess callback called when the file successfully loads
  1483. * @param onProgress callback called while file is loading (if the server supports this mode)
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @param onOpened callback called when the web request is opened
  1487. * @returns a file request object
  1488. */
  1489. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1490. /**
  1491. * Checks if the loaded document was accessed via `file:`-Protocol.
  1492. * @returns boolean
  1493. */
  1494. static IsFileURL(): boolean;
  1495. }
  1496. }
  1497. declare module BABYLON {
  1498. /** @hidden */
  1499. export class ShaderProcessor {
  1500. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1501. private static _ProcessPrecision;
  1502. private static _ExtractOperation;
  1503. private static _BuildSubExpression;
  1504. private static _BuildExpression;
  1505. private static _MoveCursorWithinIf;
  1506. private static _MoveCursor;
  1507. private static _EvaluatePreProcessors;
  1508. private static _PreparePreProcessors;
  1509. private static _ProcessShaderConversion;
  1510. private static _ProcessIncludes;
  1511. /**
  1512. * Loads a file from a url
  1513. * @param url url to load
  1514. * @param onSuccess callback called when the file successfully loads
  1515. * @param onProgress callback called while file is loading (if the server supports this mode)
  1516. * @param offlineProvider defines the offline provider for caching
  1517. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1518. * @param onError callback called when the file fails to load
  1519. * @returns a file request object
  1520. * @hidden
  1521. */
  1522. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1523. }
  1524. }
  1525. declare module BABYLON {
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IColor4Like {
  1530. r: float;
  1531. g: float;
  1532. b: float;
  1533. a: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IColor3Like {
  1539. r: float;
  1540. g: float;
  1541. b: float;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IVector4Like {
  1547. x: float;
  1548. y: float;
  1549. z: float;
  1550. w: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IVector3Like {
  1556. x: float;
  1557. y: float;
  1558. z: float;
  1559. }
  1560. /**
  1561. * @hidden
  1562. */
  1563. export interface IVector2Like {
  1564. x: float;
  1565. y: float;
  1566. }
  1567. /**
  1568. * @hidden
  1569. */
  1570. export interface IMatrixLike {
  1571. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1572. updateFlag: int;
  1573. }
  1574. /**
  1575. * @hidden
  1576. */
  1577. export interface IViewportLike {
  1578. x: float;
  1579. y: float;
  1580. width: float;
  1581. height: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IPlaneLike {
  1587. normal: IVector3Like;
  1588. d: float;
  1589. normalize(): void;
  1590. }
  1591. }
  1592. declare module BABYLON {
  1593. /**
  1594. * Interface used to define common properties for effect fallbacks
  1595. */
  1596. export interface IEffectFallbacks {
  1597. /**
  1598. * Removes the defines that should be removed when falling back.
  1599. * @param currentDefines defines the current define statements for the shader.
  1600. * @param effect defines the current effect we try to compile
  1601. * @returns The resulting defines with defines of the current rank removed.
  1602. */
  1603. reduce(currentDefines: string, effect: Effect): string;
  1604. /**
  1605. * Removes the fallback from the bound mesh.
  1606. */
  1607. unBindMesh(): void;
  1608. /**
  1609. * Checks to see if more fallbacks are still availible.
  1610. */
  1611. hasMoreFallbacks: boolean;
  1612. }
  1613. }
  1614. declare module BABYLON {
  1615. /**
  1616. * Class used to evalaute queries containing `and` and `or` operators
  1617. */
  1618. export class AndOrNotEvaluator {
  1619. /**
  1620. * Evaluate a query
  1621. * @param query defines the query to evaluate
  1622. * @param evaluateCallback defines the callback used to filter result
  1623. * @returns true if the query matches
  1624. */
  1625. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1626. private static _HandleParenthesisContent;
  1627. private static _SimplifyNegation;
  1628. }
  1629. }
  1630. declare module BABYLON {
  1631. /**
  1632. * Class used to store custom tags
  1633. */
  1634. export class Tags {
  1635. /**
  1636. * Adds support for tags on the given object
  1637. * @param obj defines the object to use
  1638. */
  1639. static EnableFor(obj: any): void;
  1640. /**
  1641. * Removes tags support
  1642. * @param obj defines the object to use
  1643. */
  1644. static DisableFor(obj: any): void;
  1645. /**
  1646. * Gets a boolean indicating if the given object has tags
  1647. * @param obj defines the object to use
  1648. * @returns a boolean
  1649. */
  1650. static HasTags(obj: any): boolean;
  1651. /**
  1652. * Gets the tags available on a given object
  1653. * @param obj defines the object to use
  1654. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1655. * @returns the tags
  1656. */
  1657. static GetTags(obj: any, asString?: boolean): any;
  1658. /**
  1659. * Adds tags to an object
  1660. * @param obj defines the object to use
  1661. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1662. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1663. */
  1664. static AddTagsTo(obj: any, tagsString: string): void;
  1665. /**
  1666. * @hidden
  1667. */
  1668. static _AddTagTo(obj: any, tag: string): void;
  1669. /**
  1670. * Removes specific tags from a specific object
  1671. * @param obj defines the object to use
  1672. * @param tagsString defines the tags to remove
  1673. */
  1674. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1675. /**
  1676. * @hidden
  1677. */
  1678. static _RemoveTagFrom(obj: any, tag: string): void;
  1679. /**
  1680. * Defines if tags hosted on an object match a given query
  1681. * @param obj defines the object to use
  1682. * @param tagsQuery defines the tag query
  1683. * @returns a boolean
  1684. */
  1685. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1686. }
  1687. }
  1688. declare module BABYLON {
  1689. /**
  1690. * Scalar computation library
  1691. */
  1692. export class Scalar {
  1693. /**
  1694. * Two pi constants convenient for computation.
  1695. */
  1696. static TwoPi: number;
  1697. /**
  1698. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1699. * @param a number
  1700. * @param b number
  1701. * @param epsilon (default = 1.401298E-45)
  1702. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1703. */
  1704. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1705. /**
  1706. * Returns a string : the upper case translation of the number i to hexadecimal.
  1707. * @param i number
  1708. * @returns the upper case translation of the number i to hexadecimal.
  1709. */
  1710. static ToHex(i: number): string;
  1711. /**
  1712. * Returns -1 if value is negative and +1 is value is positive.
  1713. * @param value the value
  1714. * @returns the value itself if it's equal to zero.
  1715. */
  1716. static Sign(value: number): number;
  1717. /**
  1718. * Returns the value itself if it's between min and max.
  1719. * Returns min if the value is lower than min.
  1720. * Returns max if the value is greater than max.
  1721. * @param value the value to clmap
  1722. * @param min the min value to clamp to (default: 0)
  1723. * @param max the max value to clamp to (default: 1)
  1724. * @returns the clamped value
  1725. */
  1726. static Clamp(value: number, min?: number, max?: number): number;
  1727. /**
  1728. * the log2 of value.
  1729. * @param value the value to compute log2 of
  1730. * @returns the log2 of value.
  1731. */
  1732. static Log2(value: number): number;
  1733. /**
  1734. * Loops the value, so that it is never larger than length and never smaller than 0.
  1735. *
  1736. * This is similar to the modulo operator but it works with floating point numbers.
  1737. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1738. * With t = 5 and length = 2.5, the result would be 0.0.
  1739. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1740. * @param value the value
  1741. * @param length the length
  1742. * @returns the looped value
  1743. */
  1744. static Repeat(value: number, length: number): number;
  1745. /**
  1746. * Normalize the value between 0.0 and 1.0 using min and max values
  1747. * @param value value to normalize
  1748. * @param min max to normalize between
  1749. * @param max min to normalize between
  1750. * @returns the normalized value
  1751. */
  1752. static Normalize(value: number, min: number, max: number): number;
  1753. /**
  1754. * Denormalize the value from 0.0 and 1.0 using min and max values
  1755. * @param normalized value to denormalize
  1756. * @param min max to denormalize between
  1757. * @param max min to denormalize between
  1758. * @returns the denormalized value
  1759. */
  1760. static Denormalize(normalized: number, min: number, max: number): number;
  1761. /**
  1762. * Calculates the shortest difference between two given angles given in degrees.
  1763. * @param current current angle in degrees
  1764. * @param target target angle in degrees
  1765. * @returns the delta
  1766. */
  1767. static DeltaAngle(current: number, target: number): number;
  1768. /**
  1769. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1770. * @param tx value
  1771. * @param length length
  1772. * @returns The returned value will move back and forth between 0 and length
  1773. */
  1774. static PingPong(tx: number, length: number): number;
  1775. /**
  1776. * Interpolates between min and max with smoothing at the limits.
  1777. *
  1778. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1779. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1780. * @param from from
  1781. * @param to to
  1782. * @param tx value
  1783. * @returns the smooth stepped value
  1784. */
  1785. static SmoothStep(from: number, to: number, tx: number): number;
  1786. /**
  1787. * Moves a value current towards target.
  1788. *
  1789. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1790. * Negative values of maxDelta pushes the value away from target.
  1791. * @param current current value
  1792. * @param target target value
  1793. * @param maxDelta max distance to move
  1794. * @returns resulting value
  1795. */
  1796. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1797. /**
  1798. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1799. *
  1800. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1801. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1802. * @param current current value
  1803. * @param target target value
  1804. * @param maxDelta max distance to move
  1805. * @returns resulting angle
  1806. */
  1807. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1808. /**
  1809. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1810. * @param start start value
  1811. * @param end target value
  1812. * @param amount amount to lerp between
  1813. * @returns the lerped value
  1814. */
  1815. static Lerp(start: number, end: number, amount: number): number;
  1816. /**
  1817. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1818. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1819. * @param start start value
  1820. * @param end target value
  1821. * @param amount amount to lerp between
  1822. * @returns the lerped value
  1823. */
  1824. static LerpAngle(start: number, end: number, amount: number): number;
  1825. /**
  1826. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1827. * @param a start value
  1828. * @param b target value
  1829. * @param value value between a and b
  1830. * @returns the inverseLerp value
  1831. */
  1832. static InverseLerp(a: number, b: number, value: number): number;
  1833. /**
  1834. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1835. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1836. * @param value1 spline value
  1837. * @param tangent1 spline value
  1838. * @param value2 spline value
  1839. * @param tangent2 spline value
  1840. * @param amount input value
  1841. * @returns hermite result
  1842. */
  1843. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1844. /**
  1845. * Returns a random float number between and min and max values
  1846. * @param min min value of random
  1847. * @param max max value of random
  1848. * @returns random value
  1849. */
  1850. static RandomRange(min: number, max: number): number;
  1851. /**
  1852. * This function returns percentage of a number in a given range.
  1853. *
  1854. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1855. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1856. * @param number to convert to percentage
  1857. * @param min min range
  1858. * @param max max range
  1859. * @returns the percentage
  1860. */
  1861. static RangeToPercent(number: number, min: number, max: number): number;
  1862. /**
  1863. * This function returns number that corresponds to the percentage in a given range.
  1864. *
  1865. * PercentToRange(0.34,0,100) will return 34.
  1866. * @param percent to convert to number
  1867. * @param min min range
  1868. * @param max max range
  1869. * @returns the number
  1870. */
  1871. static PercentToRange(percent: number, min: number, max: number): number;
  1872. /**
  1873. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1874. * @param angle The angle to normalize in radian.
  1875. * @return The converted angle.
  1876. */
  1877. static NormalizeRadians(angle: number): number;
  1878. }
  1879. }
  1880. declare module BABYLON {
  1881. /**
  1882. * Constant used to convert a value to gamma space
  1883. * @ignorenaming
  1884. */
  1885. export const ToGammaSpace: number;
  1886. /**
  1887. * Constant used to convert a value to linear space
  1888. * @ignorenaming
  1889. */
  1890. export const ToLinearSpace = 2.2;
  1891. /**
  1892. * Constant used to define the minimal number value in Babylon.js
  1893. * @ignorenaming
  1894. */
  1895. let Epsilon: number;
  1896. }
  1897. declare module BABYLON {
  1898. /**
  1899. * Class used to represent a viewport on screen
  1900. */
  1901. export class Viewport {
  1902. /** viewport left coordinate */
  1903. x: number;
  1904. /** viewport top coordinate */
  1905. y: number;
  1906. /**viewport width */
  1907. width: number;
  1908. /** viewport height */
  1909. height: number;
  1910. /**
  1911. * Creates a Viewport object located at (x, y) and sized (width, height)
  1912. * @param x defines viewport left coordinate
  1913. * @param y defines viewport top coordinate
  1914. * @param width defines the viewport width
  1915. * @param height defines the viewport height
  1916. */
  1917. constructor(
  1918. /** viewport left coordinate */
  1919. x: number,
  1920. /** viewport top coordinate */
  1921. y: number,
  1922. /**viewport width */
  1923. width: number,
  1924. /** viewport height */
  1925. height: number);
  1926. /**
  1927. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1928. * @param renderWidth defines the rendering width
  1929. * @param renderHeight defines the rendering height
  1930. * @returns a new Viewport
  1931. */
  1932. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1933. /**
  1934. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1935. * @param renderWidth defines the rendering width
  1936. * @param renderHeight defines the rendering height
  1937. * @param ref defines the target viewport
  1938. * @returns the current viewport
  1939. */
  1940. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1941. /**
  1942. * Returns a new Viewport copied from the current one
  1943. * @returns a new Viewport
  1944. */
  1945. clone(): Viewport;
  1946. }
  1947. }
  1948. declare module BABYLON {
  1949. /**
  1950. * Class containing a set of static utilities functions for arrays.
  1951. */
  1952. export class ArrayTools {
  1953. /**
  1954. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1955. * @param size the number of element to construct and put in the array
  1956. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1957. * @returns a new array filled with new objects
  1958. */
  1959. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1960. }
  1961. }
  1962. declare module BABYLON {
  1963. /**
  1964. * Represents a plane by the equation ax + by + cz + d = 0
  1965. */
  1966. export class Plane {
  1967. private static _TmpMatrix;
  1968. /**
  1969. * Normal of the plane (a,b,c)
  1970. */
  1971. normal: Vector3;
  1972. /**
  1973. * d component of the plane
  1974. */
  1975. d: number;
  1976. /**
  1977. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1978. * @param a a component of the plane
  1979. * @param b b component of the plane
  1980. * @param c c component of the plane
  1981. * @param d d component of the plane
  1982. */
  1983. constructor(a: number, b: number, c: number, d: number);
  1984. /**
  1985. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1986. */
  1987. asArray(): number[];
  1988. /**
  1989. * @returns a new plane copied from the current Plane.
  1990. */
  1991. clone(): Plane;
  1992. /**
  1993. * @returns the string "Plane".
  1994. */
  1995. getClassName(): string;
  1996. /**
  1997. * @returns the Plane hash code.
  1998. */
  1999. getHashCode(): number;
  2000. /**
  2001. * Normalize the current Plane in place.
  2002. * @returns the updated Plane.
  2003. */
  2004. normalize(): Plane;
  2005. /**
  2006. * Applies a transformation the plane and returns the result
  2007. * @param transformation the transformation matrix to be applied to the plane
  2008. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2009. */
  2010. transform(transformation: DeepImmutable<Matrix>): Plane;
  2011. /**
  2012. * Compute the dot product between the point and the plane normal
  2013. * @param point point to calculate the dot product with
  2014. * @returns the dot product (float) of the point coordinates and the plane normal.
  2015. */
  2016. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2017. /**
  2018. * Updates the current Plane from the plane defined by the three given points.
  2019. * @param point1 one of the points used to contruct the plane
  2020. * @param point2 one of the points used to contruct the plane
  2021. * @param point3 one of the points used to contruct the plane
  2022. * @returns the updated Plane.
  2023. */
  2024. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2025. /**
  2026. * Checks if the plane is facing a given direction
  2027. * @param direction the direction to check if the plane is facing
  2028. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2029. * @returns True is the vector "direction" is the same side than the plane normal.
  2030. */
  2031. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2032. /**
  2033. * Calculates the distance to a point
  2034. * @param point point to calculate distance to
  2035. * @returns the signed distance (float) from the given point to the Plane.
  2036. */
  2037. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2038. /**
  2039. * Creates a plane from an array
  2040. * @param array the array to create a plane from
  2041. * @returns a new Plane from the given array.
  2042. */
  2043. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2044. /**
  2045. * Creates a plane from three points
  2046. * @param point1 point used to create the plane
  2047. * @param point2 point used to create the plane
  2048. * @param point3 point used to create the plane
  2049. * @returns a new Plane defined by the three given points.
  2050. */
  2051. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2052. /**
  2053. * Creates a plane from an origin point and a normal
  2054. * @param origin origin of the plane to be constructed
  2055. * @param normal normal of the plane to be constructed
  2056. * @returns a new Plane the normal vector to this plane at the given origin point.
  2057. * Note : the vector "normal" is updated because normalized.
  2058. */
  2059. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2060. /**
  2061. * Calculates the distance from a plane and a point
  2062. * @param origin origin of the plane to be constructed
  2063. * @param normal normal of the plane to be constructed
  2064. * @param point point to calculate distance to
  2065. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2066. */
  2067. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2068. }
  2069. }
  2070. declare module BABYLON {
  2071. /** @hidden */
  2072. export class PerformanceConfigurator {
  2073. /** @hidden */
  2074. static MatrixUse64Bits: boolean;
  2075. /** @hidden */
  2076. static MatrixTrackPrecisionChange: boolean;
  2077. /** @hidden */
  2078. static MatrixCurrentType: any;
  2079. /** @hidden */
  2080. static MatrixTrackedMatrices: Array<any> | null;
  2081. /** @hidden */
  2082. static SetMatrixPrecision(use64bits: boolean): void;
  2083. }
  2084. }
  2085. declare module BABYLON {
  2086. /**
  2087. * Class representing a vector containing 2 coordinates
  2088. */
  2089. export class Vector2 {
  2090. /** defines the first coordinate */
  2091. x: number;
  2092. /** defines the second coordinate */
  2093. y: number;
  2094. /**
  2095. * Creates a new Vector2 from the given x and y coordinates
  2096. * @param x defines the first coordinate
  2097. * @param y defines the second coordinate
  2098. */
  2099. constructor(
  2100. /** defines the first coordinate */
  2101. x?: number,
  2102. /** defines the second coordinate */
  2103. y?: number);
  2104. /**
  2105. * Gets a string with the Vector2 coordinates
  2106. * @returns a string with the Vector2 coordinates
  2107. */
  2108. toString(): string;
  2109. /**
  2110. * Gets class name
  2111. * @returns the string "Vector2"
  2112. */
  2113. getClassName(): string;
  2114. /**
  2115. * Gets current vector hash code
  2116. * @returns the Vector2 hash code as a number
  2117. */
  2118. getHashCode(): number;
  2119. /**
  2120. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2121. * @param array defines the source array
  2122. * @param index defines the offset in source array
  2123. * @returns the current Vector2
  2124. */
  2125. toArray(array: FloatArray, index?: number): Vector2;
  2126. /**
  2127. * Update the current vector from an array
  2128. * @param array defines the destination array
  2129. * @param index defines the offset in the destination array
  2130. * @returns the current Vector3
  2131. */
  2132. fromArray(array: FloatArray, index?: number): Vector2;
  2133. /**
  2134. * Copy the current vector to an array
  2135. * @returns a new array with 2 elements: the Vector2 coordinates.
  2136. */
  2137. asArray(): number[];
  2138. /**
  2139. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2140. * @param source defines the source Vector2
  2141. * @returns the current updated Vector2
  2142. */
  2143. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Sets the Vector2 coordinates with the given floats
  2146. * @param x defines the first coordinate
  2147. * @param y defines the second coordinate
  2148. * @returns the current updated Vector2
  2149. */
  2150. copyFromFloats(x: number, y: number): Vector2;
  2151. /**
  2152. * Sets the Vector2 coordinates with the given floats
  2153. * @param x defines the first coordinate
  2154. * @param y defines the second coordinate
  2155. * @returns the current updated Vector2
  2156. */
  2157. set(x: number, y: number): Vector2;
  2158. /**
  2159. * Add another vector with the current one
  2160. * @param otherVector defines the other vector
  2161. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2162. */
  2163. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2164. /**
  2165. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2166. * @param otherVector defines the other vector
  2167. * @param result defines the target vector
  2168. * @returns the unmodified current Vector2
  2169. */
  2170. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2171. /**
  2172. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. addVector3(otherVector: Vector3): Vector2;
  2183. /**
  2184. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2185. * @param otherVector defines the other vector
  2186. * @returns a new Vector2
  2187. */
  2188. subtract(otherVector: Vector2): Vector2;
  2189. /**
  2190. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2191. * @param otherVector defines the other vector
  2192. * @param result defines the target vector
  2193. * @returns the unmodified current Vector2
  2194. */
  2195. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2196. /**
  2197. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2198. * @param otherVector defines the other vector
  2199. * @returns the current updated Vector2
  2200. */
  2201. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2202. /**
  2203. * Multiplies in place the current Vector2 coordinates by the given ones
  2204. * @param otherVector defines the other vector
  2205. * @returns the current updated Vector2
  2206. */
  2207. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2208. /**
  2209. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2210. * @param otherVector defines the other vector
  2211. * @returns a new Vector2
  2212. */
  2213. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2216. * @param otherVector defines the other vector
  2217. * @param result defines the target vector
  2218. * @returns the unmodified current Vector2
  2219. */
  2220. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2223. * @param x defines the first coordinate
  2224. * @param y defines the second coordinate
  2225. * @returns a new Vector2
  2226. */
  2227. multiplyByFloats(x: number, y: number): Vector2;
  2228. /**
  2229. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2230. * @param otherVector defines the other vector
  2231. * @returns a new Vector2
  2232. */
  2233. divide(otherVector: Vector2): Vector2;
  2234. /**
  2235. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2236. * @param otherVector defines the other vector
  2237. * @param result defines the target vector
  2238. * @returns the unmodified current Vector2
  2239. */
  2240. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2241. /**
  2242. * Divides the current Vector2 coordinates by the given ones
  2243. * @param otherVector defines the other vector
  2244. * @returns the current updated Vector2
  2245. */
  2246. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2247. /**
  2248. * Gets a new Vector2 with current Vector2 negated coordinates
  2249. * @returns a new Vector2
  2250. */
  2251. negate(): Vector2;
  2252. /**
  2253. * Negate this vector in place
  2254. * @returns this
  2255. */
  2256. negateInPlace(): Vector2;
  2257. /**
  2258. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2259. * @param result defines the Vector3 object where to store the result
  2260. * @returns the current Vector2
  2261. */
  2262. negateToRef(result: Vector2): Vector2;
  2263. /**
  2264. * Multiply the Vector2 coordinates by scale
  2265. * @param scale defines the scaling factor
  2266. * @returns the current updated Vector2
  2267. */
  2268. scaleInPlace(scale: number): Vector2;
  2269. /**
  2270. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2271. * @param scale defines the scaling factor
  2272. * @returns a new Vector2
  2273. */
  2274. scale(scale: number): Vector2;
  2275. /**
  2276. * Scale the current Vector2 values by a factor to a given Vector2
  2277. * @param scale defines the scale factor
  2278. * @param result defines the Vector2 object where to store the result
  2279. * @returns the unmodified current Vector2
  2280. */
  2281. scaleToRef(scale: number, result: Vector2): Vector2;
  2282. /**
  2283. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2284. * @param scale defines the scale factor
  2285. * @param result defines the Vector2 object where to store the result
  2286. * @returns the unmodified current Vector2
  2287. */
  2288. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2289. /**
  2290. * Gets a boolean if two vectors are equals
  2291. * @param otherVector defines the other vector
  2292. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2293. */
  2294. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2295. /**
  2296. * Gets a boolean if two vectors are equals (using an epsilon value)
  2297. * @param otherVector defines the other vector
  2298. * @param epsilon defines the minimal distance to consider equality
  2299. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2300. */
  2301. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2302. /**
  2303. * Gets a new Vector2 from current Vector2 floored values
  2304. * @returns a new Vector2
  2305. */
  2306. floor(): Vector2;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. fract(): Vector2;
  2312. /**
  2313. * Gets the length of the vector
  2314. * @returns the vector length (float)
  2315. */
  2316. length(): number;
  2317. /**
  2318. * Gets the vector squared length
  2319. * @returns the vector squared length (float)
  2320. */
  2321. lengthSquared(): number;
  2322. /**
  2323. * Normalize the vector
  2324. * @returns the current updated Vector2
  2325. */
  2326. normalize(): Vector2;
  2327. /**
  2328. * Gets a new Vector2 copied from the Vector2
  2329. * @returns a new Vector2
  2330. */
  2331. clone(): Vector2;
  2332. /**
  2333. * Gets a new Vector2(0, 0)
  2334. * @returns a new Vector2
  2335. */
  2336. static Zero(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(1, 1)
  2339. * @returns a new Vector2
  2340. */
  2341. static One(): Vector2;
  2342. /**
  2343. * Gets a new Vector2 set from the given index element of the given array
  2344. * @param array defines the data source
  2345. * @param offset defines the offset in the data source
  2346. * @returns a new Vector2
  2347. */
  2348. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2349. /**
  2350. * Sets "result" from the given index element of the given array
  2351. * @param array defines the data source
  2352. * @param offset defines the offset in the data source
  2353. * @param result defines the target vector
  2354. */
  2355. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2356. /**
  2357. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2358. * @param value1 defines 1st point of control
  2359. * @param value2 defines 2nd point of control
  2360. * @param value3 defines 3rd point of control
  2361. * @param value4 defines 4th point of control
  2362. * @param amount defines the interpolation factor
  2363. * @returns a new Vector2
  2364. */
  2365. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2366. /**
  2367. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2368. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2369. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2370. * @param value defines the value to clamp
  2371. * @param min defines the lower limit
  2372. * @param max defines the upper limit
  2373. * @returns a new Vector2
  2374. */
  2375. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2378. * @param value1 defines the 1st control point
  2379. * @param tangent1 defines the outgoing tangent
  2380. * @param value2 defines the 2nd control point
  2381. * @param tangent2 defines the incoming tangent
  2382. * @param amount defines the interpolation factor
  2383. * @returns a new Vector2
  2384. */
  2385. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2386. /**
  2387. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2388. * @param start defines the start vector
  2389. * @param end defines the end vector
  2390. * @param amount defines the interpolation factor
  2391. * @returns a new Vector2
  2392. */
  2393. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2394. /**
  2395. * Gets the dot product of the vector "left" and the vector "right"
  2396. * @param left defines first vector
  2397. * @param right defines second vector
  2398. * @returns the dot product (float)
  2399. */
  2400. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2401. /**
  2402. * Returns a new Vector2 equal to the normalized given vector
  2403. * @param vector defines the vector to normalize
  2404. * @returns a new Vector2
  2405. */
  2406. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2407. /**
  2408. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2409. * @param left defines 1st vector
  2410. * @param right defines 2nd vector
  2411. * @returns a new Vector2
  2412. */
  2413. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2414. /**
  2415. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2416. * @param left defines 1st vector
  2417. * @param right defines 2nd vector
  2418. * @returns a new Vector2
  2419. */
  2420. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2421. /**
  2422. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2423. * @param vector defines the vector to transform
  2424. * @param transformation defines the matrix to apply
  2425. * @returns a new Vector2
  2426. */
  2427. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2428. /**
  2429. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2430. * @param vector defines the vector to transform
  2431. * @param transformation defines the matrix to apply
  2432. * @param result defines the target vector
  2433. */
  2434. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2435. /**
  2436. * Determines if a given vector is included in a triangle
  2437. * @param p defines the vector to test
  2438. * @param p0 defines 1st triangle point
  2439. * @param p1 defines 2nd triangle point
  2440. * @param p2 defines 3rd triangle point
  2441. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2442. */
  2443. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2444. /**
  2445. * Gets the distance between the vectors "value1" and "value2"
  2446. * @param value1 defines first vector
  2447. * @param value2 defines second vector
  2448. * @returns the distance between vectors
  2449. */
  2450. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2451. /**
  2452. * Returns the squared distance between the vectors "value1" and "value2"
  2453. * @param value1 defines first vector
  2454. * @param value2 defines second vector
  2455. * @returns the squared distance between vectors
  2456. */
  2457. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2458. /**
  2459. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2460. * @param value1 defines first vector
  2461. * @param value2 defines second vector
  2462. * @returns a new Vector2
  2463. */
  2464. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2465. /**
  2466. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2467. * @param p defines the middle point
  2468. * @param segA defines one point of the segment
  2469. * @param segB defines the other point of the segment
  2470. * @returns the shortest distance
  2471. */
  2472. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2473. }
  2474. /**
  2475. * Class used to store (x,y,z) vector representation
  2476. * A Vector3 is the main object used in 3D geometry
  2477. * It can represent etiher the coordinates of a point the space, either a direction
  2478. * Reminder: js uses a left handed forward facing system
  2479. */
  2480. export class Vector3 {
  2481. private static _UpReadOnly;
  2482. private static _ZeroReadOnly;
  2483. /** @hidden */
  2484. _x: number;
  2485. /** @hidden */
  2486. _y: number;
  2487. /** @hidden */
  2488. _z: number;
  2489. /** @hidden */
  2490. _isDirty: boolean;
  2491. /** Gets or sets the x coordinate */
  2492. get x(): number;
  2493. set x(value: number);
  2494. /** Gets or sets the y coordinate */
  2495. get y(): number;
  2496. set y(value: number);
  2497. /** Gets or sets the z coordinate */
  2498. get z(): number;
  2499. set z(value: number);
  2500. /**
  2501. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2502. * @param x defines the first coordinates (on X axis)
  2503. * @param y defines the second coordinates (on Y axis)
  2504. * @param z defines the third coordinates (on Z axis)
  2505. */
  2506. constructor(x?: number, y?: number, z?: number);
  2507. /**
  2508. * Creates a string representation of the Vector3
  2509. * @returns a string with the Vector3 coordinates.
  2510. */
  2511. toString(): string;
  2512. /**
  2513. * Gets the class name
  2514. * @returns the string "Vector3"
  2515. */
  2516. getClassName(): string;
  2517. /**
  2518. * Creates the Vector3 hash code
  2519. * @returns a number which tends to be unique between Vector3 instances
  2520. */
  2521. getHashCode(): number;
  2522. /**
  2523. * Creates an array containing three elements : the coordinates of the Vector3
  2524. * @returns a new array of numbers
  2525. */
  2526. asArray(): number[];
  2527. /**
  2528. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2529. * @param array defines the destination array
  2530. * @param index defines the offset in the destination array
  2531. * @returns the current Vector3
  2532. */
  2533. toArray(array: FloatArray, index?: number): Vector3;
  2534. /**
  2535. * Update the current vector from an array
  2536. * @param array defines the destination array
  2537. * @param index defines the offset in the destination array
  2538. * @returns the current Vector3
  2539. */
  2540. fromArray(array: FloatArray, index?: number): Vector3;
  2541. /**
  2542. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2543. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2544. */
  2545. toQuaternion(): Quaternion;
  2546. /**
  2547. * Adds the given vector to the current Vector3
  2548. * @param otherVector defines the second operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2552. /**
  2553. * Adds the given coordinates to the current Vector3
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the current updated Vector3
  2558. */
  2559. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2562. * @param otherVector defines the second operand
  2563. * @returns the resulting Vector3
  2564. */
  2565. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2566. /**
  2567. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2568. * @param otherVector defines the second operand
  2569. * @param result defines the Vector3 object where to store the result
  2570. * @returns the current Vector3
  2571. */
  2572. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2573. /**
  2574. * Subtract the given vector from the current Vector3
  2575. * @param otherVector defines the second operand
  2576. * @returns the current updated Vector3
  2577. */
  2578. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2579. /**
  2580. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2581. * @param otherVector defines the second operand
  2582. * @returns the resulting Vector3
  2583. */
  2584. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2585. /**
  2586. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2587. * @param otherVector defines the second operand
  2588. * @param result defines the Vector3 object where to store the result
  2589. * @returns the current Vector3
  2590. */
  2591. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2592. /**
  2593. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2594. * @param x defines the x coordinate of the operand
  2595. * @param y defines the y coordinate of the operand
  2596. * @param z defines the z coordinate of the operand
  2597. * @returns the resulting Vector3
  2598. */
  2599. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2600. /**
  2601. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2602. * @param x defines the x coordinate of the operand
  2603. * @param y defines the y coordinate of the operand
  2604. * @param z defines the z coordinate of the operand
  2605. * @param result defines the Vector3 object where to store the result
  2606. * @returns the current Vector3
  2607. */
  2608. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2609. /**
  2610. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2611. * @returns a new Vector3
  2612. */
  2613. negate(): Vector3;
  2614. /**
  2615. * Negate this vector in place
  2616. * @returns this
  2617. */
  2618. negateInPlace(): Vector3;
  2619. /**
  2620. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2621. * @param result defines the Vector3 object where to store the result
  2622. * @returns the current Vector3
  2623. */
  2624. negateToRef(result: Vector3): Vector3;
  2625. /**
  2626. * Multiplies the Vector3 coordinates by the float "scale"
  2627. * @param scale defines the multiplier factor
  2628. * @returns the current updated Vector3
  2629. */
  2630. scaleInPlace(scale: number): Vector3;
  2631. /**
  2632. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2633. * @param scale defines the multiplier factor
  2634. * @returns a new Vector3
  2635. */
  2636. scale(scale: number): Vector3;
  2637. /**
  2638. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2639. * @param scale defines the multiplier factor
  2640. * @param result defines the Vector3 object where to store the result
  2641. * @returns the current Vector3
  2642. */
  2643. scaleToRef(scale: number, result: Vector3): Vector3;
  2644. /**
  2645. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2646. * @param scale defines the scale factor
  2647. * @param result defines the Vector3 object where to store the result
  2648. * @returns the unmodified current Vector3
  2649. */
  2650. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2651. /**
  2652. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2653. * @param origin defines the origin of the projection ray
  2654. * @param plane defines the plane to project to
  2655. * @returns the projected vector3
  2656. */
  2657. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2658. /**
  2659. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2660. * @param origin defines the origin of the projection ray
  2661. * @param plane defines the plane to project to
  2662. * @param result defines the Vector3 where to store the result
  2663. */
  2664. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2665. /**
  2666. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2667. * @param otherVector defines the second operand
  2668. * @returns true if both vectors are equals
  2669. */
  2670. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2671. /**
  2672. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2673. * @param otherVector defines the second operand
  2674. * @param epsilon defines the minimal distance to define values as equals
  2675. * @returns true if both vectors are distant less than epsilon
  2676. */
  2677. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2678. /**
  2679. * Returns true if the current Vector3 coordinates equals the given floats
  2680. * @param x defines the x coordinate of the operand
  2681. * @param y defines the y coordinate of the operand
  2682. * @param z defines the z coordinate of the operand
  2683. * @returns true if both vectors are equals
  2684. */
  2685. equalsToFloats(x: number, y: number, z: number): boolean;
  2686. /**
  2687. * Multiplies the current Vector3 coordinates by the given ones
  2688. * @param otherVector defines the second operand
  2689. * @returns the current updated Vector3
  2690. */
  2691. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2692. /**
  2693. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2694. * @param otherVector defines the second operand
  2695. * @returns the new Vector3
  2696. */
  2697. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2698. /**
  2699. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2700. * @param otherVector defines the second operand
  2701. * @param result defines the Vector3 object where to store the result
  2702. * @returns the current Vector3
  2703. */
  2704. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2705. /**
  2706. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2707. * @param x defines the x coordinate of the operand
  2708. * @param y defines the y coordinate of the operand
  2709. * @param z defines the z coordinate of the operand
  2710. * @returns the new Vector3
  2711. */
  2712. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2713. /**
  2714. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2715. * @param otherVector defines the second operand
  2716. * @returns the new Vector3
  2717. */
  2718. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2719. /**
  2720. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2721. * @param otherVector defines the second operand
  2722. * @param result defines the Vector3 object where to store the result
  2723. * @returns the current Vector3
  2724. */
  2725. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2726. /**
  2727. * Divides the current Vector3 coordinates by the given ones.
  2728. * @param otherVector defines the second operand
  2729. * @returns the current updated Vector3
  2730. */
  2731. divideInPlace(otherVector: Vector3): Vector3;
  2732. /**
  2733. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2734. * @param other defines the second operand
  2735. * @returns the current updated Vector3
  2736. */
  2737. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2738. /**
  2739. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2740. * @param other defines the second operand
  2741. * @returns the current updated Vector3
  2742. */
  2743. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2744. /**
  2745. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2746. * @param x defines the x coordinate of the operand
  2747. * @param y defines the y coordinate of the operand
  2748. * @param z defines the z coordinate of the operand
  2749. * @returns the current updated Vector3
  2750. */
  2751. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2752. /**
  2753. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2754. * @param x defines the x coordinate of the operand
  2755. * @param y defines the y coordinate of the operand
  2756. * @param z defines the z coordinate of the operand
  2757. * @returns the current updated Vector3
  2758. */
  2759. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2760. /**
  2761. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2762. * Check if is non uniform within a certain amount of decimal places to account for this
  2763. * @param epsilon the amount the values can differ
  2764. * @returns if the the vector is non uniform to a certain number of decimal places
  2765. */
  2766. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2767. /**
  2768. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2769. */
  2770. get isNonUniform(): boolean;
  2771. /**
  2772. * Gets a new Vector3 from current Vector3 floored values
  2773. * @returns a new Vector3
  2774. */
  2775. floor(): Vector3;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. fract(): Vector3;
  2781. /**
  2782. * Gets the length of the Vector3
  2783. * @returns the length of the Vector3
  2784. */
  2785. length(): number;
  2786. /**
  2787. * Gets the squared length of the Vector3
  2788. * @returns squared length of the Vector3
  2789. */
  2790. lengthSquared(): number;
  2791. /**
  2792. * Normalize the current Vector3.
  2793. * Please note that this is an in place operation.
  2794. * @returns the current updated Vector3
  2795. */
  2796. normalize(): Vector3;
  2797. /**
  2798. * Reorders the x y z properties of the vector in place
  2799. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2800. * @returns the current updated vector
  2801. */
  2802. reorderInPlace(order: string): this;
  2803. /**
  2804. * Rotates the vector around 0,0,0 by a quaternion
  2805. * @param quaternion the rotation quaternion
  2806. * @param result vector to store the result
  2807. * @returns the resulting vector
  2808. */
  2809. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2810. /**
  2811. * Rotates a vector around a given point
  2812. * @param quaternion the rotation quaternion
  2813. * @param point the point to rotate around
  2814. * @param result vector to store the result
  2815. * @returns the resulting vector
  2816. */
  2817. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2818. /**
  2819. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2820. * The cross product is then orthogonal to both current and "other"
  2821. * @param other defines the right operand
  2822. * @returns the cross product
  2823. */
  2824. cross(other: Vector3): Vector3;
  2825. /**
  2826. * Normalize the current Vector3 with the given input length.
  2827. * Please note that this is an in place operation.
  2828. * @param len the length of the vector
  2829. * @returns the current updated Vector3
  2830. */
  2831. normalizeFromLength(len: number): Vector3;
  2832. /**
  2833. * Normalize the current Vector3 to a new vector
  2834. * @returns the new Vector3
  2835. */
  2836. normalizeToNew(): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to the reference
  2839. * @param reference define the Vector3 to update
  2840. * @returns the updated Vector3
  2841. */
  2842. normalizeToRef(reference: Vector3): Vector3;
  2843. /**
  2844. * Creates a new Vector3 copied from the current Vector3
  2845. * @returns the new Vector3
  2846. */
  2847. clone(): Vector3;
  2848. /**
  2849. * Copies the given vector coordinates to the current Vector3 ones
  2850. * @param source defines the source Vector3
  2851. * @returns the current updated Vector3
  2852. */
  2853. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2854. /**
  2855. * Copies the given floats to the current Vector3 coordinates
  2856. * @param x defines the x coordinate of the operand
  2857. * @param y defines the y coordinate of the operand
  2858. * @param z defines the z coordinate of the operand
  2859. * @returns the current updated Vector3
  2860. */
  2861. copyFromFloats(x: number, y: number, z: number): Vector3;
  2862. /**
  2863. * Copies the given floats to the current Vector3 coordinates
  2864. * @param x defines the x coordinate of the operand
  2865. * @param y defines the y coordinate of the operand
  2866. * @param z defines the z coordinate of the operand
  2867. * @returns the current updated Vector3
  2868. */
  2869. set(x: number, y: number, z: number): Vector3;
  2870. /**
  2871. * Copies the given float to the current Vector3 coordinates
  2872. * @param v defines the x, y and z coordinates of the operand
  2873. * @returns the current updated Vector3
  2874. */
  2875. setAll(v: number): Vector3;
  2876. /**
  2877. * Get the clip factor between two vectors
  2878. * @param vector0 defines the first operand
  2879. * @param vector1 defines the second operand
  2880. * @param axis defines the axis to use
  2881. * @param size defines the size along the axis
  2882. * @returns the clip factor
  2883. */
  2884. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2885. /**
  2886. * Get angle between two vectors
  2887. * @param vector0 angle between vector0 and vector1
  2888. * @param vector1 angle between vector0 and vector1
  2889. * @param normal direction of the normal
  2890. * @return the angle between vector0 and vector1
  2891. */
  2892. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2893. /**
  2894. * Returns a new Vector3 set from the index "offset" of the given array
  2895. * @param array defines the source array
  2896. * @param offset defines the offset in the source array
  2897. * @returns the new Vector3
  2898. */
  2899. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2900. /**
  2901. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2902. * @param array defines the source array
  2903. * @param offset defines the offset in the source array
  2904. * @returns the new Vector3
  2905. * @deprecated Please use FromArray instead.
  2906. */
  2907. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2908. /**
  2909. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2910. * @param array defines the source array
  2911. * @param offset defines the offset in the source array
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2915. /**
  2916. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2917. * @param array defines the source array
  2918. * @param offset defines the offset in the source array
  2919. * @param result defines the Vector3 where to store the result
  2920. * @deprecated Please use FromArrayToRef instead.
  2921. */
  2922. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2923. /**
  2924. * Sets the given vector "result" with the given floats.
  2925. * @param x defines the x coordinate of the source
  2926. * @param y defines the y coordinate of the source
  2927. * @param z defines the z coordinate of the source
  2928. * @param result defines the Vector3 where to store the result
  2929. */
  2930. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2931. /**
  2932. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2933. * @returns a new empty Vector3
  2934. */
  2935. static Zero(): Vector3;
  2936. /**
  2937. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2938. * @returns a new unit Vector3
  2939. */
  2940. static One(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2943. * @returns a new up Vector3
  2944. */
  2945. static Up(): Vector3;
  2946. /**
  2947. * Gets a up Vector3 that must not be updated
  2948. */
  2949. static get UpReadOnly(): DeepImmutable<Vector3>;
  2950. /**
  2951. * Gets a zero Vector3 that must not be updated
  2952. */
  2953. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2954. /**
  2955. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2956. * @returns a new down Vector3
  2957. */
  2958. static Down(): Vector3;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2961. * @param rightHandedSystem is the scene right-handed (negative z)
  2962. * @returns a new forward Vector3
  2963. */
  2964. static Forward(rightHandedSystem?: boolean): Vector3;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2967. * @param rightHandedSystem is the scene right-handed (negative-z)
  2968. * @returns a new forward Vector3
  2969. */
  2970. static Backward(rightHandedSystem?: boolean): Vector3;
  2971. /**
  2972. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2973. * @returns a new right Vector3
  2974. */
  2975. static Right(): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2978. * @returns a new left Vector3
  2979. */
  2980. static Left(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2983. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2984. * @param vector defines the Vector3 to transform
  2985. * @param transformation defines the transformation matrix
  2986. * @returns the transformed Vector3
  2987. */
  2988. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2989. /**
  2990. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2991. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2992. * @param vector defines the Vector3 to transform
  2993. * @param transformation defines the transformation matrix
  2994. * @param result defines the Vector3 where to store the result
  2995. */
  2996. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2997. /**
  2998. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2999. * This method computes tranformed coordinates only, not transformed direction vectors
  3000. * @param x define the x coordinate of the source vector
  3001. * @param y define the y coordinate of the source vector
  3002. * @param z define the z coordinate of the source vector
  3003. * @param transformation defines the transformation matrix
  3004. * @param result defines the Vector3 where to store the result
  3005. */
  3006. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3007. /**
  3008. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3009. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3010. * @param vector defines the Vector3 to transform
  3011. * @param transformation defines the transformation matrix
  3012. * @returns the new Vector3
  3013. */
  3014. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3015. /**
  3016. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3017. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3018. * @param vector defines the Vector3 to transform
  3019. * @param transformation defines the transformation matrix
  3020. * @param result defines the Vector3 where to store the result
  3021. */
  3022. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3023. /**
  3024. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3025. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3026. * @param x define the x coordinate of the source vector
  3027. * @param y define the y coordinate of the source vector
  3028. * @param z define the z coordinate of the source vector
  3029. * @param transformation defines the transformation matrix
  3030. * @param result defines the Vector3 where to store the result
  3031. */
  3032. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3033. /**
  3034. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3035. * @param value1 defines the first control point
  3036. * @param value2 defines the second control point
  3037. * @param value3 defines the third control point
  3038. * @param value4 defines the fourth control point
  3039. * @param amount defines the amount on the spline to use
  3040. * @returns the new Vector3
  3041. */
  3042. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3043. /**
  3044. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3045. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3046. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3047. * @param value defines the current value
  3048. * @param min defines the lower range value
  3049. * @param max defines the upper range value
  3050. * @returns the new Vector3
  3051. */
  3052. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3053. /**
  3054. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3055. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3056. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3057. * @param value defines the current value
  3058. * @param min defines the lower range value
  3059. * @param max defines the upper range value
  3060. * @param result defines the Vector3 where to store the result
  3061. */
  3062. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3063. /**
  3064. * Checks if a given vector is inside a specific range
  3065. * @param v defines the vector to test
  3066. * @param min defines the minimum range
  3067. * @param max defines the maximum range
  3068. */
  3069. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3070. /**
  3071. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3072. * @param value1 defines the first control point
  3073. * @param tangent1 defines the first tangent vector
  3074. * @param value2 defines the second control point
  3075. * @param tangent2 defines the second tangent vector
  3076. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3077. * @returns the new Vector3
  3078. */
  3079. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3080. /**
  3081. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3082. * @param start defines the start value
  3083. * @param end defines the end value
  3084. * @param amount max defines amount between both (between 0 and 1)
  3085. * @returns the new Vector3
  3086. */
  3087. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3088. /**
  3089. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3090. * @param start defines the start value
  3091. * @param end defines the end value
  3092. * @param amount max defines amount between both (between 0 and 1)
  3093. * @param result defines the Vector3 where to store the result
  3094. */
  3095. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3096. /**
  3097. * Returns the dot product (float) between the vectors "left" and "right"
  3098. * @param left defines the left operand
  3099. * @param right defines the right operand
  3100. * @returns the dot product
  3101. */
  3102. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3103. /**
  3104. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3105. * The cross product is then orthogonal to both "left" and "right"
  3106. * @param left defines the left operand
  3107. * @param right defines the right operand
  3108. * @returns the cross product
  3109. */
  3110. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3111. /**
  3112. * Sets the given vector "result" with the cross product of "left" and "right"
  3113. * The cross product is then orthogonal to both "left" and "right"
  3114. * @param left defines the left operand
  3115. * @param right defines the right operand
  3116. * @param result defines the Vector3 where to store the result
  3117. */
  3118. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3119. /**
  3120. * Returns a new Vector3 as the normalization of the given vector
  3121. * @param vector defines the Vector3 to normalize
  3122. * @returns the new Vector3
  3123. */
  3124. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3125. /**
  3126. * Sets the given vector "result" with the normalization of the given first vector
  3127. * @param vector defines the Vector3 to normalize
  3128. * @param result defines the Vector3 where to store the result
  3129. */
  3130. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3131. /**
  3132. * Project a Vector3 onto screen space
  3133. * @param vector defines the Vector3 to project
  3134. * @param world defines the world matrix to use
  3135. * @param transform defines the transform (view x projection) matrix to use
  3136. * @param viewport defines the screen viewport to use
  3137. * @returns the new Vector3
  3138. */
  3139. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3140. /**
  3141. * Project a Vector3 onto screen space to reference
  3142. * @param vector defines the Vector3 to project
  3143. * @param world defines the world matrix to use
  3144. * @param transform defines the transform (view x projection) matrix to use
  3145. * @param viewport defines the screen viewport to use
  3146. * @param result the vector in which the screen space will be stored
  3147. * @returns the new Vector3
  3148. */
  3149. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3150. /** @hidden */
  3151. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3152. /**
  3153. * Unproject from screen space to object space
  3154. * @param source defines the screen space Vector3 to use
  3155. * @param viewportWidth defines the current width of the viewport
  3156. * @param viewportHeight defines the current height of the viewport
  3157. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3158. * @param transform defines the transform (view x projection) matrix to use
  3159. * @returns the new Vector3
  3160. */
  3161. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3162. /**
  3163. * Unproject from screen space to object space
  3164. * @param source defines the screen space Vector3 to use
  3165. * @param viewportWidth defines the current width of the viewport
  3166. * @param viewportHeight defines the current height of the viewport
  3167. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3168. * @param view defines the view matrix to use
  3169. * @param projection defines the projection matrix to use
  3170. * @returns the new Vector3
  3171. */
  3172. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3173. /**
  3174. * Unproject from screen space to object space
  3175. * @param source defines the screen space Vector3 to use
  3176. * @param viewportWidth defines the current width of the viewport
  3177. * @param viewportHeight defines the current height of the viewport
  3178. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3179. * @param view defines the view matrix to use
  3180. * @param projection defines the projection matrix to use
  3181. * @param result defines the Vector3 where to store the result
  3182. */
  3183. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3184. /**
  3185. * Unproject from screen space to object space
  3186. * @param sourceX defines the screen space x coordinate to use
  3187. * @param sourceY defines the screen space y coordinate to use
  3188. * @param sourceZ defines the screen space z coordinate to use
  3189. * @param viewportWidth defines the current width of the viewport
  3190. * @param viewportHeight defines the current height of the viewport
  3191. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3192. * @param view defines the view matrix to use
  3193. * @param projection defines the projection matrix to use
  3194. * @param result defines the Vector3 where to store the result
  3195. */
  3196. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3197. /**
  3198. * Gets the minimal coordinate values between two Vector3
  3199. * @param left defines the first operand
  3200. * @param right defines the second operand
  3201. * @returns the new Vector3
  3202. */
  3203. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3204. /**
  3205. * Gets the maximal coordinate values between two Vector3
  3206. * @param left defines the first operand
  3207. * @param right defines the second operand
  3208. * @returns the new Vector3
  3209. */
  3210. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3211. /**
  3212. * Returns the distance between the vectors "value1" and "value2"
  3213. * @param value1 defines the first operand
  3214. * @param value2 defines the second operand
  3215. * @returns the distance
  3216. */
  3217. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3218. /**
  3219. * Returns the squared distance between the vectors "value1" and "value2"
  3220. * @param value1 defines the first operand
  3221. * @param value2 defines the second operand
  3222. * @returns the squared distance
  3223. */
  3224. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3225. /**
  3226. * Returns a new Vector3 located at the center between "value1" and "value2"
  3227. * @param value1 defines the first operand
  3228. * @param value2 defines the second operand
  3229. * @returns the new Vector3
  3230. */
  3231. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3232. /**
  3233. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3234. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3235. * to something in order to rotate it from its local system to the given target system
  3236. * Note: axis1, axis2 and axis3 are normalized during this operation
  3237. * @param axis1 defines the first axis
  3238. * @param axis2 defines the second axis
  3239. * @param axis3 defines the third axis
  3240. * @returns a new Vector3
  3241. */
  3242. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3243. /**
  3244. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3245. * @param axis1 defines the first axis
  3246. * @param axis2 defines the second axis
  3247. * @param axis3 defines the third axis
  3248. * @param ref defines the Vector3 where to store the result
  3249. */
  3250. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3251. }
  3252. /**
  3253. * Vector4 class created for EulerAngle class conversion to Quaternion
  3254. */
  3255. export class Vector4 {
  3256. /** x value of the vector */
  3257. x: number;
  3258. /** y value of the vector */
  3259. y: number;
  3260. /** z value of the vector */
  3261. z: number;
  3262. /** w value of the vector */
  3263. w: number;
  3264. /**
  3265. * Creates a Vector4 object from the given floats.
  3266. * @param x x value of the vector
  3267. * @param y y value of the vector
  3268. * @param z z value of the vector
  3269. * @param w w value of the vector
  3270. */
  3271. constructor(
  3272. /** x value of the vector */
  3273. x: number,
  3274. /** y value of the vector */
  3275. y: number,
  3276. /** z value of the vector */
  3277. z: number,
  3278. /** w value of the vector */
  3279. w: number);
  3280. /**
  3281. * Returns the string with the Vector4 coordinates.
  3282. * @returns a string containing all the vector values
  3283. */
  3284. toString(): string;
  3285. /**
  3286. * Returns the string "Vector4".
  3287. * @returns "Vector4"
  3288. */
  3289. getClassName(): string;
  3290. /**
  3291. * Returns the Vector4 hash code.
  3292. * @returns a unique hash code
  3293. */
  3294. getHashCode(): number;
  3295. /**
  3296. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3297. * @returns the resulting array
  3298. */
  3299. asArray(): number[];
  3300. /**
  3301. * Populates the given array from the given index with the Vector4 coordinates.
  3302. * @param array array to populate
  3303. * @param index index of the array to start at (default: 0)
  3304. * @returns the Vector4.
  3305. */
  3306. toArray(array: FloatArray, index?: number): Vector4;
  3307. /**
  3308. * Update the current vector from an array
  3309. * @param array defines the destination array
  3310. * @param index defines the offset in the destination array
  3311. * @returns the current Vector3
  3312. */
  3313. fromArray(array: FloatArray, index?: number): Vector4;
  3314. /**
  3315. * Adds the given vector to the current Vector4.
  3316. * @param otherVector the vector to add
  3317. * @returns the updated Vector4.
  3318. */
  3319. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3320. /**
  3321. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3322. * @param otherVector the vector to add
  3323. * @returns the resulting vector
  3324. */
  3325. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3326. /**
  3327. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3328. * @param otherVector the vector to add
  3329. * @param result the vector to store the result
  3330. * @returns the current Vector4.
  3331. */
  3332. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3333. /**
  3334. * Subtract in place the given vector from the current Vector4.
  3335. * @param otherVector the vector to subtract
  3336. * @returns the updated Vector4.
  3337. */
  3338. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3339. /**
  3340. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3341. * @param otherVector the vector to add
  3342. * @returns the new vector with the result
  3343. */
  3344. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3345. /**
  3346. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3347. * @param otherVector the vector to subtract
  3348. * @param result the vector to store the result
  3349. * @returns the current Vector4.
  3350. */
  3351. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3352. /**
  3353. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3354. */
  3355. /**
  3356. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3357. * @param x value to subtract
  3358. * @param y value to subtract
  3359. * @param z value to subtract
  3360. * @param w value to subtract
  3361. * @returns new vector containing the result
  3362. */
  3363. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3364. /**
  3365. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3366. * @param x value to subtract
  3367. * @param y value to subtract
  3368. * @param z value to subtract
  3369. * @param w value to subtract
  3370. * @param result the vector to store the result in
  3371. * @returns the current Vector4.
  3372. */
  3373. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3374. /**
  3375. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3376. * @returns a new vector with the negated values
  3377. */
  3378. negate(): Vector4;
  3379. /**
  3380. * Negate this vector in place
  3381. * @returns this
  3382. */
  3383. negateInPlace(): Vector4;
  3384. /**
  3385. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3386. * @param result defines the Vector3 object where to store the result
  3387. * @returns the current Vector4
  3388. */
  3389. negateToRef(result: Vector4): Vector4;
  3390. /**
  3391. * Multiplies the current Vector4 coordinates by scale (float).
  3392. * @param scale the number to scale with
  3393. * @returns the updated Vector4.
  3394. */
  3395. scaleInPlace(scale: number): Vector4;
  3396. /**
  3397. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3398. * @param scale the number to scale with
  3399. * @returns a new vector with the result
  3400. */
  3401. scale(scale: number): Vector4;
  3402. /**
  3403. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3404. * @param scale the number to scale with
  3405. * @param result a vector to store the result in
  3406. * @returns the current Vector4.
  3407. */
  3408. scaleToRef(scale: number, result: Vector4): Vector4;
  3409. /**
  3410. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3411. * @param scale defines the scale factor
  3412. * @param result defines the Vector4 object where to store the result
  3413. * @returns the unmodified current Vector4
  3414. */
  3415. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3416. /**
  3417. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3418. * @param otherVector the vector to compare against
  3419. * @returns true if they are equal
  3420. */
  3421. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3422. /**
  3423. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3424. * @param otherVector vector to compare against
  3425. * @param epsilon (Default: very small number)
  3426. * @returns true if they are equal
  3427. */
  3428. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3429. /**
  3430. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3431. * @param x x value to compare against
  3432. * @param y y value to compare against
  3433. * @param z z value to compare against
  3434. * @param w w value to compare against
  3435. * @returns true if equal
  3436. */
  3437. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3438. /**
  3439. * Multiplies in place the current Vector4 by the given one.
  3440. * @param otherVector vector to multiple with
  3441. * @returns the updated Vector4.
  3442. */
  3443. multiplyInPlace(otherVector: Vector4): Vector4;
  3444. /**
  3445. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3446. * @param otherVector vector to multiple with
  3447. * @returns resulting new vector
  3448. */
  3449. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3452. * @param otherVector vector to multiple with
  3453. * @param result vector to store the result
  3454. * @returns the current Vector4.
  3455. */
  3456. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3457. /**
  3458. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3459. * @param x x value multiply with
  3460. * @param y y value multiply with
  3461. * @param z z value multiply with
  3462. * @param w w value multiply with
  3463. * @returns resulting new vector
  3464. */
  3465. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3466. /**
  3467. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3468. * @param otherVector vector to devide with
  3469. * @returns resulting new vector
  3470. */
  3471. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3472. /**
  3473. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3474. * @param otherVector vector to devide with
  3475. * @param result vector to store the result
  3476. * @returns the current Vector4.
  3477. */
  3478. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3479. /**
  3480. * Divides the current Vector3 coordinates by the given ones.
  3481. * @param otherVector vector to devide with
  3482. * @returns the updated Vector3.
  3483. */
  3484. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3485. /**
  3486. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3487. * @param other defines the second operand
  3488. * @returns the current updated Vector4
  3489. */
  3490. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3491. /**
  3492. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3493. * @param other defines the second operand
  3494. * @returns the current updated Vector4
  3495. */
  3496. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector4 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. floor(): Vector4;
  3502. /**
  3503. * Gets a new Vector4 from current Vector3 floored values
  3504. * @returns a new Vector4
  3505. */
  3506. fract(): Vector4;
  3507. /**
  3508. * Returns the Vector4 length (float).
  3509. * @returns the length
  3510. */
  3511. length(): number;
  3512. /**
  3513. * Returns the Vector4 squared length (float).
  3514. * @returns the length squared
  3515. */
  3516. lengthSquared(): number;
  3517. /**
  3518. * Normalizes in place the Vector4.
  3519. * @returns the updated Vector4.
  3520. */
  3521. normalize(): Vector4;
  3522. /**
  3523. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3524. * @returns this converted to a new vector3
  3525. */
  3526. toVector3(): Vector3;
  3527. /**
  3528. * Returns a new Vector4 copied from the current one.
  3529. * @returns the new cloned vector
  3530. */
  3531. clone(): Vector4;
  3532. /**
  3533. * Updates the current Vector4 with the given one coordinates.
  3534. * @param source the source vector to copy from
  3535. * @returns the updated Vector4.
  3536. */
  3537. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3538. /**
  3539. * Updates the current Vector4 coordinates with the given floats.
  3540. * @param x float to copy from
  3541. * @param y float to copy from
  3542. * @param z float to copy from
  3543. * @param w float to copy from
  3544. * @returns the updated Vector4.
  3545. */
  3546. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3547. /**
  3548. * Updates the current Vector4 coordinates with the given floats.
  3549. * @param x float to set from
  3550. * @param y float to set from
  3551. * @param z float to set from
  3552. * @param w float to set from
  3553. * @returns the updated Vector4.
  3554. */
  3555. set(x: number, y: number, z: number, w: number): Vector4;
  3556. /**
  3557. * Copies the given float to the current Vector3 coordinates
  3558. * @param v defines the x, y, z and w coordinates of the operand
  3559. * @returns the current updated Vector3
  3560. */
  3561. setAll(v: number): Vector4;
  3562. /**
  3563. * Returns a new Vector4 set from the starting index of the given array.
  3564. * @param array the array to pull values from
  3565. * @param offset the offset into the array to start at
  3566. * @returns the new vector
  3567. */
  3568. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3569. /**
  3570. * Updates the given vector "result" from the starting index of the given array.
  3571. * @param array the array to pull values from
  3572. * @param offset the offset into the array to start at
  3573. * @param result the vector to store the result in
  3574. */
  3575. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3576. /**
  3577. * Updates the given vector "result" from the starting index of the given Float32Array.
  3578. * @param array the array to pull values from
  3579. * @param offset the offset into the array to start at
  3580. * @param result the vector to store the result in
  3581. */
  3582. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3583. /**
  3584. * Updates the given vector "result" coordinates from the given floats.
  3585. * @param x float to set from
  3586. * @param y float to set from
  3587. * @param z float to set from
  3588. * @param w float to set from
  3589. * @param result the vector to the floats in
  3590. */
  3591. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3592. /**
  3593. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3594. * @returns the new vector
  3595. */
  3596. static Zero(): Vector4;
  3597. /**
  3598. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3599. * @returns the new vector
  3600. */
  3601. static One(): Vector4;
  3602. /**
  3603. * Returns a new normalized Vector4 from the given one.
  3604. * @param vector the vector to normalize
  3605. * @returns the vector
  3606. */
  3607. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Updates the given vector "result" from the normalization of the given one.
  3610. * @param vector the vector to normalize
  3611. * @param result the vector to store the result in
  3612. */
  3613. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3614. /**
  3615. * Returns a vector with the minimum values from the left and right vectors
  3616. * @param left left vector to minimize
  3617. * @param right right vector to minimize
  3618. * @returns a new vector with the minimum of the left and right vector values
  3619. */
  3620. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3621. /**
  3622. * Returns a vector with the maximum values from the left and right vectors
  3623. * @param left left vector to maximize
  3624. * @param right right vector to maximize
  3625. * @returns a new vector with the maximum of the left and right vector values
  3626. */
  3627. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3628. /**
  3629. * Returns the distance (float) between the vectors "value1" and "value2".
  3630. * @param value1 value to calulate the distance between
  3631. * @param value2 value to calulate the distance between
  3632. * @return the distance between the two vectors
  3633. */
  3634. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3635. /**
  3636. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3637. * @param value1 value to calulate the distance between
  3638. * @param value2 value to calulate the distance between
  3639. * @return the distance between the two vectors squared
  3640. */
  3641. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3642. /**
  3643. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3644. * @param value1 value to calulate the center between
  3645. * @param value2 value to calulate the center between
  3646. * @return the center between the two vectors
  3647. */
  3648. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3649. /**
  3650. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3651. * This methods computes transformed normalized direction vectors only.
  3652. * @param vector the vector to transform
  3653. * @param transformation the transformation matrix to apply
  3654. * @returns the new vector
  3655. */
  3656. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3657. /**
  3658. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3659. * This methods computes transformed normalized direction vectors only.
  3660. * @param vector the vector to transform
  3661. * @param transformation the transformation matrix to apply
  3662. * @param result the vector to store the result in
  3663. */
  3664. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3665. /**
  3666. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3667. * This methods computes transformed normalized direction vectors only.
  3668. * @param x value to transform
  3669. * @param y value to transform
  3670. * @param z value to transform
  3671. * @param w value to transform
  3672. * @param transformation the transformation matrix to apply
  3673. * @param result the vector to store the results in
  3674. */
  3675. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3676. /**
  3677. * Creates a new Vector4 from a Vector3
  3678. * @param source defines the source data
  3679. * @param w defines the 4th component (default is 0)
  3680. * @returns a new Vector4
  3681. */
  3682. static FromVector3(source: Vector3, w?: number): Vector4;
  3683. }
  3684. /**
  3685. * Class used to store quaternion data
  3686. * @see https://en.wikipedia.org/wiki/Quaternion
  3687. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3688. */
  3689. export class Quaternion {
  3690. /** @hidden */
  3691. _x: number;
  3692. /** @hidden */
  3693. _y: number;
  3694. /** @hidden */
  3695. _z: number;
  3696. /** @hidden */
  3697. _w: number;
  3698. /** @hidden */
  3699. _isDirty: boolean;
  3700. /** Gets or sets the x coordinate */
  3701. get x(): number;
  3702. set x(value: number);
  3703. /** Gets or sets the y coordinate */
  3704. get y(): number;
  3705. set y(value: number);
  3706. /** Gets or sets the z coordinate */
  3707. get z(): number;
  3708. set z(value: number);
  3709. /** Gets or sets the w coordinate */
  3710. get w(): number;
  3711. set w(value: number);
  3712. /**
  3713. * Creates a new Quaternion from the given floats
  3714. * @param x defines the first component (0 by default)
  3715. * @param y defines the second component (0 by default)
  3716. * @param z defines the third component (0 by default)
  3717. * @param w defines the fourth component (1.0 by default)
  3718. */
  3719. constructor(x?: number, y?: number, z?: number, w?: number);
  3720. /**
  3721. * Gets a string representation for the current quaternion
  3722. * @returns a string with the Quaternion coordinates
  3723. */
  3724. toString(): string;
  3725. /**
  3726. * Gets the class name of the quaternion
  3727. * @returns the string "Quaternion"
  3728. */
  3729. getClassName(): string;
  3730. /**
  3731. * Gets a hash code for this quaternion
  3732. * @returns the quaternion hash code
  3733. */
  3734. getHashCode(): number;
  3735. /**
  3736. * Copy the quaternion to an array
  3737. * @returns a new array populated with 4 elements from the quaternion coordinates
  3738. */
  3739. asArray(): number[];
  3740. /**
  3741. * Check if two quaternions are equals
  3742. * @param otherQuaternion defines the second operand
  3743. * @return true if the current quaternion and the given one coordinates are strictly equals
  3744. */
  3745. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3746. /**
  3747. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3748. * @param otherQuaternion defines the other quaternion
  3749. * @param epsilon defines the minimal distance to consider equality
  3750. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3751. */
  3752. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3753. /**
  3754. * Clone the current quaternion
  3755. * @returns a new quaternion copied from the current one
  3756. */
  3757. clone(): Quaternion;
  3758. /**
  3759. * Copy a quaternion to the current one
  3760. * @param other defines the other quaternion
  3761. * @returns the updated current quaternion
  3762. */
  3763. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3764. /**
  3765. * Updates the current quaternion with the given float coordinates
  3766. * @param x defines the x coordinate
  3767. * @param y defines the y coordinate
  3768. * @param z defines the z coordinate
  3769. * @param w defines the w coordinate
  3770. * @returns the updated current quaternion
  3771. */
  3772. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3773. /**
  3774. * Updates the current quaternion from the given float coordinates
  3775. * @param x defines the x coordinate
  3776. * @param y defines the y coordinate
  3777. * @param z defines the z coordinate
  3778. * @param w defines the w coordinate
  3779. * @returns the updated current quaternion
  3780. */
  3781. set(x: number, y: number, z: number, w: number): Quaternion;
  3782. /**
  3783. * Adds two quaternions
  3784. * @param other defines the second operand
  3785. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3786. */
  3787. add(other: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Add a quaternion to the current one
  3790. * @param other defines the quaternion to add
  3791. * @returns the current quaternion
  3792. */
  3793. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3794. /**
  3795. * Subtract two quaternions
  3796. * @param other defines the second operand
  3797. * @returns a new quaternion as the subtraction result of the given one from the current one
  3798. */
  3799. subtract(other: Quaternion): Quaternion;
  3800. /**
  3801. * Multiplies the current quaternion by a scale factor
  3802. * @param value defines the scale factor
  3803. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3804. */
  3805. scale(value: number): Quaternion;
  3806. /**
  3807. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3808. * @param scale defines the scale factor
  3809. * @param result defines the Quaternion object where to store the result
  3810. * @returns the unmodified current quaternion
  3811. */
  3812. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3813. /**
  3814. * Multiplies in place the current quaternion by a scale factor
  3815. * @param value defines the scale factor
  3816. * @returns the current modified quaternion
  3817. */
  3818. scaleInPlace(value: number): Quaternion;
  3819. /**
  3820. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3821. * @param scale defines the scale factor
  3822. * @param result defines the Quaternion object where to store the result
  3823. * @returns the unmodified current quaternion
  3824. */
  3825. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3826. /**
  3827. * Multiplies two quaternions
  3828. * @param q1 defines the second operand
  3829. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3830. */
  3831. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3832. /**
  3833. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3834. * @param q1 defines the second operand
  3835. * @param result defines the target quaternion
  3836. * @returns the current quaternion
  3837. */
  3838. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3839. /**
  3840. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3841. * @param q1 defines the second operand
  3842. * @returns the currentupdated quaternion
  3843. */
  3844. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3845. /**
  3846. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3847. * @param ref defines the target quaternion
  3848. * @returns the current quaternion
  3849. */
  3850. conjugateToRef(ref: Quaternion): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns the current updated quaternion
  3854. */
  3855. conjugateInPlace(): Quaternion;
  3856. /**
  3857. * Conjugates in place (1-q) the current quaternion
  3858. * @returns a new quaternion
  3859. */
  3860. conjugate(): Quaternion;
  3861. /**
  3862. * Gets length of current quaternion
  3863. * @returns the quaternion length (float)
  3864. */
  3865. length(): number;
  3866. /**
  3867. * Normalize in place the current quaternion
  3868. * @returns the current updated quaternion
  3869. */
  3870. normalize(): Quaternion;
  3871. /**
  3872. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3873. * @param order is a reserved parameter and is ignored for now
  3874. * @returns a new Vector3 containing the Euler angles
  3875. */
  3876. toEulerAngles(order?: string): Vector3;
  3877. /**
  3878. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3879. * @param result defines the vector which will be filled with the Euler angles
  3880. * @returns the current unchanged quaternion
  3881. */
  3882. toEulerAnglesToRef(result: Vector3): Quaternion;
  3883. /**
  3884. * Updates the given rotation matrix with the current quaternion values
  3885. * @param result defines the target matrix
  3886. * @returns the current unchanged quaternion
  3887. */
  3888. toRotationMatrix(result: Matrix): Quaternion;
  3889. /**
  3890. * Updates the current quaternion from the given rotation matrix values
  3891. * @param matrix defines the source matrix
  3892. * @returns the current updated quaternion
  3893. */
  3894. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3895. /**
  3896. * Creates a new quaternion from a rotation matrix
  3897. * @param matrix defines the source matrix
  3898. * @returns a new quaternion created from the given rotation matrix values
  3899. */
  3900. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3901. /**
  3902. * Updates the given quaternion with the given rotation matrix values
  3903. * @param matrix defines the source matrix
  3904. * @param result defines the target quaternion
  3905. */
  3906. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3907. /**
  3908. * Returns the dot product (float) between the quaternions "left" and "right"
  3909. * @param left defines the left operand
  3910. * @param right defines the right operand
  3911. * @returns the dot product
  3912. */
  3913. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3914. /**
  3915. * Checks if the two quaternions are close to each other
  3916. * @param quat0 defines the first quaternion to check
  3917. * @param quat1 defines the second quaternion to check
  3918. * @returns true if the two quaternions are close to each other
  3919. */
  3920. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3921. /**
  3922. * Creates an empty quaternion
  3923. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3924. */
  3925. static Zero(): Quaternion;
  3926. /**
  3927. * Inverse a given quaternion
  3928. * @param q defines the source quaternion
  3929. * @returns a new quaternion as the inverted current quaternion
  3930. */
  3931. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3932. /**
  3933. * Inverse a given quaternion
  3934. * @param q defines the source quaternion
  3935. * @param result the quaternion the result will be stored in
  3936. * @returns the result quaternion
  3937. */
  3938. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3939. /**
  3940. * Creates an identity quaternion
  3941. * @returns the identity quaternion
  3942. */
  3943. static Identity(): Quaternion;
  3944. /**
  3945. * Gets a boolean indicating if the given quaternion is identity
  3946. * @param quaternion defines the quaternion to check
  3947. * @returns true if the quaternion is identity
  3948. */
  3949. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3950. /**
  3951. * Creates a quaternion from a rotation around an axis
  3952. * @param axis defines the axis to use
  3953. * @param angle defines the angle to use
  3954. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3955. */
  3956. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3957. /**
  3958. * Creates a rotation around an axis and stores it into the given quaternion
  3959. * @param axis defines the axis to use
  3960. * @param angle defines the angle to use
  3961. * @param result defines the target quaternion
  3962. * @returns the target quaternion
  3963. */
  3964. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3965. /**
  3966. * Creates a new quaternion from data stored into an array
  3967. * @param array defines the data source
  3968. * @param offset defines the offset in the source array where the data starts
  3969. * @returns a new quaternion
  3970. */
  3971. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3972. /**
  3973. * Updates the given quaternion "result" from the starting index of the given array.
  3974. * @param array the array to pull values from
  3975. * @param offset the offset into the array to start at
  3976. * @param result the quaternion to store the result in
  3977. */
  3978. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3979. /**
  3980. * Create a quaternion from Euler rotation angles
  3981. * @param x Pitch
  3982. * @param y Yaw
  3983. * @param z Roll
  3984. * @returns the new Quaternion
  3985. */
  3986. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3987. /**
  3988. * Updates a quaternion from Euler rotation angles
  3989. * @param x Pitch
  3990. * @param y Yaw
  3991. * @param z Roll
  3992. * @param result the quaternion to store the result
  3993. * @returns the updated quaternion
  3994. */
  3995. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3996. /**
  3997. * Create a quaternion from Euler rotation vector
  3998. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3999. * @returns the new Quaternion
  4000. */
  4001. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4002. /**
  4003. * Updates a quaternion from Euler rotation vector
  4004. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4005. * @param result the quaternion to store the result
  4006. * @returns the updated quaternion
  4007. */
  4008. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4009. /**
  4010. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4011. * @param yaw defines the rotation around Y axis
  4012. * @param pitch defines the rotation around X axis
  4013. * @param roll defines the rotation around Z axis
  4014. * @returns the new quaternion
  4015. */
  4016. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4017. /**
  4018. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4019. * @param yaw defines the rotation around Y axis
  4020. * @param pitch defines the rotation around X axis
  4021. * @param roll defines the rotation around Z axis
  4022. * @param result defines the target quaternion
  4023. */
  4024. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4025. /**
  4026. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4027. * @param alpha defines the rotation around first axis
  4028. * @param beta defines the rotation around second axis
  4029. * @param gamma defines the rotation around third axis
  4030. * @returns the new quaternion
  4031. */
  4032. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4033. /**
  4034. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4035. * @param alpha defines the rotation around first axis
  4036. * @param beta defines the rotation around second axis
  4037. * @param gamma defines the rotation around third axis
  4038. * @param result defines the target quaternion
  4039. */
  4040. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4041. /**
  4042. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4043. * @param axis1 defines the first axis
  4044. * @param axis2 defines the second axis
  4045. * @param axis3 defines the third axis
  4046. * @returns the new quaternion
  4047. */
  4048. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4049. /**
  4050. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4051. * @param axis1 defines the first axis
  4052. * @param axis2 defines the second axis
  4053. * @param axis3 defines the third axis
  4054. * @param ref defines the target quaternion
  4055. */
  4056. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4057. /**
  4058. * Interpolates between two quaternions
  4059. * @param left defines first quaternion
  4060. * @param right defines second quaternion
  4061. * @param amount defines the gradient to use
  4062. * @returns the new interpolated quaternion
  4063. */
  4064. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4065. /**
  4066. * Interpolates between two quaternions and stores it into a target quaternion
  4067. * @param left defines first quaternion
  4068. * @param right defines second quaternion
  4069. * @param amount defines the gradient to use
  4070. * @param result defines the target quaternion
  4071. */
  4072. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4073. /**
  4074. * Interpolate between two quaternions using Hermite interpolation
  4075. * @param value1 defines first quaternion
  4076. * @param tangent1 defines the incoming tangent
  4077. * @param value2 defines second quaternion
  4078. * @param tangent2 defines the outgoing tangent
  4079. * @param amount defines the target quaternion
  4080. * @returns the new interpolated quaternion
  4081. */
  4082. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4083. }
  4084. /**
  4085. * Class used to store matrix data (4x4)
  4086. */
  4087. export class Matrix {
  4088. /**
  4089. * Gets the precision of matrix computations
  4090. */
  4091. static get Use64Bits(): boolean;
  4092. private static _updateFlagSeed;
  4093. private static _identityReadOnly;
  4094. private _isIdentity;
  4095. private _isIdentityDirty;
  4096. private _isIdentity3x2;
  4097. private _isIdentity3x2Dirty;
  4098. /**
  4099. * Gets the update flag of the matrix which is an unique number for the matrix.
  4100. * It will be incremented every time the matrix data change.
  4101. * You can use it to speed the comparison between two versions of the same matrix.
  4102. */
  4103. updateFlag: number;
  4104. private readonly _m;
  4105. /**
  4106. * Gets the internal data of the matrix
  4107. */
  4108. get m(): DeepImmutable<Float32Array | Array<number>>;
  4109. /** @hidden */
  4110. _markAsUpdated(): void;
  4111. /** @hidden */
  4112. private _updateIdentityStatus;
  4113. /**
  4114. * Creates an empty matrix (filled with zeros)
  4115. */
  4116. constructor();
  4117. /**
  4118. * Check if the current matrix is identity
  4119. * @returns true is the matrix is the identity matrix
  4120. */
  4121. isIdentity(): boolean;
  4122. /**
  4123. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4124. * @returns true is the matrix is the identity matrix
  4125. */
  4126. isIdentityAs3x2(): boolean;
  4127. /**
  4128. * Gets the determinant of the matrix
  4129. * @returns the matrix determinant
  4130. */
  4131. determinant(): number;
  4132. /**
  4133. * Returns the matrix as a Float32Array or Array<number>
  4134. * @returns the matrix underlying array
  4135. */
  4136. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4137. /**
  4138. * Returns the matrix as a Float32Array or Array<number>
  4139. * @returns the matrix underlying array.
  4140. */
  4141. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4142. /**
  4143. * Inverts the current matrix in place
  4144. * @returns the current inverted matrix
  4145. */
  4146. invert(): Matrix;
  4147. /**
  4148. * Sets all the matrix elements to zero
  4149. * @returns the current matrix
  4150. */
  4151. reset(): Matrix;
  4152. /**
  4153. * Adds the current matrix with a second one
  4154. * @param other defines the matrix to add
  4155. * @returns a new matrix as the addition of the current matrix and the given one
  4156. */
  4157. add(other: DeepImmutable<Matrix>): Matrix;
  4158. /**
  4159. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4160. * @param other defines the matrix to add
  4161. * @param result defines the target matrix
  4162. * @returns the current matrix
  4163. */
  4164. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4165. /**
  4166. * Adds in place the given matrix to the current matrix
  4167. * @param other defines the second operand
  4168. * @returns the current updated matrix
  4169. */
  4170. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4171. /**
  4172. * Sets the given matrix to the current inverted Matrix
  4173. * @param other defines the target matrix
  4174. * @returns the unmodified current matrix
  4175. */
  4176. invertToRef(other: Matrix): Matrix;
  4177. /**
  4178. * add a value at the specified position in the current Matrix
  4179. * @param index the index of the value within the matrix. between 0 and 15.
  4180. * @param value the value to be added
  4181. * @returns the current updated matrix
  4182. */
  4183. addAtIndex(index: number, value: number): Matrix;
  4184. /**
  4185. * mutiply the specified position in the current Matrix by a value
  4186. * @param index the index of the value within the matrix. between 0 and 15.
  4187. * @param value the value to be added
  4188. * @returns the current updated matrix
  4189. */
  4190. multiplyAtIndex(index: number, value: number): Matrix;
  4191. /**
  4192. * Inserts the translation vector (using 3 floats) in the current matrix
  4193. * @param x defines the 1st component of the translation
  4194. * @param y defines the 2nd component of the translation
  4195. * @param z defines the 3rd component of the translation
  4196. * @returns the current updated matrix
  4197. */
  4198. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4199. /**
  4200. * Adds the translation vector (using 3 floats) in the current matrix
  4201. * @param x defines the 1st component of the translation
  4202. * @param y defines the 2nd component of the translation
  4203. * @param z defines the 3rd component of the translation
  4204. * @returns the current updated matrix
  4205. */
  4206. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4207. /**
  4208. * Inserts the translation vector in the current matrix
  4209. * @param vector3 defines the translation to insert
  4210. * @returns the current updated matrix
  4211. */
  4212. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4213. /**
  4214. * Gets the translation value of the current matrix
  4215. * @returns a new Vector3 as the extracted translation from the matrix
  4216. */
  4217. getTranslation(): Vector3;
  4218. /**
  4219. * Fill a Vector3 with the extracted translation from the matrix
  4220. * @param result defines the Vector3 where to store the translation
  4221. * @returns the current matrix
  4222. */
  4223. getTranslationToRef(result: Vector3): Matrix;
  4224. /**
  4225. * Remove rotation and scaling part from the matrix
  4226. * @returns the updated matrix
  4227. */
  4228. removeRotationAndScaling(): Matrix;
  4229. /**
  4230. * Multiply two matrices
  4231. * @param other defines the second operand
  4232. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4233. */
  4234. multiply(other: DeepImmutable<Matrix>): Matrix;
  4235. /**
  4236. * Copy the current matrix from the given one
  4237. * @param other defines the source matrix
  4238. * @returns the current updated matrix
  4239. */
  4240. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4241. /**
  4242. * Populates the given array from the starting index with the current matrix values
  4243. * @param array defines the target array
  4244. * @param offset defines the offset in the target array where to start storing values
  4245. * @returns the current matrix
  4246. */
  4247. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4248. /**
  4249. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4250. * @param other defines the second operand
  4251. * @param result defines the matrix where to store the multiplication
  4252. * @returns the current matrix
  4253. */
  4254. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4255. /**
  4256. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4257. * @param other defines the second operand
  4258. * @param result defines the array where to store the multiplication
  4259. * @param offset defines the offset in the target array where to start storing values
  4260. * @returns the current matrix
  4261. */
  4262. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4263. /**
  4264. * Check equality between this matrix and a second one
  4265. * @param value defines the second matrix to compare
  4266. * @returns true is the current matrix and the given one values are strictly equal
  4267. */
  4268. equals(value: DeepImmutable<Matrix>): boolean;
  4269. /**
  4270. * Clone the current matrix
  4271. * @returns a new matrix from the current matrix
  4272. */
  4273. clone(): Matrix;
  4274. /**
  4275. * Returns the name of the current matrix class
  4276. * @returns the string "Matrix"
  4277. */
  4278. getClassName(): string;
  4279. /**
  4280. * Gets the hash code of the current matrix
  4281. * @returns the hash code
  4282. */
  4283. getHashCode(): number;
  4284. /**
  4285. * Decomposes the current Matrix into a translation, rotation and scaling components
  4286. * @param scale defines the scale vector3 given as a reference to update
  4287. * @param rotation defines the rotation quaternion given as a reference to update
  4288. * @param translation defines the translation vector3 given as a reference to update
  4289. * @returns true if operation was successful
  4290. */
  4291. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4292. /**
  4293. * Gets specific row of the matrix
  4294. * @param index defines the number of the row to get
  4295. * @returns the index-th row of the current matrix as a new Vector4
  4296. */
  4297. getRow(index: number): Nullable<Vector4>;
  4298. /**
  4299. * Sets the index-th row of the current matrix to the vector4 values
  4300. * @param index defines the number of the row to set
  4301. * @param row defines the target vector4
  4302. * @returns the updated current matrix
  4303. */
  4304. setRow(index: number, row: Vector4): Matrix;
  4305. /**
  4306. * Compute the transpose of the matrix
  4307. * @returns the new transposed matrix
  4308. */
  4309. transpose(): Matrix;
  4310. /**
  4311. * Compute the transpose of the matrix and store it in a given matrix
  4312. * @param result defines the target matrix
  4313. * @returns the current matrix
  4314. */
  4315. transposeToRef(result: Matrix): Matrix;
  4316. /**
  4317. * Sets the index-th row of the current matrix with the given 4 x float values
  4318. * @param index defines the row index
  4319. * @param x defines the x component to set
  4320. * @param y defines the y component to set
  4321. * @param z defines the z component to set
  4322. * @param w defines the w component to set
  4323. * @returns the updated current matrix
  4324. */
  4325. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4326. /**
  4327. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4328. * @param scale defines the scale factor
  4329. * @returns a new matrix
  4330. */
  4331. scale(scale: number): Matrix;
  4332. /**
  4333. * Scale the current matrix values by a factor to a given result matrix
  4334. * @param scale defines the scale factor
  4335. * @param result defines the matrix to store the result
  4336. * @returns the current matrix
  4337. */
  4338. scaleToRef(scale: number, result: Matrix): Matrix;
  4339. /**
  4340. * Scale the current matrix values by a factor and add the result to a given matrix
  4341. * @param scale defines the scale factor
  4342. * @param result defines the Matrix to store the result
  4343. * @returns the current matrix
  4344. */
  4345. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4346. /**
  4347. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4348. * @param ref matrix to store the result
  4349. */
  4350. toNormalMatrix(ref: Matrix): void;
  4351. /**
  4352. * Gets only rotation part of the current matrix
  4353. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4354. */
  4355. getRotationMatrix(): Matrix;
  4356. /**
  4357. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4358. * @param result defines the target matrix to store data to
  4359. * @returns the current matrix
  4360. */
  4361. getRotationMatrixToRef(result: Matrix): Matrix;
  4362. /**
  4363. * Toggles model matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleModelMatrixHandInPlace(): void;
  4366. /**
  4367. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4368. */
  4369. toggleProjectionMatrixHandInPlace(): void;
  4370. /**
  4371. * Creates a matrix from an array
  4372. * @param array defines the source array
  4373. * @param offset defines an offset in the source array
  4374. * @returns a new Matrix set from the starting index of the given array
  4375. */
  4376. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4377. /**
  4378. * Copy the content of an array into a given matrix
  4379. * @param array defines the source array
  4380. * @param offset defines an offset in the source array
  4381. * @param result defines the target matrix
  4382. */
  4383. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4384. /**
  4385. * Stores an array into a matrix after having multiplied each component by a given factor
  4386. * @param array defines the source array
  4387. * @param offset defines the offset in the source array
  4388. * @param scale defines the scaling factor
  4389. * @param result defines the target matrix
  4390. */
  4391. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4392. /**
  4393. * Gets an identity matrix that must not be updated
  4394. */
  4395. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4396. /**
  4397. * Stores a list of values (16) inside a given matrix
  4398. * @param initialM11 defines 1st value of 1st row
  4399. * @param initialM12 defines 2nd value of 1st row
  4400. * @param initialM13 defines 3rd value of 1st row
  4401. * @param initialM14 defines 4th value of 1st row
  4402. * @param initialM21 defines 1st value of 2nd row
  4403. * @param initialM22 defines 2nd value of 2nd row
  4404. * @param initialM23 defines 3rd value of 2nd row
  4405. * @param initialM24 defines 4th value of 2nd row
  4406. * @param initialM31 defines 1st value of 3rd row
  4407. * @param initialM32 defines 2nd value of 3rd row
  4408. * @param initialM33 defines 3rd value of 3rd row
  4409. * @param initialM34 defines 4th value of 3rd row
  4410. * @param initialM41 defines 1st value of 4th row
  4411. * @param initialM42 defines 2nd value of 4th row
  4412. * @param initialM43 defines 3rd value of 4th row
  4413. * @param initialM44 defines 4th value of 4th row
  4414. * @param result defines the target matrix
  4415. */
  4416. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4417. /**
  4418. * Creates new matrix from a list of values (16)
  4419. * @param initialM11 defines 1st value of 1st row
  4420. * @param initialM12 defines 2nd value of 1st row
  4421. * @param initialM13 defines 3rd value of 1st row
  4422. * @param initialM14 defines 4th value of 1st row
  4423. * @param initialM21 defines 1st value of 2nd row
  4424. * @param initialM22 defines 2nd value of 2nd row
  4425. * @param initialM23 defines 3rd value of 2nd row
  4426. * @param initialM24 defines 4th value of 2nd row
  4427. * @param initialM31 defines 1st value of 3rd row
  4428. * @param initialM32 defines 2nd value of 3rd row
  4429. * @param initialM33 defines 3rd value of 3rd row
  4430. * @param initialM34 defines 4th value of 3rd row
  4431. * @param initialM41 defines 1st value of 4th row
  4432. * @param initialM42 defines 2nd value of 4th row
  4433. * @param initialM43 defines 3rd value of 4th row
  4434. * @param initialM44 defines 4th value of 4th row
  4435. * @returns the new matrix
  4436. */
  4437. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4438. /**
  4439. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4440. * @param scale defines the scale vector3
  4441. * @param rotation defines the rotation quaternion
  4442. * @param translation defines the translation vector3
  4443. * @returns a new matrix
  4444. */
  4445. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4446. /**
  4447. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4448. * @param scale defines the scale vector3
  4449. * @param rotation defines the rotation quaternion
  4450. * @param translation defines the translation vector3
  4451. * @param result defines the target matrix
  4452. */
  4453. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4454. /**
  4455. * Creates a new identity matrix
  4456. * @returns a new identity matrix
  4457. */
  4458. static Identity(): Matrix;
  4459. /**
  4460. * Creates a new identity matrix and stores the result in a given matrix
  4461. * @param result defines the target matrix
  4462. */
  4463. static IdentityToRef(result: Matrix): void;
  4464. /**
  4465. * Creates a new zero matrix
  4466. * @returns a new zero matrix
  4467. */
  4468. static Zero(): Matrix;
  4469. /**
  4470. * Creates a new rotation matrix for "angle" radians around the X axis
  4471. * @param angle defines the angle (in radians) to use
  4472. * @return the new matrix
  4473. */
  4474. static RotationX(angle: number): Matrix;
  4475. /**
  4476. * Creates a new matrix as the invert of a given matrix
  4477. * @param source defines the source matrix
  4478. * @returns the new matrix
  4479. */
  4480. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4481. /**
  4482. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4483. * @param angle defines the angle (in radians) to use
  4484. * @param result defines the target matrix
  4485. */
  4486. static RotationXToRef(angle: number, result: Matrix): void;
  4487. /**
  4488. * Creates a new rotation matrix for "angle" radians around the Y axis
  4489. * @param angle defines the angle (in radians) to use
  4490. * @return the new matrix
  4491. */
  4492. static RotationY(angle: number): Matrix;
  4493. /**
  4494. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4495. * @param angle defines the angle (in radians) to use
  4496. * @param result defines the target matrix
  4497. */
  4498. static RotationYToRef(angle: number, result: Matrix): void;
  4499. /**
  4500. * Creates a new rotation matrix for "angle" radians around the Z axis
  4501. * @param angle defines the angle (in radians) to use
  4502. * @return the new matrix
  4503. */
  4504. static RotationZ(angle: number): Matrix;
  4505. /**
  4506. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4507. * @param angle defines the angle (in radians) to use
  4508. * @param result defines the target matrix
  4509. */
  4510. static RotationZToRef(angle: number, result: Matrix): void;
  4511. /**
  4512. * Creates a new rotation matrix for "angle" radians around the given axis
  4513. * @param axis defines the axis to use
  4514. * @param angle defines the angle (in radians) to use
  4515. * @return the new matrix
  4516. */
  4517. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4518. /**
  4519. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4520. * @param axis defines the axis to use
  4521. * @param angle defines the angle (in radians) to use
  4522. * @param result defines the target matrix
  4523. */
  4524. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4525. /**
  4526. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4527. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4528. * @param from defines the vector to align
  4529. * @param to defines the vector to align to
  4530. * @param result defines the target matrix
  4531. */
  4532. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4533. /**
  4534. * Creates a rotation matrix
  4535. * @param yaw defines the yaw angle in radians (Y axis)
  4536. * @param pitch defines the pitch angle in radians (X axis)
  4537. * @param roll defines the roll angle in radians (Z axis)
  4538. * @returns the new rotation matrix
  4539. */
  4540. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4541. /**
  4542. * Creates a rotation matrix and stores it in a given matrix
  4543. * @param yaw defines the yaw angle in radians (Y axis)
  4544. * @param pitch defines the pitch angle in radians (X axis)
  4545. * @param roll defines the roll angle in radians (Z axis)
  4546. * @param result defines the target matrix
  4547. */
  4548. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4549. /**
  4550. * Creates a scaling matrix
  4551. * @param x defines the scale factor on X axis
  4552. * @param y defines the scale factor on Y axis
  4553. * @param z defines the scale factor on Z axis
  4554. * @returns the new matrix
  4555. */
  4556. static Scaling(x: number, y: number, z: number): Matrix;
  4557. /**
  4558. * Creates a scaling matrix and stores it in a given matrix
  4559. * @param x defines the scale factor on X axis
  4560. * @param y defines the scale factor on Y axis
  4561. * @param z defines the scale factor on Z axis
  4562. * @param result defines the target matrix
  4563. */
  4564. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4565. /**
  4566. * Creates a translation matrix
  4567. * @param x defines the translation on X axis
  4568. * @param y defines the translation on Y axis
  4569. * @param z defines the translationon Z axis
  4570. * @returns the new matrix
  4571. */
  4572. static Translation(x: number, y: number, z: number): Matrix;
  4573. /**
  4574. * Creates a translation matrix and stores it in a given matrix
  4575. * @param x defines the translation on X axis
  4576. * @param y defines the translation on Y axis
  4577. * @param z defines the translationon Z axis
  4578. * @param result defines the target matrix
  4579. */
  4580. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4581. /**
  4582. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4583. * @param startValue defines the start value
  4584. * @param endValue defines the end value
  4585. * @param gradient defines the gradient factor
  4586. * @returns the new matrix
  4587. */
  4588. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4589. /**
  4590. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4591. * @param startValue defines the start value
  4592. * @param endValue defines the end value
  4593. * @param gradient defines the gradient factor
  4594. * @param result defines the Matrix object where to store data
  4595. */
  4596. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4597. /**
  4598. * Builds a new matrix whose values are computed by:
  4599. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4600. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4601. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4602. * @param startValue defines the first matrix
  4603. * @param endValue defines the second matrix
  4604. * @param gradient defines the gradient between the two matrices
  4605. * @returns the new matrix
  4606. */
  4607. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4608. /**
  4609. * Update a matrix to values which are computed by:
  4610. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4611. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4612. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4613. * @param startValue defines the first matrix
  4614. * @param endValue defines the second matrix
  4615. * @param gradient defines the gradient between the two matrices
  4616. * @param result defines the target matrix
  4617. */
  4618. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4619. /**
  4620. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4621. * This function works in left handed mode
  4622. * @param eye defines the final position of the entity
  4623. * @param target defines where the entity should look at
  4624. * @param up defines the up vector for the entity
  4625. * @returns the new matrix
  4626. */
  4627. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4628. /**
  4629. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4630. * This function works in left handed mode
  4631. * @param eye defines the final position of the entity
  4632. * @param target defines where the entity should look at
  4633. * @param up defines the up vector for the entity
  4634. * @param result defines the target matrix
  4635. */
  4636. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4637. /**
  4638. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4639. * This function works in right handed mode
  4640. * @param eye defines the final position of the entity
  4641. * @param target defines where the entity should look at
  4642. * @param up defines the up vector for the entity
  4643. * @returns the new matrix
  4644. */
  4645. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4646. /**
  4647. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4648. * This function works in right handed mode
  4649. * @param eye defines the final position of the entity
  4650. * @param target defines where the entity should look at
  4651. * @param up defines the up vector for the entity
  4652. * @param result defines the target matrix
  4653. */
  4654. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4655. /**
  4656. * Create a left-handed orthographic projection matrix
  4657. * @param width defines the viewport width
  4658. * @param height defines the viewport height
  4659. * @param znear defines the near clip plane
  4660. * @param zfar defines the far clip plane
  4661. * @returns a new matrix as a left-handed orthographic projection matrix
  4662. */
  4663. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4664. /**
  4665. * Store a left-handed orthographic projection to a given matrix
  4666. * @param width defines the viewport width
  4667. * @param height defines the viewport height
  4668. * @param znear defines the near clip plane
  4669. * @param zfar defines the far clip plane
  4670. * @param result defines the target matrix
  4671. */
  4672. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4673. /**
  4674. * Create a left-handed orthographic projection matrix
  4675. * @param left defines the viewport left coordinate
  4676. * @param right defines the viewport right coordinate
  4677. * @param bottom defines the viewport bottom coordinate
  4678. * @param top defines the viewport top coordinate
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @returns a new matrix as a left-handed orthographic projection matrix
  4682. */
  4683. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4684. /**
  4685. * Stores a left-handed orthographic projection into a given matrix
  4686. * @param left defines the viewport left coordinate
  4687. * @param right defines the viewport right coordinate
  4688. * @param bottom defines the viewport bottom coordinate
  4689. * @param top defines the viewport top coordinate
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @param result defines the target matrix
  4693. */
  4694. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4695. /**
  4696. * Creates a right-handed orthographic projection matrix
  4697. * @param left defines the viewport left coordinate
  4698. * @param right defines the viewport right coordinate
  4699. * @param bottom defines the viewport bottom coordinate
  4700. * @param top defines the viewport top coordinate
  4701. * @param znear defines the near clip plane
  4702. * @param zfar defines the far clip plane
  4703. * @returns a new matrix as a right-handed orthographic projection matrix
  4704. */
  4705. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4706. /**
  4707. * Stores a right-handed orthographic projection into a given matrix
  4708. * @param left defines the viewport left coordinate
  4709. * @param right defines the viewport right coordinate
  4710. * @param bottom defines the viewport bottom coordinate
  4711. * @param top defines the viewport top coordinate
  4712. * @param znear defines the near clip plane
  4713. * @param zfar defines the far clip plane
  4714. * @param result defines the target matrix
  4715. */
  4716. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4717. /**
  4718. * Creates a left-handed perspective projection matrix
  4719. * @param width defines the viewport width
  4720. * @param height defines the viewport height
  4721. * @param znear defines the near clip plane
  4722. * @param zfar defines the far clip plane
  4723. * @returns a new matrix as a left-handed perspective projection matrix
  4724. */
  4725. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4726. /**
  4727. * Creates a left-handed perspective projection matrix
  4728. * @param fov defines the horizontal field of view
  4729. * @param aspect defines the aspect ratio
  4730. * @param znear defines the near clip plane
  4731. * @param zfar defines the far clip plane
  4732. * @returns a new matrix as a left-handed perspective projection matrix
  4733. */
  4734. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4735. /**
  4736. * Stores a left-handed perspective projection into a given matrix
  4737. * @param fov defines the horizontal field of view
  4738. * @param aspect defines the aspect ratio
  4739. * @param znear defines the near clip plane
  4740. * @param zfar defines the far clip plane
  4741. * @param result defines the target matrix
  4742. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4743. */
  4744. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4745. /**
  4746. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4747. * @param fov defines the horizontal field of view
  4748. * @param aspect defines the aspect ratio
  4749. * @param znear defines the near clip plane
  4750. * @param zfar not used as infinity is used as far clip
  4751. * @param result defines the target matrix
  4752. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4753. */
  4754. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4755. /**
  4756. * Creates a right-handed perspective projection matrix
  4757. * @param fov defines the horizontal field of view
  4758. * @param aspect defines the aspect ratio
  4759. * @param znear defines the near clip plane
  4760. * @param zfar defines the far clip plane
  4761. * @returns a new matrix as a right-handed perspective projection matrix
  4762. */
  4763. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4764. /**
  4765. * Stores a right-handed perspective projection into a given matrix
  4766. * @param fov defines the horizontal field of view
  4767. * @param aspect defines the aspect ratio
  4768. * @param znear defines the near clip plane
  4769. * @param zfar defines the far clip plane
  4770. * @param result defines the target matrix
  4771. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4772. */
  4773. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4774. /**
  4775. * Stores a right-handed perspective projection into a given matrix
  4776. * @param fov defines the horizontal field of view
  4777. * @param aspect defines the aspect ratio
  4778. * @param znear defines the near clip plane
  4779. * @param zfar not used as infinity is used as far clip
  4780. * @param result defines the target matrix
  4781. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4782. */
  4783. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4784. /**
  4785. * Stores a perspective projection for WebVR info a given matrix
  4786. * @param fov defines the field of view
  4787. * @param znear defines the near clip plane
  4788. * @param zfar defines the far clip plane
  4789. * @param result defines the target matrix
  4790. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4791. */
  4792. static PerspectiveFovWebVRToRef(fov: {
  4793. upDegrees: number;
  4794. downDegrees: number;
  4795. leftDegrees: number;
  4796. rightDegrees: number;
  4797. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4798. /**
  4799. * Computes a complete transformation matrix
  4800. * @param viewport defines the viewport to use
  4801. * @param world defines the world matrix
  4802. * @param view defines the view matrix
  4803. * @param projection defines the projection matrix
  4804. * @param zmin defines the near clip plane
  4805. * @param zmax defines the far clip plane
  4806. * @returns the transformation matrix
  4807. */
  4808. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4809. /**
  4810. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4811. * @param matrix defines the matrix to use
  4812. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4813. */
  4814. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4815. /**
  4816. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4817. * @param matrix defines the matrix to use
  4818. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4819. */
  4820. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4821. /**
  4822. * Compute the transpose of a given matrix
  4823. * @param matrix defines the matrix to transpose
  4824. * @returns the new matrix
  4825. */
  4826. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4827. /**
  4828. * Compute the transpose of a matrix and store it in a target matrix
  4829. * @param matrix defines the matrix to transpose
  4830. * @param result defines the target matrix
  4831. */
  4832. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4833. /**
  4834. * Computes a reflection matrix from a plane
  4835. * @param plane defines the reflection plane
  4836. * @returns a new matrix
  4837. */
  4838. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4839. /**
  4840. * Computes a reflection matrix from a plane
  4841. * @param plane defines the reflection plane
  4842. * @param result defines the target matrix
  4843. */
  4844. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4845. /**
  4846. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4847. * @param xaxis defines the value of the 1st axis
  4848. * @param yaxis defines the value of the 2nd axis
  4849. * @param zaxis defines the value of the 3rd axis
  4850. * @param result defines the target matrix
  4851. */
  4852. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4853. /**
  4854. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4855. * @param quat defines the quaternion to use
  4856. * @param result defines the target matrix
  4857. */
  4858. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4859. }
  4860. /**
  4861. * @hidden
  4862. */
  4863. export class TmpVectors {
  4864. static Vector2: Vector2[];
  4865. static Vector3: Vector3[];
  4866. static Vector4: Vector4[];
  4867. static Quaternion: Quaternion[];
  4868. static Matrix: Matrix[];
  4869. }
  4870. }
  4871. declare module BABYLON {
  4872. /**
  4873. * Defines potential orientation for back face culling
  4874. */
  4875. export enum Orientation {
  4876. /**
  4877. * Clockwise
  4878. */
  4879. CW = 0,
  4880. /** Counter clockwise */
  4881. CCW = 1
  4882. }
  4883. /** Class used to represent a Bezier curve */
  4884. export class BezierCurve {
  4885. /**
  4886. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4887. * @param t defines the time
  4888. * @param x1 defines the left coordinate on X axis
  4889. * @param y1 defines the left coordinate on Y axis
  4890. * @param x2 defines the right coordinate on X axis
  4891. * @param y2 defines the right coordinate on Y axis
  4892. * @returns the interpolated value
  4893. */
  4894. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4895. }
  4896. /**
  4897. * Defines angle representation
  4898. */
  4899. export class Angle {
  4900. private _radians;
  4901. /**
  4902. * Creates an Angle object of "radians" radians (float).
  4903. * @param radians the angle in radians
  4904. */
  4905. constructor(radians: number);
  4906. /**
  4907. * Get value in degrees
  4908. * @returns the Angle value in degrees (float)
  4909. */
  4910. degrees(): number;
  4911. /**
  4912. * Get value in radians
  4913. * @returns the Angle value in radians (float)
  4914. */
  4915. radians(): number;
  4916. /**
  4917. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4918. * @param a defines first point as the origin
  4919. * @param b defines point
  4920. * @returns a new Angle
  4921. */
  4922. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4923. /**
  4924. * Gets a new Angle object from the given float in radians
  4925. * @param radians defines the angle value in radians
  4926. * @returns a new Angle
  4927. */
  4928. static FromRadians(radians: number): Angle;
  4929. /**
  4930. * Gets a new Angle object from the given float in degrees
  4931. * @param degrees defines the angle value in degrees
  4932. * @returns a new Angle
  4933. */
  4934. static FromDegrees(degrees: number): Angle;
  4935. }
  4936. /**
  4937. * This represents an arc in a 2d space.
  4938. */
  4939. export class Arc2 {
  4940. /** Defines the start point of the arc */
  4941. startPoint: Vector2;
  4942. /** Defines the mid point of the arc */
  4943. midPoint: Vector2;
  4944. /** Defines the end point of the arc */
  4945. endPoint: Vector2;
  4946. /**
  4947. * Defines the center point of the arc.
  4948. */
  4949. centerPoint: Vector2;
  4950. /**
  4951. * Defines the radius of the arc.
  4952. */
  4953. radius: number;
  4954. /**
  4955. * Defines the angle of the arc (from mid point to end point).
  4956. */
  4957. angle: Angle;
  4958. /**
  4959. * Defines the start angle of the arc (from start point to middle point).
  4960. */
  4961. startAngle: Angle;
  4962. /**
  4963. * Defines the orientation of the arc (clock wise/counter clock wise).
  4964. */
  4965. orientation: Orientation;
  4966. /**
  4967. * Creates an Arc object from the three given points : start, middle and end.
  4968. * @param startPoint Defines the start point of the arc
  4969. * @param midPoint Defines the midlle point of the arc
  4970. * @param endPoint Defines the end point of the arc
  4971. */
  4972. constructor(
  4973. /** Defines the start point of the arc */
  4974. startPoint: Vector2,
  4975. /** Defines the mid point of the arc */
  4976. midPoint: Vector2,
  4977. /** Defines the end point of the arc */
  4978. endPoint: Vector2);
  4979. }
  4980. /**
  4981. * Represents a 2D path made up of multiple 2D points
  4982. */
  4983. export class Path2 {
  4984. private _points;
  4985. private _length;
  4986. /**
  4987. * If the path start and end point are the same
  4988. */
  4989. closed: boolean;
  4990. /**
  4991. * Creates a Path2 object from the starting 2D coordinates x and y.
  4992. * @param x the starting points x value
  4993. * @param y the starting points y value
  4994. */
  4995. constructor(x: number, y: number);
  4996. /**
  4997. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4998. * @param x the added points x value
  4999. * @param y the added points y value
  5000. * @returns the updated Path2.
  5001. */
  5002. addLineTo(x: number, y: number): Path2;
  5003. /**
  5004. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5005. * @param midX middle point x value
  5006. * @param midY middle point y value
  5007. * @param endX end point x value
  5008. * @param endY end point y value
  5009. * @param numberOfSegments (default: 36)
  5010. * @returns the updated Path2.
  5011. */
  5012. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5013. /**
  5014. * Closes the Path2.
  5015. * @returns the Path2.
  5016. */
  5017. close(): Path2;
  5018. /**
  5019. * Gets the sum of the distance between each sequential point in the path
  5020. * @returns the Path2 total length (float).
  5021. */
  5022. length(): number;
  5023. /**
  5024. * Gets the points which construct the path
  5025. * @returns the Path2 internal array of points.
  5026. */
  5027. getPoints(): Vector2[];
  5028. /**
  5029. * Retreives the point at the distance aways from the starting point
  5030. * @param normalizedLengthPosition the length along the path to retreive the point from
  5031. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5032. */
  5033. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5034. /**
  5035. * Creates a new path starting from an x and y position
  5036. * @param x starting x value
  5037. * @param y starting y value
  5038. * @returns a new Path2 starting at the coordinates (x, y).
  5039. */
  5040. static StartingAt(x: number, y: number): Path2;
  5041. }
  5042. /**
  5043. * Represents a 3D path made up of multiple 3D points
  5044. */
  5045. export class Path3D {
  5046. /**
  5047. * an array of Vector3, the curve axis of the Path3D
  5048. */
  5049. path: Vector3[];
  5050. private _curve;
  5051. private _distances;
  5052. private _tangents;
  5053. private _normals;
  5054. private _binormals;
  5055. private _raw;
  5056. private _alignTangentsWithPath;
  5057. private readonly _pointAtData;
  5058. /**
  5059. * new Path3D(path, normal, raw)
  5060. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5061. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5062. * @param path an array of Vector3, the curve axis of the Path3D
  5063. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5064. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5065. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5066. */
  5067. constructor(
  5068. /**
  5069. * an array of Vector3, the curve axis of the Path3D
  5070. */
  5071. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5072. /**
  5073. * Returns the Path3D array of successive Vector3 designing its curve.
  5074. * @returns the Path3D array of successive Vector3 designing its curve.
  5075. */
  5076. getCurve(): Vector3[];
  5077. /**
  5078. * Returns the Path3D array of successive Vector3 designing its curve.
  5079. * @returns the Path3D array of successive Vector3 designing its curve.
  5080. */
  5081. getPoints(): Vector3[];
  5082. /**
  5083. * @returns the computed length (float) of the path.
  5084. */
  5085. length(): number;
  5086. /**
  5087. * Returns an array populated with tangent vectors on each Path3D curve point.
  5088. * @returns an array populated with tangent vectors on each Path3D curve point.
  5089. */
  5090. getTangents(): Vector3[];
  5091. /**
  5092. * Returns an array populated with normal vectors on each Path3D curve point.
  5093. * @returns an array populated with normal vectors on each Path3D curve point.
  5094. */
  5095. getNormals(): Vector3[];
  5096. /**
  5097. * Returns an array populated with binormal vectors on each Path3D curve point.
  5098. * @returns an array populated with binormal vectors on each Path3D curve point.
  5099. */
  5100. getBinormals(): Vector3[];
  5101. /**
  5102. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5103. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5104. */
  5105. getDistances(): number[];
  5106. /**
  5107. * Returns an interpolated point along this path
  5108. * @param position the position of the point along this path, from 0.0 to 1.0
  5109. * @returns a new Vector3 as the point
  5110. */
  5111. getPointAt(position: number): Vector3;
  5112. /**
  5113. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5114. * @param position the position of the point along this path, from 0.0 to 1.0
  5115. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5116. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5117. */
  5118. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5119. /**
  5120. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5121. * @param position the position of the point along this path, from 0.0 to 1.0
  5122. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5123. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5124. */
  5125. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5126. /**
  5127. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5128. * @param position the position of the point along this path, from 0.0 to 1.0
  5129. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5130. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5131. */
  5132. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5133. /**
  5134. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5135. * @param position the position of the point along this path, from 0.0 to 1.0
  5136. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5137. */
  5138. getDistanceAt(position: number): number;
  5139. /**
  5140. * Returns the array index of the previous point of an interpolated point along this path
  5141. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5142. * @returns the array index
  5143. */
  5144. getPreviousPointIndexAt(position: number): number;
  5145. /**
  5146. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5147. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5148. * @returns the sub position
  5149. */
  5150. getSubPositionAt(position: number): number;
  5151. /**
  5152. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5153. * @param target the vector of which to get the closest position to
  5154. * @returns the position of the closest virtual point on this path to the target vector
  5155. */
  5156. getClosestPositionTo(target: Vector3): number;
  5157. /**
  5158. * Returns a sub path (slice) of this path
  5159. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5160. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5161. * @returns a sub path (slice) of this path
  5162. */
  5163. slice(start?: number, end?: number): Path3D;
  5164. /**
  5165. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5166. * @param path path which all values are copied into the curves points
  5167. * @param firstNormal which should be projected onto the curve
  5168. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5169. * @returns the same object updated.
  5170. */
  5171. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5172. private _compute;
  5173. private _getFirstNonNullVector;
  5174. private _getLastNonNullVector;
  5175. private _normalVector;
  5176. /**
  5177. * Updates the point at data for an interpolated point along this curve
  5178. * @param position the position of the point along this curve, from 0.0 to 1.0
  5179. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5180. * @returns the (updated) point at data
  5181. */
  5182. private _updatePointAtData;
  5183. /**
  5184. * Updates the point at data from the specified parameters
  5185. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5186. * @param point the interpolated point
  5187. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5188. */
  5189. private _setPointAtData;
  5190. /**
  5191. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5192. */
  5193. private _updateInterpolationMatrix;
  5194. }
  5195. /**
  5196. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5197. * A Curve3 is designed from a series of successive Vector3.
  5198. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5199. */
  5200. export class Curve3 {
  5201. private _points;
  5202. private _length;
  5203. /**
  5204. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5205. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5206. * @param v1 (Vector3) the control point
  5207. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5208. * @param nbPoints (integer) the wanted number of points in the curve
  5209. * @returns the created Curve3
  5210. */
  5211. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5212. /**
  5213. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5214. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5215. * @param v1 (Vector3) the first control point
  5216. * @param v2 (Vector3) the second control point
  5217. * @param v3 (Vector3) the end point of the Cubic Bezier
  5218. * @param nbPoints (integer) the wanted number of points in the curve
  5219. * @returns the created Curve3
  5220. */
  5221. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5222. /**
  5223. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5224. * @param p1 (Vector3) the origin point of the Hermite Spline
  5225. * @param t1 (Vector3) the tangent vector at the origin point
  5226. * @param p2 (Vector3) the end point of the Hermite Spline
  5227. * @param t2 (Vector3) the tangent vector at the end point
  5228. * @param nbPoints (integer) the wanted number of points in the curve
  5229. * @returns the created Curve3
  5230. */
  5231. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5232. /**
  5233. * Returns a Curve3 object along a CatmullRom Spline curve :
  5234. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5235. * @param nbPoints (integer) the wanted number of points between each curve control points
  5236. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5237. * @returns the created Curve3
  5238. */
  5239. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5240. /**
  5241. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5242. * A Curve3 is designed from a series of successive Vector3.
  5243. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5244. * @param points points which make up the curve
  5245. */
  5246. constructor(points: Vector3[]);
  5247. /**
  5248. * @returns the Curve3 stored array of successive Vector3
  5249. */
  5250. getPoints(): Vector3[];
  5251. /**
  5252. * @returns the computed length (float) of the curve.
  5253. */
  5254. length(): number;
  5255. /**
  5256. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5257. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5258. * curveA and curveB keep unchanged.
  5259. * @param curve the curve to continue from this curve
  5260. * @returns the newly constructed curve
  5261. */
  5262. continue(curve: DeepImmutable<Curve3>): Curve3;
  5263. private _computeLength;
  5264. }
  5265. }
  5266. declare module BABYLON {
  5267. /**
  5268. * This represents the main contract an easing function should follow.
  5269. * Easing functions are used throughout the animation system.
  5270. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5271. */
  5272. export interface IEasingFunction {
  5273. /**
  5274. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5275. * of the easing function.
  5276. * The link below provides some of the most common examples of easing functions.
  5277. * @see https://easings.net/
  5278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5279. * @returns the corresponding value on the curve defined by the easing function
  5280. */
  5281. ease(gradient: number): number;
  5282. }
  5283. /**
  5284. * Base class used for every default easing function.
  5285. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5286. */
  5287. export class EasingFunction implements IEasingFunction {
  5288. /**
  5289. * Interpolation follows the mathematical formula associated with the easing function.
  5290. */
  5291. static readonly EASINGMODE_EASEIN: number;
  5292. /**
  5293. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5294. */
  5295. static readonly EASINGMODE_EASEOUT: number;
  5296. /**
  5297. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5298. */
  5299. static readonly EASINGMODE_EASEINOUT: number;
  5300. private _easingMode;
  5301. /**
  5302. * Sets the easing mode of the current function.
  5303. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5304. */
  5305. setEasingMode(easingMode: number): void;
  5306. /**
  5307. * Gets the current easing mode.
  5308. * @returns the easing mode
  5309. */
  5310. getEasingMode(): number;
  5311. /**
  5312. * @hidden
  5313. */
  5314. easeInCore(gradient: number): number;
  5315. /**
  5316. * Given an input gradient between 0 and 1, this returns the corresponding value
  5317. * of the easing function.
  5318. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5319. * @returns the corresponding value on the curve defined by the easing function
  5320. */
  5321. ease(gradient: number): number;
  5322. }
  5323. /**
  5324. * Easing function with a circle shape (see link below).
  5325. * @see https://easings.net/#easeInCirc
  5326. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5327. */
  5328. export class CircleEase extends EasingFunction implements IEasingFunction {
  5329. /** @hidden */
  5330. easeInCore(gradient: number): number;
  5331. }
  5332. /**
  5333. * Easing function with a ease back shape (see link below).
  5334. * @see https://easings.net/#easeInBack
  5335. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5336. */
  5337. export class BackEase extends EasingFunction implements IEasingFunction {
  5338. /** Defines the amplitude of the function */
  5339. amplitude: number;
  5340. /**
  5341. * Instantiates a back ease easing
  5342. * @see https://easings.net/#easeInBack
  5343. * @param amplitude Defines the amplitude of the function
  5344. */
  5345. constructor(
  5346. /** Defines the amplitude of the function */
  5347. amplitude?: number);
  5348. /** @hidden */
  5349. easeInCore(gradient: number): number;
  5350. }
  5351. /**
  5352. * Easing function with a bouncing shape (see link below).
  5353. * @see https://easings.net/#easeInBounce
  5354. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5355. */
  5356. export class BounceEase extends EasingFunction implements IEasingFunction {
  5357. /** Defines the number of bounces */
  5358. bounces: number;
  5359. /** Defines the amplitude of the bounce */
  5360. bounciness: number;
  5361. /**
  5362. * Instantiates a bounce easing
  5363. * @see https://easings.net/#easeInBounce
  5364. * @param bounces Defines the number of bounces
  5365. * @param bounciness Defines the amplitude of the bounce
  5366. */
  5367. constructor(
  5368. /** Defines the number of bounces */
  5369. bounces?: number,
  5370. /** Defines the amplitude of the bounce */
  5371. bounciness?: number);
  5372. /** @hidden */
  5373. easeInCore(gradient: number): number;
  5374. }
  5375. /**
  5376. * Easing function with a power of 3 shape (see link below).
  5377. * @see https://easings.net/#easeInCubic
  5378. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5379. */
  5380. export class CubicEase extends EasingFunction implements IEasingFunction {
  5381. /** @hidden */
  5382. easeInCore(gradient: number): number;
  5383. }
  5384. /**
  5385. * Easing function with an elastic shape (see link below).
  5386. * @see https://easings.net/#easeInElastic
  5387. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5388. */
  5389. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5390. /** Defines the number of oscillations*/
  5391. oscillations: number;
  5392. /** Defines the amplitude of the oscillations*/
  5393. springiness: number;
  5394. /**
  5395. * Instantiates an elastic easing function
  5396. * @see https://easings.net/#easeInElastic
  5397. * @param oscillations Defines the number of oscillations
  5398. * @param springiness Defines the amplitude of the oscillations
  5399. */
  5400. constructor(
  5401. /** Defines the number of oscillations*/
  5402. oscillations?: number,
  5403. /** Defines the amplitude of the oscillations*/
  5404. springiness?: number);
  5405. /** @hidden */
  5406. easeInCore(gradient: number): number;
  5407. }
  5408. /**
  5409. * Easing function with an exponential shape (see link below).
  5410. * @see https://easings.net/#easeInExpo
  5411. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5412. */
  5413. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5414. /** Defines the exponent of the function */
  5415. exponent: number;
  5416. /**
  5417. * Instantiates an exponential easing function
  5418. * @see https://easings.net/#easeInExpo
  5419. * @param exponent Defines the exponent of the function
  5420. */
  5421. constructor(
  5422. /** Defines the exponent of the function */
  5423. exponent?: number);
  5424. /** @hidden */
  5425. easeInCore(gradient: number): number;
  5426. }
  5427. /**
  5428. * Easing function with a power shape (see link below).
  5429. * @see https://easings.net/#easeInQuad
  5430. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5431. */
  5432. export class PowerEase extends EasingFunction implements IEasingFunction {
  5433. /** Defines the power of the function */
  5434. power: number;
  5435. /**
  5436. * Instantiates an power base easing function
  5437. * @see https://easings.net/#easeInQuad
  5438. * @param power Defines the power of the function
  5439. */
  5440. constructor(
  5441. /** Defines the power of the function */
  5442. power?: number);
  5443. /** @hidden */
  5444. easeInCore(gradient: number): number;
  5445. }
  5446. /**
  5447. * Easing function with a power of 2 shape (see link below).
  5448. * @see https://easings.net/#easeInQuad
  5449. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5450. */
  5451. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5452. /** @hidden */
  5453. easeInCore(gradient: number): number;
  5454. }
  5455. /**
  5456. * Easing function with a power of 4 shape (see link below).
  5457. * @see https://easings.net/#easeInQuart
  5458. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5459. */
  5460. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5461. /** @hidden */
  5462. easeInCore(gradient: number): number;
  5463. }
  5464. /**
  5465. * Easing function with a power of 5 shape (see link below).
  5466. * @see https://easings.net/#easeInQuint
  5467. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5468. */
  5469. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5470. /** @hidden */
  5471. easeInCore(gradient: number): number;
  5472. }
  5473. /**
  5474. * Easing function with a sin shape (see link below).
  5475. * @see https://easings.net/#easeInSine
  5476. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5477. */
  5478. export class SineEase extends EasingFunction implements IEasingFunction {
  5479. /** @hidden */
  5480. easeInCore(gradient: number): number;
  5481. }
  5482. /**
  5483. * Easing function with a bezier shape (see link below).
  5484. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5485. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5486. */
  5487. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5488. /** Defines the x component of the start tangent in the bezier curve */
  5489. x1: number;
  5490. /** Defines the y component of the start tangent in the bezier curve */
  5491. y1: number;
  5492. /** Defines the x component of the end tangent in the bezier curve */
  5493. x2: number;
  5494. /** Defines the y component of the end tangent in the bezier curve */
  5495. y2: number;
  5496. /**
  5497. * Instantiates a bezier function
  5498. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5499. * @param x1 Defines the x component of the start tangent in the bezier curve
  5500. * @param y1 Defines the y component of the start tangent in the bezier curve
  5501. * @param x2 Defines the x component of the end tangent in the bezier curve
  5502. * @param y2 Defines the y component of the end tangent in the bezier curve
  5503. */
  5504. constructor(
  5505. /** Defines the x component of the start tangent in the bezier curve */
  5506. x1?: number,
  5507. /** Defines the y component of the start tangent in the bezier curve */
  5508. y1?: number,
  5509. /** Defines the x component of the end tangent in the bezier curve */
  5510. x2?: number,
  5511. /** Defines the y component of the end tangent in the bezier curve */
  5512. y2?: number);
  5513. /** @hidden */
  5514. easeInCore(gradient: number): number;
  5515. }
  5516. }
  5517. declare module BABYLON {
  5518. /**
  5519. * Class used to hold a RBG color
  5520. */
  5521. export class Color3 {
  5522. /**
  5523. * Defines the red component (between 0 and 1, default is 0)
  5524. */
  5525. r: number;
  5526. /**
  5527. * Defines the green component (between 0 and 1, default is 0)
  5528. */
  5529. g: number;
  5530. /**
  5531. * Defines the blue component (between 0 and 1, default is 0)
  5532. */
  5533. b: number;
  5534. /**
  5535. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5536. * @param r defines the red component (between 0 and 1, default is 0)
  5537. * @param g defines the green component (between 0 and 1, default is 0)
  5538. * @param b defines the blue component (between 0 and 1, default is 0)
  5539. */
  5540. constructor(
  5541. /**
  5542. * Defines the red component (between 0 and 1, default is 0)
  5543. */
  5544. r?: number,
  5545. /**
  5546. * Defines the green component (between 0 and 1, default is 0)
  5547. */
  5548. g?: number,
  5549. /**
  5550. * Defines the blue component (between 0 and 1, default is 0)
  5551. */
  5552. b?: number);
  5553. /**
  5554. * Creates a string with the Color3 current values
  5555. * @returns the string representation of the Color3 object
  5556. */
  5557. toString(): string;
  5558. /**
  5559. * Returns the string "Color3"
  5560. * @returns "Color3"
  5561. */
  5562. getClassName(): string;
  5563. /**
  5564. * Compute the Color3 hash code
  5565. * @returns an unique number that can be used to hash Color3 objects
  5566. */
  5567. getHashCode(): number;
  5568. /**
  5569. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5570. * @param array defines the array where to store the r,g,b components
  5571. * @param index defines an optional index in the target array to define where to start storing values
  5572. * @returns the current Color3 object
  5573. */
  5574. toArray(array: FloatArray, index?: number): Color3;
  5575. /**
  5576. * Update the current color with values stored in an array from the starting index of the given array
  5577. * @param array defines the source array
  5578. * @param offset defines an offset in the source array
  5579. * @returns the current Color3 object
  5580. */
  5581. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5582. /**
  5583. * Returns a new Color4 object from the current Color3 and the given alpha
  5584. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5585. * @returns a new Color4 object
  5586. */
  5587. toColor4(alpha?: number): Color4;
  5588. /**
  5589. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5590. * @returns the new array
  5591. */
  5592. asArray(): number[];
  5593. /**
  5594. * Returns the luminance value
  5595. * @returns a float value
  5596. */
  5597. toLuminance(): number;
  5598. /**
  5599. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5600. * @param otherColor defines the second operand
  5601. * @returns the new Color3 object
  5602. */
  5603. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5604. /**
  5605. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5606. * @param otherColor defines the second operand
  5607. * @param result defines the Color3 object where to store the result
  5608. * @returns the current Color3
  5609. */
  5610. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5611. /**
  5612. * Determines equality between Color3 objects
  5613. * @param otherColor defines the second operand
  5614. * @returns true if the rgb values are equal to the given ones
  5615. */
  5616. equals(otherColor: DeepImmutable<Color3>): boolean;
  5617. /**
  5618. * Determines equality between the current Color3 object and a set of r,b,g values
  5619. * @param r defines the red component to check
  5620. * @param g defines the green component to check
  5621. * @param b defines the blue component to check
  5622. * @returns true if the rgb values are equal to the given ones
  5623. */
  5624. equalsFloats(r: number, g: number, b: number): boolean;
  5625. /**
  5626. * Multiplies in place each rgb value by scale
  5627. * @param scale defines the scaling factor
  5628. * @returns the updated Color3
  5629. */
  5630. scale(scale: number): Color3;
  5631. /**
  5632. * Multiplies the rgb values by scale and stores the result into "result"
  5633. * @param scale defines the scaling factor
  5634. * @param result defines the Color3 object where to store the result
  5635. * @returns the unmodified current Color3
  5636. */
  5637. scaleToRef(scale: number, result: Color3): Color3;
  5638. /**
  5639. * Scale the current Color3 values by a factor and add the result to a given Color3
  5640. * @param scale defines the scale factor
  5641. * @param result defines color to store the result into
  5642. * @returns the unmodified current Color3
  5643. */
  5644. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5645. /**
  5646. * Clamps the rgb values by the min and max values and stores the result into "result"
  5647. * @param min defines minimum clamping value (default is 0)
  5648. * @param max defines maximum clamping value (default is 1)
  5649. * @param result defines color to store the result into
  5650. * @returns the original Color3
  5651. */
  5652. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5653. /**
  5654. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5655. * @param otherColor defines the second operand
  5656. * @returns the new Color3
  5657. */
  5658. add(otherColor: DeepImmutable<Color3>): Color3;
  5659. /**
  5660. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5661. * @param otherColor defines the second operand
  5662. * @param result defines Color3 object to store the result into
  5663. * @returns the unmodified current Color3
  5664. */
  5665. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5666. /**
  5667. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5668. * @param otherColor defines the second operand
  5669. * @returns the new Color3
  5670. */
  5671. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5672. /**
  5673. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5674. * @param otherColor defines the second operand
  5675. * @param result defines Color3 object to store the result into
  5676. * @returns the unmodified current Color3
  5677. */
  5678. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5679. /**
  5680. * Copy the current object
  5681. * @returns a new Color3 copied the current one
  5682. */
  5683. clone(): Color3;
  5684. /**
  5685. * Copies the rgb values from the source in the current Color3
  5686. * @param source defines the source Color3 object
  5687. * @returns the updated Color3 object
  5688. */
  5689. copyFrom(source: DeepImmutable<Color3>): Color3;
  5690. /**
  5691. * Updates the Color3 rgb values from the given floats
  5692. * @param r defines the red component to read from
  5693. * @param g defines the green component to read from
  5694. * @param b defines the blue component to read from
  5695. * @returns the current Color3 object
  5696. */
  5697. copyFromFloats(r: number, g: number, b: number): Color3;
  5698. /**
  5699. * Updates the Color3 rgb values from the given floats
  5700. * @param r defines the red component to read from
  5701. * @param g defines the green component to read from
  5702. * @param b defines the blue component to read from
  5703. * @returns the current Color3 object
  5704. */
  5705. set(r: number, g: number, b: number): Color3;
  5706. /**
  5707. * Compute the Color3 hexadecimal code as a string
  5708. * @returns a string containing the hexadecimal representation of the Color3 object
  5709. */
  5710. toHexString(): string;
  5711. /**
  5712. * Computes a new Color3 converted from the current one to linear space
  5713. * @returns a new Color3 object
  5714. */
  5715. toLinearSpace(): Color3;
  5716. /**
  5717. * Converts current color in rgb space to HSV values
  5718. * @returns a new color3 representing the HSV values
  5719. */
  5720. toHSV(): Color3;
  5721. /**
  5722. * Converts current color in rgb space to HSV values
  5723. * @param result defines the Color3 where to store the HSV values
  5724. */
  5725. toHSVToRef(result: Color3): void;
  5726. /**
  5727. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5728. * @param convertedColor defines the Color3 object where to store the linear space version
  5729. * @returns the unmodified Color3
  5730. */
  5731. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5732. /**
  5733. * Computes a new Color3 converted from the current one to gamma space
  5734. * @returns a new Color3 object
  5735. */
  5736. toGammaSpace(): Color3;
  5737. /**
  5738. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5739. * @param convertedColor defines the Color3 object where to store the gamma space version
  5740. * @returns the unmodified Color3
  5741. */
  5742. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5743. private static _BlackReadOnly;
  5744. /**
  5745. * Convert Hue, saturation and value to a Color3 (RGB)
  5746. * @param hue defines the hue
  5747. * @param saturation defines the saturation
  5748. * @param value defines the value
  5749. * @param result defines the Color3 where to store the RGB values
  5750. */
  5751. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5752. /**
  5753. * Creates a new Color3 from the string containing valid hexadecimal values
  5754. * @param hex defines a string containing valid hexadecimal values
  5755. * @returns a new Color3 object
  5756. */
  5757. static FromHexString(hex: string): Color3;
  5758. /**
  5759. * Creates a new Color3 from the starting index of the given array
  5760. * @param array defines the source array
  5761. * @param offset defines an offset in the source array
  5762. * @returns a new Color3 object
  5763. */
  5764. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5765. /**
  5766. * Creates a new Color3 from the starting index element of the given array
  5767. * @param array defines the source array to read from
  5768. * @param offset defines the offset in the source array
  5769. * @param result defines the target Color3 object
  5770. */
  5771. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5772. /**
  5773. * Creates a new Color3 from integer values (< 256)
  5774. * @param r defines the red component to read from (value between 0 and 255)
  5775. * @param g defines the green component to read from (value between 0 and 255)
  5776. * @param b defines the blue component to read from (value between 0 and 255)
  5777. * @returns a new Color3 object
  5778. */
  5779. static FromInts(r: number, g: number, b: number): Color3;
  5780. /**
  5781. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5782. * @param start defines the start Color3 value
  5783. * @param end defines the end Color3 value
  5784. * @param amount defines the gradient value between start and end
  5785. * @returns a new Color3 object
  5786. */
  5787. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5788. /**
  5789. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5790. * @param left defines the start value
  5791. * @param right defines the end value
  5792. * @param amount defines the gradient factor
  5793. * @param result defines the Color3 object where to store the result
  5794. */
  5795. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5796. /**
  5797. * Returns a Color3 value containing a red color
  5798. * @returns a new Color3 object
  5799. */
  5800. static Red(): Color3;
  5801. /**
  5802. * Returns a Color3 value containing a green color
  5803. * @returns a new Color3 object
  5804. */
  5805. static Green(): Color3;
  5806. /**
  5807. * Returns a Color3 value containing a blue color
  5808. * @returns a new Color3 object
  5809. */
  5810. static Blue(): Color3;
  5811. /**
  5812. * Returns a Color3 value containing a black color
  5813. * @returns a new Color3 object
  5814. */
  5815. static Black(): Color3;
  5816. /**
  5817. * Gets a Color3 value containing a black color that must not be updated
  5818. */
  5819. static get BlackReadOnly(): DeepImmutable<Color3>;
  5820. /**
  5821. * Returns a Color3 value containing a white color
  5822. * @returns a new Color3 object
  5823. */
  5824. static White(): Color3;
  5825. /**
  5826. * Returns a Color3 value containing a purple color
  5827. * @returns a new Color3 object
  5828. */
  5829. static Purple(): Color3;
  5830. /**
  5831. * Returns a Color3 value containing a magenta color
  5832. * @returns a new Color3 object
  5833. */
  5834. static Magenta(): Color3;
  5835. /**
  5836. * Returns a Color3 value containing a yellow color
  5837. * @returns a new Color3 object
  5838. */
  5839. static Yellow(): Color3;
  5840. /**
  5841. * Returns a Color3 value containing a gray color
  5842. * @returns a new Color3 object
  5843. */
  5844. static Gray(): Color3;
  5845. /**
  5846. * Returns a Color3 value containing a teal color
  5847. * @returns a new Color3 object
  5848. */
  5849. static Teal(): Color3;
  5850. /**
  5851. * Returns a Color3 value containing a random color
  5852. * @returns a new Color3 object
  5853. */
  5854. static Random(): Color3;
  5855. }
  5856. /**
  5857. * Class used to hold a RBGA color
  5858. */
  5859. export class Color4 {
  5860. /**
  5861. * Defines the red component (between 0 and 1, default is 0)
  5862. */
  5863. r: number;
  5864. /**
  5865. * Defines the green component (between 0 and 1, default is 0)
  5866. */
  5867. g: number;
  5868. /**
  5869. * Defines the blue component (between 0 and 1, default is 0)
  5870. */
  5871. b: number;
  5872. /**
  5873. * Defines the alpha component (between 0 and 1, default is 1)
  5874. */
  5875. a: number;
  5876. /**
  5877. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5878. * @param r defines the red component (between 0 and 1, default is 0)
  5879. * @param g defines the green component (between 0 and 1, default is 0)
  5880. * @param b defines the blue component (between 0 and 1, default is 0)
  5881. * @param a defines the alpha component (between 0 and 1, default is 1)
  5882. */
  5883. constructor(
  5884. /**
  5885. * Defines the red component (between 0 and 1, default is 0)
  5886. */
  5887. r?: number,
  5888. /**
  5889. * Defines the green component (between 0 and 1, default is 0)
  5890. */
  5891. g?: number,
  5892. /**
  5893. * Defines the blue component (between 0 and 1, default is 0)
  5894. */
  5895. b?: number,
  5896. /**
  5897. * Defines the alpha component (between 0 and 1, default is 1)
  5898. */
  5899. a?: number);
  5900. /**
  5901. * Adds in place the given Color4 values to the current Color4 object
  5902. * @param right defines the second operand
  5903. * @returns the current updated Color4 object
  5904. */
  5905. addInPlace(right: DeepImmutable<Color4>): Color4;
  5906. /**
  5907. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5908. * @returns the new array
  5909. */
  5910. asArray(): number[];
  5911. /**
  5912. * Stores from the starting index in the given array the Color4 successive values
  5913. * @param array defines the array where to store the r,g,b components
  5914. * @param index defines an optional index in the target array to define where to start storing values
  5915. * @returns the current Color4 object
  5916. */
  5917. toArray(array: number[], index?: number): Color4;
  5918. /**
  5919. * Update the current color with values stored in an array from the starting index of the given array
  5920. * @param array defines the source array
  5921. * @param offset defines an offset in the source array
  5922. * @returns the current Color4 object
  5923. */
  5924. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5925. /**
  5926. * Determines equality between Color4 objects
  5927. * @param otherColor defines the second operand
  5928. * @returns true if the rgba values are equal to the given ones
  5929. */
  5930. equals(otherColor: DeepImmutable<Color4>): boolean;
  5931. /**
  5932. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5933. * @param right defines the second operand
  5934. * @returns a new Color4 object
  5935. */
  5936. add(right: DeepImmutable<Color4>): Color4;
  5937. /**
  5938. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5939. * @param right defines the second operand
  5940. * @returns a new Color4 object
  5941. */
  5942. subtract(right: DeepImmutable<Color4>): Color4;
  5943. /**
  5944. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5945. * @param right defines the second operand
  5946. * @param result defines the Color4 object where to store the result
  5947. * @returns the current Color4 object
  5948. */
  5949. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5950. /**
  5951. * Creates a new Color4 with the current Color4 values multiplied by scale
  5952. * @param scale defines the scaling factor to apply
  5953. * @returns a new Color4 object
  5954. */
  5955. scale(scale: number): Color4;
  5956. /**
  5957. * Multiplies the current Color4 values by scale and stores the result in "result"
  5958. * @param scale defines the scaling factor to apply
  5959. * @param result defines the Color4 object where to store the result
  5960. * @returns the current unmodified Color4
  5961. */
  5962. scaleToRef(scale: number, result: Color4): Color4;
  5963. /**
  5964. * Scale the current Color4 values by a factor and add the result to a given Color4
  5965. * @param scale defines the scale factor
  5966. * @param result defines the Color4 object where to store the result
  5967. * @returns the unmodified current Color4
  5968. */
  5969. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5970. /**
  5971. * Clamps the rgb values by the min and max values and stores the result into "result"
  5972. * @param min defines minimum clamping value (default is 0)
  5973. * @param max defines maximum clamping value (default is 1)
  5974. * @param result defines color to store the result into.
  5975. * @returns the cuurent Color4
  5976. */
  5977. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5978. /**
  5979. * Multipy an Color4 value by another and return a new Color4 object
  5980. * @param color defines the Color4 value to multiply by
  5981. * @returns a new Color4 object
  5982. */
  5983. multiply(color: Color4): Color4;
  5984. /**
  5985. * Multipy a Color4 value by another and push the result in a reference value
  5986. * @param color defines the Color4 value to multiply by
  5987. * @param result defines the Color4 to fill the result in
  5988. * @returns the result Color4
  5989. */
  5990. multiplyToRef(color: Color4, result: Color4): Color4;
  5991. /**
  5992. * Creates a string with the Color4 current values
  5993. * @returns the string representation of the Color4 object
  5994. */
  5995. toString(): string;
  5996. /**
  5997. * Returns the string "Color4"
  5998. * @returns "Color4"
  5999. */
  6000. getClassName(): string;
  6001. /**
  6002. * Compute the Color4 hash code
  6003. * @returns an unique number that can be used to hash Color4 objects
  6004. */
  6005. getHashCode(): number;
  6006. /**
  6007. * Creates a new Color4 copied from the current one
  6008. * @returns a new Color4 object
  6009. */
  6010. clone(): Color4;
  6011. /**
  6012. * Copies the given Color4 values into the current one
  6013. * @param source defines the source Color4 object
  6014. * @returns the current updated Color4 object
  6015. */
  6016. copyFrom(source: Color4): Color4;
  6017. /**
  6018. * Copies the given float values into the current one
  6019. * @param r defines the red component to read from
  6020. * @param g defines the green component to read from
  6021. * @param b defines the blue component to read from
  6022. * @param a defines the alpha component to read from
  6023. * @returns the current updated Color4 object
  6024. */
  6025. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6026. /**
  6027. * Copies the given float values into the current one
  6028. * @param r defines the red component to read from
  6029. * @param g defines the green component to read from
  6030. * @param b defines the blue component to read from
  6031. * @param a defines the alpha component to read from
  6032. * @returns the current updated Color4 object
  6033. */
  6034. set(r: number, g: number, b: number, a: number): Color4;
  6035. /**
  6036. * Compute the Color4 hexadecimal code as a string
  6037. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6038. * @returns a string containing the hexadecimal representation of the Color4 object
  6039. */
  6040. toHexString(returnAsColor3?: boolean): string;
  6041. /**
  6042. * Computes a new Color4 converted from the current one to linear space
  6043. * @returns a new Color4 object
  6044. */
  6045. toLinearSpace(): Color4;
  6046. /**
  6047. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6048. * @param convertedColor defines the Color4 object where to store the linear space version
  6049. * @returns the unmodified Color4
  6050. */
  6051. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6052. /**
  6053. * Computes a new Color4 converted from the current one to gamma space
  6054. * @returns a new Color4 object
  6055. */
  6056. toGammaSpace(): Color4;
  6057. /**
  6058. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6059. * @param convertedColor defines the Color4 object where to store the gamma space version
  6060. * @returns the unmodified Color4
  6061. */
  6062. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6063. /**
  6064. * Creates a new Color4 from the string containing valid hexadecimal values
  6065. * @param hex defines a string containing valid hexadecimal values
  6066. * @returns a new Color4 object
  6067. */
  6068. static FromHexString(hex: string): Color4;
  6069. /**
  6070. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6071. * @param left defines the start value
  6072. * @param right defines the end value
  6073. * @param amount defines the gradient factor
  6074. * @returns a new Color4 object
  6075. */
  6076. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6077. /**
  6078. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6079. * @param left defines the start value
  6080. * @param right defines the end value
  6081. * @param amount defines the gradient factor
  6082. * @param result defines the Color4 object where to store data
  6083. */
  6084. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6085. /**
  6086. * Creates a new Color4 from a Color3 and an alpha value
  6087. * @param color3 defines the source Color3 to read from
  6088. * @param alpha defines the alpha component (1.0 by default)
  6089. * @returns a new Color4 object
  6090. */
  6091. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6092. /**
  6093. * Creates a new Color4 from the starting index element of the given array
  6094. * @param array defines the source array to read from
  6095. * @param offset defines the offset in the source array
  6096. * @returns a new Color4 object
  6097. */
  6098. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6099. /**
  6100. * Creates a new Color4 from the starting index element of the given array
  6101. * @param array defines the source array to read from
  6102. * @param offset defines the offset in the source array
  6103. * @param result defines the target Color4 object
  6104. */
  6105. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6106. /**
  6107. * Creates a new Color3 from integer values (< 256)
  6108. * @param r defines the red component to read from (value between 0 and 255)
  6109. * @param g defines the green component to read from (value between 0 and 255)
  6110. * @param b defines the blue component to read from (value between 0 and 255)
  6111. * @param a defines the alpha component to read from (value between 0 and 255)
  6112. * @returns a new Color3 object
  6113. */
  6114. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6115. /**
  6116. * Check the content of a given array and convert it to an array containing RGBA data
  6117. * If the original array was already containing count * 4 values then it is returned directly
  6118. * @param colors defines the array to check
  6119. * @param count defines the number of RGBA data to expect
  6120. * @returns an array containing count * 4 values (RGBA)
  6121. */
  6122. static CheckColors4(colors: number[], count: number): number[];
  6123. }
  6124. /**
  6125. * @hidden
  6126. */
  6127. export class TmpColors {
  6128. static Color3: Color3[];
  6129. static Color4: Color4[];
  6130. }
  6131. }
  6132. declare module BABYLON {
  6133. /**
  6134. * Defines an interface which represents an animation key frame
  6135. */
  6136. export interface IAnimationKey {
  6137. /**
  6138. * Frame of the key frame
  6139. */
  6140. frame: number;
  6141. /**
  6142. * Value at the specifies key frame
  6143. */
  6144. value: any;
  6145. /**
  6146. * The input tangent for the cubic hermite spline
  6147. */
  6148. inTangent?: any;
  6149. /**
  6150. * The output tangent for the cubic hermite spline
  6151. */
  6152. outTangent?: any;
  6153. /**
  6154. * The animation interpolation type
  6155. */
  6156. interpolation?: AnimationKeyInterpolation;
  6157. }
  6158. /**
  6159. * Enum for the animation key frame interpolation type
  6160. */
  6161. export enum AnimationKeyInterpolation {
  6162. /**
  6163. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6164. */
  6165. STEP = 1
  6166. }
  6167. }
  6168. declare module BABYLON {
  6169. /**
  6170. * Represents the range of an animation
  6171. */
  6172. export class AnimationRange {
  6173. /**The name of the animation range**/
  6174. name: string;
  6175. /**The starting frame of the animation */
  6176. from: number;
  6177. /**The ending frame of the animation*/
  6178. to: number;
  6179. /**
  6180. * Initializes the range of an animation
  6181. * @param name The name of the animation range
  6182. * @param from The starting frame of the animation
  6183. * @param to The ending frame of the animation
  6184. */
  6185. constructor(
  6186. /**The name of the animation range**/
  6187. name: string,
  6188. /**The starting frame of the animation */
  6189. from: number,
  6190. /**The ending frame of the animation*/
  6191. to: number);
  6192. /**
  6193. * Makes a copy of the animation range
  6194. * @returns A copy of the animation range
  6195. */
  6196. clone(): AnimationRange;
  6197. }
  6198. }
  6199. declare module BABYLON {
  6200. /**
  6201. * Composed of a frame, and an action function
  6202. */
  6203. export class AnimationEvent {
  6204. /** The frame for which the event is triggered **/
  6205. frame: number;
  6206. /** The event to perform when triggered **/
  6207. action: (currentFrame: number) => void;
  6208. /** Specifies if the event should be triggered only once**/
  6209. onlyOnce?: boolean | undefined;
  6210. /**
  6211. * Specifies if the animation event is done
  6212. */
  6213. isDone: boolean;
  6214. /**
  6215. * Initializes the animation event
  6216. * @param frame The frame for which the event is triggered
  6217. * @param action The event to perform when triggered
  6218. * @param onlyOnce Specifies if the event should be triggered only once
  6219. */
  6220. constructor(
  6221. /** The frame for which the event is triggered **/
  6222. frame: number,
  6223. /** The event to perform when triggered **/
  6224. action: (currentFrame: number) => void,
  6225. /** Specifies if the event should be triggered only once**/
  6226. onlyOnce?: boolean | undefined);
  6227. /** @hidden */
  6228. _clone(): AnimationEvent;
  6229. }
  6230. }
  6231. declare module BABYLON {
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module BABYLON {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module BABYLON {
  6383. /**
  6384. * @ignore
  6385. * This is a list of all the different input types that are available in the application.
  6386. * Fo instance: ArcRotateCameraGamepadInput...
  6387. */
  6388. export var CameraInputTypes: {};
  6389. /**
  6390. * This is the contract to implement in order to create a new input class.
  6391. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6392. */
  6393. export interface ICameraInput<TCamera extends Camera> {
  6394. /**
  6395. * Defines the camera the input is attached to.
  6396. */
  6397. camera: Nullable<TCamera>;
  6398. /**
  6399. * Gets the class name of the current intput.
  6400. * @returns the class name
  6401. */
  6402. getClassName(): string;
  6403. /**
  6404. * Get the friendly name associated with the input class.
  6405. * @returns the input friendly name
  6406. */
  6407. getSimpleName(): string;
  6408. /**
  6409. * Attach the input controls to a specific dom element to get the input from.
  6410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6411. */
  6412. attachControl(noPreventDefault?: boolean): void;
  6413. /**
  6414. * Detach the current controls from the specified dom element.
  6415. */
  6416. detachControl(): void;
  6417. /**
  6418. * Update the current camera state depending on the inputs that have been used this frame.
  6419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6420. */
  6421. checkInputs?: () => void;
  6422. }
  6423. /**
  6424. * Represents a map of input types to input instance or input index to input instance.
  6425. */
  6426. export interface CameraInputsMap<TCamera extends Camera> {
  6427. /**
  6428. * Accessor to the input by input type.
  6429. */
  6430. [name: string]: ICameraInput<TCamera>;
  6431. /**
  6432. * Accessor to the input by input index.
  6433. */
  6434. [idx: number]: ICameraInput<TCamera>;
  6435. }
  6436. /**
  6437. * This represents the input manager used within a camera.
  6438. * It helps dealing with all the different kind of input attached to a camera.
  6439. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6440. */
  6441. export class CameraInputsManager<TCamera extends Camera> {
  6442. /**
  6443. * Defines the list of inputs attahed to the camera.
  6444. */
  6445. attached: CameraInputsMap<TCamera>;
  6446. /**
  6447. * Defines the dom element the camera is collecting inputs from.
  6448. * This is null if the controls have not been attached.
  6449. */
  6450. attachedToElement: boolean;
  6451. /**
  6452. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6453. */
  6454. noPreventDefault: boolean;
  6455. /**
  6456. * Defined the camera the input manager belongs to.
  6457. */
  6458. camera: TCamera;
  6459. /**
  6460. * Update the current camera state depending on the inputs that have been used this frame.
  6461. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6462. */
  6463. checkInputs: () => void;
  6464. /**
  6465. * Instantiate a new Camera Input Manager.
  6466. * @param camera Defines the camera the input manager blongs to
  6467. */
  6468. constructor(camera: TCamera);
  6469. /**
  6470. * Add an input method to a camera
  6471. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6472. * @param input camera input method
  6473. */
  6474. add(input: ICameraInput<TCamera>): void;
  6475. /**
  6476. * Remove a specific input method from a camera
  6477. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6478. * @param inputToRemove camera input method
  6479. */
  6480. remove(inputToRemove: ICameraInput<TCamera>): void;
  6481. /**
  6482. * Remove a specific input type from a camera
  6483. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6484. * @param inputType the type of the input to remove
  6485. */
  6486. removeByType(inputType: string): void;
  6487. private _addCheckInputs;
  6488. /**
  6489. * Attach the input controls to the currently attached dom element to listen the events from.
  6490. * @param input Defines the input to attach
  6491. */
  6492. attachInput(input: ICameraInput<TCamera>): void;
  6493. /**
  6494. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6495. * @param element Defines the dom element to collect the events from
  6496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6497. */
  6498. attachElement(noPreventDefault?: boolean): void;
  6499. /**
  6500. * Detach the current manager inputs controls from a specific dom element.
  6501. * @param element Defines the dom element to collect the events from
  6502. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6503. */
  6504. detachElement(disconnect?: boolean): void;
  6505. /**
  6506. * Rebuild the dynamic inputCheck function from the current list of
  6507. * defined inputs in the manager.
  6508. */
  6509. rebuildInputCheck(): void;
  6510. /**
  6511. * Remove all attached input methods from a camera
  6512. */
  6513. clear(): void;
  6514. /**
  6515. * Serialize the current input manager attached to a camera.
  6516. * This ensures than once parsed,
  6517. * the input associated to the camera will be identical to the current ones
  6518. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6519. */
  6520. serialize(serializedCamera: any): void;
  6521. /**
  6522. * Parses an input manager serialized JSON to restore the previous list of inputs
  6523. * and states associated to a camera.
  6524. * @param parsedCamera Defines the JSON to parse
  6525. */
  6526. parse(parsedCamera: any): void;
  6527. }
  6528. }
  6529. declare module BABYLON {
  6530. /**
  6531. * Class used to store data that will be store in GPU memory
  6532. */
  6533. export class Buffer {
  6534. private _engine;
  6535. private _buffer;
  6536. /** @hidden */
  6537. _data: Nullable<DataArray>;
  6538. private _updatable;
  6539. private _instanced;
  6540. private _divisor;
  6541. /**
  6542. * Gets the byte stride.
  6543. */
  6544. readonly byteStride: number;
  6545. /**
  6546. * Constructor
  6547. * @param engine the engine
  6548. * @param data the data to use for this buffer
  6549. * @param updatable whether the data is updatable
  6550. * @param stride the stride (optional)
  6551. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6552. * @param instanced whether the buffer is instanced (optional)
  6553. * @param useBytes set to true if the stride in in bytes (optional)
  6554. * @param divisor sets an optional divisor for instances (1 by default)
  6555. */
  6556. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6557. /**
  6558. * Create a new VertexBuffer based on the current buffer
  6559. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6560. * @param offset defines offset in the buffer (0 by default)
  6561. * @param size defines the size in floats of attributes (position is 3 for instance)
  6562. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6563. * @param instanced defines if the vertex buffer contains indexed data
  6564. * @param useBytes defines if the offset and stride are in bytes *
  6565. * @param divisor sets an optional divisor for instances (1 by default)
  6566. * @returns the new vertex buffer
  6567. */
  6568. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6569. /**
  6570. * Gets a boolean indicating if the Buffer is updatable?
  6571. * @returns true if the buffer is updatable
  6572. */
  6573. isUpdatable(): boolean;
  6574. /**
  6575. * Gets current buffer's data
  6576. * @returns a DataArray or null
  6577. */
  6578. getData(): Nullable<DataArray>;
  6579. /**
  6580. * Gets underlying native buffer
  6581. * @returns underlying native buffer
  6582. */
  6583. getBuffer(): Nullable<DataBuffer>;
  6584. /**
  6585. * Gets the stride in float32 units (i.e. byte stride / 4).
  6586. * May not be an integer if the byte stride is not divisible by 4.
  6587. * @returns the stride in float32 units
  6588. * @deprecated Please use byteStride instead.
  6589. */
  6590. getStrideSize(): number;
  6591. /**
  6592. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6593. * @param data defines the data to store
  6594. */
  6595. create(data?: Nullable<DataArray>): void;
  6596. /** @hidden */
  6597. _rebuild(): void;
  6598. /**
  6599. * Update current buffer data
  6600. * @param data defines the data to store
  6601. */
  6602. update(data: DataArray): void;
  6603. /**
  6604. * Updates the data directly.
  6605. * @param data the new data
  6606. * @param offset the new offset
  6607. * @param vertexCount the vertex count (optional)
  6608. * @param useBytes set to true if the offset is in bytes
  6609. */
  6610. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6611. /**
  6612. * Release all resources
  6613. */
  6614. dispose(): void;
  6615. }
  6616. /**
  6617. * Specialized buffer used to store vertex data
  6618. */
  6619. export class VertexBuffer {
  6620. /** @hidden */
  6621. _buffer: Buffer;
  6622. private _kind;
  6623. private _size;
  6624. private _ownsBuffer;
  6625. private _instanced;
  6626. private _instanceDivisor;
  6627. /**
  6628. * The byte type.
  6629. */
  6630. static readonly BYTE: number;
  6631. /**
  6632. * The unsigned byte type.
  6633. */
  6634. static readonly UNSIGNED_BYTE: number;
  6635. /**
  6636. * The short type.
  6637. */
  6638. static readonly SHORT: number;
  6639. /**
  6640. * The unsigned short type.
  6641. */
  6642. static readonly UNSIGNED_SHORT: number;
  6643. /**
  6644. * The integer type.
  6645. */
  6646. static readonly INT: number;
  6647. /**
  6648. * The unsigned integer type.
  6649. */
  6650. static readonly UNSIGNED_INT: number;
  6651. /**
  6652. * The float type.
  6653. */
  6654. static readonly FLOAT: number;
  6655. /**
  6656. * Gets or sets the instance divisor when in instanced mode
  6657. */
  6658. get instanceDivisor(): number;
  6659. set instanceDivisor(value: number);
  6660. /**
  6661. * Gets the byte stride.
  6662. */
  6663. readonly byteStride: number;
  6664. /**
  6665. * Gets the byte offset.
  6666. */
  6667. readonly byteOffset: number;
  6668. /**
  6669. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6670. */
  6671. readonly normalized: boolean;
  6672. /**
  6673. * Gets the data type of each component in the array.
  6674. */
  6675. readonly type: number;
  6676. /**
  6677. * Constructor
  6678. * @param engine the engine
  6679. * @param data the data to use for this vertex buffer
  6680. * @param kind the vertex buffer kind
  6681. * @param updatable whether the data is updatable
  6682. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6683. * @param stride the stride (optional)
  6684. * @param instanced whether the buffer is instanced (optional)
  6685. * @param offset the offset of the data (optional)
  6686. * @param size the number of components (optional)
  6687. * @param type the type of the component (optional)
  6688. * @param normalized whether the data contains normalized data (optional)
  6689. * @param useBytes set to true if stride and offset are in bytes (optional)
  6690. * @param divisor defines the instance divisor to use (1 by default)
  6691. */
  6692. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6693. /** @hidden */
  6694. _rebuild(): void;
  6695. /**
  6696. * Returns the kind of the VertexBuffer (string)
  6697. * @returns a string
  6698. */
  6699. getKind(): string;
  6700. /**
  6701. * Gets a boolean indicating if the VertexBuffer is updatable?
  6702. * @returns true if the buffer is updatable
  6703. */
  6704. isUpdatable(): boolean;
  6705. /**
  6706. * Gets current buffer's data
  6707. * @returns a DataArray or null
  6708. */
  6709. getData(): Nullable<DataArray>;
  6710. /**
  6711. * Gets underlying native buffer
  6712. * @returns underlying native buffer
  6713. */
  6714. getBuffer(): Nullable<DataBuffer>;
  6715. /**
  6716. * Gets the stride in float32 units (i.e. byte stride / 4).
  6717. * May not be an integer if the byte stride is not divisible by 4.
  6718. * @returns the stride in float32 units
  6719. * @deprecated Please use byteStride instead.
  6720. */
  6721. getStrideSize(): number;
  6722. /**
  6723. * Returns the offset as a multiple of the type byte length.
  6724. * @returns the offset in bytes
  6725. * @deprecated Please use byteOffset instead.
  6726. */
  6727. getOffset(): number;
  6728. /**
  6729. * Returns the number of components per vertex attribute (integer)
  6730. * @returns the size in float
  6731. */
  6732. getSize(): number;
  6733. /**
  6734. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6735. * @returns true if this buffer is instanced
  6736. */
  6737. getIsInstanced(): boolean;
  6738. /**
  6739. * Returns the instancing divisor, zero for non-instanced (integer).
  6740. * @returns a number
  6741. */
  6742. getInstanceDivisor(): number;
  6743. /**
  6744. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6745. * @param data defines the data to store
  6746. */
  6747. create(data?: DataArray): void;
  6748. /**
  6749. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6750. * This function will create a new buffer if the current one is not updatable
  6751. * @param data defines the data to store
  6752. */
  6753. update(data: DataArray): void;
  6754. /**
  6755. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6756. * Returns the directly updated WebGLBuffer.
  6757. * @param data the new data
  6758. * @param offset the new offset
  6759. * @param useBytes set to true if the offset is in bytes
  6760. */
  6761. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6762. /**
  6763. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6764. */
  6765. dispose(): void;
  6766. /**
  6767. * Enumerates each value of this vertex buffer as numbers.
  6768. * @param count the number of values to enumerate
  6769. * @param callback the callback function called for each value
  6770. */
  6771. forEach(count: number, callback: (value: number, index: number) => void): void;
  6772. /**
  6773. * Positions
  6774. */
  6775. static readonly PositionKind: string;
  6776. /**
  6777. * Normals
  6778. */
  6779. static readonly NormalKind: string;
  6780. /**
  6781. * Tangents
  6782. */
  6783. static readonly TangentKind: string;
  6784. /**
  6785. * Texture coordinates
  6786. */
  6787. static readonly UVKind: string;
  6788. /**
  6789. * Texture coordinates 2
  6790. */
  6791. static readonly UV2Kind: string;
  6792. /**
  6793. * Texture coordinates 3
  6794. */
  6795. static readonly UV3Kind: string;
  6796. /**
  6797. * Texture coordinates 4
  6798. */
  6799. static readonly UV4Kind: string;
  6800. /**
  6801. * Texture coordinates 5
  6802. */
  6803. static readonly UV5Kind: string;
  6804. /**
  6805. * Texture coordinates 6
  6806. */
  6807. static readonly UV6Kind: string;
  6808. /**
  6809. * Colors
  6810. */
  6811. static readonly ColorKind: string;
  6812. /**
  6813. * Matrix indices (for bones)
  6814. */
  6815. static readonly MatricesIndicesKind: string;
  6816. /**
  6817. * Matrix weights (for bones)
  6818. */
  6819. static readonly MatricesWeightsKind: string;
  6820. /**
  6821. * Additional matrix indices (for bones)
  6822. */
  6823. static readonly MatricesIndicesExtraKind: string;
  6824. /**
  6825. * Additional matrix weights (for bones)
  6826. */
  6827. static readonly MatricesWeightsExtraKind: string;
  6828. /**
  6829. * Deduces the stride given a kind.
  6830. * @param kind The kind string to deduce
  6831. * @returns The deduced stride
  6832. */
  6833. static DeduceStride(kind: string): number;
  6834. /**
  6835. * Gets the byte length of the given type.
  6836. * @param type the type
  6837. * @returns the number of bytes
  6838. */
  6839. static GetTypeByteLength(type: number): number;
  6840. /**
  6841. * Enumerates each value of the given parameters as numbers.
  6842. * @param data the data to enumerate
  6843. * @param byteOffset the byte offset of the data
  6844. * @param byteStride the byte stride of the data
  6845. * @param componentCount the number of components per element
  6846. * @param componentType the type of the component
  6847. * @param count the number of values to enumerate
  6848. * @param normalized whether the data is normalized
  6849. * @param callback the callback function called for each value
  6850. */
  6851. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6852. private static _GetFloatValue;
  6853. }
  6854. }
  6855. declare module BABYLON {
  6856. /**
  6857. * The options Interface for creating a Capsule Mesh
  6858. */
  6859. export interface ICreateCapsuleOptions {
  6860. /** The Orientation of the capsule. Default : Vector3.Up() */
  6861. orientation?: Vector3;
  6862. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6863. subdivisions: number;
  6864. /** Number of cylindrical segments on the capsule. */
  6865. tessellation: number;
  6866. /** Height or Length of the capsule. */
  6867. height: number;
  6868. /** Radius of the capsule. */
  6869. radius: number;
  6870. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6871. capSubdivisions: number;
  6872. /** Overwrite for the top radius. */
  6873. radiusTop?: number;
  6874. /** Overwrite for the bottom radius. */
  6875. radiusBottom?: number;
  6876. /** Overwrite for the top capSubdivisions. */
  6877. topCapSubdivisions?: number;
  6878. /** Overwrite for the bottom capSubdivisions. */
  6879. bottomCapSubdivisions?: number;
  6880. }
  6881. /**
  6882. * Class containing static functions to help procedurally build meshes
  6883. */
  6884. export class CapsuleBuilder {
  6885. /**
  6886. * Creates a capsule or a pill mesh
  6887. * @param name defines the name of the mesh
  6888. * @param options The constructors options.
  6889. * @param scene The scene the mesh is scoped to.
  6890. * @returns Capsule Mesh
  6891. */
  6892. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6893. }
  6894. }
  6895. declare module BABYLON {
  6896. /**
  6897. * @hidden
  6898. */
  6899. export class IntersectionInfo {
  6900. bu: Nullable<number>;
  6901. bv: Nullable<number>;
  6902. distance: number;
  6903. faceId: number;
  6904. subMeshId: number;
  6905. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6906. }
  6907. }
  6908. declare module BABYLON {
  6909. /**
  6910. * Class used to store bounding sphere information
  6911. */
  6912. export class BoundingSphere {
  6913. /**
  6914. * Gets the center of the bounding sphere in local space
  6915. */
  6916. readonly center: Vector3;
  6917. /**
  6918. * Radius of the bounding sphere in local space
  6919. */
  6920. radius: number;
  6921. /**
  6922. * Gets the center of the bounding sphere in world space
  6923. */
  6924. readonly centerWorld: Vector3;
  6925. /**
  6926. * Radius of the bounding sphere in world space
  6927. */
  6928. radiusWorld: number;
  6929. /**
  6930. * Gets the minimum vector in local space
  6931. */
  6932. readonly minimum: Vector3;
  6933. /**
  6934. * Gets the maximum vector in local space
  6935. */
  6936. readonly maximum: Vector3;
  6937. private _worldMatrix;
  6938. private static readonly TmpVector3;
  6939. /**
  6940. * Creates a new bounding sphere
  6941. * @param min defines the minimum vector (in local space)
  6942. * @param max defines the maximum vector (in local space)
  6943. * @param worldMatrix defines the new world matrix
  6944. */
  6945. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6946. /**
  6947. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6948. * @param min defines the new minimum vector (in local space)
  6949. * @param max defines the new maximum vector (in local space)
  6950. * @param worldMatrix defines the new world matrix
  6951. */
  6952. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6953. /**
  6954. * Scale the current bounding sphere by applying a scale factor
  6955. * @param factor defines the scale factor to apply
  6956. * @returns the current bounding box
  6957. */
  6958. scale(factor: number): BoundingSphere;
  6959. /**
  6960. * Gets the world matrix of the bounding box
  6961. * @returns a matrix
  6962. */
  6963. getWorldMatrix(): DeepImmutable<Matrix>;
  6964. /** @hidden */
  6965. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6966. /**
  6967. * Tests if the bounding sphere is intersecting the frustum planes
  6968. * @param frustumPlanes defines the frustum planes to test
  6969. * @returns true if there is an intersection
  6970. */
  6971. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6972. /**
  6973. * Tests if the bounding sphere center is in between the frustum planes.
  6974. * Used for optimistic fast inclusion.
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @returns true if the sphere center is in between the frustum planes
  6977. */
  6978. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. /**
  6980. * Tests if a point is inside the bounding sphere
  6981. * @param point defines the point to test
  6982. * @returns true if the point is inside the bounding sphere
  6983. */
  6984. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6985. /**
  6986. * Checks if two sphere intersct
  6987. * @param sphere0 sphere 0
  6988. * @param sphere1 sphere 1
  6989. * @returns true if the speres intersect
  6990. */
  6991. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6992. }
  6993. }
  6994. declare module BABYLON {
  6995. /**
  6996. * Class used to store bounding box information
  6997. */
  6998. export class BoundingBox implements ICullable {
  6999. /**
  7000. * Gets the 8 vectors representing the bounding box in local space
  7001. */
  7002. readonly vectors: Vector3[];
  7003. /**
  7004. * Gets the center of the bounding box in local space
  7005. */
  7006. readonly center: Vector3;
  7007. /**
  7008. * Gets the center of the bounding box in world space
  7009. */
  7010. readonly centerWorld: Vector3;
  7011. /**
  7012. * Gets the extend size in local space
  7013. */
  7014. readonly extendSize: Vector3;
  7015. /**
  7016. * Gets the extend size in world space
  7017. */
  7018. readonly extendSizeWorld: Vector3;
  7019. /**
  7020. * Gets the OBB (object bounding box) directions
  7021. */
  7022. readonly directions: Vector3[];
  7023. /**
  7024. * Gets the 8 vectors representing the bounding box in world space
  7025. */
  7026. readonly vectorsWorld: Vector3[];
  7027. /**
  7028. * Gets the minimum vector in world space
  7029. */
  7030. readonly minimumWorld: Vector3;
  7031. /**
  7032. * Gets the maximum vector in world space
  7033. */
  7034. readonly maximumWorld: Vector3;
  7035. /**
  7036. * Gets the minimum vector in local space
  7037. */
  7038. readonly minimum: Vector3;
  7039. /**
  7040. * Gets the maximum vector in local space
  7041. */
  7042. readonly maximum: Vector3;
  7043. private _worldMatrix;
  7044. private static readonly TmpVector3;
  7045. /**
  7046. * @hidden
  7047. */
  7048. _tag: number;
  7049. /**
  7050. * Creates a new bounding box
  7051. * @param min defines the minimum vector (in local space)
  7052. * @param max defines the maximum vector (in local space)
  7053. * @param worldMatrix defines the new world matrix
  7054. */
  7055. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7056. /**
  7057. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7058. * @param min defines the new minimum vector (in local space)
  7059. * @param max defines the new maximum vector (in local space)
  7060. * @param worldMatrix defines the new world matrix
  7061. */
  7062. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7063. /**
  7064. * Scale the current bounding box by applying a scale factor
  7065. * @param factor defines the scale factor to apply
  7066. * @returns the current bounding box
  7067. */
  7068. scale(factor: number): BoundingBox;
  7069. /**
  7070. * Gets the world matrix of the bounding box
  7071. * @returns a matrix
  7072. */
  7073. getWorldMatrix(): DeepImmutable<Matrix>;
  7074. /** @hidden */
  7075. _update(world: DeepImmutable<Matrix>): void;
  7076. /**
  7077. * Tests if the bounding box is intersecting the frustum planes
  7078. * @param frustumPlanes defines the frustum planes to test
  7079. * @returns true if there is an intersection
  7080. */
  7081. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7082. /**
  7083. * Tests if the bounding box is entirely inside the frustum planes
  7084. * @param frustumPlanes defines the frustum planes to test
  7085. * @returns true if there is an inclusion
  7086. */
  7087. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7088. /**
  7089. * Tests if a point is inside the bounding box
  7090. * @param point defines the point to test
  7091. * @returns true if the point is inside the bounding box
  7092. */
  7093. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7094. /**
  7095. * Tests if the bounding box intersects with a bounding sphere
  7096. * @param sphere defines the sphere to test
  7097. * @returns true if there is an intersection
  7098. */
  7099. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7100. /**
  7101. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7102. * @param min defines the min vector to use
  7103. * @param max defines the max vector to use
  7104. * @returns true if there is an intersection
  7105. */
  7106. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7107. /**
  7108. * Tests if two bounding boxes are intersections
  7109. * @param box0 defines the first box to test
  7110. * @param box1 defines the second box to test
  7111. * @returns true if there is an intersection
  7112. */
  7113. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7114. /**
  7115. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7116. * @param minPoint defines the minimum vector of the bounding box
  7117. * @param maxPoint defines the maximum vector of the bounding box
  7118. * @param sphereCenter defines the sphere center
  7119. * @param sphereRadius defines the sphere radius
  7120. * @returns true if there is an intersection
  7121. */
  7122. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7123. /**
  7124. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7125. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7126. * @param frustumPlanes defines the frustum planes to test
  7127. * @return true if there is an inclusion
  7128. */
  7129. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7130. /**
  7131. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7132. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7133. * @param frustumPlanes defines the frustum planes to test
  7134. * @return true if there is an intersection
  7135. */
  7136. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. }
  7138. }
  7139. declare module BABYLON {
  7140. /** @hidden */
  7141. export class Collider {
  7142. /** Define if a collision was found */
  7143. collisionFound: boolean;
  7144. /**
  7145. * Define last intersection point in local space
  7146. */
  7147. intersectionPoint: Vector3;
  7148. /**
  7149. * Define last collided mesh
  7150. */
  7151. collidedMesh: Nullable<AbstractMesh>;
  7152. private _collisionPoint;
  7153. private _planeIntersectionPoint;
  7154. private _tempVector;
  7155. private _tempVector2;
  7156. private _tempVector3;
  7157. private _tempVector4;
  7158. private _edge;
  7159. private _baseToVertex;
  7160. private _destinationPoint;
  7161. private _slidePlaneNormal;
  7162. private _displacementVector;
  7163. /** @hidden */
  7164. _radius: Vector3;
  7165. /** @hidden */
  7166. _retry: number;
  7167. private _velocity;
  7168. private _basePoint;
  7169. private _epsilon;
  7170. /** @hidden */
  7171. _velocityWorldLength: number;
  7172. /** @hidden */
  7173. _basePointWorld: Vector3;
  7174. private _velocityWorld;
  7175. private _normalizedVelocity;
  7176. /** @hidden */
  7177. _initialVelocity: Vector3;
  7178. /** @hidden */
  7179. _initialPosition: Vector3;
  7180. private _nearestDistance;
  7181. private _collisionMask;
  7182. get collisionMask(): number;
  7183. set collisionMask(mask: number);
  7184. /**
  7185. * Gets the plane normal used to compute the sliding response (in local space)
  7186. */
  7187. get slidePlaneNormal(): Vector3;
  7188. /** @hidden */
  7189. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7190. /** @hidden */
  7191. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7192. /** @hidden */
  7193. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7194. /** @hidden */
  7195. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7196. /** @hidden */
  7197. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7198. /** @hidden */
  7199. _getResponse(pos: Vector3, vel: Vector3): void;
  7200. }
  7201. }
  7202. declare module BABYLON {
  7203. /**
  7204. * Interface for cullable objects
  7205. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7206. */
  7207. export interface ICullable {
  7208. /**
  7209. * Checks if the object or part of the object is in the frustum
  7210. * @param frustumPlanes Camera near/planes
  7211. * @returns true if the object is in frustum otherwise false
  7212. */
  7213. isInFrustum(frustumPlanes: Plane[]): boolean;
  7214. /**
  7215. * Checks if a cullable object (mesh...) is in the camera frustum
  7216. * Unlike isInFrustum this cheks the full bounding box
  7217. * @param frustumPlanes Camera near/planes
  7218. * @returns true if the object is in frustum otherwise false
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7221. }
  7222. /**
  7223. * Info for a bounding data of a mesh
  7224. */
  7225. export class BoundingInfo implements ICullable {
  7226. /**
  7227. * Bounding box for the mesh
  7228. */
  7229. readonly boundingBox: BoundingBox;
  7230. /**
  7231. * Bounding sphere for the mesh
  7232. */
  7233. readonly boundingSphere: BoundingSphere;
  7234. private _isLocked;
  7235. private static readonly TmpVector3;
  7236. /**
  7237. * Constructs bounding info
  7238. * @param minimum min vector of the bounding box/sphere
  7239. * @param maximum max vector of the bounding box/sphere
  7240. * @param worldMatrix defines the new world matrix
  7241. */
  7242. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7243. /**
  7244. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7245. * @param min defines the new minimum vector (in local space)
  7246. * @param max defines the new maximum vector (in local space)
  7247. * @param worldMatrix defines the new world matrix
  7248. */
  7249. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7250. /**
  7251. * min vector of the bounding box/sphere
  7252. */
  7253. get minimum(): Vector3;
  7254. /**
  7255. * max vector of the bounding box/sphere
  7256. */
  7257. get maximum(): Vector3;
  7258. /**
  7259. * If the info is locked and won't be updated to avoid perf overhead
  7260. */
  7261. get isLocked(): boolean;
  7262. set isLocked(value: boolean);
  7263. /**
  7264. * Updates the bounding sphere and box
  7265. * @param world world matrix to be used to update
  7266. */
  7267. update(world: DeepImmutable<Matrix>): void;
  7268. /**
  7269. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7270. * @param center New center of the bounding info
  7271. * @param extend New extend of the bounding info
  7272. * @returns the current bounding info
  7273. */
  7274. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7275. /**
  7276. * Scale the current bounding info by applying a scale factor
  7277. * @param factor defines the scale factor to apply
  7278. * @returns the current bounding info
  7279. */
  7280. scale(factor: number): BoundingInfo;
  7281. /**
  7282. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7283. * @param frustumPlanes defines the frustum to test
  7284. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7285. * @returns true if the bounding info is in the frustum planes
  7286. */
  7287. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7288. /**
  7289. * Gets the world distance between the min and max points of the bounding box
  7290. */
  7291. get diagonalLength(): number;
  7292. /**
  7293. * Checks if a cullable object (mesh...) is in the camera frustum
  7294. * Unlike isInFrustum this cheks the full bounding box
  7295. * @param frustumPlanes Camera near/planes
  7296. * @returns true if the object is in frustum otherwise false
  7297. */
  7298. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7299. /** @hidden */
  7300. _checkCollision(collider: Collider): boolean;
  7301. /**
  7302. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7303. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7304. * @param point the point to check intersection with
  7305. * @returns if the point intersects
  7306. */
  7307. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7308. /**
  7309. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7310. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7311. * @param boundingInfo the bounding info to check intersection with
  7312. * @param precise if the intersection should be done using OBB
  7313. * @returns if the bounding info intersects
  7314. */
  7315. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7316. }
  7317. }
  7318. declare module BABYLON {
  7319. /**
  7320. * Extracts minimum and maximum values from a list of indexed positions
  7321. * @param positions defines the positions to use
  7322. * @param indices defines the indices to the positions
  7323. * @param indexStart defines the start index
  7324. * @param indexCount defines the end index
  7325. * @param bias defines bias value to add to the result
  7326. * @return minimum and maximum values
  7327. */
  7328. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7329. minimum: Vector3;
  7330. maximum: Vector3;
  7331. };
  7332. /**
  7333. * Extracts minimum and maximum values from a list of positions
  7334. * @param positions defines the positions to use
  7335. * @param start defines the start index in the positions array
  7336. * @param count defines the number of positions to handle
  7337. * @param bias defines bias value to add to the result
  7338. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7339. * @return minimum and maximum values
  7340. */
  7341. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7342. minimum: Vector3;
  7343. maximum: Vector3;
  7344. };
  7345. }
  7346. declare module BABYLON {
  7347. /** @hidden */
  7348. export class WebGLDataBuffer extends DataBuffer {
  7349. private _buffer;
  7350. constructor(resource: WebGLBuffer);
  7351. get underlyingResource(): any;
  7352. }
  7353. }
  7354. declare module BABYLON {
  7355. /** @hidden */
  7356. export class WebGLPipelineContext implements IPipelineContext {
  7357. engine: ThinEngine;
  7358. program: Nullable<WebGLProgram>;
  7359. context?: WebGLRenderingContext;
  7360. vertexShader?: WebGLShader;
  7361. fragmentShader?: WebGLShader;
  7362. isParallelCompiled: boolean;
  7363. onCompiled?: () => void;
  7364. transformFeedback?: WebGLTransformFeedback | null;
  7365. vertexCompilationError: Nullable<string>;
  7366. fragmentCompilationError: Nullable<string>;
  7367. programLinkError: Nullable<string>;
  7368. programValidationError: Nullable<string>;
  7369. get isAsync(): boolean;
  7370. get isReady(): boolean;
  7371. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7372. _getVertexShaderCode(): string | null;
  7373. _getFragmentShaderCode(): string | null;
  7374. }
  7375. }
  7376. declare module BABYLON {
  7377. interface ThinEngine {
  7378. /**
  7379. * Create an uniform buffer
  7380. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7381. * @param elements defines the content of the uniform buffer
  7382. * @returns the webGL uniform buffer
  7383. */
  7384. createUniformBuffer(elements: FloatArray): DataBuffer;
  7385. /**
  7386. * Create a dynamic uniform buffer
  7387. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7388. * @param elements defines the content of the uniform buffer
  7389. * @returns the webGL uniform buffer
  7390. */
  7391. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7392. /**
  7393. * Update an existing uniform buffer
  7394. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7395. * @param uniformBuffer defines the target uniform buffer
  7396. * @param elements defines the content to update
  7397. * @param offset defines the offset in the uniform buffer where update should start
  7398. * @param count defines the size of the data to update
  7399. */
  7400. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7401. /**
  7402. * Bind an uniform buffer to the current webGL context
  7403. * @param buffer defines the buffer to bind
  7404. */
  7405. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7406. /**
  7407. * Bind a buffer to the current webGL context at a given location
  7408. * @param buffer defines the buffer to bind
  7409. * @param location defines the index where to bind the buffer
  7410. */
  7411. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7412. /**
  7413. * Bind a specific block at a given index in a specific shader program
  7414. * @param pipelineContext defines the pipeline context to use
  7415. * @param blockName defines the block name
  7416. * @param index defines the index where to bind the block
  7417. */
  7418. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7419. }
  7420. }
  7421. declare module BABYLON {
  7422. /**
  7423. * Uniform buffer objects.
  7424. *
  7425. * Handles blocks of uniform on the GPU.
  7426. *
  7427. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7428. *
  7429. * For more information, please refer to :
  7430. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7431. */
  7432. export class UniformBuffer {
  7433. private _engine;
  7434. private _buffer;
  7435. private _data;
  7436. private _bufferData;
  7437. private _dynamic?;
  7438. private _uniformLocations;
  7439. private _uniformSizes;
  7440. private _uniformLocationPointer;
  7441. private _needSync;
  7442. private _noUBO;
  7443. private _currentEffect;
  7444. /** @hidden */
  7445. _alreadyBound: boolean;
  7446. private static _MAX_UNIFORM_SIZE;
  7447. private static _tempBuffer;
  7448. /**
  7449. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7450. * This is dynamic to allow compat with webgl 1 and 2.
  7451. * You will need to pass the name of the uniform as well as the value.
  7452. */
  7453. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7454. /**
  7455. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7456. * This is dynamic to allow compat with webgl 1 and 2.
  7457. * You will need to pass the name of the uniform as well as the value.
  7458. */
  7459. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7460. /**
  7461. * Lambda to Update a single float in a uniform buffer.
  7462. * This is dynamic to allow compat with webgl 1 and 2.
  7463. * You will need to pass the name of the uniform as well as the value.
  7464. */
  7465. updateFloat: (name: string, x: number) => void;
  7466. /**
  7467. * Lambda to Update a vec2 of float in a uniform buffer.
  7468. * This is dynamic to allow compat with webgl 1 and 2.
  7469. * You will need to pass the name of the uniform as well as the value.
  7470. */
  7471. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7472. /**
  7473. * Lambda to Update a vec3 of float in a uniform buffer.
  7474. * This is dynamic to allow compat with webgl 1 and 2.
  7475. * You will need to pass the name of the uniform as well as the value.
  7476. */
  7477. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7478. /**
  7479. * Lambda to Update a vec4 of float in a uniform buffer.
  7480. * This is dynamic to allow compat with webgl 1 and 2.
  7481. * You will need to pass the name of the uniform as well as the value.
  7482. */
  7483. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7484. /**
  7485. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7486. * This is dynamic to allow compat with webgl 1 and 2.
  7487. * You will need to pass the name of the uniform as well as the value.
  7488. */
  7489. updateMatrix: (name: string, mat: Matrix) => void;
  7490. /**
  7491. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7492. * This is dynamic to allow compat with webgl 1 and 2.
  7493. * You will need to pass the name of the uniform as well as the value.
  7494. */
  7495. updateVector3: (name: string, vector: Vector3) => void;
  7496. /**
  7497. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7498. * This is dynamic to allow compat with webgl 1 and 2.
  7499. * You will need to pass the name of the uniform as well as the value.
  7500. */
  7501. updateVector4: (name: string, vector: Vector4) => void;
  7502. /**
  7503. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7504. * This is dynamic to allow compat with webgl 1 and 2.
  7505. * You will need to pass the name of the uniform as well as the value.
  7506. */
  7507. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7508. /**
  7509. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7510. * This is dynamic to allow compat with webgl 1 and 2.
  7511. * You will need to pass the name of the uniform as well as the value.
  7512. */
  7513. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7514. /**
  7515. * Instantiates a new Uniform buffer objects.
  7516. *
  7517. * Handles blocks of uniform on the GPU.
  7518. *
  7519. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7520. *
  7521. * For more information, please refer to :
  7522. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7523. * @param engine Define the engine the buffer is associated with
  7524. * @param data Define the data contained in the buffer
  7525. * @param dynamic Define if the buffer is updatable
  7526. */
  7527. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7528. /**
  7529. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7530. * or just falling back on setUniformXXX calls.
  7531. */
  7532. get useUbo(): boolean;
  7533. /**
  7534. * Indicates if the WebGL underlying uniform buffer is in sync
  7535. * with the javascript cache data.
  7536. */
  7537. get isSync(): boolean;
  7538. /**
  7539. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7540. * Also, a dynamic UniformBuffer will disable cache verification and always
  7541. * update the underlying WebGL uniform buffer to the GPU.
  7542. * @returns if Dynamic, otherwise false
  7543. */
  7544. isDynamic(): boolean;
  7545. /**
  7546. * The data cache on JS side.
  7547. * @returns the underlying data as a float array
  7548. */
  7549. getData(): Float32Array;
  7550. /**
  7551. * The underlying WebGL Uniform buffer.
  7552. * @returns the webgl buffer
  7553. */
  7554. getBuffer(): Nullable<DataBuffer>;
  7555. /**
  7556. * std140 layout specifies how to align data within an UBO structure.
  7557. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7558. * for specs.
  7559. */
  7560. private _fillAlignment;
  7561. /**
  7562. * Adds an uniform in the buffer.
  7563. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7564. * for the layout to be correct !
  7565. * @param name Name of the uniform, as used in the uniform block in the shader.
  7566. * @param size Data size, or data directly.
  7567. */
  7568. addUniform(name: string, size: number | number[]): void;
  7569. /**
  7570. * Adds a Matrix 4x4 to the uniform buffer.
  7571. * @param name Name of the uniform, as used in the uniform block in the shader.
  7572. * @param mat A 4x4 matrix.
  7573. */
  7574. addMatrix(name: string, mat: Matrix): void;
  7575. /**
  7576. * Adds a vec2 to the uniform buffer.
  7577. * @param name Name of the uniform, as used in the uniform block in the shader.
  7578. * @param x Define the x component value of the vec2
  7579. * @param y Define the y component value of the vec2
  7580. */
  7581. addFloat2(name: string, x: number, y: number): void;
  7582. /**
  7583. * Adds a vec3 to the uniform buffer.
  7584. * @param name Name of the uniform, as used in the uniform block in the shader.
  7585. * @param x Define the x component value of the vec3
  7586. * @param y Define the y component value of the vec3
  7587. * @param z Define the z component value of the vec3
  7588. */
  7589. addFloat3(name: string, x: number, y: number, z: number): void;
  7590. /**
  7591. * Adds a vec3 to the uniform buffer.
  7592. * @param name Name of the uniform, as used in the uniform block in the shader.
  7593. * @param color Define the vec3 from a Color
  7594. */
  7595. addColor3(name: string, color: Color3): void;
  7596. /**
  7597. * Adds a vec4 to the uniform buffer.
  7598. * @param name Name of the uniform, as used in the uniform block in the shader.
  7599. * @param color Define the rgb components from a Color
  7600. * @param alpha Define the a component of the vec4
  7601. */
  7602. addColor4(name: string, color: Color3, alpha: number): void;
  7603. /**
  7604. * Adds a vec3 to the uniform buffer.
  7605. * @param name Name of the uniform, as used in the uniform block in the shader.
  7606. * @param vector Define the vec3 components from a Vector
  7607. */
  7608. addVector3(name: string, vector: Vector3): void;
  7609. /**
  7610. * Adds a Matrix 3x3 to the uniform buffer.
  7611. * @param name Name of the uniform, as used in the uniform block in the shader.
  7612. */
  7613. addMatrix3x3(name: string): void;
  7614. /**
  7615. * Adds a Matrix 2x2 to the uniform buffer.
  7616. * @param name Name of the uniform, as used in the uniform block in the shader.
  7617. */
  7618. addMatrix2x2(name: string): void;
  7619. /**
  7620. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7621. */
  7622. create(): void;
  7623. /** @hidden */
  7624. _rebuild(): void;
  7625. /**
  7626. * Updates the WebGL Uniform Buffer on the GPU.
  7627. * If the `dynamic` flag is set to true, no cache comparison is done.
  7628. * Otherwise, the buffer will be updated only if the cache differs.
  7629. */
  7630. update(): void;
  7631. /**
  7632. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7633. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7634. * @param data Define the flattened data
  7635. * @param size Define the size of the data.
  7636. */
  7637. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7638. private _valueCache;
  7639. private _cacheMatrix;
  7640. private _updateMatrix3x3ForUniform;
  7641. private _updateMatrix3x3ForEffect;
  7642. private _updateMatrix2x2ForEffect;
  7643. private _updateMatrix2x2ForUniform;
  7644. private _updateFloatForEffect;
  7645. private _updateFloatForUniform;
  7646. private _updateFloat2ForEffect;
  7647. private _updateFloat2ForUniform;
  7648. private _updateFloat3ForEffect;
  7649. private _updateFloat3ForUniform;
  7650. private _updateFloat4ForEffect;
  7651. private _updateFloat4ForUniform;
  7652. private _updateMatrixForEffect;
  7653. private _updateMatrixForUniform;
  7654. private _updateVector3ForEffect;
  7655. private _updateVector3ForUniform;
  7656. private _updateVector4ForEffect;
  7657. private _updateVector4ForUniform;
  7658. private _updateColor3ForEffect;
  7659. private _updateColor3ForUniform;
  7660. private _updateColor4ForEffect;
  7661. private _updateColor4ForUniform;
  7662. /**
  7663. * Sets a sampler uniform on the effect.
  7664. * @param name Define the name of the sampler.
  7665. * @param texture Define the texture to set in the sampler
  7666. */
  7667. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7668. /**
  7669. * Directly updates the value of the uniform in the cache AND on the GPU.
  7670. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7671. * @param data Define the flattened data
  7672. */
  7673. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7674. /**
  7675. * Binds this uniform buffer to an effect.
  7676. * @param effect Define the effect to bind the buffer to
  7677. * @param name Name of the uniform block in the shader.
  7678. */
  7679. bindToEffect(effect: Effect, name: string): void;
  7680. /**
  7681. * Disposes the uniform buffer.
  7682. */
  7683. dispose(): void;
  7684. }
  7685. }
  7686. declare module BABYLON {
  7687. /**
  7688. * Enum that determines the text-wrapping mode to use.
  7689. */
  7690. export enum InspectableType {
  7691. /**
  7692. * Checkbox for booleans
  7693. */
  7694. Checkbox = 0,
  7695. /**
  7696. * Sliders for numbers
  7697. */
  7698. Slider = 1,
  7699. /**
  7700. * Vector3
  7701. */
  7702. Vector3 = 2,
  7703. /**
  7704. * Quaternions
  7705. */
  7706. Quaternion = 3,
  7707. /**
  7708. * Color3
  7709. */
  7710. Color3 = 4,
  7711. /**
  7712. * String
  7713. */
  7714. String = 5
  7715. }
  7716. /**
  7717. * Interface used to define custom inspectable properties.
  7718. * This interface is used by the inspector to display custom property grids
  7719. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7720. */
  7721. export interface IInspectable {
  7722. /**
  7723. * Gets the label to display
  7724. */
  7725. label: string;
  7726. /**
  7727. * Gets the name of the property to edit
  7728. */
  7729. propertyName: string;
  7730. /**
  7731. * Gets the type of the editor to use
  7732. */
  7733. type: InspectableType;
  7734. /**
  7735. * Gets the minimum value of the property when using in "slider" mode
  7736. */
  7737. min?: number;
  7738. /**
  7739. * Gets the maximum value of the property when using in "slider" mode
  7740. */
  7741. max?: number;
  7742. /**
  7743. * Gets the setp to use when using in "slider" mode
  7744. */
  7745. step?: number;
  7746. }
  7747. }
  7748. declare module BABYLON {
  7749. /**
  7750. * Class used to provide helper for timing
  7751. */
  7752. export class TimingTools {
  7753. /**
  7754. * Polyfill for setImmediate
  7755. * @param action defines the action to execute after the current execution block
  7756. */
  7757. static SetImmediate(action: () => void): void;
  7758. }
  7759. }
  7760. declare module BABYLON {
  7761. /**
  7762. * Class used to enable instatition of objects by class name
  7763. */
  7764. export class InstantiationTools {
  7765. /**
  7766. * Use this object to register external classes like custom textures or material
  7767. * to allow the laoders to instantiate them
  7768. */
  7769. static RegisteredExternalClasses: {
  7770. [key: string]: Object;
  7771. };
  7772. /**
  7773. * Tries to instantiate a new object from a given class name
  7774. * @param className defines the class name to instantiate
  7775. * @returns the new object or null if the system was not able to do the instantiation
  7776. */
  7777. static Instantiate(className: string): any;
  7778. }
  7779. }
  7780. declare module BABYLON {
  7781. /**
  7782. * Define options used to create a depth texture
  7783. */
  7784. export class DepthTextureCreationOptions {
  7785. /** Specifies whether or not a stencil should be allocated in the texture */
  7786. generateStencil?: boolean;
  7787. /** Specifies whether or not bilinear filtering is enable on the texture */
  7788. bilinearFiltering?: boolean;
  7789. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7790. comparisonFunction?: number;
  7791. /** Specifies if the created texture is a cube texture */
  7792. isCube?: boolean;
  7793. }
  7794. }
  7795. declare module BABYLON {
  7796. interface ThinEngine {
  7797. /**
  7798. * Creates a depth stencil cube texture.
  7799. * This is only available in WebGL 2.
  7800. * @param size The size of face edge in the cube texture.
  7801. * @param options The options defining the cube texture.
  7802. * @returns The cube texture
  7803. */
  7804. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7805. /**
  7806. * Creates a cube texture
  7807. * @param rootUrl defines the url where the files to load is located
  7808. * @param scene defines the current scene
  7809. * @param files defines the list of files to load (1 per face)
  7810. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7811. * @param onLoad defines an optional callback raised when the texture is loaded
  7812. * @param onError defines an optional callback raised if there is an issue to load the texture
  7813. * @param format defines the format of the data
  7814. * @param forcedExtension defines the extension to use to pick the right loader
  7815. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7816. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7817. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7818. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7819. * @param loaderOptions options to be passed to the loader
  7820. * @returns the cube texture as an InternalTexture
  7821. */
  7822. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  7823. /**
  7824. * Creates a cube texture
  7825. * @param rootUrl defines the url where the files to load is located
  7826. * @param scene defines the current scene
  7827. * @param files defines the list of files to load (1 per face)
  7828. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7829. * @param onLoad defines an optional callback raised when the texture is loaded
  7830. * @param onError defines an optional callback raised if there is an issue to load the texture
  7831. * @param format defines the format of the data
  7832. * @param forcedExtension defines the extension to use to pick the right loader
  7833. * @returns the cube texture as an InternalTexture
  7834. */
  7835. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7836. /**
  7837. * Creates a cube texture
  7838. * @param rootUrl defines the url where the files to load is located
  7839. * @param scene defines the current scene
  7840. * @param files defines the list of files to load (1 per face)
  7841. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7842. * @param onLoad defines an optional callback raised when the texture is loaded
  7843. * @param onError defines an optional callback raised if there is an issue to load the texture
  7844. * @param format defines the format of the data
  7845. * @param forcedExtension defines the extension to use to pick the right loader
  7846. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7847. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7848. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7849. * @returns the cube texture as an InternalTexture
  7850. */
  7851. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7852. /** @hidden */
  7853. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7854. /** @hidden */
  7855. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7856. /** @hidden */
  7857. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7858. /** @hidden */
  7859. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7860. /**
  7861. * @hidden
  7862. */
  7863. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  7864. }
  7865. }
  7866. declare module BABYLON {
  7867. /**
  7868. * Class for creating a cube texture
  7869. */
  7870. export class CubeTexture extends BaseTexture {
  7871. private _delayedOnLoad;
  7872. /**
  7873. * Observable triggered once the texture has been loaded.
  7874. */
  7875. onLoadObservable: Observable<CubeTexture>;
  7876. /**
  7877. * The url of the texture
  7878. */
  7879. url: string;
  7880. /**
  7881. * Gets or sets the center of the bounding box associated with the cube texture.
  7882. * It must define where the camera used to render the texture was set
  7883. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7884. */
  7885. boundingBoxPosition: Vector3;
  7886. private _boundingBoxSize;
  7887. /**
  7888. * Gets or sets the size of the bounding box associated with the cube texture
  7889. * When defined, the cubemap will switch to local mode
  7890. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7891. * @example https://www.babylonjs-playground.com/#RNASML
  7892. */
  7893. set boundingBoxSize(value: Vector3);
  7894. /**
  7895. * Returns the bounding box size
  7896. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7897. */
  7898. get boundingBoxSize(): Vector3;
  7899. protected _rotationY: number;
  7900. /**
  7901. * Sets texture matrix rotation angle around Y axis in radians.
  7902. */
  7903. set rotationY(value: number);
  7904. /**
  7905. * Gets texture matrix rotation angle around Y axis radians.
  7906. */
  7907. get rotationY(): number;
  7908. /**
  7909. * Are mip maps generated for this texture or not.
  7910. */
  7911. get noMipmap(): boolean;
  7912. private _noMipmap;
  7913. private _files;
  7914. protected _forcedExtension: Nullable<string>;
  7915. private _extensions;
  7916. private _textureMatrix;
  7917. private _format;
  7918. private _createPolynomials;
  7919. private _loaderOptions;
  7920. /**
  7921. * Creates a cube texture from an array of image urls
  7922. * @param files defines an array of image urls
  7923. * @param scene defines the hosting scene
  7924. * @param noMipmap specifies if mip maps are not used
  7925. * @returns a cube texture
  7926. */
  7927. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7928. /**
  7929. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7930. * @param url defines the url of the prefiltered texture
  7931. * @param scene defines the scene the texture is attached to
  7932. * @param forcedExtension defines the extension of the file if different from the url
  7933. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7934. * @return the prefiltered texture
  7935. */
  7936. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7937. /**
  7938. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7939. * as prefiltered data.
  7940. * @param rootUrl defines the url of the texture or the root name of the six images
  7941. * @param null defines the scene or engine the texture is attached to
  7942. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7943. * @param noMipmap defines if mipmaps should be created or not
  7944. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7945. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7946. * @param onError defines a callback triggered in case of error during load
  7947. * @param format defines the internal format to use for the texture once loaded
  7948. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7949. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7950. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7951. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7952. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7953. * @param loaderOptions options to be passed to the loader
  7954. * @return the cube texture
  7955. */
  7956. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  7957. /**
  7958. * Get the current class name of the texture useful for serialization or dynamic coding.
  7959. * @returns "CubeTexture"
  7960. */
  7961. getClassName(): string;
  7962. /**
  7963. * Update the url (and optional buffer) of this texture if url was null during construction.
  7964. * @param url the url of the texture
  7965. * @param forcedExtension defines the extension to use
  7966. * @param onLoad callback called when the texture is loaded (defaults to null)
  7967. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7968. */
  7969. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7970. /**
  7971. * Delays loading of the cube texture
  7972. * @param forcedExtension defines the extension to use
  7973. */
  7974. delayLoad(forcedExtension?: string): void;
  7975. /**
  7976. * Returns the reflection texture matrix
  7977. * @returns the reflection texture matrix
  7978. */
  7979. getReflectionTextureMatrix(): Matrix;
  7980. /**
  7981. * Sets the reflection texture matrix
  7982. * @param value Reflection texture matrix
  7983. */
  7984. setReflectionTextureMatrix(value: Matrix): void;
  7985. /**
  7986. * Parses text to create a cube texture
  7987. * @param parsedTexture define the serialized text to read from
  7988. * @param scene defines the hosting scene
  7989. * @param rootUrl defines the root url of the cube texture
  7990. * @returns a cube texture
  7991. */
  7992. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7993. /**
  7994. * Makes a clone, or deep copy, of the cube texture
  7995. * @returns a new cube texture
  7996. */
  7997. clone(): CubeTexture;
  7998. }
  7999. }
  8000. declare module BABYLON {
  8001. /**
  8002. * Manages the defines for the Material
  8003. */
  8004. export class MaterialDefines {
  8005. /** @hidden */
  8006. protected _keys: string[];
  8007. private _isDirty;
  8008. /** @hidden */
  8009. _renderId: number;
  8010. /** @hidden */
  8011. _areLightsDirty: boolean;
  8012. /** @hidden */
  8013. _areLightsDisposed: boolean;
  8014. /** @hidden */
  8015. _areAttributesDirty: boolean;
  8016. /** @hidden */
  8017. _areTexturesDirty: boolean;
  8018. /** @hidden */
  8019. _areFresnelDirty: boolean;
  8020. /** @hidden */
  8021. _areMiscDirty: boolean;
  8022. /** @hidden */
  8023. _arePrePassDirty: boolean;
  8024. /** @hidden */
  8025. _areImageProcessingDirty: boolean;
  8026. /** @hidden */
  8027. _normals: boolean;
  8028. /** @hidden */
  8029. _uvs: boolean;
  8030. /** @hidden */
  8031. _needNormals: boolean;
  8032. /** @hidden */
  8033. _needUVs: boolean;
  8034. [id: string]: any;
  8035. /**
  8036. * Specifies if the material needs to be re-calculated
  8037. */
  8038. get isDirty(): boolean;
  8039. /**
  8040. * Marks the material to indicate that it has been re-calculated
  8041. */
  8042. markAsProcessed(): void;
  8043. /**
  8044. * Marks the material to indicate that it needs to be re-calculated
  8045. */
  8046. markAsUnprocessed(): void;
  8047. /**
  8048. * Marks the material to indicate all of its defines need to be re-calculated
  8049. */
  8050. markAllAsDirty(): void;
  8051. /**
  8052. * Marks the material to indicate that image processing needs to be re-calculated
  8053. */
  8054. markAsImageProcessingDirty(): void;
  8055. /**
  8056. * Marks the material to indicate the lights need to be re-calculated
  8057. * @param disposed Defines whether the light is dirty due to dispose or not
  8058. */
  8059. markAsLightDirty(disposed?: boolean): void;
  8060. /**
  8061. * Marks the attribute state as changed
  8062. */
  8063. markAsAttributesDirty(): void;
  8064. /**
  8065. * Marks the texture state as changed
  8066. */
  8067. markAsTexturesDirty(): void;
  8068. /**
  8069. * Marks the fresnel state as changed
  8070. */
  8071. markAsFresnelDirty(): void;
  8072. /**
  8073. * Marks the misc state as changed
  8074. */
  8075. markAsMiscDirty(): void;
  8076. /**
  8077. * Marks the prepass state as changed
  8078. */
  8079. markAsPrePassDirty(): void;
  8080. /**
  8081. * Rebuilds the material defines
  8082. */
  8083. rebuild(): void;
  8084. /**
  8085. * Specifies if two material defines are equal
  8086. * @param other - A material define instance to compare to
  8087. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8088. */
  8089. isEqual(other: MaterialDefines): boolean;
  8090. /**
  8091. * Clones this instance's defines to another instance
  8092. * @param other - material defines to clone values to
  8093. */
  8094. cloneTo(other: MaterialDefines): void;
  8095. /**
  8096. * Resets the material define values
  8097. */
  8098. reset(): void;
  8099. /**
  8100. * Converts the material define values to a string
  8101. * @returns - String of material define information
  8102. */
  8103. toString(): string;
  8104. }
  8105. }
  8106. declare module BABYLON {
  8107. /**
  8108. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8109. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8110. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8111. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8112. */
  8113. export class ColorCurves {
  8114. private _dirty;
  8115. private _tempColor;
  8116. private _globalCurve;
  8117. private _highlightsCurve;
  8118. private _midtonesCurve;
  8119. private _shadowsCurve;
  8120. private _positiveCurve;
  8121. private _negativeCurve;
  8122. private _globalHue;
  8123. private _globalDensity;
  8124. private _globalSaturation;
  8125. private _globalExposure;
  8126. /**
  8127. * Gets the global Hue value.
  8128. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8129. */
  8130. get globalHue(): number;
  8131. /**
  8132. * Sets the global Hue value.
  8133. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8134. */
  8135. set globalHue(value: number);
  8136. /**
  8137. * Gets the global Density value.
  8138. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8139. * Values less than zero provide a filter of opposite hue.
  8140. */
  8141. get globalDensity(): number;
  8142. /**
  8143. * Sets the global Density value.
  8144. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8145. * Values less than zero provide a filter of opposite hue.
  8146. */
  8147. set globalDensity(value: number);
  8148. /**
  8149. * Gets the global Saturation value.
  8150. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8151. */
  8152. get globalSaturation(): number;
  8153. /**
  8154. * Sets the global Saturation value.
  8155. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8156. */
  8157. set globalSaturation(value: number);
  8158. /**
  8159. * Gets the global Exposure value.
  8160. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8161. */
  8162. get globalExposure(): number;
  8163. /**
  8164. * Sets the global Exposure value.
  8165. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8166. */
  8167. set globalExposure(value: number);
  8168. private _highlightsHue;
  8169. private _highlightsDensity;
  8170. private _highlightsSaturation;
  8171. private _highlightsExposure;
  8172. /**
  8173. * Gets the highlights Hue value.
  8174. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8175. */
  8176. get highlightsHue(): number;
  8177. /**
  8178. * Sets the highlights Hue value.
  8179. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8180. */
  8181. set highlightsHue(value: number);
  8182. /**
  8183. * Gets the highlights Density value.
  8184. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8185. * Values less than zero provide a filter of opposite hue.
  8186. */
  8187. get highlightsDensity(): number;
  8188. /**
  8189. * Sets the highlights Density value.
  8190. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8191. * Values less than zero provide a filter of opposite hue.
  8192. */
  8193. set highlightsDensity(value: number);
  8194. /**
  8195. * Gets the highlights Saturation value.
  8196. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8197. */
  8198. get highlightsSaturation(): number;
  8199. /**
  8200. * Sets the highlights Saturation value.
  8201. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8202. */
  8203. set highlightsSaturation(value: number);
  8204. /**
  8205. * Gets the highlights Exposure value.
  8206. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8207. */
  8208. get highlightsExposure(): number;
  8209. /**
  8210. * Sets the highlights Exposure value.
  8211. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8212. */
  8213. set highlightsExposure(value: number);
  8214. private _midtonesHue;
  8215. private _midtonesDensity;
  8216. private _midtonesSaturation;
  8217. private _midtonesExposure;
  8218. /**
  8219. * Gets the midtones Hue value.
  8220. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8221. */
  8222. get midtonesHue(): number;
  8223. /**
  8224. * Sets the midtones Hue value.
  8225. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8226. */
  8227. set midtonesHue(value: number);
  8228. /**
  8229. * Gets the midtones Density value.
  8230. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8231. * Values less than zero provide a filter of opposite hue.
  8232. */
  8233. get midtonesDensity(): number;
  8234. /**
  8235. * Sets the midtones Density value.
  8236. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8237. * Values less than zero provide a filter of opposite hue.
  8238. */
  8239. set midtonesDensity(value: number);
  8240. /**
  8241. * Gets the midtones Saturation value.
  8242. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8243. */
  8244. get midtonesSaturation(): number;
  8245. /**
  8246. * Sets the midtones Saturation value.
  8247. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8248. */
  8249. set midtonesSaturation(value: number);
  8250. /**
  8251. * Gets the midtones Exposure value.
  8252. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8253. */
  8254. get midtonesExposure(): number;
  8255. /**
  8256. * Sets the midtones Exposure value.
  8257. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8258. */
  8259. set midtonesExposure(value: number);
  8260. private _shadowsHue;
  8261. private _shadowsDensity;
  8262. private _shadowsSaturation;
  8263. private _shadowsExposure;
  8264. /**
  8265. * Gets the shadows Hue value.
  8266. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8267. */
  8268. get shadowsHue(): number;
  8269. /**
  8270. * Sets the shadows Hue value.
  8271. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8272. */
  8273. set shadowsHue(value: number);
  8274. /**
  8275. * Gets the shadows Density value.
  8276. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8277. * Values less than zero provide a filter of opposite hue.
  8278. */
  8279. get shadowsDensity(): number;
  8280. /**
  8281. * Sets the shadows Density value.
  8282. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8283. * Values less than zero provide a filter of opposite hue.
  8284. */
  8285. set shadowsDensity(value: number);
  8286. /**
  8287. * Gets the shadows Saturation value.
  8288. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8289. */
  8290. get shadowsSaturation(): number;
  8291. /**
  8292. * Sets the shadows Saturation value.
  8293. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8294. */
  8295. set shadowsSaturation(value: number);
  8296. /**
  8297. * Gets the shadows Exposure value.
  8298. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8299. */
  8300. get shadowsExposure(): number;
  8301. /**
  8302. * Sets the shadows Exposure value.
  8303. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8304. */
  8305. set shadowsExposure(value: number);
  8306. /**
  8307. * Returns the class name
  8308. * @returns The class name
  8309. */
  8310. getClassName(): string;
  8311. /**
  8312. * Binds the color curves to the shader.
  8313. * @param colorCurves The color curve to bind
  8314. * @param effect The effect to bind to
  8315. * @param positiveUniform The positive uniform shader parameter
  8316. * @param neutralUniform The neutral uniform shader parameter
  8317. * @param negativeUniform The negative uniform shader parameter
  8318. */
  8319. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8320. /**
  8321. * Prepare the list of uniforms associated with the ColorCurves effects.
  8322. * @param uniformsList The list of uniforms used in the effect
  8323. */
  8324. static PrepareUniforms(uniformsList: string[]): void;
  8325. /**
  8326. * Returns color grading data based on a hue, density, saturation and exposure value.
  8327. * @param filterHue The hue of the color filter.
  8328. * @param filterDensity The density of the color filter.
  8329. * @param saturation The saturation.
  8330. * @param exposure The exposure.
  8331. * @param result The result data container.
  8332. */
  8333. private getColorGradingDataToRef;
  8334. /**
  8335. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8336. * @param value The input slider value in range [-100,100].
  8337. * @returns Adjusted value.
  8338. */
  8339. private static applyColorGradingSliderNonlinear;
  8340. /**
  8341. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8342. * @param hue The hue (H) input.
  8343. * @param saturation The saturation (S) input.
  8344. * @param brightness The brightness (B) input.
  8345. * @result An RGBA color represented as Vector4.
  8346. */
  8347. private static fromHSBToRef;
  8348. /**
  8349. * Returns a value clamped between min and max
  8350. * @param value The value to clamp
  8351. * @param min The minimum of value
  8352. * @param max The maximum of value
  8353. * @returns The clamped value.
  8354. */
  8355. private static clamp;
  8356. /**
  8357. * Clones the current color curve instance.
  8358. * @return The cloned curves
  8359. */
  8360. clone(): ColorCurves;
  8361. /**
  8362. * Serializes the current color curve instance to a json representation.
  8363. * @return a JSON representation
  8364. */
  8365. serialize(): any;
  8366. /**
  8367. * Parses the color curve from a json representation.
  8368. * @param source the JSON source to parse
  8369. * @return The parsed curves
  8370. */
  8371. static Parse(source: any): ColorCurves;
  8372. }
  8373. }
  8374. declare module BABYLON {
  8375. /**
  8376. * Interface to follow in your material defines to integrate easily the
  8377. * Image proccessing functions.
  8378. * @hidden
  8379. */
  8380. export interface IImageProcessingConfigurationDefines {
  8381. IMAGEPROCESSING: boolean;
  8382. VIGNETTE: boolean;
  8383. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8384. VIGNETTEBLENDMODEOPAQUE: boolean;
  8385. TONEMAPPING: boolean;
  8386. TONEMAPPING_ACES: boolean;
  8387. CONTRAST: boolean;
  8388. EXPOSURE: boolean;
  8389. COLORCURVES: boolean;
  8390. COLORGRADING: boolean;
  8391. COLORGRADING3D: boolean;
  8392. SAMPLER3DGREENDEPTH: boolean;
  8393. SAMPLER3DBGRMAP: boolean;
  8394. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8395. }
  8396. /**
  8397. * @hidden
  8398. */
  8399. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8400. IMAGEPROCESSING: boolean;
  8401. VIGNETTE: boolean;
  8402. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8403. VIGNETTEBLENDMODEOPAQUE: boolean;
  8404. TONEMAPPING: boolean;
  8405. TONEMAPPING_ACES: boolean;
  8406. CONTRAST: boolean;
  8407. COLORCURVES: boolean;
  8408. COLORGRADING: boolean;
  8409. COLORGRADING3D: boolean;
  8410. SAMPLER3DGREENDEPTH: boolean;
  8411. SAMPLER3DBGRMAP: boolean;
  8412. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8413. EXPOSURE: boolean;
  8414. constructor();
  8415. }
  8416. /**
  8417. * This groups together the common properties used for image processing either in direct forward pass
  8418. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8419. * or not.
  8420. */
  8421. export class ImageProcessingConfiguration {
  8422. /**
  8423. * Default tone mapping applied in BabylonJS.
  8424. */
  8425. static readonly TONEMAPPING_STANDARD: number;
  8426. /**
  8427. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8428. * to other engines rendering to increase portability.
  8429. */
  8430. static readonly TONEMAPPING_ACES: number;
  8431. /**
  8432. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8433. */
  8434. colorCurves: Nullable<ColorCurves>;
  8435. private _colorCurvesEnabled;
  8436. /**
  8437. * Gets wether the color curves effect is enabled.
  8438. */
  8439. get colorCurvesEnabled(): boolean;
  8440. /**
  8441. * Sets wether the color curves effect is enabled.
  8442. */
  8443. set colorCurvesEnabled(value: boolean);
  8444. private _colorGradingTexture;
  8445. /**
  8446. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8447. */
  8448. get colorGradingTexture(): Nullable<BaseTexture>;
  8449. /**
  8450. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8451. */
  8452. set colorGradingTexture(value: Nullable<BaseTexture>);
  8453. private _colorGradingEnabled;
  8454. /**
  8455. * Gets wether the color grading effect is enabled.
  8456. */
  8457. get colorGradingEnabled(): boolean;
  8458. /**
  8459. * Sets wether the color grading effect is enabled.
  8460. */
  8461. set colorGradingEnabled(value: boolean);
  8462. private _colorGradingWithGreenDepth;
  8463. /**
  8464. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8465. */
  8466. get colorGradingWithGreenDepth(): boolean;
  8467. /**
  8468. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8469. */
  8470. set colorGradingWithGreenDepth(value: boolean);
  8471. private _colorGradingBGR;
  8472. /**
  8473. * Gets wether the color grading texture contains BGR values.
  8474. */
  8475. get colorGradingBGR(): boolean;
  8476. /**
  8477. * Sets wether the color grading texture contains BGR values.
  8478. */
  8479. set colorGradingBGR(value: boolean);
  8480. /** @hidden */
  8481. _exposure: number;
  8482. /**
  8483. * Gets the Exposure used in the effect.
  8484. */
  8485. get exposure(): number;
  8486. /**
  8487. * Sets the Exposure used in the effect.
  8488. */
  8489. set exposure(value: number);
  8490. private _toneMappingEnabled;
  8491. /**
  8492. * Gets wether the tone mapping effect is enabled.
  8493. */
  8494. get toneMappingEnabled(): boolean;
  8495. /**
  8496. * Sets wether the tone mapping effect is enabled.
  8497. */
  8498. set toneMappingEnabled(value: boolean);
  8499. private _toneMappingType;
  8500. /**
  8501. * Gets the type of tone mapping effect.
  8502. */
  8503. get toneMappingType(): number;
  8504. /**
  8505. * Sets the type of tone mapping effect used in BabylonJS.
  8506. */
  8507. set toneMappingType(value: number);
  8508. protected _contrast: number;
  8509. /**
  8510. * Gets the contrast used in the effect.
  8511. */
  8512. get contrast(): number;
  8513. /**
  8514. * Sets the contrast used in the effect.
  8515. */
  8516. set contrast(value: number);
  8517. /**
  8518. * Vignette stretch size.
  8519. */
  8520. vignetteStretch: number;
  8521. /**
  8522. * Vignette centre X Offset.
  8523. */
  8524. vignetteCentreX: number;
  8525. /**
  8526. * Vignette centre Y Offset.
  8527. */
  8528. vignetteCentreY: number;
  8529. /**
  8530. * Vignette weight or intensity of the vignette effect.
  8531. */
  8532. vignetteWeight: number;
  8533. /**
  8534. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8535. * if vignetteEnabled is set to true.
  8536. */
  8537. vignetteColor: Color4;
  8538. /**
  8539. * Camera field of view used by the Vignette effect.
  8540. */
  8541. vignetteCameraFov: number;
  8542. private _vignetteBlendMode;
  8543. /**
  8544. * Gets the vignette blend mode allowing different kind of effect.
  8545. */
  8546. get vignetteBlendMode(): number;
  8547. /**
  8548. * Sets the vignette blend mode allowing different kind of effect.
  8549. */
  8550. set vignetteBlendMode(value: number);
  8551. private _vignetteEnabled;
  8552. /**
  8553. * Gets wether the vignette effect is enabled.
  8554. */
  8555. get vignetteEnabled(): boolean;
  8556. /**
  8557. * Sets wether the vignette effect is enabled.
  8558. */
  8559. set vignetteEnabled(value: boolean);
  8560. private _applyByPostProcess;
  8561. /**
  8562. * Gets wether the image processing is applied through a post process or not.
  8563. */
  8564. get applyByPostProcess(): boolean;
  8565. /**
  8566. * Sets wether the image processing is applied through a post process or not.
  8567. */
  8568. set applyByPostProcess(value: boolean);
  8569. private _isEnabled;
  8570. /**
  8571. * Gets wether the image processing is enabled or not.
  8572. */
  8573. get isEnabled(): boolean;
  8574. /**
  8575. * Sets wether the image processing is enabled or not.
  8576. */
  8577. set isEnabled(value: boolean);
  8578. /**
  8579. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8580. */
  8581. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8582. /**
  8583. * Method called each time the image processing information changes requires to recompile the effect.
  8584. */
  8585. protected _updateParameters(): void;
  8586. /**
  8587. * Gets the current class name.
  8588. * @return "ImageProcessingConfiguration"
  8589. */
  8590. getClassName(): string;
  8591. /**
  8592. * Prepare the list of uniforms associated with the Image Processing effects.
  8593. * @param uniforms The list of uniforms used in the effect
  8594. * @param defines the list of defines currently in use
  8595. */
  8596. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8597. /**
  8598. * Prepare the list of samplers associated with the Image Processing effects.
  8599. * @param samplersList The list of uniforms used in the effect
  8600. * @param defines the list of defines currently in use
  8601. */
  8602. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8603. /**
  8604. * Prepare the list of defines associated to the shader.
  8605. * @param defines the list of defines to complete
  8606. * @param forPostProcess Define if we are currently in post process mode or not
  8607. */
  8608. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8609. /**
  8610. * Returns true if all the image processing information are ready.
  8611. * @returns True if ready, otherwise, false
  8612. */
  8613. isReady(): boolean;
  8614. /**
  8615. * Binds the image processing to the shader.
  8616. * @param effect The effect to bind to
  8617. * @param overrideAspectRatio Override the aspect ratio of the effect
  8618. */
  8619. bind(effect: Effect, overrideAspectRatio?: number): void;
  8620. /**
  8621. * Clones the current image processing instance.
  8622. * @return The cloned image processing
  8623. */
  8624. clone(): ImageProcessingConfiguration;
  8625. /**
  8626. * Serializes the current image processing instance to a json representation.
  8627. * @return a JSON representation
  8628. */
  8629. serialize(): any;
  8630. /**
  8631. * Parses the image processing from a json representation.
  8632. * @param source the JSON source to parse
  8633. * @return The parsed image processing
  8634. */
  8635. static Parse(source: any): ImageProcessingConfiguration;
  8636. private static _VIGNETTEMODE_MULTIPLY;
  8637. private static _VIGNETTEMODE_OPAQUE;
  8638. /**
  8639. * Used to apply the vignette as a mix with the pixel color.
  8640. */
  8641. static get VIGNETTEMODE_MULTIPLY(): number;
  8642. /**
  8643. * Used to apply the vignette as a replacement of the pixel color.
  8644. */
  8645. static get VIGNETTEMODE_OPAQUE(): number;
  8646. }
  8647. }
  8648. declare module BABYLON {
  8649. /** @hidden */
  8650. export var postprocessVertexShader: {
  8651. name: string;
  8652. shader: string;
  8653. };
  8654. }
  8655. declare module BABYLON {
  8656. /**
  8657. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8658. */
  8659. export type RenderTargetTextureSize = number | {
  8660. width: number;
  8661. height: number;
  8662. layers?: number;
  8663. };
  8664. interface ThinEngine {
  8665. /**
  8666. * Creates a new render target texture
  8667. * @param size defines the size of the texture
  8668. * @param options defines the options used to create the texture
  8669. * @returns a new render target texture stored in an InternalTexture
  8670. */
  8671. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8672. /**
  8673. * Creates a depth stencil texture.
  8674. * This is only available in WebGL 2 or with the depth texture extension available.
  8675. * @param size The size of face edge in the texture.
  8676. * @param options The options defining the texture.
  8677. * @returns The texture
  8678. */
  8679. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8680. /** @hidden */
  8681. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8682. }
  8683. }
  8684. declare module BABYLON {
  8685. /**
  8686. * Defines the kind of connection point for node based material
  8687. */
  8688. export enum NodeMaterialBlockConnectionPointTypes {
  8689. /** Float */
  8690. Float = 1,
  8691. /** Int */
  8692. Int = 2,
  8693. /** Vector2 */
  8694. Vector2 = 4,
  8695. /** Vector3 */
  8696. Vector3 = 8,
  8697. /** Vector4 */
  8698. Vector4 = 16,
  8699. /** Color3 */
  8700. Color3 = 32,
  8701. /** Color4 */
  8702. Color4 = 64,
  8703. /** Matrix */
  8704. Matrix = 128,
  8705. /** Custom object */
  8706. Object = 256,
  8707. /** Detect type based on connection */
  8708. AutoDetect = 1024,
  8709. /** Output type that will be defined by input type */
  8710. BasedOnInput = 2048
  8711. }
  8712. }
  8713. declare module BABYLON {
  8714. /**
  8715. * Enum used to define the target of a block
  8716. */
  8717. export enum NodeMaterialBlockTargets {
  8718. /** Vertex shader */
  8719. Vertex = 1,
  8720. /** Fragment shader */
  8721. Fragment = 2,
  8722. /** Neutral */
  8723. Neutral = 4,
  8724. /** Vertex and Fragment */
  8725. VertexAndFragment = 3
  8726. }
  8727. }
  8728. declare module BABYLON {
  8729. /**
  8730. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8731. */
  8732. export enum NodeMaterialBlockConnectionPointMode {
  8733. /** Value is an uniform */
  8734. Uniform = 0,
  8735. /** Value is a mesh attribute */
  8736. Attribute = 1,
  8737. /** Value is a varying between vertex and fragment shaders */
  8738. Varying = 2,
  8739. /** Mode is undefined */
  8740. Undefined = 3
  8741. }
  8742. }
  8743. declare module BABYLON {
  8744. /**
  8745. * Enum used to define system values e.g. values automatically provided by the system
  8746. */
  8747. export enum NodeMaterialSystemValues {
  8748. /** World */
  8749. World = 1,
  8750. /** View */
  8751. View = 2,
  8752. /** Projection */
  8753. Projection = 3,
  8754. /** ViewProjection */
  8755. ViewProjection = 4,
  8756. /** WorldView */
  8757. WorldView = 5,
  8758. /** WorldViewProjection */
  8759. WorldViewProjection = 6,
  8760. /** CameraPosition */
  8761. CameraPosition = 7,
  8762. /** Fog Color */
  8763. FogColor = 8,
  8764. /** Delta time */
  8765. DeltaTime = 9
  8766. }
  8767. }
  8768. declare module BABYLON {
  8769. /** Defines supported spaces */
  8770. export enum Space {
  8771. /** Local (object) space */
  8772. LOCAL = 0,
  8773. /** World space */
  8774. WORLD = 1,
  8775. /** Bone space */
  8776. BONE = 2
  8777. }
  8778. /** Defines the 3 main axes */
  8779. export class Axis {
  8780. /** X axis */
  8781. static X: Vector3;
  8782. /** Y axis */
  8783. static Y: Vector3;
  8784. /** Z axis */
  8785. static Z: Vector3;
  8786. }
  8787. /**
  8788. * Defines cartesian components.
  8789. */
  8790. export enum Coordinate {
  8791. /** X axis */
  8792. X = 0,
  8793. /** Y axis */
  8794. Y = 1,
  8795. /** Z axis */
  8796. Z = 2
  8797. }
  8798. }
  8799. declare module BABYLON {
  8800. /**
  8801. * Represents a camera frustum
  8802. */
  8803. export class Frustum {
  8804. /**
  8805. * Gets the planes representing the frustum
  8806. * @param transform matrix to be applied to the returned planes
  8807. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8808. */
  8809. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8810. /**
  8811. * Gets the near frustum plane transformed by the transform matrix
  8812. * @param transform transformation matrix to be applied to the resulting frustum plane
  8813. * @param frustumPlane the resuling frustum plane
  8814. */
  8815. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8816. /**
  8817. * Gets the far frustum plane transformed by the transform matrix
  8818. * @param transform transformation matrix to be applied to the resulting frustum plane
  8819. * @param frustumPlane the resuling frustum plane
  8820. */
  8821. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8822. /**
  8823. * Gets the left frustum plane transformed by the transform matrix
  8824. * @param transform transformation matrix to be applied to the resulting frustum plane
  8825. * @param frustumPlane the resuling frustum plane
  8826. */
  8827. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8828. /**
  8829. * Gets the right frustum plane transformed by the transform matrix
  8830. * @param transform transformation matrix to be applied to the resulting frustum plane
  8831. * @param frustumPlane the resuling frustum plane
  8832. */
  8833. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8834. /**
  8835. * Gets the top frustum plane transformed by the transform matrix
  8836. * @param transform transformation matrix to be applied to the resulting frustum plane
  8837. * @param frustumPlane the resuling frustum plane
  8838. */
  8839. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8840. /**
  8841. * Gets the bottom frustum plane transformed by the transform matrix
  8842. * @param transform transformation matrix to be applied to the resulting frustum plane
  8843. * @param frustumPlane the resuling frustum plane
  8844. */
  8845. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8846. /**
  8847. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8848. * @param transform transformation matrix to be applied to the resulting frustum planes
  8849. * @param frustumPlanes the resuling frustum planes
  8850. */
  8851. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8852. }
  8853. }
  8854. declare module BABYLON {
  8855. /**
  8856. * Interface for the size containing width and height
  8857. */
  8858. export interface ISize {
  8859. /**
  8860. * Width
  8861. */
  8862. width: number;
  8863. /**
  8864. * Heighht
  8865. */
  8866. height: number;
  8867. }
  8868. /**
  8869. * Size containing widht and height
  8870. */
  8871. export class Size implements ISize {
  8872. /**
  8873. * Width
  8874. */
  8875. width: number;
  8876. /**
  8877. * Height
  8878. */
  8879. height: number;
  8880. /**
  8881. * Creates a Size object from the given width and height (floats).
  8882. * @param width width of the new size
  8883. * @param height height of the new size
  8884. */
  8885. constructor(width: number, height: number);
  8886. /**
  8887. * Returns a string with the Size width and height
  8888. * @returns a string with the Size width and height
  8889. */
  8890. toString(): string;
  8891. /**
  8892. * "Size"
  8893. * @returns the string "Size"
  8894. */
  8895. getClassName(): string;
  8896. /**
  8897. * Returns the Size hash code.
  8898. * @returns a hash code for a unique width and height
  8899. */
  8900. getHashCode(): number;
  8901. /**
  8902. * Updates the current size from the given one.
  8903. * @param src the given size
  8904. */
  8905. copyFrom(src: Size): void;
  8906. /**
  8907. * Updates in place the current Size from the given floats.
  8908. * @param width width of the new size
  8909. * @param height height of the new size
  8910. * @returns the updated Size.
  8911. */
  8912. copyFromFloats(width: number, height: number): Size;
  8913. /**
  8914. * Updates in place the current Size from the given floats.
  8915. * @param width width to set
  8916. * @param height height to set
  8917. * @returns the updated Size.
  8918. */
  8919. set(width: number, height: number): Size;
  8920. /**
  8921. * Multiplies the width and height by numbers
  8922. * @param w factor to multiple the width by
  8923. * @param h factor to multiple the height by
  8924. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8925. */
  8926. multiplyByFloats(w: number, h: number): Size;
  8927. /**
  8928. * Clones the size
  8929. * @returns a new Size copied from the given one.
  8930. */
  8931. clone(): Size;
  8932. /**
  8933. * True if the current Size and the given one width and height are strictly equal.
  8934. * @param other the other size to compare against
  8935. * @returns True if the current Size and the given one width and height are strictly equal.
  8936. */
  8937. equals(other: Size): boolean;
  8938. /**
  8939. * The surface of the Size : width * height (float).
  8940. */
  8941. get surface(): number;
  8942. /**
  8943. * Create a new size of zero
  8944. * @returns a new Size set to (0.0, 0.0)
  8945. */
  8946. static Zero(): Size;
  8947. /**
  8948. * Sums the width and height of two sizes
  8949. * @param otherSize size to add to this size
  8950. * @returns a new Size set as the addition result of the current Size and the given one.
  8951. */
  8952. add(otherSize: Size): Size;
  8953. /**
  8954. * Subtracts the width and height of two
  8955. * @param otherSize size to subtract to this size
  8956. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8957. */
  8958. subtract(otherSize: Size): Size;
  8959. /**
  8960. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8961. * @param start starting size to lerp between
  8962. * @param end end size to lerp between
  8963. * @param amount amount to lerp between the start and end values
  8964. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8965. */
  8966. static Lerp(start: Size, end: Size, amount: number): Size;
  8967. }
  8968. }
  8969. declare module BABYLON {
  8970. /**
  8971. * Contains position and normal vectors for a vertex
  8972. */
  8973. export class PositionNormalVertex {
  8974. /** the position of the vertex (defaut: 0,0,0) */
  8975. position: Vector3;
  8976. /** the normal of the vertex (defaut: 0,1,0) */
  8977. normal: Vector3;
  8978. /**
  8979. * Creates a PositionNormalVertex
  8980. * @param position the position of the vertex (defaut: 0,0,0)
  8981. * @param normal the normal of the vertex (defaut: 0,1,0)
  8982. */
  8983. constructor(
  8984. /** the position of the vertex (defaut: 0,0,0) */
  8985. position?: Vector3,
  8986. /** the normal of the vertex (defaut: 0,1,0) */
  8987. normal?: Vector3);
  8988. /**
  8989. * Clones the PositionNormalVertex
  8990. * @returns the cloned PositionNormalVertex
  8991. */
  8992. clone(): PositionNormalVertex;
  8993. }
  8994. /**
  8995. * Contains position, normal and uv vectors for a vertex
  8996. */
  8997. export class PositionNormalTextureVertex {
  8998. /** the position of the vertex (defaut: 0,0,0) */
  8999. position: Vector3;
  9000. /** the normal of the vertex (defaut: 0,1,0) */
  9001. normal: Vector3;
  9002. /** the uv of the vertex (default: 0,0) */
  9003. uv: Vector2;
  9004. /**
  9005. * Creates a PositionNormalTextureVertex
  9006. * @param position the position of the vertex (defaut: 0,0,0)
  9007. * @param normal the normal of the vertex (defaut: 0,1,0)
  9008. * @param uv the uv of the vertex (default: 0,0)
  9009. */
  9010. constructor(
  9011. /** the position of the vertex (defaut: 0,0,0) */
  9012. position?: Vector3,
  9013. /** the normal of the vertex (defaut: 0,1,0) */
  9014. normal?: Vector3,
  9015. /** the uv of the vertex (default: 0,0) */
  9016. uv?: Vector2);
  9017. /**
  9018. * Clones the PositionNormalTextureVertex
  9019. * @returns the cloned PositionNormalTextureVertex
  9020. */
  9021. clone(): PositionNormalTextureVertex;
  9022. }
  9023. }
  9024. declare module BABYLON {
  9025. /**
  9026. * Enum defining the type of animations supported by InputBlock
  9027. */
  9028. export enum AnimatedInputBlockTypes {
  9029. /** No animation */
  9030. None = 0,
  9031. /** Time based animation. Will only work for floats */
  9032. Time = 1
  9033. }
  9034. }
  9035. declare module BABYLON {
  9036. /**
  9037. * Interface describing all the common properties and methods a shadow light needs to implement.
  9038. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9039. * as well as binding the different shadow properties to the effects.
  9040. */
  9041. export interface IShadowLight extends Light {
  9042. /**
  9043. * The light id in the scene (used in scene.findLighById for instance)
  9044. */
  9045. id: string;
  9046. /**
  9047. * The position the shdow will be casted from.
  9048. */
  9049. position: Vector3;
  9050. /**
  9051. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9052. */
  9053. direction: Vector3;
  9054. /**
  9055. * The transformed position. Position of the light in world space taking parenting in account.
  9056. */
  9057. transformedPosition: Vector3;
  9058. /**
  9059. * The transformed direction. Direction of the light in world space taking parenting in account.
  9060. */
  9061. transformedDirection: Vector3;
  9062. /**
  9063. * The friendly name of the light in the scene.
  9064. */
  9065. name: string;
  9066. /**
  9067. * Defines the shadow projection clipping minimum z value.
  9068. */
  9069. shadowMinZ: number;
  9070. /**
  9071. * Defines the shadow projection clipping maximum z value.
  9072. */
  9073. shadowMaxZ: number;
  9074. /**
  9075. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9076. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9077. */
  9078. computeTransformedInformation(): boolean;
  9079. /**
  9080. * Gets the scene the light belongs to.
  9081. * @returns The scene
  9082. */
  9083. getScene(): Scene;
  9084. /**
  9085. * Callback defining a custom Projection Matrix Builder.
  9086. * This can be used to override the default projection matrix computation.
  9087. */
  9088. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9089. /**
  9090. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9091. * @param matrix The materix to updated with the projection information
  9092. * @param viewMatrix The transform matrix of the light
  9093. * @param renderList The list of mesh to render in the map
  9094. * @returns The current light
  9095. */
  9096. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9097. /**
  9098. * Gets the current depth scale used in ESM.
  9099. * @returns The scale
  9100. */
  9101. getDepthScale(): number;
  9102. /**
  9103. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9104. * @returns true if a cube texture needs to be use
  9105. */
  9106. needCube(): boolean;
  9107. /**
  9108. * Detects if the projection matrix requires to be recomputed this frame.
  9109. * @returns true if it requires to be recomputed otherwise, false.
  9110. */
  9111. needProjectionMatrixCompute(): boolean;
  9112. /**
  9113. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9114. */
  9115. forceProjectionMatrixCompute(): void;
  9116. /**
  9117. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9118. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9119. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9120. */
  9121. getShadowDirection(faceIndex?: number): Vector3;
  9122. /**
  9123. * Gets the minZ used for shadow according to both the scene and the light.
  9124. * @param activeCamera The camera we are returning the min for
  9125. * @returns the depth min z
  9126. */
  9127. getDepthMinZ(activeCamera: Camera): number;
  9128. /**
  9129. * Gets the maxZ used for shadow according to both the scene and the light.
  9130. * @param activeCamera The camera we are returning the max for
  9131. * @returns the depth max z
  9132. */
  9133. getDepthMaxZ(activeCamera: Camera): number;
  9134. }
  9135. /**
  9136. * Base implementation IShadowLight
  9137. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9138. */
  9139. export abstract class ShadowLight extends Light implements IShadowLight {
  9140. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9141. protected _position: Vector3;
  9142. protected _setPosition(value: Vector3): void;
  9143. /**
  9144. * Sets the position the shadow will be casted from. Also use as the light position for both
  9145. * point and spot lights.
  9146. */
  9147. get position(): Vector3;
  9148. /**
  9149. * Sets the position the shadow will be casted from. Also use as the light position for both
  9150. * point and spot lights.
  9151. */
  9152. set position(value: Vector3);
  9153. protected _direction: Vector3;
  9154. protected _setDirection(value: Vector3): void;
  9155. /**
  9156. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9157. * Also use as the light direction on spot and directional lights.
  9158. */
  9159. get direction(): Vector3;
  9160. /**
  9161. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9162. * Also use as the light direction on spot and directional lights.
  9163. */
  9164. set direction(value: Vector3);
  9165. protected _shadowMinZ: number;
  9166. /**
  9167. * Gets the shadow projection clipping minimum z value.
  9168. */
  9169. get shadowMinZ(): number;
  9170. /**
  9171. * Sets the shadow projection clipping minimum z value.
  9172. */
  9173. set shadowMinZ(value: number);
  9174. protected _shadowMaxZ: number;
  9175. /**
  9176. * Sets the shadow projection clipping maximum z value.
  9177. */
  9178. get shadowMaxZ(): number;
  9179. /**
  9180. * Gets the shadow projection clipping maximum z value.
  9181. */
  9182. set shadowMaxZ(value: number);
  9183. /**
  9184. * Callback defining a custom Projection Matrix Builder.
  9185. * This can be used to override the default projection matrix computation.
  9186. */
  9187. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9188. /**
  9189. * The transformed position. Position of the light in world space taking parenting in account.
  9190. */
  9191. transformedPosition: Vector3;
  9192. /**
  9193. * The transformed direction. Direction of the light in world space taking parenting in account.
  9194. */
  9195. transformedDirection: Vector3;
  9196. private _needProjectionMatrixCompute;
  9197. /**
  9198. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9199. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9200. */
  9201. computeTransformedInformation(): boolean;
  9202. /**
  9203. * Return the depth scale used for the shadow map.
  9204. * @returns the depth scale.
  9205. */
  9206. getDepthScale(): number;
  9207. /**
  9208. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9209. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9210. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9211. */
  9212. getShadowDirection(faceIndex?: number): Vector3;
  9213. /**
  9214. * Returns the ShadowLight absolute position in the World.
  9215. * @returns the position vector in world space
  9216. */
  9217. getAbsolutePosition(): Vector3;
  9218. /**
  9219. * Sets the ShadowLight direction toward the passed target.
  9220. * @param target The point to target in local space
  9221. * @returns the updated ShadowLight direction
  9222. */
  9223. setDirectionToTarget(target: Vector3): Vector3;
  9224. /**
  9225. * Returns the light rotation in euler definition.
  9226. * @returns the x y z rotation in local space.
  9227. */
  9228. getRotation(): Vector3;
  9229. /**
  9230. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9231. * @returns true if a cube texture needs to be use
  9232. */
  9233. needCube(): boolean;
  9234. /**
  9235. * Detects if the projection matrix requires to be recomputed this frame.
  9236. * @returns true if it requires to be recomputed otherwise, false.
  9237. */
  9238. needProjectionMatrixCompute(): boolean;
  9239. /**
  9240. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9241. */
  9242. forceProjectionMatrixCompute(): void;
  9243. /** @hidden */
  9244. _initCache(): void;
  9245. /** @hidden */
  9246. _isSynchronized(): boolean;
  9247. /**
  9248. * Computes the world matrix of the node
  9249. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9250. * @returns the world matrix
  9251. */
  9252. computeWorldMatrix(force?: boolean): Matrix;
  9253. /**
  9254. * Gets the minZ used for shadow according to both the scene and the light.
  9255. * @param activeCamera The camera we are returning the min for
  9256. * @returns the depth min z
  9257. */
  9258. getDepthMinZ(activeCamera: Camera): number;
  9259. /**
  9260. * Gets the maxZ used for shadow according to both the scene and the light.
  9261. * @param activeCamera The camera we are returning the max for
  9262. * @returns the depth max z
  9263. */
  9264. getDepthMaxZ(activeCamera: Camera): number;
  9265. /**
  9266. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9267. * @param matrix The materix to updated with the projection information
  9268. * @param viewMatrix The transform matrix of the light
  9269. * @param renderList The list of mesh to render in the map
  9270. * @returns The current light
  9271. */
  9272. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9273. }
  9274. }
  9275. declare module BABYLON {
  9276. /** @hidden */
  9277. export var packingFunctions: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module BABYLON {
  9283. /** @hidden */
  9284. export var bayerDitherFunctions: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module BABYLON {
  9290. /** @hidden */
  9291. export var shadowMapFragmentDeclaration: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module BABYLON {
  9297. /** @hidden */
  9298. export var clipPlaneFragmentDeclaration: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module BABYLON {
  9304. /** @hidden */
  9305. export var clipPlaneFragment: {
  9306. name: string;
  9307. shader: string;
  9308. };
  9309. }
  9310. declare module BABYLON {
  9311. /** @hidden */
  9312. export var shadowMapFragment: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module BABYLON {
  9318. /** @hidden */
  9319. export var shadowMapPixelShader: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module BABYLON {
  9325. /** @hidden */
  9326. export var bonesDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module BABYLON {
  9332. /** @hidden */
  9333. export var morphTargetsVertexGlobalDeclaration: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var morphTargetsVertexDeclaration: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var instancesDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var helperFunctions: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var shadowMapVertexDeclaration: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var clipPlaneVertexDeclaration: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /** @hidden */
  9375. export var morphTargetsVertex: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module BABYLON {
  9381. /** @hidden */
  9382. export var instancesVertex: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module BABYLON {
  9388. /** @hidden */
  9389. export var bonesVertex: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module BABYLON {
  9395. /** @hidden */
  9396. export var shadowMapVertexNormalBias: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module BABYLON {
  9402. /** @hidden */
  9403. export var shadowMapVertexMetric: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var clipPlaneVertex: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var shadowMapVertexShader: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /** @hidden */
  9424. export var depthBoxBlurPixelShader: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module BABYLON {
  9430. /** @hidden */
  9431. export var shadowMapFragmentSoftTransparentShadow: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module BABYLON {
  9437. /**
  9438. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9439. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9440. */
  9441. export class EffectFallbacks implements IEffectFallbacks {
  9442. private _defines;
  9443. private _currentRank;
  9444. private _maxRank;
  9445. private _mesh;
  9446. /**
  9447. * Removes the fallback from the bound mesh.
  9448. */
  9449. unBindMesh(): void;
  9450. /**
  9451. * Adds a fallback on the specified property.
  9452. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9453. * @param define The name of the define in the shader
  9454. */
  9455. addFallback(rank: number, define: string): void;
  9456. /**
  9457. * Sets the mesh to use CPU skinning when needing to fallback.
  9458. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9459. * @param mesh The mesh to use the fallbacks.
  9460. */
  9461. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9462. /**
  9463. * Checks to see if more fallbacks are still availible.
  9464. */
  9465. get hasMoreFallbacks(): boolean;
  9466. /**
  9467. * Removes the defines that should be removed when falling back.
  9468. * @param currentDefines defines the current define statements for the shader.
  9469. * @param effect defines the current effect we try to compile
  9470. * @returns The resulting defines with defines of the current rank removed.
  9471. */
  9472. reduce(currentDefines: string, effect: Effect): string;
  9473. }
  9474. }
  9475. declare module BABYLON {
  9476. /**
  9477. * Interface used to define Action
  9478. */
  9479. export interface IAction {
  9480. /**
  9481. * Trigger for the action
  9482. */
  9483. trigger: number;
  9484. /** Options of the trigger */
  9485. triggerOptions: any;
  9486. /**
  9487. * Gets the trigger parameters
  9488. * @returns the trigger parameters
  9489. */
  9490. getTriggerParameter(): any;
  9491. /**
  9492. * Internal only - executes current action event
  9493. * @hidden
  9494. */
  9495. _executeCurrent(evt?: ActionEvent): void;
  9496. /**
  9497. * Serialize placeholder for child classes
  9498. * @param parent of child
  9499. * @returns the serialized object
  9500. */
  9501. serialize(parent: any): any;
  9502. /**
  9503. * Internal only
  9504. * @hidden
  9505. */
  9506. _prepare(): void;
  9507. /**
  9508. * Internal only - manager for action
  9509. * @hidden
  9510. */
  9511. _actionManager: Nullable<AbstractActionManager>;
  9512. /**
  9513. * Adds action to chain of actions, may be a DoNothingAction
  9514. * @param action defines the next action to execute
  9515. * @returns The action passed in
  9516. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9517. */
  9518. then(action: IAction): IAction;
  9519. }
  9520. /**
  9521. * The action to be carried out following a trigger
  9522. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9523. */
  9524. export class Action implements IAction {
  9525. /** the trigger, with or without parameters, for the action */
  9526. triggerOptions: any;
  9527. /**
  9528. * Trigger for the action
  9529. */
  9530. trigger: number;
  9531. /**
  9532. * Internal only - manager for action
  9533. * @hidden
  9534. */
  9535. _actionManager: ActionManager;
  9536. private _nextActiveAction;
  9537. private _child;
  9538. private _condition?;
  9539. private _triggerParameter;
  9540. /**
  9541. * An event triggered prior to action being executed.
  9542. */
  9543. onBeforeExecuteObservable: Observable<Action>;
  9544. /**
  9545. * Creates a new Action
  9546. * @param triggerOptions the trigger, with or without parameters, for the action
  9547. * @param condition an optional determinant of action
  9548. */
  9549. constructor(
  9550. /** the trigger, with or without parameters, for the action */
  9551. triggerOptions: any, condition?: Condition);
  9552. /**
  9553. * Internal only
  9554. * @hidden
  9555. */
  9556. _prepare(): void;
  9557. /**
  9558. * Gets the trigger parameters
  9559. * @returns the trigger parameters
  9560. */
  9561. getTriggerParameter(): any;
  9562. /**
  9563. * Internal only - executes current action event
  9564. * @hidden
  9565. */
  9566. _executeCurrent(evt?: ActionEvent): void;
  9567. /**
  9568. * Execute placeholder for child classes
  9569. * @param evt optional action event
  9570. */
  9571. execute(evt?: ActionEvent): void;
  9572. /**
  9573. * Skips to next active action
  9574. */
  9575. skipToNextActiveAction(): void;
  9576. /**
  9577. * Adds action to chain of actions, may be a DoNothingAction
  9578. * @param action defines the next action to execute
  9579. * @returns The action passed in
  9580. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9581. */
  9582. then(action: Action): Action;
  9583. /**
  9584. * Internal only
  9585. * @hidden
  9586. */
  9587. _getProperty(propertyPath: string): string;
  9588. /**
  9589. * Internal only
  9590. * @hidden
  9591. */
  9592. _getEffectiveTarget(target: any, propertyPath: string): any;
  9593. /**
  9594. * Serialize placeholder for child classes
  9595. * @param parent of child
  9596. * @returns the serialized object
  9597. */
  9598. serialize(parent: any): any;
  9599. /**
  9600. * Internal only called by serialize
  9601. * @hidden
  9602. */
  9603. protected _serialize(serializedAction: any, parent?: any): any;
  9604. /**
  9605. * Internal only
  9606. * @hidden
  9607. */
  9608. static _SerializeValueAsString: (value: any) => string;
  9609. /**
  9610. * Internal only
  9611. * @hidden
  9612. */
  9613. static _GetTargetProperty: (target: Scene | Node) => {
  9614. name: string;
  9615. targetType: string;
  9616. value: string;
  9617. };
  9618. }
  9619. }
  9620. declare module BABYLON {
  9621. /**
  9622. * A Condition applied to an Action
  9623. */
  9624. export class Condition {
  9625. /**
  9626. * Internal only - manager for action
  9627. * @hidden
  9628. */
  9629. _actionManager: ActionManager;
  9630. /**
  9631. * Internal only
  9632. * @hidden
  9633. */
  9634. _evaluationId: number;
  9635. /**
  9636. * Internal only
  9637. * @hidden
  9638. */
  9639. _currentResult: boolean;
  9640. /**
  9641. * Creates a new Condition
  9642. * @param actionManager the manager of the action the condition is applied to
  9643. */
  9644. constructor(actionManager: ActionManager);
  9645. /**
  9646. * Check if the current condition is valid
  9647. * @returns a boolean
  9648. */
  9649. isValid(): boolean;
  9650. /**
  9651. * Internal only
  9652. * @hidden
  9653. */
  9654. _getProperty(propertyPath: string): string;
  9655. /**
  9656. * Internal only
  9657. * @hidden
  9658. */
  9659. _getEffectiveTarget(target: any, propertyPath: string): any;
  9660. /**
  9661. * Serialize placeholder for child classes
  9662. * @returns the serialized object
  9663. */
  9664. serialize(): any;
  9665. /**
  9666. * Internal only
  9667. * @hidden
  9668. */
  9669. protected _serialize(serializedCondition: any): any;
  9670. }
  9671. /**
  9672. * Defines specific conditional operators as extensions of Condition
  9673. */
  9674. export class ValueCondition extends Condition {
  9675. /** path to specify the property of the target the conditional operator uses */
  9676. propertyPath: string;
  9677. /** the value compared by the conditional operator against the current value of the property */
  9678. value: any;
  9679. /** the conditional operator, default ValueCondition.IsEqual */
  9680. operator: number;
  9681. /**
  9682. * Internal only
  9683. * @hidden
  9684. */
  9685. private static _IsEqual;
  9686. /**
  9687. * Internal only
  9688. * @hidden
  9689. */
  9690. private static _IsDifferent;
  9691. /**
  9692. * Internal only
  9693. * @hidden
  9694. */
  9695. private static _IsGreater;
  9696. /**
  9697. * Internal only
  9698. * @hidden
  9699. */
  9700. private static _IsLesser;
  9701. /**
  9702. * returns the number for IsEqual
  9703. */
  9704. static get IsEqual(): number;
  9705. /**
  9706. * Returns the number for IsDifferent
  9707. */
  9708. static get IsDifferent(): number;
  9709. /**
  9710. * Returns the number for IsGreater
  9711. */
  9712. static get IsGreater(): number;
  9713. /**
  9714. * Returns the number for IsLesser
  9715. */
  9716. static get IsLesser(): number;
  9717. /**
  9718. * Internal only The action manager for the condition
  9719. * @hidden
  9720. */
  9721. _actionManager: ActionManager;
  9722. /**
  9723. * Internal only
  9724. * @hidden
  9725. */
  9726. private _target;
  9727. /**
  9728. * Internal only
  9729. * @hidden
  9730. */
  9731. private _effectiveTarget;
  9732. /**
  9733. * Internal only
  9734. * @hidden
  9735. */
  9736. private _property;
  9737. /**
  9738. * Creates a new ValueCondition
  9739. * @param actionManager manager for the action the condition applies to
  9740. * @param target for the action
  9741. * @param propertyPath path to specify the property of the target the conditional operator uses
  9742. * @param value the value compared by the conditional operator against the current value of the property
  9743. * @param operator the conditional operator, default ValueCondition.IsEqual
  9744. */
  9745. constructor(actionManager: ActionManager, target: any,
  9746. /** path to specify the property of the target the conditional operator uses */
  9747. propertyPath: string,
  9748. /** the value compared by the conditional operator against the current value of the property */
  9749. value: any,
  9750. /** the conditional operator, default ValueCondition.IsEqual */
  9751. operator?: number);
  9752. /**
  9753. * Compares the given value with the property value for the specified conditional operator
  9754. * @returns the result of the comparison
  9755. */
  9756. isValid(): boolean;
  9757. /**
  9758. * Serialize the ValueCondition into a JSON compatible object
  9759. * @returns serialization object
  9760. */
  9761. serialize(): any;
  9762. /**
  9763. * Gets the name of the conditional operator for the ValueCondition
  9764. * @param operator the conditional operator
  9765. * @returns the name
  9766. */
  9767. static GetOperatorName(operator: number): string;
  9768. }
  9769. /**
  9770. * Defines a predicate condition as an extension of Condition
  9771. */
  9772. export class PredicateCondition extends Condition {
  9773. /** defines the predicate function used to validate the condition */
  9774. predicate: () => boolean;
  9775. /**
  9776. * Internal only - manager for action
  9777. * @hidden
  9778. */
  9779. _actionManager: ActionManager;
  9780. /**
  9781. * Creates a new PredicateCondition
  9782. * @param actionManager manager for the action the condition applies to
  9783. * @param predicate defines the predicate function used to validate the condition
  9784. */
  9785. constructor(actionManager: ActionManager,
  9786. /** defines the predicate function used to validate the condition */
  9787. predicate: () => boolean);
  9788. /**
  9789. * @returns the validity of the predicate condition
  9790. */
  9791. isValid(): boolean;
  9792. }
  9793. /**
  9794. * Defines a state condition as an extension of Condition
  9795. */
  9796. export class StateCondition extends Condition {
  9797. /** Value to compare with target state */
  9798. value: string;
  9799. /**
  9800. * Internal only - manager for action
  9801. * @hidden
  9802. */
  9803. _actionManager: ActionManager;
  9804. /**
  9805. * Internal only
  9806. * @hidden
  9807. */
  9808. private _target;
  9809. /**
  9810. * Creates a new StateCondition
  9811. * @param actionManager manager for the action the condition applies to
  9812. * @param target of the condition
  9813. * @param value to compare with target state
  9814. */
  9815. constructor(actionManager: ActionManager, target: any,
  9816. /** Value to compare with target state */
  9817. value: string);
  9818. /**
  9819. * Gets a boolean indicating if the current condition is met
  9820. * @returns the validity of the state
  9821. */
  9822. isValid(): boolean;
  9823. /**
  9824. * Serialize the StateCondition into a JSON compatible object
  9825. * @returns serialization object
  9826. */
  9827. serialize(): any;
  9828. }
  9829. }
  9830. declare module BABYLON {
  9831. /**
  9832. * This defines an action responsible to toggle a boolean once triggered.
  9833. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9834. */
  9835. export class SwitchBooleanAction extends Action {
  9836. /**
  9837. * The path to the boolean property in the target object
  9838. */
  9839. propertyPath: string;
  9840. private _target;
  9841. private _effectiveTarget;
  9842. private _property;
  9843. /**
  9844. * Instantiate the action
  9845. * @param triggerOptions defines the trigger options
  9846. * @param target defines the object containing the boolean
  9847. * @param propertyPath defines the path to the boolean property in the target object
  9848. * @param condition defines the trigger related conditions
  9849. */
  9850. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9851. /** @hidden */
  9852. _prepare(): void;
  9853. /**
  9854. * Execute the action toggle the boolean value.
  9855. */
  9856. execute(): void;
  9857. /**
  9858. * Serializes the actions and its related information.
  9859. * @param parent defines the object to serialize in
  9860. * @returns the serialized object
  9861. */
  9862. serialize(parent: any): any;
  9863. }
  9864. /**
  9865. * This defines an action responsible to set a the state field of the target
  9866. * to a desired value once triggered.
  9867. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9868. */
  9869. export class SetStateAction extends Action {
  9870. /**
  9871. * The value to store in the state field.
  9872. */
  9873. value: string;
  9874. private _target;
  9875. /**
  9876. * Instantiate the action
  9877. * @param triggerOptions defines the trigger options
  9878. * @param target defines the object containing the state property
  9879. * @param value defines the value to store in the state field
  9880. * @param condition defines the trigger related conditions
  9881. */
  9882. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9883. /**
  9884. * Execute the action and store the value on the target state property.
  9885. */
  9886. execute(): void;
  9887. /**
  9888. * Serializes the actions and its related information.
  9889. * @param parent defines the object to serialize in
  9890. * @returns the serialized object
  9891. */
  9892. serialize(parent: any): any;
  9893. }
  9894. /**
  9895. * This defines an action responsible to set a property of the target
  9896. * to a desired value once triggered.
  9897. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9898. */
  9899. export class SetValueAction extends Action {
  9900. /**
  9901. * The path of the property to set in the target.
  9902. */
  9903. propertyPath: string;
  9904. /**
  9905. * The value to set in the property
  9906. */
  9907. value: any;
  9908. private _target;
  9909. private _effectiveTarget;
  9910. private _property;
  9911. /**
  9912. * Instantiate the action
  9913. * @param triggerOptions defines the trigger options
  9914. * @param target defines the object containing the property
  9915. * @param propertyPath defines the path of the property to set in the target
  9916. * @param value defines the value to set in the property
  9917. * @param condition defines the trigger related conditions
  9918. */
  9919. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9920. /** @hidden */
  9921. _prepare(): void;
  9922. /**
  9923. * Execute the action and set the targetted property to the desired value.
  9924. */
  9925. execute(): void;
  9926. /**
  9927. * Serializes the actions and its related information.
  9928. * @param parent defines the object to serialize in
  9929. * @returns the serialized object
  9930. */
  9931. serialize(parent: any): any;
  9932. }
  9933. /**
  9934. * This defines an action responsible to increment the target value
  9935. * to a desired value once triggered.
  9936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9937. */
  9938. export class IncrementValueAction extends Action {
  9939. /**
  9940. * The path of the property to increment in the target.
  9941. */
  9942. propertyPath: string;
  9943. /**
  9944. * The value we should increment the property by.
  9945. */
  9946. value: any;
  9947. private _target;
  9948. private _effectiveTarget;
  9949. private _property;
  9950. /**
  9951. * Instantiate the action
  9952. * @param triggerOptions defines the trigger options
  9953. * @param target defines the object containing the property
  9954. * @param propertyPath defines the path of the property to increment in the target
  9955. * @param value defines the value value we should increment the property by
  9956. * @param condition defines the trigger related conditions
  9957. */
  9958. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9959. /** @hidden */
  9960. _prepare(): void;
  9961. /**
  9962. * Execute the action and increment the target of the value amount.
  9963. */
  9964. execute(): void;
  9965. /**
  9966. * Serializes the actions and its related information.
  9967. * @param parent defines the object to serialize in
  9968. * @returns the serialized object
  9969. */
  9970. serialize(parent: any): any;
  9971. }
  9972. /**
  9973. * This defines an action responsible to start an animation once triggered.
  9974. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9975. */
  9976. export class PlayAnimationAction extends Action {
  9977. /**
  9978. * Where the animation should start (animation frame)
  9979. */
  9980. from: number;
  9981. /**
  9982. * Where the animation should stop (animation frame)
  9983. */
  9984. to: number;
  9985. /**
  9986. * Define if the animation should loop or stop after the first play.
  9987. */
  9988. loop?: boolean;
  9989. private _target;
  9990. /**
  9991. * Instantiate the action
  9992. * @param triggerOptions defines the trigger options
  9993. * @param target defines the target animation or animation name
  9994. * @param from defines from where the animation should start (animation frame)
  9995. * @param end defines where the animation should stop (animation frame)
  9996. * @param loop defines if the animation should loop or stop after the first play
  9997. * @param condition defines the trigger related conditions
  9998. */
  9999. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10000. /** @hidden */
  10001. _prepare(): void;
  10002. /**
  10003. * Execute the action and play the animation.
  10004. */
  10005. execute(): void;
  10006. /**
  10007. * Serializes the actions and its related information.
  10008. * @param parent defines the object to serialize in
  10009. * @returns the serialized object
  10010. */
  10011. serialize(parent: any): any;
  10012. }
  10013. /**
  10014. * This defines an action responsible to stop an animation once triggered.
  10015. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10016. */
  10017. export class StopAnimationAction extends Action {
  10018. private _target;
  10019. /**
  10020. * Instantiate the action
  10021. * @param triggerOptions defines the trigger options
  10022. * @param target defines the target animation or animation name
  10023. * @param condition defines the trigger related conditions
  10024. */
  10025. constructor(triggerOptions: any, target: any, condition?: Condition);
  10026. /** @hidden */
  10027. _prepare(): void;
  10028. /**
  10029. * Execute the action and stop the animation.
  10030. */
  10031. execute(): void;
  10032. /**
  10033. * Serializes the actions and its related information.
  10034. * @param parent defines the object to serialize in
  10035. * @returns the serialized object
  10036. */
  10037. serialize(parent: any): any;
  10038. }
  10039. /**
  10040. * This defines an action responsible that does nothing once triggered.
  10041. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10042. */
  10043. export class DoNothingAction extends Action {
  10044. /**
  10045. * Instantiate the action
  10046. * @param triggerOptions defines the trigger options
  10047. * @param condition defines the trigger related conditions
  10048. */
  10049. constructor(triggerOptions?: any, condition?: Condition);
  10050. /**
  10051. * Execute the action and do nothing.
  10052. */
  10053. execute(): void;
  10054. /**
  10055. * Serializes the actions and its related information.
  10056. * @param parent defines the object to serialize in
  10057. * @returns the serialized object
  10058. */
  10059. serialize(parent: any): any;
  10060. }
  10061. /**
  10062. * This defines an action responsible to trigger several actions once triggered.
  10063. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10064. */
  10065. export class CombineAction extends Action {
  10066. /**
  10067. * The list of aggregated animations to run.
  10068. */
  10069. children: Action[];
  10070. /**
  10071. * Instantiate the action
  10072. * @param triggerOptions defines the trigger options
  10073. * @param children defines the list of aggregated animations to run
  10074. * @param condition defines the trigger related conditions
  10075. */
  10076. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10077. /** @hidden */
  10078. _prepare(): void;
  10079. /**
  10080. * Execute the action and executes all the aggregated actions.
  10081. */
  10082. execute(evt: ActionEvent): void;
  10083. /**
  10084. * Serializes the actions and its related information.
  10085. * @param parent defines the object to serialize in
  10086. * @returns the serialized object
  10087. */
  10088. serialize(parent: any): any;
  10089. }
  10090. /**
  10091. * This defines an action responsible to run code (external event) once triggered.
  10092. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10093. */
  10094. export class ExecuteCodeAction extends Action {
  10095. /**
  10096. * The callback function to run.
  10097. */
  10098. func: (evt: ActionEvent) => void;
  10099. /**
  10100. * Instantiate the action
  10101. * @param triggerOptions defines the trigger options
  10102. * @param func defines the callback function to run
  10103. * @param condition defines the trigger related conditions
  10104. */
  10105. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10106. /**
  10107. * Execute the action and run the attached code.
  10108. */
  10109. execute(evt: ActionEvent): void;
  10110. }
  10111. /**
  10112. * This defines an action responsible to set the parent property of the target once triggered.
  10113. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10114. */
  10115. export class SetParentAction extends Action {
  10116. private _parent;
  10117. private _target;
  10118. /**
  10119. * Instantiate the action
  10120. * @param triggerOptions defines the trigger options
  10121. * @param target defines the target containing the parent property
  10122. * @param parent defines from where the animation should start (animation frame)
  10123. * @param condition defines the trigger related conditions
  10124. */
  10125. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10126. /** @hidden */
  10127. _prepare(): void;
  10128. /**
  10129. * Execute the action and set the parent property.
  10130. */
  10131. execute(): void;
  10132. /**
  10133. * Serializes the actions and its related information.
  10134. * @param parent defines the object to serialize in
  10135. * @returns the serialized object
  10136. */
  10137. serialize(parent: any): any;
  10138. }
  10139. }
  10140. declare module BABYLON {
  10141. /**
  10142. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10143. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10144. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10145. */
  10146. export class ActionManager extends AbstractActionManager {
  10147. /**
  10148. * Nothing
  10149. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10150. */
  10151. static readonly NothingTrigger: number;
  10152. /**
  10153. * On pick
  10154. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10155. */
  10156. static readonly OnPickTrigger: number;
  10157. /**
  10158. * On left pick
  10159. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10160. */
  10161. static readonly OnLeftPickTrigger: number;
  10162. /**
  10163. * On right pick
  10164. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10165. */
  10166. static readonly OnRightPickTrigger: number;
  10167. /**
  10168. * On center pick
  10169. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10170. */
  10171. static readonly OnCenterPickTrigger: number;
  10172. /**
  10173. * On pick down
  10174. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10175. */
  10176. static readonly OnPickDownTrigger: number;
  10177. /**
  10178. * On double pick
  10179. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10180. */
  10181. static readonly OnDoublePickTrigger: number;
  10182. /**
  10183. * On pick up
  10184. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10185. */
  10186. static readonly OnPickUpTrigger: number;
  10187. /**
  10188. * On pick out.
  10189. * This trigger will only be raised if you also declared a OnPickDown
  10190. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10191. */
  10192. static readonly OnPickOutTrigger: number;
  10193. /**
  10194. * On long press
  10195. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10196. */
  10197. static readonly OnLongPressTrigger: number;
  10198. /**
  10199. * On pointer over
  10200. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10201. */
  10202. static readonly OnPointerOverTrigger: number;
  10203. /**
  10204. * On pointer out
  10205. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10206. */
  10207. static readonly OnPointerOutTrigger: number;
  10208. /**
  10209. * On every frame
  10210. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10211. */
  10212. static readonly OnEveryFrameTrigger: number;
  10213. /**
  10214. * On intersection enter
  10215. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10216. */
  10217. static readonly OnIntersectionEnterTrigger: number;
  10218. /**
  10219. * On intersection exit
  10220. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10221. */
  10222. static readonly OnIntersectionExitTrigger: number;
  10223. /**
  10224. * On key down
  10225. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10226. */
  10227. static readonly OnKeyDownTrigger: number;
  10228. /**
  10229. * On key up
  10230. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10231. */
  10232. static readonly OnKeyUpTrigger: number;
  10233. private _scene;
  10234. /**
  10235. * Creates a new action manager
  10236. * @param scene defines the hosting scene
  10237. */
  10238. constructor(scene: Scene);
  10239. /**
  10240. * Releases all associated resources
  10241. */
  10242. dispose(): void;
  10243. /**
  10244. * Gets hosting scene
  10245. * @returns the hosting scene
  10246. */
  10247. getScene(): Scene;
  10248. /**
  10249. * Does this action manager handles actions of any of the given triggers
  10250. * @param triggers defines the triggers to be tested
  10251. * @return a boolean indicating whether one (or more) of the triggers is handled
  10252. */
  10253. hasSpecificTriggers(triggers: number[]): boolean;
  10254. /**
  10255. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10256. * speed.
  10257. * @param triggerA defines the trigger to be tested
  10258. * @param triggerB defines the trigger to be tested
  10259. * @return a boolean indicating whether one (or more) of the triggers is handled
  10260. */
  10261. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10262. /**
  10263. * Does this action manager handles actions of a given trigger
  10264. * @param trigger defines the trigger to be tested
  10265. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10266. * @return whether the trigger is handled
  10267. */
  10268. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10269. /**
  10270. * Does this action manager has pointer triggers
  10271. */
  10272. get hasPointerTriggers(): boolean;
  10273. /**
  10274. * Does this action manager has pick triggers
  10275. */
  10276. get hasPickTriggers(): boolean;
  10277. /**
  10278. * Registers an action to this action manager
  10279. * @param action defines the action to be registered
  10280. * @return the action amended (prepared) after registration
  10281. */
  10282. registerAction(action: IAction): Nullable<IAction>;
  10283. /**
  10284. * Unregisters an action to this action manager
  10285. * @param action defines the action to be unregistered
  10286. * @return a boolean indicating whether the action has been unregistered
  10287. */
  10288. unregisterAction(action: IAction): Boolean;
  10289. /**
  10290. * Process a specific trigger
  10291. * @param trigger defines the trigger to process
  10292. * @param evt defines the event details to be processed
  10293. */
  10294. processTrigger(trigger: number, evt?: IActionEvent): void;
  10295. /** @hidden */
  10296. _getEffectiveTarget(target: any, propertyPath: string): any;
  10297. /** @hidden */
  10298. _getProperty(propertyPath: string): string;
  10299. /**
  10300. * Serialize this manager to a JSON object
  10301. * @param name defines the property name to store this manager
  10302. * @returns a JSON representation of this manager
  10303. */
  10304. serialize(name: string): any;
  10305. /**
  10306. * Creates a new ActionManager from a JSON data
  10307. * @param parsedActions defines the JSON data to read from
  10308. * @param object defines the hosting mesh
  10309. * @param scene defines the hosting scene
  10310. */
  10311. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10312. /**
  10313. * Get a trigger name by index
  10314. * @param trigger defines the trigger index
  10315. * @returns a trigger name
  10316. */
  10317. static GetTriggerName(trigger: number): string;
  10318. }
  10319. }
  10320. declare module BABYLON {
  10321. /**
  10322. * Class used to represent a sprite
  10323. * @see https://doc.babylonjs.com/babylon101/sprites
  10324. */
  10325. export class Sprite implements IAnimatable {
  10326. /** defines the name */
  10327. name: string;
  10328. /** Gets or sets the current world position */
  10329. position: Vector3;
  10330. /** Gets or sets the main color */
  10331. color: Color4;
  10332. /** Gets or sets the width */
  10333. width: number;
  10334. /** Gets or sets the height */
  10335. height: number;
  10336. /** Gets or sets rotation angle */
  10337. angle: number;
  10338. /** Gets or sets the cell index in the sprite sheet */
  10339. cellIndex: number;
  10340. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10341. cellRef: string;
  10342. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10343. invertU: boolean;
  10344. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10345. invertV: boolean;
  10346. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10347. disposeWhenFinishedAnimating: boolean;
  10348. /** Gets the list of attached animations */
  10349. animations: Nullable<Array<Animation>>;
  10350. /** Gets or sets a boolean indicating if the sprite can be picked */
  10351. isPickable: boolean;
  10352. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10353. useAlphaForPicking: boolean;
  10354. /** @hidden */
  10355. _xOffset: number;
  10356. /** @hidden */
  10357. _yOffset: number;
  10358. /** @hidden */
  10359. _xSize: number;
  10360. /** @hidden */
  10361. _ySize: number;
  10362. /**
  10363. * Gets or sets the associated action manager
  10364. */
  10365. actionManager: Nullable<ActionManager>;
  10366. /**
  10367. * An event triggered when the control has been disposed
  10368. */
  10369. onDisposeObservable: Observable<Sprite>;
  10370. private _animationStarted;
  10371. private _loopAnimation;
  10372. private _fromIndex;
  10373. private _toIndex;
  10374. private _delay;
  10375. private _direction;
  10376. private _manager;
  10377. private _time;
  10378. private _onAnimationEnd;
  10379. /**
  10380. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10381. */
  10382. isVisible: boolean;
  10383. /**
  10384. * Gets or sets the sprite size
  10385. */
  10386. get size(): number;
  10387. set size(value: number);
  10388. /**
  10389. * Returns a boolean indicating if the animation is started
  10390. */
  10391. get animationStarted(): boolean;
  10392. /**
  10393. * Gets or sets the unique id of the sprite
  10394. */
  10395. uniqueId: number;
  10396. /**
  10397. * Gets the manager of this sprite
  10398. */
  10399. get manager(): ISpriteManager;
  10400. /**
  10401. * Creates a new Sprite
  10402. * @param name defines the name
  10403. * @param manager defines the manager
  10404. */
  10405. constructor(
  10406. /** defines the name */
  10407. name: string, manager: ISpriteManager);
  10408. /**
  10409. * Returns the string "Sprite"
  10410. * @returns "Sprite"
  10411. */
  10412. getClassName(): string;
  10413. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10414. get fromIndex(): number;
  10415. set fromIndex(value: number);
  10416. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10417. get toIndex(): number;
  10418. set toIndex(value: number);
  10419. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10420. get loopAnimation(): boolean;
  10421. set loopAnimation(value: boolean);
  10422. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10423. get delay(): number;
  10424. set delay(value: number);
  10425. /**
  10426. * Starts an animation
  10427. * @param from defines the initial key
  10428. * @param to defines the end key
  10429. * @param loop defines if the animation must loop
  10430. * @param delay defines the start delay (in ms)
  10431. * @param onAnimationEnd defines a callback to call when animation ends
  10432. */
  10433. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10434. /** Stops current animation (if any) */
  10435. stopAnimation(): void;
  10436. /** @hidden */
  10437. _animate(deltaTime: number): void;
  10438. /** Release associated resources */
  10439. dispose(): void;
  10440. /**
  10441. * Serializes the sprite to a JSON object
  10442. * @returns the JSON object
  10443. */
  10444. serialize(): any;
  10445. /**
  10446. * Parses a JSON object to create a new sprite
  10447. * @param parsedSprite The JSON object to parse
  10448. * @param manager defines the hosting manager
  10449. * @returns the new sprite
  10450. */
  10451. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10452. }
  10453. }
  10454. declare module BABYLON {
  10455. /**
  10456. * Information about the result of picking within a scene
  10457. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10458. */
  10459. export class PickingInfo {
  10460. /** @hidden */
  10461. _pickingUnavailable: boolean;
  10462. /**
  10463. * If the pick collided with an object
  10464. */
  10465. hit: boolean;
  10466. /**
  10467. * Distance away where the pick collided
  10468. */
  10469. distance: number;
  10470. /**
  10471. * The location of pick collision
  10472. */
  10473. pickedPoint: Nullable<Vector3>;
  10474. /**
  10475. * The mesh corresponding the the pick collision
  10476. */
  10477. pickedMesh: Nullable<AbstractMesh>;
  10478. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10479. bu: number;
  10480. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10481. bv: number;
  10482. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10483. faceId: number;
  10484. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10485. subMeshFaceId: number;
  10486. /** Id of the the submesh that was picked */
  10487. subMeshId: number;
  10488. /** If a sprite was picked, this will be the sprite the pick collided with */
  10489. pickedSprite: Nullable<Sprite>;
  10490. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10491. thinInstanceIndex: number;
  10492. /**
  10493. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10494. */
  10495. originMesh: Nullable<AbstractMesh>;
  10496. /**
  10497. * The ray that was used to perform the picking.
  10498. */
  10499. ray: Nullable<Ray>;
  10500. /**
  10501. * Gets the normal correspodning to the face the pick collided with
  10502. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10503. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10504. * @returns The normal correspodning to the face the pick collided with
  10505. */
  10506. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10507. /**
  10508. * Gets the texture coordinates of where the pick occured
  10509. * @returns the vector containing the coordnates of the texture
  10510. */
  10511. getTextureCoordinates(): Nullable<Vector2>;
  10512. }
  10513. }
  10514. declare module BABYLON {
  10515. /**
  10516. * Class representing a ray with position and direction
  10517. */
  10518. export class Ray {
  10519. /** origin point */
  10520. origin: Vector3;
  10521. /** direction */
  10522. direction: Vector3;
  10523. /** length of the ray */
  10524. length: number;
  10525. private static readonly _TmpVector3;
  10526. private _tmpRay;
  10527. /**
  10528. * Creates a new ray
  10529. * @param origin origin point
  10530. * @param direction direction
  10531. * @param length length of the ray
  10532. */
  10533. constructor(
  10534. /** origin point */
  10535. origin: Vector3,
  10536. /** direction */
  10537. direction: Vector3,
  10538. /** length of the ray */
  10539. length?: number);
  10540. /**
  10541. * Checks if the ray intersects a box
  10542. * This does not account for the ray lenght by design to improve perfs.
  10543. * @param minimum bound of the box
  10544. * @param maximum bound of the box
  10545. * @param intersectionTreshold extra extend to be added to the box in all direction
  10546. * @returns if the box was hit
  10547. */
  10548. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10549. /**
  10550. * Checks if the ray intersects a box
  10551. * This does not account for the ray lenght by design to improve perfs.
  10552. * @param box the bounding box to check
  10553. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10554. * @returns if the box was hit
  10555. */
  10556. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10557. /**
  10558. * If the ray hits a sphere
  10559. * @param sphere the bounding sphere to check
  10560. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10561. * @returns true if it hits the sphere
  10562. */
  10563. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10564. /**
  10565. * If the ray hits a triange
  10566. * @param vertex0 triangle vertex
  10567. * @param vertex1 triangle vertex
  10568. * @param vertex2 triangle vertex
  10569. * @returns intersection information if hit
  10570. */
  10571. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10572. /**
  10573. * Checks if ray intersects a plane
  10574. * @param plane the plane to check
  10575. * @returns the distance away it was hit
  10576. */
  10577. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10578. /**
  10579. * Calculate the intercept of a ray on a given axis
  10580. * @param axis to check 'x' | 'y' | 'z'
  10581. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10582. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10583. */
  10584. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10585. /**
  10586. * Checks if ray intersects a mesh
  10587. * @param mesh the mesh to check
  10588. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10589. * @returns picking info of the intersecton
  10590. */
  10591. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10592. /**
  10593. * Checks if ray intersects a mesh
  10594. * @param meshes the meshes to check
  10595. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10596. * @param results array to store result in
  10597. * @returns Array of picking infos
  10598. */
  10599. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10600. private _comparePickingInfo;
  10601. private static smallnum;
  10602. private static rayl;
  10603. /**
  10604. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10605. * @param sega the first point of the segment to test the intersection against
  10606. * @param segb the second point of the segment to test the intersection against
  10607. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10608. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10609. */
  10610. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10611. /**
  10612. * Update the ray from viewport position
  10613. * @param x position
  10614. * @param y y position
  10615. * @param viewportWidth viewport width
  10616. * @param viewportHeight viewport height
  10617. * @param world world matrix
  10618. * @param view view matrix
  10619. * @param projection projection matrix
  10620. * @returns this ray updated
  10621. */
  10622. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10623. /**
  10624. * Creates a ray with origin and direction of 0,0,0
  10625. * @returns the new ray
  10626. */
  10627. static Zero(): Ray;
  10628. /**
  10629. * Creates a new ray from screen space and viewport
  10630. * @param x position
  10631. * @param y y position
  10632. * @param viewportWidth viewport width
  10633. * @param viewportHeight viewport height
  10634. * @param world world matrix
  10635. * @param view view matrix
  10636. * @param projection projection matrix
  10637. * @returns new ray
  10638. */
  10639. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10640. /**
  10641. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10642. * transformed to the given world matrix.
  10643. * @param origin The origin point
  10644. * @param end The end point
  10645. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10646. * @returns the new ray
  10647. */
  10648. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10649. /**
  10650. * Transforms a ray by a matrix
  10651. * @param ray ray to transform
  10652. * @param matrix matrix to apply
  10653. * @returns the resulting new ray
  10654. */
  10655. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10656. /**
  10657. * Transforms a ray by a matrix
  10658. * @param ray ray to transform
  10659. * @param matrix matrix to apply
  10660. * @param result ray to store result in
  10661. */
  10662. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10663. /**
  10664. * Unproject a ray from screen space to object space
  10665. * @param sourceX defines the screen space x coordinate to use
  10666. * @param sourceY defines the screen space y coordinate to use
  10667. * @param viewportWidth defines the current width of the viewport
  10668. * @param viewportHeight defines the current height of the viewport
  10669. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10670. * @param view defines the view matrix to use
  10671. * @param projection defines the projection matrix to use
  10672. */
  10673. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10674. }
  10675. /**
  10676. * Type used to define predicate used to select faces when a mesh intersection is detected
  10677. */
  10678. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10679. interface Scene {
  10680. /** @hidden */
  10681. _tempPickingRay: Nullable<Ray>;
  10682. /** @hidden */
  10683. _cachedRayForTransform: Ray;
  10684. /** @hidden */
  10685. _pickWithRayInverseMatrix: Matrix;
  10686. /** @hidden */
  10687. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10688. /** @hidden */
  10689. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10690. /** @hidden */
  10691. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10692. }
  10693. }
  10694. declare module BABYLON {
  10695. /**
  10696. * Groups all the scene component constants in one place to ease maintenance.
  10697. * @hidden
  10698. */
  10699. export class SceneComponentConstants {
  10700. static readonly NAME_EFFECTLAYER: string;
  10701. static readonly NAME_LAYER: string;
  10702. static readonly NAME_LENSFLARESYSTEM: string;
  10703. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10704. static readonly NAME_PARTICLESYSTEM: string;
  10705. static readonly NAME_GAMEPAD: string;
  10706. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10707. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10708. static readonly NAME_PREPASSRENDERER: string;
  10709. static readonly NAME_DEPTHRENDERER: string;
  10710. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10711. static readonly NAME_SPRITE: string;
  10712. static readonly NAME_SUBSURFACE: string;
  10713. static readonly NAME_OUTLINERENDERER: string;
  10714. static readonly NAME_PROCEDURALTEXTURE: string;
  10715. static readonly NAME_SHADOWGENERATOR: string;
  10716. static readonly NAME_OCTREE: string;
  10717. static readonly NAME_PHYSICSENGINE: string;
  10718. static readonly NAME_AUDIO: string;
  10719. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10720. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10721. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10722. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10723. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10724. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10725. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10726. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10727. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10728. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10729. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10730. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10731. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10732. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10733. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10734. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10735. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10736. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10737. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10738. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10739. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10740. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10741. static readonly STEP_AFTERRENDER_AUDIO: number;
  10742. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10743. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10744. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10745. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10746. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10747. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10748. static readonly STEP_POINTERMOVE_SPRITE: number;
  10749. static readonly STEP_POINTERDOWN_SPRITE: number;
  10750. static readonly STEP_POINTERUP_SPRITE: number;
  10751. }
  10752. /**
  10753. * This represents a scene component.
  10754. *
  10755. * This is used to decouple the dependency the scene is having on the different workloads like
  10756. * layers, post processes...
  10757. */
  10758. export interface ISceneComponent {
  10759. /**
  10760. * The name of the component. Each component must have a unique name.
  10761. */
  10762. name: string;
  10763. /**
  10764. * The scene the component belongs to.
  10765. */
  10766. scene: Scene;
  10767. /**
  10768. * Register the component to one instance of a scene.
  10769. */
  10770. register(): void;
  10771. /**
  10772. * Rebuilds the elements related to this component in case of
  10773. * context lost for instance.
  10774. */
  10775. rebuild(): void;
  10776. /**
  10777. * Disposes the component and the associated ressources.
  10778. */
  10779. dispose(): void;
  10780. }
  10781. /**
  10782. * This represents a SERIALIZABLE scene component.
  10783. *
  10784. * This extends Scene Component to add Serialization methods on top.
  10785. */
  10786. export interface ISceneSerializableComponent extends ISceneComponent {
  10787. /**
  10788. * Adds all the elements from the container to the scene
  10789. * @param container the container holding the elements
  10790. */
  10791. addFromContainer(container: AbstractScene): void;
  10792. /**
  10793. * Removes all the elements in the container from the scene
  10794. * @param container contains the elements to remove
  10795. * @param dispose if the removed element should be disposed (default: false)
  10796. */
  10797. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10798. /**
  10799. * Serializes the component data to the specified json object
  10800. * @param serializationObject The object to serialize to
  10801. */
  10802. serialize(serializationObject: any): void;
  10803. }
  10804. /**
  10805. * Strong typing of a Mesh related stage step action
  10806. */
  10807. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10808. /**
  10809. * Strong typing of a Evaluate Sub Mesh related stage step action
  10810. */
  10811. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10812. /**
  10813. * Strong typing of a pre active Mesh related stage step action
  10814. */
  10815. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10816. /**
  10817. * Strong typing of a Camera related stage step action
  10818. */
  10819. export type CameraStageAction = (camera: Camera) => void;
  10820. /**
  10821. * Strong typing of a Camera Frame buffer related stage step action
  10822. */
  10823. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10824. /**
  10825. * Strong typing of a Render Target related stage step action
  10826. */
  10827. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10828. /**
  10829. * Strong typing of a RenderingGroup related stage step action
  10830. */
  10831. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10832. /**
  10833. * Strong typing of a Mesh Render related stage step action
  10834. */
  10835. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10836. /**
  10837. * Strong typing of a simple stage step action
  10838. */
  10839. export type SimpleStageAction = () => void;
  10840. /**
  10841. * Strong typing of a render target action.
  10842. */
  10843. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10844. /**
  10845. * Strong typing of a pointer move action.
  10846. */
  10847. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10848. /**
  10849. * Strong typing of a pointer up/down action.
  10850. */
  10851. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10852. /**
  10853. * Representation of a stage in the scene (Basically a list of ordered steps)
  10854. * @hidden
  10855. */
  10856. export class Stage<T extends Function> extends Array<{
  10857. index: number;
  10858. component: ISceneComponent;
  10859. action: T;
  10860. }> {
  10861. /**
  10862. * Hide ctor from the rest of the world.
  10863. * @param items The items to add.
  10864. */
  10865. private constructor();
  10866. /**
  10867. * Creates a new Stage.
  10868. * @returns A new instance of a Stage
  10869. */
  10870. static Create<T extends Function>(): Stage<T>;
  10871. /**
  10872. * Registers a step in an ordered way in the targeted stage.
  10873. * @param index Defines the position to register the step in
  10874. * @param component Defines the component attached to the step
  10875. * @param action Defines the action to launch during the step
  10876. */
  10877. registerStep(index: number, component: ISceneComponent, action: T): void;
  10878. /**
  10879. * Clears all the steps from the stage.
  10880. */
  10881. clear(): void;
  10882. }
  10883. }
  10884. declare module BABYLON {
  10885. interface Scene {
  10886. /** @hidden */
  10887. _pointerOverSprite: Nullable<Sprite>;
  10888. /** @hidden */
  10889. _pickedDownSprite: Nullable<Sprite>;
  10890. /** @hidden */
  10891. _tempSpritePickingRay: Nullable<Ray>;
  10892. /**
  10893. * All of the sprite managers added to this scene
  10894. * @see https://doc.babylonjs.com/babylon101/sprites
  10895. */
  10896. spriteManagers: Array<ISpriteManager>;
  10897. /**
  10898. * An event triggered when sprites rendering is about to start
  10899. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10900. */
  10901. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10902. /**
  10903. * An event triggered when sprites rendering is done
  10904. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10905. */
  10906. onAfterSpritesRenderingObservable: Observable<Scene>;
  10907. /** @hidden */
  10908. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10909. /** Launch a ray to try to pick a sprite in the scene
  10910. * @param x position on screen
  10911. * @param y position on screen
  10912. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10913. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10914. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10915. * @returns a PickingInfo
  10916. */
  10917. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10918. /** Use the given ray to pick a sprite in the scene
  10919. * @param ray The ray (in world space) to use to pick meshes
  10920. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10921. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10922. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10923. * @returns a PickingInfo
  10924. */
  10925. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10926. /** @hidden */
  10927. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10928. /** Launch a ray to try to pick sprites in the scene
  10929. * @param x position on screen
  10930. * @param y position on screen
  10931. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10932. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10933. * @returns a PickingInfo array
  10934. */
  10935. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10936. /** Use the given ray to pick sprites in the scene
  10937. * @param ray The ray (in world space) to use to pick meshes
  10938. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10939. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10940. * @returns a PickingInfo array
  10941. */
  10942. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10943. /**
  10944. * Force the sprite under the pointer
  10945. * @param sprite defines the sprite to use
  10946. */
  10947. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10948. /**
  10949. * Gets the sprite under the pointer
  10950. * @returns a Sprite or null if no sprite is under the pointer
  10951. */
  10952. getPointerOverSprite(): Nullable<Sprite>;
  10953. }
  10954. /**
  10955. * Defines the sprite scene component responsible to manage sprites
  10956. * in a given scene.
  10957. */
  10958. export class SpriteSceneComponent implements ISceneComponent {
  10959. /**
  10960. * The component name helpfull to identify the component in the list of scene components.
  10961. */
  10962. readonly name: string;
  10963. /**
  10964. * The scene the component belongs to.
  10965. */
  10966. scene: Scene;
  10967. /** @hidden */
  10968. private _spritePredicate;
  10969. /**
  10970. * Creates a new instance of the component for the given scene
  10971. * @param scene Defines the scene to register the component in
  10972. */
  10973. constructor(scene: Scene);
  10974. /**
  10975. * Registers the component in a given scene
  10976. */
  10977. register(): void;
  10978. /**
  10979. * Rebuilds the elements related to this component in case of
  10980. * context lost for instance.
  10981. */
  10982. rebuild(): void;
  10983. /**
  10984. * Disposes the component and the associated ressources.
  10985. */
  10986. dispose(): void;
  10987. private _pickSpriteButKeepRay;
  10988. private _pointerMove;
  10989. private _pointerDown;
  10990. private _pointerUp;
  10991. }
  10992. }
  10993. declare module BABYLON {
  10994. /** @hidden */
  10995. export var fogFragmentDeclaration: {
  10996. name: string;
  10997. shader: string;
  10998. };
  10999. }
  11000. declare module BABYLON {
  11001. /** @hidden */
  11002. export var fogFragment: {
  11003. name: string;
  11004. shader: string;
  11005. };
  11006. }
  11007. declare module BABYLON {
  11008. /** @hidden */
  11009. export var imageProcessingCompatibility: {
  11010. name: string;
  11011. shader: string;
  11012. };
  11013. }
  11014. declare module BABYLON {
  11015. /** @hidden */
  11016. export var spritesPixelShader: {
  11017. name: string;
  11018. shader: string;
  11019. };
  11020. }
  11021. declare module BABYLON {
  11022. /** @hidden */
  11023. export var fogVertexDeclaration: {
  11024. name: string;
  11025. shader: string;
  11026. };
  11027. }
  11028. declare module BABYLON {
  11029. /** @hidden */
  11030. export var spritesVertexShader: {
  11031. name: string;
  11032. shader: string;
  11033. };
  11034. }
  11035. declare module BABYLON {
  11036. /**
  11037. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11038. */
  11039. export interface ISpriteManager extends IDisposable {
  11040. /**
  11041. * Gets manager's name
  11042. */
  11043. name: string;
  11044. /**
  11045. * Restricts the camera to viewing objects with the same layerMask.
  11046. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11047. */
  11048. layerMask: number;
  11049. /**
  11050. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11051. */
  11052. isPickable: boolean;
  11053. /**
  11054. * Gets the hosting scene
  11055. */
  11056. scene: Scene;
  11057. /**
  11058. * Specifies the rendering group id for this mesh (0 by default)
  11059. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11060. */
  11061. renderingGroupId: number;
  11062. /**
  11063. * Defines the list of sprites managed by the manager.
  11064. */
  11065. sprites: Array<Sprite>;
  11066. /**
  11067. * Gets or sets the spritesheet texture
  11068. */
  11069. texture: Texture;
  11070. /** Defines the default width of a cell in the spritesheet */
  11071. cellWidth: number;
  11072. /** Defines the default height of a cell in the spritesheet */
  11073. cellHeight: number;
  11074. /**
  11075. * Tests the intersection of a sprite with a specific ray.
  11076. * @param ray The ray we are sending to test the collision
  11077. * @param camera The camera space we are sending rays in
  11078. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11079. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11080. * @returns picking info or null.
  11081. */
  11082. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11083. /**
  11084. * Intersects the sprites with a ray
  11085. * @param ray defines the ray to intersect with
  11086. * @param camera defines the current active camera
  11087. * @param predicate defines a predicate used to select candidate sprites
  11088. * @returns null if no hit or a PickingInfo array
  11089. */
  11090. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11091. /**
  11092. * Renders the list of sprites on screen.
  11093. */
  11094. render(): void;
  11095. }
  11096. /**
  11097. * Class used to manage multiple sprites on the same spritesheet
  11098. * @see https://doc.babylonjs.com/babylon101/sprites
  11099. */
  11100. export class SpriteManager implements ISpriteManager {
  11101. /** defines the manager's name */
  11102. name: string;
  11103. /** Define the Url to load snippets */
  11104. static SnippetUrl: string;
  11105. /** Snippet ID if the manager was created from the snippet server */
  11106. snippetId: string;
  11107. /** Gets the list of sprites */
  11108. sprites: Sprite[];
  11109. /** Gets or sets the rendering group id (0 by default) */
  11110. renderingGroupId: number;
  11111. /** Gets or sets camera layer mask */
  11112. layerMask: number;
  11113. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11114. fogEnabled: boolean;
  11115. /** Gets or sets a boolean indicating if the sprites are pickable */
  11116. isPickable: boolean;
  11117. /** Defines the default width of a cell in the spritesheet */
  11118. cellWidth: number;
  11119. /** Defines the default height of a cell in the spritesheet */
  11120. cellHeight: number;
  11121. /** Associative array from JSON sprite data file */
  11122. private _cellData;
  11123. /** Array of sprite names from JSON sprite data file */
  11124. private _spriteMap;
  11125. /** True when packed cell data from JSON file is ready*/
  11126. private _packedAndReady;
  11127. private _textureContent;
  11128. private _useInstancing;
  11129. /**
  11130. * An event triggered when the manager is disposed.
  11131. */
  11132. onDisposeObservable: Observable<SpriteManager>;
  11133. private _onDisposeObserver;
  11134. /**
  11135. * Callback called when the manager is disposed
  11136. */
  11137. set onDispose(callback: () => void);
  11138. private _capacity;
  11139. private _fromPacked;
  11140. private _spriteTexture;
  11141. private _epsilon;
  11142. private _scene;
  11143. private _vertexData;
  11144. private _buffer;
  11145. private _vertexBuffers;
  11146. private _spriteBuffer;
  11147. private _indexBuffer;
  11148. private _effectBase;
  11149. private _effectFog;
  11150. private _vertexBufferSize;
  11151. /**
  11152. * Gets or sets the unique id of the sprite
  11153. */
  11154. uniqueId: number;
  11155. /**
  11156. * Gets the array of sprites
  11157. */
  11158. get children(): Sprite[];
  11159. /**
  11160. * Gets the hosting scene
  11161. */
  11162. get scene(): Scene;
  11163. /**
  11164. * Gets the capacity of the manager
  11165. */
  11166. get capacity(): number;
  11167. /**
  11168. * Gets or sets the spritesheet texture
  11169. */
  11170. get texture(): Texture;
  11171. set texture(value: Texture);
  11172. private _blendMode;
  11173. /**
  11174. * Blend mode use to render the particle, it can be any of
  11175. * the static Constants.ALPHA_x properties provided in this class.
  11176. * Default value is Constants.ALPHA_COMBINE
  11177. */
  11178. get blendMode(): number;
  11179. set blendMode(blendMode: number);
  11180. /** Disables writing to the depth buffer when rendering the sprites.
  11181. * It can be handy to disable depth writing when using textures without alpha channel
  11182. * and setting some specific blend modes.
  11183. */
  11184. disableDepthWrite: boolean;
  11185. /**
  11186. * Creates a new sprite manager
  11187. * @param name defines the manager's name
  11188. * @param imgUrl defines the sprite sheet url
  11189. * @param capacity defines the maximum allowed number of sprites
  11190. * @param cellSize defines the size of a sprite cell
  11191. * @param scene defines the hosting scene
  11192. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11193. * @param samplingMode defines the smapling mode to use with spritesheet
  11194. * @param fromPacked set to false; do not alter
  11195. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11196. */
  11197. constructor(
  11198. /** defines the manager's name */
  11199. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11200. /**
  11201. * Returns the string "SpriteManager"
  11202. * @returns "SpriteManager"
  11203. */
  11204. getClassName(): string;
  11205. private _makePacked;
  11206. private _appendSpriteVertex;
  11207. private _checkTextureAlpha;
  11208. /**
  11209. * Intersects the sprites with a ray
  11210. * @param ray defines the ray to intersect with
  11211. * @param camera defines the current active camera
  11212. * @param predicate defines a predicate used to select candidate sprites
  11213. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11214. * @returns null if no hit or a PickingInfo
  11215. */
  11216. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11217. /**
  11218. * Intersects the sprites with a ray
  11219. * @param ray defines the ray to intersect with
  11220. * @param camera defines the current active camera
  11221. * @param predicate defines a predicate used to select candidate sprites
  11222. * @returns null if no hit or a PickingInfo array
  11223. */
  11224. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11225. /**
  11226. * Render all child sprites
  11227. */
  11228. render(): void;
  11229. /**
  11230. * Release associated resources
  11231. */
  11232. dispose(): void;
  11233. /**
  11234. * Serializes the sprite manager to a JSON object
  11235. * @param serializeTexture defines if the texture must be serialized as well
  11236. * @returns the JSON object
  11237. */
  11238. serialize(serializeTexture?: boolean): any;
  11239. /**
  11240. * Parses a JSON object to create a new sprite manager.
  11241. * @param parsedManager The JSON object to parse
  11242. * @param scene The scene to create the sprite managerin
  11243. * @param rootUrl The root url to use to load external dependencies like texture
  11244. * @returns the new sprite manager
  11245. */
  11246. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11247. /**
  11248. * Creates a sprite manager from a snippet saved in a remote file
  11249. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11250. * @param url defines the url to load from
  11251. * @param scene defines the hosting scene
  11252. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11253. * @returns a promise that will resolve to the new sprite manager
  11254. */
  11255. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11256. /**
  11257. * Creates a sprite manager from a snippet saved by the sprite editor
  11258. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11259. * @param scene defines the hosting scene
  11260. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11261. * @returns a promise that will resolve to the new sprite manager
  11262. */
  11263. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11264. }
  11265. }
  11266. declare module BABYLON {
  11267. /** Interface used by value gradients (color, factor, ...) */
  11268. export interface IValueGradient {
  11269. /**
  11270. * Gets or sets the gradient value (between 0 and 1)
  11271. */
  11272. gradient: number;
  11273. }
  11274. /** Class used to store color4 gradient */
  11275. export class ColorGradient implements IValueGradient {
  11276. /**
  11277. * Gets or sets the gradient value (between 0 and 1)
  11278. */
  11279. gradient: number;
  11280. /**
  11281. * Gets or sets first associated color
  11282. */
  11283. color1: Color4;
  11284. /**
  11285. * Gets or sets second associated color
  11286. */
  11287. color2?: Color4 | undefined;
  11288. /**
  11289. * Creates a new color4 gradient
  11290. * @param gradient gets or sets the gradient value (between 0 and 1)
  11291. * @param color1 gets or sets first associated color
  11292. * @param color2 gets or sets first second color
  11293. */
  11294. constructor(
  11295. /**
  11296. * Gets or sets the gradient value (between 0 and 1)
  11297. */
  11298. gradient: number,
  11299. /**
  11300. * Gets or sets first associated color
  11301. */
  11302. color1: Color4,
  11303. /**
  11304. * Gets or sets second associated color
  11305. */
  11306. color2?: Color4 | undefined);
  11307. /**
  11308. * Will get a color picked randomly between color1 and color2.
  11309. * If color2 is undefined then color1 will be used
  11310. * @param result defines the target Color4 to store the result in
  11311. */
  11312. getColorToRef(result: Color4): void;
  11313. }
  11314. /** Class used to store color 3 gradient */
  11315. export class Color3Gradient implements IValueGradient {
  11316. /**
  11317. * Gets or sets the gradient value (between 0 and 1)
  11318. */
  11319. gradient: number;
  11320. /**
  11321. * Gets or sets the associated color
  11322. */
  11323. color: Color3;
  11324. /**
  11325. * Creates a new color3 gradient
  11326. * @param gradient gets or sets the gradient value (between 0 and 1)
  11327. * @param color gets or sets associated color
  11328. */
  11329. constructor(
  11330. /**
  11331. * Gets or sets the gradient value (between 0 and 1)
  11332. */
  11333. gradient: number,
  11334. /**
  11335. * Gets or sets the associated color
  11336. */
  11337. color: Color3);
  11338. }
  11339. /** Class used to store factor gradient */
  11340. export class FactorGradient implements IValueGradient {
  11341. /**
  11342. * Gets or sets the gradient value (between 0 and 1)
  11343. */
  11344. gradient: number;
  11345. /**
  11346. * Gets or sets first associated factor
  11347. */
  11348. factor1: number;
  11349. /**
  11350. * Gets or sets second associated factor
  11351. */
  11352. factor2?: number | undefined;
  11353. /**
  11354. * Creates a new factor gradient
  11355. * @param gradient gets or sets the gradient value (between 0 and 1)
  11356. * @param factor1 gets or sets first associated factor
  11357. * @param factor2 gets or sets second associated factor
  11358. */
  11359. constructor(
  11360. /**
  11361. * Gets or sets the gradient value (between 0 and 1)
  11362. */
  11363. gradient: number,
  11364. /**
  11365. * Gets or sets first associated factor
  11366. */
  11367. factor1: number,
  11368. /**
  11369. * Gets or sets second associated factor
  11370. */
  11371. factor2?: number | undefined);
  11372. /**
  11373. * Will get a number picked randomly between factor1 and factor2.
  11374. * If factor2 is undefined then factor1 will be used
  11375. * @returns the picked number
  11376. */
  11377. getFactor(): number;
  11378. }
  11379. /**
  11380. * Helper used to simplify some generic gradient tasks
  11381. */
  11382. export class GradientHelper {
  11383. /**
  11384. * Gets the current gradient from an array of IValueGradient
  11385. * @param ratio defines the current ratio to get
  11386. * @param gradients defines the array of IValueGradient
  11387. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11388. */
  11389. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11390. }
  11391. }
  11392. declare module BABYLON {
  11393. interface ThinEngine {
  11394. /**
  11395. * Creates a raw texture
  11396. * @param data defines the data to store in the texture
  11397. * @param width defines the width of the texture
  11398. * @param height defines the height of the texture
  11399. * @param format defines the format of the data
  11400. * @param generateMipMaps defines if the engine should generate the mip levels
  11401. * @param invertY defines if data must be stored with Y axis inverted
  11402. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11403. * @param compression defines the compression used (null by default)
  11404. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11405. * @returns the raw texture inside an InternalTexture
  11406. */
  11407. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11408. /**
  11409. * Update a raw texture
  11410. * @param texture defines the texture to update
  11411. * @param data defines the data to store in the texture
  11412. * @param format defines the format of the data
  11413. * @param invertY defines if data must be stored with Y axis inverted
  11414. */
  11415. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11416. /**
  11417. * Update a raw texture
  11418. * @param texture defines the texture to update
  11419. * @param data defines the data to store in the texture
  11420. * @param format defines the format of the data
  11421. * @param invertY defines if data must be stored with Y axis inverted
  11422. * @param compression defines the compression used (null by default)
  11423. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11424. */
  11425. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11426. /**
  11427. * Creates a new raw cube texture
  11428. * @param data defines the array of data to use to create each face
  11429. * @param size defines the size of the textures
  11430. * @param format defines the format of the data
  11431. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11432. * @param generateMipMaps defines if the engine should generate the mip levels
  11433. * @param invertY defines if data must be stored with Y axis inverted
  11434. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11435. * @param compression defines the compression used (null by default)
  11436. * @returns the cube texture as an InternalTexture
  11437. */
  11438. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11439. /**
  11440. * Update a raw cube texture
  11441. * @param texture defines the texture to udpdate
  11442. * @param data defines the data to store
  11443. * @param format defines the data format
  11444. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11445. * @param invertY defines if data must be stored with Y axis inverted
  11446. */
  11447. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11448. /**
  11449. * Update a raw cube texture
  11450. * @param texture defines the texture to udpdate
  11451. * @param data defines the data to store
  11452. * @param format defines the data format
  11453. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11454. * @param invertY defines if data must be stored with Y axis inverted
  11455. * @param compression defines the compression used (null by default)
  11456. */
  11457. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11458. /**
  11459. * Update a raw cube texture
  11460. * @param texture defines the texture to udpdate
  11461. * @param data defines the data to store
  11462. * @param format defines the data format
  11463. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11464. * @param invertY defines if data must be stored with Y axis inverted
  11465. * @param compression defines the compression used (null by default)
  11466. * @param level defines which level of the texture to update
  11467. */
  11468. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11469. /**
  11470. * Creates a new raw cube texture from a specified url
  11471. * @param url defines the url where the data is located
  11472. * @param scene defines the current scene
  11473. * @param size defines the size of the textures
  11474. * @param format defines the format of the data
  11475. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11476. * @param noMipmap defines if the engine should avoid generating the mip levels
  11477. * @param callback defines a callback used to extract texture data from loaded data
  11478. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11479. * @param onLoad defines a callback called when texture is loaded
  11480. * @param onError defines a callback called if there is an error
  11481. * @returns the cube texture as an InternalTexture
  11482. */
  11483. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11484. /**
  11485. * Creates a new raw cube texture from a specified url
  11486. * @param url defines the url where the data is located
  11487. * @param scene defines the current scene
  11488. * @param size defines the size of the textures
  11489. * @param format defines the format of the data
  11490. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11491. * @param noMipmap defines if the engine should avoid generating the mip levels
  11492. * @param callback defines a callback used to extract texture data from loaded data
  11493. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11494. * @param onLoad defines a callback called when texture is loaded
  11495. * @param onError defines a callback called if there is an error
  11496. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11497. * @param invertY defines if data must be stored with Y axis inverted
  11498. * @returns the cube texture as an InternalTexture
  11499. */
  11500. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11501. /**
  11502. * Creates a new raw 3D texture
  11503. * @param data defines the data used to create the texture
  11504. * @param width defines the width of the texture
  11505. * @param height defines the height of the texture
  11506. * @param depth defines the depth of the texture
  11507. * @param format defines the format of the texture
  11508. * @param generateMipMaps defines if the engine must generate mip levels
  11509. * @param invertY defines if data must be stored with Y axis inverted
  11510. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11511. * @param compression defines the compressed used (can be null)
  11512. * @param textureType defines the compressed used (can be null)
  11513. * @returns a new raw 3D texture (stored in an InternalTexture)
  11514. */
  11515. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11516. /**
  11517. * Update a raw 3D texture
  11518. * @param texture defines the texture to update
  11519. * @param data defines the data to store
  11520. * @param format defines the data format
  11521. * @param invertY defines if data must be stored with Y axis inverted
  11522. */
  11523. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11524. /**
  11525. * Update a raw 3D texture
  11526. * @param texture defines the texture to update
  11527. * @param data defines the data to store
  11528. * @param format defines the data format
  11529. * @param invertY defines if data must be stored with Y axis inverted
  11530. * @param compression defines the used compression (can be null)
  11531. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11532. */
  11533. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11534. /**
  11535. * Creates a new raw 2D array texture
  11536. * @param data defines the data used to create the texture
  11537. * @param width defines the width of the texture
  11538. * @param height defines the height of the texture
  11539. * @param depth defines the number of layers of the texture
  11540. * @param format defines the format of the texture
  11541. * @param generateMipMaps defines if the engine must generate mip levels
  11542. * @param invertY defines if data must be stored with Y axis inverted
  11543. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11544. * @param compression defines the compressed used (can be null)
  11545. * @param textureType defines the compressed used (can be null)
  11546. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11547. */
  11548. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11549. /**
  11550. * Update a raw 2D array texture
  11551. * @param texture defines the texture to update
  11552. * @param data defines the data to store
  11553. * @param format defines the data format
  11554. * @param invertY defines if data must be stored with Y axis inverted
  11555. */
  11556. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11557. /**
  11558. * Update a raw 2D array texture
  11559. * @param texture defines the texture to update
  11560. * @param data defines the data to store
  11561. * @param format defines the data format
  11562. * @param invertY defines if data must be stored with Y axis inverted
  11563. * @param compression defines the used compression (can be null)
  11564. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11565. */
  11566. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11567. }
  11568. }
  11569. declare module BABYLON {
  11570. /**
  11571. * Raw texture can help creating a texture directly from an array of data.
  11572. * This can be super useful if you either get the data from an uncompressed source or
  11573. * if you wish to create your texture pixel by pixel.
  11574. */
  11575. export class RawTexture extends Texture {
  11576. /**
  11577. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11578. */
  11579. format: number;
  11580. /**
  11581. * Instantiates a new RawTexture.
  11582. * Raw texture can help creating a texture directly from an array of data.
  11583. * This can be super useful if you either get the data from an uncompressed source or
  11584. * if you wish to create your texture pixel by pixel.
  11585. * @param data define the array of data to use to create the texture
  11586. * @param width define the width of the texture
  11587. * @param height define the height of the texture
  11588. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11589. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11590. * @param generateMipMaps define whether mip maps should be generated or not
  11591. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11592. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11593. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11594. */
  11595. constructor(data: ArrayBufferView, width: number, height: number,
  11596. /**
  11597. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11598. */
  11599. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11600. /**
  11601. * Updates the texture underlying data.
  11602. * @param data Define the new data of the texture
  11603. */
  11604. update(data: ArrayBufferView): void;
  11605. /**
  11606. * Creates a luminance texture from some data.
  11607. * @param data Define the texture data
  11608. * @param width Define the width of the texture
  11609. * @param height Define the height of the texture
  11610. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11611. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11612. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11613. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11614. * @returns the luminance texture
  11615. */
  11616. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11617. /**
  11618. * Creates a luminance alpha texture from some data.
  11619. * @param data Define the texture data
  11620. * @param width Define the width of the texture
  11621. * @param height Define the height of the texture
  11622. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11623. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11624. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11625. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11626. * @returns the luminance alpha texture
  11627. */
  11628. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11629. /**
  11630. * Creates an alpha texture from some data.
  11631. * @param data Define the texture data
  11632. * @param width Define the width of the texture
  11633. * @param height Define the height of the texture
  11634. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11635. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11636. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11637. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11638. * @returns the alpha texture
  11639. */
  11640. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11641. /**
  11642. * Creates a RGB texture from some data.
  11643. * @param data Define the texture data
  11644. * @param width Define the width of the texture
  11645. * @param height Define the height of the texture
  11646. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11647. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11648. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11649. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11650. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11651. * @returns the RGB alpha texture
  11652. */
  11653. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11654. /**
  11655. * Creates a RGBA texture from some data.
  11656. * @param data Define the texture data
  11657. * @param width Define the width of the texture
  11658. * @param height Define the height of the texture
  11659. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11660. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11661. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11662. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11663. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11664. * @returns the RGBA texture
  11665. */
  11666. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11667. /**
  11668. * Creates a R texture from some data.
  11669. * @param data Define the texture data
  11670. * @param width Define the width of the texture
  11671. * @param height Define the height of the texture
  11672. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11673. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11674. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11675. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11676. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11677. * @returns the R texture
  11678. */
  11679. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11680. }
  11681. }
  11682. declare module BABYLON {
  11683. interface ThinEngine {
  11684. /**
  11685. * Update a dynamic index buffer
  11686. * @param indexBuffer defines the target index buffer
  11687. * @param indices defines the data to update
  11688. * @param offset defines the offset in the target index buffer where update should start
  11689. */
  11690. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11691. /**
  11692. * Updates a dynamic vertex buffer.
  11693. * @param vertexBuffer the vertex buffer to update
  11694. * @param data the data used to update the vertex buffer
  11695. * @param byteOffset the byte offset of the data
  11696. * @param byteLength the byte length of the data
  11697. */
  11698. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11699. }
  11700. }
  11701. declare module BABYLON {
  11702. interface AbstractScene {
  11703. /**
  11704. * The list of procedural textures added to the scene
  11705. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11706. */
  11707. proceduralTextures: Array<ProceduralTexture>;
  11708. }
  11709. /**
  11710. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11711. * in a given scene.
  11712. */
  11713. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11714. /**
  11715. * The component name helpfull to identify the component in the list of scene components.
  11716. */
  11717. readonly name: string;
  11718. /**
  11719. * The scene the component belongs to.
  11720. */
  11721. scene: Scene;
  11722. /**
  11723. * Creates a new instance of the component for the given scene
  11724. * @param scene Defines the scene to register the component in
  11725. */
  11726. constructor(scene: Scene);
  11727. /**
  11728. * Registers the component in a given scene
  11729. */
  11730. register(): void;
  11731. /**
  11732. * Rebuilds the elements related to this component in case of
  11733. * context lost for instance.
  11734. */
  11735. rebuild(): void;
  11736. /**
  11737. * Disposes the component and the associated ressources.
  11738. */
  11739. dispose(): void;
  11740. private _beforeClear;
  11741. }
  11742. }
  11743. declare module BABYLON {
  11744. interface ThinEngine {
  11745. /**
  11746. * Creates a new render target cube texture
  11747. * @param size defines the size of the texture
  11748. * @param options defines the options used to create the texture
  11749. * @returns a new render target cube texture stored in an InternalTexture
  11750. */
  11751. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11752. }
  11753. }
  11754. declare module BABYLON {
  11755. /** @hidden */
  11756. export var proceduralVertexShader: {
  11757. name: string;
  11758. shader: string;
  11759. };
  11760. }
  11761. declare module BABYLON {
  11762. /**
  11763. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11764. * This is the base class of any Procedural texture and contains most of the shareable code.
  11765. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11766. */
  11767. export class ProceduralTexture extends Texture {
  11768. /**
  11769. * Define if the texture is enabled or not (disabled texture will not render)
  11770. */
  11771. isEnabled: boolean;
  11772. /**
  11773. * Define if the texture must be cleared before rendering (default is true)
  11774. */
  11775. autoClear: boolean;
  11776. /**
  11777. * Callback called when the texture is generated
  11778. */
  11779. onGenerated: () => void;
  11780. /**
  11781. * Event raised when the texture is generated
  11782. */
  11783. onGeneratedObservable: Observable<ProceduralTexture>;
  11784. /**
  11785. * Event raised before the texture is generated
  11786. */
  11787. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11788. /**
  11789. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11790. */
  11791. nodeMaterialSource: Nullable<NodeMaterial>;
  11792. /** @hidden */
  11793. _generateMipMaps: boolean;
  11794. /** @hidden **/
  11795. _effect: Effect;
  11796. /** @hidden */
  11797. _textures: {
  11798. [key: string]: Texture;
  11799. };
  11800. /** @hidden */
  11801. protected _fallbackTexture: Nullable<Texture>;
  11802. private _size;
  11803. private _currentRefreshId;
  11804. private _frameId;
  11805. private _refreshRate;
  11806. private _vertexBuffers;
  11807. private _indexBuffer;
  11808. private _uniforms;
  11809. private _samplers;
  11810. private _fragment;
  11811. private _floats;
  11812. private _ints;
  11813. private _floatsArrays;
  11814. private _colors3;
  11815. private _colors4;
  11816. private _vectors2;
  11817. private _vectors3;
  11818. private _matrices;
  11819. private _fallbackTextureUsed;
  11820. private _fullEngine;
  11821. private _cachedDefines;
  11822. private _contentUpdateId;
  11823. private _contentData;
  11824. /**
  11825. * Instantiates a new procedural texture.
  11826. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11827. * This is the base class of any Procedural texture and contains most of the shareable code.
  11828. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11829. * @param name Define the name of the texture
  11830. * @param size Define the size of the texture to create
  11831. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11832. * @param scene Define the scene the texture belongs to
  11833. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11834. * @param generateMipMaps Define if the texture should creates mip maps or not
  11835. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11836. * @param textureType The FBO internal texture type
  11837. */
  11838. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  11839. /**
  11840. * The effect that is created when initializing the post process.
  11841. * @returns The created effect corresponding the the postprocess.
  11842. */
  11843. getEffect(): Effect;
  11844. /**
  11845. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11846. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11847. */
  11848. getContent(): Nullable<ArrayBufferView>;
  11849. private _createIndexBuffer;
  11850. /** @hidden */
  11851. _rebuild(): void;
  11852. /**
  11853. * Resets the texture in order to recreate its associated resources.
  11854. * This can be called in case of context loss
  11855. */
  11856. reset(): void;
  11857. protected _getDefines(): string;
  11858. /**
  11859. * Is the texture ready to be used ? (rendered at least once)
  11860. * @returns true if ready, otherwise, false.
  11861. */
  11862. isReady(): boolean;
  11863. /**
  11864. * Resets the refresh counter of the texture and start bak from scratch.
  11865. * Could be useful to regenerate the texture if it is setup to render only once.
  11866. */
  11867. resetRefreshCounter(): void;
  11868. /**
  11869. * Set the fragment shader to use in order to render the texture.
  11870. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11871. */
  11872. setFragment(fragment: any): void;
  11873. /**
  11874. * Define the refresh rate of the texture or the rendering frequency.
  11875. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11876. */
  11877. get refreshRate(): number;
  11878. set refreshRate(value: number);
  11879. /** @hidden */
  11880. _shouldRender(): boolean;
  11881. /**
  11882. * Get the size the texture is rendering at.
  11883. * @returns the size (on cube texture it is always squared)
  11884. */
  11885. getRenderSize(): RenderTargetTextureSize;
  11886. /**
  11887. * Resize the texture to new value.
  11888. * @param size Define the new size the texture should have
  11889. * @param generateMipMaps Define whether the new texture should create mip maps
  11890. */
  11891. resize(size: number, generateMipMaps: boolean): void;
  11892. private _checkUniform;
  11893. /**
  11894. * Set a texture in the shader program used to render.
  11895. * @param name Define the name of the uniform samplers as defined in the shader
  11896. * @param texture Define the texture to bind to this sampler
  11897. * @return the texture itself allowing "fluent" like uniform updates
  11898. */
  11899. setTexture(name: string, texture: Texture): ProceduralTexture;
  11900. /**
  11901. * Set a float in the shader.
  11902. * @param name Define the name of the uniform as defined in the shader
  11903. * @param value Define the value to give to the uniform
  11904. * @return the texture itself allowing "fluent" like uniform updates
  11905. */
  11906. setFloat(name: string, value: number): ProceduralTexture;
  11907. /**
  11908. * Set a int in the shader.
  11909. * @param name Define the name of the uniform as defined in the shader
  11910. * @param value Define the value to give to the uniform
  11911. * @return the texture itself allowing "fluent" like uniform updates
  11912. */
  11913. setInt(name: string, value: number): ProceduralTexture;
  11914. /**
  11915. * Set an array of floats in the shader.
  11916. * @param name Define the name of the uniform as defined in the shader
  11917. * @param value Define the value to give to the uniform
  11918. * @return the texture itself allowing "fluent" like uniform updates
  11919. */
  11920. setFloats(name: string, value: number[]): ProceduralTexture;
  11921. /**
  11922. * Set a vec3 in the shader from a Color3.
  11923. * @param name Define the name of the uniform as defined in the shader
  11924. * @param value Define the value to give to the uniform
  11925. * @return the texture itself allowing "fluent" like uniform updates
  11926. */
  11927. setColor3(name: string, value: Color3): ProceduralTexture;
  11928. /**
  11929. * Set a vec4 in the shader from a Color4.
  11930. * @param name Define the name of the uniform as defined in the shader
  11931. * @param value Define the value to give to the uniform
  11932. * @return the texture itself allowing "fluent" like uniform updates
  11933. */
  11934. setColor4(name: string, value: Color4): ProceduralTexture;
  11935. /**
  11936. * Set a vec2 in the shader from a Vector2.
  11937. * @param name Define the name of the uniform as defined in the shader
  11938. * @param value Define the value to give to the uniform
  11939. * @return the texture itself allowing "fluent" like uniform updates
  11940. */
  11941. setVector2(name: string, value: Vector2): ProceduralTexture;
  11942. /**
  11943. * Set a vec3 in the shader from a Vector3.
  11944. * @param name Define the name of the uniform as defined in the shader
  11945. * @param value Define the value to give to the uniform
  11946. * @return the texture itself allowing "fluent" like uniform updates
  11947. */
  11948. setVector3(name: string, value: Vector3): ProceduralTexture;
  11949. /**
  11950. * Set a mat4 in the shader from a MAtrix.
  11951. * @param name Define the name of the uniform as defined in the shader
  11952. * @param value Define the value to give to the uniform
  11953. * @return the texture itself allowing "fluent" like uniform updates
  11954. */
  11955. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11956. /**
  11957. * Render the texture to its associated render target.
  11958. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11959. */
  11960. render(useCameraPostProcess?: boolean): void;
  11961. /**
  11962. * Clone the texture.
  11963. * @returns the cloned texture
  11964. */
  11965. clone(): ProceduralTexture;
  11966. /**
  11967. * Dispose the texture and release its asoociated resources.
  11968. */
  11969. dispose(): void;
  11970. }
  11971. }
  11972. declare module BABYLON {
  11973. /**
  11974. * This represents the base class for particle system in Babylon.
  11975. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11976. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11977. * @example https://doc.babylonjs.com/babylon101/particles
  11978. */
  11979. export class BaseParticleSystem {
  11980. /**
  11981. * Source color is added to the destination color without alpha affecting the result
  11982. */
  11983. static BLENDMODE_ONEONE: number;
  11984. /**
  11985. * Blend current color and particle color using particle’s alpha
  11986. */
  11987. static BLENDMODE_STANDARD: number;
  11988. /**
  11989. * Add current color and particle color multiplied by particle’s alpha
  11990. */
  11991. static BLENDMODE_ADD: number;
  11992. /**
  11993. * Multiply current color with particle color
  11994. */
  11995. static BLENDMODE_MULTIPLY: number;
  11996. /**
  11997. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11998. */
  11999. static BLENDMODE_MULTIPLYADD: number;
  12000. /**
  12001. * List of animations used by the particle system.
  12002. */
  12003. animations: Animation[];
  12004. /**
  12005. * Gets or sets the unique id of the particle system
  12006. */
  12007. uniqueId: number;
  12008. /**
  12009. * The id of the Particle system.
  12010. */
  12011. id: string;
  12012. /**
  12013. * The friendly name of the Particle system.
  12014. */
  12015. name: string;
  12016. /**
  12017. * Snippet ID if the particle system was created from the snippet server
  12018. */
  12019. snippetId: string;
  12020. /**
  12021. * The rendering group used by the Particle system to chose when to render.
  12022. */
  12023. renderingGroupId: number;
  12024. /**
  12025. * The emitter represents the Mesh or position we are attaching the particle system to.
  12026. */
  12027. emitter: Nullable<AbstractMesh | Vector3>;
  12028. /**
  12029. * The maximum number of particles to emit per frame
  12030. */
  12031. emitRate: number;
  12032. /**
  12033. * If you want to launch only a few particles at once, that can be done, as well.
  12034. */
  12035. manualEmitCount: number;
  12036. /**
  12037. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12038. */
  12039. updateSpeed: number;
  12040. /**
  12041. * The amount of time the particle system is running (depends of the overall update speed).
  12042. */
  12043. targetStopDuration: number;
  12044. /**
  12045. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12046. */
  12047. disposeOnStop: boolean;
  12048. /**
  12049. * Minimum power of emitting particles.
  12050. */
  12051. minEmitPower: number;
  12052. /**
  12053. * Maximum power of emitting particles.
  12054. */
  12055. maxEmitPower: number;
  12056. /**
  12057. * Minimum life time of emitting particles.
  12058. */
  12059. minLifeTime: number;
  12060. /**
  12061. * Maximum life time of emitting particles.
  12062. */
  12063. maxLifeTime: number;
  12064. /**
  12065. * Minimum Size of emitting particles.
  12066. */
  12067. minSize: number;
  12068. /**
  12069. * Maximum Size of emitting particles.
  12070. */
  12071. maxSize: number;
  12072. /**
  12073. * Minimum scale of emitting particles on X axis.
  12074. */
  12075. minScaleX: number;
  12076. /**
  12077. * Maximum scale of emitting particles on X axis.
  12078. */
  12079. maxScaleX: number;
  12080. /**
  12081. * Minimum scale of emitting particles on Y axis.
  12082. */
  12083. minScaleY: number;
  12084. /**
  12085. * Maximum scale of emitting particles on Y axis.
  12086. */
  12087. maxScaleY: number;
  12088. /**
  12089. * Gets or sets the minimal initial rotation in radians.
  12090. */
  12091. minInitialRotation: number;
  12092. /**
  12093. * Gets or sets the maximal initial rotation in radians.
  12094. */
  12095. maxInitialRotation: number;
  12096. /**
  12097. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12098. */
  12099. minAngularSpeed: number;
  12100. /**
  12101. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12102. */
  12103. maxAngularSpeed: number;
  12104. /**
  12105. * The texture used to render each particle. (this can be a spritesheet)
  12106. */
  12107. particleTexture: Nullable<BaseTexture>;
  12108. /**
  12109. * The layer mask we are rendering the particles through.
  12110. */
  12111. layerMask: number;
  12112. /**
  12113. * This can help using your own shader to render the particle system.
  12114. * The according effect will be created
  12115. */
  12116. customShader: any;
  12117. /**
  12118. * By default particle system starts as soon as they are created. This prevents the
  12119. * automatic start to happen and let you decide when to start emitting particles.
  12120. */
  12121. preventAutoStart: boolean;
  12122. private _noiseTexture;
  12123. /**
  12124. * Gets or sets a texture used to add random noise to particle positions
  12125. */
  12126. get noiseTexture(): Nullable<ProceduralTexture>;
  12127. set noiseTexture(value: Nullable<ProceduralTexture>);
  12128. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12129. noiseStrength: Vector3;
  12130. /**
  12131. * Callback triggered when the particle animation is ending.
  12132. */
  12133. onAnimationEnd: Nullable<() => void>;
  12134. /**
  12135. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12136. */
  12137. blendMode: number;
  12138. /**
  12139. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12140. * to override the particles.
  12141. */
  12142. forceDepthWrite: boolean;
  12143. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  12144. preWarmCycles: number;
  12145. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12146. preWarmStepOffset: number;
  12147. /**
  12148. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  12149. */
  12150. spriteCellChangeSpeed: number;
  12151. /**
  12152. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12153. */
  12154. startSpriteCellID: number;
  12155. /**
  12156. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12157. */
  12158. endSpriteCellID: number;
  12159. /**
  12160. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12161. */
  12162. spriteCellWidth: number;
  12163. /**
  12164. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12165. */
  12166. spriteCellHeight: number;
  12167. /**
  12168. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12169. */
  12170. spriteRandomStartCell: boolean;
  12171. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12172. translationPivot: Vector2;
  12173. /** @hidden */
  12174. protected _isAnimationSheetEnabled: boolean;
  12175. /**
  12176. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12177. */
  12178. beginAnimationOnStart: boolean;
  12179. /**
  12180. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12181. */
  12182. beginAnimationFrom: number;
  12183. /**
  12184. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12185. */
  12186. beginAnimationTo: number;
  12187. /**
  12188. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12189. */
  12190. beginAnimationLoop: boolean;
  12191. /**
  12192. * Gets or sets a world offset applied to all particles
  12193. */
  12194. worldOffset: Vector3;
  12195. /**
  12196. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12197. */
  12198. get isAnimationSheetEnabled(): boolean;
  12199. set isAnimationSheetEnabled(value: boolean);
  12200. /**
  12201. * Get hosting scene
  12202. * @returns the scene
  12203. */
  12204. getScene(): Nullable<Scene>;
  12205. /**
  12206. * You can use gravity if you want to give an orientation to your particles.
  12207. */
  12208. gravity: Vector3;
  12209. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12210. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12211. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12212. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12213. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12214. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12215. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12216. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12217. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12218. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12219. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12220. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12221. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12222. /**
  12223. * Defines the delay in milliseconds before starting the system (0 by default)
  12224. */
  12225. startDelay: number;
  12226. /**
  12227. * Gets the current list of drag gradients.
  12228. * You must use addDragGradient and removeDragGradient to udpate this list
  12229. * @returns the list of drag gradients
  12230. */
  12231. getDragGradients(): Nullable<Array<FactorGradient>>;
  12232. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12233. limitVelocityDamping: number;
  12234. /**
  12235. * Gets the current list of limit velocity gradients.
  12236. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12237. * @returns the list of limit velocity gradients
  12238. */
  12239. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12240. /**
  12241. * Gets the current list of color gradients.
  12242. * You must use addColorGradient and removeColorGradient to udpate this list
  12243. * @returns the list of color gradients
  12244. */
  12245. getColorGradients(): Nullable<Array<ColorGradient>>;
  12246. /**
  12247. * Gets the current list of size gradients.
  12248. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12249. * @returns the list of size gradients
  12250. */
  12251. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12252. /**
  12253. * Gets the current list of color remap gradients.
  12254. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12255. * @returns the list of color remap gradients
  12256. */
  12257. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12258. /**
  12259. * Gets the current list of alpha remap gradients.
  12260. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12261. * @returns the list of alpha remap gradients
  12262. */
  12263. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12264. /**
  12265. * Gets the current list of life time gradients.
  12266. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12267. * @returns the list of life time gradients
  12268. */
  12269. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12270. /**
  12271. * Gets the current list of angular speed gradients.
  12272. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12273. * @returns the list of angular speed gradients
  12274. */
  12275. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12276. /**
  12277. * Gets the current list of velocity gradients.
  12278. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12279. * @returns the list of velocity gradients
  12280. */
  12281. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12282. /**
  12283. * Gets the current list of start size gradients.
  12284. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12285. * @returns the list of start size gradients
  12286. */
  12287. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12288. /**
  12289. * Gets the current list of emit rate gradients.
  12290. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12291. * @returns the list of emit rate gradients
  12292. */
  12293. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12294. /**
  12295. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12296. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12297. */
  12298. get direction1(): Vector3;
  12299. set direction1(value: Vector3);
  12300. /**
  12301. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12302. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12303. */
  12304. get direction2(): Vector3;
  12305. set direction2(value: Vector3);
  12306. /**
  12307. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12308. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12309. */
  12310. get minEmitBox(): Vector3;
  12311. set minEmitBox(value: Vector3);
  12312. /**
  12313. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12314. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12315. */
  12316. get maxEmitBox(): Vector3;
  12317. set maxEmitBox(value: Vector3);
  12318. /**
  12319. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12320. */
  12321. color1: Color4;
  12322. /**
  12323. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12324. */
  12325. color2: Color4;
  12326. /**
  12327. * Color the particle will have at the end of its lifetime
  12328. */
  12329. colorDead: Color4;
  12330. /**
  12331. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12332. */
  12333. textureMask: Color4;
  12334. /**
  12335. * The particle emitter type defines the emitter used by the particle system.
  12336. * It can be for example box, sphere, or cone...
  12337. */
  12338. particleEmitterType: IParticleEmitterType;
  12339. /** @hidden */
  12340. _isSubEmitter: boolean;
  12341. /**
  12342. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12343. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12344. */
  12345. billboardMode: number;
  12346. protected _isBillboardBased: boolean;
  12347. /**
  12348. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12349. */
  12350. get isBillboardBased(): boolean;
  12351. set isBillboardBased(value: boolean);
  12352. /**
  12353. * The scene the particle system belongs to.
  12354. */
  12355. protected _scene: Nullable<Scene>;
  12356. /**
  12357. * The engine the particle system belongs to.
  12358. */
  12359. protected _engine: ThinEngine;
  12360. /**
  12361. * Local cache of defines for image processing.
  12362. */
  12363. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12364. /**
  12365. * Default configuration related to image processing available in the standard Material.
  12366. */
  12367. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12368. /**
  12369. * Gets the image processing configuration used either in this material.
  12370. */
  12371. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12372. /**
  12373. * Sets the Default image processing configuration used either in the this material.
  12374. *
  12375. * If sets to null, the scene one is in use.
  12376. */
  12377. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12378. /**
  12379. * Attaches a new image processing configuration to the Standard Material.
  12380. * @param configuration
  12381. */
  12382. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12383. /** @hidden */
  12384. protected _reset(): void;
  12385. /** @hidden */
  12386. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12387. /**
  12388. * Instantiates a particle system.
  12389. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12390. * @param name The name of the particle system
  12391. */
  12392. constructor(name: string);
  12393. /**
  12394. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12395. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12396. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12397. * @returns the emitter
  12398. */
  12399. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12400. /**
  12401. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12402. * @param radius The radius of the hemisphere to emit from
  12403. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12404. * @returns the emitter
  12405. */
  12406. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12407. /**
  12408. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12409. * @param radius The radius of the sphere to emit from
  12410. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12411. * @returns the emitter
  12412. */
  12413. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12414. /**
  12415. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12416. * @param radius The radius of the sphere to emit from
  12417. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12418. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12419. * @returns the emitter
  12420. */
  12421. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12422. /**
  12423. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12424. * @param radius The radius of the emission cylinder
  12425. * @param height The height of the emission cylinder
  12426. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12427. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12428. * @returns the emitter
  12429. */
  12430. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12431. /**
  12432. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12433. * @param radius The radius of the cylinder to emit from
  12434. * @param height The height of the emission cylinder
  12435. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12436. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12437. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12438. * @returns the emitter
  12439. */
  12440. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12441. /**
  12442. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12443. * @param radius The radius of the cone to emit from
  12444. * @param angle The base angle of the cone
  12445. * @returns the emitter
  12446. */
  12447. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12448. /**
  12449. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12450. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12451. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12452. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12453. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12454. * @returns the emitter
  12455. */
  12456. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12457. }
  12458. }
  12459. declare module BABYLON {
  12460. /**
  12461. * Type of sub emitter
  12462. */
  12463. export enum SubEmitterType {
  12464. /**
  12465. * Attached to the particle over it's lifetime
  12466. */
  12467. ATTACHED = 0,
  12468. /**
  12469. * Created when the particle dies
  12470. */
  12471. END = 1
  12472. }
  12473. /**
  12474. * Sub emitter class used to emit particles from an existing particle
  12475. */
  12476. export class SubEmitter {
  12477. /**
  12478. * the particle system to be used by the sub emitter
  12479. */
  12480. particleSystem: ParticleSystem;
  12481. /**
  12482. * Type of the submitter (Default: END)
  12483. */
  12484. type: SubEmitterType;
  12485. /**
  12486. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  12487. * Note: This only is supported when using an emitter of type Mesh
  12488. */
  12489. inheritDirection: boolean;
  12490. /**
  12491. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12492. */
  12493. inheritedVelocityAmount: number;
  12494. /**
  12495. * Creates a sub emitter
  12496. * @param particleSystem the particle system to be used by the sub emitter
  12497. */
  12498. constructor(
  12499. /**
  12500. * the particle system to be used by the sub emitter
  12501. */
  12502. particleSystem: ParticleSystem);
  12503. /**
  12504. * Clones the sub emitter
  12505. * @returns the cloned sub emitter
  12506. */
  12507. clone(): SubEmitter;
  12508. /**
  12509. * Serialize current object to a JSON object
  12510. * @returns the serialized object
  12511. */
  12512. serialize(): any;
  12513. /** @hidden */
  12514. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12515. /**
  12516. * Creates a new SubEmitter from a serialized JSON version
  12517. * @param serializationObject defines the JSON object to read from
  12518. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12519. * @param rootUrl defines the rootUrl for data loading
  12520. * @returns a new SubEmitter
  12521. */
  12522. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12523. /** Release associated resources */
  12524. dispose(): void;
  12525. }
  12526. }
  12527. declare module BABYLON {
  12528. /** @hidden */
  12529. export var imageProcessingDeclaration: {
  12530. name: string;
  12531. shader: string;
  12532. };
  12533. }
  12534. declare module BABYLON {
  12535. /** @hidden */
  12536. export var imageProcessingFunctions: {
  12537. name: string;
  12538. shader: string;
  12539. };
  12540. }
  12541. declare module BABYLON {
  12542. /** @hidden */
  12543. export var particlesPixelShader: {
  12544. name: string;
  12545. shader: string;
  12546. };
  12547. }
  12548. declare module BABYLON {
  12549. /** @hidden */
  12550. export var particlesVertexShader: {
  12551. name: string;
  12552. shader: string;
  12553. };
  12554. }
  12555. declare module BABYLON {
  12556. /**
  12557. * Interface used to define entities containing multiple clip planes
  12558. */
  12559. export interface IClipPlanesHolder {
  12560. /**
  12561. * Gets or sets the active clipplane 1
  12562. */
  12563. clipPlane: Nullable<Plane>;
  12564. /**
  12565. * Gets or sets the active clipplane 2
  12566. */
  12567. clipPlane2: Nullable<Plane>;
  12568. /**
  12569. * Gets or sets the active clipplane 3
  12570. */
  12571. clipPlane3: Nullable<Plane>;
  12572. /**
  12573. * Gets or sets the active clipplane 4
  12574. */
  12575. clipPlane4: Nullable<Plane>;
  12576. /**
  12577. * Gets or sets the active clipplane 5
  12578. */
  12579. clipPlane5: Nullable<Plane>;
  12580. /**
  12581. * Gets or sets the active clipplane 6
  12582. */
  12583. clipPlane6: Nullable<Plane>;
  12584. }
  12585. }
  12586. declare module BABYLON {
  12587. /**
  12588. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12589. *
  12590. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12591. *
  12592. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12593. */
  12594. export class ThinMaterialHelper {
  12595. /**
  12596. * Binds the clip plane information from the holder to the effect.
  12597. * @param effect The effect we are binding the data to
  12598. * @param holder The entity containing the clip plane information
  12599. */
  12600. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12601. }
  12602. }
  12603. declare module BABYLON {
  12604. interface ThinEngine {
  12605. /**
  12606. * Sets alpha constants used by some alpha blending modes
  12607. * @param r defines the red component
  12608. * @param g defines the green component
  12609. * @param b defines the blue component
  12610. * @param a defines the alpha component
  12611. */
  12612. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12613. /**
  12614. * Sets the current alpha mode
  12615. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12616. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12617. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12618. */
  12619. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12620. /**
  12621. * Gets the current alpha mode
  12622. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12623. * @returns the current alpha mode
  12624. */
  12625. getAlphaMode(): number;
  12626. /**
  12627. * Sets the current alpha equation
  12628. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12629. */
  12630. setAlphaEquation(equation: number): void;
  12631. /**
  12632. * Gets the current alpha equation.
  12633. * @returns the current alpha equation
  12634. */
  12635. getAlphaEquation(): number;
  12636. }
  12637. }
  12638. declare module BABYLON {
  12639. /**
  12640. * This represents a particle system in Babylon.
  12641. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12642. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12643. * @example https://doc.babylonjs.com/babylon101/particles
  12644. */
  12645. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12646. /**
  12647. * Billboard mode will only apply to Y axis
  12648. */
  12649. static readonly BILLBOARDMODE_Y: number;
  12650. /**
  12651. * Billboard mode will apply to all axes
  12652. */
  12653. static readonly BILLBOARDMODE_ALL: number;
  12654. /**
  12655. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12656. */
  12657. static readonly BILLBOARDMODE_STRETCHED: number;
  12658. /**
  12659. * This function can be defined to provide custom update for active particles.
  12660. * This function will be called instead of regular update (age, position, color, etc.).
  12661. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12662. */
  12663. updateFunction: (particles: Particle[]) => void;
  12664. private _emitterWorldMatrix;
  12665. /**
  12666. * This function can be defined to specify initial direction for every new particle.
  12667. * It by default use the emitterType defined function
  12668. */
  12669. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12670. /**
  12671. * This function can be defined to specify initial position for every new particle.
  12672. * It by default use the emitterType defined function
  12673. */
  12674. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12675. /**
  12676. * @hidden
  12677. */
  12678. _inheritedVelocityOffset: Vector3;
  12679. /**
  12680. * An event triggered when the system is disposed
  12681. */
  12682. onDisposeObservable: Observable<IParticleSystem>;
  12683. /**
  12684. * An event triggered when the system is stopped
  12685. */
  12686. onStoppedObservable: Observable<IParticleSystem>;
  12687. private _onDisposeObserver;
  12688. /**
  12689. * Sets a callback that will be triggered when the system is disposed
  12690. */
  12691. set onDispose(callback: () => void);
  12692. private _particles;
  12693. private _epsilon;
  12694. private _capacity;
  12695. private _stockParticles;
  12696. private _newPartsExcess;
  12697. private _vertexData;
  12698. private _vertexBuffer;
  12699. private _vertexBuffers;
  12700. private _spriteBuffer;
  12701. private _indexBuffer;
  12702. private _effect;
  12703. private _customEffect;
  12704. private _cachedDefines;
  12705. private _scaledColorStep;
  12706. private _colorDiff;
  12707. private _scaledDirection;
  12708. private _scaledGravity;
  12709. private _currentRenderId;
  12710. private _alive;
  12711. private _useInstancing;
  12712. private _vertexArrayObject;
  12713. private _started;
  12714. private _stopped;
  12715. private _actualFrame;
  12716. private _scaledUpdateSpeed;
  12717. private _vertexBufferSize;
  12718. /** @hidden */
  12719. _currentEmitRateGradient: Nullable<FactorGradient>;
  12720. /** @hidden */
  12721. _currentEmitRate1: number;
  12722. /** @hidden */
  12723. _currentEmitRate2: number;
  12724. /** @hidden */
  12725. _currentStartSizeGradient: Nullable<FactorGradient>;
  12726. /** @hidden */
  12727. _currentStartSize1: number;
  12728. /** @hidden */
  12729. _currentStartSize2: number;
  12730. private readonly _rawTextureWidth;
  12731. private _rampGradientsTexture;
  12732. private _useRampGradients;
  12733. /** Gets or sets a matrix to use to compute projection */
  12734. defaultProjectionMatrix: Matrix;
  12735. /** Gets or sets a matrix to use to compute view */
  12736. defaultViewMatrix: Matrix;
  12737. /** Gets or sets a boolean indicating that ramp gradients must be used
  12738. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12739. */
  12740. get useRampGradients(): boolean;
  12741. set useRampGradients(value: boolean);
  12742. /**
  12743. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  12744. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  12745. */
  12746. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12747. private _subEmitters;
  12748. /**
  12749. * @hidden
  12750. * If the particle systems emitter should be disposed when the particle system is disposed
  12751. */
  12752. _disposeEmitterOnDispose: boolean;
  12753. /**
  12754. * The current active Sub-systems, this property is used by the root particle system only.
  12755. */
  12756. activeSubSystems: Array<ParticleSystem>;
  12757. /**
  12758. * Specifies if the particles are updated in emitter local space or world space
  12759. */
  12760. isLocal: boolean;
  12761. private _rootParticleSystem;
  12762. /**
  12763. * Gets the current list of active particles
  12764. */
  12765. get particles(): Particle[];
  12766. /**
  12767. * Gets the number of particles active at the same time.
  12768. * @returns The number of active particles.
  12769. */
  12770. getActiveCount(): number;
  12771. /**
  12772. * Returns the string "ParticleSystem"
  12773. * @returns a string containing the class name
  12774. */
  12775. getClassName(): string;
  12776. /**
  12777. * Gets a boolean indicating that the system is stopping
  12778. * @returns true if the system is currently stopping
  12779. */
  12780. isStopping(): boolean;
  12781. /**
  12782. * Gets the custom effect used to render the particles
  12783. * @param blendMode Blend mode for which the effect should be retrieved
  12784. * @returns The effect
  12785. */
  12786. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12787. /**
  12788. * Sets the custom effect used to render the particles
  12789. * @param effect The effect to set
  12790. * @param blendMode Blend mode for which the effect should be set
  12791. */
  12792. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12793. /** @hidden */
  12794. private _onBeforeDrawParticlesObservable;
  12795. /**
  12796. * Observable that will be called just before the particles are drawn
  12797. */
  12798. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12799. /**
  12800. * Gets the name of the particle vertex shader
  12801. */
  12802. get vertexShaderName(): string;
  12803. /**
  12804. * Instantiates a particle system.
  12805. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12806. * @param name The name of the particle system
  12807. * @param capacity The max number of particles alive at the same time
  12808. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12809. * @param customEffect a custom effect used to change the way particles are rendered by default
  12810. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12811. * @param epsilon Offset used to render the particles
  12812. */
  12813. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12814. private _addFactorGradient;
  12815. private _removeFactorGradient;
  12816. /**
  12817. * Adds a new life time gradient
  12818. * @param gradient defines the gradient to use (between 0 and 1)
  12819. * @param factor defines the life time factor to affect to the specified gradient
  12820. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12821. * @returns the current particle system
  12822. */
  12823. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12824. /**
  12825. * Remove a specific life time gradient
  12826. * @param gradient defines the gradient to remove
  12827. * @returns the current particle system
  12828. */
  12829. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12830. /**
  12831. * Adds a new size gradient
  12832. * @param gradient defines the gradient to use (between 0 and 1)
  12833. * @param factor defines the size factor to affect to the specified gradient
  12834. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12835. * @returns the current particle system
  12836. */
  12837. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12838. /**
  12839. * Remove a specific size gradient
  12840. * @param gradient defines the gradient to remove
  12841. * @returns the current particle system
  12842. */
  12843. removeSizeGradient(gradient: number): IParticleSystem;
  12844. /**
  12845. * Adds a new color remap gradient
  12846. * @param gradient defines the gradient to use (between 0 and 1)
  12847. * @param min defines the color remap minimal range
  12848. * @param max defines the color remap maximal range
  12849. * @returns the current particle system
  12850. */
  12851. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12852. /**
  12853. * Remove a specific color remap gradient
  12854. * @param gradient defines the gradient to remove
  12855. * @returns the current particle system
  12856. */
  12857. removeColorRemapGradient(gradient: number): IParticleSystem;
  12858. /**
  12859. * Adds a new alpha remap gradient
  12860. * @param gradient defines the gradient to use (between 0 and 1)
  12861. * @param min defines the alpha remap minimal range
  12862. * @param max defines the alpha remap maximal range
  12863. * @returns the current particle system
  12864. */
  12865. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12866. /**
  12867. * Remove a specific alpha remap gradient
  12868. * @param gradient defines the gradient to remove
  12869. * @returns the current particle system
  12870. */
  12871. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12872. /**
  12873. * Adds a new angular speed gradient
  12874. * @param gradient defines the gradient to use (between 0 and 1)
  12875. * @param factor defines the angular speed to affect to the specified gradient
  12876. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12877. * @returns the current particle system
  12878. */
  12879. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12880. /**
  12881. * Remove a specific angular speed gradient
  12882. * @param gradient defines the gradient to remove
  12883. * @returns the current particle system
  12884. */
  12885. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12886. /**
  12887. * Adds a new velocity gradient
  12888. * @param gradient defines the gradient to use (between 0 and 1)
  12889. * @param factor defines the velocity to affect to the specified gradient
  12890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12891. * @returns the current particle system
  12892. */
  12893. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12894. /**
  12895. * Remove a specific velocity gradient
  12896. * @param gradient defines the gradient to remove
  12897. * @returns the current particle system
  12898. */
  12899. removeVelocityGradient(gradient: number): IParticleSystem;
  12900. /**
  12901. * Adds a new limit velocity gradient
  12902. * @param gradient defines the gradient to use (between 0 and 1)
  12903. * @param factor defines the limit velocity value to affect to the specified gradient
  12904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12905. * @returns the current particle system
  12906. */
  12907. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12908. /**
  12909. * Remove a specific limit velocity gradient
  12910. * @param gradient defines the gradient to remove
  12911. * @returns the current particle system
  12912. */
  12913. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12914. /**
  12915. * Adds a new drag gradient
  12916. * @param gradient defines the gradient to use (between 0 and 1)
  12917. * @param factor defines the drag value to affect to the specified gradient
  12918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12919. * @returns the current particle system
  12920. */
  12921. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12922. /**
  12923. * Remove a specific drag gradient
  12924. * @param gradient defines the gradient to remove
  12925. * @returns the current particle system
  12926. */
  12927. removeDragGradient(gradient: number): IParticleSystem;
  12928. /**
  12929. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12930. * @param gradient defines the gradient to use (between 0 and 1)
  12931. * @param factor defines the emit rate value to affect to the specified gradient
  12932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12933. * @returns the current particle system
  12934. */
  12935. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12936. /**
  12937. * Remove a specific emit rate gradient
  12938. * @param gradient defines the gradient to remove
  12939. * @returns the current particle system
  12940. */
  12941. removeEmitRateGradient(gradient: number): IParticleSystem;
  12942. /**
  12943. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12944. * @param gradient defines the gradient to use (between 0 and 1)
  12945. * @param factor defines the start size value to affect to the specified gradient
  12946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12947. * @returns the current particle system
  12948. */
  12949. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12950. /**
  12951. * Remove a specific start size gradient
  12952. * @param gradient defines the gradient to remove
  12953. * @returns the current particle system
  12954. */
  12955. removeStartSizeGradient(gradient: number): IParticleSystem;
  12956. private _createRampGradientTexture;
  12957. /**
  12958. * Gets the current list of ramp gradients.
  12959. * You must use addRampGradient and removeRampGradient to udpate this list
  12960. * @returns the list of ramp gradients
  12961. */
  12962. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12963. /** Force the system to rebuild all gradients that need to be resync */
  12964. forceRefreshGradients(): void;
  12965. private _syncRampGradientTexture;
  12966. /**
  12967. * Adds a new ramp gradient used to remap particle colors
  12968. * @param gradient defines the gradient to use (between 0 and 1)
  12969. * @param color defines the color to affect to the specified gradient
  12970. * @returns the current particle system
  12971. */
  12972. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12973. /**
  12974. * Remove a specific ramp gradient
  12975. * @param gradient defines the gradient to remove
  12976. * @returns the current particle system
  12977. */
  12978. removeRampGradient(gradient: number): ParticleSystem;
  12979. /**
  12980. * Adds a new color gradient
  12981. * @param gradient defines the gradient to use (between 0 and 1)
  12982. * @param color1 defines the color to affect to the specified gradient
  12983. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12984. * @returns this particle system
  12985. */
  12986. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12987. /**
  12988. * Remove a specific color gradient
  12989. * @param gradient defines the gradient to remove
  12990. * @returns this particle system
  12991. */
  12992. removeColorGradient(gradient: number): IParticleSystem;
  12993. private _fetchR;
  12994. protected _reset(): void;
  12995. private _resetEffect;
  12996. private _createVertexBuffers;
  12997. private _createIndexBuffer;
  12998. /**
  12999. * Gets the maximum number of particles active at the same time.
  13000. * @returns The max number of active particles.
  13001. */
  13002. getCapacity(): number;
  13003. /**
  13004. * Gets whether there are still active particles in the system.
  13005. * @returns True if it is alive, otherwise false.
  13006. */
  13007. isAlive(): boolean;
  13008. /**
  13009. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13010. * @returns True if it has been started, otherwise false.
  13011. */
  13012. isStarted(): boolean;
  13013. private _prepareSubEmitterInternalArray;
  13014. /**
  13015. * Starts the particle system and begins to emit
  13016. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13017. */
  13018. start(delay?: number): void;
  13019. /**
  13020. * Stops the particle system.
  13021. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  13022. */
  13023. stop(stopSubEmitters?: boolean): void;
  13024. /**
  13025. * Remove all active particles
  13026. */
  13027. reset(): void;
  13028. /**
  13029. * @hidden (for internal use only)
  13030. */
  13031. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13032. /**
  13033. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13034. * Its lifetime will start back at 0.
  13035. */
  13036. recycleParticle: (particle: Particle) => void;
  13037. private _stopSubEmitters;
  13038. private _createParticle;
  13039. private _removeFromRoot;
  13040. private _emitFromParticle;
  13041. private _update;
  13042. /** @hidden */
  13043. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13044. /** @hidden */
  13045. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13046. /**
  13047. * Fill the defines array according to the current settings of the particle system
  13048. * @param defines Array to be updated
  13049. * @param blendMode blend mode to take into account when updating the array
  13050. */
  13051. fillDefines(defines: Array<string>, blendMode: number): void;
  13052. /**
  13053. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13054. * @param uniforms Uniforms array to fill
  13055. * @param attributes Attributes array to fill
  13056. * @param samplers Samplers array to fill
  13057. */
  13058. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13059. /** @hidden */
  13060. private _getEffect;
  13061. /**
  13062. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13063. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13064. */
  13065. animate(preWarmOnly?: boolean): void;
  13066. private _appendParticleVertices;
  13067. /**
  13068. * Rebuilds the particle system.
  13069. */
  13070. rebuild(): void;
  13071. /**
  13072. * Is this system ready to be used/rendered
  13073. * @return true if the system is ready
  13074. */
  13075. isReady(): boolean;
  13076. private _render;
  13077. /**
  13078. * Renders the particle system in its current state.
  13079. * @returns the current number of particles
  13080. */
  13081. render(): number;
  13082. /**
  13083. * Disposes the particle system and free the associated resources
  13084. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13085. */
  13086. dispose(disposeTexture?: boolean): void;
  13087. /**
  13088. * Clones the particle system.
  13089. * @param name The name of the cloned object
  13090. * @param newEmitter The new emitter to use
  13091. * @returns the cloned particle system
  13092. */
  13093. clone(name: string, newEmitter: any): ParticleSystem;
  13094. /**
  13095. * Serializes the particle system to a JSON object
  13096. * @param serializeTexture defines if the texture must be serialized as well
  13097. * @returns the JSON object
  13098. */
  13099. serialize(serializeTexture?: boolean): any;
  13100. /** @hidden */
  13101. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13102. /** @hidden */
  13103. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13104. /**
  13105. * Parses a JSON object to create a particle system.
  13106. * @param parsedParticleSystem The JSON object to parse
  13107. * @param sceneOrEngine The scene or the engine to create the particle system in
  13108. * @param rootUrl The root url to use to load external dependencies like texture
  13109. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13110. * @returns the Parsed particle system
  13111. */
  13112. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13113. }
  13114. }
  13115. declare module BABYLON {
  13116. /**
  13117. * A particle represents one of the element emitted by a particle system.
  13118. * This is mainly define by its coordinates, direction, velocity and age.
  13119. */
  13120. export class Particle {
  13121. /**
  13122. * The particle system the particle belongs to.
  13123. */
  13124. particleSystem: ParticleSystem;
  13125. private static _Count;
  13126. /**
  13127. * Unique ID of the particle
  13128. */
  13129. id: number;
  13130. /**
  13131. * The world position of the particle in the scene.
  13132. */
  13133. position: Vector3;
  13134. /**
  13135. * The world direction of the particle in the scene.
  13136. */
  13137. direction: Vector3;
  13138. /**
  13139. * The color of the particle.
  13140. */
  13141. color: Color4;
  13142. /**
  13143. * The color change of the particle per step.
  13144. */
  13145. colorStep: Color4;
  13146. /**
  13147. * Defines how long will the life of the particle be.
  13148. */
  13149. lifeTime: number;
  13150. /**
  13151. * The current age of the particle.
  13152. */
  13153. age: number;
  13154. /**
  13155. * The current size of the particle.
  13156. */
  13157. size: number;
  13158. /**
  13159. * The current scale of the particle.
  13160. */
  13161. scale: Vector2;
  13162. /**
  13163. * The current angle of the particle.
  13164. */
  13165. angle: number;
  13166. /**
  13167. * Defines how fast is the angle changing.
  13168. */
  13169. angularSpeed: number;
  13170. /**
  13171. * Defines the cell index used by the particle to be rendered from a sprite.
  13172. */
  13173. cellIndex: number;
  13174. /**
  13175. * The information required to support color remapping
  13176. */
  13177. remapData: Vector4;
  13178. /** @hidden */
  13179. _randomCellOffset?: number;
  13180. /** @hidden */
  13181. _initialDirection: Nullable<Vector3>;
  13182. /** @hidden */
  13183. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13184. /** @hidden */
  13185. _initialStartSpriteCellID: number;
  13186. /** @hidden */
  13187. _initialEndSpriteCellID: number;
  13188. /** @hidden */
  13189. _currentColorGradient: Nullable<ColorGradient>;
  13190. /** @hidden */
  13191. _currentColor1: Color4;
  13192. /** @hidden */
  13193. _currentColor2: Color4;
  13194. /** @hidden */
  13195. _currentSizeGradient: Nullable<FactorGradient>;
  13196. /** @hidden */
  13197. _currentSize1: number;
  13198. /** @hidden */
  13199. _currentSize2: number;
  13200. /** @hidden */
  13201. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13202. /** @hidden */
  13203. _currentAngularSpeed1: number;
  13204. /** @hidden */
  13205. _currentAngularSpeed2: number;
  13206. /** @hidden */
  13207. _currentVelocityGradient: Nullable<FactorGradient>;
  13208. /** @hidden */
  13209. _currentVelocity1: number;
  13210. /** @hidden */
  13211. _currentVelocity2: number;
  13212. /** @hidden */
  13213. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13214. /** @hidden */
  13215. _currentLimitVelocity1: number;
  13216. /** @hidden */
  13217. _currentLimitVelocity2: number;
  13218. /** @hidden */
  13219. _currentDragGradient: Nullable<FactorGradient>;
  13220. /** @hidden */
  13221. _currentDrag1: number;
  13222. /** @hidden */
  13223. _currentDrag2: number;
  13224. /** @hidden */
  13225. _randomNoiseCoordinates1: Vector3;
  13226. /** @hidden */
  13227. _randomNoiseCoordinates2: Vector3;
  13228. /** @hidden */
  13229. _localPosition?: Vector3;
  13230. /**
  13231. * Creates a new instance Particle
  13232. * @param particleSystem the particle system the particle belongs to
  13233. */
  13234. constructor(
  13235. /**
  13236. * The particle system the particle belongs to.
  13237. */
  13238. particleSystem: ParticleSystem);
  13239. private updateCellInfoFromSystem;
  13240. /**
  13241. * Defines how the sprite cell index is updated for the particle
  13242. */
  13243. updateCellIndex(): void;
  13244. /** @hidden */
  13245. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13246. /** @hidden */
  13247. _inheritParticleInfoToSubEmitters(): void;
  13248. /** @hidden */
  13249. _reset(): void;
  13250. /**
  13251. * Copy the properties of particle to another one.
  13252. * @param other the particle to copy the information to.
  13253. */
  13254. copyTo(other: Particle): void;
  13255. }
  13256. }
  13257. declare module BABYLON {
  13258. /**
  13259. * Particle emitter represents a volume emitting particles.
  13260. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13261. */
  13262. export interface IParticleEmitterType {
  13263. /**
  13264. * Called by the particle System when the direction is computed for the created particle.
  13265. * @param worldMatrix is the world matrix of the particle system
  13266. * @param directionToUpdate is the direction vector to update with the result
  13267. * @param particle is the particle we are computed the direction for
  13268. * @param isLocal defines if the direction should be set in local space
  13269. */
  13270. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13271. /**
  13272. * Called by the particle System when the position is computed for the created particle.
  13273. * @param worldMatrix is the world matrix of the particle system
  13274. * @param positionToUpdate is the position vector to update with the result
  13275. * @param particle is the particle we are computed the position for
  13276. * @param isLocal defines if the position should be set in local space
  13277. */
  13278. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13279. /**
  13280. * Clones the current emitter and returns a copy of it
  13281. * @returns the new emitter
  13282. */
  13283. clone(): IParticleEmitterType;
  13284. /**
  13285. * Called by the GPUParticleSystem to setup the update shader
  13286. * @param effect defines the update shader
  13287. */
  13288. applyToShader(effect: Effect): void;
  13289. /**
  13290. * Returns a string to use to update the GPU particles update shader
  13291. * @returns the effect defines string
  13292. */
  13293. getEffectDefines(): string;
  13294. /**
  13295. * Returns a string representing the class name
  13296. * @returns a string containing the class name
  13297. */
  13298. getClassName(): string;
  13299. /**
  13300. * Serializes the particle system to a JSON object.
  13301. * @returns the JSON object
  13302. */
  13303. serialize(): any;
  13304. /**
  13305. * Parse properties from a JSON object
  13306. * @param serializationObject defines the JSON object
  13307. * @param scene defines the hosting scene
  13308. */
  13309. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13310. }
  13311. }
  13312. declare module BABYLON {
  13313. /**
  13314. * Particle emitter emitting particles from the inside of a box.
  13315. * It emits the particles randomly between 2 given directions.
  13316. */
  13317. export class BoxParticleEmitter implements IParticleEmitterType {
  13318. /**
  13319. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13320. */
  13321. direction1: Vector3;
  13322. /**
  13323. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13324. */
  13325. direction2: Vector3;
  13326. /**
  13327. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13328. */
  13329. minEmitBox: Vector3;
  13330. /**
  13331. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13332. */
  13333. maxEmitBox: Vector3;
  13334. /**
  13335. * Creates a new instance BoxParticleEmitter
  13336. */
  13337. constructor();
  13338. /**
  13339. * Called by the particle System when the direction is computed for the created particle.
  13340. * @param worldMatrix is the world matrix of the particle system
  13341. * @param directionToUpdate is the direction vector to update with the result
  13342. * @param particle is the particle we are computed the direction for
  13343. * @param isLocal defines if the direction should be set in local space
  13344. */
  13345. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13346. /**
  13347. * Called by the particle System when the position is computed for the created particle.
  13348. * @param worldMatrix is the world matrix of the particle system
  13349. * @param positionToUpdate is the position vector to update with the result
  13350. * @param particle is the particle we are computed the position for
  13351. * @param isLocal defines if the position should be set in local space
  13352. */
  13353. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13354. /**
  13355. * Clones the current emitter and returns a copy of it
  13356. * @returns the new emitter
  13357. */
  13358. clone(): BoxParticleEmitter;
  13359. /**
  13360. * Called by the GPUParticleSystem to setup the update shader
  13361. * @param effect defines the update shader
  13362. */
  13363. applyToShader(effect: Effect): void;
  13364. /**
  13365. * Returns a string to use to update the GPU particles update shader
  13366. * @returns a string containng the defines string
  13367. */
  13368. getEffectDefines(): string;
  13369. /**
  13370. * Returns the string "BoxParticleEmitter"
  13371. * @returns a string containing the class name
  13372. */
  13373. getClassName(): string;
  13374. /**
  13375. * Serializes the particle system to a JSON object.
  13376. * @returns the JSON object
  13377. */
  13378. serialize(): any;
  13379. /**
  13380. * Parse properties from a JSON object
  13381. * @param serializationObject defines the JSON object
  13382. */
  13383. parse(serializationObject: any): void;
  13384. }
  13385. }
  13386. declare module BABYLON {
  13387. /**
  13388. * Particle emitter emitting particles from the inside of a cone.
  13389. * It emits the particles alongside the cone volume from the base to the particle.
  13390. * The emission direction might be randomized.
  13391. */
  13392. export class ConeParticleEmitter implements IParticleEmitterType {
  13393. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13394. directionRandomizer: number;
  13395. private _radius;
  13396. private _angle;
  13397. private _height;
  13398. /**
  13399. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13400. */
  13401. radiusRange: number;
  13402. /**
  13403. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13404. */
  13405. heightRange: number;
  13406. /**
  13407. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13408. */
  13409. emitFromSpawnPointOnly: boolean;
  13410. /**
  13411. * Gets or sets the radius of the emission cone
  13412. */
  13413. get radius(): number;
  13414. set radius(value: number);
  13415. /**
  13416. * Gets or sets the angle of the emission cone
  13417. */
  13418. get angle(): number;
  13419. set angle(value: number);
  13420. private _buildHeight;
  13421. /**
  13422. * Creates a new instance ConeParticleEmitter
  13423. * @param radius the radius of the emission cone (1 by default)
  13424. * @param angle the cone base angle (PI by default)
  13425. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13426. */
  13427. constructor(radius?: number, angle?: number,
  13428. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13429. directionRandomizer?: number);
  13430. /**
  13431. * Called by the particle System when the direction is computed for the created particle.
  13432. * @param worldMatrix is the world matrix of the particle system
  13433. * @param directionToUpdate is the direction vector to update with the result
  13434. * @param particle is the particle we are computed the direction for
  13435. * @param isLocal defines if the direction should be set in local space
  13436. */
  13437. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13438. /**
  13439. * Called by the particle System when the position is computed for the created particle.
  13440. * @param worldMatrix is the world matrix of the particle system
  13441. * @param positionToUpdate is the position vector to update with the result
  13442. * @param particle is the particle we are computed the position for
  13443. * @param isLocal defines if the position should be set in local space
  13444. */
  13445. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13446. /**
  13447. * Clones the current emitter and returns a copy of it
  13448. * @returns the new emitter
  13449. */
  13450. clone(): ConeParticleEmitter;
  13451. /**
  13452. * Called by the GPUParticleSystem to setup the update shader
  13453. * @param effect defines the update shader
  13454. */
  13455. applyToShader(effect: Effect): void;
  13456. /**
  13457. * Returns a string to use to update the GPU particles update shader
  13458. * @returns a string containng the defines string
  13459. */
  13460. getEffectDefines(): string;
  13461. /**
  13462. * Returns the string "ConeParticleEmitter"
  13463. * @returns a string containing the class name
  13464. */
  13465. getClassName(): string;
  13466. /**
  13467. * Serializes the particle system to a JSON object.
  13468. * @returns the JSON object
  13469. */
  13470. serialize(): any;
  13471. /**
  13472. * Parse properties from a JSON object
  13473. * @param serializationObject defines the JSON object
  13474. */
  13475. parse(serializationObject: any): void;
  13476. }
  13477. }
  13478. declare module BABYLON {
  13479. /**
  13480. * Particle emitter emitting particles from the inside of a cylinder.
  13481. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13482. */
  13483. export class CylinderParticleEmitter implements IParticleEmitterType {
  13484. /**
  13485. * The radius of the emission cylinder.
  13486. */
  13487. radius: number;
  13488. /**
  13489. * The height of the emission cylinder.
  13490. */
  13491. height: number;
  13492. /**
  13493. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13494. */
  13495. radiusRange: number;
  13496. /**
  13497. * How much to randomize the particle direction [0-1].
  13498. */
  13499. directionRandomizer: number;
  13500. /**
  13501. * Creates a new instance CylinderParticleEmitter
  13502. * @param radius the radius of the emission cylinder (1 by default)
  13503. * @param height the height of the emission cylinder (1 by default)
  13504. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13505. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13506. */
  13507. constructor(
  13508. /**
  13509. * The radius of the emission cylinder.
  13510. */
  13511. radius?: number,
  13512. /**
  13513. * The height of the emission cylinder.
  13514. */
  13515. height?: number,
  13516. /**
  13517. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13518. */
  13519. radiusRange?: number,
  13520. /**
  13521. * How much to randomize the particle direction [0-1].
  13522. */
  13523. directionRandomizer?: number);
  13524. /**
  13525. * Called by the particle System when the direction is computed for the created particle.
  13526. * @param worldMatrix is the world matrix of the particle system
  13527. * @param directionToUpdate is the direction vector to update with the result
  13528. * @param particle is the particle we are computed the direction for
  13529. * @param isLocal defines if the direction should be set in local space
  13530. */
  13531. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13532. /**
  13533. * Called by the particle System when the position is computed for the created particle.
  13534. * @param worldMatrix is the world matrix of the particle system
  13535. * @param positionToUpdate is the position vector to update with the result
  13536. * @param particle is the particle we are computed the position for
  13537. * @param isLocal defines if the position should be set in local space
  13538. */
  13539. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13540. /**
  13541. * Clones the current emitter and returns a copy of it
  13542. * @returns the new emitter
  13543. */
  13544. clone(): CylinderParticleEmitter;
  13545. /**
  13546. * Called by the GPUParticleSystem to setup the update shader
  13547. * @param effect defines the update shader
  13548. */
  13549. applyToShader(effect: Effect): void;
  13550. /**
  13551. * Returns a string to use to update the GPU particles update shader
  13552. * @returns a string containng the defines string
  13553. */
  13554. getEffectDefines(): string;
  13555. /**
  13556. * Returns the string "CylinderParticleEmitter"
  13557. * @returns a string containing the class name
  13558. */
  13559. getClassName(): string;
  13560. /**
  13561. * Serializes the particle system to a JSON object.
  13562. * @returns the JSON object
  13563. */
  13564. serialize(): any;
  13565. /**
  13566. * Parse properties from a JSON object
  13567. * @param serializationObject defines the JSON object
  13568. */
  13569. parse(serializationObject: any): void;
  13570. }
  13571. /**
  13572. * Particle emitter emitting particles from the inside of a cylinder.
  13573. * It emits the particles randomly between two vectors.
  13574. */
  13575. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13576. /**
  13577. * The min limit of the emission direction.
  13578. */
  13579. direction1: Vector3;
  13580. /**
  13581. * The max limit of the emission direction.
  13582. */
  13583. direction2: Vector3;
  13584. /**
  13585. * Creates a new instance CylinderDirectedParticleEmitter
  13586. * @param radius the radius of the emission cylinder (1 by default)
  13587. * @param height the height of the emission cylinder (1 by default)
  13588. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13589. * @param direction1 the min limit of the emission direction (up vector by default)
  13590. * @param direction2 the max limit of the emission direction (up vector by default)
  13591. */
  13592. constructor(radius?: number, height?: number, radiusRange?: number,
  13593. /**
  13594. * The min limit of the emission direction.
  13595. */
  13596. direction1?: Vector3,
  13597. /**
  13598. * The max limit of the emission direction.
  13599. */
  13600. direction2?: Vector3);
  13601. /**
  13602. * Called by the particle System when the direction is computed for the created particle.
  13603. * @param worldMatrix is the world matrix of the particle system
  13604. * @param directionToUpdate is the direction vector to update with the result
  13605. * @param particle is the particle we are computed the direction for
  13606. */
  13607. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13608. /**
  13609. * Clones the current emitter and returns a copy of it
  13610. * @returns the new emitter
  13611. */
  13612. clone(): CylinderDirectedParticleEmitter;
  13613. /**
  13614. * Called by the GPUParticleSystem to setup the update shader
  13615. * @param effect defines the update shader
  13616. */
  13617. applyToShader(effect: Effect): void;
  13618. /**
  13619. * Returns a string to use to update the GPU particles update shader
  13620. * @returns a string containng the defines string
  13621. */
  13622. getEffectDefines(): string;
  13623. /**
  13624. * Returns the string "CylinderDirectedParticleEmitter"
  13625. * @returns a string containing the class name
  13626. */
  13627. getClassName(): string;
  13628. /**
  13629. * Serializes the particle system to a JSON object.
  13630. * @returns the JSON object
  13631. */
  13632. serialize(): any;
  13633. /**
  13634. * Parse properties from a JSON object
  13635. * @param serializationObject defines the JSON object
  13636. */
  13637. parse(serializationObject: any): void;
  13638. }
  13639. }
  13640. declare module BABYLON {
  13641. /**
  13642. * Particle emitter emitting particles from the inside of a hemisphere.
  13643. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13644. */
  13645. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13646. /**
  13647. * The radius of the emission hemisphere.
  13648. */
  13649. radius: number;
  13650. /**
  13651. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13652. */
  13653. radiusRange: number;
  13654. /**
  13655. * How much to randomize the particle direction [0-1].
  13656. */
  13657. directionRandomizer: number;
  13658. /**
  13659. * Creates a new instance HemisphericParticleEmitter
  13660. * @param radius the radius of the emission hemisphere (1 by default)
  13661. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13662. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13663. */
  13664. constructor(
  13665. /**
  13666. * The radius of the emission hemisphere.
  13667. */
  13668. radius?: number,
  13669. /**
  13670. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13671. */
  13672. radiusRange?: number,
  13673. /**
  13674. * How much to randomize the particle direction [0-1].
  13675. */
  13676. directionRandomizer?: number);
  13677. /**
  13678. * Called by the particle System when the direction is computed for the created particle.
  13679. * @param worldMatrix is the world matrix of the particle system
  13680. * @param directionToUpdate is the direction vector to update with the result
  13681. * @param particle is the particle we are computed the direction for
  13682. * @param isLocal defines if the direction should be set in local space
  13683. */
  13684. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13685. /**
  13686. * Called by the particle System when the position is computed for the created particle.
  13687. * @param worldMatrix is the world matrix of the particle system
  13688. * @param positionToUpdate is the position vector to update with the result
  13689. * @param particle is the particle we are computed the position for
  13690. * @param isLocal defines if the position should be set in local space
  13691. */
  13692. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13693. /**
  13694. * Clones the current emitter and returns a copy of it
  13695. * @returns the new emitter
  13696. */
  13697. clone(): HemisphericParticleEmitter;
  13698. /**
  13699. * Called by the GPUParticleSystem to setup the update shader
  13700. * @param effect defines the update shader
  13701. */
  13702. applyToShader(effect: Effect): void;
  13703. /**
  13704. * Returns a string to use to update the GPU particles update shader
  13705. * @returns a string containng the defines string
  13706. */
  13707. getEffectDefines(): string;
  13708. /**
  13709. * Returns the string "HemisphericParticleEmitter"
  13710. * @returns a string containing the class name
  13711. */
  13712. getClassName(): string;
  13713. /**
  13714. * Serializes the particle system to a JSON object.
  13715. * @returns the JSON object
  13716. */
  13717. serialize(): any;
  13718. /**
  13719. * Parse properties from a JSON object
  13720. * @param serializationObject defines the JSON object
  13721. */
  13722. parse(serializationObject: any): void;
  13723. }
  13724. }
  13725. declare module BABYLON {
  13726. /**
  13727. * Particle emitter emitting particles from a point.
  13728. * It emits the particles randomly between 2 given directions.
  13729. */
  13730. export class PointParticleEmitter implements IParticleEmitterType {
  13731. /**
  13732. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13733. */
  13734. direction1: Vector3;
  13735. /**
  13736. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13737. */
  13738. direction2: Vector3;
  13739. /**
  13740. * Creates a new instance PointParticleEmitter
  13741. */
  13742. constructor();
  13743. /**
  13744. * Called by the particle System when the direction is computed for the created particle.
  13745. * @param worldMatrix is the world matrix of the particle system
  13746. * @param directionToUpdate is the direction vector to update with the result
  13747. * @param particle is the particle we are computed the direction for
  13748. * @param isLocal defines if the direction should be set in local space
  13749. */
  13750. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13751. /**
  13752. * Called by the particle System when the position is computed for the created particle.
  13753. * @param worldMatrix is the world matrix of the particle system
  13754. * @param positionToUpdate is the position vector to update with the result
  13755. * @param particle is the particle we are computed the position for
  13756. * @param isLocal defines if the position should be set in local space
  13757. */
  13758. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13759. /**
  13760. * Clones the current emitter and returns a copy of it
  13761. * @returns the new emitter
  13762. */
  13763. clone(): PointParticleEmitter;
  13764. /**
  13765. * Called by the GPUParticleSystem to setup the update shader
  13766. * @param effect defines the update shader
  13767. */
  13768. applyToShader(effect: Effect): void;
  13769. /**
  13770. * Returns a string to use to update the GPU particles update shader
  13771. * @returns a string containng the defines string
  13772. */
  13773. getEffectDefines(): string;
  13774. /**
  13775. * Returns the string "PointParticleEmitter"
  13776. * @returns a string containing the class name
  13777. */
  13778. getClassName(): string;
  13779. /**
  13780. * Serializes the particle system to a JSON object.
  13781. * @returns the JSON object
  13782. */
  13783. serialize(): any;
  13784. /**
  13785. * Parse properties from a JSON object
  13786. * @param serializationObject defines the JSON object
  13787. */
  13788. parse(serializationObject: any): void;
  13789. }
  13790. }
  13791. declare module BABYLON {
  13792. /**
  13793. * Particle emitter emitting particles from the inside of a sphere.
  13794. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13795. */
  13796. export class SphereParticleEmitter implements IParticleEmitterType {
  13797. /**
  13798. * The radius of the emission sphere.
  13799. */
  13800. radius: number;
  13801. /**
  13802. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13803. */
  13804. radiusRange: number;
  13805. /**
  13806. * How much to randomize the particle direction [0-1].
  13807. */
  13808. directionRandomizer: number;
  13809. /**
  13810. * Creates a new instance SphereParticleEmitter
  13811. * @param radius the radius of the emission sphere (1 by default)
  13812. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13813. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13814. */
  13815. constructor(
  13816. /**
  13817. * The radius of the emission sphere.
  13818. */
  13819. radius?: number,
  13820. /**
  13821. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13822. */
  13823. radiusRange?: number,
  13824. /**
  13825. * How much to randomize the particle direction [0-1].
  13826. */
  13827. directionRandomizer?: number);
  13828. /**
  13829. * Called by the particle System when the direction is computed for the created particle.
  13830. * @param worldMatrix is the world matrix of the particle system
  13831. * @param directionToUpdate is the direction vector to update with the result
  13832. * @param particle is the particle we are computed the direction for
  13833. * @param isLocal defines if the direction should be set in local space
  13834. */
  13835. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13836. /**
  13837. * Called by the particle System when the position is computed for the created particle.
  13838. * @param worldMatrix is the world matrix of the particle system
  13839. * @param positionToUpdate is the position vector to update with the result
  13840. * @param particle is the particle we are computed the position for
  13841. * @param isLocal defines if the position should be set in local space
  13842. */
  13843. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13844. /**
  13845. * Clones the current emitter and returns a copy of it
  13846. * @returns the new emitter
  13847. */
  13848. clone(): SphereParticleEmitter;
  13849. /**
  13850. * Called by the GPUParticleSystem to setup the update shader
  13851. * @param effect defines the update shader
  13852. */
  13853. applyToShader(effect: Effect): void;
  13854. /**
  13855. * Returns a string to use to update the GPU particles update shader
  13856. * @returns a string containng the defines string
  13857. */
  13858. getEffectDefines(): string;
  13859. /**
  13860. * Returns the string "SphereParticleEmitter"
  13861. * @returns a string containing the class name
  13862. */
  13863. getClassName(): string;
  13864. /**
  13865. * Serializes the particle system to a JSON object.
  13866. * @returns the JSON object
  13867. */
  13868. serialize(): any;
  13869. /**
  13870. * Parse properties from a JSON object
  13871. * @param serializationObject defines the JSON object
  13872. */
  13873. parse(serializationObject: any): void;
  13874. }
  13875. /**
  13876. * Particle emitter emitting particles from the inside of a sphere.
  13877. * It emits the particles randomly between two vectors.
  13878. */
  13879. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13880. /**
  13881. * The min limit of the emission direction.
  13882. */
  13883. direction1: Vector3;
  13884. /**
  13885. * The max limit of the emission direction.
  13886. */
  13887. direction2: Vector3;
  13888. /**
  13889. * Creates a new instance SphereDirectedParticleEmitter
  13890. * @param radius the radius of the emission sphere (1 by default)
  13891. * @param direction1 the min limit of the emission direction (up vector by default)
  13892. * @param direction2 the max limit of the emission direction (up vector by default)
  13893. */
  13894. constructor(radius?: number,
  13895. /**
  13896. * The min limit of the emission direction.
  13897. */
  13898. direction1?: Vector3,
  13899. /**
  13900. * The max limit of the emission direction.
  13901. */
  13902. direction2?: Vector3);
  13903. /**
  13904. * Called by the particle System when the direction is computed for the created particle.
  13905. * @param worldMatrix is the world matrix of the particle system
  13906. * @param directionToUpdate is the direction vector to update with the result
  13907. * @param particle is the particle we are computed the direction for
  13908. */
  13909. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13910. /**
  13911. * Clones the current emitter and returns a copy of it
  13912. * @returns the new emitter
  13913. */
  13914. clone(): SphereDirectedParticleEmitter;
  13915. /**
  13916. * Called by the GPUParticleSystem to setup the update shader
  13917. * @param effect defines the update shader
  13918. */
  13919. applyToShader(effect: Effect): void;
  13920. /**
  13921. * Returns a string to use to update the GPU particles update shader
  13922. * @returns a string containng the defines string
  13923. */
  13924. getEffectDefines(): string;
  13925. /**
  13926. * Returns the string "SphereDirectedParticleEmitter"
  13927. * @returns a string containing the class name
  13928. */
  13929. getClassName(): string;
  13930. /**
  13931. * Serializes the particle system to a JSON object.
  13932. * @returns the JSON object
  13933. */
  13934. serialize(): any;
  13935. /**
  13936. * Parse properties from a JSON object
  13937. * @param serializationObject defines the JSON object
  13938. */
  13939. parse(serializationObject: any): void;
  13940. }
  13941. }
  13942. declare module BABYLON {
  13943. /**
  13944. * Particle emitter emitting particles from a custom list of positions.
  13945. */
  13946. export class CustomParticleEmitter implements IParticleEmitterType {
  13947. /**
  13948. * Gets or sets the position generator that will create the inital position of each particle.
  13949. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13950. */
  13951. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13952. /**
  13953. * Gets or sets the destination generator that will create the final destination of each particle.
  13954. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13955. */
  13956. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13957. /**
  13958. * Creates a new instance CustomParticleEmitter
  13959. */
  13960. constructor();
  13961. /**
  13962. * Called by the particle System when the direction is computed for the created particle.
  13963. * @param worldMatrix is the world matrix of the particle system
  13964. * @param directionToUpdate is the direction vector to update with the result
  13965. * @param particle is the particle we are computed the direction for
  13966. * @param isLocal defines if the direction should be set in local space
  13967. */
  13968. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13969. /**
  13970. * Called by the particle System when the position is computed for the created particle.
  13971. * @param worldMatrix is the world matrix of the particle system
  13972. * @param positionToUpdate is the position vector to update with the result
  13973. * @param particle is the particle we are computed the position for
  13974. * @param isLocal defines if the position should be set in local space
  13975. */
  13976. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13977. /**
  13978. * Clones the current emitter and returns a copy of it
  13979. * @returns the new emitter
  13980. */
  13981. clone(): CustomParticleEmitter;
  13982. /**
  13983. * Called by the GPUParticleSystem to setup the update shader
  13984. * @param effect defines the update shader
  13985. */
  13986. applyToShader(effect: Effect): void;
  13987. /**
  13988. * Returns a string to use to update the GPU particles update shader
  13989. * @returns a string containng the defines string
  13990. */
  13991. getEffectDefines(): string;
  13992. /**
  13993. * Returns the string "PointParticleEmitter"
  13994. * @returns a string containing the class name
  13995. */
  13996. getClassName(): string;
  13997. /**
  13998. * Serializes the particle system to a JSON object.
  13999. * @returns the JSON object
  14000. */
  14001. serialize(): any;
  14002. /**
  14003. * Parse properties from a JSON object
  14004. * @param serializationObject defines the JSON object
  14005. */
  14006. parse(serializationObject: any): void;
  14007. }
  14008. }
  14009. declare module BABYLON {
  14010. /**
  14011. * Particle emitter emitting particles from the inside of a box.
  14012. * It emits the particles randomly between 2 given directions.
  14013. */
  14014. export class MeshParticleEmitter implements IParticleEmitterType {
  14015. private _indices;
  14016. private _positions;
  14017. private _normals;
  14018. private _storedNormal;
  14019. private _mesh;
  14020. /**
  14021. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14022. */
  14023. direction1: Vector3;
  14024. /**
  14025. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14026. */
  14027. direction2: Vector3;
  14028. /**
  14029. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14030. */
  14031. useMeshNormalsForDirection: boolean;
  14032. /** Defines the mesh to use as source */
  14033. get mesh(): Nullable<AbstractMesh>;
  14034. set mesh(value: Nullable<AbstractMesh>);
  14035. /**
  14036. * Creates a new instance MeshParticleEmitter
  14037. * @param mesh defines the mesh to use as source
  14038. */
  14039. constructor(mesh?: Nullable<AbstractMesh>);
  14040. /**
  14041. * Called by the particle System when the direction is computed for the created particle.
  14042. * @param worldMatrix is the world matrix of the particle system
  14043. * @param directionToUpdate is the direction vector to update with the result
  14044. * @param particle is the particle we are computed the direction for
  14045. * @param isLocal defines if the direction should be set in local space
  14046. */
  14047. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14048. /**
  14049. * Called by the particle System when the position is computed for the created particle.
  14050. * @param worldMatrix is the world matrix of the particle system
  14051. * @param positionToUpdate is the position vector to update with the result
  14052. * @param particle is the particle we are computed the position for
  14053. * @param isLocal defines if the position should be set in local space
  14054. */
  14055. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14056. /**
  14057. * Clones the current emitter and returns a copy of it
  14058. * @returns the new emitter
  14059. */
  14060. clone(): MeshParticleEmitter;
  14061. /**
  14062. * Called by the GPUParticleSystem to setup the update shader
  14063. * @param effect defines the update shader
  14064. */
  14065. applyToShader(effect: Effect): void;
  14066. /**
  14067. * Returns a string to use to update the GPU particles update shader
  14068. * @returns a string containng the defines string
  14069. */
  14070. getEffectDefines(): string;
  14071. /**
  14072. * Returns the string "BoxParticleEmitter"
  14073. * @returns a string containing the class name
  14074. */
  14075. getClassName(): string;
  14076. /**
  14077. * Serializes the particle system to a JSON object.
  14078. * @returns the JSON object
  14079. */
  14080. serialize(): any;
  14081. /**
  14082. * Parse properties from a JSON object
  14083. * @param serializationObject defines the JSON object
  14084. * @param scene defines the hosting scene
  14085. */
  14086. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14087. }
  14088. }
  14089. declare module BABYLON {
  14090. /**
  14091. * Interface representing a particle system in Babylon.js.
  14092. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14093. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14094. */
  14095. export interface IParticleSystem {
  14096. /**
  14097. * List of animations used by the particle system.
  14098. */
  14099. animations: Animation[];
  14100. /**
  14101. * The id of the Particle system.
  14102. */
  14103. id: string;
  14104. /**
  14105. * The name of the Particle system.
  14106. */
  14107. name: string;
  14108. /**
  14109. * The emitter represents the Mesh or position we are attaching the particle system to.
  14110. */
  14111. emitter: Nullable<AbstractMesh | Vector3>;
  14112. /**
  14113. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14114. */
  14115. isBillboardBased: boolean;
  14116. /**
  14117. * The rendering group used by the Particle system to chose when to render.
  14118. */
  14119. renderingGroupId: number;
  14120. /**
  14121. * The layer mask we are rendering the particles through.
  14122. */
  14123. layerMask: number;
  14124. /**
  14125. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14126. */
  14127. updateSpeed: number;
  14128. /**
  14129. * The amount of time the particle system is running (depends of the overall update speed).
  14130. */
  14131. targetStopDuration: number;
  14132. /**
  14133. * The texture used to render each particle. (this can be a spritesheet)
  14134. */
  14135. particleTexture: Nullable<BaseTexture>;
  14136. /**
  14137. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14138. */
  14139. blendMode: number;
  14140. /**
  14141. * Minimum life time of emitting particles.
  14142. */
  14143. minLifeTime: number;
  14144. /**
  14145. * Maximum life time of emitting particles.
  14146. */
  14147. maxLifeTime: number;
  14148. /**
  14149. * Minimum Size of emitting particles.
  14150. */
  14151. minSize: number;
  14152. /**
  14153. * Maximum Size of emitting particles.
  14154. */
  14155. maxSize: number;
  14156. /**
  14157. * Minimum scale of emitting particles on X axis.
  14158. */
  14159. minScaleX: number;
  14160. /**
  14161. * Maximum scale of emitting particles on X axis.
  14162. */
  14163. maxScaleX: number;
  14164. /**
  14165. * Minimum scale of emitting particles on Y axis.
  14166. */
  14167. minScaleY: number;
  14168. /**
  14169. * Maximum scale of emitting particles on Y axis.
  14170. */
  14171. maxScaleY: number;
  14172. /**
  14173. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14174. */
  14175. color1: Color4;
  14176. /**
  14177. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14178. */
  14179. color2: Color4;
  14180. /**
  14181. * Color the particle will have at the end of its lifetime.
  14182. */
  14183. colorDead: Color4;
  14184. /**
  14185. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14186. */
  14187. emitRate: number;
  14188. /**
  14189. * You can use gravity if you want to give an orientation to your particles.
  14190. */
  14191. gravity: Vector3;
  14192. /**
  14193. * Minimum power of emitting particles.
  14194. */
  14195. minEmitPower: number;
  14196. /**
  14197. * Maximum power of emitting particles.
  14198. */
  14199. maxEmitPower: number;
  14200. /**
  14201. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14202. */
  14203. minAngularSpeed: number;
  14204. /**
  14205. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14206. */
  14207. maxAngularSpeed: number;
  14208. /**
  14209. * Gets or sets the minimal initial rotation in radians.
  14210. */
  14211. minInitialRotation: number;
  14212. /**
  14213. * Gets or sets the maximal initial rotation in radians.
  14214. */
  14215. maxInitialRotation: number;
  14216. /**
  14217. * The particle emitter type defines the emitter used by the particle system.
  14218. * It can be for example box, sphere, or cone...
  14219. */
  14220. particleEmitterType: Nullable<IParticleEmitterType>;
  14221. /**
  14222. * Defines the delay in milliseconds before starting the system (0 by default)
  14223. */
  14224. startDelay: number;
  14225. /**
  14226. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  14227. */
  14228. preWarmCycles: number;
  14229. /**
  14230. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14231. */
  14232. preWarmStepOffset: number;
  14233. /**
  14234. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14235. */
  14236. spriteCellChangeSpeed: number;
  14237. /**
  14238. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14239. */
  14240. startSpriteCellID: number;
  14241. /**
  14242. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14243. */
  14244. endSpriteCellID: number;
  14245. /**
  14246. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14247. */
  14248. spriteCellWidth: number;
  14249. /**
  14250. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14251. */
  14252. spriteCellHeight: number;
  14253. /**
  14254. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14255. */
  14256. spriteRandomStartCell: boolean;
  14257. /**
  14258. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14259. */
  14260. isAnimationSheetEnabled: boolean;
  14261. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14262. translationPivot: Vector2;
  14263. /**
  14264. * Gets or sets a texture used to add random noise to particle positions
  14265. */
  14266. noiseTexture: Nullable<BaseTexture>;
  14267. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14268. noiseStrength: Vector3;
  14269. /**
  14270. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14271. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14272. */
  14273. billboardMode: number;
  14274. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14275. limitVelocityDamping: number;
  14276. /**
  14277. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14278. */
  14279. beginAnimationOnStart: boolean;
  14280. /**
  14281. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14282. */
  14283. beginAnimationFrom: number;
  14284. /**
  14285. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14286. */
  14287. beginAnimationTo: number;
  14288. /**
  14289. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14290. */
  14291. beginAnimationLoop: boolean;
  14292. /**
  14293. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14294. */
  14295. disposeOnStop: boolean;
  14296. /**
  14297. * Specifies if the particles are updated in emitter local space or world space
  14298. */
  14299. isLocal: boolean;
  14300. /** Snippet ID if the particle system was created from the snippet server */
  14301. snippetId: string;
  14302. /** Gets or sets a matrix to use to compute projection */
  14303. defaultProjectionMatrix: Matrix;
  14304. /**
  14305. * Gets the maximum number of particles active at the same time.
  14306. * @returns The max number of active particles.
  14307. */
  14308. getCapacity(): number;
  14309. /**
  14310. * Gets the number of particles active at the same time.
  14311. * @returns The number of active particles.
  14312. */
  14313. getActiveCount(): number;
  14314. /**
  14315. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14316. * @returns True if it has been started, otherwise false.
  14317. */
  14318. isStarted(): boolean;
  14319. /**
  14320. * Animates the particle system for this frame.
  14321. */
  14322. animate(): void;
  14323. /**
  14324. * Renders the particle system in its current state.
  14325. * @returns the current number of particles
  14326. */
  14327. render(): number;
  14328. /**
  14329. * Dispose the particle system and frees its associated resources.
  14330. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14331. */
  14332. dispose(disposeTexture?: boolean): void;
  14333. /**
  14334. * An event triggered when the system is disposed
  14335. */
  14336. onDisposeObservable: Observable<IParticleSystem>;
  14337. /**
  14338. * An event triggered when the system is stopped
  14339. */
  14340. onStoppedObservable: Observable<IParticleSystem>;
  14341. /**
  14342. * Clones the particle system.
  14343. * @param name The name of the cloned object
  14344. * @param newEmitter The new emitter to use
  14345. * @returns the cloned particle system
  14346. */
  14347. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14348. /**
  14349. * Serializes the particle system to a JSON object
  14350. * @param serializeTexture defines if the texture must be serialized as well
  14351. * @returns the JSON object
  14352. */
  14353. serialize(serializeTexture: boolean): any;
  14354. /**
  14355. * Rebuild the particle system
  14356. */
  14357. rebuild(): void;
  14358. /** Force the system to rebuild all gradients that need to be resync */
  14359. forceRefreshGradients(): void;
  14360. /**
  14361. * Starts the particle system and begins to emit
  14362. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14363. */
  14364. start(delay?: number): void;
  14365. /**
  14366. * Stops the particle system.
  14367. */
  14368. stop(): void;
  14369. /**
  14370. * Remove all active particles
  14371. */
  14372. reset(): void;
  14373. /**
  14374. * Gets a boolean indicating that the system is stopping
  14375. * @returns true if the system is currently stopping
  14376. */
  14377. isStopping(): boolean;
  14378. /**
  14379. * Is this system ready to be used/rendered
  14380. * @return true if the system is ready
  14381. */
  14382. isReady(): boolean;
  14383. /**
  14384. * Returns the string "ParticleSystem"
  14385. * @returns a string containing the class name
  14386. */
  14387. getClassName(): string;
  14388. /**
  14389. * Gets the custom effect used to render the particles
  14390. * @param blendMode Blend mode for which the effect should be retrieved
  14391. * @returns The effect
  14392. */
  14393. getCustomEffect(blendMode: number): Nullable<Effect>;
  14394. /**
  14395. * Sets the custom effect used to render the particles
  14396. * @param effect The effect to set
  14397. * @param blendMode Blend mode for which the effect should be set
  14398. */
  14399. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14400. /**
  14401. * Fill the defines array according to the current settings of the particle system
  14402. * @param defines Array to be updated
  14403. * @param blendMode blend mode to take into account when updating the array
  14404. */
  14405. fillDefines(defines: Array<string>, blendMode: number): void;
  14406. /**
  14407. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14408. * @param uniforms Uniforms array to fill
  14409. * @param attributes Attributes array to fill
  14410. * @param samplers Samplers array to fill
  14411. */
  14412. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14413. /**
  14414. * Observable that will be called just before the particles are drawn
  14415. */
  14416. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14417. /**
  14418. * Gets the name of the particle vertex shader
  14419. */
  14420. vertexShaderName: string;
  14421. /**
  14422. * Adds a new color gradient
  14423. * @param gradient defines the gradient to use (between 0 and 1)
  14424. * @param color1 defines the color to affect to the specified gradient
  14425. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14426. * @returns the current particle system
  14427. */
  14428. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14429. /**
  14430. * Remove a specific color gradient
  14431. * @param gradient defines the gradient to remove
  14432. * @returns the current particle system
  14433. */
  14434. removeColorGradient(gradient: number): IParticleSystem;
  14435. /**
  14436. * Adds a new size gradient
  14437. * @param gradient defines the gradient to use (between 0 and 1)
  14438. * @param factor defines the size factor to affect to the specified gradient
  14439. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14440. * @returns the current particle system
  14441. */
  14442. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14443. /**
  14444. * Remove a specific size gradient
  14445. * @param gradient defines the gradient to remove
  14446. * @returns the current particle system
  14447. */
  14448. removeSizeGradient(gradient: number): IParticleSystem;
  14449. /**
  14450. * Gets the current list of color gradients.
  14451. * You must use addColorGradient and removeColorGradient to udpate this list
  14452. * @returns the list of color gradients
  14453. */
  14454. getColorGradients(): Nullable<Array<ColorGradient>>;
  14455. /**
  14456. * Gets the current list of size gradients.
  14457. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14458. * @returns the list of size gradients
  14459. */
  14460. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14461. /**
  14462. * Gets the current list of angular speed gradients.
  14463. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14464. * @returns the list of angular speed gradients
  14465. */
  14466. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14467. /**
  14468. * Adds a new angular speed gradient
  14469. * @param gradient defines the gradient to use (between 0 and 1)
  14470. * @param factor defines the angular speed to affect to the specified gradient
  14471. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14472. * @returns the current particle system
  14473. */
  14474. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14475. /**
  14476. * Remove a specific angular speed gradient
  14477. * @param gradient defines the gradient to remove
  14478. * @returns the current particle system
  14479. */
  14480. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14481. /**
  14482. * Gets the current list of velocity gradients.
  14483. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14484. * @returns the list of velocity gradients
  14485. */
  14486. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14487. /**
  14488. * Adds a new velocity gradient
  14489. * @param gradient defines the gradient to use (between 0 and 1)
  14490. * @param factor defines the velocity to affect to the specified gradient
  14491. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14492. * @returns the current particle system
  14493. */
  14494. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14495. /**
  14496. * Remove a specific velocity gradient
  14497. * @param gradient defines the gradient to remove
  14498. * @returns the current particle system
  14499. */
  14500. removeVelocityGradient(gradient: number): IParticleSystem;
  14501. /**
  14502. * Gets the current list of limit velocity gradients.
  14503. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14504. * @returns the list of limit velocity gradients
  14505. */
  14506. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14507. /**
  14508. * Adds a new limit velocity gradient
  14509. * @param gradient defines the gradient to use (between 0 and 1)
  14510. * @param factor defines the limit velocity to affect to the specified gradient
  14511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14512. * @returns the current particle system
  14513. */
  14514. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14515. /**
  14516. * Remove a specific limit velocity gradient
  14517. * @param gradient defines the gradient to remove
  14518. * @returns the current particle system
  14519. */
  14520. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14521. /**
  14522. * Adds a new drag gradient
  14523. * @param gradient defines the gradient to use (between 0 and 1)
  14524. * @param factor defines the drag to affect to the specified gradient
  14525. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14526. * @returns the current particle system
  14527. */
  14528. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14529. /**
  14530. * Remove a specific drag gradient
  14531. * @param gradient defines the gradient to remove
  14532. * @returns the current particle system
  14533. */
  14534. removeDragGradient(gradient: number): IParticleSystem;
  14535. /**
  14536. * Gets the current list of drag gradients.
  14537. * You must use addDragGradient and removeDragGradient to udpate this list
  14538. * @returns the list of drag gradients
  14539. */
  14540. getDragGradients(): Nullable<Array<FactorGradient>>;
  14541. /**
  14542. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14543. * @param gradient defines the gradient to use (between 0 and 1)
  14544. * @param factor defines the emit rate to affect to the specified gradient
  14545. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14546. * @returns the current particle system
  14547. */
  14548. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14549. /**
  14550. * Remove a specific emit rate gradient
  14551. * @param gradient defines the gradient to remove
  14552. * @returns the current particle system
  14553. */
  14554. removeEmitRateGradient(gradient: number): IParticleSystem;
  14555. /**
  14556. * Gets the current list of emit rate gradients.
  14557. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14558. * @returns the list of emit rate gradients
  14559. */
  14560. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14561. /**
  14562. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14563. * @param gradient defines the gradient to use (between 0 and 1)
  14564. * @param factor defines the start size to affect to the specified gradient
  14565. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14566. * @returns the current particle system
  14567. */
  14568. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14569. /**
  14570. * Remove a specific start size gradient
  14571. * @param gradient defines the gradient to remove
  14572. * @returns the current particle system
  14573. */
  14574. removeStartSizeGradient(gradient: number): IParticleSystem;
  14575. /**
  14576. * Gets the current list of start size gradients.
  14577. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14578. * @returns the list of start size gradients
  14579. */
  14580. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14581. /**
  14582. * Adds a new life time gradient
  14583. * @param gradient defines the gradient to use (between 0 and 1)
  14584. * @param factor defines the life time factor to affect to the specified gradient
  14585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14586. * @returns the current particle system
  14587. */
  14588. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14589. /**
  14590. * Remove a specific life time gradient
  14591. * @param gradient defines the gradient to remove
  14592. * @returns the current particle system
  14593. */
  14594. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14595. /**
  14596. * Gets the current list of life time gradients.
  14597. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14598. * @returns the list of life time gradients
  14599. */
  14600. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14601. /**
  14602. * Gets the current list of color gradients.
  14603. * You must use addColorGradient and removeColorGradient to udpate this list
  14604. * @returns the list of color gradients
  14605. */
  14606. getColorGradients(): Nullable<Array<ColorGradient>>;
  14607. /**
  14608. * Adds a new ramp gradient used to remap particle colors
  14609. * @param gradient defines the gradient to use (between 0 and 1)
  14610. * @param color defines the color to affect to the specified gradient
  14611. * @returns the current particle system
  14612. */
  14613. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14614. /**
  14615. * Gets the current list of ramp gradients.
  14616. * You must use addRampGradient and removeRampGradient to udpate this list
  14617. * @returns the list of ramp gradients
  14618. */
  14619. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14620. /** Gets or sets a boolean indicating that ramp gradients must be used
  14621. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14622. */
  14623. useRampGradients: boolean;
  14624. /**
  14625. * Adds a new color remap gradient
  14626. * @param gradient defines the gradient to use (between 0 and 1)
  14627. * @param min defines the color remap minimal range
  14628. * @param max defines the color remap maximal range
  14629. * @returns the current particle system
  14630. */
  14631. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14632. /**
  14633. * Gets the current list of color remap gradients.
  14634. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14635. * @returns the list of color remap gradients
  14636. */
  14637. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14638. /**
  14639. * Adds a new alpha remap gradient
  14640. * @param gradient defines the gradient to use (between 0 and 1)
  14641. * @param min defines the alpha remap minimal range
  14642. * @param max defines the alpha remap maximal range
  14643. * @returns the current particle system
  14644. */
  14645. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14646. /**
  14647. * Gets the current list of alpha remap gradients.
  14648. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14649. * @returns the list of alpha remap gradients
  14650. */
  14651. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14652. /**
  14653. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14654. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14655. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14656. * @returns the emitter
  14657. */
  14658. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14659. /**
  14660. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14661. * @param radius The radius of the hemisphere to emit from
  14662. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14663. * @returns the emitter
  14664. */
  14665. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14666. /**
  14667. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14668. * @param radius The radius of the sphere to emit from
  14669. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14670. * @returns the emitter
  14671. */
  14672. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14673. /**
  14674. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14675. * @param radius The radius of the sphere to emit from
  14676. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14677. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14678. * @returns the emitter
  14679. */
  14680. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14681. /**
  14682. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14683. * @param radius The radius of the emission cylinder
  14684. * @param height The height of the emission cylinder
  14685. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14686. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14687. * @returns the emitter
  14688. */
  14689. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14690. /**
  14691. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14692. * @param radius The radius of the cylinder to emit from
  14693. * @param height The height of the emission cylinder
  14694. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14695. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14696. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14697. * @returns the emitter
  14698. */
  14699. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14700. /**
  14701. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14702. * @param radius The radius of the cone to emit from
  14703. * @param angle The base angle of the cone
  14704. * @returns the emitter
  14705. */
  14706. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14707. /**
  14708. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14709. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14710. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14711. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14712. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14713. * @returns the emitter
  14714. */
  14715. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14716. /**
  14717. * Get hosting scene
  14718. * @returns the scene
  14719. */
  14720. getScene(): Nullable<Scene>;
  14721. }
  14722. }
  14723. declare module BABYLON {
  14724. /**
  14725. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14726. * @see https://doc.babylonjs.com/how_to/transformnode
  14727. */
  14728. export class TransformNode extends Node {
  14729. /**
  14730. * Object will not rotate to face the camera
  14731. */
  14732. static BILLBOARDMODE_NONE: number;
  14733. /**
  14734. * Object will rotate to face the camera but only on the x axis
  14735. */
  14736. static BILLBOARDMODE_X: number;
  14737. /**
  14738. * Object will rotate to face the camera but only on the y axis
  14739. */
  14740. static BILLBOARDMODE_Y: number;
  14741. /**
  14742. * Object will rotate to face the camera but only on the z axis
  14743. */
  14744. static BILLBOARDMODE_Z: number;
  14745. /**
  14746. * Object will rotate to face the camera
  14747. */
  14748. static BILLBOARDMODE_ALL: number;
  14749. /**
  14750. * Object will rotate to face the camera's position instead of orientation
  14751. */
  14752. static BILLBOARDMODE_USE_POSITION: number;
  14753. private static _TmpRotation;
  14754. private static _TmpScaling;
  14755. private static _TmpTranslation;
  14756. private _forward;
  14757. private _forwardInverted;
  14758. private _up;
  14759. private _right;
  14760. private _rightInverted;
  14761. private _position;
  14762. private _rotation;
  14763. private _rotationQuaternion;
  14764. protected _scaling: Vector3;
  14765. protected _isDirty: boolean;
  14766. private _transformToBoneReferal;
  14767. private _isAbsoluteSynced;
  14768. private _billboardMode;
  14769. /**
  14770. * Gets or sets the billboard mode. Default is 0.
  14771. *
  14772. * | Value | Type | Description |
  14773. * | --- | --- | --- |
  14774. * | 0 | BILLBOARDMODE_NONE | |
  14775. * | 1 | BILLBOARDMODE_X | |
  14776. * | 2 | BILLBOARDMODE_Y | |
  14777. * | 4 | BILLBOARDMODE_Z | |
  14778. * | 7 | BILLBOARDMODE_ALL | |
  14779. *
  14780. */
  14781. get billboardMode(): number;
  14782. set billboardMode(value: number);
  14783. private _preserveParentRotationForBillboard;
  14784. /**
  14785. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14786. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14787. */
  14788. get preserveParentRotationForBillboard(): boolean;
  14789. set preserveParentRotationForBillboard(value: boolean);
  14790. /**
  14791. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14792. */
  14793. scalingDeterminant: number;
  14794. private _infiniteDistance;
  14795. /**
  14796. * Gets or sets the distance of the object to max, often used by skybox
  14797. */
  14798. get infiniteDistance(): boolean;
  14799. set infiniteDistance(value: boolean);
  14800. /**
  14801. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14802. * By default the system will update normals to compensate
  14803. */
  14804. ignoreNonUniformScaling: boolean;
  14805. /**
  14806. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14807. */
  14808. reIntegrateRotationIntoRotationQuaternion: boolean;
  14809. /** @hidden */
  14810. _poseMatrix: Nullable<Matrix>;
  14811. /** @hidden */
  14812. _localMatrix: Matrix;
  14813. private _usePivotMatrix;
  14814. private _absolutePosition;
  14815. private _absoluteScaling;
  14816. private _absoluteRotationQuaternion;
  14817. private _pivotMatrix;
  14818. private _pivotMatrixInverse;
  14819. /** @hidden */
  14820. _postMultiplyPivotMatrix: boolean;
  14821. protected _isWorldMatrixFrozen: boolean;
  14822. /** @hidden */
  14823. _indexInSceneTransformNodesArray: number;
  14824. /**
  14825. * An event triggered after the world matrix is updated
  14826. */
  14827. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14828. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14829. /**
  14830. * Gets a string identifying the name of the class
  14831. * @returns "TransformNode" string
  14832. */
  14833. getClassName(): string;
  14834. /**
  14835. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14836. */
  14837. get position(): Vector3;
  14838. set position(newPosition: Vector3);
  14839. /**
  14840. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14841. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14842. */
  14843. get rotation(): Vector3;
  14844. set rotation(newRotation: Vector3);
  14845. /**
  14846. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14847. */
  14848. get scaling(): Vector3;
  14849. set scaling(newScaling: Vector3);
  14850. /**
  14851. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14852. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14853. */
  14854. get rotationQuaternion(): Nullable<Quaternion>;
  14855. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14856. /**
  14857. * The forward direction of that transform in world space.
  14858. */
  14859. get forward(): Vector3;
  14860. /**
  14861. * The up direction of that transform in world space.
  14862. */
  14863. get up(): Vector3;
  14864. /**
  14865. * The right direction of that transform in world space.
  14866. */
  14867. get right(): Vector3;
  14868. /**
  14869. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14870. * @param matrix the matrix to copy the pose from
  14871. * @returns this TransformNode.
  14872. */
  14873. updatePoseMatrix(matrix: Matrix): TransformNode;
  14874. /**
  14875. * Returns the mesh Pose matrix.
  14876. * @returns the pose matrix
  14877. */
  14878. getPoseMatrix(): Matrix;
  14879. /** @hidden */
  14880. _isSynchronized(): boolean;
  14881. /** @hidden */
  14882. _initCache(): void;
  14883. /**
  14884. * Flag the transform node as dirty (Forcing it to update everything)
  14885. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14886. * @returns this transform node
  14887. */
  14888. markAsDirty(property: string): TransformNode;
  14889. /**
  14890. * Returns the current mesh absolute position.
  14891. * Returns a Vector3.
  14892. */
  14893. get absolutePosition(): Vector3;
  14894. /**
  14895. * Returns the current mesh absolute scaling.
  14896. * Returns a Vector3.
  14897. */
  14898. get absoluteScaling(): Vector3;
  14899. /**
  14900. * Returns the current mesh absolute rotation.
  14901. * Returns a Quaternion.
  14902. */
  14903. get absoluteRotationQuaternion(): Quaternion;
  14904. /**
  14905. * Sets a new matrix to apply before all other transformation
  14906. * @param matrix defines the transform matrix
  14907. * @returns the current TransformNode
  14908. */
  14909. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14910. /**
  14911. * Sets a new pivot matrix to the current node
  14912. * @param matrix defines the new pivot matrix to use
  14913. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14914. * @returns the current TransformNode
  14915. */
  14916. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14917. /**
  14918. * Returns the mesh pivot matrix.
  14919. * Default : Identity.
  14920. * @returns the matrix
  14921. */
  14922. getPivotMatrix(): Matrix;
  14923. /**
  14924. * Instantiate (when possible) or clone that node with its hierarchy
  14925. * @param newParent defines the new parent to use for the instance (or clone)
  14926. * @param options defines options to configure how copy is done
  14927. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14928. * @returns an instance (or a clone) of the current node with its hiearchy
  14929. */
  14930. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14931. doNotInstantiate: boolean;
  14932. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14933. /**
  14934. * Prevents the World matrix to be computed any longer
  14935. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14936. * @returns the TransformNode.
  14937. */
  14938. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14939. /**
  14940. * Allows back the World matrix computation.
  14941. * @returns the TransformNode.
  14942. */
  14943. unfreezeWorldMatrix(): this;
  14944. /**
  14945. * True if the World matrix has been frozen.
  14946. */
  14947. get isWorldMatrixFrozen(): boolean;
  14948. /**
  14949. * Retuns the mesh absolute position in the World.
  14950. * @returns a Vector3.
  14951. */
  14952. getAbsolutePosition(): Vector3;
  14953. /**
  14954. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14955. * @param absolutePosition the absolute position to set
  14956. * @returns the TransformNode.
  14957. */
  14958. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14959. /**
  14960. * Sets the mesh position in its local space.
  14961. * @param vector3 the position to set in localspace
  14962. * @returns the TransformNode.
  14963. */
  14964. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14965. /**
  14966. * Returns the mesh position in the local space from the current World matrix values.
  14967. * @returns a new Vector3.
  14968. */
  14969. getPositionExpressedInLocalSpace(): Vector3;
  14970. /**
  14971. * Translates the mesh along the passed Vector3 in its local space.
  14972. * @param vector3 the distance to translate in localspace
  14973. * @returns the TransformNode.
  14974. */
  14975. locallyTranslate(vector3: Vector3): TransformNode;
  14976. private static _lookAtVectorCache;
  14977. /**
  14978. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14979. * @param targetPoint the position (must be in same space as current mesh) to look at
  14980. * @param yawCor optional yaw (y-axis) correction in radians
  14981. * @param pitchCor optional pitch (x-axis) correction in radians
  14982. * @param rollCor optional roll (z-axis) correction in radians
  14983. * @param space the choosen space of the target
  14984. * @returns the TransformNode.
  14985. */
  14986. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14987. /**
  14988. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14989. * This Vector3 is expressed in the World space.
  14990. * @param localAxis axis to rotate
  14991. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14992. */
  14993. getDirection(localAxis: Vector3): Vector3;
  14994. /**
  14995. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14996. * localAxis is expressed in the mesh local space.
  14997. * result is computed in the Wordl space from the mesh World matrix.
  14998. * @param localAxis axis to rotate
  14999. * @param result the resulting transformnode
  15000. * @returns this TransformNode.
  15001. */
  15002. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15003. /**
  15004. * Sets this transform node rotation to the given local axis.
  15005. * @param localAxis the axis in local space
  15006. * @param yawCor optional yaw (y-axis) correction in radians
  15007. * @param pitchCor optional pitch (x-axis) correction in radians
  15008. * @param rollCor optional roll (z-axis) correction in radians
  15009. * @returns this TransformNode
  15010. */
  15011. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15012. /**
  15013. * Sets a new pivot point to the current node
  15014. * @param point defines the new pivot point to use
  15015. * @param space defines if the point is in world or local space (local by default)
  15016. * @returns the current TransformNode
  15017. */
  15018. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15019. /**
  15020. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15021. * @returns the pivot point
  15022. */
  15023. getPivotPoint(): Vector3;
  15024. /**
  15025. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15026. * @param result the vector3 to store the result
  15027. * @returns this TransformNode.
  15028. */
  15029. getPivotPointToRef(result: Vector3): TransformNode;
  15030. /**
  15031. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15032. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15033. */
  15034. getAbsolutePivotPoint(): Vector3;
  15035. /**
  15036. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15037. * @param result vector3 to store the result
  15038. * @returns this TransformNode.
  15039. */
  15040. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15041. /**
  15042. * Defines the passed node as the parent of the current node.
  15043. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15044. * @see https://doc.babylonjs.com/how_to/parenting
  15045. * @param node the node ot set as the parent
  15046. * @returns this TransformNode.
  15047. */
  15048. setParent(node: Nullable<Node>): TransformNode;
  15049. private _nonUniformScaling;
  15050. /**
  15051. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15052. */
  15053. get nonUniformScaling(): boolean;
  15054. /** @hidden */
  15055. _updateNonUniformScalingState(value: boolean): boolean;
  15056. /**
  15057. * Attach the current TransformNode to another TransformNode associated with a bone
  15058. * @param bone Bone affecting the TransformNode
  15059. * @param affectedTransformNode TransformNode associated with the bone
  15060. * @returns this object
  15061. */
  15062. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15063. /**
  15064. * Detach the transform node if its associated with a bone
  15065. * @returns this object
  15066. */
  15067. detachFromBone(): TransformNode;
  15068. private static _rotationAxisCache;
  15069. /**
  15070. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15071. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15072. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15073. * The passed axis is also normalized.
  15074. * @param axis the axis to rotate around
  15075. * @param amount the amount to rotate in radians
  15076. * @param space Space to rotate in (Default: local)
  15077. * @returns the TransformNode.
  15078. */
  15079. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15080. /**
  15081. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15082. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15083. * The passed axis is also normalized. .
  15084. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15085. * @param point the point to rotate around
  15086. * @param axis the axis to rotate around
  15087. * @param amount the amount to rotate in radians
  15088. * @returns the TransformNode
  15089. */
  15090. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15091. /**
  15092. * Translates the mesh along the axis vector for the passed distance in the given space.
  15093. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15094. * @param axis the axis to translate in
  15095. * @param distance the distance to translate
  15096. * @param space Space to rotate in (Default: local)
  15097. * @returns the TransformNode.
  15098. */
  15099. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15100. /**
  15101. * Adds a rotation step to the mesh current rotation.
  15102. * x, y, z are Euler angles expressed in radians.
  15103. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15104. * This means this rotation is made in the mesh local space only.
  15105. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15106. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15107. * ```javascript
  15108. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15109. * ```
  15110. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15111. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  15112. * @param x Rotation to add
  15113. * @param y Rotation to add
  15114. * @param z Rotation to add
  15115. * @returns the TransformNode.
  15116. */
  15117. addRotation(x: number, y: number, z: number): TransformNode;
  15118. /**
  15119. * @hidden
  15120. */
  15121. protected _getEffectiveParent(): Nullable<Node>;
  15122. /**
  15123. * Computes the world matrix of the node
  15124. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15125. * @returns the world matrix
  15126. */
  15127. computeWorldMatrix(force?: boolean): Matrix;
  15128. /**
  15129. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15130. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15131. */
  15132. resetLocalMatrix(independentOfChildren?: boolean): void;
  15133. protected _afterComputeWorldMatrix(): void;
  15134. /**
  15135. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15136. * @param func callback function to add
  15137. *
  15138. * @returns the TransformNode.
  15139. */
  15140. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15141. /**
  15142. * Removes a registered callback function.
  15143. * @param func callback function to remove
  15144. * @returns the TransformNode.
  15145. */
  15146. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15147. /**
  15148. * Gets the position of the current mesh in camera space
  15149. * @param camera defines the camera to use
  15150. * @returns a position
  15151. */
  15152. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15153. /**
  15154. * Returns the distance from the mesh to the active camera
  15155. * @param camera defines the camera to use
  15156. * @returns the distance
  15157. */
  15158. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15159. /**
  15160. * Clone the current transform node
  15161. * @param name Name of the new clone
  15162. * @param newParent New parent for the clone
  15163. * @param doNotCloneChildren Do not clone children hierarchy
  15164. * @returns the new transform node
  15165. */
  15166. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15167. /**
  15168. * Serializes the objects information.
  15169. * @param currentSerializationObject defines the object to serialize in
  15170. * @returns the serialized object
  15171. */
  15172. serialize(currentSerializationObject?: any): any;
  15173. /**
  15174. * Returns a new TransformNode object parsed from the source provided.
  15175. * @param parsedTransformNode is the source.
  15176. * @param scene the scne the object belongs to
  15177. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15178. * @returns a new TransformNode object parsed from the source provided.
  15179. */
  15180. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15181. /**
  15182. * Get all child-transformNodes of this node
  15183. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  15184. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  15185. * @returns an array of TransformNode
  15186. */
  15187. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15188. /**
  15189. * Releases resources associated with this transform node.
  15190. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15191. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15192. */
  15193. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15194. /**
  15195. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15196. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15197. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15198. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15199. * @returns the current mesh
  15200. */
  15201. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15202. private _syncAbsoluteScalingAndRotation;
  15203. }
  15204. }
  15205. declare module BABYLON {
  15206. /**
  15207. * Class used to override all child animations of a given target
  15208. */
  15209. export class AnimationPropertiesOverride {
  15210. /**
  15211. * Gets or sets a value indicating if animation blending must be used
  15212. */
  15213. enableBlending: boolean;
  15214. /**
  15215. * Gets or sets the blending speed to use when enableBlending is true
  15216. */
  15217. blendingSpeed: number;
  15218. /**
  15219. * Gets or sets the default loop mode to use
  15220. */
  15221. loopMode: number;
  15222. }
  15223. }
  15224. declare module BABYLON {
  15225. /**
  15226. * Class used to store bone information
  15227. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15228. */
  15229. export class Bone extends Node {
  15230. /**
  15231. * defines the bone name
  15232. */
  15233. name: string;
  15234. private static _tmpVecs;
  15235. private static _tmpQuat;
  15236. private static _tmpMats;
  15237. /**
  15238. * Gets the list of child bones
  15239. */
  15240. children: Bone[];
  15241. /** Gets the animations associated with this bone */
  15242. animations: Animation[];
  15243. /**
  15244. * Gets or sets bone length
  15245. */
  15246. length: number;
  15247. /**
  15248. * @hidden Internal only
  15249. * Set this value to map this bone to a different index in the transform matrices
  15250. * Set this value to -1 to exclude the bone from the transform matrices
  15251. */
  15252. _index: Nullable<number>;
  15253. private _skeleton;
  15254. private _localMatrix;
  15255. private _restPose;
  15256. private _bindPose;
  15257. private _baseMatrix;
  15258. private _absoluteTransform;
  15259. private _invertedAbsoluteTransform;
  15260. private _parent;
  15261. private _scalingDeterminant;
  15262. private _worldTransform;
  15263. private _localScaling;
  15264. private _localRotation;
  15265. private _localPosition;
  15266. private _needToDecompose;
  15267. private _needToCompose;
  15268. /** @hidden */
  15269. _linkedTransformNode: Nullable<TransformNode>;
  15270. /** @hidden */
  15271. _waitingTransformNodeId: Nullable<string>;
  15272. /** @hidden */
  15273. get _matrix(): Matrix;
  15274. /** @hidden */
  15275. set _matrix(value: Matrix);
  15276. /**
  15277. * Create a new bone
  15278. * @param name defines the bone name
  15279. * @param skeleton defines the parent skeleton
  15280. * @param parentBone defines the parent (can be null if the bone is the root)
  15281. * @param localMatrix defines the local matrix
  15282. * @param restPose defines the rest pose matrix
  15283. * @param baseMatrix defines the base matrix
  15284. * @param index defines index of the bone in the hiearchy
  15285. */
  15286. constructor(
  15287. /**
  15288. * defines the bone name
  15289. */
  15290. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15291. /**
  15292. * Gets the current object class name.
  15293. * @return the class name
  15294. */
  15295. getClassName(): string;
  15296. /**
  15297. * Gets the parent skeleton
  15298. * @returns a skeleton
  15299. */
  15300. getSkeleton(): Skeleton;
  15301. /**
  15302. * Gets parent bone
  15303. * @returns a bone or null if the bone is the root of the bone hierarchy
  15304. */
  15305. getParent(): Nullable<Bone>;
  15306. /**
  15307. * Returns an array containing the root bones
  15308. * @returns an array containing the root bones
  15309. */
  15310. getChildren(): Array<Bone>;
  15311. /**
  15312. * Gets the node index in matrix array generated for rendering
  15313. * @returns the node index
  15314. */
  15315. getIndex(): number;
  15316. /**
  15317. * Sets the parent bone
  15318. * @param parent defines the parent (can be null if the bone is the root)
  15319. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15320. */
  15321. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15322. /**
  15323. * Gets the local matrix
  15324. * @returns a matrix
  15325. */
  15326. getLocalMatrix(): Matrix;
  15327. /**
  15328. * Gets the base matrix (initial matrix which remains unchanged)
  15329. * @returns a matrix
  15330. */
  15331. getBaseMatrix(): Matrix;
  15332. /**
  15333. * Gets the rest pose matrix
  15334. * @returns a matrix
  15335. */
  15336. getRestPose(): Matrix;
  15337. /**
  15338. * Sets the rest pose matrix
  15339. * @param matrix the local-space rest pose to set for this bone
  15340. */
  15341. setRestPose(matrix: Matrix): void;
  15342. /**
  15343. * Gets the bind pose matrix
  15344. * @returns the bind pose matrix
  15345. */
  15346. getBindPose(): Matrix;
  15347. /**
  15348. * Sets the bind pose matrix
  15349. * @param matrix the local-space bind pose to set for this bone
  15350. */
  15351. setBindPose(matrix: Matrix): void;
  15352. /**
  15353. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15354. */
  15355. getWorldMatrix(): Matrix;
  15356. /**
  15357. * Sets the local matrix to rest pose matrix
  15358. */
  15359. returnToRest(): void;
  15360. /**
  15361. * Gets the inverse of the absolute transform matrix.
  15362. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15363. * @returns a matrix
  15364. */
  15365. getInvertedAbsoluteTransform(): Matrix;
  15366. /**
  15367. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15368. * @returns a matrix
  15369. */
  15370. getAbsoluteTransform(): Matrix;
  15371. /**
  15372. * Links with the given transform node.
  15373. * The local matrix of this bone is copied from the transform node every frame.
  15374. * @param transformNode defines the transform node to link to
  15375. */
  15376. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15377. /**
  15378. * Gets the node used to drive the bone's transformation
  15379. * @returns a transform node or null
  15380. */
  15381. getTransformNode(): Nullable<TransformNode>;
  15382. /** Gets or sets current position (in local space) */
  15383. get position(): Vector3;
  15384. set position(newPosition: Vector3);
  15385. /** Gets or sets current rotation (in local space) */
  15386. get rotation(): Vector3;
  15387. set rotation(newRotation: Vector3);
  15388. /** Gets or sets current rotation quaternion (in local space) */
  15389. get rotationQuaternion(): Quaternion;
  15390. set rotationQuaternion(newRotation: Quaternion);
  15391. /** Gets or sets current scaling (in local space) */
  15392. get scaling(): Vector3;
  15393. set scaling(newScaling: Vector3);
  15394. /**
  15395. * Gets the animation properties override
  15396. */
  15397. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15398. private _decompose;
  15399. private _compose;
  15400. /**
  15401. * Update the base and local matrices
  15402. * @param matrix defines the new base or local matrix
  15403. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15404. * @param updateLocalMatrix defines if the local matrix should be updated
  15405. */
  15406. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15407. /** @hidden */
  15408. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15409. /**
  15410. * Flag the bone as dirty (Forcing it to update everything)
  15411. */
  15412. markAsDirty(): void;
  15413. /** @hidden */
  15414. _markAsDirtyAndCompose(): void;
  15415. private _markAsDirtyAndDecompose;
  15416. /**
  15417. * Translate the bone in local or world space
  15418. * @param vec The amount to translate the bone
  15419. * @param space The space that the translation is in
  15420. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15421. */
  15422. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15423. /**
  15424. * Set the postion of the bone in local or world space
  15425. * @param position The position to set the bone
  15426. * @param space The space that the position is in
  15427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15428. */
  15429. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15430. /**
  15431. * Set the absolute position of the bone (world space)
  15432. * @param position The position to set the bone
  15433. * @param mesh The mesh that this bone is attached to
  15434. */
  15435. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15436. /**
  15437. * Scale the bone on the x, y and z axes (in local space)
  15438. * @param x The amount to scale the bone on the x axis
  15439. * @param y The amount to scale the bone on the y axis
  15440. * @param z The amount to scale the bone on the z axis
  15441. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15442. */
  15443. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15444. /**
  15445. * Set the bone scaling in local space
  15446. * @param scale defines the scaling vector
  15447. */
  15448. setScale(scale: Vector3): void;
  15449. /**
  15450. * Gets the current scaling in local space
  15451. * @returns the current scaling vector
  15452. */
  15453. getScale(): Vector3;
  15454. /**
  15455. * Gets the current scaling in local space and stores it in a target vector
  15456. * @param result defines the target vector
  15457. */
  15458. getScaleToRef(result: Vector3): void;
  15459. /**
  15460. * Set the yaw, pitch, and roll of the bone in local or world space
  15461. * @param yaw The rotation of the bone on the y axis
  15462. * @param pitch The rotation of the bone on the x axis
  15463. * @param roll The rotation of the bone on the z axis
  15464. * @param space The space that the axes of rotation are in
  15465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15466. */
  15467. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15468. /**
  15469. * Add a rotation to the bone on an axis in local or world space
  15470. * @param axis The axis to rotate the bone on
  15471. * @param amount The amount to rotate the bone
  15472. * @param space The space that the axis is in
  15473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15474. */
  15475. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15476. /**
  15477. * Set the rotation of the bone to a particular axis angle in local or world space
  15478. * @param axis The axis to rotate the bone on
  15479. * @param angle The angle that the bone should be rotated to
  15480. * @param space The space that the axis is in
  15481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15482. */
  15483. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15484. /**
  15485. * Set the euler rotation of the bone in local or world space
  15486. * @param rotation The euler rotation that the bone should be set to
  15487. * @param space The space that the rotation is in
  15488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15489. */
  15490. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15491. /**
  15492. * Set the quaternion rotation of the bone in local or world space
  15493. * @param quat The quaternion rotation that the bone should be set to
  15494. * @param space The space that the rotation is in
  15495. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15496. */
  15497. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15498. /**
  15499. * Set the rotation matrix of the bone in local or world space
  15500. * @param rotMat The rotation matrix that the bone should be set to
  15501. * @param space The space that the rotation is in
  15502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15503. */
  15504. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15505. private _rotateWithMatrix;
  15506. private _getNegativeRotationToRef;
  15507. /**
  15508. * Get the position of the bone in local or world space
  15509. * @param space The space that the returned position is in
  15510. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15511. * @returns The position of the bone
  15512. */
  15513. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15514. /**
  15515. * Copy the position of the bone to a vector3 in local or world space
  15516. * @param space The space that the returned position is in
  15517. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15518. * @param result The vector3 to copy the position to
  15519. */
  15520. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15521. /**
  15522. * Get the absolute position of the bone (world space)
  15523. * @param mesh The mesh that this bone is attached to
  15524. * @returns The absolute position of the bone
  15525. */
  15526. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15527. /**
  15528. * Copy the absolute position of the bone (world space) to the result param
  15529. * @param mesh The mesh that this bone is attached to
  15530. * @param result The vector3 to copy the absolute position to
  15531. */
  15532. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15533. /**
  15534. * Compute the absolute transforms of this bone and its children
  15535. */
  15536. computeAbsoluteTransforms(): void;
  15537. /**
  15538. * Get the world direction from an axis that is in the local space of the bone
  15539. * @param localAxis The local direction that is used to compute the world direction
  15540. * @param mesh The mesh that this bone is attached to
  15541. * @returns The world direction
  15542. */
  15543. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15544. /**
  15545. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15546. * @param localAxis The local direction that is used to compute the world direction
  15547. * @param mesh The mesh that this bone is attached to
  15548. * @param result The vector3 that the world direction will be copied to
  15549. */
  15550. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15551. /**
  15552. * Get the euler rotation of the bone in local or world space
  15553. * @param space The space that the rotation should be in
  15554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15555. * @returns The euler rotation
  15556. */
  15557. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15558. /**
  15559. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15560. * @param space The space that the rotation should be in
  15561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15562. * @param result The vector3 that the rotation should be copied to
  15563. */
  15564. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15565. /**
  15566. * Get the quaternion rotation of the bone in either local or world space
  15567. * @param space The space that the rotation should be in
  15568. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15569. * @returns The quaternion rotation
  15570. */
  15571. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15572. /**
  15573. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15574. * @param space The space that the rotation should be in
  15575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15576. * @param result The quaternion that the rotation should be copied to
  15577. */
  15578. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15579. /**
  15580. * Get the rotation matrix of the bone in local or world space
  15581. * @param space The space that the rotation should be in
  15582. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15583. * @returns The rotation matrix
  15584. */
  15585. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15586. /**
  15587. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15588. * @param space The space that the rotation should be in
  15589. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15590. * @param result The quaternion that the rotation should be copied to
  15591. */
  15592. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15593. /**
  15594. * Get the world position of a point that is in the local space of the bone
  15595. * @param position The local position
  15596. * @param mesh The mesh that this bone is attached to
  15597. * @returns The world position
  15598. */
  15599. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15600. /**
  15601. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15602. * @param position The local position
  15603. * @param mesh The mesh that this bone is attached to
  15604. * @param result The vector3 that the world position should be copied to
  15605. */
  15606. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15607. /**
  15608. * Get the local position of a point that is in world space
  15609. * @param position The world position
  15610. * @param mesh The mesh that this bone is attached to
  15611. * @returns The local position
  15612. */
  15613. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15614. /**
  15615. * Get the local position of a point that is in world space and copy it to the result param
  15616. * @param position The world position
  15617. * @param mesh The mesh that this bone is attached to
  15618. * @param result The vector3 that the local position should be copied to
  15619. */
  15620. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15621. /**
  15622. * Set the current local matrix as the restPose for this bone.
  15623. */
  15624. setCurrentPoseAsRest(): void;
  15625. }
  15626. }
  15627. declare module BABYLON {
  15628. /**
  15629. * Defines a runtime animation
  15630. */
  15631. export class RuntimeAnimation {
  15632. private _events;
  15633. /**
  15634. * The current frame of the runtime animation
  15635. */
  15636. private _currentFrame;
  15637. /**
  15638. * The animation used by the runtime animation
  15639. */
  15640. private _animation;
  15641. /**
  15642. * The target of the runtime animation
  15643. */
  15644. private _target;
  15645. /**
  15646. * The initiating animatable
  15647. */
  15648. private _host;
  15649. /**
  15650. * The original value of the runtime animation
  15651. */
  15652. private _originalValue;
  15653. /**
  15654. * The original blend value of the runtime animation
  15655. */
  15656. private _originalBlendValue;
  15657. /**
  15658. * The offsets cache of the runtime animation
  15659. */
  15660. private _offsetsCache;
  15661. /**
  15662. * The high limits cache of the runtime animation
  15663. */
  15664. private _highLimitsCache;
  15665. /**
  15666. * Specifies if the runtime animation has been stopped
  15667. */
  15668. private _stopped;
  15669. /**
  15670. * The blending factor of the runtime animation
  15671. */
  15672. private _blendingFactor;
  15673. /**
  15674. * The BabylonJS scene
  15675. */
  15676. private _scene;
  15677. /**
  15678. * The current value of the runtime animation
  15679. */
  15680. private _currentValue;
  15681. /** @hidden */
  15682. _animationState: _IAnimationState;
  15683. /**
  15684. * The active target of the runtime animation
  15685. */
  15686. private _activeTargets;
  15687. private _currentActiveTarget;
  15688. private _directTarget;
  15689. /**
  15690. * The target path of the runtime animation
  15691. */
  15692. private _targetPath;
  15693. /**
  15694. * The weight of the runtime animation
  15695. */
  15696. private _weight;
  15697. /**
  15698. * The ratio offset of the runtime animation
  15699. */
  15700. private _ratioOffset;
  15701. /**
  15702. * The previous delay of the runtime animation
  15703. */
  15704. private _previousDelay;
  15705. /**
  15706. * The previous ratio of the runtime animation
  15707. */
  15708. private _previousRatio;
  15709. private _enableBlending;
  15710. private _keys;
  15711. private _minFrame;
  15712. private _maxFrame;
  15713. private _minValue;
  15714. private _maxValue;
  15715. private _targetIsArray;
  15716. /**
  15717. * Gets the current frame of the runtime animation
  15718. */
  15719. get currentFrame(): number;
  15720. /**
  15721. * Gets the weight of the runtime animation
  15722. */
  15723. get weight(): number;
  15724. /**
  15725. * Gets the current value of the runtime animation
  15726. */
  15727. get currentValue(): any;
  15728. /**
  15729. * Gets the target path of the runtime animation
  15730. */
  15731. get targetPath(): string;
  15732. /**
  15733. * Gets the actual target of the runtime animation
  15734. */
  15735. get target(): any;
  15736. /**
  15737. * Gets the additive state of the runtime animation
  15738. */
  15739. get isAdditive(): boolean;
  15740. /** @hidden */
  15741. _onLoop: () => void;
  15742. /**
  15743. * Create a new RuntimeAnimation object
  15744. * @param target defines the target of the animation
  15745. * @param animation defines the source animation object
  15746. * @param scene defines the hosting scene
  15747. * @param host defines the initiating Animatable
  15748. */
  15749. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15750. private _preparePath;
  15751. /**
  15752. * Gets the animation from the runtime animation
  15753. */
  15754. get animation(): Animation;
  15755. /**
  15756. * Resets the runtime animation to the beginning
  15757. * @param restoreOriginal defines whether to restore the target property to the original value
  15758. */
  15759. reset(restoreOriginal?: boolean): void;
  15760. /**
  15761. * Specifies if the runtime animation is stopped
  15762. * @returns Boolean specifying if the runtime animation is stopped
  15763. */
  15764. isStopped(): boolean;
  15765. /**
  15766. * Disposes of the runtime animation
  15767. */
  15768. dispose(): void;
  15769. /**
  15770. * Apply the interpolated value to the target
  15771. * @param currentValue defines the value computed by the animation
  15772. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15773. */
  15774. setValue(currentValue: any, weight: number): void;
  15775. private _getOriginalValues;
  15776. private _setValue;
  15777. /**
  15778. * Gets the loop pmode of the runtime animation
  15779. * @returns Loop Mode
  15780. */
  15781. private _getCorrectLoopMode;
  15782. /**
  15783. * Move the current animation to a given frame
  15784. * @param frame defines the frame to move to
  15785. */
  15786. goToFrame(frame: number): void;
  15787. /**
  15788. * @hidden Internal use only
  15789. */
  15790. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15791. /**
  15792. * Execute the current animation
  15793. * @param delay defines the delay to add to the current frame
  15794. * @param from defines the lower bound of the animation range
  15795. * @param to defines the upper bound of the animation range
  15796. * @param loop defines if the current animation must loop
  15797. * @param speedRatio defines the current speed ratio
  15798. * @param weight defines the weight of the animation (default is -1 so no weight)
  15799. * @param onLoop optional callback called when animation loops
  15800. * @returns a boolean indicating if the animation is running
  15801. */
  15802. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15803. }
  15804. }
  15805. declare module BABYLON {
  15806. /**
  15807. * Class used to store an actual running animation
  15808. */
  15809. export class Animatable {
  15810. /** defines the target object */
  15811. target: any;
  15812. /** defines the starting frame number (default is 0) */
  15813. fromFrame: number;
  15814. /** defines the ending frame number (default is 100) */
  15815. toFrame: number;
  15816. /** defines if the animation must loop (default is false) */
  15817. loopAnimation: boolean;
  15818. /** defines a callback to call when animation ends if it is not looping */
  15819. onAnimationEnd?: (() => void) | null | undefined;
  15820. /** defines a callback to call when animation loops */
  15821. onAnimationLoop?: (() => void) | null | undefined;
  15822. /** defines whether the animation should be evaluated additively */
  15823. isAdditive: boolean;
  15824. private _localDelayOffset;
  15825. private _pausedDelay;
  15826. private _runtimeAnimations;
  15827. private _paused;
  15828. private _scene;
  15829. private _speedRatio;
  15830. private _weight;
  15831. private _syncRoot;
  15832. /**
  15833. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15834. * This will only apply for non looping animation (default is true)
  15835. */
  15836. disposeOnEnd: boolean;
  15837. /**
  15838. * Gets a boolean indicating if the animation has started
  15839. */
  15840. animationStarted: boolean;
  15841. /**
  15842. * Observer raised when the animation ends
  15843. */
  15844. onAnimationEndObservable: Observable<Animatable>;
  15845. /**
  15846. * Observer raised when the animation loops
  15847. */
  15848. onAnimationLoopObservable: Observable<Animatable>;
  15849. /**
  15850. * Gets the root Animatable used to synchronize and normalize animations
  15851. */
  15852. get syncRoot(): Nullable<Animatable>;
  15853. /**
  15854. * Gets the current frame of the first RuntimeAnimation
  15855. * Used to synchronize Animatables
  15856. */
  15857. get masterFrame(): number;
  15858. /**
  15859. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15860. */
  15861. get weight(): number;
  15862. set weight(value: number);
  15863. /**
  15864. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15865. */
  15866. get speedRatio(): number;
  15867. set speedRatio(value: number);
  15868. /**
  15869. * Creates a new Animatable
  15870. * @param scene defines the hosting scene
  15871. * @param target defines the target object
  15872. * @param fromFrame defines the starting frame number (default is 0)
  15873. * @param toFrame defines the ending frame number (default is 100)
  15874. * @param loopAnimation defines if the animation must loop (default is false)
  15875. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15876. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15877. * @param animations defines a group of animation to add to the new Animatable
  15878. * @param onAnimationLoop defines a callback to call when animation loops
  15879. * @param isAdditive defines whether the animation should be evaluated additively
  15880. */
  15881. constructor(scene: Scene,
  15882. /** defines the target object */
  15883. target: any,
  15884. /** defines the starting frame number (default is 0) */
  15885. fromFrame?: number,
  15886. /** defines the ending frame number (default is 100) */
  15887. toFrame?: number,
  15888. /** defines if the animation must loop (default is false) */
  15889. loopAnimation?: boolean, speedRatio?: number,
  15890. /** defines a callback to call when animation ends if it is not looping */
  15891. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15892. /** defines a callback to call when animation loops */
  15893. onAnimationLoop?: (() => void) | null | undefined,
  15894. /** defines whether the animation should be evaluated additively */
  15895. isAdditive?: boolean);
  15896. /**
  15897. * Synchronize and normalize current Animatable with a source Animatable
  15898. * This is useful when using animation weights and when animations are not of the same length
  15899. * @param root defines the root Animatable to synchronize with
  15900. * @returns the current Animatable
  15901. */
  15902. syncWith(root: Animatable): Animatable;
  15903. /**
  15904. * Gets the list of runtime animations
  15905. * @returns an array of RuntimeAnimation
  15906. */
  15907. getAnimations(): RuntimeAnimation[];
  15908. /**
  15909. * Adds more animations to the current animatable
  15910. * @param target defines the target of the animations
  15911. * @param animations defines the new animations to add
  15912. */
  15913. appendAnimations(target: any, animations: Animation[]): void;
  15914. /**
  15915. * Gets the source animation for a specific property
  15916. * @param property defines the propertyu to look for
  15917. * @returns null or the source animation for the given property
  15918. */
  15919. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15920. /**
  15921. * Gets the runtime animation for a specific property
  15922. * @param property defines the propertyu to look for
  15923. * @returns null or the runtime animation for the given property
  15924. */
  15925. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15926. /**
  15927. * Resets the animatable to its original state
  15928. */
  15929. reset(): void;
  15930. /**
  15931. * Allows the animatable to blend with current running animations
  15932. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15933. * @param blendingSpeed defines the blending speed to use
  15934. */
  15935. enableBlending(blendingSpeed: number): void;
  15936. /**
  15937. * Disable animation blending
  15938. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15939. */
  15940. disableBlending(): void;
  15941. /**
  15942. * Jump directly to a given frame
  15943. * @param frame defines the frame to jump to
  15944. */
  15945. goToFrame(frame: number): void;
  15946. /**
  15947. * Pause the animation
  15948. */
  15949. pause(): void;
  15950. /**
  15951. * Restart the animation
  15952. */
  15953. restart(): void;
  15954. private _raiseOnAnimationEnd;
  15955. /**
  15956. * Stop and delete the current animation
  15957. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15958. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  15959. */
  15960. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15961. /**
  15962. * Wait asynchronously for the animation to end
  15963. * @returns a promise which will be fullfilled when the animation ends
  15964. */
  15965. waitAsync(): Promise<Animatable>;
  15966. /** @hidden */
  15967. _animate(delay: number): boolean;
  15968. }
  15969. interface Scene {
  15970. /** @hidden */
  15971. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15972. /** @hidden */
  15973. _processLateAnimationBindingsForMatrices(holder: {
  15974. totalWeight: number;
  15975. totalAdditiveWeight: number;
  15976. animations: RuntimeAnimation[];
  15977. additiveAnimations: RuntimeAnimation[];
  15978. originalValue: Matrix;
  15979. }): any;
  15980. /** @hidden */
  15981. _processLateAnimationBindingsForQuaternions(holder: {
  15982. totalWeight: number;
  15983. totalAdditiveWeight: number;
  15984. animations: RuntimeAnimation[];
  15985. additiveAnimations: RuntimeAnimation[];
  15986. originalValue: Quaternion;
  15987. }, refQuaternion: Quaternion): Quaternion;
  15988. /** @hidden */
  15989. _processLateAnimationBindings(): void;
  15990. /**
  15991. * Will start the animation sequence of a given target
  15992. * @param target defines the target
  15993. * @param from defines from which frame should animation start
  15994. * @param to defines until which frame should animation run.
  15995. * @param weight defines the weight to apply to the animation (1.0 by default)
  15996. * @param loop defines if the animation loops
  15997. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15998. * @param onAnimationEnd defines the function to be executed when the animation ends
  15999. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16000. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16001. * @param onAnimationLoop defines the callback to call when an animation loops
  16002. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16003. * @returns the animatable object created for this animation
  16004. */
  16005. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16006. /**
  16007. * Will start the animation sequence of a given target
  16008. * @param target defines the target
  16009. * @param from defines from which frame should animation start
  16010. * @param to defines until which frame should animation run.
  16011. * @param loop defines if the animation loops
  16012. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16013. * @param onAnimationEnd defines the function to be executed when the animation ends
  16014. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16015. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16016. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16017. * @param onAnimationLoop defines the callback to call when an animation loops
  16018. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16019. * @returns the animatable object created for this animation
  16020. */
  16021. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16022. /**
  16023. * Will start the animation sequence of a given target and its hierarchy
  16024. * @param target defines the target
  16025. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16026. * @param from defines from which frame should animation start
  16027. * @param to defines until which frame should animation run.
  16028. * @param loop defines if the animation loops
  16029. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16030. * @param onAnimationEnd defines the function to be executed when the animation ends
  16031. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16032. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16033. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16034. * @param onAnimationLoop defines the callback to call when an animation loops
  16035. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16036. * @returns the list of created animatables
  16037. */
  16038. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16039. /**
  16040. * Begin a new animation on a given node
  16041. * @param target defines the target where the animation will take place
  16042. * @param animations defines the list of animations to start
  16043. * @param from defines the initial value
  16044. * @param to defines the final value
  16045. * @param loop defines if you want animation to loop (off by default)
  16046. * @param speedRatio defines the speed ratio to apply to all animations
  16047. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16048. * @param onAnimationLoop defines the callback to call when an animation loops
  16049. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16050. * @returns the list of created animatables
  16051. */
  16052. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16053. /**
  16054. * Begin a new animation on a given node and its hierarchy
  16055. * @param target defines the root node where the animation will take place
  16056. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16057. * @param animations defines the list of animations to start
  16058. * @param from defines the initial value
  16059. * @param to defines the final value
  16060. * @param loop defines if you want animation to loop (off by default)
  16061. * @param speedRatio defines the speed ratio to apply to all animations
  16062. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16063. * @param onAnimationLoop defines the callback to call when an animation loops
  16064. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16065. * @returns the list of animatables created for all nodes
  16066. */
  16067. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16068. /**
  16069. * Gets the animatable associated with a specific target
  16070. * @param target defines the target of the animatable
  16071. * @returns the required animatable if found
  16072. */
  16073. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16074. /**
  16075. * Gets all animatables associated with a given target
  16076. * @param target defines the target to look animatables for
  16077. * @returns an array of Animatables
  16078. */
  16079. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16080. /**
  16081. * Stops and removes all animations that have been applied to the scene
  16082. */
  16083. stopAllAnimations(): void;
  16084. /**
  16085. * Gets the current delta time used by animation engine
  16086. */
  16087. deltaTime: number;
  16088. }
  16089. interface Bone {
  16090. /**
  16091. * Copy an animation range from another bone
  16092. * @param source defines the source bone
  16093. * @param rangeName defines the range name to copy
  16094. * @param frameOffset defines the frame offset
  16095. * @param rescaleAsRequired defines if rescaling must be applied if required
  16096. * @param skelDimensionsRatio defines the scaling ratio
  16097. * @returns true if operation was successful
  16098. */
  16099. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16100. }
  16101. }
  16102. declare module BABYLON {
  16103. /**
  16104. * Class used to handle skinning animations
  16105. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16106. */
  16107. export class Skeleton implements IAnimatable {
  16108. /** defines the skeleton name */
  16109. name: string;
  16110. /** defines the skeleton Id */
  16111. id: string;
  16112. /**
  16113. * Defines the list of child bones
  16114. */
  16115. bones: Bone[];
  16116. /**
  16117. * Defines an estimate of the dimension of the skeleton at rest
  16118. */
  16119. dimensionsAtRest: Vector3;
  16120. /**
  16121. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16122. */
  16123. needInitialSkinMatrix: boolean;
  16124. /**
  16125. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16126. */
  16127. overrideMesh: Nullable<AbstractMesh>;
  16128. /**
  16129. * Gets the list of animations attached to this skeleton
  16130. */
  16131. animations: Array<Animation>;
  16132. private _scene;
  16133. private _isDirty;
  16134. private _transformMatrices;
  16135. private _transformMatrixTexture;
  16136. private _meshesWithPoseMatrix;
  16137. private _animatables;
  16138. private _identity;
  16139. private _synchronizedWithMesh;
  16140. private _ranges;
  16141. private _lastAbsoluteTransformsUpdateId;
  16142. private _canUseTextureForBones;
  16143. private _uniqueId;
  16144. /** @hidden */
  16145. _numBonesWithLinkedTransformNode: number;
  16146. /** @hidden */
  16147. _hasWaitingData: Nullable<boolean>;
  16148. /** @hidden */
  16149. _waitingOverrideMeshId: Nullable<string>;
  16150. /**
  16151. * Specifies if the skeleton should be serialized
  16152. */
  16153. doNotSerialize: boolean;
  16154. private _useTextureToStoreBoneMatrices;
  16155. /**
  16156. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16157. * Please note that this option is not available if the hardware does not support it
  16158. */
  16159. get useTextureToStoreBoneMatrices(): boolean;
  16160. set useTextureToStoreBoneMatrices(value: boolean);
  16161. private _animationPropertiesOverride;
  16162. /**
  16163. * Gets or sets the animation properties override
  16164. */
  16165. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16166. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16167. /**
  16168. * List of inspectable custom properties (used by the Inspector)
  16169. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16170. */
  16171. inspectableCustomProperties: IInspectable[];
  16172. /**
  16173. * An observable triggered before computing the skeleton's matrices
  16174. */
  16175. onBeforeComputeObservable: Observable<Skeleton>;
  16176. /**
  16177. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16178. */
  16179. get isUsingTextureForMatrices(): boolean;
  16180. /**
  16181. * Gets the unique ID of this skeleton
  16182. */
  16183. get uniqueId(): number;
  16184. /**
  16185. * Creates a new skeleton
  16186. * @param name defines the skeleton name
  16187. * @param id defines the skeleton Id
  16188. * @param scene defines the hosting scene
  16189. */
  16190. constructor(
  16191. /** defines the skeleton name */
  16192. name: string,
  16193. /** defines the skeleton Id */
  16194. id: string, scene: Scene);
  16195. /**
  16196. * Gets the current object class name.
  16197. * @return the class name
  16198. */
  16199. getClassName(): string;
  16200. /**
  16201. * Returns an array containing the root bones
  16202. * @returns an array containing the root bones
  16203. */
  16204. getChildren(): Array<Bone>;
  16205. /**
  16206. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16207. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16208. * @returns a Float32Array containing matrices data
  16209. */
  16210. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16211. /**
  16212. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16213. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16214. * @returns a raw texture containing the data
  16215. */
  16216. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16217. /**
  16218. * Gets the current hosting scene
  16219. * @returns a scene object
  16220. */
  16221. getScene(): Scene;
  16222. /**
  16223. * Gets a string representing the current skeleton data
  16224. * @param fullDetails defines a boolean indicating if we want a verbose version
  16225. * @returns a string representing the current skeleton data
  16226. */
  16227. toString(fullDetails?: boolean): string;
  16228. /**
  16229. * Get bone's index searching by name
  16230. * @param name defines bone's name to search for
  16231. * @return the indice of the bone. Returns -1 if not found
  16232. */
  16233. getBoneIndexByName(name: string): number;
  16234. /**
  16235. * Creater a new animation range
  16236. * @param name defines the name of the range
  16237. * @param from defines the start key
  16238. * @param to defines the end key
  16239. */
  16240. createAnimationRange(name: string, from: number, to: number): void;
  16241. /**
  16242. * Delete a specific animation range
  16243. * @param name defines the name of the range
  16244. * @param deleteFrames defines if frames must be removed as well
  16245. */
  16246. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16247. /**
  16248. * Gets a specific animation range
  16249. * @param name defines the name of the range to look for
  16250. * @returns the requested animation range or null if not found
  16251. */
  16252. getAnimationRange(name: string): Nullable<AnimationRange>;
  16253. /**
  16254. * Gets the list of all animation ranges defined on this skeleton
  16255. * @returns an array
  16256. */
  16257. getAnimationRanges(): Nullable<AnimationRange>[];
  16258. /**
  16259. * Copy animation range from a source skeleton.
  16260. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16261. * @param source defines the source skeleton
  16262. * @param name defines the name of the range to copy
  16263. * @param rescaleAsRequired defines if rescaling must be applied if required
  16264. * @returns true if operation was successful
  16265. */
  16266. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16267. /**
  16268. * Forces the skeleton to go to rest pose
  16269. */
  16270. returnToRest(): void;
  16271. private _getHighestAnimationFrame;
  16272. /**
  16273. * Begin a specific animation range
  16274. * @param name defines the name of the range to start
  16275. * @param loop defines if looping must be turned on (false by default)
  16276. * @param speedRatio defines the speed ratio to apply (1 by default)
  16277. * @param onAnimationEnd defines a callback which will be called when animation will end
  16278. * @returns a new animatable
  16279. */
  16280. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16281. /**
  16282. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16283. * @param skeleton defines the Skeleton containing the animation range to convert
  16284. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16285. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16286. * @returns the original skeleton
  16287. */
  16288. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16289. /** @hidden */
  16290. _markAsDirty(): void;
  16291. /** @hidden */
  16292. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16293. /** @hidden */
  16294. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16295. private _computeTransformMatrices;
  16296. /**
  16297. * Build all resources required to render a skeleton
  16298. */
  16299. prepare(): void;
  16300. /**
  16301. * Gets the list of animatables currently running for this skeleton
  16302. * @returns an array of animatables
  16303. */
  16304. getAnimatables(): IAnimatable[];
  16305. /**
  16306. * Clone the current skeleton
  16307. * @param name defines the name of the new skeleton
  16308. * @param id defines the id of the new skeleton
  16309. * @returns the new skeleton
  16310. */
  16311. clone(name: string, id?: string): Skeleton;
  16312. /**
  16313. * Enable animation blending for this skeleton
  16314. * @param blendingSpeed defines the blending speed to apply
  16315. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16316. */
  16317. enableBlending(blendingSpeed?: number): void;
  16318. /**
  16319. * Releases all resources associated with the current skeleton
  16320. */
  16321. dispose(): void;
  16322. /**
  16323. * Serialize the skeleton in a JSON object
  16324. * @returns a JSON object
  16325. */
  16326. serialize(): any;
  16327. /**
  16328. * Creates a new skeleton from serialized data
  16329. * @param parsedSkeleton defines the serialized data
  16330. * @param scene defines the hosting scene
  16331. * @returns a new skeleton
  16332. */
  16333. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16334. /**
  16335. * Compute all node absolute transforms
  16336. * @param forceUpdate defines if computation must be done even if cache is up to date
  16337. */
  16338. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16339. /**
  16340. * Gets the root pose matrix
  16341. * @returns a matrix
  16342. */
  16343. getPoseMatrix(): Nullable<Matrix>;
  16344. /**
  16345. * Sorts bones per internal index
  16346. */
  16347. sortBones(): void;
  16348. private _sortBones;
  16349. /**
  16350. * Set the current local matrix as the restPose for all bones in the skeleton.
  16351. */
  16352. setCurrentPoseAsRest(): void;
  16353. }
  16354. }
  16355. declare module BABYLON {
  16356. /**
  16357. * Creates an instance based on a source mesh.
  16358. */
  16359. export class InstancedMesh extends AbstractMesh {
  16360. private _sourceMesh;
  16361. private _currentLOD;
  16362. /** @hidden */
  16363. _indexInSourceMeshInstanceArray: number;
  16364. constructor(name: string, source: Mesh);
  16365. /**
  16366. * Returns the string "InstancedMesh".
  16367. */
  16368. getClassName(): string;
  16369. /** Gets the list of lights affecting that mesh */
  16370. get lightSources(): Light[];
  16371. _resyncLightSources(): void;
  16372. _resyncLightSource(light: Light): void;
  16373. _removeLightSource(light: Light, dispose: boolean): void;
  16374. /**
  16375. * If the source mesh receives shadows
  16376. */
  16377. get receiveShadows(): boolean;
  16378. /**
  16379. * The material of the source mesh
  16380. */
  16381. get material(): Nullable<Material>;
  16382. /**
  16383. * Visibility of the source mesh
  16384. */
  16385. get visibility(): number;
  16386. /**
  16387. * Skeleton of the source mesh
  16388. */
  16389. get skeleton(): Nullable<Skeleton>;
  16390. /**
  16391. * Rendering ground id of the source mesh
  16392. */
  16393. get renderingGroupId(): number;
  16394. set renderingGroupId(value: number);
  16395. /**
  16396. * Returns the total number of vertices (integer).
  16397. */
  16398. getTotalVertices(): number;
  16399. /**
  16400. * Returns a positive integer : the total number of indices in this mesh geometry.
  16401. * @returns the numner of indices or zero if the mesh has no geometry.
  16402. */
  16403. getTotalIndices(): number;
  16404. /**
  16405. * The source mesh of the instance
  16406. */
  16407. get sourceMesh(): Mesh;
  16408. /**
  16409. * Creates a new InstancedMesh object from the mesh model.
  16410. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16411. * @param name defines the name of the new instance
  16412. * @returns a new InstancedMesh
  16413. */
  16414. createInstance(name: string): InstancedMesh;
  16415. /**
  16416. * Is this node ready to be used/rendered
  16417. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16418. * @return {boolean} is it ready
  16419. */
  16420. isReady(completeCheck?: boolean): boolean;
  16421. /**
  16422. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16423. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16424. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  16425. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16426. */
  16427. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16428. /**
  16429. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16430. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16431. * The `data` are either a numeric array either a Float32Array.
  16432. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16433. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  16434. * Note that a new underlying VertexBuffer object is created each call.
  16435. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16436. *
  16437. * Possible `kind` values :
  16438. * - VertexBuffer.PositionKind
  16439. * - VertexBuffer.UVKind
  16440. * - VertexBuffer.UV2Kind
  16441. * - VertexBuffer.UV3Kind
  16442. * - VertexBuffer.UV4Kind
  16443. * - VertexBuffer.UV5Kind
  16444. * - VertexBuffer.UV6Kind
  16445. * - VertexBuffer.ColorKind
  16446. * - VertexBuffer.MatricesIndicesKind
  16447. * - VertexBuffer.MatricesIndicesExtraKind
  16448. * - VertexBuffer.MatricesWeightsKind
  16449. * - VertexBuffer.MatricesWeightsExtraKind
  16450. *
  16451. * Returns the Mesh.
  16452. */
  16453. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16454. /**
  16455. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16456. * If the mesh has no geometry, it is simply returned as it is.
  16457. * The `data` are either a numeric array either a Float32Array.
  16458. * No new underlying VertexBuffer object is created.
  16459. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16460. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16461. *
  16462. * Possible `kind` values :
  16463. * - VertexBuffer.PositionKind
  16464. * - VertexBuffer.UVKind
  16465. * - VertexBuffer.UV2Kind
  16466. * - VertexBuffer.UV3Kind
  16467. * - VertexBuffer.UV4Kind
  16468. * - VertexBuffer.UV5Kind
  16469. * - VertexBuffer.UV6Kind
  16470. * - VertexBuffer.ColorKind
  16471. * - VertexBuffer.MatricesIndicesKind
  16472. * - VertexBuffer.MatricesIndicesExtraKind
  16473. * - VertexBuffer.MatricesWeightsKind
  16474. * - VertexBuffer.MatricesWeightsExtraKind
  16475. *
  16476. * Returns the Mesh.
  16477. */
  16478. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16479. /**
  16480. * Sets the mesh indices.
  16481. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16482. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16483. * This method creates a new index buffer each call.
  16484. * Returns the Mesh.
  16485. */
  16486. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16487. /**
  16488. * Boolean : True if the mesh owns the requested kind of data.
  16489. */
  16490. isVerticesDataPresent(kind: string): boolean;
  16491. /**
  16492. * Returns an array of indices (IndicesArray).
  16493. */
  16494. getIndices(): Nullable<IndicesArray>;
  16495. get _positions(): Nullable<Vector3[]>;
  16496. /**
  16497. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16498. * This means the mesh underlying bounding box and sphere are recomputed.
  16499. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16500. * @returns the current mesh
  16501. */
  16502. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16503. /** @hidden */
  16504. _preActivate(): InstancedMesh;
  16505. /** @hidden */
  16506. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16507. /** @hidden */
  16508. _postActivate(): void;
  16509. getWorldMatrix(): Matrix;
  16510. get isAnInstance(): boolean;
  16511. /**
  16512. * Returns the current associated LOD AbstractMesh.
  16513. */
  16514. getLOD(camera: Camera): AbstractMesh;
  16515. /** @hidden */
  16516. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16517. /** @hidden */
  16518. _syncSubMeshes(): InstancedMesh;
  16519. /** @hidden */
  16520. _generatePointsArray(): boolean;
  16521. /** @hidden */
  16522. _updateBoundingInfo(): AbstractMesh;
  16523. /**
  16524. * Creates a new InstancedMesh from the current mesh.
  16525. * - name (string) : the cloned mesh name
  16526. * - newParent (optional Node) : the optional Node to parent the clone to.
  16527. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16528. *
  16529. * Returns the clone.
  16530. */
  16531. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16532. /**
  16533. * Disposes the InstancedMesh.
  16534. * Returns nothing.
  16535. */
  16536. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16537. }
  16538. interface Mesh {
  16539. /**
  16540. * Register a custom buffer that will be instanced
  16541. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16542. * @param kind defines the buffer kind
  16543. * @param stride defines the stride in floats
  16544. */
  16545. registerInstancedBuffer(kind: string, stride: number): void;
  16546. /**
  16547. * true to use the edge renderer for all instances of this mesh
  16548. */
  16549. edgesShareWithInstances: boolean;
  16550. /** @hidden */
  16551. _userInstancedBuffersStorage: {
  16552. data: {
  16553. [key: string]: Float32Array;
  16554. };
  16555. sizes: {
  16556. [key: string]: number;
  16557. };
  16558. vertexBuffers: {
  16559. [key: string]: Nullable<VertexBuffer>;
  16560. };
  16561. strides: {
  16562. [key: string]: number;
  16563. };
  16564. };
  16565. }
  16566. interface AbstractMesh {
  16567. /**
  16568. * Object used to store instanced buffers defined by user
  16569. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16570. */
  16571. instancedBuffers: {
  16572. [key: string]: any;
  16573. };
  16574. }
  16575. }
  16576. declare module BABYLON {
  16577. /**
  16578. * Defines the options associated with the creation of a shader material.
  16579. */
  16580. export interface IShaderMaterialOptions {
  16581. /**
  16582. * Does the material work in alpha blend mode
  16583. */
  16584. needAlphaBlending: boolean;
  16585. /**
  16586. * Does the material work in alpha test mode
  16587. */
  16588. needAlphaTesting: boolean;
  16589. /**
  16590. * The list of attribute names used in the shader
  16591. */
  16592. attributes: string[];
  16593. /**
  16594. * The list of unifrom names used in the shader
  16595. */
  16596. uniforms: string[];
  16597. /**
  16598. * The list of UBO names used in the shader
  16599. */
  16600. uniformBuffers: string[];
  16601. /**
  16602. * The list of sampler names used in the shader
  16603. */
  16604. samplers: string[];
  16605. /**
  16606. * The list of defines used in the shader
  16607. */
  16608. defines: string[];
  16609. }
  16610. /**
  16611. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16612. *
  16613. * This returned material effects how the mesh will look based on the code in the shaders.
  16614. *
  16615. * @see https://doc.babylonjs.com/how_to/shader_material
  16616. */
  16617. export class ShaderMaterial extends Material {
  16618. private _shaderPath;
  16619. private _options;
  16620. private _textures;
  16621. private _textureArrays;
  16622. private _floats;
  16623. private _ints;
  16624. private _floatsArrays;
  16625. private _colors3;
  16626. private _colors3Arrays;
  16627. private _colors4;
  16628. private _colors4Arrays;
  16629. private _vectors2;
  16630. private _vectors3;
  16631. private _vectors4;
  16632. private _matrices;
  16633. private _matrixArrays;
  16634. private _matrices3x3;
  16635. private _matrices2x2;
  16636. private _vectors2Arrays;
  16637. private _vectors3Arrays;
  16638. private _vectors4Arrays;
  16639. private _cachedWorldViewMatrix;
  16640. private _cachedWorldViewProjectionMatrix;
  16641. private _renderId;
  16642. private _multiview;
  16643. private _cachedDefines;
  16644. /** Define the Url to load snippets */
  16645. static SnippetUrl: string;
  16646. /** Snippet ID if the material was created from the snippet server */
  16647. snippetId: string;
  16648. /**
  16649. * Instantiate a new shader material.
  16650. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16651. * This returned material effects how the mesh will look based on the code in the shaders.
  16652. * @see https://doc.babylonjs.com/how_to/shader_material
  16653. * @param name Define the name of the material in the scene
  16654. * @param scene Define the scene the material belongs to
  16655. * @param shaderPath Defines the route to the shader code in one of three ways:
  16656. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16657. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16658. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16659. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16660. * @param options Define the options used to create the shader
  16661. */
  16662. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16663. /**
  16664. * Gets the shader path used to define the shader code
  16665. * It can be modified to trigger a new compilation
  16666. */
  16667. get shaderPath(): any;
  16668. /**
  16669. * Sets the shader path used to define the shader code
  16670. * It can be modified to trigger a new compilation
  16671. */
  16672. set shaderPath(shaderPath: any);
  16673. /**
  16674. * Gets the options used to compile the shader.
  16675. * They can be modified to trigger a new compilation
  16676. */
  16677. get options(): IShaderMaterialOptions;
  16678. /**
  16679. * Gets the current class name of the material e.g. "ShaderMaterial"
  16680. * Mainly use in serialization.
  16681. * @returns the class name
  16682. */
  16683. getClassName(): string;
  16684. /**
  16685. * Specifies if the material will require alpha blending
  16686. * @returns a boolean specifying if alpha blending is needed
  16687. */
  16688. needAlphaBlending(): boolean;
  16689. /**
  16690. * Specifies if this material should be rendered in alpha test mode
  16691. * @returns a boolean specifying if an alpha test is needed.
  16692. */
  16693. needAlphaTesting(): boolean;
  16694. private _checkUniform;
  16695. /**
  16696. * Set a texture in the shader.
  16697. * @param name Define the name of the uniform samplers as defined in the shader
  16698. * @param texture Define the texture to bind to this sampler
  16699. * @return the material itself allowing "fluent" like uniform updates
  16700. */
  16701. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16702. /**
  16703. * Set a texture array in the shader.
  16704. * @param name Define the name of the uniform sampler array as defined in the shader
  16705. * @param textures Define the list of textures to bind to this sampler
  16706. * @return the material itself allowing "fluent" like uniform updates
  16707. */
  16708. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16709. /**
  16710. * Set a float in the shader.
  16711. * @param name Define the name of the uniform as defined in the shader
  16712. * @param value Define the value to give to the uniform
  16713. * @return the material itself allowing "fluent" like uniform updates
  16714. */
  16715. setFloat(name: string, value: number): ShaderMaterial;
  16716. /**
  16717. * Set a int in the shader.
  16718. * @param name Define the name of the uniform as defined in the shader
  16719. * @param value Define the value to give to the uniform
  16720. * @return the material itself allowing "fluent" like uniform updates
  16721. */
  16722. setInt(name: string, value: number): ShaderMaterial;
  16723. /**
  16724. * Set an array of floats in the shader.
  16725. * @param name Define the name of the uniform as defined in the shader
  16726. * @param value Define the value to give to the uniform
  16727. * @return the material itself allowing "fluent" like uniform updates
  16728. */
  16729. setFloats(name: string, value: number[]): ShaderMaterial;
  16730. /**
  16731. * Set a vec3 in the shader from a Color3.
  16732. * @param name Define the name of the uniform as defined in the shader
  16733. * @param value Define the value to give to the uniform
  16734. * @return the material itself allowing "fluent" like uniform updates
  16735. */
  16736. setColor3(name: string, value: Color3): ShaderMaterial;
  16737. /**
  16738. * Set a vec3 array in the shader from a Color3 array.
  16739. * @param name Define the name of the uniform as defined in the shader
  16740. * @param value Define the value to give to the uniform
  16741. * @return the material itself allowing "fluent" like uniform updates
  16742. */
  16743. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16744. /**
  16745. * Set a vec4 in the shader from a Color4.
  16746. * @param name Define the name of the uniform as defined in the shader
  16747. * @param value Define the value to give to the uniform
  16748. * @return the material itself allowing "fluent" like uniform updates
  16749. */
  16750. setColor4(name: string, value: Color4): ShaderMaterial;
  16751. /**
  16752. * Set a vec4 array in the shader from a Color4 array.
  16753. * @param name Define the name of the uniform as defined in the shader
  16754. * @param value Define the value to give to the uniform
  16755. * @return the material itself allowing "fluent" like uniform updates
  16756. */
  16757. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16758. /**
  16759. * Set a vec2 in the shader from a Vector2.
  16760. * @param name Define the name of the uniform as defined in the shader
  16761. * @param value Define the value to give to the uniform
  16762. * @return the material itself allowing "fluent" like uniform updates
  16763. */
  16764. setVector2(name: string, value: Vector2): ShaderMaterial;
  16765. /**
  16766. * Set a vec3 in the shader from a Vector3.
  16767. * @param name Define the name of the uniform as defined in the shader
  16768. * @param value Define the value to give to the uniform
  16769. * @return the material itself allowing "fluent" like uniform updates
  16770. */
  16771. setVector3(name: string, value: Vector3): ShaderMaterial;
  16772. /**
  16773. * Set a vec4 in the shader from a Vector4.
  16774. * @param name Define the name of the uniform as defined in the shader
  16775. * @param value Define the value to give to the uniform
  16776. * @return the material itself allowing "fluent" like uniform updates
  16777. */
  16778. setVector4(name: string, value: Vector4): ShaderMaterial;
  16779. /**
  16780. * Set a mat4 in the shader from a Matrix.
  16781. * @param name Define the name of the uniform as defined in the shader
  16782. * @param value Define the value to give to the uniform
  16783. * @return the material itself allowing "fluent" like uniform updates
  16784. */
  16785. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16786. /**
  16787. * Set a float32Array in the shader from a matrix array.
  16788. * @param name Define the name of the uniform as defined in the shader
  16789. * @param value Define the value to give to the uniform
  16790. * @return the material itself allowing "fluent" like uniform updates
  16791. */
  16792. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16793. /**
  16794. * Set a mat3 in the shader from a Float32Array.
  16795. * @param name Define the name of the uniform as defined in the shader
  16796. * @param value Define the value to give to the uniform
  16797. * @return the material itself allowing "fluent" like uniform updates
  16798. */
  16799. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16800. /**
  16801. * Set a mat2 in the shader from a Float32Array.
  16802. * @param name Define the name of the uniform as defined in the shader
  16803. * @param value Define the value to give to the uniform
  16804. * @return the material itself allowing "fluent" like uniform updates
  16805. */
  16806. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16807. /**
  16808. * Set a vec2 array in the shader from a number array.
  16809. * @param name Define the name of the uniform as defined in the shader
  16810. * @param value Define the value to give to the uniform
  16811. * @return the material itself allowing "fluent" like uniform updates
  16812. */
  16813. setArray2(name: string, value: number[]): ShaderMaterial;
  16814. /**
  16815. * Set a vec3 array in the shader from a number array.
  16816. * @param name Define the name of the uniform as defined in the shader
  16817. * @param value Define the value to give to the uniform
  16818. * @return the material itself allowing "fluent" like uniform updates
  16819. */
  16820. setArray3(name: string, value: number[]): ShaderMaterial;
  16821. /**
  16822. * Set a vec4 array in the shader from a number array.
  16823. * @param name Define the name of the uniform as defined in the shader
  16824. * @param value Define the value to give to the uniform
  16825. * @return the material itself allowing "fluent" like uniform updates
  16826. */
  16827. setArray4(name: string, value: number[]): ShaderMaterial;
  16828. private _checkCache;
  16829. /**
  16830. * Specifies that the submesh is ready to be used
  16831. * @param mesh defines the mesh to check
  16832. * @param subMesh defines which submesh to check
  16833. * @param useInstances specifies that instances should be used
  16834. * @returns a boolean indicating that the submesh is ready or not
  16835. */
  16836. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16837. /**
  16838. * Checks if the material is ready to render the requested mesh
  16839. * @param mesh Define the mesh to render
  16840. * @param useInstances Define whether or not the material is used with instances
  16841. * @returns true if ready, otherwise false
  16842. */
  16843. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16844. /**
  16845. * Binds the world matrix to the material
  16846. * @param world defines the world transformation matrix
  16847. * @param effectOverride - If provided, use this effect instead of internal effect
  16848. */
  16849. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16850. /**
  16851. * Binds the submesh to this material by preparing the effect and shader to draw
  16852. * @param world defines the world transformation matrix
  16853. * @param mesh defines the mesh containing the submesh
  16854. * @param subMesh defines the submesh to bind the material to
  16855. */
  16856. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16857. /**
  16858. * Binds the material to the mesh
  16859. * @param world defines the world transformation matrix
  16860. * @param mesh defines the mesh to bind the material to
  16861. * @param effectOverride - If provided, use this effect instead of internal effect
  16862. */
  16863. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16864. protected _afterBind(mesh?: Mesh): void;
  16865. /**
  16866. * Gets the active textures from the material
  16867. * @returns an array of textures
  16868. */
  16869. getActiveTextures(): BaseTexture[];
  16870. /**
  16871. * Specifies if the material uses a texture
  16872. * @param texture defines the texture to check against the material
  16873. * @returns a boolean specifying if the material uses the texture
  16874. */
  16875. hasTexture(texture: BaseTexture): boolean;
  16876. /**
  16877. * Makes a duplicate of the material, and gives it a new name
  16878. * @param name defines the new name for the duplicated material
  16879. * @returns the cloned material
  16880. */
  16881. clone(name: string): ShaderMaterial;
  16882. /**
  16883. * Disposes the material
  16884. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16885. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16886. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16887. */
  16888. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16889. /**
  16890. * Serializes this material in a JSON representation
  16891. * @returns the serialized material object
  16892. */
  16893. serialize(): any;
  16894. /**
  16895. * Creates a shader material from parsed shader material data
  16896. * @param source defines the JSON represnetation of the material
  16897. * @param scene defines the hosting scene
  16898. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16899. * @returns a new material
  16900. */
  16901. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16902. /**
  16903. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16904. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16905. * @param url defines the url to load from
  16906. * @param scene defines the hosting scene
  16907. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16908. * @returns a promise that will resolve to the new ShaderMaterial
  16909. */
  16910. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16911. /**
  16912. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16913. * @param snippetId defines the snippet to load
  16914. * @param scene defines the hosting scene
  16915. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16916. * @returns a promise that will resolve to the new ShaderMaterial
  16917. */
  16918. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16919. }
  16920. }
  16921. declare module BABYLON {
  16922. /** @hidden */
  16923. export var colorPixelShader: {
  16924. name: string;
  16925. shader: string;
  16926. };
  16927. }
  16928. declare module BABYLON {
  16929. /** @hidden */
  16930. export var colorVertexShader: {
  16931. name: string;
  16932. shader: string;
  16933. };
  16934. }
  16935. declare module BABYLON {
  16936. /**
  16937. * Line mesh
  16938. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16939. */
  16940. export class LinesMesh extends Mesh {
  16941. /**
  16942. * If vertex color should be applied to the mesh
  16943. */
  16944. readonly useVertexColor?: boolean | undefined;
  16945. /**
  16946. * If vertex alpha should be applied to the mesh
  16947. */
  16948. readonly useVertexAlpha?: boolean | undefined;
  16949. /**
  16950. * Color of the line (Default: White)
  16951. */
  16952. color: Color3;
  16953. /**
  16954. * Alpha of the line (Default: 1)
  16955. */
  16956. alpha: number;
  16957. /**
  16958. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16959. * This margin is expressed in world space coordinates, so its value may vary.
  16960. * Default value is 0.1
  16961. */
  16962. intersectionThreshold: number;
  16963. private _colorShader;
  16964. private color4;
  16965. /**
  16966. * Creates a new LinesMesh
  16967. * @param name defines the name
  16968. * @param scene defines the hosting scene
  16969. * @param parent defines the parent mesh if any
  16970. * @param source defines the optional source LinesMesh used to clone data from
  16971. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16972. * When false, achieved by calling a clone(), also passing False.
  16973. * This will make creation of children, recursive.
  16974. * @param useVertexColor defines if this LinesMesh supports vertex color
  16975. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16976. */
  16977. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16978. /**
  16979. * If vertex color should be applied to the mesh
  16980. */
  16981. useVertexColor?: boolean | undefined,
  16982. /**
  16983. * If vertex alpha should be applied to the mesh
  16984. */
  16985. useVertexAlpha?: boolean | undefined);
  16986. private _addClipPlaneDefine;
  16987. private _removeClipPlaneDefine;
  16988. isReady(): boolean;
  16989. /**
  16990. * Returns the string "LineMesh"
  16991. */
  16992. getClassName(): string;
  16993. /**
  16994. * @hidden
  16995. */
  16996. get material(): Material;
  16997. /**
  16998. * @hidden
  16999. */
  17000. set material(value: Material);
  17001. /**
  17002. * @hidden
  17003. */
  17004. get checkCollisions(): boolean;
  17005. /** @hidden */
  17006. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17007. /** @hidden */
  17008. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17009. /**
  17010. * Disposes of the line mesh
  17011. * @param doNotRecurse If children should be disposed
  17012. */
  17013. dispose(doNotRecurse?: boolean): void;
  17014. /**
  17015. * Returns a new LineMesh object cloned from the current one.
  17016. */
  17017. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17018. /**
  17019. * Creates a new InstancedLinesMesh object from the mesh model.
  17020. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17021. * @param name defines the name of the new instance
  17022. * @returns a new InstancedLinesMesh
  17023. */
  17024. createInstance(name: string): InstancedLinesMesh;
  17025. }
  17026. /**
  17027. * Creates an instance based on a source LinesMesh
  17028. */
  17029. export class InstancedLinesMesh extends InstancedMesh {
  17030. /**
  17031. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17032. * This margin is expressed in world space coordinates, so its value may vary.
  17033. * Initilized with the intersectionThreshold value of the source LinesMesh
  17034. */
  17035. intersectionThreshold: number;
  17036. constructor(name: string, source: LinesMesh);
  17037. /**
  17038. * Returns the string "InstancedLinesMesh".
  17039. */
  17040. getClassName(): string;
  17041. }
  17042. }
  17043. declare module BABYLON {
  17044. /** @hidden */
  17045. export var linePixelShader: {
  17046. name: string;
  17047. shader: string;
  17048. };
  17049. }
  17050. declare module BABYLON {
  17051. /** @hidden */
  17052. export var lineVertexShader: {
  17053. name: string;
  17054. shader: string;
  17055. };
  17056. }
  17057. declare module BABYLON {
  17058. interface Scene {
  17059. /** @hidden */
  17060. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17061. }
  17062. interface AbstractMesh {
  17063. /**
  17064. * Gets the edgesRenderer associated with the mesh
  17065. */
  17066. edgesRenderer: Nullable<EdgesRenderer>;
  17067. }
  17068. interface LinesMesh {
  17069. /**
  17070. * Enables the edge rendering mode on the mesh.
  17071. * This mode makes the mesh edges visible
  17072. * @param epsilon defines the maximal distance between two angles to detect a face
  17073. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17074. * @returns the currentAbstractMesh
  17075. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17076. */
  17077. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17078. }
  17079. interface InstancedLinesMesh {
  17080. /**
  17081. * Enables the edge rendering mode on the mesh.
  17082. * This mode makes the mesh edges visible
  17083. * @param epsilon defines the maximal distance between two angles to detect a face
  17084. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17085. * @returns the current InstancedLinesMesh
  17086. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17087. */
  17088. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17089. }
  17090. /**
  17091. * Defines the minimum contract an Edges renderer should follow.
  17092. */
  17093. export interface IEdgesRenderer extends IDisposable {
  17094. /**
  17095. * Gets or sets a boolean indicating if the edgesRenderer is active
  17096. */
  17097. isEnabled: boolean;
  17098. /**
  17099. * Renders the edges of the attached mesh,
  17100. */
  17101. render(): void;
  17102. /**
  17103. * Checks wether or not the edges renderer is ready to render.
  17104. * @return true if ready, otherwise false.
  17105. */
  17106. isReady(): boolean;
  17107. /**
  17108. * List of instances to render in case the source mesh has instances
  17109. */
  17110. customInstances: SmartArray<Matrix>;
  17111. }
  17112. /**
  17113. * Defines the additional options of the edges renderer
  17114. */
  17115. export interface IEdgesRendererOptions {
  17116. /**
  17117. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17118. * If not defined, the default value is true
  17119. */
  17120. useAlternateEdgeFinder?: boolean;
  17121. /**
  17122. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17123. * If not defined, the default value is true.
  17124. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  17125. * This option is used only if useAlternateEdgeFinder = true
  17126. */
  17127. useFastVertexMerger?: boolean;
  17128. /**
  17129. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17130. * The default value is 1e-6
  17131. * This option is used only if useAlternateEdgeFinder = true
  17132. */
  17133. epsilonVertexMerge?: number;
  17134. /**
  17135. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  17136. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  17137. * This option is used only if useAlternateEdgeFinder = true
  17138. */
  17139. applyTessellation?: boolean;
  17140. /**
  17141. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  17142. * The default value is 1e-6
  17143. * This option is used only if useAlternateEdgeFinder = true
  17144. */
  17145. epsilonVertexAligned?: number;
  17146. }
  17147. /**
  17148. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17149. */
  17150. export class EdgesRenderer implements IEdgesRenderer {
  17151. /**
  17152. * Define the size of the edges with an orthographic camera
  17153. */
  17154. edgesWidthScalerForOrthographic: number;
  17155. /**
  17156. * Define the size of the edges with a perspective camera
  17157. */
  17158. edgesWidthScalerForPerspective: number;
  17159. protected _source: AbstractMesh;
  17160. protected _linesPositions: number[];
  17161. protected _linesNormals: number[];
  17162. protected _linesIndices: number[];
  17163. protected _epsilon: number;
  17164. protected _indicesCount: number;
  17165. protected _lineShader: ShaderMaterial;
  17166. protected _ib: DataBuffer;
  17167. protected _buffers: {
  17168. [key: string]: Nullable<VertexBuffer>;
  17169. };
  17170. protected _buffersForInstances: {
  17171. [key: string]: Nullable<VertexBuffer>;
  17172. };
  17173. protected _checkVerticesInsteadOfIndices: boolean;
  17174. protected _options: Nullable<IEdgesRendererOptions>;
  17175. private _meshRebuildObserver;
  17176. private _meshDisposeObserver;
  17177. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17178. isEnabled: boolean;
  17179. /**
  17180. * List of instances to render in case the source mesh has instances
  17181. */
  17182. customInstances: SmartArray<Matrix>;
  17183. private static GetShader;
  17184. /**
  17185. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17186. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17187. * @param source Mesh used to create edges
  17188. * @param epsilon sum of angles in adjacency to check for edge
  17189. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17190. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17191. * @param options The options to apply when generating the edges
  17192. */
  17193. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17194. protected _prepareRessources(): void;
  17195. /** @hidden */
  17196. _rebuild(): void;
  17197. /**
  17198. * Releases the required resources for the edges renderer
  17199. */
  17200. dispose(): void;
  17201. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17202. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17203. /**
  17204. * Checks if the pair of p0 and p1 is en edge
  17205. * @param faceIndex
  17206. * @param edge
  17207. * @param faceNormals
  17208. * @param p0
  17209. * @param p1
  17210. * @private
  17211. */
  17212. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17213. /**
  17214. * push line into the position, normal and index buffer
  17215. * @protected
  17216. */
  17217. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17218. /**
  17219. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17220. */
  17221. private _tessellateTriangle;
  17222. private _generateEdgesLinesAlternate;
  17223. /**
  17224. * Generates lines edges from adjacencjes
  17225. * @private
  17226. */
  17227. _generateEdgesLines(): void;
  17228. /**
  17229. * Checks wether or not the edges renderer is ready to render.
  17230. * @return true if ready, otherwise false.
  17231. */
  17232. isReady(): boolean;
  17233. /**
  17234. * Renders the edges of the attached mesh,
  17235. */
  17236. render(): void;
  17237. }
  17238. /**
  17239. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17240. */
  17241. export class LineEdgesRenderer extends EdgesRenderer {
  17242. /**
  17243. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17244. * @param source LineMesh used to generate edges
  17245. * @param epsilon not important (specified angle for edge detection)
  17246. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17247. */
  17248. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17249. /**
  17250. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17251. */
  17252. _generateEdgesLines(): void;
  17253. }
  17254. }
  17255. declare module BABYLON {
  17256. /**
  17257. * This represents the object necessary to create a rendering group.
  17258. * This is exclusively used and created by the rendering manager.
  17259. * To modify the behavior, you use the available helpers in your scene or meshes.
  17260. * @hidden
  17261. */
  17262. export class RenderingGroup {
  17263. index: number;
  17264. private static _zeroVector;
  17265. private _scene;
  17266. private _opaqueSubMeshes;
  17267. private _transparentSubMeshes;
  17268. private _alphaTestSubMeshes;
  17269. private _depthOnlySubMeshes;
  17270. private _particleSystems;
  17271. private _spriteManagers;
  17272. private _opaqueSortCompareFn;
  17273. private _alphaTestSortCompareFn;
  17274. private _transparentSortCompareFn;
  17275. private _renderOpaque;
  17276. private _renderAlphaTest;
  17277. private _renderTransparent;
  17278. /** @hidden */
  17279. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17280. onBeforeTransparentRendering: () => void;
  17281. /**
  17282. * Set the opaque sort comparison function.
  17283. * If null the sub meshes will be render in the order they were created
  17284. */
  17285. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17286. /**
  17287. * Set the alpha test sort comparison function.
  17288. * If null the sub meshes will be render in the order they were created
  17289. */
  17290. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17291. /**
  17292. * Set the transparent sort comparison function.
  17293. * If null the sub meshes will be render in the order they were created
  17294. */
  17295. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17296. /**
  17297. * Creates a new rendering group.
  17298. * @param index The rendering group index
  17299. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17300. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17301. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17302. */
  17303. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17304. /**
  17305. * Render all the sub meshes contained in the group.
  17306. * @param customRenderFunction Used to override the default render behaviour of the group.
  17307. * @returns true if rendered some submeshes.
  17308. */
  17309. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17310. /**
  17311. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17312. * @param subMeshes The submeshes to render
  17313. */
  17314. private renderOpaqueSorted;
  17315. /**
  17316. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17317. * @param subMeshes The submeshes to render
  17318. */
  17319. private renderAlphaTestSorted;
  17320. /**
  17321. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17322. * @param subMeshes The submeshes to render
  17323. */
  17324. private renderTransparentSorted;
  17325. /**
  17326. * Renders the submeshes in a specified order.
  17327. * @param subMeshes The submeshes to sort before render
  17328. * @param sortCompareFn The comparison function use to sort
  17329. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17330. * @param transparent Specifies to activate blending if true
  17331. */
  17332. private static renderSorted;
  17333. /**
  17334. * Renders the submeshes in the order they were dispatched (no sort applied).
  17335. * @param subMeshes The submeshes to render
  17336. */
  17337. private static renderUnsorted;
  17338. /**
  17339. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17340. * are rendered back to front if in the same alpha index.
  17341. *
  17342. * @param a The first submesh
  17343. * @param b The second submesh
  17344. * @returns The result of the comparison
  17345. */
  17346. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17347. /**
  17348. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17349. * are rendered back to front.
  17350. *
  17351. * @param a The first submesh
  17352. * @param b The second submesh
  17353. * @returns The result of the comparison
  17354. */
  17355. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17356. /**
  17357. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17358. * are rendered front to back (prevent overdraw).
  17359. *
  17360. * @param a The first submesh
  17361. * @param b The second submesh
  17362. * @returns The result of the comparison
  17363. */
  17364. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17365. /**
  17366. * Resets the different lists of submeshes to prepare a new frame.
  17367. */
  17368. prepare(): void;
  17369. dispose(): void;
  17370. /**
  17371. * Inserts the submesh in its correct queue depending on its material.
  17372. * @param subMesh The submesh to dispatch
  17373. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17374. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17375. */
  17376. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17377. dispatchSprites(spriteManager: ISpriteManager): void;
  17378. dispatchParticles(particleSystem: IParticleSystem): void;
  17379. private _renderParticles;
  17380. private _renderSprites;
  17381. }
  17382. }
  17383. declare module BABYLON {
  17384. /**
  17385. * Interface describing the different options available in the rendering manager
  17386. * regarding Auto Clear between groups.
  17387. */
  17388. export interface IRenderingManagerAutoClearSetup {
  17389. /**
  17390. * Defines whether or not autoclear is enable.
  17391. */
  17392. autoClear: boolean;
  17393. /**
  17394. * Defines whether or not to autoclear the depth buffer.
  17395. */
  17396. depth: boolean;
  17397. /**
  17398. * Defines whether or not to autoclear the stencil buffer.
  17399. */
  17400. stencil: boolean;
  17401. }
  17402. /**
  17403. * This class is used by the onRenderingGroupObservable
  17404. */
  17405. export class RenderingGroupInfo {
  17406. /**
  17407. * The Scene that being rendered
  17408. */
  17409. scene: Scene;
  17410. /**
  17411. * The camera currently used for the rendering pass
  17412. */
  17413. camera: Nullable<Camera>;
  17414. /**
  17415. * The ID of the renderingGroup being processed
  17416. */
  17417. renderingGroupId: number;
  17418. }
  17419. /**
  17420. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17421. * It is enable to manage the different groups as well as the different necessary sort functions.
  17422. * This should not be used directly aside of the few static configurations
  17423. */
  17424. export class RenderingManager {
  17425. /**
  17426. * The max id used for rendering groups (not included)
  17427. */
  17428. static MAX_RENDERINGGROUPS: number;
  17429. /**
  17430. * The min id used for rendering groups (included)
  17431. */
  17432. static MIN_RENDERINGGROUPS: number;
  17433. /**
  17434. * Used to globally prevent autoclearing scenes.
  17435. */
  17436. static AUTOCLEAR: boolean;
  17437. /**
  17438. * @hidden
  17439. */
  17440. _useSceneAutoClearSetup: boolean;
  17441. private _scene;
  17442. private _renderingGroups;
  17443. private _depthStencilBufferAlreadyCleaned;
  17444. private _autoClearDepthStencil;
  17445. private _customOpaqueSortCompareFn;
  17446. private _customAlphaTestSortCompareFn;
  17447. private _customTransparentSortCompareFn;
  17448. private _renderingGroupInfo;
  17449. /**
  17450. * Instantiates a new rendering group for a particular scene
  17451. * @param scene Defines the scene the groups belongs to
  17452. */
  17453. constructor(scene: Scene);
  17454. private _clearDepthStencilBuffer;
  17455. /**
  17456. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17457. * @hidden
  17458. */
  17459. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17460. /**
  17461. * Resets the different information of the group to prepare a new frame
  17462. * @hidden
  17463. */
  17464. reset(): void;
  17465. /**
  17466. * Dispose and release the group and its associated resources.
  17467. * @hidden
  17468. */
  17469. dispose(): void;
  17470. /**
  17471. * Clear the info related to rendering groups preventing retention points during dispose.
  17472. */
  17473. freeRenderingGroups(): void;
  17474. private _prepareRenderingGroup;
  17475. /**
  17476. * Add a sprite manager to the rendering manager in order to render it this frame.
  17477. * @param spriteManager Define the sprite manager to render
  17478. */
  17479. dispatchSprites(spriteManager: ISpriteManager): void;
  17480. /**
  17481. * Add a particle system to the rendering manager in order to render it this frame.
  17482. * @param particleSystem Define the particle system to render
  17483. */
  17484. dispatchParticles(particleSystem: IParticleSystem): void;
  17485. /**
  17486. * Add a submesh to the manager in order to render it this frame
  17487. * @param subMesh The submesh to dispatch
  17488. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17489. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17490. */
  17491. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17492. /**
  17493. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17494. * This allowed control for front to back rendering or reversly depending of the special needs.
  17495. *
  17496. * @param renderingGroupId The rendering group id corresponding to its index
  17497. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17498. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17499. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17500. */
  17501. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  17502. /**
  17503. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17504. *
  17505. * @param renderingGroupId The rendering group id corresponding to its index
  17506. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17507. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17508. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17509. */
  17510. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17511. /**
  17512. * Gets the current auto clear configuration for one rendering group of the rendering
  17513. * manager.
  17514. * @param index the rendering group index to get the information for
  17515. * @returns The auto clear setup for the requested rendering group
  17516. */
  17517. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17518. }
  17519. }
  17520. declare module BABYLON {
  17521. /**
  17522. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17523. */
  17524. export interface ICustomShaderOptions {
  17525. /**
  17526. * Gets or sets the custom shader name to use
  17527. */
  17528. shaderName: string;
  17529. /**
  17530. * The list of attribute names used in the shader
  17531. */
  17532. attributes?: string[];
  17533. /**
  17534. * The list of unifrom names used in the shader
  17535. */
  17536. uniforms?: string[];
  17537. /**
  17538. * The list of sampler names used in the shader
  17539. */
  17540. samplers?: string[];
  17541. /**
  17542. * The list of defines used in the shader
  17543. */
  17544. defines?: string[];
  17545. }
  17546. /**
  17547. * Interface to implement to create a shadow generator compatible with BJS.
  17548. */
  17549. export interface IShadowGenerator {
  17550. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17551. id: string;
  17552. /**
  17553. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17554. * @returns The render target texture if present otherwise, null
  17555. */
  17556. getShadowMap(): Nullable<RenderTargetTexture>;
  17557. /**
  17558. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17559. * @param subMesh The submesh we want to render in the shadow map
  17560. * @param useInstances Defines wether will draw in the map using instances
  17561. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17562. * @returns true if ready otherwise, false
  17563. */
  17564. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17565. /**
  17566. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17567. * @param defines Defines of the material we want to update
  17568. * @param lightIndex Index of the light in the enabled light list of the material
  17569. */
  17570. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17571. /**
  17572. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17573. * defined in the generator but impacting the effect).
  17574. * It implies the unifroms available on the materials are the standard BJS ones.
  17575. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17576. * @param effect The effect we are binfing the information for
  17577. */
  17578. bindShadowLight(lightIndex: string, effect: Effect): void;
  17579. /**
  17580. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17581. * (eq to shadow prjection matrix * light transform matrix)
  17582. * @returns The transform matrix used to create the shadow map
  17583. */
  17584. getTransformMatrix(): Matrix;
  17585. /**
  17586. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17587. * Cube and 2D textures for instance.
  17588. */
  17589. recreateShadowMap(): void;
  17590. /**
  17591. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17592. * @param onCompiled Callback triggered at the and of the effects compilation
  17593. * @param options Sets of optional options forcing the compilation with different modes
  17594. */
  17595. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17596. useInstances: boolean;
  17597. }>): void;
  17598. /**
  17599. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17600. * @param options Sets of optional options forcing the compilation with different modes
  17601. * @returns A promise that resolves when the compilation completes
  17602. */
  17603. forceCompilationAsync(options?: Partial<{
  17604. useInstances: boolean;
  17605. }>): Promise<void>;
  17606. /**
  17607. * Serializes the shadow generator setup to a json object.
  17608. * @returns The serialized JSON object
  17609. */
  17610. serialize(): any;
  17611. /**
  17612. * Disposes the Shadow map and related Textures and effects.
  17613. */
  17614. dispose(): void;
  17615. }
  17616. /**
  17617. * Default implementation IShadowGenerator.
  17618. * This is the main object responsible of generating shadows in the framework.
  17619. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17620. */
  17621. export class ShadowGenerator implements IShadowGenerator {
  17622. /**
  17623. * Name of the shadow generator class
  17624. */
  17625. static CLASSNAME: string;
  17626. /**
  17627. * Shadow generator mode None: no filtering applied.
  17628. */
  17629. static readonly FILTER_NONE: number;
  17630. /**
  17631. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17632. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17633. */
  17634. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17635. /**
  17636. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17637. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17638. */
  17639. static readonly FILTER_POISSONSAMPLING: number;
  17640. /**
  17641. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17642. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17643. */
  17644. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17645. /**
  17646. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17647. * edge artifacts on steep falloff.
  17648. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17649. */
  17650. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17651. /**
  17652. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17653. * edge artifacts on steep falloff.
  17654. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17655. */
  17656. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17657. /**
  17658. * Shadow generator mode PCF: Percentage Closer Filtering
  17659. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17660. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17661. */
  17662. static readonly FILTER_PCF: number;
  17663. /**
  17664. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17665. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17666. * Contact Hardening
  17667. */
  17668. static readonly FILTER_PCSS: number;
  17669. /**
  17670. * Reserved for PCF and PCSS
  17671. * Highest Quality.
  17672. *
  17673. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17674. *
  17675. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17676. */
  17677. static readonly QUALITY_HIGH: number;
  17678. /**
  17679. * Reserved for PCF and PCSS
  17680. * Good tradeoff for quality/perf cross devices
  17681. *
  17682. * Execute PCF on a 3*3 kernel.
  17683. *
  17684. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17685. */
  17686. static readonly QUALITY_MEDIUM: number;
  17687. /**
  17688. * Reserved for PCF and PCSS
  17689. * The lowest quality but the fastest.
  17690. *
  17691. * Execute PCF on a 1*1 kernel.
  17692. *
  17693. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17694. */
  17695. static readonly QUALITY_LOW: number;
  17696. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17697. id: string;
  17698. /** Gets or sets the custom shader name to use */
  17699. customShaderOptions: ICustomShaderOptions;
  17700. /**
  17701. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17702. */
  17703. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17704. /**
  17705. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17706. */
  17707. onAfterShadowMapRenderObservable: Observable<Effect>;
  17708. /**
  17709. * Observable triggered before a mesh is rendered in the shadow map.
  17710. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17711. */
  17712. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17713. /**
  17714. * Observable triggered after a mesh is rendered in the shadow map.
  17715. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17716. */
  17717. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17718. protected _bias: number;
  17719. /**
  17720. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17721. */
  17722. get bias(): number;
  17723. /**
  17724. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17725. */
  17726. set bias(bias: number);
  17727. protected _normalBias: number;
  17728. /**
  17729. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17730. */
  17731. get normalBias(): number;
  17732. /**
  17733. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17734. */
  17735. set normalBias(normalBias: number);
  17736. protected _blurBoxOffset: number;
  17737. /**
  17738. * Gets the blur box offset: offset applied during the blur pass.
  17739. * Only useful if useKernelBlur = false
  17740. */
  17741. get blurBoxOffset(): number;
  17742. /**
  17743. * Sets the blur box offset: offset applied during the blur pass.
  17744. * Only useful if useKernelBlur = false
  17745. */
  17746. set blurBoxOffset(value: number);
  17747. protected _blurScale: number;
  17748. /**
  17749. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17750. * 2 means half of the size.
  17751. */
  17752. get blurScale(): number;
  17753. /**
  17754. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17755. * 2 means half of the size.
  17756. */
  17757. set blurScale(value: number);
  17758. protected _blurKernel: number;
  17759. /**
  17760. * Gets the blur kernel: kernel size of the blur pass.
  17761. * Only useful if useKernelBlur = true
  17762. */
  17763. get blurKernel(): number;
  17764. /**
  17765. * Sets the blur kernel: kernel size of the blur pass.
  17766. * Only useful if useKernelBlur = true
  17767. */
  17768. set blurKernel(value: number);
  17769. protected _useKernelBlur: boolean;
  17770. /**
  17771. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17772. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17773. */
  17774. get useKernelBlur(): boolean;
  17775. /**
  17776. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17777. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17778. */
  17779. set useKernelBlur(value: boolean);
  17780. protected _depthScale: number;
  17781. /**
  17782. * Gets the depth scale used in ESM mode.
  17783. */
  17784. get depthScale(): number;
  17785. /**
  17786. * Sets the depth scale used in ESM mode.
  17787. * This can override the scale stored on the light.
  17788. */
  17789. set depthScale(value: number);
  17790. protected _validateFilter(filter: number): number;
  17791. protected _filter: number;
  17792. /**
  17793. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17794. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17795. */
  17796. get filter(): number;
  17797. /**
  17798. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17799. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17800. */
  17801. set filter(value: number);
  17802. /**
  17803. * Gets if the current filter is set to Poisson Sampling.
  17804. */
  17805. get usePoissonSampling(): boolean;
  17806. /**
  17807. * Sets the current filter to Poisson Sampling.
  17808. */
  17809. set usePoissonSampling(value: boolean);
  17810. /**
  17811. * Gets if the current filter is set to ESM.
  17812. */
  17813. get useExponentialShadowMap(): boolean;
  17814. /**
  17815. * Sets the current filter is to ESM.
  17816. */
  17817. set useExponentialShadowMap(value: boolean);
  17818. /**
  17819. * Gets if the current filter is set to filtered ESM.
  17820. */
  17821. get useBlurExponentialShadowMap(): boolean;
  17822. /**
  17823. * Gets if the current filter is set to filtered ESM.
  17824. */
  17825. set useBlurExponentialShadowMap(value: boolean);
  17826. /**
  17827. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17828. * exponential to prevent steep falloff artifacts).
  17829. */
  17830. get useCloseExponentialShadowMap(): boolean;
  17831. /**
  17832. * Sets the current filter to "close ESM" (using the inverse of the
  17833. * exponential to prevent steep falloff artifacts).
  17834. */
  17835. set useCloseExponentialShadowMap(value: boolean);
  17836. /**
  17837. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17838. * exponential to prevent steep falloff artifacts).
  17839. */
  17840. get useBlurCloseExponentialShadowMap(): boolean;
  17841. /**
  17842. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17843. * exponential to prevent steep falloff artifacts).
  17844. */
  17845. set useBlurCloseExponentialShadowMap(value: boolean);
  17846. /**
  17847. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17848. */
  17849. get usePercentageCloserFiltering(): boolean;
  17850. /**
  17851. * Sets the current filter to "PCF" (percentage closer filtering).
  17852. */
  17853. set usePercentageCloserFiltering(value: boolean);
  17854. protected _filteringQuality: number;
  17855. /**
  17856. * Gets the PCF or PCSS Quality.
  17857. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17858. */
  17859. get filteringQuality(): number;
  17860. /**
  17861. * Sets the PCF or PCSS Quality.
  17862. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17863. */
  17864. set filteringQuality(filteringQuality: number);
  17865. /**
  17866. * Gets if the current filter is set to "PCSS" (contact hardening).
  17867. */
  17868. get useContactHardeningShadow(): boolean;
  17869. /**
  17870. * Sets the current filter to "PCSS" (contact hardening).
  17871. */
  17872. set useContactHardeningShadow(value: boolean);
  17873. protected _contactHardeningLightSizeUVRatio: number;
  17874. /**
  17875. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17876. * Using a ratio helps keeping shape stability independently of the map size.
  17877. *
  17878. * It does not account for the light projection as it was having too much
  17879. * instability during the light setup or during light position changes.
  17880. *
  17881. * Only valid if useContactHardeningShadow is true.
  17882. */
  17883. get contactHardeningLightSizeUVRatio(): number;
  17884. /**
  17885. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17886. * Using a ratio helps keeping shape stability independently of the map size.
  17887. *
  17888. * It does not account for the light projection as it was having too much
  17889. * instability during the light setup or during light position changes.
  17890. *
  17891. * Only valid if useContactHardeningShadow is true.
  17892. */
  17893. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17894. protected _darkness: number;
  17895. /** Gets or sets the actual darkness of a shadow */
  17896. get darkness(): number;
  17897. set darkness(value: number);
  17898. /**
  17899. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17900. * 0 means strongest and 1 would means no shadow.
  17901. * @returns the darkness.
  17902. */
  17903. getDarkness(): number;
  17904. /**
  17905. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17906. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17907. * @returns the shadow generator allowing fluent coding.
  17908. */
  17909. setDarkness(darkness: number): ShadowGenerator;
  17910. protected _transparencyShadow: boolean;
  17911. /** Gets or sets the ability to have transparent shadow */
  17912. get transparencyShadow(): boolean;
  17913. set transparencyShadow(value: boolean);
  17914. /**
  17915. * Sets the ability to have transparent shadow (boolean).
  17916. * @param transparent True if transparent else False
  17917. * @returns the shadow generator allowing fluent coding
  17918. */
  17919. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17920. /**
  17921. * Enables or disables shadows with varying strength based on the transparency
  17922. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17923. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17924. * mesh.visibility * alphaTexture.a
  17925. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17926. */
  17927. enableSoftTransparentShadow: boolean;
  17928. protected _shadowMap: Nullable<RenderTargetTexture>;
  17929. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17930. /**
  17931. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17932. * @returns The render target texture if present otherwise, null
  17933. */
  17934. getShadowMap(): Nullable<RenderTargetTexture>;
  17935. /**
  17936. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17937. * @returns The render target texture if the shadow map is present otherwise, null
  17938. */
  17939. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17940. /**
  17941. * Gets the class name of that object
  17942. * @returns "ShadowGenerator"
  17943. */
  17944. getClassName(): string;
  17945. /**
  17946. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17947. * @param mesh Mesh to add
  17948. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17949. * @returns the Shadow Generator itself
  17950. */
  17951. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17952. /**
  17953. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17954. * @param mesh Mesh to remove
  17955. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17956. * @returns the Shadow Generator itself
  17957. */
  17958. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17959. /**
  17960. * Controls the extent to which the shadows fade out at the edge of the frustum
  17961. */
  17962. frustumEdgeFalloff: number;
  17963. protected _light: IShadowLight;
  17964. /**
  17965. * Returns the associated light object.
  17966. * @returns the light generating the shadow
  17967. */
  17968. getLight(): IShadowLight;
  17969. /**
  17970. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17971. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17972. * It might on the other hand introduce peter panning.
  17973. */
  17974. forceBackFacesOnly: boolean;
  17975. protected _scene: Scene;
  17976. protected _lightDirection: Vector3;
  17977. protected _effect: Effect;
  17978. protected _viewMatrix: Matrix;
  17979. protected _projectionMatrix: Matrix;
  17980. protected _transformMatrix: Matrix;
  17981. protected _cachedPosition: Vector3;
  17982. protected _cachedDirection: Vector3;
  17983. protected _cachedDefines: string;
  17984. protected _currentRenderID: number;
  17985. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17986. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17987. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17988. protected _blurPostProcesses: PostProcess[];
  17989. protected _mapSize: number;
  17990. protected _currentFaceIndex: number;
  17991. protected _currentFaceIndexCache: number;
  17992. protected _textureType: number;
  17993. protected _defaultTextureMatrix: Matrix;
  17994. protected _storedUniqueId: Nullable<number>;
  17995. /** @hidden */
  17996. static _SceneComponentInitialization: (scene: Scene) => void;
  17997. /**
  17998. * Gets or sets the size of the texture what stores the shadows
  17999. */
  18000. get mapSize(): number;
  18001. set mapSize(size: number);
  18002. /**
  18003. * Creates a ShadowGenerator object.
  18004. * A ShadowGenerator is the required tool to use the shadows.
  18005. * Each light casting shadows needs to use its own ShadowGenerator.
  18006. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18007. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18008. * @param light The light object generating the shadows.
  18009. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  18010. */
  18011. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18012. protected _initializeGenerator(): void;
  18013. protected _createTargetRenderTexture(): void;
  18014. protected _initializeShadowMap(): void;
  18015. protected _initializeBlurRTTAndPostProcesses(): void;
  18016. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18017. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18018. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18019. protected _applyFilterValues(): void;
  18020. /**
  18021. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18022. * @param onCompiled Callback triggered at the and of the effects compilation
  18023. * @param options Sets of optional options forcing the compilation with different modes
  18024. */
  18025. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18026. useInstances: boolean;
  18027. }>): void;
  18028. /**
  18029. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18030. * @param options Sets of optional options forcing the compilation with different modes
  18031. * @returns A promise that resolves when the compilation completes
  18032. */
  18033. forceCompilationAsync(options?: Partial<{
  18034. useInstances: boolean;
  18035. }>): Promise<void>;
  18036. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18037. private _prepareShadowDefines;
  18038. /**
  18039. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18040. * @param subMesh The submesh we want to render in the shadow map
  18041. * @param useInstances Defines wether will draw in the map using instances
  18042. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18043. * @returns true if ready otherwise, false
  18044. */
  18045. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18046. /**
  18047. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18048. * @param defines Defines of the material we want to update
  18049. * @param lightIndex Index of the light in the enabled light list of the material
  18050. */
  18051. prepareDefines(defines: any, lightIndex: number): void;
  18052. /**
  18053. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18054. * defined in the generator but impacting the effect).
  18055. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18056. * @param effect The effect we are binfing the information for
  18057. */
  18058. bindShadowLight(lightIndex: string, effect: Effect): void;
  18059. /**
  18060. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18061. * (eq to shadow prjection matrix * light transform matrix)
  18062. * @returns The transform matrix used to create the shadow map
  18063. */
  18064. getTransformMatrix(): Matrix;
  18065. /**
  18066. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18067. * Cube and 2D textures for instance.
  18068. */
  18069. recreateShadowMap(): void;
  18070. protected _disposeBlurPostProcesses(): void;
  18071. protected _disposeRTTandPostProcesses(): void;
  18072. /**
  18073. * Disposes the ShadowGenerator.
  18074. * Returns nothing.
  18075. */
  18076. dispose(): void;
  18077. /**
  18078. * Serializes the shadow generator setup to a json object.
  18079. * @returns The serialized JSON object
  18080. */
  18081. serialize(): any;
  18082. /**
  18083. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18084. * @param parsedShadowGenerator The JSON object to parse
  18085. * @param scene The scene to create the shadow map for
  18086. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18087. * @returns The parsed shadow generator
  18088. */
  18089. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18090. }
  18091. }
  18092. declare module BABYLON {
  18093. /**
  18094. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18095. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18096. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  18097. */
  18098. export abstract class Light extends Node {
  18099. /**
  18100. * Falloff Default: light is falling off following the material specification:
  18101. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18102. */
  18103. static readonly FALLOFF_DEFAULT: number;
  18104. /**
  18105. * Falloff Physical: light is falling off following the inverse squared distance law.
  18106. */
  18107. static readonly FALLOFF_PHYSICAL: number;
  18108. /**
  18109. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18110. * to enhance interoperability with other engines.
  18111. */
  18112. static readonly FALLOFF_GLTF: number;
  18113. /**
  18114. * Falloff Standard: light is falling off like in the standard material
  18115. * to enhance interoperability with other materials.
  18116. */
  18117. static readonly FALLOFF_STANDARD: number;
  18118. /**
  18119. * If every light affecting the material is in this lightmapMode,
  18120. * material.lightmapTexture adds or multiplies
  18121. * (depends on material.useLightmapAsShadowmap)
  18122. * after every other light calculations.
  18123. */
  18124. static readonly LIGHTMAP_DEFAULT: number;
  18125. /**
  18126. * material.lightmapTexture as only diffuse lighting from this light
  18127. * adds only specular lighting from this light
  18128. * adds dynamic shadows
  18129. */
  18130. static readonly LIGHTMAP_SPECULAR: number;
  18131. /**
  18132. * material.lightmapTexture as only lighting
  18133. * no light calculation from this light
  18134. * only adds dynamic shadows from this light
  18135. */
  18136. static readonly LIGHTMAP_SHADOWSONLY: number;
  18137. /**
  18138. * Each light type uses the default quantity according to its type:
  18139. * point/spot lights use luminous intensity
  18140. * directional lights use illuminance
  18141. */
  18142. static readonly INTENSITYMODE_AUTOMATIC: number;
  18143. /**
  18144. * lumen (lm)
  18145. */
  18146. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18147. /**
  18148. * candela (lm/sr)
  18149. */
  18150. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18151. /**
  18152. * lux (lm/m^2)
  18153. */
  18154. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18155. /**
  18156. * nit (cd/m^2)
  18157. */
  18158. static readonly INTENSITYMODE_LUMINANCE: number;
  18159. /**
  18160. * Light type const id of the point light.
  18161. */
  18162. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18163. /**
  18164. * Light type const id of the directional light.
  18165. */
  18166. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18167. /**
  18168. * Light type const id of the spot light.
  18169. */
  18170. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18171. /**
  18172. * Light type const id of the hemispheric light.
  18173. */
  18174. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18175. /**
  18176. * Diffuse gives the basic color to an object.
  18177. */
  18178. diffuse: Color3;
  18179. /**
  18180. * Specular produces a highlight color on an object.
  18181. * Note: This is note affecting PBR materials.
  18182. */
  18183. specular: Color3;
  18184. /**
  18185. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18186. * falling off base on range or angle.
  18187. * This can be set to any values in Light.FALLOFF_x.
  18188. *
  18189. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18190. * other types of materials.
  18191. */
  18192. falloffType: number;
  18193. /**
  18194. * Strength of the light.
  18195. * Note: By default it is define in the framework own unit.
  18196. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18197. */
  18198. intensity: number;
  18199. private _range;
  18200. protected _inverseSquaredRange: number;
  18201. /**
  18202. * Defines how far from the source the light is impacting in scene units.
  18203. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18204. */
  18205. get range(): number;
  18206. /**
  18207. * Defines how far from the source the light is impacting in scene units.
  18208. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18209. */
  18210. set range(value: number);
  18211. /**
  18212. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18213. * of light.
  18214. */
  18215. private _photometricScale;
  18216. private _intensityMode;
  18217. /**
  18218. * Gets the photometric scale used to interpret the intensity.
  18219. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18220. */
  18221. get intensityMode(): number;
  18222. /**
  18223. * Sets the photometric scale used to interpret the intensity.
  18224. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18225. */
  18226. set intensityMode(value: number);
  18227. private _radius;
  18228. /**
  18229. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18230. */
  18231. get radius(): number;
  18232. /**
  18233. * sets the light radius used by PBR Materials to simulate soft area lights.
  18234. */
  18235. set radius(value: number);
  18236. private _renderPriority;
  18237. /**
  18238. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18239. * exceeding the number allowed of the materials.
  18240. */
  18241. renderPriority: number;
  18242. private _shadowEnabled;
  18243. /**
  18244. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18245. * the current shadow generator.
  18246. */
  18247. get shadowEnabled(): boolean;
  18248. /**
  18249. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18250. * the current shadow generator.
  18251. */
  18252. set shadowEnabled(value: boolean);
  18253. private _includedOnlyMeshes;
  18254. /**
  18255. * Gets the only meshes impacted by this light.
  18256. */
  18257. get includedOnlyMeshes(): AbstractMesh[];
  18258. /**
  18259. * Sets the only meshes impacted by this light.
  18260. */
  18261. set includedOnlyMeshes(value: AbstractMesh[]);
  18262. private _excludedMeshes;
  18263. /**
  18264. * Gets the meshes not impacted by this light.
  18265. */
  18266. get excludedMeshes(): AbstractMesh[];
  18267. /**
  18268. * Sets the meshes not impacted by this light.
  18269. */
  18270. set excludedMeshes(value: AbstractMesh[]);
  18271. private _excludeWithLayerMask;
  18272. /**
  18273. * Gets the layer id use to find what meshes are not impacted by the light.
  18274. * Inactive if 0
  18275. */
  18276. get excludeWithLayerMask(): number;
  18277. /**
  18278. * Sets the layer id use to find what meshes are not impacted by the light.
  18279. * Inactive if 0
  18280. */
  18281. set excludeWithLayerMask(value: number);
  18282. private _includeOnlyWithLayerMask;
  18283. /**
  18284. * Gets the layer id use to find what meshes are impacted by the light.
  18285. * Inactive if 0
  18286. */
  18287. get includeOnlyWithLayerMask(): number;
  18288. /**
  18289. * Sets the layer id use to find what meshes are impacted by the light.
  18290. * Inactive if 0
  18291. */
  18292. set includeOnlyWithLayerMask(value: number);
  18293. private _lightmapMode;
  18294. /**
  18295. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18296. */
  18297. get lightmapMode(): number;
  18298. /**
  18299. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18300. */
  18301. set lightmapMode(value: number);
  18302. /**
  18303. * Shadow generator associted to the light.
  18304. * @hidden Internal use only.
  18305. */
  18306. _shadowGenerator: Nullable<IShadowGenerator>;
  18307. /**
  18308. * @hidden Internal use only.
  18309. */
  18310. _excludedMeshesIds: string[];
  18311. /**
  18312. * @hidden Internal use only.
  18313. */
  18314. _includedOnlyMeshesIds: string[];
  18315. /**
  18316. * The current light unifom buffer.
  18317. * @hidden Internal use only.
  18318. */
  18319. _uniformBuffer: UniformBuffer;
  18320. /** @hidden */
  18321. _renderId: number;
  18322. /**
  18323. * Creates a Light object in the scene.
  18324. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18325. * @param name The firendly name of the light
  18326. * @param scene The scene the light belongs too
  18327. */
  18328. constructor(name: string, scene: Scene);
  18329. protected abstract _buildUniformLayout(): void;
  18330. /**
  18331. * Sets the passed Effect "effect" with the Light information.
  18332. * @param effect The effect to update
  18333. * @param lightIndex The index of the light in the effect to update
  18334. * @returns The light
  18335. */
  18336. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18337. /**
  18338. * Sets the passed Effect "effect" with the Light textures.
  18339. * @param effect The effect to update
  18340. * @param lightIndex The index of the light in the effect to update
  18341. * @returns The light
  18342. */
  18343. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18344. /**
  18345. * Binds the lights information from the scene to the effect for the given mesh.
  18346. * @param lightIndex Light index
  18347. * @param scene The scene where the light belongs to
  18348. * @param effect The effect we are binding the data to
  18349. * @param useSpecular Defines if specular is supported
  18350. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18351. */
  18352. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18353. /**
  18354. * Sets the passed Effect "effect" with the Light information.
  18355. * @param effect The effect to update
  18356. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18357. * @returns The light
  18358. */
  18359. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18360. /**
  18361. * Returns the string "Light".
  18362. * @returns the class name
  18363. */
  18364. getClassName(): string;
  18365. /** @hidden */
  18366. readonly _isLight: boolean;
  18367. /**
  18368. * Converts the light information to a readable string for debug purpose.
  18369. * @param fullDetails Supports for multiple levels of logging within scene loading
  18370. * @returns the human readable light info
  18371. */
  18372. toString(fullDetails?: boolean): string;
  18373. /** @hidden */
  18374. protected _syncParentEnabledState(): void;
  18375. /**
  18376. * Set the enabled state of this node.
  18377. * @param value - the new enabled state
  18378. */
  18379. setEnabled(value: boolean): void;
  18380. /**
  18381. * Returns the Light associated shadow generator if any.
  18382. * @return the associated shadow generator.
  18383. */
  18384. getShadowGenerator(): Nullable<IShadowGenerator>;
  18385. /**
  18386. * Returns a Vector3, the absolute light position in the World.
  18387. * @returns the world space position of the light
  18388. */
  18389. getAbsolutePosition(): Vector3;
  18390. /**
  18391. * Specifies if the light will affect the passed mesh.
  18392. * @param mesh The mesh to test against the light
  18393. * @return true the mesh is affected otherwise, false.
  18394. */
  18395. canAffectMesh(mesh: AbstractMesh): boolean;
  18396. /**
  18397. * Sort function to order lights for rendering.
  18398. * @param a First Light object to compare to second.
  18399. * @param b Second Light object to compare first.
  18400. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18401. */
  18402. static CompareLightsPriority(a: Light, b: Light): number;
  18403. /**
  18404. * Releases resources associated with this node.
  18405. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18406. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18407. */
  18408. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18409. /**
  18410. * Returns the light type ID (integer).
  18411. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18412. */
  18413. getTypeID(): number;
  18414. /**
  18415. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18416. * @returns the scaled intensity in intensity mode unit
  18417. */
  18418. getScaledIntensity(): number;
  18419. /**
  18420. * Returns a new Light object, named "name", from the current one.
  18421. * @param name The name of the cloned light
  18422. * @param newParent The parent of this light, if it has one
  18423. * @returns the new created light
  18424. */
  18425. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18426. /**
  18427. * Serializes the current light into a Serialization object.
  18428. * @returns the serialized object.
  18429. */
  18430. serialize(): any;
  18431. /**
  18432. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18433. * This new light is named "name" and added to the passed scene.
  18434. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18435. * @param name The friendly name of the light
  18436. * @param scene The scene the new light will belong to
  18437. * @returns the constructor function
  18438. */
  18439. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18440. /**
  18441. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18442. * @param parsedLight The JSON representation of the light
  18443. * @param scene The scene to create the parsed light in
  18444. * @returns the created light after parsing
  18445. */
  18446. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18447. private _hookArrayForExcluded;
  18448. private _hookArrayForIncludedOnly;
  18449. private _resyncMeshes;
  18450. /**
  18451. * Forces the meshes to update their light related information in their rendering used effects
  18452. * @hidden Internal Use Only
  18453. */
  18454. _markMeshesAsLightDirty(): void;
  18455. /**
  18456. * Recomputes the cached photometric scale if needed.
  18457. */
  18458. private _computePhotometricScale;
  18459. /**
  18460. * Returns the Photometric Scale according to the light type and intensity mode.
  18461. */
  18462. private _getPhotometricScale;
  18463. /**
  18464. * Reorder the light in the scene according to their defined priority.
  18465. * @hidden Internal Use Only
  18466. */
  18467. _reorderLightsInScene(): void;
  18468. /**
  18469. * Prepares the list of defines specific to the light type.
  18470. * @param defines the list of defines
  18471. * @param lightIndex defines the index of the light for the effect
  18472. */
  18473. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18474. }
  18475. }
  18476. declare module BABYLON {
  18477. /**
  18478. * Configuration needed for prepass-capable materials
  18479. */
  18480. export class PrePassConfiguration {
  18481. /**
  18482. * Previous world matrices of meshes carrying this material
  18483. * Used for computing velocity
  18484. */
  18485. previousWorldMatrices: {
  18486. [index: number]: Matrix;
  18487. };
  18488. /**
  18489. * Previous view project matrix
  18490. * Used for computing velocity
  18491. */
  18492. previousViewProjection: Matrix;
  18493. /**
  18494. * Previous bones of meshes carrying this material
  18495. * Used for computing velocity
  18496. */
  18497. previousBones: {
  18498. [index: number]: Float32Array;
  18499. };
  18500. /**
  18501. * Add the required uniforms to the current list.
  18502. * @param uniforms defines the current uniform list.
  18503. */
  18504. static AddUniforms(uniforms: string[]): void;
  18505. /**
  18506. * Add the required samplers to the current list.
  18507. * @param samplers defines the current sampler list.
  18508. */
  18509. static AddSamplers(samplers: string[]): void;
  18510. /**
  18511. * Binds the material data.
  18512. * @param effect defines the effect to update
  18513. * @param scene defines the scene the material belongs to.
  18514. * @param mesh The mesh
  18515. * @param world World matrix of this mesh
  18516. * @param isFrozen Is the material frozen
  18517. */
  18518. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  18519. }
  18520. }
  18521. declare module BABYLON {
  18522. /**
  18523. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18524. * This is the base of the follow, arc rotate cameras and Free camera
  18525. * @see https://doc.babylonjs.com/features/cameras
  18526. */
  18527. export class TargetCamera extends Camera {
  18528. private static _RigCamTransformMatrix;
  18529. private static _TargetTransformMatrix;
  18530. private static _TargetFocalPoint;
  18531. private _tmpUpVector;
  18532. private _tmpTargetVector;
  18533. /**
  18534. * Define the current direction the camera is moving to
  18535. */
  18536. cameraDirection: Vector3;
  18537. /**
  18538. * Define the current rotation the camera is rotating to
  18539. */
  18540. cameraRotation: Vector2;
  18541. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18542. ignoreParentScaling: boolean;
  18543. /**
  18544. * When set, the up vector of the camera will be updated by the rotation of the camera
  18545. */
  18546. updateUpVectorFromRotation: boolean;
  18547. private _tmpQuaternion;
  18548. /**
  18549. * Define the current rotation of the camera
  18550. */
  18551. rotation: Vector3;
  18552. /**
  18553. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18554. */
  18555. rotationQuaternion: Quaternion;
  18556. /**
  18557. * Define the current speed of the camera
  18558. */
  18559. speed: number;
  18560. /**
  18561. * Add constraint to the camera to prevent it to move freely in all directions and
  18562. * around all axis.
  18563. */
  18564. noRotationConstraint: boolean;
  18565. /**
  18566. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18567. * panning
  18568. */
  18569. invertRotation: boolean;
  18570. /**
  18571. * Speed multiplier for inverse camera panning
  18572. */
  18573. inverseRotationSpeed: number;
  18574. /**
  18575. * Define the current target of the camera as an object or a position.
  18576. */
  18577. lockedTarget: any;
  18578. /** @hidden */
  18579. _currentTarget: Vector3;
  18580. /** @hidden */
  18581. _initialFocalDistance: number;
  18582. /** @hidden */
  18583. _viewMatrix: Matrix;
  18584. /** @hidden */
  18585. _camMatrix: Matrix;
  18586. /** @hidden */
  18587. _cameraTransformMatrix: Matrix;
  18588. /** @hidden */
  18589. _cameraRotationMatrix: Matrix;
  18590. /** @hidden */
  18591. _referencePoint: Vector3;
  18592. /** @hidden */
  18593. _transformedReferencePoint: Vector3;
  18594. /** @hidden */
  18595. _reset: () => void;
  18596. private _defaultUp;
  18597. /**
  18598. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18599. * This is the base of the follow, arc rotate cameras and Free camera
  18600. * @see https://doc.babylonjs.com/features/cameras
  18601. * @param name Defines the name of the camera in the scene
  18602. * @param position Defines the start position of the camera in the scene
  18603. * @param scene Defines the scene the camera belongs to
  18604. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18605. */
  18606. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18607. /**
  18608. * Gets the position in front of the camera at a given distance.
  18609. * @param distance The distance from the camera we want the position to be
  18610. * @returns the position
  18611. */
  18612. getFrontPosition(distance: number): Vector3;
  18613. /** @hidden */
  18614. _getLockedTargetPosition(): Nullable<Vector3>;
  18615. private _storedPosition;
  18616. private _storedRotation;
  18617. private _storedRotationQuaternion;
  18618. /**
  18619. * Store current camera state of the camera (fov, position, rotation, etc..)
  18620. * @returns the camera
  18621. */
  18622. storeState(): Camera;
  18623. /**
  18624. * Restored camera state. You must call storeState() first
  18625. * @returns whether it was successful or not
  18626. * @hidden
  18627. */
  18628. _restoreStateValues(): boolean;
  18629. /** @hidden */
  18630. _initCache(): void;
  18631. /** @hidden */
  18632. _updateCache(ignoreParentClass?: boolean): void;
  18633. /** @hidden */
  18634. _isSynchronizedViewMatrix(): boolean;
  18635. /** @hidden */
  18636. _computeLocalCameraSpeed(): number;
  18637. /**
  18638. * Defines the target the camera should look at.
  18639. * @param target Defines the new target as a Vector or a mesh
  18640. */
  18641. setTarget(target: Vector3): void;
  18642. /**
  18643. * Defines the target point of the camera.
  18644. * The camera looks towards it form the radius distance.
  18645. */
  18646. get target(): Vector3;
  18647. set target(value: Vector3);
  18648. /**
  18649. * Return the current target position of the camera. This value is expressed in local space.
  18650. * @returns the target position
  18651. */
  18652. getTarget(): Vector3;
  18653. /** @hidden */
  18654. _decideIfNeedsToMove(): boolean;
  18655. /** @hidden */
  18656. _updatePosition(): void;
  18657. /** @hidden */
  18658. _checkInputs(): void;
  18659. protected _updateCameraRotationMatrix(): void;
  18660. /**
  18661. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  18662. * @returns the current camera
  18663. */
  18664. private _rotateUpVectorWithCameraRotationMatrix;
  18665. private _cachedRotationZ;
  18666. private _cachedQuaternionRotationZ;
  18667. /** @hidden */
  18668. _getViewMatrix(): Matrix;
  18669. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18670. /**
  18671. * @hidden
  18672. */
  18673. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18674. /**
  18675. * @hidden
  18676. */
  18677. _updateRigCameras(): void;
  18678. private _getRigCamPositionAndTarget;
  18679. /**
  18680. * Gets the current object class name.
  18681. * @return the class name
  18682. */
  18683. getClassName(): string;
  18684. }
  18685. }
  18686. declare module BABYLON {
  18687. /**
  18688. * Gather the list of keyboard event types as constants.
  18689. */
  18690. export class KeyboardEventTypes {
  18691. /**
  18692. * The keydown event is fired when a key becomes active (pressed).
  18693. */
  18694. static readonly KEYDOWN: number;
  18695. /**
  18696. * The keyup event is fired when a key has been released.
  18697. */
  18698. static readonly KEYUP: number;
  18699. }
  18700. /**
  18701. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18702. */
  18703. export class KeyboardInfo {
  18704. /**
  18705. * Defines the type of event (KeyboardEventTypes)
  18706. */
  18707. type: number;
  18708. /**
  18709. * Defines the related dom event
  18710. */
  18711. event: KeyboardEvent;
  18712. /**
  18713. * Instantiates a new keyboard info.
  18714. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18715. * @param type Defines the type of event (KeyboardEventTypes)
  18716. * @param event Defines the related dom event
  18717. */
  18718. constructor(
  18719. /**
  18720. * Defines the type of event (KeyboardEventTypes)
  18721. */
  18722. type: number,
  18723. /**
  18724. * Defines the related dom event
  18725. */
  18726. event: KeyboardEvent);
  18727. }
  18728. /**
  18729. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18730. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18731. */
  18732. export class KeyboardInfoPre extends KeyboardInfo {
  18733. /**
  18734. * Defines the type of event (KeyboardEventTypes)
  18735. */
  18736. type: number;
  18737. /**
  18738. * Defines the related dom event
  18739. */
  18740. event: KeyboardEvent;
  18741. /**
  18742. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18743. */
  18744. skipOnPointerObservable: boolean;
  18745. /**
  18746. * Instantiates a new keyboard pre info.
  18747. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18748. * @param type Defines the type of event (KeyboardEventTypes)
  18749. * @param event Defines the related dom event
  18750. */
  18751. constructor(
  18752. /**
  18753. * Defines the type of event (KeyboardEventTypes)
  18754. */
  18755. type: number,
  18756. /**
  18757. * Defines the related dom event
  18758. */
  18759. event: KeyboardEvent);
  18760. }
  18761. }
  18762. declare module BABYLON {
  18763. /**
  18764. * Manage the keyboard inputs to control the movement of a free camera.
  18765. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18766. */
  18767. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18768. /**
  18769. * Defines the camera the input is attached to.
  18770. */
  18771. camera: FreeCamera;
  18772. /**
  18773. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18774. */
  18775. keysUp: number[];
  18776. /**
  18777. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18778. */
  18779. keysUpward: number[];
  18780. /**
  18781. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18782. */
  18783. keysDown: number[];
  18784. /**
  18785. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18786. */
  18787. keysDownward: number[];
  18788. /**
  18789. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18790. */
  18791. keysLeft: number[];
  18792. /**
  18793. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18794. */
  18795. keysRight: number[];
  18796. private _keys;
  18797. private _onCanvasBlurObserver;
  18798. private _onKeyboardObserver;
  18799. private _engine;
  18800. private _scene;
  18801. /**
  18802. * Attach the input controls to a specific dom element to get the input from.
  18803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18804. */
  18805. attachControl(noPreventDefault?: boolean): void;
  18806. /**
  18807. * Detach the current controls from the specified dom element.
  18808. */
  18809. detachControl(): void;
  18810. /**
  18811. * Update the current camera state depending on the inputs that have been used this frame.
  18812. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18813. */
  18814. checkInputs(): void;
  18815. /**
  18816. * Gets the class name of the current intput.
  18817. * @returns the class name
  18818. */
  18819. getClassName(): string;
  18820. /** @hidden */
  18821. _onLostFocus(): void;
  18822. /**
  18823. * Get the friendly name associated with the input class.
  18824. * @returns the input friendly name
  18825. */
  18826. getSimpleName(): string;
  18827. }
  18828. }
  18829. declare module BABYLON {
  18830. /**
  18831. * Gather the list of pointer event types as constants.
  18832. */
  18833. export class PointerEventTypes {
  18834. /**
  18835. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  18836. */
  18837. static readonly POINTERDOWN: number;
  18838. /**
  18839. * The pointerup event is fired when a pointer is no longer active.
  18840. */
  18841. static readonly POINTERUP: number;
  18842. /**
  18843. * The pointermove event is fired when a pointer changes coordinates.
  18844. */
  18845. static readonly POINTERMOVE: number;
  18846. /**
  18847. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18848. */
  18849. static readonly POINTERWHEEL: number;
  18850. /**
  18851. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18852. */
  18853. static readonly POINTERPICK: number;
  18854. /**
  18855. * The pointertap event is fired when a the object has been touched and released without drag.
  18856. */
  18857. static readonly POINTERTAP: number;
  18858. /**
  18859. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18860. */
  18861. static readonly POINTERDOUBLETAP: number;
  18862. }
  18863. /**
  18864. * Base class of pointer info types.
  18865. */
  18866. export class PointerInfoBase {
  18867. /**
  18868. * Defines the type of event (PointerEventTypes)
  18869. */
  18870. type: number;
  18871. /**
  18872. * Defines the related dom event
  18873. */
  18874. event: PointerEvent | MouseWheelEvent;
  18875. /**
  18876. * Instantiates the base class of pointers info.
  18877. * @param type Defines the type of event (PointerEventTypes)
  18878. * @param event Defines the related dom event
  18879. */
  18880. constructor(
  18881. /**
  18882. * Defines the type of event (PointerEventTypes)
  18883. */
  18884. type: number,
  18885. /**
  18886. * Defines the related dom event
  18887. */
  18888. event: PointerEvent | MouseWheelEvent);
  18889. }
  18890. /**
  18891. * This class is used to store pointer related info for the onPrePointerObservable event.
  18892. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18893. */
  18894. export class PointerInfoPre extends PointerInfoBase {
  18895. /**
  18896. * Ray from a pointer if availible (eg. 6dof controller)
  18897. */
  18898. ray: Nullable<Ray>;
  18899. /**
  18900. * Defines the local position of the pointer on the canvas.
  18901. */
  18902. localPosition: Vector2;
  18903. /**
  18904. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18905. */
  18906. skipOnPointerObservable: boolean;
  18907. /**
  18908. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18909. * @param type Defines the type of event (PointerEventTypes)
  18910. * @param event Defines the related dom event
  18911. * @param localX Defines the local x coordinates of the pointer when the event occured
  18912. * @param localY Defines the local y coordinates of the pointer when the event occured
  18913. */
  18914. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18915. }
  18916. /**
  18917. * This type contains all the data related to a pointer event in Babylon.js.
  18918. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  18919. */
  18920. export class PointerInfo extends PointerInfoBase {
  18921. /**
  18922. * Defines the picking info associated to the info (if any)\
  18923. */
  18924. pickInfo: Nullable<PickingInfo>;
  18925. /**
  18926. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18927. * @param type Defines the type of event (PointerEventTypes)
  18928. * @param event Defines the related dom event
  18929. * @param pickInfo Defines the picking info associated to the info (if any)\
  18930. */
  18931. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18932. /**
  18933. * Defines the picking info associated to the info (if any)\
  18934. */
  18935. pickInfo: Nullable<PickingInfo>);
  18936. }
  18937. /**
  18938. * Data relating to a touch event on the screen.
  18939. */
  18940. export interface PointerTouch {
  18941. /**
  18942. * X coordinate of touch.
  18943. */
  18944. x: number;
  18945. /**
  18946. * Y coordinate of touch.
  18947. */
  18948. y: number;
  18949. /**
  18950. * Id of touch. Unique for each finger.
  18951. */
  18952. pointerId: number;
  18953. /**
  18954. * Event type passed from DOM.
  18955. */
  18956. type: any;
  18957. }
  18958. }
  18959. declare module BABYLON {
  18960. /**
  18961. * Manage the mouse inputs to control the movement of a free camera.
  18962. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18963. */
  18964. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18965. /**
  18966. * Define if touch is enabled in the mouse input
  18967. */
  18968. touchEnabled: boolean;
  18969. /**
  18970. * Defines the camera the input is attached to.
  18971. */
  18972. camera: FreeCamera;
  18973. /**
  18974. * Defines the buttons associated with the input to handle camera move.
  18975. */
  18976. buttons: number[];
  18977. /**
  18978. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18979. */
  18980. angularSensibility: number;
  18981. private _pointerInput;
  18982. private _onMouseMove;
  18983. private _observer;
  18984. private previousPosition;
  18985. /**
  18986. * Observable for when a pointer move event occurs containing the move offset
  18987. */
  18988. onPointerMovedObservable: Observable<{
  18989. offsetX: number;
  18990. offsetY: number;
  18991. }>;
  18992. /**
  18993. * @hidden
  18994. * If the camera should be rotated automatically based on pointer movement
  18995. */
  18996. _allowCameraRotation: boolean;
  18997. /**
  18998. * Manage the mouse inputs to control the movement of a free camera.
  18999. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19000. * @param touchEnabled Defines if touch is enabled or not
  19001. */
  19002. constructor(
  19003. /**
  19004. * Define if touch is enabled in the mouse input
  19005. */
  19006. touchEnabled?: boolean);
  19007. /**
  19008. * Attach the input controls to a specific dom element to get the input from.
  19009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19010. */
  19011. attachControl(noPreventDefault?: boolean): void;
  19012. /**
  19013. * Called on JS contextmenu event.
  19014. * Override this method to provide functionality.
  19015. */
  19016. protected onContextMenu(evt: PointerEvent): void;
  19017. /**
  19018. * Detach the current controls from the specified dom element.
  19019. */
  19020. detachControl(): void;
  19021. /**
  19022. * Gets the class name of the current intput.
  19023. * @returns the class name
  19024. */
  19025. getClassName(): string;
  19026. /**
  19027. * Get the friendly name associated with the input class.
  19028. * @returns the input friendly name
  19029. */
  19030. getSimpleName(): string;
  19031. }
  19032. }
  19033. declare module BABYLON {
  19034. /**
  19035. * Base class for mouse wheel input..
  19036. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  19037. * for example usage.
  19038. */
  19039. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  19040. /**
  19041. * Defines the camera the input is attached to.
  19042. */
  19043. abstract camera: Camera;
  19044. /**
  19045. * How fast is the camera moves in relation to X axis mouseWheel events.
  19046. * Use negative value to reverse direction.
  19047. */
  19048. wheelPrecisionX: number;
  19049. /**
  19050. * How fast is the camera moves in relation to Y axis mouseWheel events.
  19051. * Use negative value to reverse direction.
  19052. */
  19053. wheelPrecisionY: number;
  19054. /**
  19055. * How fast is the camera moves in relation to Z axis mouseWheel events.
  19056. * Use negative value to reverse direction.
  19057. */
  19058. wheelPrecisionZ: number;
  19059. /**
  19060. * Observable for when a mouse wheel move event occurs.
  19061. */
  19062. onChangedObservable: Observable<{
  19063. wheelDeltaX: number;
  19064. wheelDeltaY: number;
  19065. wheelDeltaZ: number;
  19066. }>;
  19067. private _wheel;
  19068. private _observer;
  19069. /**
  19070. * Attach the input controls to a specific dom element to get the input from.
  19071. * @param noPreventDefault Defines whether event caught by the controls
  19072. * should call preventdefault().
  19073. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19074. */
  19075. attachControl(noPreventDefault?: boolean): void;
  19076. /**
  19077. * Detach the current controls from the specified dom element.
  19078. */
  19079. detachControl(): void;
  19080. /**
  19081. * Called for each rendered frame.
  19082. */
  19083. checkInputs(): void;
  19084. /**
  19085. * Gets the class name of the current intput.
  19086. * @returns the class name
  19087. */
  19088. getClassName(): string;
  19089. /**
  19090. * Get the friendly name associated with the input class.
  19091. * @returns the input friendly name
  19092. */
  19093. getSimpleName(): string;
  19094. /**
  19095. * Incremental value of multiple mouse wheel movements of the X axis.
  19096. * Should be zero-ed when read.
  19097. */
  19098. protected _wheelDeltaX: number;
  19099. /**
  19100. * Incremental value of multiple mouse wheel movements of the Y axis.
  19101. * Should be zero-ed when read.
  19102. */
  19103. protected _wheelDeltaY: number;
  19104. /**
  19105. * Incremental value of multiple mouse wheel movements of the Z axis.
  19106. * Should be zero-ed when read.
  19107. */
  19108. protected _wheelDeltaZ: number;
  19109. /**
  19110. * Firefox uses a different scheme to report scroll distances to other
  19111. * browsers. Rather than use complicated methods to calculate the exact
  19112. * multiple we need to apply, let's just cheat and use a constant.
  19113. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  19114. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  19115. */
  19116. private readonly _ffMultiplier;
  19117. /**
  19118. * Different event attributes for wheel data fall into a few set ranges.
  19119. * Some relevant but dated date here:
  19120. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  19121. */
  19122. private readonly _normalize;
  19123. }
  19124. }
  19125. declare module BABYLON {
  19126. /**
  19127. * Manage the mouse wheel inputs to control a free camera.
  19128. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19129. */
  19130. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  19131. /**
  19132. * Defines the camera the input is attached to.
  19133. */
  19134. camera: FreeCamera;
  19135. /**
  19136. * Gets the class name of the current input.
  19137. * @returns the class name
  19138. */
  19139. getClassName(): string;
  19140. /**
  19141. * Set which movement axis (relative to camera's orientation) the mouse
  19142. * wheel's X axis controls.
  19143. * @param axis The axis to be moved. Set null to clear.
  19144. */
  19145. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  19146. /**
  19147. * Get the configured movement axis (relative to camera's orientation) the
  19148. * mouse wheel's X axis controls.
  19149. * @returns The configured axis or null if none.
  19150. */
  19151. get wheelXMoveRelative(): Nullable<Coordinate>;
  19152. /**
  19153. * Set which movement axis (relative to camera's orientation) the mouse
  19154. * wheel's Y axis controls.
  19155. * @param axis The axis to be moved. Set null to clear.
  19156. */
  19157. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  19158. /**
  19159. * Get the configured movement axis (relative to camera's orientation) the
  19160. * mouse wheel's Y axis controls.
  19161. * @returns The configured axis or null if none.
  19162. */
  19163. get wheelYMoveRelative(): Nullable<Coordinate>;
  19164. /**
  19165. * Set which movement axis (relative to camera's orientation) the mouse
  19166. * wheel's Z axis controls.
  19167. * @param axis The axis to be moved. Set null to clear.
  19168. */
  19169. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  19170. /**
  19171. * Get the configured movement axis (relative to camera's orientation) the
  19172. * mouse wheel's Z axis controls.
  19173. * @returns The configured axis or null if none.
  19174. */
  19175. get wheelZMoveRelative(): Nullable<Coordinate>;
  19176. /**
  19177. * Set which rotation axis (relative to camera's orientation) the mouse
  19178. * wheel's X axis controls.
  19179. * @param axis The axis to be moved. Set null to clear.
  19180. */
  19181. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  19182. /**
  19183. * Get the configured rotation axis (relative to camera's orientation) the
  19184. * mouse wheel's X axis controls.
  19185. * @returns The configured axis or null if none.
  19186. */
  19187. get wheelXRotateRelative(): Nullable<Coordinate>;
  19188. /**
  19189. * Set which rotation axis (relative to camera's orientation) the mouse
  19190. * wheel's Y axis controls.
  19191. * @param axis The axis to be moved. Set null to clear.
  19192. */
  19193. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  19194. /**
  19195. * Get the configured rotation axis (relative to camera's orientation) the
  19196. * mouse wheel's Y axis controls.
  19197. * @returns The configured axis or null if none.
  19198. */
  19199. get wheelYRotateRelative(): Nullable<Coordinate>;
  19200. /**
  19201. * Set which rotation axis (relative to camera's orientation) the mouse
  19202. * wheel's Z axis controls.
  19203. * @param axis The axis to be moved. Set null to clear.
  19204. */
  19205. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  19206. /**
  19207. * Get the configured rotation axis (relative to camera's orientation) the
  19208. * mouse wheel's Z axis controls.
  19209. * @returns The configured axis or null if none.
  19210. */
  19211. get wheelZRotateRelative(): Nullable<Coordinate>;
  19212. /**
  19213. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  19214. * controls.
  19215. * @param axis The axis to be moved. Set null to clear.
  19216. */
  19217. set wheelXMoveScene(axis: Nullable<Coordinate>);
  19218. /**
  19219. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19220. * X axis controls.
  19221. * @returns The configured axis or null if none.
  19222. */
  19223. get wheelXMoveScene(): Nullable<Coordinate>;
  19224. /**
  19225. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  19226. * controls.
  19227. * @param axis The axis to be moved. Set null to clear.
  19228. */
  19229. set wheelYMoveScene(axis: Nullable<Coordinate>);
  19230. /**
  19231. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19232. * Y axis controls.
  19233. * @returns The configured axis or null if none.
  19234. */
  19235. get wheelYMoveScene(): Nullable<Coordinate>;
  19236. /**
  19237. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  19238. * controls.
  19239. * @param axis The axis to be moved. Set null to clear.
  19240. */
  19241. set wheelZMoveScene(axis: Nullable<Coordinate>);
  19242. /**
  19243. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19244. * Z axis controls.
  19245. * @returns The configured axis or null if none.
  19246. */
  19247. get wheelZMoveScene(): Nullable<Coordinate>;
  19248. /**
  19249. * Called for each rendered frame.
  19250. */
  19251. checkInputs(): void;
  19252. private _moveRelative;
  19253. private _rotateRelative;
  19254. private _moveScene;
  19255. /**
  19256. * These are set to the desired default behaviour.
  19257. */
  19258. private _wheelXAction;
  19259. private _wheelXActionCoordinate;
  19260. private _wheelYAction;
  19261. private _wheelYActionCoordinate;
  19262. private _wheelZAction;
  19263. private _wheelZActionCoordinate;
  19264. /**
  19265. * Update the camera according to any configured properties for the 3
  19266. * mouse-wheel axis.
  19267. */
  19268. private _updateCamera;
  19269. }
  19270. }
  19271. declare module BABYLON {
  19272. /**
  19273. * Manage the touch inputs to control the movement of a free camera.
  19274. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19275. */
  19276. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19277. /**
  19278. * Define if mouse events can be treated as touch events
  19279. */
  19280. allowMouse: boolean;
  19281. /**
  19282. * Defines the camera the input is attached to.
  19283. */
  19284. camera: FreeCamera;
  19285. /**
  19286. * Defines the touch sensibility for rotation.
  19287. * The higher the faster.
  19288. */
  19289. touchAngularSensibility: number;
  19290. /**
  19291. * Defines the touch sensibility for move.
  19292. * The higher the faster.
  19293. */
  19294. touchMoveSensibility: number;
  19295. private _offsetX;
  19296. private _offsetY;
  19297. private _pointerPressed;
  19298. private _pointerInput?;
  19299. private _observer;
  19300. private _onLostFocus;
  19301. /**
  19302. * Manage the touch inputs to control the movement of a free camera.
  19303. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19304. * @param allowMouse Defines if mouse events can be treated as touch events
  19305. */
  19306. constructor(
  19307. /**
  19308. * Define if mouse events can be treated as touch events
  19309. */
  19310. allowMouse?: boolean);
  19311. /**
  19312. * Attach the input controls to a specific dom element to get the input from.
  19313. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19314. */
  19315. attachControl(noPreventDefault?: boolean): void;
  19316. /**
  19317. * Detach the current controls from the specified dom element.
  19318. * @param element Defines the element to stop listening the inputs from
  19319. */
  19320. detachControl(): void;
  19321. /**
  19322. * Update the current camera state depending on the inputs that have been used this frame.
  19323. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19324. */
  19325. checkInputs(): void;
  19326. /**
  19327. * Gets the class name of the current intput.
  19328. * @returns the class name
  19329. */
  19330. getClassName(): string;
  19331. /**
  19332. * Get the friendly name associated with the input class.
  19333. * @returns the input friendly name
  19334. */
  19335. getSimpleName(): string;
  19336. }
  19337. }
  19338. declare module BABYLON {
  19339. /**
  19340. * Default Inputs manager for the FreeCamera.
  19341. * It groups all the default supported inputs for ease of use.
  19342. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19343. */
  19344. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19345. /**
  19346. * @hidden
  19347. */
  19348. _mouseInput: Nullable<FreeCameraMouseInput>;
  19349. /**
  19350. * @hidden
  19351. */
  19352. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  19353. /**
  19354. * Instantiates a new FreeCameraInputsManager.
  19355. * @param camera Defines the camera the inputs belong to
  19356. */
  19357. constructor(camera: FreeCamera);
  19358. /**
  19359. * Add keyboard input support to the input manager.
  19360. * @returns the current input manager
  19361. */
  19362. addKeyboard(): FreeCameraInputsManager;
  19363. /**
  19364. * Add mouse input support to the input manager.
  19365. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19366. * @returns the current input manager
  19367. */
  19368. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19369. /**
  19370. * Removes the mouse input support from the manager
  19371. * @returns the current input manager
  19372. */
  19373. removeMouse(): FreeCameraInputsManager;
  19374. /**
  19375. * Add mouse wheel input support to the input manager.
  19376. * @returns the current input manager
  19377. */
  19378. addMouseWheel(): FreeCameraInputsManager;
  19379. /**
  19380. * Removes the mouse wheel input support from the manager
  19381. * @returns the current input manager
  19382. */
  19383. removeMouseWheel(): FreeCameraInputsManager;
  19384. /**
  19385. * Add touch input support to the input manager.
  19386. * @returns the current input manager
  19387. */
  19388. addTouch(): FreeCameraInputsManager;
  19389. /**
  19390. * Remove all attached input methods from a camera
  19391. */
  19392. clear(): void;
  19393. }
  19394. }
  19395. declare module BABYLON {
  19396. /**
  19397. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19398. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19399. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19400. */
  19401. export class FreeCamera extends TargetCamera {
  19402. /**
  19403. * Define the collision ellipsoid of the camera.
  19404. * This is helpful to simulate a camera body like the player body around the camera
  19405. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19406. */
  19407. ellipsoid: Vector3;
  19408. /**
  19409. * Define an offset for the position of the ellipsoid around the camera.
  19410. * This can be helpful to determine the center of the body near the gravity center of the body
  19411. * instead of its head.
  19412. */
  19413. ellipsoidOffset: Vector3;
  19414. /**
  19415. * Enable or disable collisions of the camera with the rest of the scene objects.
  19416. */
  19417. checkCollisions: boolean;
  19418. /**
  19419. * Enable or disable gravity on the camera.
  19420. */
  19421. applyGravity: boolean;
  19422. /**
  19423. * Define the input manager associated to the camera.
  19424. */
  19425. inputs: FreeCameraInputsManager;
  19426. /**
  19427. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19428. * Higher values reduce sensitivity.
  19429. */
  19430. get angularSensibility(): number;
  19431. /**
  19432. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19433. * Higher values reduce sensitivity.
  19434. */
  19435. set angularSensibility(value: number);
  19436. /**
  19437. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19438. */
  19439. get keysUp(): number[];
  19440. set keysUp(value: number[]);
  19441. /**
  19442. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19443. */
  19444. get keysUpward(): number[];
  19445. set keysUpward(value: number[]);
  19446. /**
  19447. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19448. */
  19449. get keysDown(): number[];
  19450. set keysDown(value: number[]);
  19451. /**
  19452. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19453. */
  19454. get keysDownward(): number[];
  19455. set keysDownward(value: number[]);
  19456. /**
  19457. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19458. */
  19459. get keysLeft(): number[];
  19460. set keysLeft(value: number[]);
  19461. /**
  19462. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19463. */
  19464. get keysRight(): number[];
  19465. set keysRight(value: number[]);
  19466. /**
  19467. * Event raised when the camera collide with a mesh in the scene.
  19468. */
  19469. onCollide: (collidedMesh: AbstractMesh) => void;
  19470. private _collider;
  19471. private _needMoveForGravity;
  19472. private _oldPosition;
  19473. private _diffPosition;
  19474. private _newPosition;
  19475. /** @hidden */
  19476. _localDirection: Vector3;
  19477. /** @hidden */
  19478. _transformedDirection: Vector3;
  19479. /**
  19480. * Instantiates a Free Camera.
  19481. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19482. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19483. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19484. * @param name Define the name of the camera in the scene
  19485. * @param position Define the start position of the camera in the scene
  19486. * @param scene Define the scene the camera belongs to
  19487. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19488. */
  19489. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19490. /**
  19491. * Attached controls to the current camera.
  19492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19493. */
  19494. attachControl(noPreventDefault?: boolean): void;
  19495. /**
  19496. * Detach the current controls from the camera.
  19497. * The camera will stop reacting to inputs.
  19498. */
  19499. detachControl(): void;
  19500. private _collisionMask;
  19501. /**
  19502. * Define a collision mask to limit the list of object the camera can collide with
  19503. */
  19504. get collisionMask(): number;
  19505. set collisionMask(mask: number);
  19506. /** @hidden */
  19507. _collideWithWorld(displacement: Vector3): void;
  19508. private _onCollisionPositionChange;
  19509. /** @hidden */
  19510. _checkInputs(): void;
  19511. /** @hidden */
  19512. _decideIfNeedsToMove(): boolean;
  19513. /** @hidden */
  19514. _updatePosition(): void;
  19515. /**
  19516. * Destroy the camera and release the current resources hold by it.
  19517. */
  19518. dispose(): void;
  19519. /**
  19520. * Gets the current object class name.
  19521. * @return the class name
  19522. */
  19523. getClassName(): string;
  19524. }
  19525. }
  19526. declare module BABYLON {
  19527. /**
  19528. * Represents a gamepad control stick position
  19529. */
  19530. export class StickValues {
  19531. /**
  19532. * The x component of the control stick
  19533. */
  19534. x: number;
  19535. /**
  19536. * The y component of the control stick
  19537. */
  19538. y: number;
  19539. /**
  19540. * Initializes the gamepad x and y control stick values
  19541. * @param x The x component of the gamepad control stick value
  19542. * @param y The y component of the gamepad control stick value
  19543. */
  19544. constructor(
  19545. /**
  19546. * The x component of the control stick
  19547. */
  19548. x: number,
  19549. /**
  19550. * The y component of the control stick
  19551. */
  19552. y: number);
  19553. }
  19554. /**
  19555. * An interface which manages callbacks for gamepad button changes
  19556. */
  19557. export interface GamepadButtonChanges {
  19558. /**
  19559. * Called when a gamepad has been changed
  19560. */
  19561. changed: boolean;
  19562. /**
  19563. * Called when a gamepad press event has been triggered
  19564. */
  19565. pressChanged: boolean;
  19566. /**
  19567. * Called when a touch event has been triggered
  19568. */
  19569. touchChanged: boolean;
  19570. /**
  19571. * Called when a value has changed
  19572. */
  19573. valueChanged: boolean;
  19574. }
  19575. /**
  19576. * Represents a gamepad
  19577. */
  19578. export class Gamepad {
  19579. /**
  19580. * The id of the gamepad
  19581. */
  19582. id: string;
  19583. /**
  19584. * The index of the gamepad
  19585. */
  19586. index: number;
  19587. /**
  19588. * The browser gamepad
  19589. */
  19590. browserGamepad: any;
  19591. /**
  19592. * Specifies what type of gamepad this represents
  19593. */
  19594. type: number;
  19595. private _leftStick;
  19596. private _rightStick;
  19597. /** @hidden */
  19598. _isConnected: boolean;
  19599. private _leftStickAxisX;
  19600. private _leftStickAxisY;
  19601. private _rightStickAxisX;
  19602. private _rightStickAxisY;
  19603. /**
  19604. * Triggered when the left control stick has been changed
  19605. */
  19606. private _onleftstickchanged;
  19607. /**
  19608. * Triggered when the right control stick has been changed
  19609. */
  19610. private _onrightstickchanged;
  19611. /**
  19612. * Represents a gamepad controller
  19613. */
  19614. static GAMEPAD: number;
  19615. /**
  19616. * Represents a generic controller
  19617. */
  19618. static GENERIC: number;
  19619. /**
  19620. * Represents an XBox controller
  19621. */
  19622. static XBOX: number;
  19623. /**
  19624. * Represents a pose-enabled controller
  19625. */
  19626. static POSE_ENABLED: number;
  19627. /**
  19628. * Represents an Dual Shock controller
  19629. */
  19630. static DUALSHOCK: number;
  19631. /**
  19632. * Specifies whether the left control stick should be Y-inverted
  19633. */
  19634. protected _invertLeftStickY: boolean;
  19635. /**
  19636. * Specifies if the gamepad has been connected
  19637. */
  19638. get isConnected(): boolean;
  19639. /**
  19640. * Initializes the gamepad
  19641. * @param id The id of the gamepad
  19642. * @param index The index of the gamepad
  19643. * @param browserGamepad The browser gamepad
  19644. * @param leftStickX The x component of the left joystick
  19645. * @param leftStickY The y component of the left joystick
  19646. * @param rightStickX The x component of the right joystick
  19647. * @param rightStickY The y component of the right joystick
  19648. */
  19649. constructor(
  19650. /**
  19651. * The id of the gamepad
  19652. */
  19653. id: string,
  19654. /**
  19655. * The index of the gamepad
  19656. */
  19657. index: number,
  19658. /**
  19659. * The browser gamepad
  19660. */
  19661. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19662. /**
  19663. * Callback triggered when the left joystick has changed
  19664. * @param callback
  19665. */
  19666. onleftstickchanged(callback: (values: StickValues) => void): void;
  19667. /**
  19668. * Callback triggered when the right joystick has changed
  19669. * @param callback
  19670. */
  19671. onrightstickchanged(callback: (values: StickValues) => void): void;
  19672. /**
  19673. * Gets the left joystick
  19674. */
  19675. get leftStick(): StickValues;
  19676. /**
  19677. * Sets the left joystick values
  19678. */
  19679. set leftStick(newValues: StickValues);
  19680. /**
  19681. * Gets the right joystick
  19682. */
  19683. get rightStick(): StickValues;
  19684. /**
  19685. * Sets the right joystick value
  19686. */
  19687. set rightStick(newValues: StickValues);
  19688. /**
  19689. * Updates the gamepad joystick positions
  19690. */
  19691. update(): void;
  19692. /**
  19693. * Disposes the gamepad
  19694. */
  19695. dispose(): void;
  19696. }
  19697. /**
  19698. * Represents a generic gamepad
  19699. */
  19700. export class GenericPad extends Gamepad {
  19701. private _buttons;
  19702. private _onbuttondown;
  19703. private _onbuttonup;
  19704. /**
  19705. * Observable triggered when a button has been pressed
  19706. */
  19707. onButtonDownObservable: Observable<number>;
  19708. /**
  19709. * Observable triggered when a button has been released
  19710. */
  19711. onButtonUpObservable: Observable<number>;
  19712. /**
  19713. * Callback triggered when a button has been pressed
  19714. * @param callback Called when a button has been pressed
  19715. */
  19716. onbuttondown(callback: (buttonPressed: number) => void): void;
  19717. /**
  19718. * Callback triggered when a button has been released
  19719. * @param callback Called when a button has been released
  19720. */
  19721. onbuttonup(callback: (buttonReleased: number) => void): void;
  19722. /**
  19723. * Initializes the generic gamepad
  19724. * @param id The id of the generic gamepad
  19725. * @param index The index of the generic gamepad
  19726. * @param browserGamepad The browser gamepad
  19727. */
  19728. constructor(id: string, index: number, browserGamepad: any);
  19729. private _setButtonValue;
  19730. /**
  19731. * Updates the generic gamepad
  19732. */
  19733. update(): void;
  19734. /**
  19735. * Disposes the generic gamepad
  19736. */
  19737. dispose(): void;
  19738. }
  19739. }
  19740. declare module BABYLON {
  19741. /**
  19742. * Defines the types of pose enabled controllers that are supported
  19743. */
  19744. export enum PoseEnabledControllerType {
  19745. /**
  19746. * HTC Vive
  19747. */
  19748. VIVE = 0,
  19749. /**
  19750. * Oculus Rift
  19751. */
  19752. OCULUS = 1,
  19753. /**
  19754. * Windows mixed reality
  19755. */
  19756. WINDOWS = 2,
  19757. /**
  19758. * Samsung gear VR
  19759. */
  19760. GEAR_VR = 3,
  19761. /**
  19762. * Google Daydream
  19763. */
  19764. DAYDREAM = 4,
  19765. /**
  19766. * Generic
  19767. */
  19768. GENERIC = 5
  19769. }
  19770. /**
  19771. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19772. */
  19773. export interface MutableGamepadButton {
  19774. /**
  19775. * Value of the button/trigger
  19776. */
  19777. value: number;
  19778. /**
  19779. * If the button/trigger is currently touched
  19780. */
  19781. touched: boolean;
  19782. /**
  19783. * If the button/trigger is currently pressed
  19784. */
  19785. pressed: boolean;
  19786. }
  19787. /**
  19788. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19789. * @hidden
  19790. */
  19791. export interface ExtendedGamepadButton extends GamepadButton {
  19792. /**
  19793. * If the button/trigger is currently pressed
  19794. */
  19795. readonly pressed: boolean;
  19796. /**
  19797. * If the button/trigger is currently touched
  19798. */
  19799. readonly touched: boolean;
  19800. /**
  19801. * Value of the button/trigger
  19802. */
  19803. readonly value: number;
  19804. }
  19805. /** @hidden */
  19806. export interface _GamePadFactory {
  19807. /**
  19808. * Returns whether or not the current gamepad can be created for this type of controller.
  19809. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19810. * @returns true if it can be created, otherwise false
  19811. */
  19812. canCreate(gamepadInfo: any): boolean;
  19813. /**
  19814. * Creates a new instance of the Gamepad.
  19815. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19816. * @returns the new gamepad instance
  19817. */
  19818. create(gamepadInfo: any): Gamepad;
  19819. }
  19820. /**
  19821. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19822. */
  19823. export class PoseEnabledControllerHelper {
  19824. /** @hidden */
  19825. static _ControllerFactories: _GamePadFactory[];
  19826. /** @hidden */
  19827. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19828. /**
  19829. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19830. * @param vrGamepad the gamepad to initialized
  19831. * @returns a vr controller of the type the gamepad identified as
  19832. */
  19833. static InitiateController(vrGamepad: any): Gamepad;
  19834. }
  19835. /**
  19836. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19837. */
  19838. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19839. /**
  19840. * If the controller is used in a webXR session
  19841. */
  19842. isXR: boolean;
  19843. private _deviceRoomPosition;
  19844. private _deviceRoomRotationQuaternion;
  19845. /**
  19846. * The device position in babylon space
  19847. */
  19848. devicePosition: Vector3;
  19849. /**
  19850. * The device rotation in babylon space
  19851. */
  19852. deviceRotationQuaternion: Quaternion;
  19853. /**
  19854. * The scale factor of the device in babylon space
  19855. */
  19856. deviceScaleFactor: number;
  19857. /**
  19858. * (Likely devicePosition should be used instead) The device position in its room space
  19859. */
  19860. position: Vector3;
  19861. /**
  19862. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19863. */
  19864. rotationQuaternion: Quaternion;
  19865. /**
  19866. * The type of controller (Eg. Windows mixed reality)
  19867. */
  19868. controllerType: PoseEnabledControllerType;
  19869. protected _calculatedPosition: Vector3;
  19870. private _calculatedRotation;
  19871. /**
  19872. * The raw pose from the device
  19873. */
  19874. rawPose: DevicePose;
  19875. private _trackPosition;
  19876. private _maxRotationDistFromHeadset;
  19877. private _draggedRoomRotation;
  19878. /**
  19879. * @hidden
  19880. */
  19881. _disableTrackPosition(fixedPosition: Vector3): void;
  19882. /**
  19883. * Internal, the mesh attached to the controller
  19884. * @hidden
  19885. */
  19886. _mesh: Nullable<AbstractMesh>;
  19887. private _poseControlledCamera;
  19888. private _leftHandSystemQuaternion;
  19889. /**
  19890. * Internal, matrix used to convert room space to babylon space
  19891. * @hidden
  19892. */
  19893. _deviceToWorld: Matrix;
  19894. /**
  19895. * Node to be used when casting a ray from the controller
  19896. * @hidden
  19897. */
  19898. _pointingPoseNode: Nullable<TransformNode>;
  19899. /**
  19900. * Name of the child mesh that can be used to cast a ray from the controller
  19901. */
  19902. static readonly POINTING_POSE: string;
  19903. /**
  19904. * Creates a new PoseEnabledController from a gamepad
  19905. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19906. */
  19907. constructor(browserGamepad: any);
  19908. private _workingMatrix;
  19909. /**
  19910. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19911. */
  19912. update(): void;
  19913. /**
  19914. * Updates only the pose device and mesh without doing any button event checking
  19915. */
  19916. protected _updatePoseAndMesh(): void;
  19917. /**
  19918. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19919. * @param poseData raw pose fromthe device
  19920. */
  19921. updateFromDevice(poseData: DevicePose): void;
  19922. /**
  19923. * @hidden
  19924. */
  19925. _meshAttachedObservable: Observable<AbstractMesh>;
  19926. /**
  19927. * Attaches a mesh to the controller
  19928. * @param mesh the mesh to be attached
  19929. */
  19930. attachToMesh(mesh: AbstractMesh): void;
  19931. /**
  19932. * Attaches the controllers mesh to a camera
  19933. * @param camera the camera the mesh should be attached to
  19934. */
  19935. attachToPoseControlledCamera(camera: TargetCamera): void;
  19936. /**
  19937. * Disposes of the controller
  19938. */
  19939. dispose(): void;
  19940. /**
  19941. * The mesh that is attached to the controller
  19942. */
  19943. get mesh(): Nullable<AbstractMesh>;
  19944. /**
  19945. * Gets the ray of the controller in the direction the controller is pointing
  19946. * @param length the length the resulting ray should be
  19947. * @returns a ray in the direction the controller is pointing
  19948. */
  19949. getForwardRay(length?: number): Ray;
  19950. }
  19951. }
  19952. declare module BABYLON {
  19953. /**
  19954. * Defines the WebVRController object that represents controllers tracked in 3D space
  19955. */
  19956. export abstract class WebVRController extends PoseEnabledController {
  19957. /**
  19958. * Internal, the default controller model for the controller
  19959. */
  19960. protected _defaultModel: Nullable<AbstractMesh>;
  19961. /**
  19962. * Fired when the trigger state has changed
  19963. */
  19964. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19965. /**
  19966. * Fired when the main button state has changed
  19967. */
  19968. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19969. /**
  19970. * Fired when the secondary button state has changed
  19971. */
  19972. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19973. /**
  19974. * Fired when the pad state has changed
  19975. */
  19976. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19977. /**
  19978. * Fired when controllers stick values have changed
  19979. */
  19980. onPadValuesChangedObservable: Observable<StickValues>;
  19981. /**
  19982. * Array of button availible on the controller
  19983. */
  19984. protected _buttons: Array<MutableGamepadButton>;
  19985. private _onButtonStateChange;
  19986. /**
  19987. * Fired when a controller button's state has changed
  19988. * @param callback the callback containing the button that was modified
  19989. */
  19990. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19991. /**
  19992. * X and Y axis corresponding to the controllers joystick
  19993. */
  19994. pad: StickValues;
  19995. /**
  19996. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19997. */
  19998. hand: string;
  19999. /**
  20000. * The default controller model for the controller
  20001. */
  20002. get defaultModel(): Nullable<AbstractMesh>;
  20003. /**
  20004. * Creates a new WebVRController from a gamepad
  20005. * @param vrGamepad the gamepad that the WebVRController should be created from
  20006. */
  20007. constructor(vrGamepad: any);
  20008. /**
  20009. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20010. */
  20011. update(): void;
  20012. /**
  20013. * Function to be called when a button is modified
  20014. */
  20015. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20016. /**
  20017. * Loads a mesh and attaches it to the controller
  20018. * @param scene the scene the mesh should be added to
  20019. * @param meshLoaded callback for when the mesh has been loaded
  20020. */
  20021. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20022. private _setButtonValue;
  20023. private _changes;
  20024. private _checkChanges;
  20025. /**
  20026. * Disposes of th webVRCOntroller
  20027. */
  20028. dispose(): void;
  20029. }
  20030. }
  20031. declare module BABYLON {
  20032. /**
  20033. * The HemisphericLight simulates the ambient environment light,
  20034. * so the passed direction is the light reflection direction, not the incoming direction.
  20035. */
  20036. export class HemisphericLight extends Light {
  20037. /**
  20038. * The groundColor is the light in the opposite direction to the one specified during creation.
  20039. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  20040. */
  20041. groundColor: Color3;
  20042. /**
  20043. * The light reflection direction, not the incoming direction.
  20044. */
  20045. direction: Vector3;
  20046. /**
  20047. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20048. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20049. * The HemisphericLight can't cast shadows.
  20050. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20051. * @param name The friendly name of the light
  20052. * @param direction The direction of the light reflection
  20053. * @param scene The scene the light belongs to
  20054. */
  20055. constructor(name: string, direction: Vector3, scene: Scene);
  20056. protected _buildUniformLayout(): void;
  20057. /**
  20058. * Returns the string "HemisphericLight".
  20059. * @return The class name
  20060. */
  20061. getClassName(): string;
  20062. /**
  20063. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20064. * Returns the updated direction.
  20065. * @param target The target the direction should point to
  20066. * @return The computed direction
  20067. */
  20068. setDirectionToTarget(target: Vector3): Vector3;
  20069. /**
  20070. * Returns the shadow generator associated to the light.
  20071. * @returns Always null for hemispheric lights because it does not support shadows.
  20072. */
  20073. getShadowGenerator(): Nullable<IShadowGenerator>;
  20074. /**
  20075. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20076. * @param effect The effect to update
  20077. * @param lightIndex The index of the light in the effect to update
  20078. * @returns The hemispheric light
  20079. */
  20080. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20081. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20082. /**
  20083. * Computes the world matrix of the node
  20084. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20085. * @param useWasUpdatedFlag defines a reserved property
  20086. * @returns the world matrix
  20087. */
  20088. computeWorldMatrix(): Matrix;
  20089. /**
  20090. * Returns the integer 3.
  20091. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20092. */
  20093. getTypeID(): number;
  20094. /**
  20095. * Prepares the list of defines specific to the light type.
  20096. * @param defines the list of defines
  20097. * @param lightIndex defines the index of the light for the effect
  20098. */
  20099. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20100. }
  20101. }
  20102. declare module BABYLON {
  20103. /** @hidden */
  20104. export var vrMultiviewToSingleviewPixelShader: {
  20105. name: string;
  20106. shader: string;
  20107. };
  20108. }
  20109. declare module BABYLON {
  20110. /**
  20111. * Renders to multiple views with a single draw call
  20112. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20113. */
  20114. export class MultiviewRenderTarget extends RenderTargetTexture {
  20115. /**
  20116. * Creates a multiview render target
  20117. * @param scene scene used with the render target
  20118. * @param size the size of the render target (used for each view)
  20119. */
  20120. constructor(scene: Scene, size?: number | {
  20121. width: number;
  20122. height: number;
  20123. } | {
  20124. ratio: number;
  20125. });
  20126. /**
  20127. * @hidden
  20128. * @param faceIndex the face index, if its a cube texture
  20129. */
  20130. _bindFrameBuffer(faceIndex?: number): void;
  20131. /**
  20132. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20133. * @returns the view count
  20134. */
  20135. getViewCount(): number;
  20136. }
  20137. }
  20138. declare module BABYLON {
  20139. interface Engine {
  20140. /**
  20141. * Creates a new multiview render target
  20142. * @param width defines the width of the texture
  20143. * @param height defines the height of the texture
  20144. * @returns the created multiview texture
  20145. */
  20146. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20147. /**
  20148. * Binds a multiview framebuffer to be drawn to
  20149. * @param multiviewTexture texture to bind
  20150. */
  20151. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20152. }
  20153. interface Camera {
  20154. /**
  20155. * @hidden
  20156. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  20157. */
  20158. _useMultiviewToSingleView: boolean;
  20159. /**
  20160. * @hidden
  20161. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  20162. */
  20163. _multiviewTexture: Nullable<RenderTargetTexture>;
  20164. /**
  20165. * @hidden
  20166. * ensures the multiview texture of the camera exists and has the specified width/height
  20167. * @param width height to set on the multiview texture
  20168. * @param height width to set on the multiview texture
  20169. */
  20170. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20171. }
  20172. interface Scene {
  20173. /** @hidden */
  20174. _transformMatrixR: Matrix;
  20175. /** @hidden */
  20176. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20177. /** @hidden */
  20178. _createMultiviewUbo(): void;
  20179. /** @hidden */
  20180. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20181. /** @hidden */
  20182. _renderMultiviewToSingleView(camera: Camera): void;
  20183. }
  20184. }
  20185. declare module BABYLON {
  20186. /**
  20187. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20188. * This will not be used for webXR as it supports displaying texture arrays directly
  20189. */
  20190. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20191. /**
  20192. * Gets a string identifying the name of the class
  20193. * @returns "VRMultiviewToSingleviewPostProcess" string
  20194. */
  20195. getClassName(): string;
  20196. /**
  20197. * Initializes a VRMultiviewToSingleview
  20198. * @param name name of the post process
  20199. * @param camera camera to be applied to
  20200. * @param scaleFactor scaling factor to the size of the output texture
  20201. */
  20202. constructor(name: string, camera: Camera, scaleFactor: number);
  20203. }
  20204. }
  20205. declare module BABYLON {
  20206. /**
  20207. * Interface used to define additional presentation attributes
  20208. */
  20209. export interface IVRPresentationAttributes {
  20210. /**
  20211. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20212. */
  20213. highRefreshRate: boolean;
  20214. /**
  20215. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20216. */
  20217. foveationLevel: number;
  20218. }
  20219. interface Engine {
  20220. /** @hidden */
  20221. _vrDisplay: any;
  20222. /** @hidden */
  20223. _vrSupported: boolean;
  20224. /** @hidden */
  20225. _oldSize: Size;
  20226. /** @hidden */
  20227. _oldHardwareScaleFactor: number;
  20228. /** @hidden */
  20229. _vrExclusivePointerMode: boolean;
  20230. /** @hidden */
  20231. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20232. /** @hidden */
  20233. _onVRDisplayPointerRestricted: () => void;
  20234. /** @hidden */
  20235. _onVRDisplayPointerUnrestricted: () => void;
  20236. /** @hidden */
  20237. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20238. /** @hidden */
  20239. _onVrDisplayDisconnect: Nullable<() => void>;
  20240. /** @hidden */
  20241. _onVrDisplayPresentChange: Nullable<() => void>;
  20242. /**
  20243. * Observable signaled when VR display mode changes
  20244. */
  20245. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20246. /**
  20247. * Observable signaled when VR request present is complete
  20248. */
  20249. onVRRequestPresentComplete: Observable<boolean>;
  20250. /**
  20251. * Observable signaled when VR request present starts
  20252. */
  20253. onVRRequestPresentStart: Observable<Engine>;
  20254. /**
  20255. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20256. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20257. */
  20258. isInVRExclusivePointerMode: boolean;
  20259. /**
  20260. * Gets a boolean indicating if a webVR device was detected
  20261. * @returns true if a webVR device was detected
  20262. */
  20263. isVRDevicePresent(): boolean;
  20264. /**
  20265. * Gets the current webVR device
  20266. * @returns the current webVR device (or null)
  20267. */
  20268. getVRDevice(): any;
  20269. /**
  20270. * Initializes a webVR display and starts listening to display change events
  20271. * The onVRDisplayChangedObservable will be notified upon these changes
  20272. * @returns A promise containing a VRDisplay and if vr is supported
  20273. */
  20274. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20275. /** @hidden */
  20276. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20277. /**
  20278. * Gets or sets the presentation attributes used to configure VR rendering
  20279. */
  20280. vrPresentationAttributes?: IVRPresentationAttributes;
  20281. /**
  20282. * Call this function to switch to webVR mode
  20283. * Will do nothing if webVR is not supported or if there is no webVR device
  20284. * @param options the webvr options provided to the camera. mainly used for multiview
  20285. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20286. */
  20287. enableVR(options: WebVROptions): void;
  20288. /** @hidden */
  20289. _onVRFullScreenTriggered(): void;
  20290. }
  20291. }
  20292. declare module BABYLON {
  20293. /**
  20294. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20295. * IMPORTANT!! The data is right-hand data.
  20296. * @export
  20297. * @interface DevicePose
  20298. */
  20299. export interface DevicePose {
  20300. /**
  20301. * The position of the device, values in array are [x,y,z].
  20302. */
  20303. readonly position: Nullable<Float32Array>;
  20304. /**
  20305. * The linearVelocity of the device, values in array are [x,y,z].
  20306. */
  20307. readonly linearVelocity: Nullable<Float32Array>;
  20308. /**
  20309. * The linearAcceleration of the device, values in array are [x,y,z].
  20310. */
  20311. readonly linearAcceleration: Nullable<Float32Array>;
  20312. /**
  20313. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20314. */
  20315. readonly orientation: Nullable<Float32Array>;
  20316. /**
  20317. * The angularVelocity of the device, values in array are [x,y,z].
  20318. */
  20319. readonly angularVelocity: Nullable<Float32Array>;
  20320. /**
  20321. * The angularAcceleration of the device, values in array are [x,y,z].
  20322. */
  20323. readonly angularAcceleration: Nullable<Float32Array>;
  20324. }
  20325. /**
  20326. * Interface representing a pose controlled object in Babylon.
  20327. * A pose controlled object has both regular pose values as well as pose values
  20328. * from an external device such as a VR head mounted display
  20329. */
  20330. export interface PoseControlled {
  20331. /**
  20332. * The position of the object in babylon space.
  20333. */
  20334. position: Vector3;
  20335. /**
  20336. * The rotation quaternion of the object in babylon space.
  20337. */
  20338. rotationQuaternion: Quaternion;
  20339. /**
  20340. * The position of the device in babylon space.
  20341. */
  20342. devicePosition?: Vector3;
  20343. /**
  20344. * The rotation quaternion of the device in babylon space.
  20345. */
  20346. deviceRotationQuaternion: Quaternion;
  20347. /**
  20348. * The raw pose coming from the device.
  20349. */
  20350. rawPose: Nullable<DevicePose>;
  20351. /**
  20352. * The scale of the device to be used when translating from device space to babylon space.
  20353. */
  20354. deviceScaleFactor: number;
  20355. /**
  20356. * Updates the poseControlled values based on the input device pose.
  20357. * @param poseData the pose data to update the object with
  20358. */
  20359. updateFromDevice(poseData: DevicePose): void;
  20360. }
  20361. /**
  20362. * Set of options to customize the webVRCamera
  20363. */
  20364. export interface WebVROptions {
  20365. /**
  20366. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20367. */
  20368. trackPosition?: boolean;
  20369. /**
  20370. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20371. */
  20372. positionScale?: number;
  20373. /**
  20374. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20375. */
  20376. displayName?: string;
  20377. /**
  20378. * Should the native controller meshes be initialized. (default: true)
  20379. */
  20380. controllerMeshes?: boolean;
  20381. /**
  20382. * Creating a default HemiLight only on controllers. (default: true)
  20383. */
  20384. defaultLightingOnControllers?: boolean;
  20385. /**
  20386. * If you don't want to use the default VR button of the helper. (default: false)
  20387. */
  20388. useCustomVRButton?: boolean;
  20389. /**
  20390. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20391. */
  20392. customVRButton?: HTMLButtonElement;
  20393. /**
  20394. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20395. */
  20396. rayLength?: number;
  20397. /**
  20398. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20399. */
  20400. defaultHeight?: number;
  20401. /**
  20402. * If multiview should be used if availible (default: false)
  20403. */
  20404. useMultiview?: boolean;
  20405. }
  20406. /**
  20407. * This represents a WebVR camera.
  20408. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20409. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20410. */
  20411. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20412. private webVROptions;
  20413. /**
  20414. * @hidden
  20415. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20416. */
  20417. _vrDevice: any;
  20418. /**
  20419. * The rawPose of the vrDevice.
  20420. */
  20421. rawPose: Nullable<DevicePose>;
  20422. private _onVREnabled;
  20423. private _specsVersion;
  20424. private _attached;
  20425. private _frameData;
  20426. protected _descendants: Array<Node>;
  20427. private _deviceRoomPosition;
  20428. /** @hidden */
  20429. _deviceRoomRotationQuaternion: Quaternion;
  20430. private _standingMatrix;
  20431. /**
  20432. * Represents device position in babylon space.
  20433. */
  20434. devicePosition: Vector3;
  20435. /**
  20436. * Represents device rotation in babylon space.
  20437. */
  20438. deviceRotationQuaternion: Quaternion;
  20439. /**
  20440. * The scale of the device to be used when translating from device space to babylon space.
  20441. */
  20442. deviceScaleFactor: number;
  20443. private _deviceToWorld;
  20444. private _worldToDevice;
  20445. /**
  20446. * References to the webVR controllers for the vrDevice.
  20447. */
  20448. controllers: Array<WebVRController>;
  20449. /**
  20450. * Emits an event when a controller is attached.
  20451. */
  20452. onControllersAttachedObservable: Observable<WebVRController[]>;
  20453. /**
  20454. * Emits an event when a controller's mesh has been loaded;
  20455. */
  20456. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20457. /**
  20458. * Emits an event when the HMD's pose has been updated.
  20459. */
  20460. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20461. private _poseSet;
  20462. /**
  20463. * If the rig cameras be used as parent instead of this camera.
  20464. */
  20465. rigParenting: boolean;
  20466. private _lightOnControllers;
  20467. private _defaultHeight?;
  20468. /**
  20469. * Instantiates a WebVRFreeCamera.
  20470. * @param name The name of the WebVRFreeCamera
  20471. * @param position The starting anchor position for the camera
  20472. * @param scene The scene the camera belongs to
  20473. * @param webVROptions a set of customizable options for the webVRCamera
  20474. */
  20475. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20476. /**
  20477. * Gets the device distance from the ground in meters.
  20478. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  20479. */
  20480. deviceDistanceToRoomGround(): number;
  20481. /**
  20482. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20483. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20484. */
  20485. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20486. /**
  20487. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20488. * @returns A promise with a boolean set to if the standing matrix is supported.
  20489. */
  20490. useStandingMatrixAsync(): Promise<boolean>;
  20491. /**
  20492. * Disposes the camera
  20493. */
  20494. dispose(): void;
  20495. /**
  20496. * Gets a vrController by name.
  20497. * @param name The name of the controller to retreive
  20498. * @returns the controller matching the name specified or null if not found
  20499. */
  20500. getControllerByName(name: string): Nullable<WebVRController>;
  20501. private _leftController;
  20502. /**
  20503. * The controller corresponding to the users left hand.
  20504. */
  20505. get leftController(): Nullable<WebVRController>;
  20506. private _rightController;
  20507. /**
  20508. * The controller corresponding to the users right hand.
  20509. */
  20510. get rightController(): Nullable<WebVRController>;
  20511. /**
  20512. * Casts a ray forward from the vrCamera's gaze.
  20513. * @param length Length of the ray (default: 100)
  20514. * @returns the ray corresponding to the gaze
  20515. */
  20516. getForwardRay(length?: number): Ray;
  20517. /**
  20518. * @hidden
  20519. * Updates the camera based on device's frame data
  20520. */
  20521. _checkInputs(): void;
  20522. /**
  20523. * Updates the poseControlled values based on the input device pose.
  20524. * @param poseData Pose coming from the device
  20525. */
  20526. updateFromDevice(poseData: DevicePose): void;
  20527. private _detachIfAttached;
  20528. /**
  20529. * WebVR's attach control will start broadcasting frames to the device.
  20530. * Note that in certain browsers (chrome for example) this function must be called
  20531. * within a user-interaction callback. Example:
  20532. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20533. *
  20534. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20535. */
  20536. attachControl(noPreventDefault?: boolean): void;
  20537. /**
  20538. * Detaches the camera from the html element and disables VR
  20539. */
  20540. detachControl(): void;
  20541. /**
  20542. * @returns the name of this class
  20543. */
  20544. getClassName(): string;
  20545. /**
  20546. * Calls resetPose on the vrDisplay
  20547. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20548. */
  20549. resetToCurrentRotation(): void;
  20550. /**
  20551. * @hidden
  20552. * Updates the rig cameras (left and right eye)
  20553. */
  20554. _updateRigCameras(): void;
  20555. private _workingVector;
  20556. private _oneVector;
  20557. private _workingMatrix;
  20558. private updateCacheCalled;
  20559. private _correctPositionIfNotTrackPosition;
  20560. /**
  20561. * @hidden
  20562. * Updates the cached values of the camera
  20563. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20564. */
  20565. _updateCache(ignoreParentClass?: boolean): void;
  20566. /**
  20567. * @hidden
  20568. * Get current device position in babylon world
  20569. */
  20570. _computeDevicePosition(): void;
  20571. /**
  20572. * Updates the current device position and rotation in the babylon world
  20573. */
  20574. update(): void;
  20575. /**
  20576. * @hidden
  20577. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20578. * @returns an identity matrix
  20579. */
  20580. _getViewMatrix(): Matrix;
  20581. private _tmpMatrix;
  20582. /**
  20583. * This function is called by the two RIG cameras.
  20584. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20585. * @hidden
  20586. */
  20587. _getWebVRViewMatrix(): Matrix;
  20588. /** @hidden */
  20589. _getWebVRProjectionMatrix(): Matrix;
  20590. private _onGamepadConnectedObserver;
  20591. private _onGamepadDisconnectedObserver;
  20592. private _updateCacheWhenTrackingDisabledObserver;
  20593. /**
  20594. * Initializes the controllers and their meshes
  20595. */
  20596. initControllers(): void;
  20597. }
  20598. }
  20599. declare module BABYLON {
  20600. /**
  20601. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20602. *
  20603. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20604. *
  20605. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20606. */
  20607. export class MaterialHelper {
  20608. /**
  20609. * Bind the current view position to an effect.
  20610. * @param effect The effect to be bound
  20611. * @param scene The scene the eyes position is used from
  20612. * @param variableName name of the shader variable that will hold the eye position
  20613. */
  20614. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20615. /**
  20616. * Helps preparing the defines values about the UVs in used in the effect.
  20617. * UVs are shared as much as we can accross channels in the shaders.
  20618. * @param texture The texture we are preparing the UVs for
  20619. * @param defines The defines to update
  20620. * @param key The channel key "diffuse", "specular"... used in the shader
  20621. */
  20622. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20623. /**
  20624. * Binds a texture matrix value to its corrsponding uniform
  20625. * @param texture The texture to bind the matrix for
  20626. * @param uniformBuffer The uniform buffer receivin the data
  20627. * @param key The channel key "diffuse", "specular"... used in the shader
  20628. */
  20629. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20630. /**
  20631. * Gets the current status of the fog (should it be enabled?)
  20632. * @param mesh defines the mesh to evaluate for fog support
  20633. * @param scene defines the hosting scene
  20634. * @returns true if fog must be enabled
  20635. */
  20636. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20637. /**
  20638. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20639. * @param mesh defines the current mesh
  20640. * @param scene defines the current scene
  20641. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20642. * @param pointsCloud defines if point cloud rendering has to be turned on
  20643. * @param fogEnabled defines if fog has to be turned on
  20644. * @param alphaTest defines if alpha testing has to be turned on
  20645. * @param defines defines the current list of defines
  20646. */
  20647. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20648. /**
  20649. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20650. * @param scene defines the current scene
  20651. * @param engine defines the current engine
  20652. * @param defines specifies the list of active defines
  20653. * @param useInstances defines if instances have to be turned on
  20654. * @param useClipPlane defines if clip plane have to be turned on
  20655. * @param useInstances defines if instances have to be turned on
  20656. * @param useThinInstances defines if thin instances have to be turned on
  20657. */
  20658. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20659. /**
  20660. * Prepares the defines for bones
  20661. * @param mesh The mesh containing the geometry data we will draw
  20662. * @param defines The defines to update
  20663. */
  20664. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20665. /**
  20666. * Prepares the defines for morph targets
  20667. * @param mesh The mesh containing the geometry data we will draw
  20668. * @param defines The defines to update
  20669. */
  20670. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20671. /**
  20672. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20673. * @param mesh The mesh containing the geometry data we will draw
  20674. * @param defines The defines to update
  20675. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20676. * @param useBones Precise whether bones should be used or not (override mesh info)
  20677. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20678. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20679. * @returns false if defines are considered not dirty and have not been checked
  20680. */
  20681. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20682. /**
  20683. * Prepares the defines related to multiview
  20684. * @param scene The scene we are intending to draw
  20685. * @param defines The defines to update
  20686. */
  20687. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20688. /**
  20689. * Prepares the defines related to the prepass
  20690. * @param scene The scene we are intending to draw
  20691. * @param defines The defines to update
  20692. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20693. */
  20694. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20695. /**
  20696. * Prepares the defines related to the light information passed in parameter
  20697. * @param scene The scene we are intending to draw
  20698. * @param mesh The mesh the effect is compiling for
  20699. * @param light The light the effect is compiling for
  20700. * @param lightIndex The index of the light
  20701. * @param defines The defines to update
  20702. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20703. * @param state Defines the current state regarding what is needed (normals, etc...)
  20704. */
  20705. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20706. needNormals: boolean;
  20707. needRebuild: boolean;
  20708. shadowEnabled: boolean;
  20709. specularEnabled: boolean;
  20710. lightmapMode: boolean;
  20711. }): void;
  20712. /**
  20713. * Prepares the defines related to the light information passed in parameter
  20714. * @param scene The scene we are intending to draw
  20715. * @param mesh The mesh the effect is compiling for
  20716. * @param defines The defines to update
  20717. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20718. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20719. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20720. * @returns true if normals will be required for the rest of the effect
  20721. */
  20722. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20723. /**
  20724. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20725. * @param lightIndex defines the light index
  20726. * @param uniformsList The uniform list
  20727. * @param samplersList The sampler list
  20728. * @param projectedLightTexture defines if projected texture must be used
  20729. * @param uniformBuffersList defines an optional list of uniform buffers
  20730. */
  20731. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20732. /**
  20733. * Prepares the uniforms and samplers list to be used in the effect
  20734. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20735. * @param samplersList The sampler list
  20736. * @param defines The defines helping in the list generation
  20737. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20738. */
  20739. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20740. /**
  20741. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20742. * @param defines The defines to update while falling back
  20743. * @param fallbacks The authorized effect fallbacks
  20744. * @param maxSimultaneousLights The maximum number of lights allowed
  20745. * @param rank the current rank of the Effect
  20746. * @returns The newly affected rank
  20747. */
  20748. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20749. private static _TmpMorphInfluencers;
  20750. /**
  20751. * Prepares the list of attributes required for morph targets according to the effect defines.
  20752. * @param attribs The current list of supported attribs
  20753. * @param mesh The mesh to prepare the morph targets attributes for
  20754. * @param influencers The number of influencers
  20755. */
  20756. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20757. /**
  20758. * Prepares the list of attributes required for morph targets according to the effect defines.
  20759. * @param attribs The current list of supported attribs
  20760. * @param mesh The mesh to prepare the morph targets attributes for
  20761. * @param defines The current Defines of the effect
  20762. */
  20763. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20764. /**
  20765. * Prepares the list of attributes required for bones according to the effect defines.
  20766. * @param attribs The current list of supported attribs
  20767. * @param mesh The mesh to prepare the bones attributes for
  20768. * @param defines The current Defines of the effect
  20769. * @param fallbacks The current efffect fallback strategy
  20770. */
  20771. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20772. /**
  20773. * Check and prepare the list of attributes required for instances according to the effect defines.
  20774. * @param attribs The current list of supported attribs
  20775. * @param defines The current MaterialDefines of the effect
  20776. */
  20777. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20778. /**
  20779. * Add the list of attributes required for instances to the attribs array.
  20780. * @param attribs The current list of supported attribs
  20781. */
  20782. static PushAttributesForInstances(attribs: string[]): void;
  20783. /**
  20784. * Binds the light information to the effect.
  20785. * @param light The light containing the generator
  20786. * @param effect The effect we are binding the data to
  20787. * @param lightIndex The light index in the effect used to render
  20788. */
  20789. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20790. /**
  20791. * Binds the lights information from the scene to the effect for the given mesh.
  20792. * @param light Light to bind
  20793. * @param lightIndex Light index
  20794. * @param scene The scene where the light belongs to
  20795. * @param effect The effect we are binding the data to
  20796. * @param useSpecular Defines if specular is supported
  20797. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20798. */
  20799. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20800. /**
  20801. * Binds the lights information from the scene to the effect for the given mesh.
  20802. * @param scene The scene the lights belongs to
  20803. * @param mesh The mesh we are binding the information to render
  20804. * @param effect The effect we are binding the data to
  20805. * @param defines The generated defines for the effect
  20806. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20807. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20808. */
  20809. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20810. private static _tempFogColor;
  20811. /**
  20812. * Binds the fog information from the scene to the effect for the given mesh.
  20813. * @param scene The scene the lights belongs to
  20814. * @param mesh The mesh we are binding the information to render
  20815. * @param effect The effect we are binding the data to
  20816. * @param linearSpace Defines if the fog effect is applied in linear space
  20817. */
  20818. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20819. /**
  20820. * Binds the bones information from the mesh to the effect.
  20821. * @param mesh The mesh we are binding the information to render
  20822. * @param effect The effect we are binding the data to
  20823. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  20824. */
  20825. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  20826. private static _CopyBonesTransformationMatrices;
  20827. /**
  20828. * Binds the morph targets information from the mesh to the effect.
  20829. * @param abstractMesh The mesh we are binding the information to render
  20830. * @param effect The effect we are binding the data to
  20831. */
  20832. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20833. /**
  20834. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20835. * @param defines The generated defines used in the effect
  20836. * @param effect The effect we are binding the data to
  20837. * @param scene The scene we are willing to render with logarithmic scale for
  20838. */
  20839. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20840. /**
  20841. * Binds the clip plane information from the scene to the effect.
  20842. * @param scene The scene the clip plane information are extracted from
  20843. * @param effect The effect we are binding the data to
  20844. */
  20845. static BindClipPlane(effect: Effect, scene: Scene): void;
  20846. }
  20847. }
  20848. declare module BABYLON {
  20849. /**
  20850. * Block used to expose an input value
  20851. */
  20852. export class InputBlock extends NodeMaterialBlock {
  20853. private _mode;
  20854. private _associatedVariableName;
  20855. private _storedValue;
  20856. private _valueCallback;
  20857. private _type;
  20858. private _animationType;
  20859. /** Gets or set a value used to limit the range of float values */
  20860. min: number;
  20861. /** Gets or set a value used to limit the range of float values */
  20862. max: number;
  20863. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20864. isBoolean: boolean;
  20865. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20866. matrixMode: number;
  20867. /** @hidden */
  20868. _systemValue: Nullable<NodeMaterialSystemValues>;
  20869. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20870. isConstant: boolean;
  20871. /** Gets or sets the group to use to display this block in the Inspector */
  20872. groupInInspector: string;
  20873. /** Gets an observable raised when the value is changed */
  20874. onValueChangedObservable: Observable<InputBlock>;
  20875. /**
  20876. * Gets or sets the connection point type (default is float)
  20877. */
  20878. get type(): NodeMaterialBlockConnectionPointTypes;
  20879. /**
  20880. * Creates a new InputBlock
  20881. * @param name defines the block name
  20882. * @param target defines the target of that block (Vertex by default)
  20883. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20884. */
  20885. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20886. /**
  20887. * Validates if a name is a reserve word.
  20888. * @param newName the new name to be given to the node.
  20889. * @returns false if the name is a reserve word, else true.
  20890. */
  20891. validateBlockName(newName: string): boolean;
  20892. /**
  20893. * Gets the output component
  20894. */
  20895. get output(): NodeMaterialConnectionPoint;
  20896. /**
  20897. * Set the source of this connection point to a vertex attribute
  20898. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20899. * @returns the current connection point
  20900. */
  20901. setAsAttribute(attributeName?: string): InputBlock;
  20902. /**
  20903. * Set the source of this connection point to a system value
  20904. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20905. * @returns the current connection point
  20906. */
  20907. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20908. /**
  20909. * Gets or sets the value of that point.
  20910. * Please note that this value will be ignored if valueCallback is defined
  20911. */
  20912. get value(): any;
  20913. set value(value: any);
  20914. /**
  20915. * Gets or sets a callback used to get the value of that point.
  20916. * Please note that setting this value will force the connection point to ignore the value property
  20917. */
  20918. get valueCallback(): () => any;
  20919. set valueCallback(value: () => any);
  20920. /**
  20921. * Gets or sets the associated variable name in the shader
  20922. */
  20923. get associatedVariableName(): string;
  20924. set associatedVariableName(value: string);
  20925. /** Gets or sets the type of animation applied to the input */
  20926. get animationType(): AnimatedInputBlockTypes;
  20927. set animationType(value: AnimatedInputBlockTypes);
  20928. /**
  20929. * Gets a boolean indicating that this connection point not defined yet
  20930. */
  20931. get isUndefined(): boolean;
  20932. /**
  20933. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20934. * In this case the connection point name must be the name of the uniform to use.
  20935. * Can only be set on inputs
  20936. */
  20937. get isUniform(): boolean;
  20938. set isUniform(value: boolean);
  20939. /**
  20940. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20941. * In this case the connection point name must be the name of the attribute to use
  20942. * Can only be set on inputs
  20943. */
  20944. get isAttribute(): boolean;
  20945. set isAttribute(value: boolean);
  20946. /**
  20947. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20948. * Can only be set on exit points
  20949. */
  20950. get isVarying(): boolean;
  20951. set isVarying(value: boolean);
  20952. /**
  20953. * Gets a boolean indicating that the current connection point is a system value
  20954. */
  20955. get isSystemValue(): boolean;
  20956. /**
  20957. * Gets or sets the current well known value or null if not defined as a system value
  20958. */
  20959. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20960. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20961. /**
  20962. * Gets the current class name
  20963. * @returns the class name
  20964. */
  20965. getClassName(): string;
  20966. /**
  20967. * Animate the input if animationType !== None
  20968. * @param scene defines the rendering scene
  20969. */
  20970. animate(scene: Scene): void;
  20971. private _emitDefine;
  20972. initialize(state: NodeMaterialBuildState): void;
  20973. /**
  20974. * Set the input block to its default value (based on its type)
  20975. */
  20976. setDefaultValue(): void;
  20977. private _emitConstant;
  20978. /** @hidden */
  20979. get _noContextSwitch(): boolean;
  20980. private _emit;
  20981. /** @hidden */
  20982. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20983. /** @hidden */
  20984. _transmit(effect: Effect, scene: Scene): void;
  20985. protected _buildBlock(state: NodeMaterialBuildState): void;
  20986. protected _dumpPropertiesCode(): string;
  20987. dispose(): void;
  20988. serialize(): any;
  20989. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20990. }
  20991. }
  20992. declare module BABYLON {
  20993. /**
  20994. * Enum used to define the compatibility state between two connection points
  20995. */
  20996. export enum NodeMaterialConnectionPointCompatibilityStates {
  20997. /** Points are compatibles */
  20998. Compatible = 0,
  20999. /** Points are incompatible because of their types */
  21000. TypeIncompatible = 1,
  21001. /** Points are incompatible because of their targets (vertex vs fragment) */
  21002. TargetIncompatible = 2
  21003. }
  21004. /**
  21005. * Defines the direction of a connection point
  21006. */
  21007. export enum NodeMaterialConnectionPointDirection {
  21008. /** Input */
  21009. Input = 0,
  21010. /** Output */
  21011. Output = 1
  21012. }
  21013. /**
  21014. * Defines a connection point for a block
  21015. */
  21016. export class NodeMaterialConnectionPoint {
  21017. /** @hidden */
  21018. _ownerBlock: NodeMaterialBlock;
  21019. /** @hidden */
  21020. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21021. private _endpoints;
  21022. private _associatedVariableName;
  21023. private _direction;
  21024. /** @hidden */
  21025. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21026. /** @hidden */
  21027. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21028. private _type;
  21029. /** @hidden */
  21030. _enforceAssociatedVariableName: boolean;
  21031. /** Gets the direction of the point */
  21032. get direction(): NodeMaterialConnectionPointDirection;
  21033. /** Indicates that this connection point needs dual validation before being connected to another point */
  21034. needDualDirectionValidation: boolean;
  21035. /**
  21036. * Gets or sets the additional types supported by this connection point
  21037. */
  21038. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21039. /**
  21040. * Gets or sets the additional types excluded by this connection point
  21041. */
  21042. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21043. /**
  21044. * Observable triggered when this point is connected
  21045. */
  21046. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21047. /**
  21048. * Gets or sets the associated variable name in the shader
  21049. */
  21050. get associatedVariableName(): string;
  21051. set associatedVariableName(value: string);
  21052. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21053. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21054. /**
  21055. * Gets or sets the connection point type (default is float)
  21056. */
  21057. get type(): NodeMaterialBlockConnectionPointTypes;
  21058. set type(value: NodeMaterialBlockConnectionPointTypes);
  21059. /**
  21060. * Gets or sets the connection point name
  21061. */
  21062. name: string;
  21063. /**
  21064. * Gets or sets the connection point name
  21065. */
  21066. displayName: string;
  21067. /**
  21068. * Gets or sets a boolean indicating that this connection point can be omitted
  21069. */
  21070. isOptional: boolean;
  21071. /**
  21072. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21073. */
  21074. isExposedOnFrame: boolean;
  21075. /**
  21076. * Gets or sets number indicating the position that the port is exposed to on a frame
  21077. */
  21078. exposedPortPosition: number;
  21079. /**
  21080. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21081. */
  21082. define: string;
  21083. /** @hidden */
  21084. _prioritizeVertex: boolean;
  21085. private _target;
  21086. /** Gets or sets the target of that connection point */
  21087. get target(): NodeMaterialBlockTargets;
  21088. set target(value: NodeMaterialBlockTargets);
  21089. /**
  21090. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21091. */
  21092. get isConnected(): boolean;
  21093. /**
  21094. * Gets a boolean indicating that the current point is connected to an input block
  21095. */
  21096. get isConnectedToInputBlock(): boolean;
  21097. /**
  21098. * Gets a the connected input block (if any)
  21099. */
  21100. get connectInputBlock(): Nullable<InputBlock>;
  21101. /** Get the other side of the connection (if any) */
  21102. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21103. /** Get the block that owns this connection point */
  21104. get ownerBlock(): NodeMaterialBlock;
  21105. /** Get the block connected on the other side of this connection (if any) */
  21106. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21107. /** Get the block connected on the endpoints of this connection (if any) */
  21108. get connectedBlocks(): Array<NodeMaterialBlock>;
  21109. /** Gets the list of connected endpoints */
  21110. get endpoints(): NodeMaterialConnectionPoint[];
  21111. /** Gets a boolean indicating if that output point is connected to at least one input */
  21112. get hasEndpoints(): boolean;
  21113. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21114. get isConnectedInVertexShader(): boolean;
  21115. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21116. get isConnectedInFragmentShader(): boolean;
  21117. /**
  21118. * Creates a block suitable to be used as an input for this input point.
  21119. * If null is returned, a block based on the point type will be created.
  21120. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  21121. */
  21122. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21123. /**
  21124. * Creates a new connection point
  21125. * @param name defines the connection point name
  21126. * @param ownerBlock defines the block hosting this connection point
  21127. * @param direction defines the direction of the connection point
  21128. */
  21129. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21130. /**
  21131. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21132. * @returns the class name
  21133. */
  21134. getClassName(): string;
  21135. /**
  21136. * Gets a boolean indicating if the current point can be connected to another point
  21137. * @param connectionPoint defines the other connection point
  21138. * @returns a boolean
  21139. */
  21140. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21141. /**
  21142. * Gets a number indicating if the current point can be connected to another point
  21143. * @param connectionPoint defines the other connection point
  21144. * @returns a number defining the compatibility state
  21145. */
  21146. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21147. /**
  21148. * Connect this point to another connection point
  21149. * @param connectionPoint defines the other connection point
  21150. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21151. * @returns the current connection point
  21152. */
  21153. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21154. /**
  21155. * Disconnect this point from one of his endpoint
  21156. * @param endpoint defines the other connection point
  21157. * @returns the current connection point
  21158. */
  21159. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21160. /**
  21161. * Serializes this point in a JSON representation
  21162. * @param isInput defines if the connection point is an input (default is true)
  21163. * @returns the serialized point object
  21164. */
  21165. serialize(isInput?: boolean): any;
  21166. /**
  21167. * Release resources
  21168. */
  21169. dispose(): void;
  21170. }
  21171. }
  21172. declare module BABYLON {
  21173. /**
  21174. * Enum used to define the material modes
  21175. */
  21176. export enum NodeMaterialModes {
  21177. /** Regular material */
  21178. Material = 0,
  21179. /** For post process */
  21180. PostProcess = 1,
  21181. /** For particle system */
  21182. Particle = 2,
  21183. /** For procedural texture */
  21184. ProceduralTexture = 3
  21185. }
  21186. }
  21187. declare module BABYLON {
  21188. /**
  21189. * Block used to read a texture from a sampler
  21190. */
  21191. export class TextureBlock extends NodeMaterialBlock {
  21192. private _defineName;
  21193. private _linearDefineName;
  21194. private _gammaDefineName;
  21195. private _tempTextureRead;
  21196. private _samplerName;
  21197. private _transformedUVName;
  21198. private _textureTransformName;
  21199. private _textureInfoName;
  21200. private _mainUVName;
  21201. private _mainUVDefineName;
  21202. private _fragmentOnly;
  21203. /**
  21204. * Gets or sets the texture associated with the node
  21205. */
  21206. texture: Nullable<Texture>;
  21207. /**
  21208. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21209. */
  21210. convertToGammaSpace: boolean;
  21211. /**
  21212. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21213. */
  21214. convertToLinearSpace: boolean;
  21215. /**
  21216. * Create a new TextureBlock
  21217. * @param name defines the block name
  21218. */
  21219. constructor(name: string, fragmentOnly?: boolean);
  21220. /**
  21221. * Gets the current class name
  21222. * @returns the class name
  21223. */
  21224. getClassName(): string;
  21225. /**
  21226. * Gets the uv input component
  21227. */
  21228. get uv(): NodeMaterialConnectionPoint;
  21229. /**
  21230. * Gets the rgba output component
  21231. */
  21232. get rgba(): NodeMaterialConnectionPoint;
  21233. /**
  21234. * Gets the rgb output component
  21235. */
  21236. get rgb(): NodeMaterialConnectionPoint;
  21237. /**
  21238. * Gets the r output component
  21239. */
  21240. get r(): NodeMaterialConnectionPoint;
  21241. /**
  21242. * Gets the g output component
  21243. */
  21244. get g(): NodeMaterialConnectionPoint;
  21245. /**
  21246. * Gets the b output component
  21247. */
  21248. get b(): NodeMaterialConnectionPoint;
  21249. /**
  21250. * Gets the a output component
  21251. */
  21252. get a(): NodeMaterialConnectionPoint;
  21253. get target(): NodeMaterialBlockTargets;
  21254. autoConfigure(material: NodeMaterial): void;
  21255. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21256. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21257. isReady(): boolean;
  21258. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21259. private get _isMixed();
  21260. private _injectVertexCode;
  21261. private _writeTextureRead;
  21262. private _writeOutput;
  21263. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21264. protected _dumpPropertiesCode(): string;
  21265. serialize(): any;
  21266. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21267. }
  21268. }
  21269. declare module BABYLON {
  21270. /** @hidden */
  21271. export var reflectionFunction: {
  21272. name: string;
  21273. shader: string;
  21274. };
  21275. }
  21276. declare module BABYLON {
  21277. /**
  21278. * Base block used to read a reflection texture from a sampler
  21279. */
  21280. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21281. /** @hidden */
  21282. _define3DName: string;
  21283. /** @hidden */
  21284. _defineCubicName: string;
  21285. /** @hidden */
  21286. _defineExplicitName: string;
  21287. /** @hidden */
  21288. _defineProjectionName: string;
  21289. /** @hidden */
  21290. _defineLocalCubicName: string;
  21291. /** @hidden */
  21292. _defineSphericalName: string;
  21293. /** @hidden */
  21294. _definePlanarName: string;
  21295. /** @hidden */
  21296. _defineEquirectangularName: string;
  21297. /** @hidden */
  21298. _defineMirroredEquirectangularFixedName: string;
  21299. /** @hidden */
  21300. _defineEquirectangularFixedName: string;
  21301. /** @hidden */
  21302. _defineSkyboxName: string;
  21303. /** @hidden */
  21304. _defineOppositeZ: string;
  21305. /** @hidden */
  21306. _cubeSamplerName: string;
  21307. /** @hidden */
  21308. _2DSamplerName: string;
  21309. protected _positionUVWName: string;
  21310. protected _directionWName: string;
  21311. protected _reflectionVectorName: string;
  21312. /** @hidden */
  21313. _reflectionCoordsName: string;
  21314. /** @hidden */
  21315. _reflectionMatrixName: string;
  21316. protected _reflectionColorName: string;
  21317. /**
  21318. * Gets or sets the texture associated with the node
  21319. */
  21320. texture: Nullable<BaseTexture>;
  21321. /**
  21322. * Create a new ReflectionTextureBaseBlock
  21323. * @param name defines the block name
  21324. */
  21325. constructor(name: string);
  21326. /**
  21327. * Gets the current class name
  21328. * @returns the class name
  21329. */
  21330. getClassName(): string;
  21331. /**
  21332. * Gets the world position input component
  21333. */
  21334. abstract get position(): NodeMaterialConnectionPoint;
  21335. /**
  21336. * Gets the world position input component
  21337. */
  21338. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21339. /**
  21340. * Gets the world normal input component
  21341. */
  21342. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21343. /**
  21344. * Gets the world input component
  21345. */
  21346. abstract get world(): NodeMaterialConnectionPoint;
  21347. /**
  21348. * Gets the camera (or eye) position component
  21349. */
  21350. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21351. /**
  21352. * Gets the view input component
  21353. */
  21354. abstract get view(): NodeMaterialConnectionPoint;
  21355. protected _getTexture(): Nullable<BaseTexture>;
  21356. autoConfigure(material: NodeMaterial): void;
  21357. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21358. isReady(): boolean;
  21359. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21360. /**
  21361. * Gets the code to inject in the vertex shader
  21362. * @param state current state of the node material building
  21363. * @returns the shader code
  21364. */
  21365. handleVertexSide(state: NodeMaterialBuildState): string;
  21366. /**
  21367. * Handles the inits for the fragment code path
  21368. * @param state node material build state
  21369. */
  21370. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21371. /**
  21372. * Generates the reflection coords code for the fragment code path
  21373. * @param worldNormalVarName name of the world normal variable
  21374. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21375. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21376. * @returns the shader code
  21377. */
  21378. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21379. /**
  21380. * Generates the reflection color code for the fragment code path
  21381. * @param lodVarName name of the lod variable
  21382. * @param swizzleLookupTexture swizzle to use for the final color variable
  21383. * @returns the shader code
  21384. */
  21385. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21386. /**
  21387. * Generates the code corresponding to the connected output points
  21388. * @param state node material build state
  21389. * @param varName name of the variable to output
  21390. * @returns the shader code
  21391. */
  21392. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21393. protected _buildBlock(state: NodeMaterialBuildState): this;
  21394. protected _dumpPropertiesCode(): string;
  21395. serialize(): any;
  21396. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21397. }
  21398. }
  21399. declare module BABYLON {
  21400. /**
  21401. * Defines a connection point to be used for points with a custom object type
  21402. */
  21403. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21404. private _blockType;
  21405. private _blockName;
  21406. private _nameForCheking?;
  21407. /**
  21408. * Creates a new connection point
  21409. * @param name defines the connection point name
  21410. * @param ownerBlock defines the block hosting this connection point
  21411. * @param direction defines the direction of the connection point
  21412. */
  21413. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21414. /**
  21415. * Gets a number indicating if the current point can be connected to another point
  21416. * @param connectionPoint defines the other connection point
  21417. * @returns a number defining the compatibility state
  21418. */
  21419. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21420. /**
  21421. * Creates a block suitable to be used as an input for this input point.
  21422. * If null is returned, a block based on the point type will be created.
  21423. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  21424. */
  21425. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21426. }
  21427. }
  21428. declare module BABYLON {
  21429. /**
  21430. * Enum defining the type of properties that can be edited in the property pages in the NME
  21431. */
  21432. export enum PropertyTypeForEdition {
  21433. /** property is a boolean */
  21434. Boolean = 0,
  21435. /** property is a float */
  21436. Float = 1,
  21437. /** property is a Vector2 */
  21438. Vector2 = 2,
  21439. /** property is a list of values */
  21440. List = 3
  21441. }
  21442. /**
  21443. * Interface that defines an option in a variable of type list
  21444. */
  21445. export interface IEditablePropertyListOption {
  21446. /** label of the option */
  21447. "label": string;
  21448. /** value of the option */
  21449. "value": number;
  21450. }
  21451. /**
  21452. * Interface that defines the options available for an editable property
  21453. */
  21454. export interface IEditablePropertyOption {
  21455. /** min value */
  21456. "min"?: number;
  21457. /** max value */
  21458. "max"?: number;
  21459. /** notifiers: indicates which actions to take when the property is changed */
  21460. "notifiers"?: {
  21461. /** the material should be rebuilt */
  21462. "rebuild"?: boolean;
  21463. /** the preview should be updated */
  21464. "update"?: boolean;
  21465. };
  21466. /** list of the options for a variable of type list */
  21467. "options"?: IEditablePropertyListOption[];
  21468. }
  21469. /**
  21470. * Interface that describes an editable property
  21471. */
  21472. export interface IPropertyDescriptionForEdition {
  21473. /** name of the property */
  21474. "propertyName": string;
  21475. /** display name of the property */
  21476. "displayName": string;
  21477. /** type of the property */
  21478. "type": PropertyTypeForEdition;
  21479. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21480. "groupName": string;
  21481. /** options for the property */
  21482. "options": IEditablePropertyOption;
  21483. }
  21484. /**
  21485. * Decorator that flags a property in a node material block as being editable
  21486. */
  21487. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21488. }
  21489. declare module BABYLON {
  21490. /**
  21491. * Block used to implement the refraction part of the sub surface module of the PBR material
  21492. */
  21493. export class RefractionBlock extends NodeMaterialBlock {
  21494. /** @hidden */
  21495. _define3DName: string;
  21496. /** @hidden */
  21497. _refractionMatrixName: string;
  21498. /** @hidden */
  21499. _defineLODRefractionAlpha: string;
  21500. /** @hidden */
  21501. _defineLinearSpecularRefraction: string;
  21502. /** @hidden */
  21503. _defineOppositeZ: string;
  21504. /** @hidden */
  21505. _cubeSamplerName: string;
  21506. /** @hidden */
  21507. _2DSamplerName: string;
  21508. /** @hidden */
  21509. _vRefractionMicrosurfaceInfosName: string;
  21510. /** @hidden */
  21511. _vRefractionInfosName: string;
  21512. private _scene;
  21513. /**
  21514. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21515. * Materials half opaque for instance using refraction could benefit from this control.
  21516. */
  21517. linkRefractionWithTransparency: boolean;
  21518. /**
  21519. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21520. */
  21521. invertRefractionY: boolean;
  21522. /**
  21523. * Gets or sets the texture associated with the node
  21524. */
  21525. texture: Nullable<BaseTexture>;
  21526. /**
  21527. * Create a new RefractionBlock
  21528. * @param name defines the block name
  21529. */
  21530. constructor(name: string);
  21531. /**
  21532. * Gets the current class name
  21533. * @returns the class name
  21534. */
  21535. getClassName(): string;
  21536. /**
  21537. * Gets the intensity input component
  21538. */
  21539. get intensity(): NodeMaterialConnectionPoint;
  21540. /**
  21541. * Gets the index of refraction input component
  21542. */
  21543. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21544. /**
  21545. * Gets the tint at distance input component
  21546. */
  21547. get tintAtDistance(): NodeMaterialConnectionPoint;
  21548. /**
  21549. * Gets the view input component
  21550. */
  21551. get view(): NodeMaterialConnectionPoint;
  21552. /**
  21553. * Gets the refraction object output component
  21554. */
  21555. get refraction(): NodeMaterialConnectionPoint;
  21556. /**
  21557. * Returns true if the block has a texture
  21558. */
  21559. get hasTexture(): boolean;
  21560. protected _getTexture(): Nullable<BaseTexture>;
  21561. autoConfigure(material: NodeMaterial): void;
  21562. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21563. isReady(): boolean;
  21564. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21565. /**
  21566. * Gets the main code of the block (fragment side)
  21567. * @param state current state of the node material building
  21568. * @returns the shader code
  21569. */
  21570. getCode(state: NodeMaterialBuildState): string;
  21571. protected _buildBlock(state: NodeMaterialBuildState): this;
  21572. protected _dumpPropertiesCode(): string;
  21573. serialize(): any;
  21574. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21575. }
  21576. }
  21577. declare module BABYLON {
  21578. /**
  21579. * Base block used as input for post process
  21580. */
  21581. export class CurrentScreenBlock extends NodeMaterialBlock {
  21582. private _samplerName;
  21583. private _linearDefineName;
  21584. private _gammaDefineName;
  21585. private _mainUVName;
  21586. private _tempTextureRead;
  21587. /**
  21588. * Gets or sets the texture associated with the node
  21589. */
  21590. texture: Nullable<BaseTexture>;
  21591. /**
  21592. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21593. */
  21594. convertToGammaSpace: boolean;
  21595. /**
  21596. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21597. */
  21598. convertToLinearSpace: boolean;
  21599. /**
  21600. * Create a new CurrentScreenBlock
  21601. * @param name defines the block name
  21602. */
  21603. constructor(name: string);
  21604. /**
  21605. * Gets the current class name
  21606. * @returns the class name
  21607. */
  21608. getClassName(): string;
  21609. /**
  21610. * Gets the uv input component
  21611. */
  21612. get uv(): NodeMaterialConnectionPoint;
  21613. /**
  21614. * Gets the rgba output component
  21615. */
  21616. get rgba(): NodeMaterialConnectionPoint;
  21617. /**
  21618. * Gets the rgb output component
  21619. */
  21620. get rgb(): NodeMaterialConnectionPoint;
  21621. /**
  21622. * Gets the r output component
  21623. */
  21624. get r(): NodeMaterialConnectionPoint;
  21625. /**
  21626. * Gets the g output component
  21627. */
  21628. get g(): NodeMaterialConnectionPoint;
  21629. /**
  21630. * Gets the b output component
  21631. */
  21632. get b(): NodeMaterialConnectionPoint;
  21633. /**
  21634. * Gets the a output component
  21635. */
  21636. get a(): NodeMaterialConnectionPoint;
  21637. /**
  21638. * Initialize the block and prepare the context for build
  21639. * @param state defines the state that will be used for the build
  21640. */
  21641. initialize(state: NodeMaterialBuildState): void;
  21642. get target(): NodeMaterialBlockTargets;
  21643. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21644. isReady(): boolean;
  21645. private _injectVertexCode;
  21646. private _writeTextureRead;
  21647. private _writeOutput;
  21648. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21649. serialize(): any;
  21650. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21651. }
  21652. }
  21653. declare module BABYLON {
  21654. /**
  21655. * Base block used for the particle texture
  21656. */
  21657. export class ParticleTextureBlock extends NodeMaterialBlock {
  21658. private _samplerName;
  21659. private _linearDefineName;
  21660. private _gammaDefineName;
  21661. private _tempTextureRead;
  21662. /**
  21663. * Gets or sets the texture associated with the node
  21664. */
  21665. texture: Nullable<BaseTexture>;
  21666. /**
  21667. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21668. */
  21669. convertToGammaSpace: boolean;
  21670. /**
  21671. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21672. */
  21673. convertToLinearSpace: boolean;
  21674. /**
  21675. * Create a new ParticleTextureBlock
  21676. * @param name defines the block name
  21677. */
  21678. constructor(name: string);
  21679. /**
  21680. * Gets the current class name
  21681. * @returns the class name
  21682. */
  21683. getClassName(): string;
  21684. /**
  21685. * Gets the uv input component
  21686. */
  21687. get uv(): NodeMaterialConnectionPoint;
  21688. /**
  21689. * Gets the rgba output component
  21690. */
  21691. get rgba(): NodeMaterialConnectionPoint;
  21692. /**
  21693. * Gets the rgb output component
  21694. */
  21695. get rgb(): NodeMaterialConnectionPoint;
  21696. /**
  21697. * Gets the r output component
  21698. */
  21699. get r(): NodeMaterialConnectionPoint;
  21700. /**
  21701. * Gets the g output component
  21702. */
  21703. get g(): NodeMaterialConnectionPoint;
  21704. /**
  21705. * Gets the b output component
  21706. */
  21707. get b(): NodeMaterialConnectionPoint;
  21708. /**
  21709. * Gets the a output component
  21710. */
  21711. get a(): NodeMaterialConnectionPoint;
  21712. /**
  21713. * Initialize the block and prepare the context for build
  21714. * @param state defines the state that will be used for the build
  21715. */
  21716. initialize(state: NodeMaterialBuildState): void;
  21717. autoConfigure(material: NodeMaterial): void;
  21718. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21719. isReady(): boolean;
  21720. private _writeOutput;
  21721. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21722. serialize(): any;
  21723. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21724. }
  21725. }
  21726. declare module BABYLON {
  21727. /**
  21728. * Class used to store shared data between 2 NodeMaterialBuildState
  21729. */
  21730. export class NodeMaterialBuildStateSharedData {
  21731. /**
  21732. * Gets the list of emitted varyings
  21733. */
  21734. temps: string[];
  21735. /**
  21736. * Gets the list of emitted varyings
  21737. */
  21738. varyings: string[];
  21739. /**
  21740. * Gets the varying declaration string
  21741. */
  21742. varyingDeclaration: string;
  21743. /**
  21744. * Input blocks
  21745. */
  21746. inputBlocks: InputBlock[];
  21747. /**
  21748. * Input blocks
  21749. */
  21750. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21751. /**
  21752. * Bindable blocks (Blocks that need to set data to the effect)
  21753. */
  21754. bindableBlocks: NodeMaterialBlock[];
  21755. /**
  21756. * List of blocks that can provide a compilation fallback
  21757. */
  21758. blocksWithFallbacks: NodeMaterialBlock[];
  21759. /**
  21760. * List of blocks that can provide a define update
  21761. */
  21762. blocksWithDefines: NodeMaterialBlock[];
  21763. /**
  21764. * List of blocks that can provide a repeatable content
  21765. */
  21766. repeatableContentBlocks: NodeMaterialBlock[];
  21767. /**
  21768. * List of blocks that can provide a dynamic list of uniforms
  21769. */
  21770. dynamicUniformBlocks: NodeMaterialBlock[];
  21771. /**
  21772. * List of blocks that can block the isReady function for the material
  21773. */
  21774. blockingBlocks: NodeMaterialBlock[];
  21775. /**
  21776. * Gets the list of animated inputs
  21777. */
  21778. animatedInputs: InputBlock[];
  21779. /**
  21780. * Build Id used to avoid multiple recompilations
  21781. */
  21782. buildId: number;
  21783. /** List of emitted variables */
  21784. variableNames: {
  21785. [key: string]: number;
  21786. };
  21787. /** List of emitted defines */
  21788. defineNames: {
  21789. [key: string]: number;
  21790. };
  21791. /** Should emit comments? */
  21792. emitComments: boolean;
  21793. /** Emit build activity */
  21794. verbose: boolean;
  21795. /** Gets or sets the hosting scene */
  21796. scene: Scene;
  21797. /**
  21798. * Gets the compilation hints emitted at compilation time
  21799. */
  21800. hints: {
  21801. needWorldViewMatrix: boolean;
  21802. needWorldViewProjectionMatrix: boolean;
  21803. needAlphaBlending: boolean;
  21804. needAlphaTesting: boolean;
  21805. };
  21806. /**
  21807. * List of compilation checks
  21808. */
  21809. checks: {
  21810. emitVertex: boolean;
  21811. emitFragment: boolean;
  21812. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21813. };
  21814. /**
  21815. * Is vertex program allowed to be empty?
  21816. */
  21817. allowEmptyVertexProgram: boolean;
  21818. /** Creates a new shared data */
  21819. constructor();
  21820. /**
  21821. * Emits console errors and exceptions if there is a failing check
  21822. */
  21823. emitErrors(): void;
  21824. }
  21825. }
  21826. declare module BABYLON {
  21827. /**
  21828. * Class used to store node based material build state
  21829. */
  21830. export class NodeMaterialBuildState {
  21831. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21832. supportUniformBuffers: boolean;
  21833. /**
  21834. * Gets the list of emitted attributes
  21835. */
  21836. attributes: string[];
  21837. /**
  21838. * Gets the list of emitted uniforms
  21839. */
  21840. uniforms: string[];
  21841. /**
  21842. * Gets the list of emitted constants
  21843. */
  21844. constants: string[];
  21845. /**
  21846. * Gets the list of emitted samplers
  21847. */
  21848. samplers: string[];
  21849. /**
  21850. * Gets the list of emitted functions
  21851. */
  21852. functions: {
  21853. [key: string]: string;
  21854. };
  21855. /**
  21856. * Gets the list of emitted extensions
  21857. */
  21858. extensions: {
  21859. [key: string]: string;
  21860. };
  21861. /**
  21862. * Gets the target of the compilation state
  21863. */
  21864. target: NodeMaterialBlockTargets;
  21865. /**
  21866. * Gets the list of emitted counters
  21867. */
  21868. counters: {
  21869. [key: string]: number;
  21870. };
  21871. /**
  21872. * Shared data between multiple NodeMaterialBuildState instances
  21873. */
  21874. sharedData: NodeMaterialBuildStateSharedData;
  21875. /** @hidden */
  21876. _vertexState: NodeMaterialBuildState;
  21877. /** @hidden */
  21878. _attributeDeclaration: string;
  21879. /** @hidden */
  21880. _uniformDeclaration: string;
  21881. /** @hidden */
  21882. _constantDeclaration: string;
  21883. /** @hidden */
  21884. _samplerDeclaration: string;
  21885. /** @hidden */
  21886. _varyingTransfer: string;
  21887. /** @hidden */
  21888. _injectAtEnd: string;
  21889. private _repeatableContentAnchorIndex;
  21890. /** @hidden */
  21891. _builtCompilationString: string;
  21892. /**
  21893. * Gets the emitted compilation strings
  21894. */
  21895. compilationString: string;
  21896. /**
  21897. * Finalize the compilation strings
  21898. * @param state defines the current compilation state
  21899. */
  21900. finalize(state: NodeMaterialBuildState): void;
  21901. /** @hidden */
  21902. get _repeatableContentAnchor(): string;
  21903. /** @hidden */
  21904. _getFreeVariableName(prefix: string): string;
  21905. /** @hidden */
  21906. _getFreeDefineName(prefix: string): string;
  21907. /** @hidden */
  21908. _excludeVariableName(name: string): void;
  21909. /** @hidden */
  21910. _emit2DSampler(name: string): void;
  21911. /** @hidden */
  21912. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21913. /** @hidden */
  21914. _emitExtension(name: string, extension: string, define?: string): void;
  21915. /** @hidden */
  21916. _emitFunction(name: string, code: string, comments: string): void;
  21917. /** @hidden */
  21918. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21919. replaceStrings?: {
  21920. search: RegExp;
  21921. replace: string;
  21922. }[];
  21923. repeatKey?: string;
  21924. }): string;
  21925. /** @hidden */
  21926. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21927. repeatKey?: string;
  21928. removeAttributes?: boolean;
  21929. removeUniforms?: boolean;
  21930. removeVaryings?: boolean;
  21931. removeIfDef?: boolean;
  21932. replaceStrings?: {
  21933. search: RegExp;
  21934. replace: string;
  21935. }[];
  21936. }, storeKey?: string): void;
  21937. /** @hidden */
  21938. _registerTempVariable(name: string): boolean;
  21939. /** @hidden */
  21940. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21941. /** @hidden */
  21942. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21943. /** @hidden */
  21944. _emitFloat(value: number): string;
  21945. }
  21946. }
  21947. declare module BABYLON {
  21948. /**
  21949. * Helper class used to generate session unique ID
  21950. */
  21951. export class UniqueIdGenerator {
  21952. private static _UniqueIdCounter;
  21953. /**
  21954. * Gets an unique (relatively to the current scene) Id
  21955. */
  21956. static get UniqueId(): number;
  21957. }
  21958. }
  21959. declare module BABYLON {
  21960. /**
  21961. * Defines a block that can be used inside a node based material
  21962. */
  21963. export class NodeMaterialBlock {
  21964. private _buildId;
  21965. private _buildTarget;
  21966. private _target;
  21967. private _isFinalMerger;
  21968. private _isInput;
  21969. private _name;
  21970. protected _isUnique: boolean;
  21971. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21972. inputsAreExclusive: boolean;
  21973. /** @hidden */
  21974. _codeVariableName: string;
  21975. /** @hidden */
  21976. _inputs: NodeMaterialConnectionPoint[];
  21977. /** @hidden */
  21978. _outputs: NodeMaterialConnectionPoint[];
  21979. /** @hidden */
  21980. _preparationId: number;
  21981. /**
  21982. * Gets the name of the block
  21983. */
  21984. get name(): string;
  21985. /**
  21986. * Sets the name of the block. Will check if the name is valid.
  21987. */
  21988. set name(newName: string);
  21989. /**
  21990. * Gets or sets the unique id of the node
  21991. */
  21992. uniqueId: number;
  21993. /**
  21994. * Gets or sets the comments associated with this block
  21995. */
  21996. comments: string;
  21997. /**
  21998. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21999. */
  22000. get isUnique(): boolean;
  22001. /**
  22002. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22003. */
  22004. get isFinalMerger(): boolean;
  22005. /**
  22006. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22007. */
  22008. get isInput(): boolean;
  22009. /**
  22010. * Gets or sets the build Id
  22011. */
  22012. get buildId(): number;
  22013. set buildId(value: number);
  22014. /**
  22015. * Gets or sets the target of the block
  22016. */
  22017. get target(): NodeMaterialBlockTargets;
  22018. set target(value: NodeMaterialBlockTargets);
  22019. /**
  22020. * Gets the list of input points
  22021. */
  22022. get inputs(): NodeMaterialConnectionPoint[];
  22023. /** Gets the list of output points */
  22024. get outputs(): NodeMaterialConnectionPoint[];
  22025. /**
  22026. * Find an input by its name
  22027. * @param name defines the name of the input to look for
  22028. * @returns the input or null if not found
  22029. */
  22030. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22031. /**
  22032. * Find an output by its name
  22033. * @param name defines the name of the outputto look for
  22034. * @returns the output or null if not found
  22035. */
  22036. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22037. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22038. visibleInInspector: boolean;
  22039. /**
  22040. * Creates a new NodeMaterialBlock
  22041. * @param name defines the block name
  22042. * @param target defines the target of that block (Vertex by default)
  22043. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22044. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22045. */
  22046. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22047. /**
  22048. * Initialize the block and prepare the context for build
  22049. * @param state defines the state that will be used for the build
  22050. */
  22051. initialize(state: NodeMaterialBuildState): void;
  22052. /**
  22053. * Bind data to effect. Will only be called for blocks with isBindable === true
  22054. * @param effect defines the effect to bind data to
  22055. * @param nodeMaterial defines the hosting NodeMaterial
  22056. * @param mesh defines the mesh that will be rendered
  22057. * @param subMesh defines the submesh that will be rendered
  22058. */
  22059. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22060. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22061. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22062. protected _writeFloat(value: number): string;
  22063. /**
  22064. * Gets the current class name e.g. "NodeMaterialBlock"
  22065. * @returns the class name
  22066. */
  22067. getClassName(): string;
  22068. /**
  22069. * Register a new input. Must be called inside a block constructor
  22070. * @param name defines the connection point name
  22071. * @param type defines the connection point type
  22072. * @param isOptional defines a boolean indicating that this input can be omitted
  22073. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22074. * @param point an already created connection point. If not provided, create a new one
  22075. * @returns the current block
  22076. */
  22077. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22078. /**
  22079. * Register a new output. Must be called inside a block constructor
  22080. * @param name defines the connection point name
  22081. * @param type defines the connection point type
  22082. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22083. * @param point an already created connection point. If not provided, create a new one
  22084. * @returns the current block
  22085. */
  22086. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22087. /**
  22088. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22089. * @param forOutput defines an optional connection point to check compatibility with
  22090. * @returns the first available input or null
  22091. */
  22092. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22093. /**
  22094. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22095. * @param forBlock defines an optional block to check compatibility with
  22096. * @returns the first available input or null
  22097. */
  22098. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22099. /**
  22100. * Gets the sibling of the given output
  22101. * @param current defines the current output
  22102. * @returns the next output in the list or null
  22103. */
  22104. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22105. /**
  22106. * Connect current block with another block
  22107. * @param other defines the block to connect with
  22108. * @param options define the various options to help pick the right connections
  22109. * @returns the current block
  22110. */
  22111. connectTo(other: NodeMaterialBlock, options?: {
  22112. input?: string;
  22113. output?: string;
  22114. outputSwizzle?: string;
  22115. }): this | undefined;
  22116. protected _buildBlock(state: NodeMaterialBuildState): void;
  22117. /**
  22118. * Add uniforms, samplers and uniform buffers at compilation time
  22119. * @param state defines the state to update
  22120. * @param nodeMaterial defines the node material requesting the update
  22121. * @param defines defines the material defines to update
  22122. * @param uniformBuffers defines the list of uniform buffer names
  22123. */
  22124. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22125. /**
  22126. * Add potential fallbacks if shader compilation fails
  22127. * @param mesh defines the mesh to be rendered
  22128. * @param fallbacks defines the current prioritized list of fallbacks
  22129. */
  22130. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22131. /**
  22132. * Initialize defines for shader compilation
  22133. * @param mesh defines the mesh to be rendered
  22134. * @param nodeMaterial defines the node material requesting the update
  22135. * @param defines defines the material defines to update
  22136. * @param useInstances specifies that instances should be used
  22137. */
  22138. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22139. /**
  22140. * Update defines for shader compilation
  22141. * @param mesh defines the mesh to be rendered
  22142. * @param nodeMaterial defines the node material requesting the update
  22143. * @param defines defines the material defines to update
  22144. * @param useInstances specifies that instances should be used
  22145. * @param subMesh defines which submesh to render
  22146. */
  22147. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22148. /**
  22149. * Lets the block try to connect some inputs automatically
  22150. * @param material defines the hosting NodeMaterial
  22151. */
  22152. autoConfigure(material: NodeMaterial): void;
  22153. /**
  22154. * Function called when a block is declared as repeatable content generator
  22155. * @param vertexShaderState defines the current compilation state for the vertex shader
  22156. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22157. * @param mesh defines the mesh to be rendered
  22158. * @param defines defines the material defines to update
  22159. */
  22160. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22161. /**
  22162. * Checks if the block is ready
  22163. * @param mesh defines the mesh to be rendered
  22164. * @param nodeMaterial defines the node material requesting the update
  22165. * @param defines defines the material defines to update
  22166. * @param useInstances specifies that instances should be used
  22167. * @returns true if the block is ready
  22168. */
  22169. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22170. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22171. private _processBuild;
  22172. /**
  22173. * Validates the new name for the block node.
  22174. * @param newName the new name to be given to the node.
  22175. * @returns false if the name is a reserve word, else true.
  22176. */
  22177. validateBlockName(newName: string): boolean;
  22178. /**
  22179. * Compile the current node and generate the shader code
  22180. * @param state defines the current compilation state (uniforms, samplers, current string)
  22181. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22182. * @returns true if already built
  22183. */
  22184. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22185. protected _inputRename(name: string): string;
  22186. protected _outputRename(name: string): string;
  22187. protected _dumpPropertiesCode(): string;
  22188. /** @hidden */
  22189. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22190. /** @hidden */
  22191. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22192. /**
  22193. * Clone the current block to a new identical block
  22194. * @param scene defines the hosting scene
  22195. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22196. * @returns a copy of the current block
  22197. */
  22198. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22199. /**
  22200. * Serializes this block in a JSON representation
  22201. * @returns the serialized block object
  22202. */
  22203. serialize(): any;
  22204. /** @hidden */
  22205. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22206. private _deserializePortDisplayNamesAndExposedOnFrame;
  22207. /**
  22208. * Release resources
  22209. */
  22210. dispose(): void;
  22211. }
  22212. }
  22213. declare module BABYLON {
  22214. /**
  22215. * Base class of materials working in push mode in babylon JS
  22216. * @hidden
  22217. */
  22218. export class PushMaterial extends Material {
  22219. protected _activeEffect: Effect;
  22220. protected _normalMatrix: Matrix;
  22221. constructor(name: string, scene: Scene);
  22222. getEffect(): Effect;
  22223. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22224. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22225. /**
  22226. * Binds the given world matrix to the active effect
  22227. *
  22228. * @param world the matrix to bind
  22229. */
  22230. bindOnlyWorldMatrix(world: Matrix): void;
  22231. /**
  22232. * Binds the given normal matrix to the active effect
  22233. *
  22234. * @param normalMatrix the matrix to bind
  22235. */
  22236. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22237. bind(world: Matrix, mesh?: Mesh): void;
  22238. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22239. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22240. }
  22241. }
  22242. declare module BABYLON {
  22243. /**
  22244. * Root class for all node material optimizers
  22245. */
  22246. export class NodeMaterialOptimizer {
  22247. /**
  22248. * Function used to optimize a NodeMaterial graph
  22249. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22250. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22251. */
  22252. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22253. }
  22254. }
  22255. declare module BABYLON {
  22256. /**
  22257. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22258. */
  22259. export class TransformBlock extends NodeMaterialBlock {
  22260. /**
  22261. * Defines the value to use to complement W value to transform it to a Vector4
  22262. */
  22263. complementW: number;
  22264. /**
  22265. * Defines the value to use to complement z value to transform it to a Vector4
  22266. */
  22267. complementZ: number;
  22268. /**
  22269. * Creates a new TransformBlock
  22270. * @param name defines the block name
  22271. */
  22272. constructor(name: string);
  22273. /**
  22274. * Gets the current class name
  22275. * @returns the class name
  22276. */
  22277. getClassName(): string;
  22278. /**
  22279. * Gets the vector input
  22280. */
  22281. get vector(): NodeMaterialConnectionPoint;
  22282. /**
  22283. * Gets the output component
  22284. */
  22285. get output(): NodeMaterialConnectionPoint;
  22286. /**
  22287. * Gets the xyz output component
  22288. */
  22289. get xyz(): NodeMaterialConnectionPoint;
  22290. /**
  22291. * Gets the matrix transform input
  22292. */
  22293. get transform(): NodeMaterialConnectionPoint;
  22294. protected _buildBlock(state: NodeMaterialBuildState): this;
  22295. /**
  22296. * Update defines for shader compilation
  22297. * @param mesh defines the mesh to be rendered
  22298. * @param nodeMaterial defines the node material requesting the update
  22299. * @param defines defines the material defines to update
  22300. * @param useInstances specifies that instances should be used
  22301. * @param subMesh defines which submesh to render
  22302. */
  22303. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22304. serialize(): any;
  22305. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22306. protected _dumpPropertiesCode(): string;
  22307. }
  22308. }
  22309. declare module BABYLON {
  22310. /**
  22311. * Block used to output the vertex position
  22312. */
  22313. export class VertexOutputBlock extends NodeMaterialBlock {
  22314. /**
  22315. * Creates a new VertexOutputBlock
  22316. * @param name defines the block name
  22317. */
  22318. constructor(name: string);
  22319. /**
  22320. * Gets the current class name
  22321. * @returns the class name
  22322. */
  22323. getClassName(): string;
  22324. /**
  22325. * Gets the vector input component
  22326. */
  22327. get vector(): NodeMaterialConnectionPoint;
  22328. protected _buildBlock(state: NodeMaterialBuildState): this;
  22329. }
  22330. }
  22331. declare module BABYLON {
  22332. /**
  22333. * Block used to output the final color
  22334. */
  22335. export class FragmentOutputBlock extends NodeMaterialBlock {
  22336. /**
  22337. * Create a new FragmentOutputBlock
  22338. * @param name defines the block name
  22339. */
  22340. constructor(name: string);
  22341. /**
  22342. * Gets the current class name
  22343. * @returns the class name
  22344. */
  22345. getClassName(): string;
  22346. /**
  22347. * Gets the rgba input component
  22348. */
  22349. get rgba(): NodeMaterialConnectionPoint;
  22350. /**
  22351. * Gets the rgb input component
  22352. */
  22353. get rgb(): NodeMaterialConnectionPoint;
  22354. /**
  22355. * Gets the a input component
  22356. */
  22357. get a(): NodeMaterialConnectionPoint;
  22358. protected _buildBlock(state: NodeMaterialBuildState): this;
  22359. }
  22360. }
  22361. declare module BABYLON {
  22362. /**
  22363. * Block used for the particle ramp gradient section
  22364. */
  22365. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22366. /**
  22367. * Create a new ParticleRampGradientBlock
  22368. * @param name defines the block name
  22369. */
  22370. constructor(name: string);
  22371. /**
  22372. * Gets the current class name
  22373. * @returns the class name
  22374. */
  22375. getClassName(): string;
  22376. /**
  22377. * Gets the color input component
  22378. */
  22379. get color(): NodeMaterialConnectionPoint;
  22380. /**
  22381. * Gets the rampColor output component
  22382. */
  22383. get rampColor(): NodeMaterialConnectionPoint;
  22384. /**
  22385. * Initialize the block and prepare the context for build
  22386. * @param state defines the state that will be used for the build
  22387. */
  22388. initialize(state: NodeMaterialBuildState): void;
  22389. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22390. }
  22391. }
  22392. declare module BABYLON {
  22393. /**
  22394. * Block used for the particle blend multiply section
  22395. */
  22396. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22397. /**
  22398. * Create a new ParticleBlendMultiplyBlock
  22399. * @param name defines the block name
  22400. */
  22401. constructor(name: string);
  22402. /**
  22403. * Gets the current class name
  22404. * @returns the class name
  22405. */
  22406. getClassName(): string;
  22407. /**
  22408. * Gets the color input component
  22409. */
  22410. get color(): NodeMaterialConnectionPoint;
  22411. /**
  22412. * Gets the alphaTexture input component
  22413. */
  22414. get alphaTexture(): NodeMaterialConnectionPoint;
  22415. /**
  22416. * Gets the alphaColor input component
  22417. */
  22418. get alphaColor(): NodeMaterialConnectionPoint;
  22419. /**
  22420. * Gets the blendColor output component
  22421. */
  22422. get blendColor(): NodeMaterialConnectionPoint;
  22423. /**
  22424. * Initialize the block and prepare the context for build
  22425. * @param state defines the state that will be used for the build
  22426. */
  22427. initialize(state: NodeMaterialBuildState): void;
  22428. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22429. }
  22430. }
  22431. declare module BABYLON {
  22432. /**
  22433. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22434. */
  22435. export class VectorMergerBlock extends NodeMaterialBlock {
  22436. /**
  22437. * Create a new VectorMergerBlock
  22438. * @param name defines the block name
  22439. */
  22440. constructor(name: string);
  22441. /**
  22442. * Gets the current class name
  22443. * @returns the class name
  22444. */
  22445. getClassName(): string;
  22446. /**
  22447. * Gets the xyz component (input)
  22448. */
  22449. get xyzIn(): NodeMaterialConnectionPoint;
  22450. /**
  22451. * Gets the xy component (input)
  22452. */
  22453. get xyIn(): NodeMaterialConnectionPoint;
  22454. /**
  22455. * Gets the x component (input)
  22456. */
  22457. get x(): NodeMaterialConnectionPoint;
  22458. /**
  22459. * Gets the y component (input)
  22460. */
  22461. get y(): NodeMaterialConnectionPoint;
  22462. /**
  22463. * Gets the z component (input)
  22464. */
  22465. get z(): NodeMaterialConnectionPoint;
  22466. /**
  22467. * Gets the w component (input)
  22468. */
  22469. get w(): NodeMaterialConnectionPoint;
  22470. /**
  22471. * Gets the xyzw component (output)
  22472. */
  22473. get xyzw(): NodeMaterialConnectionPoint;
  22474. /**
  22475. * Gets the xyz component (output)
  22476. */
  22477. get xyzOut(): NodeMaterialConnectionPoint;
  22478. /**
  22479. * Gets the xy component (output)
  22480. */
  22481. get xyOut(): NodeMaterialConnectionPoint;
  22482. /**
  22483. * Gets the xy component (output)
  22484. * @deprecated Please use xyOut instead.
  22485. */
  22486. get xy(): NodeMaterialConnectionPoint;
  22487. /**
  22488. * Gets the xyz component (output)
  22489. * @deprecated Please use xyzOut instead.
  22490. */
  22491. get xyz(): NodeMaterialConnectionPoint;
  22492. protected _buildBlock(state: NodeMaterialBuildState): this;
  22493. }
  22494. }
  22495. declare module BABYLON {
  22496. /**
  22497. * Block used to remap a float from a range to a new one
  22498. */
  22499. export class RemapBlock extends NodeMaterialBlock {
  22500. /**
  22501. * Gets or sets the source range
  22502. */
  22503. sourceRange: Vector2;
  22504. /**
  22505. * Gets or sets the target range
  22506. */
  22507. targetRange: Vector2;
  22508. /**
  22509. * Creates a new RemapBlock
  22510. * @param name defines the block name
  22511. */
  22512. constructor(name: string);
  22513. /**
  22514. * Gets the current class name
  22515. * @returns the class name
  22516. */
  22517. getClassName(): string;
  22518. /**
  22519. * Gets the input component
  22520. */
  22521. get input(): NodeMaterialConnectionPoint;
  22522. /**
  22523. * Gets the source min input component
  22524. */
  22525. get sourceMin(): NodeMaterialConnectionPoint;
  22526. /**
  22527. * Gets the source max input component
  22528. */
  22529. get sourceMax(): NodeMaterialConnectionPoint;
  22530. /**
  22531. * Gets the target min input component
  22532. */
  22533. get targetMin(): NodeMaterialConnectionPoint;
  22534. /**
  22535. * Gets the target max input component
  22536. */
  22537. get targetMax(): NodeMaterialConnectionPoint;
  22538. /**
  22539. * Gets the output component
  22540. */
  22541. get output(): NodeMaterialConnectionPoint;
  22542. protected _buildBlock(state: NodeMaterialBuildState): this;
  22543. protected _dumpPropertiesCode(): string;
  22544. serialize(): any;
  22545. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22546. }
  22547. }
  22548. declare module BABYLON {
  22549. /**
  22550. * Block used to multiply 2 values
  22551. */
  22552. export class MultiplyBlock extends NodeMaterialBlock {
  22553. /**
  22554. * Creates a new MultiplyBlock
  22555. * @param name defines the block name
  22556. */
  22557. constructor(name: string);
  22558. /**
  22559. * Gets the current class name
  22560. * @returns the class name
  22561. */
  22562. getClassName(): string;
  22563. /**
  22564. * Gets the left operand input component
  22565. */
  22566. get left(): NodeMaterialConnectionPoint;
  22567. /**
  22568. * Gets the right operand input component
  22569. */
  22570. get right(): NodeMaterialConnectionPoint;
  22571. /**
  22572. * Gets the output component
  22573. */
  22574. get output(): NodeMaterialConnectionPoint;
  22575. protected _buildBlock(state: NodeMaterialBuildState): this;
  22576. }
  22577. }
  22578. declare module BABYLON {
  22579. /**
  22580. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22581. */
  22582. export class ColorSplitterBlock extends NodeMaterialBlock {
  22583. /**
  22584. * Create a new ColorSplitterBlock
  22585. * @param name defines the block name
  22586. */
  22587. constructor(name: string);
  22588. /**
  22589. * Gets the current class name
  22590. * @returns the class name
  22591. */
  22592. getClassName(): string;
  22593. /**
  22594. * Gets the rgba component (input)
  22595. */
  22596. get rgba(): NodeMaterialConnectionPoint;
  22597. /**
  22598. * Gets the rgb component (input)
  22599. */
  22600. get rgbIn(): NodeMaterialConnectionPoint;
  22601. /**
  22602. * Gets the rgb component (output)
  22603. */
  22604. get rgbOut(): NodeMaterialConnectionPoint;
  22605. /**
  22606. * Gets the r component (output)
  22607. */
  22608. get r(): NodeMaterialConnectionPoint;
  22609. /**
  22610. * Gets the g component (output)
  22611. */
  22612. get g(): NodeMaterialConnectionPoint;
  22613. /**
  22614. * Gets the b component (output)
  22615. */
  22616. get b(): NodeMaterialConnectionPoint;
  22617. /**
  22618. * Gets the a component (output)
  22619. */
  22620. get a(): NodeMaterialConnectionPoint;
  22621. protected _inputRename(name: string): string;
  22622. protected _outputRename(name: string): string;
  22623. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22624. }
  22625. }
  22626. declare module BABYLON {
  22627. /**
  22628. * Operations supported by the Trigonometry block
  22629. */
  22630. export enum TrigonometryBlockOperations {
  22631. /** Cos */
  22632. Cos = 0,
  22633. /** Sin */
  22634. Sin = 1,
  22635. /** Abs */
  22636. Abs = 2,
  22637. /** Exp */
  22638. Exp = 3,
  22639. /** Exp2 */
  22640. Exp2 = 4,
  22641. /** Round */
  22642. Round = 5,
  22643. /** Floor */
  22644. Floor = 6,
  22645. /** Ceiling */
  22646. Ceiling = 7,
  22647. /** Square root */
  22648. Sqrt = 8,
  22649. /** Log */
  22650. Log = 9,
  22651. /** Tangent */
  22652. Tan = 10,
  22653. /** Arc tangent */
  22654. ArcTan = 11,
  22655. /** Arc cosinus */
  22656. ArcCos = 12,
  22657. /** Arc sinus */
  22658. ArcSin = 13,
  22659. /** Fraction */
  22660. Fract = 14,
  22661. /** Sign */
  22662. Sign = 15,
  22663. /** To radians (from degrees) */
  22664. Radians = 16,
  22665. /** To degrees (from radians) */
  22666. Degrees = 17
  22667. }
  22668. /**
  22669. * Block used to apply trigonometry operation to floats
  22670. */
  22671. export class TrigonometryBlock extends NodeMaterialBlock {
  22672. /**
  22673. * Gets or sets the operation applied by the block
  22674. */
  22675. operation: TrigonometryBlockOperations;
  22676. /**
  22677. * Creates a new TrigonometryBlock
  22678. * @param name defines the block name
  22679. */
  22680. constructor(name: string);
  22681. /**
  22682. * Gets the current class name
  22683. * @returns the class name
  22684. */
  22685. getClassName(): string;
  22686. /**
  22687. * Gets the input component
  22688. */
  22689. get input(): NodeMaterialConnectionPoint;
  22690. /**
  22691. * Gets the output component
  22692. */
  22693. get output(): NodeMaterialConnectionPoint;
  22694. protected _buildBlock(state: NodeMaterialBuildState): this;
  22695. serialize(): any;
  22696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22697. protected _dumpPropertiesCode(): string;
  22698. }
  22699. }
  22700. declare module BABYLON {
  22701. /**
  22702. * Interface used to configure the node material editor
  22703. */
  22704. export interface INodeMaterialEditorOptions {
  22705. /** Define the URl to load node editor script */
  22706. editorURL?: string;
  22707. }
  22708. /** @hidden */
  22709. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22710. NORMAL: boolean;
  22711. TANGENT: boolean;
  22712. UV1: boolean;
  22713. /** BONES */
  22714. NUM_BONE_INFLUENCERS: number;
  22715. BonesPerMesh: number;
  22716. BONETEXTURE: boolean;
  22717. /** MORPH TARGETS */
  22718. MORPHTARGETS: boolean;
  22719. MORPHTARGETS_NORMAL: boolean;
  22720. MORPHTARGETS_TANGENT: boolean;
  22721. MORPHTARGETS_UV: boolean;
  22722. NUM_MORPH_INFLUENCERS: number;
  22723. /** IMAGE PROCESSING */
  22724. IMAGEPROCESSING: boolean;
  22725. VIGNETTE: boolean;
  22726. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22727. VIGNETTEBLENDMODEOPAQUE: boolean;
  22728. TONEMAPPING: boolean;
  22729. TONEMAPPING_ACES: boolean;
  22730. CONTRAST: boolean;
  22731. EXPOSURE: boolean;
  22732. COLORCURVES: boolean;
  22733. COLORGRADING: boolean;
  22734. COLORGRADING3D: boolean;
  22735. SAMPLER3DGREENDEPTH: boolean;
  22736. SAMPLER3DBGRMAP: boolean;
  22737. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22738. /** MISC. */
  22739. BUMPDIRECTUV: number;
  22740. constructor();
  22741. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22742. }
  22743. /**
  22744. * Class used to configure NodeMaterial
  22745. */
  22746. export interface INodeMaterialOptions {
  22747. /**
  22748. * Defines if blocks should emit comments
  22749. */
  22750. emitComments: boolean;
  22751. }
  22752. /**
  22753. * Class used to create a node based material built by assembling shader blocks
  22754. */
  22755. export class NodeMaterial extends PushMaterial {
  22756. private static _BuildIdGenerator;
  22757. private _options;
  22758. private _vertexCompilationState;
  22759. private _fragmentCompilationState;
  22760. private _sharedData;
  22761. private _buildId;
  22762. private _buildWasSuccessful;
  22763. private _cachedWorldViewMatrix;
  22764. private _cachedWorldViewProjectionMatrix;
  22765. private _optimizers;
  22766. private _animationFrame;
  22767. /** Define the Url to load node editor script */
  22768. static EditorURL: string;
  22769. /** Define the Url to load snippets */
  22770. static SnippetUrl: string;
  22771. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22772. static IgnoreTexturesAtLoadTime: boolean;
  22773. private BJSNODEMATERIALEDITOR;
  22774. /** Get the inspector from bundle or global */
  22775. private _getGlobalNodeMaterialEditor;
  22776. /**
  22777. * Snippet ID if the material was created from the snippet server
  22778. */
  22779. snippetId: string;
  22780. /**
  22781. * Gets or sets data used by visual editor
  22782. * @see https://nme.babylonjs.com
  22783. */
  22784. editorData: any;
  22785. /**
  22786. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  22787. */
  22788. ignoreAlpha: boolean;
  22789. /**
  22790. * Defines the maximum number of lights that can be used in the material
  22791. */
  22792. maxSimultaneousLights: number;
  22793. /**
  22794. * Observable raised when the material is built
  22795. */
  22796. onBuildObservable: Observable<NodeMaterial>;
  22797. /**
  22798. * Gets or sets the root nodes of the material vertex shader
  22799. */
  22800. _vertexOutputNodes: NodeMaterialBlock[];
  22801. /**
  22802. * Gets or sets the root nodes of the material fragment (pixel) shader
  22803. */
  22804. _fragmentOutputNodes: NodeMaterialBlock[];
  22805. /** Gets or sets options to control the node material overall behavior */
  22806. get options(): INodeMaterialOptions;
  22807. set options(options: INodeMaterialOptions);
  22808. /**
  22809. * Default configuration related to image processing available in the standard Material.
  22810. */
  22811. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22812. /**
  22813. * Gets the image processing configuration used either in this material.
  22814. */
  22815. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22816. /**
  22817. * Sets the Default image processing configuration used either in the this material.
  22818. *
  22819. * If sets to null, the scene one is in use.
  22820. */
  22821. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22822. /**
  22823. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22824. */
  22825. attachedBlocks: NodeMaterialBlock[];
  22826. /**
  22827. * Specifies the mode of the node material
  22828. * @hidden
  22829. */
  22830. _mode: NodeMaterialModes;
  22831. /**
  22832. * Gets the mode property
  22833. */
  22834. get mode(): NodeMaterialModes;
  22835. /**
  22836. * A free comment about the material
  22837. */
  22838. comment: string;
  22839. /**
  22840. * Create a new node based material
  22841. * @param name defines the material name
  22842. * @param scene defines the hosting scene
  22843. * @param options defines creation option
  22844. */
  22845. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22846. /**
  22847. * Gets the current class name of the material e.g. "NodeMaterial"
  22848. * @returns the class name
  22849. */
  22850. getClassName(): string;
  22851. /**
  22852. * Keep track of the image processing observer to allow dispose and replace.
  22853. */
  22854. private _imageProcessingObserver;
  22855. /**
  22856. * Attaches a new image processing configuration to the Standard Material.
  22857. * @param configuration
  22858. */
  22859. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22860. /**
  22861. * Get a block by its name
  22862. * @param name defines the name of the block to retrieve
  22863. * @returns the required block or null if not found
  22864. */
  22865. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22866. /**
  22867. * Get a block by its name
  22868. * @param predicate defines the predicate used to find the good candidate
  22869. * @returns the required block or null if not found
  22870. */
  22871. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22872. /**
  22873. * Get an input block by its name
  22874. * @param predicate defines the predicate used to find the good candidate
  22875. * @returns the required input block or null if not found
  22876. */
  22877. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22878. /**
  22879. * Gets the list of input blocks attached to this material
  22880. * @returns an array of InputBlocks
  22881. */
  22882. getInputBlocks(): InputBlock[];
  22883. /**
  22884. * Adds a new optimizer to the list of optimizers
  22885. * @param optimizer defines the optimizers to add
  22886. * @returns the current material
  22887. */
  22888. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22889. /**
  22890. * Remove an optimizer from the list of optimizers
  22891. * @param optimizer defines the optimizers to remove
  22892. * @returns the current material
  22893. */
  22894. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22895. /**
  22896. * Add a new block to the list of output nodes
  22897. * @param node defines the node to add
  22898. * @returns the current material
  22899. */
  22900. addOutputNode(node: NodeMaterialBlock): this;
  22901. /**
  22902. * Remove a block from the list of root nodes
  22903. * @param node defines the node to remove
  22904. * @returns the current material
  22905. */
  22906. removeOutputNode(node: NodeMaterialBlock): this;
  22907. private _addVertexOutputNode;
  22908. private _removeVertexOutputNode;
  22909. private _addFragmentOutputNode;
  22910. private _removeFragmentOutputNode;
  22911. /**
  22912. * Specifies if the material will require alpha blending
  22913. * @returns a boolean specifying if alpha blending is needed
  22914. */
  22915. needAlphaBlending(): boolean;
  22916. /**
  22917. * Specifies if this material should be rendered in alpha test mode
  22918. * @returns a boolean specifying if an alpha test is needed.
  22919. */
  22920. needAlphaTesting(): boolean;
  22921. private _initializeBlock;
  22922. private _resetDualBlocks;
  22923. /**
  22924. * Remove a block from the current node material
  22925. * @param block defines the block to remove
  22926. */
  22927. removeBlock(block: NodeMaterialBlock): void;
  22928. /**
  22929. * Build the material and generates the inner effect
  22930. * @param verbose defines if the build should log activity
  22931. */
  22932. build(verbose?: boolean): void;
  22933. /**
  22934. * Runs an otpimization phase to try to improve the shader code
  22935. */
  22936. optimize(): void;
  22937. private _prepareDefinesForAttributes;
  22938. /**
  22939. * Create a post process from the material
  22940. * @param camera The camera to apply the render pass to.
  22941. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22943. * @param engine The engine which the post process will be applied. (default: current engine)
  22944. * @param reusable If the post process can be reused on the same frame. (default: false)
  22945. * @param textureType Type of textures used when performing the post process. (default: 0)
  22946. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22947. * @returns the post process created
  22948. */
  22949. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22950. /**
  22951. * Create the post process effect from the material
  22952. * @param postProcess The post process to create the effect for
  22953. */
  22954. createEffectForPostProcess(postProcess: PostProcess): void;
  22955. private _createEffectForPostProcess;
  22956. /**
  22957. * Create a new procedural texture based on this node material
  22958. * @param size defines the size of the texture
  22959. * @param scene defines the hosting scene
  22960. * @returns the new procedural texture attached to this node material
  22961. */
  22962. createProceduralTexture(size: number | {
  22963. width: number;
  22964. height: number;
  22965. layers?: number;
  22966. }, scene: Scene): Nullable<ProceduralTexture>;
  22967. private _createEffectForParticles;
  22968. private _checkInternals;
  22969. /**
  22970. * Create the effect to be used as the custom effect for a particle system
  22971. * @param particleSystem Particle system to create the effect for
  22972. * @param onCompiled defines a function to call when the effect creation is successful
  22973. * @param onError defines a function to call when the effect creation has failed
  22974. */
  22975. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22976. private _processDefines;
  22977. /**
  22978. * Get if the submesh is ready to be used and all its information available.
  22979. * Child classes can use it to update shaders
  22980. * @param mesh defines the mesh to check
  22981. * @param subMesh defines which submesh to check
  22982. * @param useInstances specifies that instances should be used
  22983. * @returns a boolean indicating that the submesh is ready or not
  22984. */
  22985. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22986. /**
  22987. * Get a string representing the shaders built by the current node graph
  22988. */
  22989. get compiledShaders(): string;
  22990. /**
  22991. * Binds the world matrix to the material
  22992. * @param world defines the world transformation matrix
  22993. */
  22994. bindOnlyWorldMatrix(world: Matrix): void;
  22995. /**
  22996. * Binds the submesh to this material by preparing the effect and shader to draw
  22997. * @param world defines the world transformation matrix
  22998. * @param mesh defines the mesh containing the submesh
  22999. * @param subMesh defines the submesh to bind the material to
  23000. */
  23001. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23002. /**
  23003. * Gets the active textures from the material
  23004. * @returns an array of textures
  23005. */
  23006. getActiveTextures(): BaseTexture[];
  23007. /**
  23008. * Gets the list of texture blocks
  23009. * @returns an array of texture blocks
  23010. */
  23011. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23012. /**
  23013. * Specifies if the material uses a texture
  23014. * @param texture defines the texture to check against the material
  23015. * @returns a boolean specifying if the material uses the texture
  23016. */
  23017. hasTexture(texture: BaseTexture): boolean;
  23018. /**
  23019. * Disposes the material
  23020. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23021. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23022. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23023. */
  23024. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23025. /** Creates the node editor window. */
  23026. private _createNodeEditor;
  23027. /**
  23028. * Launch the node material editor
  23029. * @param config Define the configuration of the editor
  23030. * @return a promise fulfilled when the node editor is visible
  23031. */
  23032. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23033. /**
  23034. * Clear the current material
  23035. */
  23036. clear(): void;
  23037. /**
  23038. * Clear the current material and set it to a default state
  23039. */
  23040. setToDefault(): void;
  23041. /**
  23042. * Clear the current material and set it to a default state for post process
  23043. */
  23044. setToDefaultPostProcess(): void;
  23045. /**
  23046. * Clear the current material and set it to a default state for procedural texture
  23047. */
  23048. setToDefaultProceduralTexture(): void;
  23049. /**
  23050. * Clear the current material and set it to a default state for particle
  23051. */
  23052. setToDefaultParticle(): void;
  23053. /**
  23054. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23055. * @param url defines the url to load from
  23056. * @returns a promise that will fullfil when the material is fully loaded
  23057. */
  23058. loadAsync(url: string): Promise<void>;
  23059. private _gatherBlocks;
  23060. /**
  23061. * Generate a string containing the code declaration required to create an equivalent of this material
  23062. * @returns a string
  23063. */
  23064. generateCode(): string;
  23065. /**
  23066. * Serializes this material in a JSON representation
  23067. * @returns the serialized material object
  23068. */
  23069. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23070. private _restoreConnections;
  23071. /**
  23072. * Clear the current graph and load a new one from a serialization object
  23073. * @param source defines the JSON representation of the material
  23074. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23075. * @param merge defines whether or not the source must be merged or replace the current content
  23076. */
  23077. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23078. /**
  23079. * Makes a duplicate of the current material.
  23080. * @param name - name to use for the new material.
  23081. */
  23082. clone(name: string): NodeMaterial;
  23083. /**
  23084. * Creates a node material from parsed material data
  23085. * @param source defines the JSON representation of the material
  23086. * @param scene defines the hosting scene
  23087. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23088. * @returns a new node material
  23089. */
  23090. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23091. /**
  23092. * Creates a node material from a snippet saved in a remote file
  23093. * @param name defines the name of the material to create
  23094. * @param url defines the url to load from
  23095. * @param scene defines the hosting scene
  23096. * @returns a promise that will resolve to the new node material
  23097. */
  23098. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23099. /**
  23100. * Creates a node material from a snippet saved by the node material editor
  23101. * @param snippetId defines the snippet to load
  23102. * @param scene defines the hosting scene
  23103. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23104. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23105. * @returns a promise that will resolve to the new node material
  23106. */
  23107. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23108. /**
  23109. * Creates a new node material set to default basic configuration
  23110. * @param name defines the name of the material
  23111. * @param scene defines the hosting scene
  23112. * @returns a new NodeMaterial
  23113. */
  23114. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23115. }
  23116. }
  23117. declare module BABYLON {
  23118. interface ThinEngine {
  23119. /**
  23120. * Unbind a list of render target textures from the webGL context
  23121. * This is used only when drawBuffer extension or webGL2 are active
  23122. * @param textures defines the render target textures to unbind
  23123. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23124. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23125. */
  23126. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23127. /**
  23128. * Create a multi render target texture
  23129. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23130. * @param size defines the size of the texture
  23131. * @param options defines the creation options
  23132. * @returns the cube texture as an InternalTexture
  23133. */
  23134. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23135. /**
  23136. * Update the sample count for a given multiple render target texture
  23137. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23138. * @param textures defines the textures to update
  23139. * @param samples defines the sample count to set
  23140. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23141. */
  23142. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23143. /**
  23144. * Select a subsets of attachments to draw to.
  23145. * @param attachments gl attachments
  23146. */
  23147. bindAttachments(attachments: number[]): void;
  23148. /**
  23149. * Creates a layout object to draw/clear on specific textures in a MRT
  23150. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23151. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23152. */
  23153. buildTextureLayout(textureStatus: boolean[]): number[];
  23154. /**
  23155. * Restores the webgl state to only draw on the main color attachment
  23156. */
  23157. restoreSingleAttachment(): void;
  23158. }
  23159. }
  23160. declare module BABYLON {
  23161. /**
  23162. * Creation options of the multi render target texture.
  23163. */
  23164. export interface IMultiRenderTargetOptions {
  23165. /**
  23166. * Define if the texture needs to create mip maps after render.
  23167. */
  23168. generateMipMaps?: boolean;
  23169. /**
  23170. * Define the types of all the draw buffers we want to create
  23171. */
  23172. types?: number[];
  23173. /**
  23174. * Define the sampling modes of all the draw buffers we want to create
  23175. */
  23176. samplingModes?: number[];
  23177. /**
  23178. * Define if a depth buffer is required
  23179. */
  23180. generateDepthBuffer?: boolean;
  23181. /**
  23182. * Define if a stencil buffer is required
  23183. */
  23184. generateStencilBuffer?: boolean;
  23185. /**
  23186. * Define if a depth texture is required instead of a depth buffer
  23187. */
  23188. generateDepthTexture?: boolean;
  23189. /**
  23190. * Define the number of desired draw buffers
  23191. */
  23192. textureCount?: number;
  23193. /**
  23194. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23195. */
  23196. doNotChangeAspectRatio?: boolean;
  23197. /**
  23198. * Define the default type of the buffers we are creating
  23199. */
  23200. defaultType?: number;
  23201. }
  23202. /**
  23203. * A multi render target, like a render target provides the ability to render to a texture.
  23204. * Unlike the render target, it can render to several draw buffers in one draw.
  23205. * This is specially interesting in deferred rendering or for any effects requiring more than
  23206. * just one color from a single pass.
  23207. */
  23208. export class MultiRenderTarget extends RenderTargetTexture {
  23209. private _internalTextures;
  23210. private _textures;
  23211. private _multiRenderTargetOptions;
  23212. private _count;
  23213. /**
  23214. * Get if draw buffers are currently supported by the used hardware and browser.
  23215. */
  23216. get isSupported(): boolean;
  23217. /**
  23218. * Get the list of textures generated by the multi render target.
  23219. */
  23220. get textures(): Texture[];
  23221. /**
  23222. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23223. */
  23224. get count(): number;
  23225. /**
  23226. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23227. */
  23228. get depthTexture(): Texture;
  23229. /**
  23230. * Set the wrapping mode on U of all the textures we are rendering to.
  23231. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23232. */
  23233. set wrapU(wrap: number);
  23234. /**
  23235. * Set the wrapping mode on V of all the textures we are rendering to.
  23236. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23237. */
  23238. set wrapV(wrap: number);
  23239. /**
  23240. * Instantiate a new multi render target texture.
  23241. * A multi render target, like a render target provides the ability to render to a texture.
  23242. * Unlike the render target, it can render to several draw buffers in one draw.
  23243. * This is specially interesting in deferred rendering or for any effects requiring more than
  23244. * just one color from a single pass.
  23245. * @param name Define the name of the texture
  23246. * @param size Define the size of the buffers to render to
  23247. * @param count Define the number of target we are rendering into
  23248. * @param scene Define the scene the texture belongs to
  23249. * @param options Define the options used to create the multi render target
  23250. */
  23251. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23252. private _initTypes;
  23253. /** @hidden */
  23254. _rebuild(forceFullRebuild?: boolean): void;
  23255. private _createInternalTextures;
  23256. private _createTextures;
  23257. /**
  23258. * Replaces a texture within the MRT.
  23259. * @param texture The new texture to insert in the MRT
  23260. * @param index The index of the texture to replace
  23261. */
  23262. replaceTexture(texture: Texture, index: number): void;
  23263. /**
  23264. * Define the number of samples used if MSAA is enabled.
  23265. */
  23266. get samples(): number;
  23267. set samples(value: number);
  23268. /**
  23269. * Resize all the textures in the multi render target.
  23270. * Be careful as it will recreate all the data in the new texture.
  23271. * @param size Define the new size
  23272. */
  23273. resize(size: any): void;
  23274. /**
  23275. * Changes the number of render targets in this MRT
  23276. * Be careful as it will recreate all the data in the new texture.
  23277. * @param count new texture count
  23278. * @param options Specifies texture types and sampling modes for new textures
  23279. */
  23280. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23281. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23282. /**
  23283. * Dispose the render targets and their associated resources
  23284. */
  23285. dispose(): void;
  23286. /**
  23287. * Release all the underlying texture used as draw buffers.
  23288. */
  23289. releaseInternalTextures(): void;
  23290. }
  23291. }
  23292. declare module BABYLON {
  23293. /** @hidden */
  23294. export var imageProcessingPixelShader: {
  23295. name: string;
  23296. shader: string;
  23297. };
  23298. }
  23299. declare module BABYLON {
  23300. /**
  23301. * ImageProcessingPostProcess
  23302. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23303. */
  23304. export class ImageProcessingPostProcess extends PostProcess {
  23305. /**
  23306. * Default configuration related to image processing available in the PBR Material.
  23307. */
  23308. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23309. /**
  23310. * Gets the image processing configuration used either in this material.
  23311. */
  23312. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23313. /**
  23314. * Sets the Default image processing configuration used either in the this material.
  23315. *
  23316. * If sets to null, the scene one is in use.
  23317. */
  23318. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23319. /**
  23320. * Keep track of the image processing observer to allow dispose and replace.
  23321. */
  23322. private _imageProcessingObserver;
  23323. /**
  23324. * Attaches a new image processing configuration to the PBR Material.
  23325. * @param configuration
  23326. */
  23327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23328. /**
  23329. * If the post process is supported.
  23330. */
  23331. get isSupported(): boolean;
  23332. /**
  23333. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23334. */
  23335. get colorCurves(): Nullable<ColorCurves>;
  23336. /**
  23337. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23338. */
  23339. set colorCurves(value: Nullable<ColorCurves>);
  23340. /**
  23341. * Gets wether the color curves effect is enabled.
  23342. */
  23343. get colorCurvesEnabled(): boolean;
  23344. /**
  23345. * Sets wether the color curves effect is enabled.
  23346. */
  23347. set colorCurvesEnabled(value: boolean);
  23348. /**
  23349. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23350. */
  23351. get colorGradingTexture(): Nullable<BaseTexture>;
  23352. /**
  23353. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23354. */
  23355. set colorGradingTexture(value: Nullable<BaseTexture>);
  23356. /**
  23357. * Gets wether the color grading effect is enabled.
  23358. */
  23359. get colorGradingEnabled(): boolean;
  23360. /**
  23361. * Gets wether the color grading effect is enabled.
  23362. */
  23363. set colorGradingEnabled(value: boolean);
  23364. /**
  23365. * Gets exposure used in the effect.
  23366. */
  23367. get exposure(): number;
  23368. /**
  23369. * Sets exposure used in the effect.
  23370. */
  23371. set exposure(value: number);
  23372. /**
  23373. * Gets wether tonemapping is enabled or not.
  23374. */
  23375. get toneMappingEnabled(): boolean;
  23376. /**
  23377. * Sets wether tonemapping is enabled or not
  23378. */
  23379. set toneMappingEnabled(value: boolean);
  23380. /**
  23381. * Gets the type of tone mapping effect.
  23382. */
  23383. get toneMappingType(): number;
  23384. /**
  23385. * Sets the type of tone mapping effect.
  23386. */
  23387. set toneMappingType(value: number);
  23388. /**
  23389. * Gets contrast used in the effect.
  23390. */
  23391. get contrast(): number;
  23392. /**
  23393. * Sets contrast used in the effect.
  23394. */
  23395. set contrast(value: number);
  23396. /**
  23397. * Gets Vignette stretch size.
  23398. */
  23399. get vignetteStretch(): number;
  23400. /**
  23401. * Sets Vignette stretch size.
  23402. */
  23403. set vignetteStretch(value: number);
  23404. /**
  23405. * Gets Vignette centre X Offset.
  23406. */
  23407. get vignetteCentreX(): number;
  23408. /**
  23409. * Sets Vignette centre X Offset.
  23410. */
  23411. set vignetteCentreX(value: number);
  23412. /**
  23413. * Gets Vignette centre Y Offset.
  23414. */
  23415. get vignetteCentreY(): number;
  23416. /**
  23417. * Sets Vignette centre Y Offset.
  23418. */
  23419. set vignetteCentreY(value: number);
  23420. /**
  23421. * Gets Vignette weight or intensity of the vignette effect.
  23422. */
  23423. get vignetteWeight(): number;
  23424. /**
  23425. * Sets Vignette weight or intensity of the vignette effect.
  23426. */
  23427. set vignetteWeight(value: number);
  23428. /**
  23429. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23430. * if vignetteEnabled is set to true.
  23431. */
  23432. get vignetteColor(): Color4;
  23433. /**
  23434. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23435. * if vignetteEnabled is set to true.
  23436. */
  23437. set vignetteColor(value: Color4);
  23438. /**
  23439. * Gets Camera field of view used by the Vignette effect.
  23440. */
  23441. get vignetteCameraFov(): number;
  23442. /**
  23443. * Sets Camera field of view used by the Vignette effect.
  23444. */
  23445. set vignetteCameraFov(value: number);
  23446. /**
  23447. * Gets the vignette blend mode allowing different kind of effect.
  23448. */
  23449. get vignetteBlendMode(): number;
  23450. /**
  23451. * Sets the vignette blend mode allowing different kind of effect.
  23452. */
  23453. set vignetteBlendMode(value: number);
  23454. /**
  23455. * Gets wether the vignette effect is enabled.
  23456. */
  23457. get vignetteEnabled(): boolean;
  23458. /**
  23459. * Sets wether the vignette effect is enabled.
  23460. */
  23461. set vignetteEnabled(value: boolean);
  23462. private _fromLinearSpace;
  23463. /**
  23464. * Gets wether the input of the processing is in Gamma or Linear Space.
  23465. */
  23466. get fromLinearSpace(): boolean;
  23467. /**
  23468. * Sets wether the input of the processing is in Gamma or Linear Space.
  23469. */
  23470. set fromLinearSpace(value: boolean);
  23471. /**
  23472. * Defines cache preventing GC.
  23473. */
  23474. private _defines;
  23475. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23476. /**
  23477. * "ImageProcessingPostProcess"
  23478. * @returns "ImageProcessingPostProcess"
  23479. */
  23480. getClassName(): string;
  23481. /**
  23482. * @hidden
  23483. */
  23484. _updateParameters(): void;
  23485. dispose(camera?: Camera): void;
  23486. }
  23487. }
  23488. declare module BABYLON {
  23489. /**
  23490. * Interface for defining prepass effects in the prepass post-process pipeline
  23491. */
  23492. export interface PrePassEffectConfiguration {
  23493. /**
  23494. * Name of the effect
  23495. */
  23496. name: string;
  23497. /**
  23498. * Post process to attach for this effect
  23499. */
  23500. postProcess?: PostProcess;
  23501. /**
  23502. * Textures required in the MRT
  23503. */
  23504. texturesRequired: number[];
  23505. /**
  23506. * Is the effect enabled
  23507. */
  23508. enabled: boolean;
  23509. /**
  23510. * Disposes the effect configuration
  23511. */
  23512. dispose?: () => void;
  23513. /**
  23514. * Creates the associated post process
  23515. */
  23516. createPostProcess?: () => PostProcess;
  23517. }
  23518. }
  23519. declare module BABYLON {
  23520. /**
  23521. * Options to be used when creating a FresnelParameters.
  23522. */
  23523. export type IFresnelParametersCreationOptions = {
  23524. /**
  23525. * Define the color used on edges (grazing angle)
  23526. */
  23527. leftColor?: Color3;
  23528. /**
  23529. * Define the color used on center
  23530. */
  23531. rightColor?: Color3;
  23532. /**
  23533. * Define bias applied to computed fresnel term
  23534. */
  23535. bias?: number;
  23536. /**
  23537. * Defined the power exponent applied to fresnel term
  23538. */
  23539. power?: number;
  23540. /**
  23541. * Define if the fresnel effect is enable or not.
  23542. */
  23543. isEnabled?: boolean;
  23544. };
  23545. /**
  23546. * Serialized format for FresnelParameters.
  23547. */
  23548. export type IFresnelParametersSerialized = {
  23549. /**
  23550. * Define the color used on edges (grazing angle) [as an array]
  23551. */
  23552. leftColor: number[];
  23553. /**
  23554. * Define the color used on center [as an array]
  23555. */
  23556. rightColor: number[];
  23557. /**
  23558. * Define bias applied to computed fresnel term
  23559. */
  23560. bias: number;
  23561. /**
  23562. * Defined the power exponent applied to fresnel term
  23563. */
  23564. power?: number;
  23565. /**
  23566. * Define if the fresnel effect is enable or not.
  23567. */
  23568. isEnabled: boolean;
  23569. };
  23570. /**
  23571. * This represents all the required information to add a fresnel effect on a material:
  23572. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23573. */
  23574. export class FresnelParameters {
  23575. private _isEnabled;
  23576. /**
  23577. * Define if the fresnel effect is enable or not.
  23578. */
  23579. get isEnabled(): boolean;
  23580. set isEnabled(value: boolean);
  23581. /**
  23582. * Define the color used on edges (grazing angle)
  23583. */
  23584. leftColor: Color3;
  23585. /**
  23586. * Define the color used on center
  23587. */
  23588. rightColor: Color3;
  23589. /**
  23590. * Define bias applied to computed fresnel term
  23591. */
  23592. bias: number;
  23593. /**
  23594. * Defined the power exponent applied to fresnel term
  23595. */
  23596. power: number;
  23597. /**
  23598. * Creates a new FresnelParameters object.
  23599. *
  23600. * @param options provide your own settings to optionally to override defaults
  23601. */
  23602. constructor(options?: IFresnelParametersCreationOptions);
  23603. /**
  23604. * Clones the current fresnel and its valuues
  23605. * @returns a clone fresnel configuration
  23606. */
  23607. clone(): FresnelParameters;
  23608. /**
  23609. * Determines equality between FresnelParameters objects
  23610. * @param otherFresnelParameters defines the second operand
  23611. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  23612. */
  23613. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  23614. /**
  23615. * Serializes the current fresnel parameters to a JSON representation.
  23616. * @return the JSON serialization
  23617. */
  23618. serialize(): IFresnelParametersSerialized;
  23619. /**
  23620. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  23621. * @param parsedFresnelParameters Define the JSON representation
  23622. * @returns the parsed parameters
  23623. */
  23624. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  23625. }
  23626. }
  23627. declare module BABYLON {
  23628. /**
  23629. * This groups all the flags used to control the materials channel.
  23630. */
  23631. export class MaterialFlags {
  23632. private static _DiffuseTextureEnabled;
  23633. /**
  23634. * Are diffuse textures enabled in the application.
  23635. */
  23636. static get DiffuseTextureEnabled(): boolean;
  23637. static set DiffuseTextureEnabled(value: boolean);
  23638. private static _DetailTextureEnabled;
  23639. /**
  23640. * Are detail textures enabled in the application.
  23641. */
  23642. static get DetailTextureEnabled(): boolean;
  23643. static set DetailTextureEnabled(value: boolean);
  23644. private static _AmbientTextureEnabled;
  23645. /**
  23646. * Are ambient textures enabled in the application.
  23647. */
  23648. static get AmbientTextureEnabled(): boolean;
  23649. static set AmbientTextureEnabled(value: boolean);
  23650. private static _OpacityTextureEnabled;
  23651. /**
  23652. * Are opacity textures enabled in the application.
  23653. */
  23654. static get OpacityTextureEnabled(): boolean;
  23655. static set OpacityTextureEnabled(value: boolean);
  23656. private static _ReflectionTextureEnabled;
  23657. /**
  23658. * Are reflection textures enabled in the application.
  23659. */
  23660. static get ReflectionTextureEnabled(): boolean;
  23661. static set ReflectionTextureEnabled(value: boolean);
  23662. private static _EmissiveTextureEnabled;
  23663. /**
  23664. * Are emissive textures enabled in the application.
  23665. */
  23666. static get EmissiveTextureEnabled(): boolean;
  23667. static set EmissiveTextureEnabled(value: boolean);
  23668. private static _SpecularTextureEnabled;
  23669. /**
  23670. * Are specular textures enabled in the application.
  23671. */
  23672. static get SpecularTextureEnabled(): boolean;
  23673. static set SpecularTextureEnabled(value: boolean);
  23674. private static _BumpTextureEnabled;
  23675. /**
  23676. * Are bump textures enabled in the application.
  23677. */
  23678. static get BumpTextureEnabled(): boolean;
  23679. static set BumpTextureEnabled(value: boolean);
  23680. private static _LightmapTextureEnabled;
  23681. /**
  23682. * Are lightmap textures enabled in the application.
  23683. */
  23684. static get LightmapTextureEnabled(): boolean;
  23685. static set LightmapTextureEnabled(value: boolean);
  23686. private static _RefractionTextureEnabled;
  23687. /**
  23688. * Are refraction textures enabled in the application.
  23689. */
  23690. static get RefractionTextureEnabled(): boolean;
  23691. static set RefractionTextureEnabled(value: boolean);
  23692. private static _ColorGradingTextureEnabled;
  23693. /**
  23694. * Are color grading textures enabled in the application.
  23695. */
  23696. static get ColorGradingTextureEnabled(): boolean;
  23697. static set ColorGradingTextureEnabled(value: boolean);
  23698. private static _FresnelEnabled;
  23699. /**
  23700. * Are fresnels enabled in the application.
  23701. */
  23702. static get FresnelEnabled(): boolean;
  23703. static set FresnelEnabled(value: boolean);
  23704. private static _ClearCoatTextureEnabled;
  23705. /**
  23706. * Are clear coat textures enabled in the application.
  23707. */
  23708. static get ClearCoatTextureEnabled(): boolean;
  23709. static set ClearCoatTextureEnabled(value: boolean);
  23710. private static _ClearCoatBumpTextureEnabled;
  23711. /**
  23712. * Are clear coat bump textures enabled in the application.
  23713. */
  23714. static get ClearCoatBumpTextureEnabled(): boolean;
  23715. static set ClearCoatBumpTextureEnabled(value: boolean);
  23716. private static _ClearCoatTintTextureEnabled;
  23717. /**
  23718. * Are clear coat tint textures enabled in the application.
  23719. */
  23720. static get ClearCoatTintTextureEnabled(): boolean;
  23721. static set ClearCoatTintTextureEnabled(value: boolean);
  23722. private static _SheenTextureEnabled;
  23723. /**
  23724. * Are sheen textures enabled in the application.
  23725. */
  23726. static get SheenTextureEnabled(): boolean;
  23727. static set SheenTextureEnabled(value: boolean);
  23728. private static _AnisotropicTextureEnabled;
  23729. /**
  23730. * Are anisotropic textures enabled in the application.
  23731. */
  23732. static get AnisotropicTextureEnabled(): boolean;
  23733. static set AnisotropicTextureEnabled(value: boolean);
  23734. private static _ThicknessTextureEnabled;
  23735. /**
  23736. * Are thickness textures enabled in the application.
  23737. */
  23738. static get ThicknessTextureEnabled(): boolean;
  23739. static set ThicknessTextureEnabled(value: boolean);
  23740. }
  23741. }
  23742. declare module BABYLON {
  23743. /** @hidden */
  23744. export var defaultFragmentDeclaration: {
  23745. name: string;
  23746. shader: string;
  23747. };
  23748. }
  23749. declare module BABYLON {
  23750. /** @hidden */
  23751. export var defaultUboDeclaration: {
  23752. name: string;
  23753. shader: string;
  23754. };
  23755. }
  23756. declare module BABYLON {
  23757. /** @hidden */
  23758. export var prePassDeclaration: {
  23759. name: string;
  23760. shader: string;
  23761. };
  23762. }
  23763. declare module BABYLON {
  23764. /** @hidden */
  23765. export var lightFragmentDeclaration: {
  23766. name: string;
  23767. shader: string;
  23768. };
  23769. }
  23770. declare module BABYLON {
  23771. /** @hidden */
  23772. export var lightUboDeclaration: {
  23773. name: string;
  23774. shader: string;
  23775. };
  23776. }
  23777. declare module BABYLON {
  23778. /** @hidden */
  23779. export var lightsFragmentFunctions: {
  23780. name: string;
  23781. shader: string;
  23782. };
  23783. }
  23784. declare module BABYLON {
  23785. /** @hidden */
  23786. export var shadowsFragmentFunctions: {
  23787. name: string;
  23788. shader: string;
  23789. };
  23790. }
  23791. declare module BABYLON {
  23792. /** @hidden */
  23793. export var fresnelFunction: {
  23794. name: string;
  23795. shader: string;
  23796. };
  23797. }
  23798. declare module BABYLON {
  23799. /** @hidden */
  23800. export var bumpFragmentMainFunctions: {
  23801. name: string;
  23802. shader: string;
  23803. };
  23804. }
  23805. declare module BABYLON {
  23806. /** @hidden */
  23807. export var bumpFragmentFunctions: {
  23808. name: string;
  23809. shader: string;
  23810. };
  23811. }
  23812. declare module BABYLON {
  23813. /** @hidden */
  23814. export var logDepthDeclaration: {
  23815. name: string;
  23816. shader: string;
  23817. };
  23818. }
  23819. declare module BABYLON {
  23820. /** @hidden */
  23821. export var bumpFragment: {
  23822. name: string;
  23823. shader: string;
  23824. };
  23825. }
  23826. declare module BABYLON {
  23827. /** @hidden */
  23828. export var depthPrePass: {
  23829. name: string;
  23830. shader: string;
  23831. };
  23832. }
  23833. declare module BABYLON {
  23834. /** @hidden */
  23835. export var lightFragment: {
  23836. name: string;
  23837. shader: string;
  23838. };
  23839. }
  23840. declare module BABYLON {
  23841. /** @hidden */
  23842. export var logDepthFragment: {
  23843. name: string;
  23844. shader: string;
  23845. };
  23846. }
  23847. declare module BABYLON {
  23848. /** @hidden */
  23849. export var defaultPixelShader: {
  23850. name: string;
  23851. shader: string;
  23852. };
  23853. }
  23854. declare module BABYLON {
  23855. /** @hidden */
  23856. export var defaultVertexDeclaration: {
  23857. name: string;
  23858. shader: string;
  23859. };
  23860. }
  23861. declare module BABYLON {
  23862. /** @hidden */
  23863. export var prePassVertexDeclaration: {
  23864. name: string;
  23865. shader: string;
  23866. };
  23867. }
  23868. declare module BABYLON {
  23869. /** @hidden */
  23870. export var bumpVertexDeclaration: {
  23871. name: string;
  23872. shader: string;
  23873. };
  23874. }
  23875. declare module BABYLON {
  23876. /** @hidden */
  23877. export var prePassVertex: {
  23878. name: string;
  23879. shader: string;
  23880. };
  23881. }
  23882. declare module BABYLON {
  23883. /** @hidden */
  23884. export var bumpVertex: {
  23885. name: string;
  23886. shader: string;
  23887. };
  23888. }
  23889. declare module BABYLON {
  23890. /** @hidden */
  23891. export var fogVertex: {
  23892. name: string;
  23893. shader: string;
  23894. };
  23895. }
  23896. declare module BABYLON {
  23897. /** @hidden */
  23898. export var shadowsVertex: {
  23899. name: string;
  23900. shader: string;
  23901. };
  23902. }
  23903. declare module BABYLON {
  23904. /** @hidden */
  23905. export var pointCloudVertex: {
  23906. name: string;
  23907. shader: string;
  23908. };
  23909. }
  23910. declare module BABYLON {
  23911. /** @hidden */
  23912. export var logDepthVertex: {
  23913. name: string;
  23914. shader: string;
  23915. };
  23916. }
  23917. declare module BABYLON {
  23918. /** @hidden */
  23919. export var defaultVertexShader: {
  23920. name: string;
  23921. shader: string;
  23922. };
  23923. }
  23924. declare module BABYLON {
  23925. /**
  23926. * @hidden
  23927. */
  23928. export interface IMaterialDetailMapDefines {
  23929. DETAIL: boolean;
  23930. DETAILDIRECTUV: number;
  23931. DETAIL_NORMALBLENDMETHOD: number;
  23932. /** @hidden */
  23933. _areTexturesDirty: boolean;
  23934. }
  23935. /**
  23936. * Define the code related to the detail map parameters of a material
  23937. *
  23938. * Inspired from:
  23939. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  23940. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  23941. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  23942. */
  23943. export class DetailMapConfiguration {
  23944. private _texture;
  23945. /**
  23946. * The detail texture of the material.
  23947. */
  23948. texture: Nullable<BaseTexture>;
  23949. /**
  23950. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  23951. * Bigger values mean stronger blending
  23952. */
  23953. diffuseBlendLevel: number;
  23954. /**
  23955. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  23956. * Bigger values mean stronger blending. Only used with PBR materials
  23957. */
  23958. roughnessBlendLevel: number;
  23959. /**
  23960. * Defines how strong the bump effect from the detail map is
  23961. * Bigger values mean stronger effect
  23962. */
  23963. bumpLevel: number;
  23964. private _normalBlendMethod;
  23965. /**
  23966. * The method used to blend the bump and detail normals together
  23967. */
  23968. normalBlendMethod: number;
  23969. private _isEnabled;
  23970. /**
  23971. * Enable or disable the detail map on this material
  23972. */
  23973. isEnabled: boolean;
  23974. /** @hidden */
  23975. private _internalMarkAllSubMeshesAsTexturesDirty;
  23976. /** @hidden */
  23977. _markAllSubMeshesAsTexturesDirty(): void;
  23978. /**
  23979. * Instantiate a new detail map
  23980. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  23981. */
  23982. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  23983. /**
  23984. * Gets whether the submesh is ready to be used or not.
  23985. * @param defines the list of "defines" to update.
  23986. * @param scene defines the scene the material belongs to.
  23987. * @returns - boolean indicating that the submesh is ready or not.
  23988. */
  23989. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  23990. /**
  23991. * Update the defines for detail map usage
  23992. * @param defines the list of "defines" to update.
  23993. * @param scene defines the scene the material belongs to.
  23994. */
  23995. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  23996. /**
  23997. * Binds the material data.
  23998. * @param uniformBuffer defines the Uniform buffer to fill in.
  23999. * @param scene defines the scene the material belongs to.
  24000. * @param isFrozen defines whether the material is frozen or not.
  24001. */
  24002. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24003. /**
  24004. * Checks to see if a texture is used in the material.
  24005. * @param texture - Base texture to use.
  24006. * @returns - Boolean specifying if a texture is used in the material.
  24007. */
  24008. hasTexture(texture: BaseTexture): boolean;
  24009. /**
  24010. * Returns an array of the actively used textures.
  24011. * @param activeTextures Array of BaseTextures
  24012. */
  24013. getActiveTextures(activeTextures: BaseTexture[]): void;
  24014. /**
  24015. * Returns the animatable textures.
  24016. * @param animatables Array of animatable textures.
  24017. */
  24018. getAnimatables(animatables: IAnimatable[]): void;
  24019. /**
  24020. * Disposes the resources of the material.
  24021. * @param forceDisposeTextures - Forces the disposal of all textures.
  24022. */
  24023. dispose(forceDisposeTextures?: boolean): void;
  24024. /**
  24025. * Get the current class name useful for serialization or dynamic coding.
  24026. * @returns "DetailMap"
  24027. */
  24028. getClassName(): string;
  24029. /**
  24030. * Add the required uniforms to the current list.
  24031. * @param uniforms defines the current uniform list.
  24032. */
  24033. static AddUniforms(uniforms: string[]): void;
  24034. /**
  24035. * Add the required samplers to the current list.
  24036. * @param samplers defines the current sampler list.
  24037. */
  24038. static AddSamplers(samplers: string[]): void;
  24039. /**
  24040. * Add the required uniforms to the current buffer.
  24041. * @param uniformBuffer defines the current uniform buffer.
  24042. */
  24043. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24044. /**
  24045. * Makes a duplicate of the current instance into another one.
  24046. * @param detailMap define the instance where to copy the info
  24047. */
  24048. copyTo(detailMap: DetailMapConfiguration): void;
  24049. /**
  24050. * Serializes this detail map instance
  24051. * @returns - An object with the serialized instance.
  24052. */
  24053. serialize(): any;
  24054. /**
  24055. * Parses a detail map setting from a serialized object.
  24056. * @param source - Serialized object.
  24057. * @param scene Defines the scene we are parsing for
  24058. * @param rootUrl Defines the rootUrl to load from
  24059. */
  24060. parse(source: any, scene: Scene, rootUrl: string): void;
  24061. }
  24062. }
  24063. declare module BABYLON {
  24064. /** @hidden */
  24065. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24066. MAINUV1: boolean;
  24067. MAINUV2: boolean;
  24068. DIFFUSE: boolean;
  24069. DIFFUSEDIRECTUV: number;
  24070. DETAIL: boolean;
  24071. DETAILDIRECTUV: number;
  24072. DETAIL_NORMALBLENDMETHOD: number;
  24073. AMBIENT: boolean;
  24074. AMBIENTDIRECTUV: number;
  24075. OPACITY: boolean;
  24076. OPACITYDIRECTUV: number;
  24077. OPACITYRGB: boolean;
  24078. REFLECTION: boolean;
  24079. EMISSIVE: boolean;
  24080. EMISSIVEDIRECTUV: number;
  24081. SPECULAR: boolean;
  24082. SPECULARDIRECTUV: number;
  24083. BUMP: boolean;
  24084. BUMPDIRECTUV: number;
  24085. PARALLAX: boolean;
  24086. PARALLAXOCCLUSION: boolean;
  24087. SPECULAROVERALPHA: boolean;
  24088. CLIPPLANE: boolean;
  24089. CLIPPLANE2: boolean;
  24090. CLIPPLANE3: boolean;
  24091. CLIPPLANE4: boolean;
  24092. CLIPPLANE5: boolean;
  24093. CLIPPLANE6: boolean;
  24094. ALPHATEST: boolean;
  24095. DEPTHPREPASS: boolean;
  24096. ALPHAFROMDIFFUSE: boolean;
  24097. POINTSIZE: boolean;
  24098. FOG: boolean;
  24099. SPECULARTERM: boolean;
  24100. DIFFUSEFRESNEL: boolean;
  24101. OPACITYFRESNEL: boolean;
  24102. REFLECTIONFRESNEL: boolean;
  24103. REFRACTIONFRESNEL: boolean;
  24104. EMISSIVEFRESNEL: boolean;
  24105. FRESNEL: boolean;
  24106. NORMAL: boolean;
  24107. UV1: boolean;
  24108. UV2: boolean;
  24109. VERTEXCOLOR: boolean;
  24110. VERTEXALPHA: boolean;
  24111. NUM_BONE_INFLUENCERS: number;
  24112. BonesPerMesh: number;
  24113. BONETEXTURE: boolean;
  24114. BONES_VELOCITY_ENABLED: boolean;
  24115. INSTANCES: boolean;
  24116. THIN_INSTANCES: boolean;
  24117. GLOSSINESS: boolean;
  24118. ROUGHNESS: boolean;
  24119. EMISSIVEASILLUMINATION: boolean;
  24120. LINKEMISSIVEWITHDIFFUSE: boolean;
  24121. REFLECTIONFRESNELFROMSPECULAR: boolean;
  24122. LIGHTMAP: boolean;
  24123. LIGHTMAPDIRECTUV: number;
  24124. OBJECTSPACE_NORMALMAP: boolean;
  24125. USELIGHTMAPASSHADOWMAP: boolean;
  24126. REFLECTIONMAP_3D: boolean;
  24127. REFLECTIONMAP_SPHERICAL: boolean;
  24128. REFLECTIONMAP_PLANAR: boolean;
  24129. REFLECTIONMAP_CUBIC: boolean;
  24130. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  24131. REFLECTIONMAP_PROJECTION: boolean;
  24132. REFLECTIONMAP_SKYBOX: boolean;
  24133. REFLECTIONMAP_EXPLICIT: boolean;
  24134. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  24135. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  24136. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  24137. INVERTCUBICMAP: boolean;
  24138. LOGARITHMICDEPTH: boolean;
  24139. REFRACTION: boolean;
  24140. REFRACTIONMAP_3D: boolean;
  24141. REFLECTIONOVERALPHA: boolean;
  24142. TWOSIDEDLIGHTING: boolean;
  24143. SHADOWFLOAT: boolean;
  24144. MORPHTARGETS: boolean;
  24145. MORPHTARGETS_NORMAL: boolean;
  24146. MORPHTARGETS_TANGENT: boolean;
  24147. MORPHTARGETS_UV: boolean;
  24148. NUM_MORPH_INFLUENCERS: number;
  24149. NONUNIFORMSCALING: boolean;
  24150. PREMULTIPLYALPHA: boolean;
  24151. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  24152. ALPHABLEND: boolean;
  24153. PREPASS: boolean;
  24154. PREPASS_IRRADIANCE: boolean;
  24155. PREPASS_IRRADIANCE_INDEX: number;
  24156. PREPASS_ALBEDO: boolean;
  24157. PREPASS_ALBEDO_INDEX: number;
  24158. PREPASS_DEPTHNORMAL: boolean;
  24159. PREPASS_DEPTHNORMAL_INDEX: number;
  24160. PREPASS_POSITION: boolean;
  24161. PREPASS_POSITION_INDEX: number;
  24162. PREPASS_VELOCITY: boolean;
  24163. PREPASS_VELOCITY_INDEX: number;
  24164. PREPASS_REFLECTIVITY: boolean;
  24165. PREPASS_REFLECTIVITY_INDEX: number;
  24166. SCENE_MRT_COUNT: number;
  24167. RGBDLIGHTMAP: boolean;
  24168. RGBDREFLECTION: boolean;
  24169. RGBDREFRACTION: boolean;
  24170. IMAGEPROCESSING: boolean;
  24171. VIGNETTE: boolean;
  24172. VIGNETTEBLENDMODEMULTIPLY: boolean;
  24173. VIGNETTEBLENDMODEOPAQUE: boolean;
  24174. TONEMAPPING: boolean;
  24175. TONEMAPPING_ACES: boolean;
  24176. CONTRAST: boolean;
  24177. COLORCURVES: boolean;
  24178. COLORGRADING: boolean;
  24179. COLORGRADING3D: boolean;
  24180. SAMPLER3DGREENDEPTH: boolean;
  24181. SAMPLER3DBGRMAP: boolean;
  24182. IMAGEPROCESSINGPOSTPROCESS: boolean;
  24183. MULTIVIEW: boolean;
  24184. /**
  24185. * If the reflection texture on this material is in linear color space
  24186. * @hidden
  24187. */
  24188. IS_REFLECTION_LINEAR: boolean;
  24189. /**
  24190. * If the refraction texture on this material is in linear color space
  24191. * @hidden
  24192. */
  24193. IS_REFRACTION_LINEAR: boolean;
  24194. EXPOSURE: boolean;
  24195. constructor();
  24196. setReflectionMode(modeToEnable: string): void;
  24197. }
  24198. /**
  24199. * This is the default material used in Babylon. It is the best trade off between quality
  24200. * and performances.
  24201. * @see https://doc.babylonjs.com/babylon101/materials
  24202. */
  24203. export class StandardMaterial extends PushMaterial {
  24204. private _diffuseTexture;
  24205. /**
  24206. * The basic texture of the material as viewed under a light.
  24207. */
  24208. diffuseTexture: Nullable<BaseTexture>;
  24209. private _ambientTexture;
  24210. /**
  24211. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  24212. */
  24213. ambientTexture: Nullable<BaseTexture>;
  24214. private _opacityTexture;
  24215. /**
  24216. * Define the transparency of the material from a texture.
  24217. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  24218. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  24219. */
  24220. opacityTexture: Nullable<BaseTexture>;
  24221. private _reflectionTexture;
  24222. /**
  24223. * Define the texture used to display the reflection.
  24224. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24225. */
  24226. reflectionTexture: Nullable<BaseTexture>;
  24227. private _emissiveTexture;
  24228. /**
  24229. * Define texture of the material as if self lit.
  24230. * This will be mixed in the final result even in the absence of light.
  24231. */
  24232. emissiveTexture: Nullable<BaseTexture>;
  24233. private _specularTexture;
  24234. /**
  24235. * Define how the color and intensity of the highlight given by the light in the material.
  24236. */
  24237. specularTexture: Nullable<BaseTexture>;
  24238. private _bumpTexture;
  24239. /**
  24240. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  24241. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  24242. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  24243. */
  24244. bumpTexture: Nullable<BaseTexture>;
  24245. private _lightmapTexture;
  24246. /**
  24247. * Complex lighting can be computationally expensive to compute at runtime.
  24248. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  24249. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  24250. */
  24251. lightmapTexture: Nullable<BaseTexture>;
  24252. private _refractionTexture;
  24253. /**
  24254. * Define the texture used to display the refraction.
  24255. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24256. */
  24257. refractionTexture: Nullable<BaseTexture>;
  24258. /**
  24259. * The color of the material lit by the environmental background lighting.
  24260. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24261. */
  24262. ambientColor: Color3;
  24263. /**
  24264. * The basic color of the material as viewed under a light.
  24265. */
  24266. diffuseColor: Color3;
  24267. /**
  24268. * Define how the color and intensity of the highlight given by the light in the material.
  24269. */
  24270. specularColor: Color3;
  24271. /**
  24272. * Define the color of the material as if self lit.
  24273. * This will be mixed in the final result even in the absence of light.
  24274. */
  24275. emissiveColor: Color3;
  24276. /**
  24277. * Defines how sharp are the highlights in the material.
  24278. * The bigger the value the sharper giving a more glossy feeling to the result.
  24279. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24280. */
  24281. specularPower: number;
  24282. private _useAlphaFromDiffuseTexture;
  24283. /**
  24284. * Does the transparency come from the diffuse texture alpha channel.
  24285. */
  24286. useAlphaFromDiffuseTexture: boolean;
  24287. private _useEmissiveAsIllumination;
  24288. /**
  24289. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24290. */
  24291. useEmissiveAsIllumination: boolean;
  24292. private _linkEmissiveWithDiffuse;
  24293. /**
  24294. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24295. * the emissive level when the final color is close to one.
  24296. */
  24297. linkEmissiveWithDiffuse: boolean;
  24298. private _useSpecularOverAlpha;
  24299. /**
  24300. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24301. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24302. */
  24303. useSpecularOverAlpha: boolean;
  24304. private _useReflectionOverAlpha;
  24305. /**
  24306. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24307. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24308. */
  24309. useReflectionOverAlpha: boolean;
  24310. private _disableLighting;
  24311. /**
  24312. * Does lights from the scene impacts this material.
  24313. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24314. */
  24315. disableLighting: boolean;
  24316. private _useObjectSpaceNormalMap;
  24317. /**
  24318. * Allows using an object space normal map (instead of tangent space).
  24319. */
  24320. useObjectSpaceNormalMap: boolean;
  24321. private _useParallax;
  24322. /**
  24323. * Is parallax enabled or not.
  24324. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24325. */
  24326. useParallax: boolean;
  24327. private _useParallaxOcclusion;
  24328. /**
  24329. * Is parallax occlusion enabled or not.
  24330. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24331. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24332. */
  24333. useParallaxOcclusion: boolean;
  24334. /**
  24335. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  24336. */
  24337. parallaxScaleBias: number;
  24338. private _roughness;
  24339. /**
  24340. * Helps to define how blurry the reflections should appears in the material.
  24341. */
  24342. roughness: number;
  24343. /**
  24344. * In case of refraction, define the value of the index of refraction.
  24345. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24346. */
  24347. indexOfRefraction: number;
  24348. /**
  24349. * Invert the refraction texture alongside the y axis.
  24350. * It can be useful with procedural textures or probe for instance.
  24351. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24352. */
  24353. invertRefractionY: boolean;
  24354. /**
  24355. * Defines the alpha limits in alpha test mode.
  24356. */
  24357. alphaCutOff: number;
  24358. private _useLightmapAsShadowmap;
  24359. /**
  24360. * In case of light mapping, define whether the map contains light or shadow informations.
  24361. */
  24362. useLightmapAsShadowmap: boolean;
  24363. private _diffuseFresnelParameters;
  24364. /**
  24365. * Define the diffuse fresnel parameters of the material.
  24366. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24367. */
  24368. diffuseFresnelParameters: FresnelParameters;
  24369. private _opacityFresnelParameters;
  24370. /**
  24371. * Define the opacity fresnel parameters of the material.
  24372. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24373. */
  24374. opacityFresnelParameters: FresnelParameters;
  24375. private _reflectionFresnelParameters;
  24376. /**
  24377. * Define the reflection fresnel parameters of the material.
  24378. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24379. */
  24380. reflectionFresnelParameters: FresnelParameters;
  24381. private _refractionFresnelParameters;
  24382. /**
  24383. * Define the refraction fresnel parameters of the material.
  24384. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24385. */
  24386. refractionFresnelParameters: FresnelParameters;
  24387. private _emissiveFresnelParameters;
  24388. /**
  24389. * Define the emissive fresnel parameters of the material.
  24390. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24391. */
  24392. emissiveFresnelParameters: FresnelParameters;
  24393. private _useReflectionFresnelFromSpecular;
  24394. /**
  24395. * If true automatically deducts the fresnels values from the material specularity.
  24396. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24397. */
  24398. useReflectionFresnelFromSpecular: boolean;
  24399. private _useGlossinessFromSpecularMapAlpha;
  24400. /**
  24401. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  24402. */
  24403. useGlossinessFromSpecularMapAlpha: boolean;
  24404. private _maxSimultaneousLights;
  24405. /**
  24406. * Defines the maximum number of lights that can be used in the material
  24407. */
  24408. maxSimultaneousLights: number;
  24409. private _invertNormalMapX;
  24410. /**
  24411. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  24412. */
  24413. invertNormalMapX: boolean;
  24414. private _invertNormalMapY;
  24415. /**
  24416. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  24417. */
  24418. invertNormalMapY: boolean;
  24419. private _twoSidedLighting;
  24420. /**
  24421. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  24422. */
  24423. twoSidedLighting: boolean;
  24424. /**
  24425. * Default configuration related to image processing available in the standard Material.
  24426. */
  24427. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24428. /**
  24429. * Gets the image processing configuration used either in this material.
  24430. */
  24431. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24432. /**
  24433. * Sets the Default image processing configuration used either in the this material.
  24434. *
  24435. * If sets to null, the scene one is in use.
  24436. */
  24437. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24438. /**
  24439. * Keep track of the image processing observer to allow dispose and replace.
  24440. */
  24441. private _imageProcessingObserver;
  24442. /**
  24443. * Attaches a new image processing configuration to the Standard Material.
  24444. * @param configuration
  24445. */
  24446. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24447. /**
  24448. * Defines additionnal PrePass parameters for the material.
  24449. */
  24450. readonly prePassConfiguration: PrePassConfiguration;
  24451. /**
  24452. * Gets wether the color curves effect is enabled.
  24453. */
  24454. get cameraColorCurvesEnabled(): boolean;
  24455. /**
  24456. * Sets wether the color curves effect is enabled.
  24457. */
  24458. set cameraColorCurvesEnabled(value: boolean);
  24459. /**
  24460. * Gets wether the color grading effect is enabled.
  24461. */
  24462. get cameraColorGradingEnabled(): boolean;
  24463. /**
  24464. * Gets wether the color grading effect is enabled.
  24465. */
  24466. set cameraColorGradingEnabled(value: boolean);
  24467. /**
  24468. * Gets wether tonemapping is enabled or not.
  24469. */
  24470. get cameraToneMappingEnabled(): boolean;
  24471. /**
  24472. * Sets wether tonemapping is enabled or not
  24473. */
  24474. set cameraToneMappingEnabled(value: boolean);
  24475. /**
  24476. * The camera exposure used on this material.
  24477. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24478. * This corresponds to a photographic exposure.
  24479. */
  24480. get cameraExposure(): number;
  24481. /**
  24482. * The camera exposure used on this material.
  24483. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24484. * This corresponds to a photographic exposure.
  24485. */
  24486. set cameraExposure(value: number);
  24487. /**
  24488. * Gets The camera contrast used on this material.
  24489. */
  24490. get cameraContrast(): number;
  24491. /**
  24492. * Sets The camera contrast used on this material.
  24493. */
  24494. set cameraContrast(value: number);
  24495. /**
  24496. * Gets the Color Grading 2D Lookup Texture.
  24497. */
  24498. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  24499. /**
  24500. * Sets the Color Grading 2D Lookup Texture.
  24501. */
  24502. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  24503. /**
  24504. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24505. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24506. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  24507. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24508. */
  24509. get cameraColorCurves(): Nullable<ColorCurves>;
  24510. /**
  24511. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24512. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24513. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  24514. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24515. */
  24516. set cameraColorCurves(value: Nullable<ColorCurves>);
  24517. /**
  24518. * Can this material render to several textures at once
  24519. */
  24520. get canRenderToMRT(): boolean;
  24521. /**
  24522. * Defines the detail map parameters for the material.
  24523. */
  24524. readonly detailMap: DetailMapConfiguration;
  24525. protected _renderTargets: SmartArray<RenderTargetTexture>;
  24526. protected _worldViewProjectionMatrix: Matrix;
  24527. protected _globalAmbientColor: Color3;
  24528. protected _useLogarithmicDepth: boolean;
  24529. protected _rebuildInParallel: boolean;
  24530. /**
  24531. * Instantiates a new standard material.
  24532. * This is the default material used in Babylon. It is the best trade off between quality
  24533. * and performances.
  24534. * @see https://doc.babylonjs.com/babylon101/materials
  24535. * @param name Define the name of the material in the scene
  24536. * @param scene Define the scene the material belong to
  24537. */
  24538. constructor(name: string, scene: Scene);
  24539. /**
  24540. * Gets a boolean indicating that current material needs to register RTT
  24541. */
  24542. get hasRenderTargetTextures(): boolean;
  24543. /**
  24544. * Gets the current class name of the material e.g. "StandardMaterial"
  24545. * Mainly use in serialization.
  24546. * @returns the class name
  24547. */
  24548. getClassName(): string;
  24549. /**
  24550. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  24551. * You can try switching to logarithmic depth.
  24552. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  24553. */
  24554. get useLogarithmicDepth(): boolean;
  24555. set useLogarithmicDepth(value: boolean);
  24556. /**
  24557. * Specifies if the material will require alpha blending
  24558. * @returns a boolean specifying if alpha blending is needed
  24559. */
  24560. needAlphaBlending(): boolean;
  24561. /**
  24562. * Specifies if this material should be rendered in alpha test mode
  24563. * @returns a boolean specifying if an alpha test is needed.
  24564. */
  24565. needAlphaTesting(): boolean;
  24566. /**
  24567. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  24568. */
  24569. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  24570. /**
  24571. * Specifies whether or not there is a usable alpha channel for transparency.
  24572. */
  24573. protected _hasAlphaChannel(): boolean;
  24574. /**
  24575. * Get the texture used for alpha test purpose.
  24576. * @returns the diffuse texture in case of the standard material.
  24577. */
  24578. getAlphaTestTexture(): Nullable<BaseTexture>;
  24579. /**
  24580. * Get if the submesh is ready to be used and all its information available.
  24581. * Child classes can use it to update shaders
  24582. * @param mesh defines the mesh to check
  24583. * @param subMesh defines which submesh to check
  24584. * @param useInstances specifies that instances should be used
  24585. * @returns a boolean indicating that the submesh is ready or not
  24586. */
  24587. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24588. /**
  24589. * Builds the material UBO layouts.
  24590. * Used internally during the effect preparation.
  24591. */
  24592. buildUniformLayout(): void;
  24593. /**
  24594. * Unbinds the material from the mesh
  24595. */
  24596. unbind(): void;
  24597. /**
  24598. * Binds the submesh to this material by preparing the effect and shader to draw
  24599. * @param world defines the world transformation matrix
  24600. * @param mesh defines the mesh containing the submesh
  24601. * @param subMesh defines the submesh to bind the material to
  24602. */
  24603. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24604. /**
  24605. * Get the list of animatables in the material.
  24606. * @returns the list of animatables object used in the material
  24607. */
  24608. getAnimatables(): IAnimatable[];
  24609. /**
  24610. * Gets the active textures from the material
  24611. * @returns an array of textures
  24612. */
  24613. getActiveTextures(): BaseTexture[];
  24614. /**
  24615. * Specifies if the material uses a texture
  24616. * @param texture defines the texture to check against the material
  24617. * @returns a boolean specifying if the material uses the texture
  24618. */
  24619. hasTexture(texture: BaseTexture): boolean;
  24620. /**
  24621. * Disposes the material
  24622. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24623. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24624. */
  24625. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  24626. /**
  24627. * Makes a duplicate of the material, and gives it a new name
  24628. * @param name defines the new name for the duplicated material
  24629. * @returns the cloned material
  24630. */
  24631. clone(name: string): StandardMaterial;
  24632. /**
  24633. * Serializes this material in a JSON representation
  24634. * @returns the serialized material object
  24635. */
  24636. serialize(): any;
  24637. /**
  24638. * Creates a standard material from parsed material data
  24639. * @param source defines the JSON representation of the material
  24640. * @param scene defines the hosting scene
  24641. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24642. * @returns a new standard material
  24643. */
  24644. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  24645. /**
  24646. * Are diffuse textures enabled in the application.
  24647. */
  24648. static get DiffuseTextureEnabled(): boolean;
  24649. static set DiffuseTextureEnabled(value: boolean);
  24650. /**
  24651. * Are detail textures enabled in the application.
  24652. */
  24653. static get DetailTextureEnabled(): boolean;
  24654. static set DetailTextureEnabled(value: boolean);
  24655. /**
  24656. * Are ambient textures enabled in the application.
  24657. */
  24658. static get AmbientTextureEnabled(): boolean;
  24659. static set AmbientTextureEnabled(value: boolean);
  24660. /**
  24661. * Are opacity textures enabled in the application.
  24662. */
  24663. static get OpacityTextureEnabled(): boolean;
  24664. static set OpacityTextureEnabled(value: boolean);
  24665. /**
  24666. * Are reflection textures enabled in the application.
  24667. */
  24668. static get ReflectionTextureEnabled(): boolean;
  24669. static set ReflectionTextureEnabled(value: boolean);
  24670. /**
  24671. * Are emissive textures enabled in the application.
  24672. */
  24673. static get EmissiveTextureEnabled(): boolean;
  24674. static set EmissiveTextureEnabled(value: boolean);
  24675. /**
  24676. * Are specular textures enabled in the application.
  24677. */
  24678. static get SpecularTextureEnabled(): boolean;
  24679. static set SpecularTextureEnabled(value: boolean);
  24680. /**
  24681. * Are bump textures enabled in the application.
  24682. */
  24683. static get BumpTextureEnabled(): boolean;
  24684. static set BumpTextureEnabled(value: boolean);
  24685. /**
  24686. * Are lightmap textures enabled in the application.
  24687. */
  24688. static get LightmapTextureEnabled(): boolean;
  24689. static set LightmapTextureEnabled(value: boolean);
  24690. /**
  24691. * Are refraction textures enabled in the application.
  24692. */
  24693. static get RefractionTextureEnabled(): boolean;
  24694. static set RefractionTextureEnabled(value: boolean);
  24695. /**
  24696. * Are color grading textures enabled in the application.
  24697. */
  24698. static get ColorGradingTextureEnabled(): boolean;
  24699. static set ColorGradingTextureEnabled(value: boolean);
  24700. /**
  24701. * Are fresnels enabled in the application.
  24702. */
  24703. static get FresnelEnabled(): boolean;
  24704. static set FresnelEnabled(value: boolean);
  24705. }
  24706. }
  24707. declare module BABYLON {
  24708. /** @hidden */
  24709. export var rgbdDecodePixelShader: {
  24710. name: string;
  24711. shader: string;
  24712. };
  24713. }
  24714. declare module BABYLON {
  24715. /**
  24716. * Class used to host RGBD texture specific utilities
  24717. */
  24718. export class RGBDTextureTools {
  24719. /**
  24720. * Expand the RGBD Texture from RGBD to Half Float if possible.
  24721. * @param texture the texture to expand.
  24722. */
  24723. static ExpandRGBDTexture(texture: Texture): void;
  24724. }
  24725. }
  24726. declare module BABYLON {
  24727. /**
  24728. * Class used to host texture specific utilities
  24729. */
  24730. export class BRDFTextureTools {
  24731. /**
  24732. * Prevents texture cache collision
  24733. */
  24734. private static _instanceNumber;
  24735. /**
  24736. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  24737. * @param scene defines the hosting scene
  24738. * @returns the environment BRDF texture
  24739. */
  24740. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  24741. private static _environmentBRDFBase64Texture;
  24742. }
  24743. }
  24744. declare module BABYLON {
  24745. /**
  24746. * @hidden
  24747. */
  24748. export interface IMaterialClearCoatDefines {
  24749. CLEARCOAT: boolean;
  24750. CLEARCOAT_DEFAULTIOR: boolean;
  24751. CLEARCOAT_TEXTURE: boolean;
  24752. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  24753. CLEARCOAT_TEXTUREDIRECTUV: number;
  24754. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  24755. CLEARCOAT_BUMP: boolean;
  24756. CLEARCOAT_BUMPDIRECTUV: number;
  24757. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  24758. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  24759. CLEARCOAT_REMAP_F0: boolean;
  24760. CLEARCOAT_TINT: boolean;
  24761. CLEARCOAT_TINT_TEXTURE: boolean;
  24762. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  24763. /** @hidden */
  24764. _areTexturesDirty: boolean;
  24765. }
  24766. /**
  24767. * Define the code related to the clear coat parameters of the pbr material.
  24768. */
  24769. export class PBRClearCoatConfiguration {
  24770. /**
  24771. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24772. * The default fits with a polyurethane material.
  24773. */
  24774. private static readonly _DefaultIndexOfRefraction;
  24775. private _isEnabled;
  24776. /**
  24777. * Defines if the clear coat is enabled in the material.
  24778. */
  24779. isEnabled: boolean;
  24780. /**
  24781. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  24782. */
  24783. intensity: number;
  24784. /**
  24785. * Defines the clear coat layer roughness.
  24786. */
  24787. roughness: number;
  24788. private _indexOfRefraction;
  24789. /**
  24790. * Defines the index of refraction of the clear coat.
  24791. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24792. * The default fits with a polyurethane material.
  24793. * Changing the default value is more performance intensive.
  24794. */
  24795. indexOfRefraction: number;
  24796. private _texture;
  24797. /**
  24798. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  24799. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  24800. * if textureRoughness is not empty, else no texture roughness is used
  24801. */
  24802. texture: Nullable<BaseTexture>;
  24803. private _useRoughnessFromMainTexture;
  24804. /**
  24805. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  24806. * If false, the green channel from textureRoughness is used for roughness
  24807. */
  24808. useRoughnessFromMainTexture: boolean;
  24809. private _textureRoughness;
  24810. /**
  24811. * Stores the clear coat roughness in a texture (green channel)
  24812. * Not used if useRoughnessFromMainTexture is true
  24813. */
  24814. textureRoughness: Nullable<BaseTexture>;
  24815. private _remapF0OnInterfaceChange;
  24816. /**
  24817. * Defines if the F0 value should be remapped to account for the interface change in the material.
  24818. */
  24819. remapF0OnInterfaceChange: boolean;
  24820. private _bumpTexture;
  24821. /**
  24822. * Define the clear coat specific bump texture.
  24823. */
  24824. bumpTexture: Nullable<BaseTexture>;
  24825. private _isTintEnabled;
  24826. /**
  24827. * Defines if the clear coat tint is enabled in the material.
  24828. */
  24829. isTintEnabled: boolean;
  24830. /**
  24831. * Defines the clear coat tint of the material.
  24832. * This is only use if tint is enabled
  24833. */
  24834. tintColor: Color3;
  24835. /**
  24836. * Defines the distance at which the tint color should be found in the
  24837. * clear coat media.
  24838. * This is only use if tint is enabled
  24839. */
  24840. tintColorAtDistance: number;
  24841. /**
  24842. * Defines the clear coat layer thickness.
  24843. * This is only use if tint is enabled
  24844. */
  24845. tintThickness: number;
  24846. private _tintTexture;
  24847. /**
  24848. * Stores the clear tint values in a texture.
  24849. * rgb is tint
  24850. * a is a thickness factor
  24851. */
  24852. tintTexture: Nullable<BaseTexture>;
  24853. /** @hidden */
  24854. private _internalMarkAllSubMeshesAsTexturesDirty;
  24855. /** @hidden */
  24856. _markAllSubMeshesAsTexturesDirty(): void;
  24857. /**
  24858. * Instantiate a new istance of clear coat configuration.
  24859. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24860. */
  24861. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24862. /**
  24863. * Gets wehter the submesh is ready to be used or not.
  24864. * @param defines the list of "defines" to update.
  24865. * @param scene defines the scene the material belongs to.
  24866. * @param engine defines the engine the material belongs to.
  24867. * @param disableBumpMap defines wether the material disables bump or not.
  24868. * @returns - boolean indicating that the submesh is ready or not.
  24869. */
  24870. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  24871. /**
  24872. * Checks to see if a texture is used in the material.
  24873. * @param defines the list of "defines" to update.
  24874. * @param scene defines the scene to the material belongs to.
  24875. */
  24876. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  24877. /**
  24878. * Binds the material data.
  24879. * @param uniformBuffer defines the Uniform buffer to fill in.
  24880. * @param scene defines the scene the material belongs to.
  24881. * @param engine defines the engine the material belongs to.
  24882. * @param disableBumpMap defines wether the material disables bump or not.
  24883. * @param isFrozen defines wether the material is frozen or not.
  24884. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  24885. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  24886. * @param subMesh the submesh to bind data for
  24887. */
  24888. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  24889. /**
  24890. * Checks to see if a texture is used in the material.
  24891. * @param texture - Base texture to use.
  24892. * @returns - Boolean specifying if a texture is used in the material.
  24893. */
  24894. hasTexture(texture: BaseTexture): boolean;
  24895. /**
  24896. * Returns an array of the actively used textures.
  24897. * @param activeTextures Array of BaseTextures
  24898. */
  24899. getActiveTextures(activeTextures: BaseTexture[]): void;
  24900. /**
  24901. * Returns the animatable textures.
  24902. * @param animatables Array of animatable textures.
  24903. */
  24904. getAnimatables(animatables: IAnimatable[]): void;
  24905. /**
  24906. * Disposes the resources of the material.
  24907. * @param forceDisposeTextures - Forces the disposal of all textures.
  24908. */
  24909. dispose(forceDisposeTextures?: boolean): void;
  24910. /**
  24911. * Get the current class name of the texture useful for serialization or dynamic coding.
  24912. * @returns "PBRClearCoatConfiguration"
  24913. */
  24914. getClassName(): string;
  24915. /**
  24916. * Add fallbacks to the effect fallbacks list.
  24917. * @param defines defines the Base texture to use.
  24918. * @param fallbacks defines the current fallback list.
  24919. * @param currentRank defines the current fallback rank.
  24920. * @returns the new fallback rank.
  24921. */
  24922. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24923. /**
  24924. * Add the required uniforms to the current list.
  24925. * @param uniforms defines the current uniform list.
  24926. */
  24927. static AddUniforms(uniforms: string[]): void;
  24928. /**
  24929. * Add the required samplers to the current list.
  24930. * @param samplers defines the current sampler list.
  24931. */
  24932. static AddSamplers(samplers: string[]): void;
  24933. /**
  24934. * Add the required uniforms to the current buffer.
  24935. * @param uniformBuffer defines the current uniform buffer.
  24936. */
  24937. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24938. /**
  24939. * Makes a duplicate of the current configuration into another one.
  24940. * @param clearCoatConfiguration define the config where to copy the info
  24941. */
  24942. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  24943. /**
  24944. * Serializes this clear coat configuration.
  24945. * @returns - An object with the serialized config.
  24946. */
  24947. serialize(): any;
  24948. /**
  24949. * Parses a anisotropy Configuration from a serialized object.
  24950. * @param source - Serialized object.
  24951. * @param scene Defines the scene we are parsing for
  24952. * @param rootUrl Defines the rootUrl to load from
  24953. */
  24954. parse(source: any, scene: Scene, rootUrl: string): void;
  24955. }
  24956. }
  24957. declare module BABYLON {
  24958. /**
  24959. * @hidden
  24960. */
  24961. export interface IMaterialAnisotropicDefines {
  24962. ANISOTROPIC: boolean;
  24963. ANISOTROPIC_TEXTURE: boolean;
  24964. ANISOTROPIC_TEXTUREDIRECTUV: number;
  24965. MAINUV1: boolean;
  24966. _areTexturesDirty: boolean;
  24967. _needUVs: boolean;
  24968. }
  24969. /**
  24970. * Define the code related to the anisotropic parameters of the pbr material.
  24971. */
  24972. export class PBRAnisotropicConfiguration {
  24973. private _isEnabled;
  24974. /**
  24975. * Defines if the anisotropy is enabled in the material.
  24976. */
  24977. isEnabled: boolean;
  24978. /**
  24979. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  24980. */
  24981. intensity: number;
  24982. /**
  24983. * Defines if the effect is along the tangents, bitangents or in between.
  24984. * By default, the effect is "strectching" the highlights along the tangents.
  24985. */
  24986. direction: Vector2;
  24987. private _texture;
  24988. /**
  24989. * Stores the anisotropy values in a texture.
  24990. * rg is direction (like normal from -1 to 1)
  24991. * b is a intensity
  24992. */
  24993. texture: Nullable<BaseTexture>;
  24994. /** @hidden */
  24995. private _internalMarkAllSubMeshesAsTexturesDirty;
  24996. /** @hidden */
  24997. _markAllSubMeshesAsTexturesDirty(): void;
  24998. /**
  24999. * Instantiate a new istance of anisotropy configuration.
  25000. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25001. */
  25002. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25003. /**
  25004. * Specifies that the submesh is ready to be used.
  25005. * @param defines the list of "defines" to update.
  25006. * @param scene defines the scene the material belongs to.
  25007. * @returns - boolean indicating that the submesh is ready or not.
  25008. */
  25009. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25010. /**
  25011. * Checks to see if a texture is used in the material.
  25012. * @param defines the list of "defines" to update.
  25013. * @param mesh the mesh we are preparing the defines for.
  25014. * @param scene defines the scene the material belongs to.
  25015. */
  25016. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25017. /**
  25018. * Binds the material data.
  25019. * @param uniformBuffer defines the Uniform buffer to fill in.
  25020. * @param scene defines the scene the material belongs to.
  25021. * @param isFrozen defines wether the material is frozen or not.
  25022. */
  25023. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25024. /**
  25025. * Checks to see if a texture is used in the material.
  25026. * @param texture - Base texture to use.
  25027. * @returns - Boolean specifying if a texture is used in the material.
  25028. */
  25029. hasTexture(texture: BaseTexture): boolean;
  25030. /**
  25031. * Returns an array of the actively used textures.
  25032. * @param activeTextures Array of BaseTextures
  25033. */
  25034. getActiveTextures(activeTextures: BaseTexture[]): void;
  25035. /**
  25036. * Returns the animatable textures.
  25037. * @param animatables Array of animatable textures.
  25038. */
  25039. getAnimatables(animatables: IAnimatable[]): void;
  25040. /**
  25041. * Disposes the resources of the material.
  25042. * @param forceDisposeTextures - Forces the disposal of all textures.
  25043. */
  25044. dispose(forceDisposeTextures?: boolean): void;
  25045. /**
  25046. * Get the current class name of the texture useful for serialization or dynamic coding.
  25047. * @returns "PBRAnisotropicConfiguration"
  25048. */
  25049. getClassName(): string;
  25050. /**
  25051. * Add fallbacks to the effect fallbacks list.
  25052. * @param defines defines the Base texture to use.
  25053. * @param fallbacks defines the current fallback list.
  25054. * @param currentRank defines the current fallback rank.
  25055. * @returns the new fallback rank.
  25056. */
  25057. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25058. /**
  25059. * Add the required uniforms to the current list.
  25060. * @param uniforms defines the current uniform list.
  25061. */
  25062. static AddUniforms(uniforms: string[]): void;
  25063. /**
  25064. * Add the required uniforms to the current buffer.
  25065. * @param uniformBuffer defines the current uniform buffer.
  25066. */
  25067. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25068. /**
  25069. * Add the required samplers to the current list.
  25070. * @param samplers defines the current sampler list.
  25071. */
  25072. static AddSamplers(samplers: string[]): void;
  25073. /**
  25074. * Makes a duplicate of the current configuration into another one.
  25075. * @param anisotropicConfiguration define the config where to copy the info
  25076. */
  25077. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  25078. /**
  25079. * Serializes this anisotropy configuration.
  25080. * @returns - An object with the serialized config.
  25081. */
  25082. serialize(): any;
  25083. /**
  25084. * Parses a anisotropy Configuration from a serialized object.
  25085. * @param source - Serialized object.
  25086. * @param scene Defines the scene we are parsing for
  25087. * @param rootUrl Defines the rootUrl to load from
  25088. */
  25089. parse(source: any, scene: Scene, rootUrl: string): void;
  25090. }
  25091. }
  25092. declare module BABYLON {
  25093. /**
  25094. * @hidden
  25095. */
  25096. export interface IMaterialBRDFDefines {
  25097. BRDF_V_HEIGHT_CORRELATED: boolean;
  25098. MS_BRDF_ENERGY_CONSERVATION: boolean;
  25099. SPHERICAL_HARMONICS: boolean;
  25100. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  25101. /** @hidden */
  25102. _areMiscDirty: boolean;
  25103. }
  25104. /**
  25105. * Define the code related to the BRDF parameters of the pbr material.
  25106. */
  25107. export class PBRBRDFConfiguration {
  25108. /**
  25109. * Default value used for the energy conservation.
  25110. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25111. */
  25112. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  25113. /**
  25114. * Default value used for the Smith Visibility Height Correlated mode.
  25115. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25116. */
  25117. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  25118. /**
  25119. * Default value used for the IBL diffuse part.
  25120. * This can help switching back to the polynomials mode globally which is a tiny bit
  25121. * less GPU intensive at the drawback of a lower quality.
  25122. */
  25123. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  25124. /**
  25125. * Default value used for activating energy conservation for the specular workflow.
  25126. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25127. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25128. */
  25129. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  25130. private _useEnergyConservation;
  25131. /**
  25132. * Defines if the material uses energy conservation.
  25133. */
  25134. useEnergyConservation: boolean;
  25135. private _useSmithVisibilityHeightCorrelated;
  25136. /**
  25137. * LEGACY Mode set to false
  25138. * Defines if the material uses height smith correlated visibility term.
  25139. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  25140. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  25141. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  25142. * Not relying on height correlated will also disable energy conservation.
  25143. */
  25144. useSmithVisibilityHeightCorrelated: boolean;
  25145. private _useSphericalHarmonics;
  25146. /**
  25147. * LEGACY Mode set to false
  25148. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  25149. * diffuse part of the IBL.
  25150. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  25151. * to the ground truth.
  25152. */
  25153. useSphericalHarmonics: boolean;
  25154. private _useSpecularGlossinessInputEnergyConservation;
  25155. /**
  25156. * Defines if the material uses energy conservation, when the specular workflow is active.
  25157. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25158. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25159. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  25160. */
  25161. useSpecularGlossinessInputEnergyConservation: boolean;
  25162. /** @hidden */
  25163. private _internalMarkAllSubMeshesAsMiscDirty;
  25164. /** @hidden */
  25165. _markAllSubMeshesAsMiscDirty(): void;
  25166. /**
  25167. * Instantiate a new istance of clear coat configuration.
  25168. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  25169. */
  25170. constructor(markAllSubMeshesAsMiscDirty: () => void);
  25171. /**
  25172. * Checks to see if a texture is used in the material.
  25173. * @param defines the list of "defines" to update.
  25174. */
  25175. prepareDefines(defines: IMaterialBRDFDefines): void;
  25176. /**
  25177. * Get the current class name of the texture useful for serialization or dynamic coding.
  25178. * @returns "PBRClearCoatConfiguration"
  25179. */
  25180. getClassName(): string;
  25181. /**
  25182. * Makes a duplicate of the current configuration into another one.
  25183. * @param brdfConfiguration define the config where to copy the info
  25184. */
  25185. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  25186. /**
  25187. * Serializes this BRDF configuration.
  25188. * @returns - An object with the serialized config.
  25189. */
  25190. serialize(): any;
  25191. /**
  25192. * Parses a anisotropy Configuration from a serialized object.
  25193. * @param source - Serialized object.
  25194. * @param scene Defines the scene we are parsing for
  25195. * @param rootUrl Defines the rootUrl to load from
  25196. */
  25197. parse(source: any, scene: Scene, rootUrl: string): void;
  25198. }
  25199. }
  25200. declare module BABYLON {
  25201. /**
  25202. * @hidden
  25203. */
  25204. export interface IMaterialSheenDefines {
  25205. SHEEN: boolean;
  25206. SHEEN_TEXTURE: boolean;
  25207. SHEEN_TEXTURE_ROUGHNESS: boolean;
  25208. SHEEN_TEXTUREDIRECTUV: number;
  25209. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  25210. SHEEN_LINKWITHALBEDO: boolean;
  25211. SHEEN_ROUGHNESS: boolean;
  25212. SHEEN_ALBEDOSCALING: boolean;
  25213. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25214. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25215. /** @hidden */
  25216. _areTexturesDirty: boolean;
  25217. }
  25218. /**
  25219. * Define the code related to the Sheen parameters of the pbr material.
  25220. */
  25221. export class PBRSheenConfiguration {
  25222. private _isEnabled;
  25223. /**
  25224. * Defines if the material uses sheen.
  25225. */
  25226. isEnabled: boolean;
  25227. private _linkSheenWithAlbedo;
  25228. /**
  25229. * Defines if the sheen is linked to the sheen color.
  25230. */
  25231. linkSheenWithAlbedo: boolean;
  25232. /**
  25233. * Defines the sheen intensity.
  25234. */
  25235. intensity: number;
  25236. /**
  25237. * Defines the sheen color.
  25238. */
  25239. color: Color3;
  25240. private _texture;
  25241. /**
  25242. * Stores the sheen tint values in a texture.
  25243. * rgb is tint
  25244. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  25245. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  25246. */
  25247. texture: Nullable<BaseTexture>;
  25248. private _useRoughnessFromMainTexture;
  25249. /**
  25250. * Indicates that the alpha channel of the texture property will be used for roughness.
  25251. * Has no effect if the roughness (and texture!) property is not defined
  25252. */
  25253. useRoughnessFromMainTexture: boolean;
  25254. private _roughness;
  25255. /**
  25256. * Defines the sheen roughness.
  25257. * It is not taken into account if linkSheenWithAlbedo is true.
  25258. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25259. */
  25260. roughness: Nullable<number>;
  25261. private _textureRoughness;
  25262. /**
  25263. * Stores the sheen roughness in a texture.
  25264. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  25265. */
  25266. textureRoughness: Nullable<BaseTexture>;
  25267. private _albedoScaling;
  25268. /**
  25269. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25270. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25271. * making it easier to setup and tweak the effect
  25272. */
  25273. albedoScaling: boolean;
  25274. /** @hidden */
  25275. private _internalMarkAllSubMeshesAsTexturesDirty;
  25276. /** @hidden */
  25277. _markAllSubMeshesAsTexturesDirty(): void;
  25278. /**
  25279. * Instantiate a new istance of clear coat configuration.
  25280. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25281. */
  25282. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25283. /**
  25284. * Specifies that the submesh is ready to be used.
  25285. * @param defines the list of "defines" to update.
  25286. * @param scene defines the scene the material belongs to.
  25287. * @returns - boolean indicating that the submesh is ready or not.
  25288. */
  25289. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25290. /**
  25291. * Checks to see if a texture is used in the material.
  25292. * @param defines the list of "defines" to update.
  25293. * @param scene defines the scene the material belongs to.
  25294. */
  25295. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25296. /**
  25297. * Binds the material data.
  25298. * @param uniformBuffer defines the Uniform buffer to fill in.
  25299. * @param scene defines the scene the material belongs to.
  25300. * @param isFrozen defines wether the material is frozen or not.
  25301. * @param subMesh the submesh to bind data for
  25302. */
  25303. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25304. /**
  25305. * Checks to see if a texture is used in the material.
  25306. * @param texture - Base texture to use.
  25307. * @returns - Boolean specifying if a texture is used in the material.
  25308. */
  25309. hasTexture(texture: BaseTexture): boolean;
  25310. /**
  25311. * Returns an array of the actively used textures.
  25312. * @param activeTextures Array of BaseTextures
  25313. */
  25314. getActiveTextures(activeTextures: BaseTexture[]): void;
  25315. /**
  25316. * Returns the animatable textures.
  25317. * @param animatables Array of animatable textures.
  25318. */
  25319. getAnimatables(animatables: IAnimatable[]): void;
  25320. /**
  25321. * Disposes the resources of the material.
  25322. * @param forceDisposeTextures - Forces the disposal of all textures.
  25323. */
  25324. dispose(forceDisposeTextures?: boolean): void;
  25325. /**
  25326. * Get the current class name of the texture useful for serialization or dynamic coding.
  25327. * @returns "PBRSheenConfiguration"
  25328. */
  25329. getClassName(): string;
  25330. /**
  25331. * Add fallbacks to the effect fallbacks list.
  25332. * @param defines defines the Base texture to use.
  25333. * @param fallbacks defines the current fallback list.
  25334. * @param currentRank defines the current fallback rank.
  25335. * @returns the new fallback rank.
  25336. */
  25337. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25338. /**
  25339. * Add the required uniforms to the current list.
  25340. * @param uniforms defines the current uniform list.
  25341. */
  25342. static AddUniforms(uniforms: string[]): void;
  25343. /**
  25344. * Add the required uniforms to the current buffer.
  25345. * @param uniformBuffer defines the current uniform buffer.
  25346. */
  25347. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25348. /**
  25349. * Add the required samplers to the current list.
  25350. * @param samplers defines the current sampler list.
  25351. */
  25352. static AddSamplers(samplers: string[]): void;
  25353. /**
  25354. * Makes a duplicate of the current configuration into another one.
  25355. * @param sheenConfiguration define the config where to copy the info
  25356. */
  25357. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  25358. /**
  25359. * Serializes this BRDF configuration.
  25360. * @returns - An object with the serialized config.
  25361. */
  25362. serialize(): any;
  25363. /**
  25364. * Parses a anisotropy Configuration from a serialized object.
  25365. * @param source - Serialized object.
  25366. * @param scene Defines the scene we are parsing for
  25367. * @param rootUrl Defines the rootUrl to load from
  25368. */
  25369. parse(source: any, scene: Scene, rootUrl: string): void;
  25370. }
  25371. }
  25372. declare module BABYLON {
  25373. /**
  25374. * @hidden
  25375. */
  25376. export interface IMaterialSubSurfaceDefines {
  25377. SUBSURFACE: boolean;
  25378. SS_REFRACTION: boolean;
  25379. SS_TRANSLUCENCY: boolean;
  25380. SS_SCATTERING: boolean;
  25381. SS_THICKNESSANDMASK_TEXTURE: boolean;
  25382. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  25383. SS_REFRACTIONMAP_3D: boolean;
  25384. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  25385. SS_LODINREFRACTIONALPHA: boolean;
  25386. SS_GAMMAREFRACTION: boolean;
  25387. SS_RGBDREFRACTION: boolean;
  25388. SS_LINEARSPECULARREFRACTION: boolean;
  25389. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  25390. SS_ALBEDOFORREFRACTIONTINT: boolean;
  25391. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  25392. /** @hidden */
  25393. _areTexturesDirty: boolean;
  25394. }
  25395. /**
  25396. * Define the code related to the sub surface parameters of the pbr material.
  25397. */
  25398. export class PBRSubSurfaceConfiguration {
  25399. private _isRefractionEnabled;
  25400. /**
  25401. * Defines if the refraction is enabled in the material.
  25402. */
  25403. isRefractionEnabled: boolean;
  25404. private _isTranslucencyEnabled;
  25405. /**
  25406. * Defines if the translucency is enabled in the material.
  25407. */
  25408. isTranslucencyEnabled: boolean;
  25409. private _isScatteringEnabled;
  25410. /**
  25411. * Defines if the sub surface scattering is enabled in the material.
  25412. */
  25413. isScatteringEnabled: boolean;
  25414. private _scatteringDiffusionProfileIndex;
  25415. /**
  25416. * Diffusion profile for subsurface scattering.
  25417. * Useful for better scattering in the skins or foliages.
  25418. */
  25419. get scatteringDiffusionProfile(): Nullable<Color3>;
  25420. set scatteringDiffusionProfile(c: Nullable<Color3>);
  25421. /**
  25422. * Defines the refraction intensity of the material.
  25423. * The refraction when enabled replaces the Diffuse part of the material.
  25424. * The intensity helps transitionning between diffuse and refraction.
  25425. */
  25426. refractionIntensity: number;
  25427. /**
  25428. * Defines the translucency intensity of the material.
  25429. * When translucency has been enabled, this defines how much of the "translucency"
  25430. * is addded to the diffuse part of the material.
  25431. */
  25432. translucencyIntensity: number;
  25433. /**
  25434. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  25435. */
  25436. useAlbedoToTintRefraction: boolean;
  25437. private _thicknessTexture;
  25438. /**
  25439. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  25440. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  25441. * 0 would mean minimumThickness
  25442. * 1 would mean maximumThickness
  25443. * The other channels might be use as a mask to vary the different effects intensity.
  25444. */
  25445. thicknessTexture: Nullable<BaseTexture>;
  25446. private _refractionTexture;
  25447. /**
  25448. * Defines the texture to use for refraction.
  25449. */
  25450. refractionTexture: Nullable<BaseTexture>;
  25451. private _indexOfRefraction;
  25452. /**
  25453. * Index of refraction of the material base layer.
  25454. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25455. *
  25456. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  25457. *
  25458. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  25459. */
  25460. indexOfRefraction: number;
  25461. private _volumeIndexOfRefraction;
  25462. /**
  25463. * Index of refraction of the material's volume.
  25464. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25465. *
  25466. * This ONLY impacts refraction. If not provided or given a non-valid value,
  25467. * the volume will use the same IOR as the surface.
  25468. */
  25469. get volumeIndexOfRefraction(): number;
  25470. set volumeIndexOfRefraction(value: number);
  25471. private _invertRefractionY;
  25472. /**
  25473. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  25474. */
  25475. invertRefractionY: boolean;
  25476. private _linkRefractionWithTransparency;
  25477. /**
  25478. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25479. * Materials half opaque for instance using refraction could benefit from this control.
  25480. */
  25481. linkRefractionWithTransparency: boolean;
  25482. /**
  25483. * Defines the minimum thickness stored in the thickness map.
  25484. * If no thickness map is defined, this value will be used to simulate thickness.
  25485. */
  25486. minimumThickness: number;
  25487. /**
  25488. * Defines the maximum thickness stored in the thickness map.
  25489. */
  25490. maximumThickness: number;
  25491. /**
  25492. * Defines the volume tint of the material.
  25493. * This is used for both translucency and scattering.
  25494. */
  25495. tintColor: Color3;
  25496. /**
  25497. * Defines the distance at which the tint color should be found in the media.
  25498. * This is used for refraction only.
  25499. */
  25500. tintColorAtDistance: number;
  25501. /**
  25502. * Defines how far each channel transmit through the media.
  25503. * It is defined as a color to simplify it selection.
  25504. */
  25505. diffusionDistance: Color3;
  25506. private _useMaskFromThicknessTexture;
  25507. /**
  25508. * Stores the intensity of the different subsurface effects in the thickness texture.
  25509. * * the green channel is the translucency intensity.
  25510. * * the blue channel is the scattering intensity.
  25511. * * the alpha channel is the refraction intensity.
  25512. */
  25513. useMaskFromThicknessTexture: boolean;
  25514. private _scene;
  25515. /** @hidden */
  25516. private _internalMarkAllSubMeshesAsTexturesDirty;
  25517. private _internalMarkScenePrePassDirty;
  25518. /** @hidden */
  25519. _markAllSubMeshesAsTexturesDirty(): void;
  25520. /** @hidden */
  25521. _markScenePrePassDirty(): void;
  25522. /**
  25523. * Instantiate a new istance of sub surface configuration.
  25524. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25525. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  25526. * @param scene The scene
  25527. */
  25528. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  25529. /**
  25530. * Gets wehter the submesh is ready to be used or not.
  25531. * @param defines the list of "defines" to update.
  25532. * @param scene defines the scene the material belongs to.
  25533. * @returns - boolean indicating that the submesh is ready or not.
  25534. */
  25535. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  25536. /**
  25537. * Checks to see if a texture is used in the material.
  25538. * @param defines the list of "defines" to update.
  25539. * @param scene defines the scene to the material belongs to.
  25540. */
  25541. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  25542. /**
  25543. * Binds the material data.
  25544. * @param uniformBuffer defines the Uniform buffer to fill in.
  25545. * @param scene defines the scene the material belongs to.
  25546. * @param engine defines the engine the material belongs to.
  25547. * @param isFrozen defines whether the material is frozen or not.
  25548. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  25549. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  25550. */
  25551. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  25552. /**
  25553. * Unbinds the material from the mesh.
  25554. * @param activeEffect defines the effect that should be unbound from.
  25555. * @returns true if unbound, otherwise false
  25556. */
  25557. unbind(activeEffect: Effect): boolean;
  25558. /**
  25559. * Returns the texture used for refraction or null if none is used.
  25560. * @param scene defines the scene the material belongs to.
  25561. * @returns - Refraction texture if present. If no refraction texture and refraction
  25562. * is linked with transparency, returns environment texture. Otherwise, returns null.
  25563. */
  25564. private _getRefractionTexture;
  25565. /**
  25566. * Returns true if alpha blending should be disabled.
  25567. */
  25568. get disableAlphaBlending(): boolean;
  25569. /**
  25570. * Fills the list of render target textures.
  25571. * @param renderTargets the list of render targets to update
  25572. */
  25573. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  25574. /**
  25575. * Checks to see if a texture is used in the material.
  25576. * @param texture - Base texture to use.
  25577. * @returns - Boolean specifying if a texture is used in the material.
  25578. */
  25579. hasTexture(texture: BaseTexture): boolean;
  25580. /**
  25581. * Gets a boolean indicating that current material needs to register RTT
  25582. * @returns true if this uses a render target otherwise false.
  25583. */
  25584. hasRenderTargetTextures(): boolean;
  25585. /**
  25586. * Returns an array of the actively used textures.
  25587. * @param activeTextures Array of BaseTextures
  25588. */
  25589. getActiveTextures(activeTextures: BaseTexture[]): void;
  25590. /**
  25591. * Returns the animatable textures.
  25592. * @param animatables Array of animatable textures.
  25593. */
  25594. getAnimatables(animatables: IAnimatable[]): void;
  25595. /**
  25596. * Disposes the resources of the material.
  25597. * @param forceDisposeTextures - Forces the disposal of all textures.
  25598. */
  25599. dispose(forceDisposeTextures?: boolean): void;
  25600. /**
  25601. * Get the current class name of the texture useful for serialization or dynamic coding.
  25602. * @returns "PBRSubSurfaceConfiguration"
  25603. */
  25604. getClassName(): string;
  25605. /**
  25606. * Add fallbacks to the effect fallbacks list.
  25607. * @param defines defines the Base texture to use.
  25608. * @param fallbacks defines the current fallback list.
  25609. * @param currentRank defines the current fallback rank.
  25610. * @returns the new fallback rank.
  25611. */
  25612. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25613. /**
  25614. * Add the required uniforms to the current list.
  25615. * @param uniforms defines the current uniform list.
  25616. */
  25617. static AddUniforms(uniforms: string[]): void;
  25618. /**
  25619. * Add the required samplers to the current list.
  25620. * @param samplers defines the current sampler list.
  25621. */
  25622. static AddSamplers(samplers: string[]): void;
  25623. /**
  25624. * Add the required uniforms to the current buffer.
  25625. * @param uniformBuffer defines the current uniform buffer.
  25626. */
  25627. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25628. /**
  25629. * Makes a duplicate of the current configuration into another one.
  25630. * @param configuration define the config where to copy the info
  25631. */
  25632. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  25633. /**
  25634. * Serializes this Sub Surface configuration.
  25635. * @returns - An object with the serialized config.
  25636. */
  25637. serialize(): any;
  25638. /**
  25639. * Parses a anisotropy Configuration from a serialized object.
  25640. * @param source - Serialized object.
  25641. * @param scene Defines the scene we are parsing for
  25642. * @param rootUrl Defines the rootUrl to load from
  25643. */
  25644. parse(source: any, scene: Scene, rootUrl: string): void;
  25645. }
  25646. }
  25647. declare module BABYLON {
  25648. /**
  25649. * Class representing spherical harmonics coefficients to the 3rd degree
  25650. */
  25651. export class SphericalHarmonics {
  25652. /**
  25653. * Defines whether or not the harmonics have been prescaled for rendering.
  25654. */
  25655. preScaled: boolean;
  25656. /**
  25657. * The l0,0 coefficients of the spherical harmonics
  25658. */
  25659. l00: Vector3;
  25660. /**
  25661. * The l1,-1 coefficients of the spherical harmonics
  25662. */
  25663. l1_1: Vector3;
  25664. /**
  25665. * The l1,0 coefficients of the spherical harmonics
  25666. */
  25667. l10: Vector3;
  25668. /**
  25669. * The l1,1 coefficients of the spherical harmonics
  25670. */
  25671. l11: Vector3;
  25672. /**
  25673. * The l2,-2 coefficients of the spherical harmonics
  25674. */
  25675. l2_2: Vector3;
  25676. /**
  25677. * The l2,-1 coefficients of the spherical harmonics
  25678. */
  25679. l2_1: Vector3;
  25680. /**
  25681. * The l2,0 coefficients of the spherical harmonics
  25682. */
  25683. l20: Vector3;
  25684. /**
  25685. * The l2,1 coefficients of the spherical harmonics
  25686. */
  25687. l21: Vector3;
  25688. /**
  25689. * The l2,2 coefficients of the spherical harmonics
  25690. */
  25691. l22: Vector3;
  25692. /**
  25693. * Adds a light to the spherical harmonics
  25694. * @param direction the direction of the light
  25695. * @param color the color of the light
  25696. * @param deltaSolidAngle the delta solid angle of the light
  25697. */
  25698. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  25699. /**
  25700. * Scales the spherical harmonics by the given amount
  25701. * @param scale the amount to scale
  25702. */
  25703. scaleInPlace(scale: number): void;
  25704. /**
  25705. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  25706. *
  25707. * ```
  25708. * E_lm = A_l * L_lm
  25709. * ```
  25710. *
  25711. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  25712. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  25713. * the scaling factors are given in equation 9.
  25714. */
  25715. convertIncidentRadianceToIrradiance(): void;
  25716. /**
  25717. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  25718. *
  25719. * ```
  25720. * L = (1/pi) * E * rho
  25721. * ```
  25722. *
  25723. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  25724. */
  25725. convertIrradianceToLambertianRadiance(): void;
  25726. /**
  25727. * Integrates the reconstruction coefficients directly in to the SH preventing further
  25728. * required operations at run time.
  25729. *
  25730. * This is simply done by scaling back the SH with Ylm constants parameter.
  25731. * The trigonometric part being applied by the shader at run time.
  25732. */
  25733. preScaleForRendering(): void;
  25734. /**
  25735. * Constructs a spherical harmonics from an array.
  25736. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  25737. * @returns the spherical harmonics
  25738. */
  25739. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  25740. /**
  25741. * Gets the spherical harmonics from polynomial
  25742. * @param polynomial the spherical polynomial
  25743. * @returns the spherical harmonics
  25744. */
  25745. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  25746. }
  25747. /**
  25748. * Class representing spherical polynomial coefficients to the 3rd degree
  25749. */
  25750. export class SphericalPolynomial {
  25751. private _harmonics;
  25752. /**
  25753. * The spherical harmonics used to create the polynomials.
  25754. */
  25755. get preScaledHarmonics(): SphericalHarmonics;
  25756. /**
  25757. * The x coefficients of the spherical polynomial
  25758. */
  25759. x: Vector3;
  25760. /**
  25761. * The y coefficients of the spherical polynomial
  25762. */
  25763. y: Vector3;
  25764. /**
  25765. * The z coefficients of the spherical polynomial
  25766. */
  25767. z: Vector3;
  25768. /**
  25769. * The xx coefficients of the spherical polynomial
  25770. */
  25771. xx: Vector3;
  25772. /**
  25773. * The yy coefficients of the spherical polynomial
  25774. */
  25775. yy: Vector3;
  25776. /**
  25777. * The zz coefficients of the spherical polynomial
  25778. */
  25779. zz: Vector3;
  25780. /**
  25781. * The xy coefficients of the spherical polynomial
  25782. */
  25783. xy: Vector3;
  25784. /**
  25785. * The yz coefficients of the spherical polynomial
  25786. */
  25787. yz: Vector3;
  25788. /**
  25789. * The zx coefficients of the spherical polynomial
  25790. */
  25791. zx: Vector3;
  25792. /**
  25793. * Adds an ambient color to the spherical polynomial
  25794. * @param color the color to add
  25795. */
  25796. addAmbient(color: Color3): void;
  25797. /**
  25798. * Scales the spherical polynomial by the given amount
  25799. * @param scale the amount to scale
  25800. */
  25801. scaleInPlace(scale: number): void;
  25802. /**
  25803. * Gets the spherical polynomial from harmonics
  25804. * @param harmonics the spherical harmonics
  25805. * @returns the spherical polynomial
  25806. */
  25807. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  25808. /**
  25809. * Constructs a spherical polynomial from an array.
  25810. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  25811. * @returns the spherical polynomial
  25812. */
  25813. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  25814. }
  25815. }
  25816. declare module BABYLON {
  25817. /**
  25818. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  25819. */
  25820. export interface CubeMapInfo {
  25821. /**
  25822. * The pixel array for the front face.
  25823. * This is stored in format, left to right, up to down format.
  25824. */
  25825. front: Nullable<ArrayBufferView>;
  25826. /**
  25827. * The pixel array for the back face.
  25828. * This is stored in format, left to right, up to down format.
  25829. */
  25830. back: Nullable<ArrayBufferView>;
  25831. /**
  25832. * The pixel array for the left face.
  25833. * This is stored in format, left to right, up to down format.
  25834. */
  25835. left: Nullable<ArrayBufferView>;
  25836. /**
  25837. * The pixel array for the right face.
  25838. * This is stored in format, left to right, up to down format.
  25839. */
  25840. right: Nullable<ArrayBufferView>;
  25841. /**
  25842. * The pixel array for the up face.
  25843. * This is stored in format, left to right, up to down format.
  25844. */
  25845. up: Nullable<ArrayBufferView>;
  25846. /**
  25847. * The pixel array for the down face.
  25848. * This is stored in format, left to right, up to down format.
  25849. */
  25850. down: Nullable<ArrayBufferView>;
  25851. /**
  25852. * The size of the cubemap stored.
  25853. *
  25854. * Each faces will be size * size pixels.
  25855. */
  25856. size: number;
  25857. /**
  25858. * The format of the texture.
  25859. *
  25860. * RGBA, RGB.
  25861. */
  25862. format: number;
  25863. /**
  25864. * The type of the texture data.
  25865. *
  25866. * UNSIGNED_INT, FLOAT.
  25867. */
  25868. type: number;
  25869. /**
  25870. * Specifies whether the texture is in gamma space.
  25871. */
  25872. gammaSpace: boolean;
  25873. }
  25874. /**
  25875. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  25876. */
  25877. export class PanoramaToCubeMapTools {
  25878. private static FACE_LEFT;
  25879. private static FACE_RIGHT;
  25880. private static FACE_FRONT;
  25881. private static FACE_BACK;
  25882. private static FACE_DOWN;
  25883. private static FACE_UP;
  25884. /**
  25885. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  25886. *
  25887. * @param float32Array The source data.
  25888. * @param inputWidth The width of the input panorama.
  25889. * @param inputHeight The height of the input panorama.
  25890. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  25891. * @return The cubemap data
  25892. */
  25893. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  25894. private static CreateCubemapTexture;
  25895. private static CalcProjectionSpherical;
  25896. }
  25897. }
  25898. declare module BABYLON {
  25899. /**
  25900. * Helper class dealing with the extraction of spherical polynomial dataArray
  25901. * from a cube map.
  25902. */
  25903. export class CubeMapToSphericalPolynomialTools {
  25904. private static FileFaces;
  25905. /**
  25906. * Converts a texture to the according Spherical Polynomial data.
  25907. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25908. *
  25909. * @param texture The texture to extract the information from.
  25910. * @return The Spherical Polynomial data.
  25911. */
  25912. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  25913. /**
  25914. * Converts a cubemap to the according Spherical Polynomial data.
  25915. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25916. *
  25917. * @param cubeInfo The Cube map to extract the information from.
  25918. * @return The Spherical Polynomial data.
  25919. */
  25920. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  25921. }
  25922. }
  25923. declare module BABYLON {
  25924. interface BaseTexture {
  25925. /**
  25926. * Get the polynomial representation of the texture data.
  25927. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25928. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25929. */
  25930. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25931. }
  25932. }
  25933. declare module BABYLON {
  25934. /** @hidden */
  25935. export var pbrFragmentDeclaration: {
  25936. name: string;
  25937. shader: string;
  25938. };
  25939. }
  25940. declare module BABYLON {
  25941. /** @hidden */
  25942. export var pbrUboDeclaration: {
  25943. name: string;
  25944. shader: string;
  25945. };
  25946. }
  25947. declare module BABYLON {
  25948. /** @hidden */
  25949. export var pbrFragmentExtraDeclaration: {
  25950. name: string;
  25951. shader: string;
  25952. };
  25953. }
  25954. declare module BABYLON {
  25955. /** @hidden */
  25956. export var pbrFragmentSamplersDeclaration: {
  25957. name: string;
  25958. shader: string;
  25959. };
  25960. }
  25961. declare module BABYLON {
  25962. /** @hidden */
  25963. export var subSurfaceScatteringFunctions: {
  25964. name: string;
  25965. shader: string;
  25966. };
  25967. }
  25968. declare module BABYLON {
  25969. /** @hidden */
  25970. export var importanceSampling: {
  25971. name: string;
  25972. shader: string;
  25973. };
  25974. }
  25975. declare module BABYLON {
  25976. /** @hidden */
  25977. export var pbrHelperFunctions: {
  25978. name: string;
  25979. shader: string;
  25980. };
  25981. }
  25982. declare module BABYLON {
  25983. /** @hidden */
  25984. export var harmonicsFunctions: {
  25985. name: string;
  25986. shader: string;
  25987. };
  25988. }
  25989. declare module BABYLON {
  25990. /** @hidden */
  25991. export var pbrDirectLightingSetupFunctions: {
  25992. name: string;
  25993. shader: string;
  25994. };
  25995. }
  25996. declare module BABYLON {
  25997. /** @hidden */
  25998. export var pbrDirectLightingFalloffFunctions: {
  25999. name: string;
  26000. shader: string;
  26001. };
  26002. }
  26003. declare module BABYLON {
  26004. /** @hidden */
  26005. export var pbrBRDFFunctions: {
  26006. name: string;
  26007. shader: string;
  26008. };
  26009. }
  26010. declare module BABYLON {
  26011. /** @hidden */
  26012. export var hdrFilteringFunctions: {
  26013. name: string;
  26014. shader: string;
  26015. };
  26016. }
  26017. declare module BABYLON {
  26018. /** @hidden */
  26019. export var pbrDirectLightingFunctions: {
  26020. name: string;
  26021. shader: string;
  26022. };
  26023. }
  26024. declare module BABYLON {
  26025. /** @hidden */
  26026. export var pbrIBLFunctions: {
  26027. name: string;
  26028. shader: string;
  26029. };
  26030. }
  26031. declare module BABYLON {
  26032. /** @hidden */
  26033. export var pbrBlockAlbedoOpacity: {
  26034. name: string;
  26035. shader: string;
  26036. };
  26037. }
  26038. declare module BABYLON {
  26039. /** @hidden */
  26040. export var pbrBlockReflectivity: {
  26041. name: string;
  26042. shader: string;
  26043. };
  26044. }
  26045. declare module BABYLON {
  26046. /** @hidden */
  26047. export var pbrBlockAmbientOcclusion: {
  26048. name: string;
  26049. shader: string;
  26050. };
  26051. }
  26052. declare module BABYLON {
  26053. /** @hidden */
  26054. export var pbrBlockAlphaFresnel: {
  26055. name: string;
  26056. shader: string;
  26057. };
  26058. }
  26059. declare module BABYLON {
  26060. /** @hidden */
  26061. export var pbrBlockAnisotropic: {
  26062. name: string;
  26063. shader: string;
  26064. };
  26065. }
  26066. declare module BABYLON {
  26067. /** @hidden */
  26068. export var pbrBlockReflection: {
  26069. name: string;
  26070. shader: string;
  26071. };
  26072. }
  26073. declare module BABYLON {
  26074. /** @hidden */
  26075. export var pbrBlockSheen: {
  26076. name: string;
  26077. shader: string;
  26078. };
  26079. }
  26080. declare module BABYLON {
  26081. /** @hidden */
  26082. export var pbrBlockClearcoat: {
  26083. name: string;
  26084. shader: string;
  26085. };
  26086. }
  26087. declare module BABYLON {
  26088. /** @hidden */
  26089. export var pbrBlockSubSurface: {
  26090. name: string;
  26091. shader: string;
  26092. };
  26093. }
  26094. declare module BABYLON {
  26095. /** @hidden */
  26096. export var pbrBlockNormalGeometric: {
  26097. name: string;
  26098. shader: string;
  26099. };
  26100. }
  26101. declare module BABYLON {
  26102. /** @hidden */
  26103. export var pbrBlockNormalFinal: {
  26104. name: string;
  26105. shader: string;
  26106. };
  26107. }
  26108. declare module BABYLON {
  26109. /** @hidden */
  26110. export var pbrBlockLightmapInit: {
  26111. name: string;
  26112. shader: string;
  26113. };
  26114. }
  26115. declare module BABYLON {
  26116. /** @hidden */
  26117. export var pbrBlockGeometryInfo: {
  26118. name: string;
  26119. shader: string;
  26120. };
  26121. }
  26122. declare module BABYLON {
  26123. /** @hidden */
  26124. export var pbrBlockReflectance0: {
  26125. name: string;
  26126. shader: string;
  26127. };
  26128. }
  26129. declare module BABYLON {
  26130. /** @hidden */
  26131. export var pbrBlockReflectance: {
  26132. name: string;
  26133. shader: string;
  26134. };
  26135. }
  26136. declare module BABYLON {
  26137. /** @hidden */
  26138. export var pbrBlockDirectLighting: {
  26139. name: string;
  26140. shader: string;
  26141. };
  26142. }
  26143. declare module BABYLON {
  26144. /** @hidden */
  26145. export var pbrBlockFinalLitComponents: {
  26146. name: string;
  26147. shader: string;
  26148. };
  26149. }
  26150. declare module BABYLON {
  26151. /** @hidden */
  26152. export var pbrBlockFinalUnlitComponents: {
  26153. name: string;
  26154. shader: string;
  26155. };
  26156. }
  26157. declare module BABYLON {
  26158. /** @hidden */
  26159. export var pbrBlockFinalColorComposition: {
  26160. name: string;
  26161. shader: string;
  26162. };
  26163. }
  26164. declare module BABYLON {
  26165. /** @hidden */
  26166. export var pbrBlockImageProcessing: {
  26167. name: string;
  26168. shader: string;
  26169. };
  26170. }
  26171. declare module BABYLON {
  26172. /** @hidden */
  26173. export var pbrDebug: {
  26174. name: string;
  26175. shader: string;
  26176. };
  26177. }
  26178. declare module BABYLON {
  26179. /** @hidden */
  26180. export var pbrPixelShader: {
  26181. name: string;
  26182. shader: string;
  26183. };
  26184. }
  26185. declare module BABYLON {
  26186. /** @hidden */
  26187. export var pbrVertexDeclaration: {
  26188. name: string;
  26189. shader: string;
  26190. };
  26191. }
  26192. declare module BABYLON {
  26193. /** @hidden */
  26194. export var pbrVertexShader: {
  26195. name: string;
  26196. shader: string;
  26197. };
  26198. }
  26199. declare module BABYLON {
  26200. /**
  26201. * Manages the defines for the PBR Material.
  26202. * @hidden
  26203. */
  26204. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  26205. PBR: boolean;
  26206. NUM_SAMPLES: string;
  26207. REALTIME_FILTERING: boolean;
  26208. MAINUV1: boolean;
  26209. MAINUV2: boolean;
  26210. UV1: boolean;
  26211. UV2: boolean;
  26212. ALBEDO: boolean;
  26213. GAMMAALBEDO: boolean;
  26214. ALBEDODIRECTUV: number;
  26215. VERTEXCOLOR: boolean;
  26216. DETAIL: boolean;
  26217. DETAILDIRECTUV: number;
  26218. DETAIL_NORMALBLENDMETHOD: number;
  26219. AMBIENT: boolean;
  26220. AMBIENTDIRECTUV: number;
  26221. AMBIENTINGRAYSCALE: boolean;
  26222. OPACITY: boolean;
  26223. VERTEXALPHA: boolean;
  26224. OPACITYDIRECTUV: number;
  26225. OPACITYRGB: boolean;
  26226. ALPHATEST: boolean;
  26227. DEPTHPREPASS: boolean;
  26228. ALPHABLEND: boolean;
  26229. ALPHAFROMALBEDO: boolean;
  26230. ALPHATESTVALUE: string;
  26231. SPECULAROVERALPHA: boolean;
  26232. RADIANCEOVERALPHA: boolean;
  26233. ALPHAFRESNEL: boolean;
  26234. LINEARALPHAFRESNEL: boolean;
  26235. PREMULTIPLYALPHA: boolean;
  26236. EMISSIVE: boolean;
  26237. EMISSIVEDIRECTUV: number;
  26238. REFLECTIVITY: boolean;
  26239. REFLECTIVITYDIRECTUV: number;
  26240. SPECULARTERM: boolean;
  26241. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  26242. MICROSURFACEAUTOMATIC: boolean;
  26243. LODBASEDMICROSFURACE: boolean;
  26244. MICROSURFACEMAP: boolean;
  26245. MICROSURFACEMAPDIRECTUV: number;
  26246. METALLICWORKFLOW: boolean;
  26247. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  26248. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  26249. METALLNESSSTOREINMETALMAPBLUE: boolean;
  26250. AOSTOREINMETALMAPRED: boolean;
  26251. METALLIC_REFLECTANCE: boolean;
  26252. METALLIC_REFLECTANCEDIRECTUV: number;
  26253. ENVIRONMENTBRDF: boolean;
  26254. ENVIRONMENTBRDF_RGBD: boolean;
  26255. NORMAL: boolean;
  26256. TANGENT: boolean;
  26257. BUMP: boolean;
  26258. BUMPDIRECTUV: number;
  26259. OBJECTSPACE_NORMALMAP: boolean;
  26260. PARALLAX: boolean;
  26261. PARALLAXOCCLUSION: boolean;
  26262. NORMALXYSCALE: boolean;
  26263. LIGHTMAP: boolean;
  26264. LIGHTMAPDIRECTUV: number;
  26265. USELIGHTMAPASSHADOWMAP: boolean;
  26266. GAMMALIGHTMAP: boolean;
  26267. RGBDLIGHTMAP: boolean;
  26268. REFLECTION: boolean;
  26269. REFLECTIONMAP_3D: boolean;
  26270. REFLECTIONMAP_SPHERICAL: boolean;
  26271. REFLECTIONMAP_PLANAR: boolean;
  26272. REFLECTIONMAP_CUBIC: boolean;
  26273. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26274. REFLECTIONMAP_PROJECTION: boolean;
  26275. REFLECTIONMAP_SKYBOX: boolean;
  26276. REFLECTIONMAP_EXPLICIT: boolean;
  26277. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26278. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26279. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26280. INVERTCUBICMAP: boolean;
  26281. USESPHERICALFROMREFLECTIONMAP: boolean;
  26282. USEIRRADIANCEMAP: boolean;
  26283. SPHERICAL_HARMONICS: boolean;
  26284. USESPHERICALINVERTEX: boolean;
  26285. REFLECTIONMAP_OPPOSITEZ: boolean;
  26286. LODINREFLECTIONALPHA: boolean;
  26287. GAMMAREFLECTION: boolean;
  26288. RGBDREFLECTION: boolean;
  26289. LINEARSPECULARREFLECTION: boolean;
  26290. RADIANCEOCCLUSION: boolean;
  26291. HORIZONOCCLUSION: boolean;
  26292. INSTANCES: boolean;
  26293. THIN_INSTANCES: boolean;
  26294. PREPASS: boolean;
  26295. PREPASS_IRRADIANCE: boolean;
  26296. PREPASS_IRRADIANCE_INDEX: number;
  26297. PREPASS_ALBEDO: boolean;
  26298. PREPASS_ALBEDO_INDEX: number;
  26299. PREPASS_DEPTHNORMAL: boolean;
  26300. PREPASS_DEPTHNORMAL_INDEX: number;
  26301. PREPASS_POSITION: boolean;
  26302. PREPASS_POSITION_INDEX: number;
  26303. PREPASS_VELOCITY: boolean;
  26304. PREPASS_VELOCITY_INDEX: number;
  26305. PREPASS_REFLECTIVITY: boolean;
  26306. PREPASS_REFLECTIVITY_INDEX: number;
  26307. SCENE_MRT_COUNT: number;
  26308. NUM_BONE_INFLUENCERS: number;
  26309. BonesPerMesh: number;
  26310. BONETEXTURE: boolean;
  26311. BONES_VELOCITY_ENABLED: boolean;
  26312. NONUNIFORMSCALING: boolean;
  26313. MORPHTARGETS: boolean;
  26314. MORPHTARGETS_NORMAL: boolean;
  26315. MORPHTARGETS_TANGENT: boolean;
  26316. MORPHTARGETS_UV: boolean;
  26317. NUM_MORPH_INFLUENCERS: number;
  26318. IMAGEPROCESSING: boolean;
  26319. VIGNETTE: boolean;
  26320. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26321. VIGNETTEBLENDMODEOPAQUE: boolean;
  26322. TONEMAPPING: boolean;
  26323. TONEMAPPING_ACES: boolean;
  26324. CONTRAST: boolean;
  26325. COLORCURVES: boolean;
  26326. COLORGRADING: boolean;
  26327. COLORGRADING3D: boolean;
  26328. SAMPLER3DGREENDEPTH: boolean;
  26329. SAMPLER3DBGRMAP: boolean;
  26330. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26331. EXPOSURE: boolean;
  26332. MULTIVIEW: boolean;
  26333. USEPHYSICALLIGHTFALLOFF: boolean;
  26334. USEGLTFLIGHTFALLOFF: boolean;
  26335. TWOSIDEDLIGHTING: boolean;
  26336. SHADOWFLOAT: boolean;
  26337. CLIPPLANE: boolean;
  26338. CLIPPLANE2: boolean;
  26339. CLIPPLANE3: boolean;
  26340. CLIPPLANE4: boolean;
  26341. CLIPPLANE5: boolean;
  26342. CLIPPLANE6: boolean;
  26343. POINTSIZE: boolean;
  26344. FOG: boolean;
  26345. LOGARITHMICDEPTH: boolean;
  26346. FORCENORMALFORWARD: boolean;
  26347. SPECULARAA: boolean;
  26348. CLEARCOAT: boolean;
  26349. CLEARCOAT_DEFAULTIOR: boolean;
  26350. CLEARCOAT_TEXTURE: boolean;
  26351. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  26352. CLEARCOAT_TEXTUREDIRECTUV: number;
  26353. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  26354. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26355. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26356. CLEARCOAT_BUMP: boolean;
  26357. CLEARCOAT_BUMPDIRECTUV: number;
  26358. CLEARCOAT_REMAP_F0: boolean;
  26359. CLEARCOAT_TINT: boolean;
  26360. CLEARCOAT_TINT_TEXTURE: boolean;
  26361. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  26362. ANISOTROPIC: boolean;
  26363. ANISOTROPIC_TEXTURE: boolean;
  26364. ANISOTROPIC_TEXTUREDIRECTUV: number;
  26365. BRDF_V_HEIGHT_CORRELATED: boolean;
  26366. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26367. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26368. SHEEN: boolean;
  26369. SHEEN_TEXTURE: boolean;
  26370. SHEEN_TEXTURE_ROUGHNESS: boolean;
  26371. SHEEN_TEXTUREDIRECTUV: number;
  26372. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  26373. SHEEN_LINKWITHALBEDO: boolean;
  26374. SHEEN_ROUGHNESS: boolean;
  26375. SHEEN_ALBEDOSCALING: boolean;
  26376. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26377. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26378. SUBSURFACE: boolean;
  26379. SS_REFRACTION: boolean;
  26380. SS_TRANSLUCENCY: boolean;
  26381. SS_SCATTERING: boolean;
  26382. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26383. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26384. SS_REFRACTIONMAP_3D: boolean;
  26385. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26386. SS_LODINREFRACTIONALPHA: boolean;
  26387. SS_GAMMAREFRACTION: boolean;
  26388. SS_RGBDREFRACTION: boolean;
  26389. SS_LINEARSPECULARREFRACTION: boolean;
  26390. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26391. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26392. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26393. UNLIT: boolean;
  26394. DEBUGMODE: number;
  26395. /**
  26396. * Initializes the PBR Material defines.
  26397. */
  26398. constructor();
  26399. /**
  26400. * Resets the PBR Material defines.
  26401. */
  26402. reset(): void;
  26403. }
  26404. /**
  26405. * The Physically based material base class of BJS.
  26406. *
  26407. * This offers the main features of a standard PBR material.
  26408. * For more information, please refer to the documentation :
  26409. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26410. */
  26411. export abstract class PBRBaseMaterial extends PushMaterial {
  26412. /**
  26413. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26414. */
  26415. static readonly PBRMATERIAL_OPAQUE: number;
  26416. /**
  26417. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26418. */
  26419. static readonly PBRMATERIAL_ALPHATEST: number;
  26420. /**
  26421. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26422. */
  26423. static readonly PBRMATERIAL_ALPHABLEND: number;
  26424. /**
  26425. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26426. * They are also discarded below the alpha cutoff threshold to improve performances.
  26427. */
  26428. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26429. /**
  26430. * Defines the default value of how much AO map is occluding the analytical lights
  26431. * (point spot...).
  26432. */
  26433. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26434. /**
  26435. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  26436. */
  26437. static readonly LIGHTFALLOFF_PHYSICAL: number;
  26438. /**
  26439. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  26440. * to enhance interoperability with other engines.
  26441. */
  26442. static readonly LIGHTFALLOFF_GLTF: number;
  26443. /**
  26444. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  26445. * to enhance interoperability with other materials.
  26446. */
  26447. static readonly LIGHTFALLOFF_STANDARD: number;
  26448. /**
  26449. * Intensity of the direct lights e.g. the four lights available in your scene.
  26450. * This impacts both the direct diffuse and specular highlights.
  26451. */
  26452. protected _directIntensity: number;
  26453. /**
  26454. * Intensity of the emissive part of the material.
  26455. * This helps controlling the emissive effect without modifying the emissive color.
  26456. */
  26457. protected _emissiveIntensity: number;
  26458. /**
  26459. * Intensity of the environment e.g. how much the environment will light the object
  26460. * either through harmonics for rough material or through the refelction for shiny ones.
  26461. */
  26462. protected _environmentIntensity: number;
  26463. /**
  26464. * This is a special control allowing the reduction of the specular highlights coming from the
  26465. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26466. */
  26467. protected _specularIntensity: number;
  26468. /**
  26469. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  26470. */
  26471. private _lightingInfos;
  26472. /**
  26473. * Debug Control allowing disabling the bump map on this material.
  26474. */
  26475. protected _disableBumpMap: boolean;
  26476. /**
  26477. * AKA Diffuse Texture in standard nomenclature.
  26478. */
  26479. protected _albedoTexture: Nullable<BaseTexture>;
  26480. /**
  26481. * AKA Occlusion Texture in other nomenclature.
  26482. */
  26483. protected _ambientTexture: Nullable<BaseTexture>;
  26484. /**
  26485. * AKA Occlusion Texture Intensity in other nomenclature.
  26486. */
  26487. protected _ambientTextureStrength: number;
  26488. /**
  26489. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26490. * 1 means it completely occludes it
  26491. * 0 mean it has no impact
  26492. */
  26493. protected _ambientTextureImpactOnAnalyticalLights: number;
  26494. /**
  26495. * Stores the alpha values in a texture.
  26496. */
  26497. protected _opacityTexture: Nullable<BaseTexture>;
  26498. /**
  26499. * Stores the reflection values in a texture.
  26500. */
  26501. protected _reflectionTexture: Nullable<BaseTexture>;
  26502. /**
  26503. * Stores the emissive values in a texture.
  26504. */
  26505. protected _emissiveTexture: Nullable<BaseTexture>;
  26506. /**
  26507. * AKA Specular texture in other nomenclature.
  26508. */
  26509. protected _reflectivityTexture: Nullable<BaseTexture>;
  26510. /**
  26511. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26512. */
  26513. protected _metallicTexture: Nullable<BaseTexture>;
  26514. /**
  26515. * Specifies the metallic scalar of the metallic/roughness workflow.
  26516. * Can also be used to scale the metalness values of the metallic texture.
  26517. */
  26518. protected _metallic: Nullable<number>;
  26519. /**
  26520. * Specifies the roughness scalar of the metallic/roughness workflow.
  26521. * Can also be used to scale the roughness values of the metallic texture.
  26522. */
  26523. protected _roughness: Nullable<number>;
  26524. /**
  26525. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26526. * By default the indexOfrefraction is used to compute F0;
  26527. *
  26528. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26529. *
  26530. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26531. * F90 = metallicReflectanceColor;
  26532. */
  26533. protected _metallicF0Factor: number;
  26534. /**
  26535. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26536. * By default the F90 is always 1;
  26537. *
  26538. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26539. *
  26540. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26541. * F90 = metallicReflectanceColor;
  26542. */
  26543. protected _metallicReflectanceColor: Color3;
  26544. /**
  26545. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26546. * This is multiply against the scalar values defined in the material.
  26547. */
  26548. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  26549. /**
  26550. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26551. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26552. */
  26553. protected _microSurfaceTexture: Nullable<BaseTexture>;
  26554. /**
  26555. * Stores surface normal data used to displace a mesh in a texture.
  26556. */
  26557. protected _bumpTexture: Nullable<BaseTexture>;
  26558. /**
  26559. * Stores the pre-calculated light information of a mesh in a texture.
  26560. */
  26561. protected _lightmapTexture: Nullable<BaseTexture>;
  26562. /**
  26563. * The color of a material in ambient lighting.
  26564. */
  26565. protected _ambientColor: Color3;
  26566. /**
  26567. * AKA Diffuse Color in other nomenclature.
  26568. */
  26569. protected _albedoColor: Color3;
  26570. /**
  26571. * AKA Specular Color in other nomenclature.
  26572. */
  26573. protected _reflectivityColor: Color3;
  26574. /**
  26575. * The color applied when light is reflected from a material.
  26576. */
  26577. protected _reflectionColor: Color3;
  26578. /**
  26579. * The color applied when light is emitted from a material.
  26580. */
  26581. protected _emissiveColor: Color3;
  26582. /**
  26583. * AKA Glossiness in other nomenclature.
  26584. */
  26585. protected _microSurface: number;
  26586. /**
  26587. * Specifies that the material will use the light map as a show map.
  26588. */
  26589. protected _useLightmapAsShadowmap: boolean;
  26590. /**
  26591. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26592. * makes the reflect vector face the model (under horizon).
  26593. */
  26594. protected _useHorizonOcclusion: boolean;
  26595. /**
  26596. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26597. * too much the area relying on ambient texture to define their ambient occlusion.
  26598. */
  26599. protected _useRadianceOcclusion: boolean;
  26600. /**
  26601. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26602. */
  26603. protected _useAlphaFromAlbedoTexture: boolean;
  26604. /**
  26605. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  26606. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26607. */
  26608. protected _useSpecularOverAlpha: boolean;
  26609. /**
  26610. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26611. */
  26612. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26613. /**
  26614. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26615. */
  26616. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  26617. /**
  26618. * Specifies if the metallic texture contains the roughness information in its green channel.
  26619. */
  26620. protected _useRoughnessFromMetallicTextureGreen: boolean;
  26621. /**
  26622. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26623. */
  26624. protected _useMetallnessFromMetallicTextureBlue: boolean;
  26625. /**
  26626. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26627. */
  26628. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  26629. /**
  26630. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26631. */
  26632. protected _useAmbientInGrayScale: boolean;
  26633. /**
  26634. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26635. * The material will try to infer what glossiness each pixel should be.
  26636. */
  26637. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  26638. /**
  26639. * Defines the falloff type used in this material.
  26640. * It by default is Physical.
  26641. */
  26642. protected _lightFalloff: number;
  26643. /**
  26644. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26645. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26646. */
  26647. protected _useRadianceOverAlpha: boolean;
  26648. /**
  26649. * Allows using an object space normal map (instead of tangent space).
  26650. */
  26651. protected _useObjectSpaceNormalMap: boolean;
  26652. /**
  26653. * Allows using the bump map in parallax mode.
  26654. */
  26655. protected _useParallax: boolean;
  26656. /**
  26657. * Allows using the bump map in parallax occlusion mode.
  26658. */
  26659. protected _useParallaxOcclusion: boolean;
  26660. /**
  26661. * Controls the scale bias of the parallax mode.
  26662. */
  26663. protected _parallaxScaleBias: number;
  26664. /**
  26665. * If sets to true, disables all the lights affecting the material.
  26666. */
  26667. protected _disableLighting: boolean;
  26668. /**
  26669. * Number of Simultaneous lights allowed on the material.
  26670. */
  26671. protected _maxSimultaneousLights: number;
  26672. /**
  26673. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  26674. */
  26675. protected _invertNormalMapX: boolean;
  26676. /**
  26677. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  26678. */
  26679. protected _invertNormalMapY: boolean;
  26680. /**
  26681. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26682. */
  26683. protected _twoSidedLighting: boolean;
  26684. /**
  26685. * Defines the alpha limits in alpha test mode.
  26686. */
  26687. protected _alphaCutOff: number;
  26688. /**
  26689. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26690. */
  26691. protected _forceAlphaTest: boolean;
  26692. /**
  26693. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26694. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26695. */
  26696. protected _useAlphaFresnel: boolean;
  26697. /**
  26698. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26699. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26700. */
  26701. protected _useLinearAlphaFresnel: boolean;
  26702. /**
  26703. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  26704. * from cos thetav and roughness:
  26705. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  26706. */
  26707. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  26708. /**
  26709. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26710. */
  26711. protected _forceIrradianceInFragment: boolean;
  26712. private _realTimeFiltering;
  26713. /**
  26714. * Enables realtime filtering on the texture.
  26715. */
  26716. get realTimeFiltering(): boolean;
  26717. set realTimeFiltering(b: boolean);
  26718. private _realTimeFilteringQuality;
  26719. /**
  26720. * Quality switch for realtime filtering
  26721. */
  26722. get realTimeFilteringQuality(): number;
  26723. set realTimeFilteringQuality(n: number);
  26724. /**
  26725. * Can this material render to several textures at once
  26726. */
  26727. get canRenderToMRT(): boolean;
  26728. /**
  26729. * Force normal to face away from face.
  26730. */
  26731. protected _forceNormalForward: boolean;
  26732. /**
  26733. * Enables specular anti aliasing in the PBR shader.
  26734. * It will both interacts on the Geometry for analytical and IBL lighting.
  26735. * It also prefilter the roughness map based on the bump values.
  26736. */
  26737. protected _enableSpecularAntiAliasing: boolean;
  26738. /**
  26739. * Default configuration related to image processing available in the PBR Material.
  26740. */
  26741. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26742. /**
  26743. * Keep track of the image processing observer to allow dispose and replace.
  26744. */
  26745. private _imageProcessingObserver;
  26746. /**
  26747. * Attaches a new image processing configuration to the PBR Material.
  26748. * @param configuration
  26749. */
  26750. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26751. /**
  26752. * Stores the available render targets.
  26753. */
  26754. private _renderTargets;
  26755. /**
  26756. * Sets the global ambient color for the material used in lighting calculations.
  26757. */
  26758. private _globalAmbientColor;
  26759. /**
  26760. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  26761. */
  26762. private _useLogarithmicDepth;
  26763. /**
  26764. * If set to true, no lighting calculations will be applied.
  26765. */
  26766. private _unlit;
  26767. private _debugMode;
  26768. /**
  26769. * @hidden
  26770. * This is reserved for the inspector.
  26771. * Defines the material debug mode.
  26772. * It helps seeing only some components of the material while troubleshooting.
  26773. */
  26774. debugMode: number;
  26775. /**
  26776. * @hidden
  26777. * This is reserved for the inspector.
  26778. * Specify from where on screen the debug mode should start.
  26779. * The value goes from -1 (full screen) to 1 (not visible)
  26780. * It helps with side by side comparison against the final render
  26781. * This defaults to -1
  26782. */
  26783. private debugLimit;
  26784. /**
  26785. * @hidden
  26786. * This is reserved for the inspector.
  26787. * As the default viewing range might not be enough (if the ambient is really small for instance)
  26788. * You can use the factor to better multiply the final value.
  26789. */
  26790. private debugFactor;
  26791. /**
  26792. * Defines the clear coat layer parameters for the material.
  26793. */
  26794. readonly clearCoat: PBRClearCoatConfiguration;
  26795. /**
  26796. * Defines the anisotropic parameters for the material.
  26797. */
  26798. readonly anisotropy: PBRAnisotropicConfiguration;
  26799. /**
  26800. * Defines the BRDF parameters for the material.
  26801. */
  26802. readonly brdf: PBRBRDFConfiguration;
  26803. /**
  26804. * Defines the Sheen parameters for the material.
  26805. */
  26806. readonly sheen: PBRSheenConfiguration;
  26807. /**
  26808. * Defines the SubSurface parameters for the material.
  26809. */
  26810. readonly subSurface: PBRSubSurfaceConfiguration;
  26811. /**
  26812. * Defines additionnal PrePass parameters for the material.
  26813. */
  26814. readonly prePassConfiguration: PrePassConfiguration;
  26815. /**
  26816. * Defines the detail map parameters for the material.
  26817. */
  26818. readonly detailMap: DetailMapConfiguration;
  26819. protected _rebuildInParallel: boolean;
  26820. /**
  26821. * Instantiates a new PBRMaterial instance.
  26822. *
  26823. * @param name The material name
  26824. * @param scene The scene the material will be use in.
  26825. */
  26826. constructor(name: string, scene: Scene);
  26827. /**
  26828. * Gets a boolean indicating that current material needs to register RTT
  26829. */
  26830. get hasRenderTargetTextures(): boolean;
  26831. /**
  26832. * Gets the name of the material class.
  26833. */
  26834. getClassName(): string;
  26835. /**
  26836. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26837. */
  26838. get useLogarithmicDepth(): boolean;
  26839. /**
  26840. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26841. */
  26842. set useLogarithmicDepth(value: boolean);
  26843. /**
  26844. * Returns true if alpha blending should be disabled.
  26845. */
  26846. protected get _disableAlphaBlending(): boolean;
  26847. /**
  26848. * Specifies whether or not this material should be rendered in alpha blend mode.
  26849. */
  26850. needAlphaBlending(): boolean;
  26851. /**
  26852. * Specifies whether or not this material should be rendered in alpha test mode.
  26853. */
  26854. needAlphaTesting(): boolean;
  26855. /**
  26856. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  26857. */
  26858. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  26859. /**
  26860. * Specifies whether or not there is a usable alpha channel for transparency.
  26861. */
  26862. protected _hasAlphaChannel(): boolean;
  26863. /**
  26864. * Gets the texture used for the alpha test.
  26865. */
  26866. getAlphaTestTexture(): Nullable<BaseTexture>;
  26867. /**
  26868. * Specifies that the submesh is ready to be used.
  26869. * @param mesh - BJS mesh.
  26870. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  26871. * @param useInstances - Specifies that instances should be used.
  26872. * @returns - boolean indicating that the submesh is ready or not.
  26873. */
  26874. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26875. /**
  26876. * Specifies if the material uses metallic roughness workflow.
  26877. * @returns boolean specifiying if the material uses metallic roughness workflow.
  26878. */
  26879. isMetallicWorkflow(): boolean;
  26880. private _prepareEffect;
  26881. private _prepareDefines;
  26882. /**
  26883. * Force shader compilation
  26884. */
  26885. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  26886. /**
  26887. * Initializes the uniform buffer layout for the shader.
  26888. */
  26889. buildUniformLayout(): void;
  26890. /**
  26891. * Unbinds the material from the mesh
  26892. */
  26893. unbind(): void;
  26894. /**
  26895. * Binds the submesh data.
  26896. * @param world - The world matrix.
  26897. * @param mesh - The BJS mesh.
  26898. * @param subMesh - A submesh of the BJS mesh.
  26899. */
  26900. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26901. /**
  26902. * Returns the animatable textures.
  26903. * @returns - Array of animatable textures.
  26904. */
  26905. getAnimatables(): IAnimatable[];
  26906. /**
  26907. * Returns the texture used for reflections.
  26908. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  26909. */
  26910. private _getReflectionTexture;
  26911. /**
  26912. * Returns an array of the actively used textures.
  26913. * @returns - Array of BaseTextures
  26914. */
  26915. getActiveTextures(): BaseTexture[];
  26916. /**
  26917. * Checks to see if a texture is used in the material.
  26918. * @param texture - Base texture to use.
  26919. * @returns - Boolean specifying if a texture is used in the material.
  26920. */
  26921. hasTexture(texture: BaseTexture): boolean;
  26922. /**
  26923. * Sets the required values to the prepass renderer.
  26924. * @param prePassRenderer defines the prepass renderer to setup
  26925. */
  26926. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26927. /**
  26928. * Disposes the resources of the material.
  26929. * @param forceDisposeEffect - Forces the disposal of effects.
  26930. * @param forceDisposeTextures - Forces the disposal of all textures.
  26931. */
  26932. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26933. }
  26934. }
  26935. declare module BABYLON {
  26936. /**
  26937. * The Physically based material of BJS.
  26938. *
  26939. * This offers the main features of a standard PBR material.
  26940. * For more information, please refer to the documentation :
  26941. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26942. */
  26943. export class PBRMaterial extends PBRBaseMaterial {
  26944. /**
  26945. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26946. */
  26947. static readonly PBRMATERIAL_OPAQUE: number;
  26948. /**
  26949. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26950. */
  26951. static readonly PBRMATERIAL_ALPHATEST: number;
  26952. /**
  26953. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26954. */
  26955. static readonly PBRMATERIAL_ALPHABLEND: number;
  26956. /**
  26957. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26958. * They are also discarded below the alpha cutoff threshold to improve performances.
  26959. */
  26960. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26961. /**
  26962. * Defines the default value of how much AO map is occluding the analytical lights
  26963. * (point spot...).
  26964. */
  26965. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26966. /**
  26967. * Intensity of the direct lights e.g. the four lights available in your scene.
  26968. * This impacts both the direct diffuse and specular highlights.
  26969. */
  26970. directIntensity: number;
  26971. /**
  26972. * Intensity of the emissive part of the material.
  26973. * This helps controlling the emissive effect without modifying the emissive color.
  26974. */
  26975. emissiveIntensity: number;
  26976. /**
  26977. * Intensity of the environment e.g. how much the environment will light the object
  26978. * either through harmonics for rough material or through the refelction for shiny ones.
  26979. */
  26980. environmentIntensity: number;
  26981. /**
  26982. * This is a special control allowing the reduction of the specular highlights coming from the
  26983. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26984. */
  26985. specularIntensity: number;
  26986. /**
  26987. * Debug Control allowing disabling the bump map on this material.
  26988. */
  26989. disableBumpMap: boolean;
  26990. /**
  26991. * AKA Diffuse Texture in standard nomenclature.
  26992. */
  26993. albedoTexture: BaseTexture;
  26994. /**
  26995. * AKA Occlusion Texture in other nomenclature.
  26996. */
  26997. ambientTexture: BaseTexture;
  26998. /**
  26999. * AKA Occlusion Texture Intensity in other nomenclature.
  27000. */
  27001. ambientTextureStrength: number;
  27002. /**
  27003. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27004. * 1 means it completely occludes it
  27005. * 0 mean it has no impact
  27006. */
  27007. ambientTextureImpactOnAnalyticalLights: number;
  27008. /**
  27009. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  27010. */
  27011. opacityTexture: BaseTexture;
  27012. /**
  27013. * Stores the reflection values in a texture.
  27014. */
  27015. reflectionTexture: Nullable<BaseTexture>;
  27016. /**
  27017. * Stores the emissive values in a texture.
  27018. */
  27019. emissiveTexture: BaseTexture;
  27020. /**
  27021. * AKA Specular texture in other nomenclature.
  27022. */
  27023. reflectivityTexture: BaseTexture;
  27024. /**
  27025. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27026. */
  27027. metallicTexture: BaseTexture;
  27028. /**
  27029. * Specifies the metallic scalar of the metallic/roughness workflow.
  27030. * Can also be used to scale the metalness values of the metallic texture.
  27031. */
  27032. metallic: Nullable<number>;
  27033. /**
  27034. * Specifies the roughness scalar of the metallic/roughness workflow.
  27035. * Can also be used to scale the roughness values of the metallic texture.
  27036. */
  27037. roughness: Nullable<number>;
  27038. /**
  27039. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27040. * By default the indexOfrefraction is used to compute F0;
  27041. *
  27042. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27043. *
  27044. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27045. * F90 = metallicReflectanceColor;
  27046. */
  27047. metallicF0Factor: number;
  27048. /**
  27049. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27050. * By default the F90 is always 1;
  27051. *
  27052. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27053. *
  27054. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27055. * F90 = metallicReflectanceColor;
  27056. */
  27057. metallicReflectanceColor: Color3;
  27058. /**
  27059. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27060. * This is multiply against the scalar values defined in the material.
  27061. */
  27062. metallicReflectanceTexture: Nullable<BaseTexture>;
  27063. /**
  27064. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27065. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27066. */
  27067. microSurfaceTexture: BaseTexture;
  27068. /**
  27069. * Stores surface normal data used to displace a mesh in a texture.
  27070. */
  27071. bumpTexture: BaseTexture;
  27072. /**
  27073. * Stores the pre-calculated light information of a mesh in a texture.
  27074. */
  27075. lightmapTexture: BaseTexture;
  27076. /**
  27077. * Stores the refracted light information in a texture.
  27078. */
  27079. get refractionTexture(): Nullable<BaseTexture>;
  27080. set refractionTexture(value: Nullable<BaseTexture>);
  27081. /**
  27082. * The color of a material in ambient lighting.
  27083. */
  27084. ambientColor: Color3;
  27085. /**
  27086. * AKA Diffuse Color in other nomenclature.
  27087. */
  27088. albedoColor: Color3;
  27089. /**
  27090. * AKA Specular Color in other nomenclature.
  27091. */
  27092. reflectivityColor: Color3;
  27093. /**
  27094. * The color reflected from the material.
  27095. */
  27096. reflectionColor: Color3;
  27097. /**
  27098. * The color emitted from the material.
  27099. */
  27100. emissiveColor: Color3;
  27101. /**
  27102. * AKA Glossiness in other nomenclature.
  27103. */
  27104. microSurface: number;
  27105. /**
  27106. * Index of refraction of the material base layer.
  27107. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  27108. *
  27109. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  27110. *
  27111. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  27112. */
  27113. get indexOfRefraction(): number;
  27114. set indexOfRefraction(value: number);
  27115. /**
  27116. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  27117. */
  27118. get invertRefractionY(): boolean;
  27119. set invertRefractionY(value: boolean);
  27120. /**
  27121. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27122. * Materials half opaque for instance using refraction could benefit from this control.
  27123. */
  27124. get linkRefractionWithTransparency(): boolean;
  27125. set linkRefractionWithTransparency(value: boolean);
  27126. /**
  27127. * If true, the light map contains occlusion information instead of lighting info.
  27128. */
  27129. useLightmapAsShadowmap: boolean;
  27130. /**
  27131. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27132. */
  27133. useAlphaFromAlbedoTexture: boolean;
  27134. /**
  27135. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27136. */
  27137. forceAlphaTest: boolean;
  27138. /**
  27139. * Defines the alpha limits in alpha test mode.
  27140. */
  27141. alphaCutOff: number;
  27142. /**
  27143. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27144. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27145. */
  27146. useSpecularOverAlpha: boolean;
  27147. /**
  27148. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27149. */
  27150. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27151. /**
  27152. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27153. */
  27154. useRoughnessFromMetallicTextureAlpha: boolean;
  27155. /**
  27156. * Specifies if the metallic texture contains the roughness information in its green channel.
  27157. */
  27158. useRoughnessFromMetallicTextureGreen: boolean;
  27159. /**
  27160. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27161. */
  27162. useMetallnessFromMetallicTextureBlue: boolean;
  27163. /**
  27164. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27165. */
  27166. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27167. /**
  27168. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27169. */
  27170. useAmbientInGrayScale: boolean;
  27171. /**
  27172. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27173. * The material will try to infer what glossiness each pixel should be.
  27174. */
  27175. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27176. /**
  27177. * BJS is using an harcoded light falloff based on a manually sets up range.
  27178. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27179. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27180. */
  27181. get usePhysicalLightFalloff(): boolean;
  27182. /**
  27183. * BJS is using an harcoded light falloff based on a manually sets up range.
  27184. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27185. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27186. */
  27187. set usePhysicalLightFalloff(value: boolean);
  27188. /**
  27189. * In order to support the falloff compatibility with gltf, a special mode has been added
  27190. * to reproduce the gltf light falloff.
  27191. */
  27192. get useGLTFLightFalloff(): boolean;
  27193. /**
  27194. * In order to support the falloff compatibility with gltf, a special mode has been added
  27195. * to reproduce the gltf light falloff.
  27196. */
  27197. set useGLTFLightFalloff(value: boolean);
  27198. /**
  27199. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27200. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27201. */
  27202. useRadianceOverAlpha: boolean;
  27203. /**
  27204. * Allows using an object space normal map (instead of tangent space).
  27205. */
  27206. useObjectSpaceNormalMap: boolean;
  27207. /**
  27208. * Allows using the bump map in parallax mode.
  27209. */
  27210. useParallax: boolean;
  27211. /**
  27212. * Allows using the bump map in parallax occlusion mode.
  27213. */
  27214. useParallaxOcclusion: boolean;
  27215. /**
  27216. * Controls the scale bias of the parallax mode.
  27217. */
  27218. parallaxScaleBias: number;
  27219. /**
  27220. * If sets to true, disables all the lights affecting the material.
  27221. */
  27222. disableLighting: boolean;
  27223. /**
  27224. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27225. */
  27226. forceIrradianceInFragment: boolean;
  27227. /**
  27228. * Number of Simultaneous lights allowed on the material.
  27229. */
  27230. maxSimultaneousLights: number;
  27231. /**
  27232. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27233. */
  27234. invertNormalMapX: boolean;
  27235. /**
  27236. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27237. */
  27238. invertNormalMapY: boolean;
  27239. /**
  27240. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27241. */
  27242. twoSidedLighting: boolean;
  27243. /**
  27244. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27245. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27246. */
  27247. useAlphaFresnel: boolean;
  27248. /**
  27249. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27250. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27251. */
  27252. useLinearAlphaFresnel: boolean;
  27253. /**
  27254. * Let user defines the brdf lookup texture used for IBL.
  27255. * A default 8bit version is embedded but you could point at :
  27256. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  27257. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  27258. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  27259. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  27260. */
  27261. environmentBRDFTexture: Nullable<BaseTexture>;
  27262. /**
  27263. * Force normal to face away from face.
  27264. */
  27265. forceNormalForward: boolean;
  27266. /**
  27267. * Enables specular anti aliasing in the PBR shader.
  27268. * It will both interacts on the Geometry for analytical and IBL lighting.
  27269. * It also prefilter the roughness map based on the bump values.
  27270. */
  27271. enableSpecularAntiAliasing: boolean;
  27272. /**
  27273. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27274. * makes the reflect vector face the model (under horizon).
  27275. */
  27276. useHorizonOcclusion: boolean;
  27277. /**
  27278. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27279. * too much the area relying on ambient texture to define their ambient occlusion.
  27280. */
  27281. useRadianceOcclusion: boolean;
  27282. /**
  27283. * If set to true, no lighting calculations will be applied.
  27284. */
  27285. unlit: boolean;
  27286. /**
  27287. * Gets the image processing configuration used either in this material.
  27288. */
  27289. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27290. /**
  27291. * Sets the Default image processing configuration used either in the this material.
  27292. *
  27293. * If sets to null, the scene one is in use.
  27294. */
  27295. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27296. /**
  27297. * Gets wether the color curves effect is enabled.
  27298. */
  27299. get cameraColorCurvesEnabled(): boolean;
  27300. /**
  27301. * Sets wether the color curves effect is enabled.
  27302. */
  27303. set cameraColorCurvesEnabled(value: boolean);
  27304. /**
  27305. * Gets wether the color grading effect is enabled.
  27306. */
  27307. get cameraColorGradingEnabled(): boolean;
  27308. /**
  27309. * Gets wether the color grading effect is enabled.
  27310. */
  27311. set cameraColorGradingEnabled(value: boolean);
  27312. /**
  27313. * Gets wether tonemapping is enabled or not.
  27314. */
  27315. get cameraToneMappingEnabled(): boolean;
  27316. /**
  27317. * Sets wether tonemapping is enabled or not
  27318. */
  27319. set cameraToneMappingEnabled(value: boolean);
  27320. /**
  27321. * The camera exposure used on this material.
  27322. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27323. * This corresponds to a photographic exposure.
  27324. */
  27325. get cameraExposure(): number;
  27326. /**
  27327. * The camera exposure used on this material.
  27328. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27329. * This corresponds to a photographic exposure.
  27330. */
  27331. set cameraExposure(value: number);
  27332. /**
  27333. * Gets The camera contrast used on this material.
  27334. */
  27335. get cameraContrast(): number;
  27336. /**
  27337. * Sets The camera contrast used on this material.
  27338. */
  27339. set cameraContrast(value: number);
  27340. /**
  27341. * Gets the Color Grading 2D Lookup Texture.
  27342. */
  27343. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27344. /**
  27345. * Sets the Color Grading 2D Lookup Texture.
  27346. */
  27347. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27348. /**
  27349. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27350. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27351. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  27352. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27353. */
  27354. get cameraColorCurves(): Nullable<ColorCurves>;
  27355. /**
  27356. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27357. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27358. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  27359. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27360. */
  27361. set cameraColorCurves(value: Nullable<ColorCurves>);
  27362. /**
  27363. * Instantiates a new PBRMaterial instance.
  27364. *
  27365. * @param name The material name
  27366. * @param scene The scene the material will be use in.
  27367. */
  27368. constructor(name: string, scene: Scene);
  27369. /**
  27370. * Returns the name of this material class.
  27371. */
  27372. getClassName(): string;
  27373. /**
  27374. * Makes a duplicate of the current material.
  27375. * @param name - name to use for the new material.
  27376. */
  27377. clone(name: string): PBRMaterial;
  27378. /**
  27379. * Serializes this PBR Material.
  27380. * @returns - An object with the serialized material.
  27381. */
  27382. serialize(): any;
  27383. /**
  27384. * Parses a PBR Material from a serialized object.
  27385. * @param source - Serialized object.
  27386. * @param scene - BJS scene instance.
  27387. * @param rootUrl - url for the scene object
  27388. * @returns - PBRMaterial
  27389. */
  27390. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  27391. }
  27392. }
  27393. declare module BABYLON {
  27394. /** @hidden */
  27395. export var mrtFragmentDeclaration: {
  27396. name: string;
  27397. shader: string;
  27398. };
  27399. }
  27400. declare module BABYLON {
  27401. /** @hidden */
  27402. export var geometryPixelShader: {
  27403. name: string;
  27404. shader: string;
  27405. };
  27406. }
  27407. declare module BABYLON {
  27408. /** @hidden */
  27409. export var geometryVertexShader: {
  27410. name: string;
  27411. shader: string;
  27412. };
  27413. }
  27414. declare module BABYLON {
  27415. /** @hidden */
  27416. interface ISavedTransformationMatrix {
  27417. world: Matrix;
  27418. viewProjection: Matrix;
  27419. }
  27420. /**
  27421. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  27422. */
  27423. export class GeometryBufferRenderer {
  27424. /**
  27425. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  27426. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  27427. */
  27428. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  27429. /**
  27430. * Constant used to retrieve the position texture index in the G-Buffer textures array
  27431. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  27432. */
  27433. static readonly POSITION_TEXTURE_TYPE: number;
  27434. /**
  27435. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  27436. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  27437. */
  27438. static readonly VELOCITY_TEXTURE_TYPE: number;
  27439. /**
  27440. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  27441. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  27442. */
  27443. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  27444. /**
  27445. * Dictionary used to store the previous transformation matrices of each rendered mesh
  27446. * in order to compute objects velocities when enableVelocity is set to "true"
  27447. * @hidden
  27448. */
  27449. _previousTransformationMatrices: {
  27450. [index: number]: ISavedTransformationMatrix;
  27451. };
  27452. /**
  27453. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  27454. * in order to compute objects velocities when enableVelocity is set to "true"
  27455. * @hidden
  27456. */
  27457. _previousBonesTransformationMatrices: {
  27458. [index: number]: Float32Array;
  27459. };
  27460. /**
  27461. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  27462. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  27463. */
  27464. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  27465. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  27466. renderTransparentMeshes: boolean;
  27467. private _scene;
  27468. private _resizeObserver;
  27469. private _multiRenderTarget;
  27470. private _ratio;
  27471. private _enablePosition;
  27472. private _enableVelocity;
  27473. private _enableReflectivity;
  27474. private _positionIndex;
  27475. private _velocityIndex;
  27476. private _reflectivityIndex;
  27477. private _depthNormalIndex;
  27478. private _linkedWithPrePass;
  27479. private _prePassRenderer;
  27480. private _attachments;
  27481. protected _effect: Effect;
  27482. protected _cachedDefines: string;
  27483. /**
  27484. * @hidden
  27485. * Sets up internal structures to share outputs with PrePassRenderer
  27486. * This method should only be called by the PrePassRenderer itself
  27487. */
  27488. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  27489. /**
  27490. * @hidden
  27491. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  27492. * This method should only be called by the PrePassRenderer itself
  27493. */
  27494. _unlinkPrePassRenderer(): void;
  27495. /**
  27496. * @hidden
  27497. * Resets the geometry buffer layout
  27498. */
  27499. _resetLayout(): void;
  27500. /**
  27501. * @hidden
  27502. * Replaces a texture in the geometry buffer renderer
  27503. * Useful when linking textures of the prepass renderer
  27504. */
  27505. _forceTextureType(geometryBufferType: number, index: number): void;
  27506. /**
  27507. * @hidden
  27508. * Sets texture attachments
  27509. * Useful when linking textures of the prepass renderer
  27510. */
  27511. _setAttachments(attachments: number[]): void;
  27512. /**
  27513. * @hidden
  27514. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  27515. * Useful when linking textures of the prepass renderer
  27516. */
  27517. _linkInternalTexture(internalTexture: InternalTexture): void;
  27518. /**
  27519. * Gets the render list (meshes to be rendered) used in the G buffer.
  27520. */
  27521. get renderList(): Nullable<AbstractMesh[]>;
  27522. /**
  27523. * Set the render list (meshes to be rendered) used in the G buffer.
  27524. */
  27525. set renderList(meshes: Nullable<AbstractMesh[]>);
  27526. /**
  27527. * Gets wether or not G buffer are supported by the running hardware.
  27528. * This requires draw buffer supports
  27529. */
  27530. get isSupported(): boolean;
  27531. /**
  27532. * Returns the index of the given texture type in the G-Buffer textures array
  27533. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  27534. * @returns the index of the given texture type in the G-Buffer textures array
  27535. */
  27536. getTextureIndex(textureType: number): number;
  27537. /**
  27538. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  27539. */
  27540. get enablePosition(): boolean;
  27541. /**
  27542. * Sets whether or not objects positions are enabled for the G buffer.
  27543. */
  27544. set enablePosition(enable: boolean);
  27545. /**
  27546. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  27547. */
  27548. get enableVelocity(): boolean;
  27549. /**
  27550. * Sets wether or not objects velocities are enabled for the G buffer.
  27551. */
  27552. set enableVelocity(enable: boolean);
  27553. /**
  27554. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  27555. */
  27556. get enableReflectivity(): boolean;
  27557. /**
  27558. * Sets wether or not objects roughness are enabled for the G buffer.
  27559. */
  27560. set enableReflectivity(enable: boolean);
  27561. /**
  27562. * Gets the scene associated with the buffer.
  27563. */
  27564. get scene(): Scene;
  27565. /**
  27566. * Gets the ratio used by the buffer during its creation.
  27567. * How big is the buffer related to the main canvas.
  27568. */
  27569. get ratio(): number;
  27570. /** @hidden */
  27571. static _SceneComponentInitialization: (scene: Scene) => void;
  27572. /**
  27573. * Creates a new G Buffer for the scene
  27574. * @param scene The scene the buffer belongs to
  27575. * @param ratio How big is the buffer related to the main canvas.
  27576. */
  27577. constructor(scene: Scene, ratio?: number);
  27578. /**
  27579. * Checks wether everything is ready to render a submesh to the G buffer.
  27580. * @param subMesh the submesh to check readiness for
  27581. * @param useInstances is the mesh drawn using instance or not
  27582. * @returns true if ready otherwise false
  27583. */
  27584. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  27585. /**
  27586. * Gets the current underlying G Buffer.
  27587. * @returns the buffer
  27588. */
  27589. getGBuffer(): MultiRenderTarget;
  27590. /**
  27591. * Gets the number of samples used to render the buffer (anti aliasing).
  27592. */
  27593. get samples(): number;
  27594. /**
  27595. * Sets the number of samples used to render the buffer (anti aliasing).
  27596. */
  27597. set samples(value: number);
  27598. /**
  27599. * Disposes the renderer and frees up associated resources.
  27600. */
  27601. dispose(): void;
  27602. private _assignRenderTargetIndices;
  27603. protected _createRenderTargets(): void;
  27604. private _copyBonesTransformationMatrices;
  27605. }
  27606. }
  27607. declare module BABYLON {
  27608. /**
  27609. * Renders a pre pass of the scene
  27610. * This means every mesh in the scene will be rendered to a render target texture
  27611. * And then this texture will be composited to the rendering canvas with post processes
  27612. * It is necessary for effects like subsurface scattering or deferred shading
  27613. */
  27614. export class PrePassRenderer {
  27615. /** @hidden */
  27616. static _SceneComponentInitialization: (scene: Scene) => void;
  27617. private _textureFormats;
  27618. /**
  27619. * To save performance, we can excluded skinned meshes from the prepass
  27620. */
  27621. excludedSkinnedMesh: AbstractMesh[];
  27622. /**
  27623. * Force material to be excluded from the prepass
  27624. * Can be useful when `useGeometryBufferFallback` is set to `true`
  27625. * and you don't want a material to show in the effect.
  27626. */
  27627. excludedMaterials: Material[];
  27628. private _textureIndices;
  27629. private _scene;
  27630. private _engine;
  27631. private _isDirty;
  27632. /**
  27633. * Number of textures in the multi render target texture where the scene is directly rendered
  27634. */
  27635. mrtCount: number;
  27636. /**
  27637. * The render target where the scene is directly rendered
  27638. */
  27639. prePassRT: MultiRenderTarget;
  27640. private _multiRenderAttachments;
  27641. private _defaultAttachments;
  27642. private _clearAttachments;
  27643. private _postProcesses;
  27644. private readonly _clearColor;
  27645. /**
  27646. * Image processing post process for composition
  27647. */
  27648. imageProcessingPostProcess: ImageProcessingPostProcess;
  27649. /**
  27650. * Configuration for prepass effects
  27651. */
  27652. private _effectConfigurations;
  27653. private _mrtFormats;
  27654. private _mrtLayout;
  27655. private _enabled;
  27656. /**
  27657. * Indicates if the prepass is enabled
  27658. */
  27659. get enabled(): boolean;
  27660. /**
  27661. * How many samples are used for MSAA of the scene render target
  27662. */
  27663. get samples(): number;
  27664. set samples(n: number);
  27665. private _geometryBuffer;
  27666. private _useGeometryBufferFallback;
  27667. /**
  27668. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  27669. */
  27670. get useGeometryBufferFallback(): boolean;
  27671. set useGeometryBufferFallback(value: boolean);
  27672. /**
  27673. * Instanciates a prepass renderer
  27674. * @param scene The scene
  27675. */
  27676. constructor(scene: Scene);
  27677. private _initializeAttachments;
  27678. private _createCompositionEffect;
  27679. /**
  27680. * Indicates if rendering a prepass is supported
  27681. */
  27682. get isSupported(): boolean;
  27683. /**
  27684. * Sets the proper output textures to draw in the engine.
  27685. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  27686. * @param subMesh Submesh on which the effect is applied
  27687. */
  27688. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  27689. /**
  27690. * @hidden
  27691. */
  27692. _beforeCameraDraw(): void;
  27693. /**
  27694. * @hidden
  27695. */
  27696. _afterCameraDraw(): void;
  27697. private _checkRTSize;
  27698. private _bindFrameBuffer;
  27699. /**
  27700. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  27701. */
  27702. clear(): void;
  27703. private _setState;
  27704. private _updateGeometryBufferLayout;
  27705. /**
  27706. * Adds an effect configuration to the prepass.
  27707. * If an effect has already been added, it won't add it twice and will return the configuration
  27708. * already present.
  27709. * @param cfg the effect configuration
  27710. * @return the effect configuration now used by the prepass
  27711. */
  27712. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  27713. /**
  27714. * Returns the index of a texture in the multi render target texture array.
  27715. * @param type Texture type
  27716. * @return The index
  27717. */
  27718. getIndex(type: number): number;
  27719. private _enable;
  27720. private _disable;
  27721. private _resetLayout;
  27722. private _resetPostProcessChain;
  27723. private _bindPostProcessChain;
  27724. /**
  27725. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  27726. */
  27727. markAsDirty(): void;
  27728. /**
  27729. * Enables a texture on the MultiRenderTarget for prepass
  27730. */
  27731. private _enableTextures;
  27732. private _update;
  27733. private _markAllMaterialsAsPrePassDirty;
  27734. /**
  27735. * Disposes the prepass renderer.
  27736. */
  27737. dispose(): void;
  27738. }
  27739. }
  27740. declare module BABYLON {
  27741. /**
  27742. * Size options for a post process
  27743. */
  27744. export type PostProcessOptions = {
  27745. width: number;
  27746. height: number;
  27747. };
  27748. /**
  27749. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27750. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27751. */
  27752. export class PostProcess {
  27753. /**
  27754. * Gets or sets the unique id of the post process
  27755. */
  27756. uniqueId: number;
  27757. /** Name of the PostProcess. */
  27758. name: string;
  27759. /**
  27760. * Width of the texture to apply the post process on
  27761. */
  27762. width: number;
  27763. /**
  27764. * Height of the texture to apply the post process on
  27765. */
  27766. height: number;
  27767. /**
  27768. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  27769. */
  27770. nodeMaterialSource: Nullable<NodeMaterial>;
  27771. /**
  27772. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27773. * @hidden
  27774. */
  27775. _outputTexture: Nullable<InternalTexture>;
  27776. /**
  27777. * Sampling mode used by the shader
  27778. * See https://doc.babylonjs.com/classes/3.1/texture
  27779. */
  27780. renderTargetSamplingMode: number;
  27781. /**
  27782. * Clear color to use when screen clearing
  27783. */
  27784. clearColor: Color4;
  27785. /**
  27786. * If the buffer needs to be cleared before applying the post process. (default: true)
  27787. * Should be set to false if shader will overwrite all previous pixels.
  27788. */
  27789. autoClear: boolean;
  27790. /**
  27791. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27792. */
  27793. alphaMode: number;
  27794. /**
  27795. * Sets the setAlphaBlendConstants of the babylon engine
  27796. */
  27797. alphaConstants: Color4;
  27798. /**
  27799. * Animations to be used for the post processing
  27800. */
  27801. animations: Animation[];
  27802. /**
  27803. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27804. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27805. */
  27806. enablePixelPerfectMode: boolean;
  27807. /**
  27808. * Force the postprocess to be applied without taking in account viewport
  27809. */
  27810. forceFullscreenViewport: boolean;
  27811. /**
  27812. * List of inspectable custom properties (used by the Inspector)
  27813. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27814. */
  27815. inspectableCustomProperties: IInspectable[];
  27816. /**
  27817. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27818. *
  27819. * | Value | Type | Description |
  27820. * | ----- | ----------------------------------- | ----------- |
  27821. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27822. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27823. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27824. *
  27825. */
  27826. scaleMode: number;
  27827. /**
  27828. * Force textures to be a power of two (default: false)
  27829. */
  27830. alwaysForcePOT: boolean;
  27831. private _samples;
  27832. /**
  27833. * Number of sample textures (default: 1)
  27834. */
  27835. get samples(): number;
  27836. set samples(n: number);
  27837. /**
  27838. * Modify the scale of the post process to be the same as the viewport (default: false)
  27839. */
  27840. adaptScaleToCurrentViewport: boolean;
  27841. private _camera;
  27842. protected _scene: Scene;
  27843. private _engine;
  27844. private _options;
  27845. private _reusable;
  27846. private _textureType;
  27847. private _textureFormat;
  27848. /**
  27849. * Smart array of input and output textures for the post process.
  27850. * @hidden
  27851. */
  27852. _textures: SmartArray<InternalTexture>;
  27853. /**
  27854. * The index in _textures that corresponds to the output texture.
  27855. * @hidden
  27856. */
  27857. _currentRenderTextureInd: number;
  27858. private _effect;
  27859. private _samplers;
  27860. private _fragmentUrl;
  27861. private _vertexUrl;
  27862. private _parameters;
  27863. private _scaleRatio;
  27864. protected _indexParameters: any;
  27865. private _shareOutputWithPostProcess;
  27866. private _texelSize;
  27867. private _forcedOutputTexture;
  27868. /**
  27869. * Prepass configuration in case this post process needs a texture from prepass
  27870. * @hidden
  27871. */
  27872. _prePassEffectConfiguration: PrePassEffectConfiguration;
  27873. /**
  27874. * Returns the fragment url or shader name used in the post process.
  27875. * @returns the fragment url or name in the shader store.
  27876. */
  27877. getEffectName(): string;
  27878. /**
  27879. * An event triggered when the postprocess is activated.
  27880. */
  27881. onActivateObservable: Observable<Camera>;
  27882. private _onActivateObserver;
  27883. /**
  27884. * A function that is added to the onActivateObservable
  27885. */
  27886. set onActivate(callback: Nullable<(camera: Camera) => void>);
  27887. /**
  27888. * An event triggered when the postprocess changes its size.
  27889. */
  27890. onSizeChangedObservable: Observable<PostProcess>;
  27891. private _onSizeChangedObserver;
  27892. /**
  27893. * A function that is added to the onSizeChangedObservable
  27894. */
  27895. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  27896. /**
  27897. * An event triggered when the postprocess applies its effect.
  27898. */
  27899. onApplyObservable: Observable<Effect>;
  27900. private _onApplyObserver;
  27901. /**
  27902. * A function that is added to the onApplyObservable
  27903. */
  27904. set onApply(callback: (effect: Effect) => void);
  27905. /**
  27906. * An event triggered before rendering the postprocess
  27907. */
  27908. onBeforeRenderObservable: Observable<Effect>;
  27909. private _onBeforeRenderObserver;
  27910. /**
  27911. * A function that is added to the onBeforeRenderObservable
  27912. */
  27913. set onBeforeRender(callback: (effect: Effect) => void);
  27914. /**
  27915. * An event triggered after rendering the postprocess
  27916. */
  27917. onAfterRenderObservable: Observable<Effect>;
  27918. private _onAfterRenderObserver;
  27919. /**
  27920. * A function that is added to the onAfterRenderObservable
  27921. */
  27922. set onAfterRender(callback: (efect: Effect) => void);
  27923. /**
  27924. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  27925. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27926. */
  27927. get inputTexture(): InternalTexture;
  27928. set inputTexture(value: InternalTexture);
  27929. /**
  27930. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  27931. * the only way to unset it is to use this function to restore its internal state
  27932. */
  27933. restoreDefaultInputTexture(): void;
  27934. /**
  27935. * Gets the camera which post process is applied to.
  27936. * @returns The camera the post process is applied to.
  27937. */
  27938. getCamera(): Camera;
  27939. /**
  27940. * Gets the texel size of the postprocess.
  27941. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27942. */
  27943. get texelSize(): Vector2;
  27944. /**
  27945. * Creates a new instance PostProcess
  27946. * @param name The name of the PostProcess.
  27947. * @param fragmentUrl The url of the fragment shader to be used.
  27948. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27949. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27950. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27951. * @param camera The camera to apply the render pass to.
  27952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27953. * @param engine The engine which the post process will be applied. (default: current engine)
  27954. * @param reusable If the post process can be reused on the same frame. (default: false)
  27955. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27956. * @param textureType Type of textures used when performing the post process. (default: 0)
  27957. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27958. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  27959. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  27960. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  27961. */
  27962. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  27963. /**
  27964. * Gets a string identifying the name of the class
  27965. * @returns "PostProcess" string
  27966. */
  27967. getClassName(): string;
  27968. /**
  27969. * Gets the engine which this post process belongs to.
  27970. * @returns The engine the post process was enabled with.
  27971. */
  27972. getEngine(): Engine;
  27973. /**
  27974. * The effect that is created when initializing the post process.
  27975. * @returns The created effect corresponding the the postprocess.
  27976. */
  27977. getEffect(): Effect;
  27978. /**
  27979. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27980. * @param postProcess The post process to share the output with.
  27981. * @returns This post process.
  27982. */
  27983. shareOutputWith(postProcess: PostProcess): PostProcess;
  27984. /**
  27985. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  27986. * This should be called if the post process that shares output with this post process is disabled/disposed.
  27987. */
  27988. useOwnOutput(): void;
  27989. /**
  27990. * Updates the effect with the current post process compile time values and recompiles the shader.
  27991. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27992. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27993. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27994. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  27995. * @param onCompiled Called when the shader has been compiled.
  27996. * @param onError Called if there is an error when compiling a shader.
  27997. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  27998. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  27999. */
  28000. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  28001. /**
  28002. * The post process is reusable if it can be used multiple times within one frame.
  28003. * @returns If the post process is reusable
  28004. */
  28005. isReusable(): boolean;
  28006. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28007. markTextureDirty(): void;
  28008. /**
  28009. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28010. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  28011. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28012. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28013. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28014. * @returns The target texture that was bound to be written to.
  28015. */
  28016. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28017. /**
  28018. * If the post process is supported.
  28019. */
  28020. get isSupported(): boolean;
  28021. /**
  28022. * The aspect ratio of the output texture.
  28023. */
  28024. get aspectRatio(): number;
  28025. /**
  28026. * Get a value indicating if the post-process is ready to be used
  28027. * @returns true if the post-process is ready (shader is compiled)
  28028. */
  28029. isReady(): boolean;
  28030. /**
  28031. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28032. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  28033. */
  28034. apply(): Nullable<Effect>;
  28035. private _disposeTextures;
  28036. /**
  28037. * Sets the required values to the prepass renderer.
  28038. * @param prePassRenderer defines the prepass renderer to setup.
  28039. * @returns true if the pre pass is needed.
  28040. */
  28041. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28042. /**
  28043. * Disposes the post process.
  28044. * @param camera The camera to dispose the post process on.
  28045. */
  28046. dispose(camera?: Camera): void;
  28047. /**
  28048. * Serializes the particle system to a JSON object
  28049. * @returns the JSON object
  28050. */
  28051. serialize(): any;
  28052. /**
  28053. * Creates a material from parsed material data
  28054. * @param parsedPostProcess defines parsed post process data
  28055. * @param scene defines the hosting scene
  28056. * @param rootUrl defines the root URL to use to load textures
  28057. * @returns a new post process
  28058. */
  28059. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  28060. }
  28061. }
  28062. declare module BABYLON {
  28063. /** @hidden */
  28064. export var kernelBlurVaryingDeclaration: {
  28065. name: string;
  28066. shader: string;
  28067. };
  28068. }
  28069. declare module BABYLON {
  28070. /** @hidden */
  28071. export var kernelBlurFragment: {
  28072. name: string;
  28073. shader: string;
  28074. };
  28075. }
  28076. declare module BABYLON {
  28077. /** @hidden */
  28078. export var kernelBlurFragment2: {
  28079. name: string;
  28080. shader: string;
  28081. };
  28082. }
  28083. declare module BABYLON {
  28084. /** @hidden */
  28085. export var kernelBlurPixelShader: {
  28086. name: string;
  28087. shader: string;
  28088. };
  28089. }
  28090. declare module BABYLON {
  28091. /** @hidden */
  28092. export var kernelBlurVertex: {
  28093. name: string;
  28094. shader: string;
  28095. };
  28096. }
  28097. declare module BABYLON {
  28098. /** @hidden */
  28099. export var kernelBlurVertexShader: {
  28100. name: string;
  28101. shader: string;
  28102. };
  28103. }
  28104. declare module BABYLON {
  28105. /**
  28106. * The Blur Post Process which blurs an image based on a kernel and direction.
  28107. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  28108. */
  28109. export class BlurPostProcess extends PostProcess {
  28110. private blockCompilation;
  28111. protected _kernel: number;
  28112. protected _idealKernel: number;
  28113. protected _packedFloat: boolean;
  28114. private _staticDefines;
  28115. /** The direction in which to blur the image. */
  28116. direction: Vector2;
  28117. /**
  28118. * Sets the length in pixels of the blur sample region
  28119. */
  28120. set kernel(v: number);
  28121. /**
  28122. * Gets the length in pixels of the blur sample region
  28123. */
  28124. get kernel(): number;
  28125. /**
  28126. * Sets wether or not the blur needs to unpack/repack floats
  28127. */
  28128. set packedFloat(v: boolean);
  28129. /**
  28130. * Gets wether or not the blur is unpacking/repacking floats
  28131. */
  28132. get packedFloat(): boolean;
  28133. /**
  28134. * Gets a string identifying the name of the class
  28135. * @returns "BlurPostProcess" string
  28136. */
  28137. getClassName(): string;
  28138. /**
  28139. * Creates a new instance BlurPostProcess
  28140. * @param name The name of the effect.
  28141. * @param direction The direction in which to blur the image.
  28142. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  28143. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28144. * @param camera The camera to apply the render pass to.
  28145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28146. * @param engine The engine which the post process will be applied. (default: current engine)
  28147. * @param reusable If the post process can be reused on the same frame. (default: false)
  28148. * @param textureType Type of textures used when performing the post process. (default: 0)
  28149. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  28150. */
  28151. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  28152. /**
  28153. * Updates the effect with the current post process compile time values and recompiles the shader.
  28154. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28155. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28156. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28157. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  28158. * @param onCompiled Called when the shader has been compiled.
  28159. * @param onError Called if there is an error when compiling a shader.
  28160. */
  28161. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28162. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28163. /**
  28164. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  28165. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  28166. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  28167. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  28168. * The gaps between physical kernels are compensated for in the weighting of the samples
  28169. * @param idealKernel Ideal blur kernel.
  28170. * @return Nearest best kernel.
  28171. */
  28172. protected _nearestBestKernel(idealKernel: number): number;
  28173. /**
  28174. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  28175. * @param x The point on the Gaussian distribution to sample.
  28176. * @return the value of the Gaussian function at x.
  28177. */
  28178. protected _gaussianWeight(x: number): number;
  28179. /**
  28180. * Generates a string that can be used as a floating point number in GLSL.
  28181. * @param x Value to print.
  28182. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  28183. * @return GLSL float string.
  28184. */
  28185. protected _glslFloat(x: number, decimalFigures?: number): string;
  28186. /** @hidden */
  28187. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  28188. }
  28189. }
  28190. declare module BABYLON {
  28191. /**
  28192. * Mirror texture can be used to simulate the view from a mirror in a scene.
  28193. * It will dynamically be rendered every frame to adapt to the camera point of view.
  28194. * You can then easily use it as a reflectionTexture on a flat surface.
  28195. * In case the surface is not a plane, please consider relying on reflection probes.
  28196. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28197. */
  28198. export class MirrorTexture extends RenderTargetTexture {
  28199. private scene;
  28200. /**
  28201. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  28202. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  28203. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28204. */
  28205. mirrorPlane: Plane;
  28206. /**
  28207. * Define the blur ratio used to blur the reflection if needed.
  28208. */
  28209. set blurRatio(value: number);
  28210. get blurRatio(): number;
  28211. /**
  28212. * Define the adaptive blur kernel used to blur the reflection if needed.
  28213. * This will autocompute the closest best match for the `blurKernel`
  28214. */
  28215. set adaptiveBlurKernel(value: number);
  28216. /**
  28217. * Define the blur kernel used to blur the reflection if needed.
  28218. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28219. */
  28220. set blurKernel(value: number);
  28221. /**
  28222. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  28223. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28224. */
  28225. set blurKernelX(value: number);
  28226. get blurKernelX(): number;
  28227. /**
  28228. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  28229. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28230. */
  28231. set blurKernelY(value: number);
  28232. get blurKernelY(): number;
  28233. private _autoComputeBlurKernel;
  28234. protected _onRatioRescale(): void;
  28235. private _updateGammaSpace;
  28236. private _imageProcessingConfigChangeObserver;
  28237. private _transformMatrix;
  28238. private _mirrorMatrix;
  28239. private _savedViewMatrix;
  28240. private _blurX;
  28241. private _blurY;
  28242. private _adaptiveBlurKernel;
  28243. private _blurKernelX;
  28244. private _blurKernelY;
  28245. private _blurRatio;
  28246. /**
  28247. * Instantiates a Mirror Texture.
  28248. * Mirror texture can be used to simulate the view from a mirror in a scene.
  28249. * It will dynamically be rendered every frame to adapt to the camera point of view.
  28250. * You can then easily use it as a reflectionTexture on a flat surface.
  28251. * In case the surface is not a plane, please consider relying on reflection probes.
  28252. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28253. * @param name
  28254. * @param size
  28255. * @param scene
  28256. * @param generateMipMaps
  28257. * @param type
  28258. * @param samplingMode
  28259. * @param generateDepthBuffer
  28260. */
  28261. constructor(name: string, size: number | {
  28262. width: number;
  28263. height: number;
  28264. } | {
  28265. ratio: number;
  28266. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  28267. private _preparePostProcesses;
  28268. /**
  28269. * Clone the mirror texture.
  28270. * @returns the cloned texture
  28271. */
  28272. clone(): MirrorTexture;
  28273. /**
  28274. * Serialize the texture to a JSON representation you could use in Parse later on
  28275. * @returns the serialized JSON representation
  28276. */
  28277. serialize(): any;
  28278. /**
  28279. * Dispose the texture and release its associated resources.
  28280. */
  28281. dispose(): void;
  28282. }
  28283. }
  28284. declare module BABYLON {
  28285. /**
  28286. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28287. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28288. */
  28289. export class Texture extends BaseTexture {
  28290. /**
  28291. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  28292. */
  28293. static SerializeBuffers: boolean;
  28294. /** @hidden */
  28295. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  28296. /** @hidden */
  28297. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  28298. /** @hidden */
  28299. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  28300. /** nearest is mag = nearest and min = nearest and mip = linear */
  28301. static readonly NEAREST_SAMPLINGMODE: number;
  28302. /** nearest is mag = nearest and min = nearest and mip = linear */
  28303. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  28304. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28305. static readonly BILINEAR_SAMPLINGMODE: number;
  28306. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28307. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  28308. /** Trilinear is mag = linear and min = linear and mip = linear */
  28309. static readonly TRILINEAR_SAMPLINGMODE: number;
  28310. /** Trilinear is mag = linear and min = linear and mip = linear */
  28311. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  28312. /** mag = nearest and min = nearest and mip = nearest */
  28313. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  28314. /** mag = nearest and min = linear and mip = nearest */
  28315. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  28316. /** mag = nearest and min = linear and mip = linear */
  28317. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  28318. /** mag = nearest and min = linear and mip = none */
  28319. static readonly NEAREST_LINEAR: number;
  28320. /** mag = nearest and min = nearest and mip = none */
  28321. static readonly NEAREST_NEAREST: number;
  28322. /** mag = linear and min = nearest and mip = nearest */
  28323. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  28324. /** mag = linear and min = nearest and mip = linear */
  28325. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  28326. /** mag = linear and min = linear and mip = none */
  28327. static readonly LINEAR_LINEAR: number;
  28328. /** mag = linear and min = nearest and mip = none */
  28329. static readonly LINEAR_NEAREST: number;
  28330. /** Explicit coordinates mode */
  28331. static readonly EXPLICIT_MODE: number;
  28332. /** Spherical coordinates mode */
  28333. static readonly SPHERICAL_MODE: number;
  28334. /** Planar coordinates mode */
  28335. static readonly PLANAR_MODE: number;
  28336. /** Cubic coordinates mode */
  28337. static readonly CUBIC_MODE: number;
  28338. /** Projection coordinates mode */
  28339. static readonly PROJECTION_MODE: number;
  28340. /** Inverse Cubic coordinates mode */
  28341. static readonly SKYBOX_MODE: number;
  28342. /** Inverse Cubic coordinates mode */
  28343. static readonly INVCUBIC_MODE: number;
  28344. /** Equirectangular coordinates mode */
  28345. static readonly EQUIRECTANGULAR_MODE: number;
  28346. /** Equirectangular Fixed coordinates mode */
  28347. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  28348. /** Equirectangular Fixed Mirrored coordinates mode */
  28349. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28350. /** Texture is not repeating outside of 0..1 UVs */
  28351. static readonly CLAMP_ADDRESSMODE: number;
  28352. /** Texture is repeating outside of 0..1 UVs */
  28353. static readonly WRAP_ADDRESSMODE: number;
  28354. /** Texture is repeating and mirrored */
  28355. static readonly MIRROR_ADDRESSMODE: number;
  28356. /**
  28357. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  28358. */
  28359. static UseSerializedUrlIfAny: boolean;
  28360. /**
  28361. * Define the url of the texture.
  28362. */
  28363. url: Nullable<string>;
  28364. /**
  28365. * Define an offset on the texture to offset the u coordinates of the UVs
  28366. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28367. */
  28368. uOffset: number;
  28369. /**
  28370. * Define an offset on the texture to offset the v coordinates of the UVs
  28371. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28372. */
  28373. vOffset: number;
  28374. /**
  28375. * Define an offset on the texture to scale the u coordinates of the UVs
  28376. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28377. */
  28378. uScale: number;
  28379. /**
  28380. * Define an offset on the texture to scale the v coordinates of the UVs
  28381. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28382. */
  28383. vScale: number;
  28384. /**
  28385. * Define an offset on the texture to rotate around the u coordinates of the UVs
  28386. * @see https://doc.babylonjs.com/how_to/more_materials
  28387. */
  28388. uAng: number;
  28389. /**
  28390. * Define an offset on the texture to rotate around the v coordinates of the UVs
  28391. * @see https://doc.babylonjs.com/how_to/more_materials
  28392. */
  28393. vAng: number;
  28394. /**
  28395. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  28396. * @see https://doc.babylonjs.com/how_to/more_materials
  28397. */
  28398. wAng: number;
  28399. /**
  28400. * Defines the center of rotation (U)
  28401. */
  28402. uRotationCenter: number;
  28403. /**
  28404. * Defines the center of rotation (V)
  28405. */
  28406. vRotationCenter: number;
  28407. /**
  28408. * Defines the center of rotation (W)
  28409. */
  28410. wRotationCenter: number;
  28411. /**
  28412. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  28413. */
  28414. homogeneousRotationInUVTransform: boolean;
  28415. /**
  28416. * Are mip maps generated for this texture or not.
  28417. */
  28418. get noMipmap(): boolean;
  28419. /**
  28420. * List of inspectable custom properties (used by the Inspector)
  28421. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28422. */
  28423. inspectableCustomProperties: Nullable<IInspectable[]>;
  28424. private _noMipmap;
  28425. /** @hidden */
  28426. _invertY: boolean;
  28427. private _rowGenerationMatrix;
  28428. private _cachedTextureMatrix;
  28429. private _projectionModeMatrix;
  28430. private _t0;
  28431. private _t1;
  28432. private _t2;
  28433. private _cachedUOffset;
  28434. private _cachedVOffset;
  28435. private _cachedUScale;
  28436. private _cachedVScale;
  28437. private _cachedUAng;
  28438. private _cachedVAng;
  28439. private _cachedWAng;
  28440. private _cachedProjectionMatrixId;
  28441. private _cachedURotationCenter;
  28442. private _cachedVRotationCenter;
  28443. private _cachedWRotationCenter;
  28444. private _cachedHomogeneousRotationInUVTransform;
  28445. private _cachedCoordinatesMode;
  28446. /** @hidden */
  28447. protected _initialSamplingMode: number;
  28448. /** @hidden */
  28449. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  28450. private _deleteBuffer;
  28451. protected _format: Nullable<number>;
  28452. private _delayedOnLoad;
  28453. private _delayedOnError;
  28454. private _mimeType?;
  28455. private _loaderOptions?;
  28456. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  28457. get mimeType(): string | undefined;
  28458. /**
  28459. * Observable triggered once the texture has been loaded.
  28460. */
  28461. onLoadObservable: Observable<Texture>;
  28462. protected _isBlocking: boolean;
  28463. /**
  28464. * Is the texture preventing material to render while loading.
  28465. * If false, a default texture will be used instead of the loading one during the preparation step.
  28466. */
  28467. set isBlocking(value: boolean);
  28468. get isBlocking(): boolean;
  28469. /**
  28470. * Get the current sampling mode associated with the texture.
  28471. */
  28472. get samplingMode(): number;
  28473. /**
  28474. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  28475. */
  28476. get invertY(): boolean;
  28477. /**
  28478. * Instantiates a new texture.
  28479. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28480. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28481. * @param url defines the url of the picture to load as a texture
  28482. * @param sceneOrEngine defines the scene or engine the texture will belong to
  28483. * @param noMipmap defines if the texture will require mip maps or not
  28484. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  28485. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28486. * @param onLoad defines a callback triggered when the texture has been loaded
  28487. * @param onError defines a callback triggered when an error occurred during the loading session
  28488. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  28489. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  28490. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28491. * @param mimeType defines an optional mime type information
  28492. * @param loaderOptions options to be passed to the loader
  28493. */
  28494. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  28495. /**
  28496. * Update the url (and optional buffer) of this texture if url was null during construction.
  28497. * @param url the url of the texture
  28498. * @param buffer the buffer of the texture (defaults to null)
  28499. * @param onLoad callback called when the texture is loaded (defaults to null)
  28500. */
  28501. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  28502. /**
  28503. * Finish the loading sequence of a texture flagged as delayed load.
  28504. * @hidden
  28505. */
  28506. delayLoad(): void;
  28507. private _prepareRowForTextureGeneration;
  28508. /**
  28509. * Checks if the texture has the same transform matrix than another texture
  28510. * @param texture texture to check against
  28511. * @returns true if the transforms are the same, else false
  28512. */
  28513. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  28514. /**
  28515. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  28516. * @returns the transform matrix of the texture.
  28517. */
  28518. getTextureMatrix(uBase?: number): Matrix;
  28519. /**
  28520. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  28521. * @returns The reflection texture transform
  28522. */
  28523. getReflectionTextureMatrix(): Matrix;
  28524. /**
  28525. * Clones the texture.
  28526. * @returns the cloned texture
  28527. */
  28528. clone(): Texture;
  28529. /**
  28530. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28531. * @returns The JSON representation of the texture
  28532. */
  28533. serialize(): any;
  28534. /**
  28535. * Get the current class name of the texture useful for serialization or dynamic coding.
  28536. * @returns "Texture"
  28537. */
  28538. getClassName(): string;
  28539. /**
  28540. * Dispose the texture and release its associated resources.
  28541. */
  28542. dispose(): void;
  28543. /**
  28544. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  28545. * @param parsedTexture Define the JSON representation of the texture
  28546. * @param scene Define the scene the parsed texture should be instantiated in
  28547. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  28548. * @returns The parsed texture if successful
  28549. */
  28550. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  28551. /**
  28552. * Creates a texture from its base 64 representation.
  28553. * @param data Define the base64 payload without the data: prefix
  28554. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28555. * @param scene Define the scene the texture should belong to
  28556. * @param noMipmap Forces the texture to not create mip map information if true
  28557. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28558. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28559. * @param onLoad define a callback triggered when the texture has been loaded
  28560. * @param onError define a callback triggered when an error occurred during the loading session
  28561. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28562. * @returns the created texture
  28563. */
  28564. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  28565. /**
  28566. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  28567. * @param data Define the base64 payload without the data: prefix
  28568. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28569. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  28570. * @param scene Define the scene the texture should belong to
  28571. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  28572. * @param noMipmap Forces the texture to not create mip map information if true
  28573. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28574. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28575. * @param onLoad define a callback triggered when the texture has been loaded
  28576. * @param onError define a callback triggered when an error occurred during the loading session
  28577. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28578. * @returns the created texture
  28579. */
  28580. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  28581. }
  28582. }
  28583. declare module BABYLON {
  28584. /**
  28585. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28586. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28587. */
  28588. export class PostProcessManager {
  28589. private _scene;
  28590. private _indexBuffer;
  28591. private _vertexBuffers;
  28592. /**
  28593. * Creates a new instance PostProcess
  28594. * @param scene The scene that the post process is associated with.
  28595. */
  28596. constructor(scene: Scene);
  28597. private _prepareBuffers;
  28598. private _buildIndexBuffer;
  28599. /**
  28600. * Rebuilds the vertex buffers of the manager.
  28601. * @hidden
  28602. */
  28603. _rebuild(): void;
  28604. /**
  28605. * Prepares a frame to be run through a post process.
  28606. * @param sourceTexture The input texture to the post procesess. (default: null)
  28607. * @param postProcesses An array of post processes to be run. (default: null)
  28608. * @returns True if the post processes were able to be run.
  28609. * @hidden
  28610. */
  28611. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28612. /**
  28613. * Manually render a set of post processes to a texture.
  28614. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  28615. * @param postProcesses An array of post processes to be run.
  28616. * @param targetTexture The target texture to render to.
  28617. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28618. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28619. * @param lodLevel defines which lod of the texture to render to
  28620. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  28621. */
  28622. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  28623. /**
  28624. * Finalize the result of the output of the postprocesses.
  28625. * @param doNotPresent If true the result will not be displayed to the screen.
  28626. * @param targetTexture The target texture to render to.
  28627. * @param faceIndex The index of the face to bind the target texture to.
  28628. * @param postProcesses The array of post processes to render.
  28629. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28630. * @hidden
  28631. */
  28632. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28633. /**
  28634. * Disposes of the post process manager.
  28635. */
  28636. dispose(): void;
  28637. }
  28638. }
  28639. declare module BABYLON {
  28640. /**
  28641. * This Helps creating a texture that will be created from a camera in your scene.
  28642. * It is basically a dynamic texture that could be used to create special effects for instance.
  28643. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  28644. */
  28645. export class RenderTargetTexture extends Texture {
  28646. /**
  28647. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  28648. */
  28649. static readonly REFRESHRATE_RENDER_ONCE: number;
  28650. /**
  28651. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  28652. */
  28653. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  28654. /**
  28655. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  28656. * the central point of your effect and can save a lot of performances.
  28657. */
  28658. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  28659. /**
  28660. * Use this predicate to dynamically define the list of mesh you want to render.
  28661. * If set, the renderList property will be overwritten.
  28662. */
  28663. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  28664. private _renderList;
  28665. /**
  28666. * Use this list to define the list of mesh you want to render.
  28667. */
  28668. get renderList(): Nullable<Array<AbstractMesh>>;
  28669. set renderList(value: Nullable<Array<AbstractMesh>>);
  28670. /**
  28671. * Use this function to overload the renderList array at rendering time.
  28672. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  28673. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  28674. * the cube (if the RTT is a cube, else layerOrFace=0).
  28675. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  28676. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  28677. * hold dummy elements!
  28678. */
  28679. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  28680. private _hookArray;
  28681. /**
  28682. * Define if particles should be rendered in your texture.
  28683. */
  28684. renderParticles: boolean;
  28685. /**
  28686. * Define if sprites should be rendered in your texture.
  28687. */
  28688. renderSprites: boolean;
  28689. /**
  28690. * Define the camera used to render the texture.
  28691. */
  28692. activeCamera: Nullable<Camera>;
  28693. /**
  28694. * Override the mesh isReady function with your own one.
  28695. */
  28696. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  28697. /**
  28698. * Override the render function of the texture with your own one.
  28699. */
  28700. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  28701. /**
  28702. * Define if camera post processes should be use while rendering the texture.
  28703. */
  28704. useCameraPostProcesses: boolean;
  28705. /**
  28706. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  28707. */
  28708. ignoreCameraViewport: boolean;
  28709. private _postProcessManager;
  28710. private _postProcesses;
  28711. private _resizeObserver;
  28712. /**
  28713. * An event triggered when the texture is unbind.
  28714. */
  28715. onBeforeBindObservable: Observable<RenderTargetTexture>;
  28716. /**
  28717. * An event triggered when the texture is unbind.
  28718. */
  28719. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  28720. private _onAfterUnbindObserver;
  28721. /**
  28722. * Set a after unbind callback in the texture.
  28723. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  28724. */
  28725. set onAfterUnbind(callback: () => void);
  28726. /**
  28727. * An event triggered before rendering the texture
  28728. */
  28729. onBeforeRenderObservable: Observable<number>;
  28730. private _onBeforeRenderObserver;
  28731. /**
  28732. * Set a before render callback in the texture.
  28733. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  28734. */
  28735. set onBeforeRender(callback: (faceIndex: number) => void);
  28736. /**
  28737. * An event triggered after rendering the texture
  28738. */
  28739. onAfterRenderObservable: Observable<number>;
  28740. private _onAfterRenderObserver;
  28741. /**
  28742. * Set a after render callback in the texture.
  28743. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  28744. */
  28745. set onAfterRender(callback: (faceIndex: number) => void);
  28746. /**
  28747. * An event triggered after the texture clear
  28748. */
  28749. onClearObservable: Observable<Engine>;
  28750. private _onClearObserver;
  28751. /**
  28752. * Set a clear callback in the texture.
  28753. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  28754. */
  28755. set onClear(callback: (Engine: Engine) => void);
  28756. /**
  28757. * An event triggered when the texture is resized.
  28758. */
  28759. onResizeObservable: Observable<RenderTargetTexture>;
  28760. /**
  28761. * Define the clear color of the Render Target if it should be different from the scene.
  28762. */
  28763. clearColor: Color4;
  28764. protected _size: number | {
  28765. width: number;
  28766. height: number;
  28767. layers?: number;
  28768. };
  28769. protected _initialSizeParameter: number | {
  28770. width: number;
  28771. height: number;
  28772. } | {
  28773. ratio: number;
  28774. };
  28775. protected _sizeRatio: Nullable<number>;
  28776. /** @hidden */
  28777. _generateMipMaps: boolean;
  28778. protected _renderingManager: RenderingManager;
  28779. /** @hidden */
  28780. _waitingRenderList?: string[];
  28781. protected _doNotChangeAspectRatio: boolean;
  28782. protected _currentRefreshId: number;
  28783. protected _refreshRate: number;
  28784. protected _textureMatrix: Matrix;
  28785. protected _samples: number;
  28786. protected _renderTargetOptions: RenderTargetCreationOptions;
  28787. /**
  28788. * Gets render target creation options that were used.
  28789. */
  28790. get renderTargetOptions(): RenderTargetCreationOptions;
  28791. protected _onRatioRescale(): void;
  28792. /**
  28793. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  28794. * It must define where the camera used to render the texture is set
  28795. */
  28796. boundingBoxPosition: Vector3;
  28797. private _boundingBoxSize;
  28798. /**
  28799. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  28800. * When defined, the cubemap will switch to local mode
  28801. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  28802. * @example https://www.babylonjs-playground.com/#RNASML
  28803. */
  28804. set boundingBoxSize(value: Vector3);
  28805. get boundingBoxSize(): Vector3;
  28806. /**
  28807. * In case the RTT has been created with a depth texture, get the associated
  28808. * depth texture.
  28809. * Otherwise, return null.
  28810. */
  28811. get depthStencilTexture(): Nullable<InternalTexture>;
  28812. /**
  28813. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  28814. * or used a shadow, depth texture...
  28815. * @param name The friendly name of the texture
  28816. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  28817. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  28818. * @param generateMipMaps True if mip maps need to be generated after render.
  28819. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  28820. * @param type The type of the buffer in the RTT (int, half float, float...)
  28821. * @param isCube True if a cube texture needs to be created
  28822. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  28823. * @param generateDepthBuffer True to generate a depth buffer
  28824. * @param generateStencilBuffer True to generate a stencil buffer
  28825. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  28826. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  28827. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28828. */
  28829. constructor(name: string, size: number | {
  28830. width: number;
  28831. height: number;
  28832. layers?: number;
  28833. } | {
  28834. ratio: number;
  28835. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  28836. /**
  28837. * Creates a depth stencil texture.
  28838. * This is only available in WebGL 2 or with the depth texture extension available.
  28839. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  28840. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  28841. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  28842. */
  28843. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  28844. private _processSizeParameter;
  28845. /**
  28846. * Define the number of samples to use in case of MSAA.
  28847. * It defaults to one meaning no MSAA has been enabled.
  28848. */
  28849. get samples(): number;
  28850. set samples(value: number);
  28851. /**
  28852. * Resets the refresh counter of the texture and start bak from scratch.
  28853. * Could be useful to regenerate the texture if it is setup to render only once.
  28854. */
  28855. resetRefreshCounter(): void;
  28856. /**
  28857. * Define the refresh rate of the texture or the rendering frequency.
  28858. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  28859. */
  28860. get refreshRate(): number;
  28861. set refreshRate(value: number);
  28862. /**
  28863. * Adds a post process to the render target rendering passes.
  28864. * @param postProcess define the post process to add
  28865. */
  28866. addPostProcess(postProcess: PostProcess): void;
  28867. /**
  28868. * Clear all the post processes attached to the render target
  28869. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  28870. */
  28871. clearPostProcesses(dispose?: boolean): void;
  28872. /**
  28873. * Remove one of the post process from the list of attached post processes to the texture
  28874. * @param postProcess define the post process to remove from the list
  28875. */
  28876. removePostProcess(postProcess: PostProcess): void;
  28877. /** @hidden */
  28878. _shouldRender(): boolean;
  28879. /**
  28880. * Gets the actual render size of the texture.
  28881. * @returns the width of the render size
  28882. */
  28883. getRenderSize(): number;
  28884. /**
  28885. * Gets the actual render width of the texture.
  28886. * @returns the width of the render size
  28887. */
  28888. getRenderWidth(): number;
  28889. /**
  28890. * Gets the actual render height of the texture.
  28891. * @returns the height of the render size
  28892. */
  28893. getRenderHeight(): number;
  28894. /**
  28895. * Gets the actual number of layers of the texture.
  28896. * @returns the number of layers
  28897. */
  28898. getRenderLayers(): number;
  28899. /**
  28900. * Get if the texture can be rescaled or not.
  28901. */
  28902. get canRescale(): boolean;
  28903. /**
  28904. * Resize the texture using a ratio.
  28905. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  28906. */
  28907. scale(ratio: number): void;
  28908. /**
  28909. * Get the texture reflection matrix used to rotate/transform the reflection.
  28910. * @returns the reflection matrix
  28911. */
  28912. getReflectionTextureMatrix(): Matrix;
  28913. /**
  28914. * Resize the texture to a new desired size.
  28915. * Be carrefull as it will recreate all the data in the new texture.
  28916. * @param size Define the new size. It can be:
  28917. * - a number for squared texture,
  28918. * - an object containing { width: number, height: number }
  28919. * - or an object containing a ratio { ratio: number }
  28920. */
  28921. resize(size: number | {
  28922. width: number;
  28923. height: number;
  28924. } | {
  28925. ratio: number;
  28926. }): void;
  28927. private _defaultRenderListPrepared;
  28928. /**
  28929. * Renders all the objects from the render list into the texture.
  28930. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  28931. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  28932. */
  28933. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  28934. private _bestReflectionRenderTargetDimension;
  28935. private _prepareRenderingManager;
  28936. /**
  28937. * @hidden
  28938. * @param faceIndex face index to bind to if this is a cubetexture
  28939. * @param layer defines the index of the texture to bind in the array
  28940. */
  28941. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  28942. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  28943. private renderToTarget;
  28944. /**
  28945. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28946. * This allowed control for front to back rendering or reversly depending of the special needs.
  28947. *
  28948. * @param renderingGroupId The rendering group id corresponding to its index
  28949. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28950. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28951. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28952. */
  28953. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  28954. /**
  28955. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28956. *
  28957. * @param renderingGroupId The rendering group id corresponding to its index
  28958. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28959. */
  28960. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28961. /**
  28962. * Clones the texture.
  28963. * @returns the cloned texture
  28964. */
  28965. clone(): RenderTargetTexture;
  28966. /**
  28967. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28968. * @returns The JSON representation of the texture
  28969. */
  28970. serialize(): any;
  28971. /**
  28972. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  28973. */
  28974. disposeFramebufferObjects(): void;
  28975. /**
  28976. * Dispose the texture and release its associated resources.
  28977. */
  28978. dispose(): void;
  28979. /** @hidden */
  28980. _rebuild(): void;
  28981. /**
  28982. * Clear the info related to rendering groups preventing retention point in material dispose.
  28983. */
  28984. freeRenderingGroups(): void;
  28985. /**
  28986. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  28987. * @returns the view count
  28988. */
  28989. getViewCount(): number;
  28990. }
  28991. }
  28992. declare module BABYLON {
  28993. /**
  28994. * Class used to manipulate GUIDs
  28995. */
  28996. export class GUID {
  28997. /**
  28998. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28999. * Be aware Math.random() could cause collisions, but:
  29000. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  29001. * @returns a pseudo random id
  29002. */
  29003. static RandomId(): string;
  29004. }
  29005. }
  29006. declare module BABYLON {
  29007. /**
  29008. * Options to be used when creating a shadow depth material
  29009. */
  29010. export interface IIOptionShadowDepthMaterial {
  29011. /** Variables in the vertex shader code that need to have their names remapped.
  29012. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29013. * "var_name" should be either: worldPos or vNormalW
  29014. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29015. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29016. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29017. */
  29018. remappedVariables?: string[];
  29019. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29020. standalone?: boolean;
  29021. }
  29022. /**
  29023. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29024. */
  29025. export class ShadowDepthWrapper {
  29026. private _scene;
  29027. private _options?;
  29028. private _baseMaterial;
  29029. private _onEffectCreatedObserver;
  29030. private _subMeshToEffect;
  29031. private _subMeshToDepthEffect;
  29032. private _meshes;
  29033. /** @hidden */
  29034. _matriceNames: any;
  29035. /** Gets the standalone status of the wrapper */
  29036. get standalone(): boolean;
  29037. /** Gets the base material the wrapper is built upon */
  29038. get baseMaterial(): Material;
  29039. /**
  29040. * Instantiate a new shadow depth wrapper.
  29041. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29042. * generate the shadow depth map. For more information, please refer to the documentation:
  29043. * https://doc.babylonjs.com/babylon101/shadows
  29044. * @param baseMaterial Material to wrap
  29045. * @param scene Define the scene the material belongs to
  29046. * @param options Options used to create the wrapper
  29047. */
  29048. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29049. /**
  29050. * Gets the effect to use to generate the depth map
  29051. * @param subMesh subMesh to get the effect for
  29052. * @param shadowGenerator shadow generator to get the effect for
  29053. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29054. */
  29055. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29056. /**
  29057. * Specifies that the submesh is ready to be used for depth rendering
  29058. * @param subMesh submesh to check
  29059. * @param defines the list of defines to take into account when checking the effect
  29060. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29061. * @param useInstances specifies that instances should be used
  29062. * @returns a boolean indicating that the submesh is ready or not
  29063. */
  29064. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29065. /**
  29066. * Disposes the resources
  29067. */
  29068. dispose(): void;
  29069. private _makeEffect;
  29070. }
  29071. }
  29072. declare module BABYLON {
  29073. /**
  29074. * Options for compiling materials.
  29075. */
  29076. export interface IMaterialCompilationOptions {
  29077. /**
  29078. * Defines whether clip planes are enabled.
  29079. */
  29080. clipPlane: boolean;
  29081. /**
  29082. * Defines whether instances are enabled.
  29083. */
  29084. useInstances: boolean;
  29085. }
  29086. /**
  29087. * Options passed when calling customShaderNameResolve
  29088. */
  29089. export interface ICustomShaderNameResolveOptions {
  29090. /**
  29091. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  29092. */
  29093. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29094. }
  29095. /**
  29096. * Base class for the main features of a material in Babylon.js
  29097. */
  29098. export class Material implements IAnimatable {
  29099. /**
  29100. * Returns the triangle fill mode
  29101. */
  29102. static readonly TriangleFillMode: number;
  29103. /**
  29104. * Returns the wireframe mode
  29105. */
  29106. static readonly WireFrameFillMode: number;
  29107. /**
  29108. * Returns the point fill mode
  29109. */
  29110. static readonly PointFillMode: number;
  29111. /**
  29112. * Returns the point list draw mode
  29113. */
  29114. static readonly PointListDrawMode: number;
  29115. /**
  29116. * Returns the line list draw mode
  29117. */
  29118. static readonly LineListDrawMode: number;
  29119. /**
  29120. * Returns the line loop draw mode
  29121. */
  29122. static readonly LineLoopDrawMode: number;
  29123. /**
  29124. * Returns the line strip draw mode
  29125. */
  29126. static readonly LineStripDrawMode: number;
  29127. /**
  29128. * Returns the triangle strip draw mode
  29129. */
  29130. static readonly TriangleStripDrawMode: number;
  29131. /**
  29132. * Returns the triangle fan draw mode
  29133. */
  29134. static readonly TriangleFanDrawMode: number;
  29135. /**
  29136. * Stores the clock-wise side orientation
  29137. */
  29138. static readonly ClockWiseSideOrientation: number;
  29139. /**
  29140. * Stores the counter clock-wise side orientation
  29141. */
  29142. static readonly CounterClockWiseSideOrientation: number;
  29143. /**
  29144. * The dirty texture flag value
  29145. */
  29146. static readonly TextureDirtyFlag: number;
  29147. /**
  29148. * The dirty light flag value
  29149. */
  29150. static readonly LightDirtyFlag: number;
  29151. /**
  29152. * The dirty fresnel flag value
  29153. */
  29154. static readonly FresnelDirtyFlag: number;
  29155. /**
  29156. * The dirty attribute flag value
  29157. */
  29158. static readonly AttributesDirtyFlag: number;
  29159. /**
  29160. * The dirty misc flag value
  29161. */
  29162. static readonly MiscDirtyFlag: number;
  29163. /**
  29164. * The dirty prepass flag value
  29165. */
  29166. static readonly PrePassDirtyFlag: number;
  29167. /**
  29168. * The all dirty flag value
  29169. */
  29170. static readonly AllDirtyFlag: number;
  29171. /**
  29172. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29173. */
  29174. static readonly MATERIAL_OPAQUE: number;
  29175. /**
  29176. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29177. */
  29178. static readonly MATERIAL_ALPHATEST: number;
  29179. /**
  29180. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29181. */
  29182. static readonly MATERIAL_ALPHABLEND: number;
  29183. /**
  29184. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29185. * They are also discarded below the alpha cutoff threshold to improve performances.
  29186. */
  29187. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29188. /**
  29189. * The Whiteout method is used to blend normals.
  29190. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29191. */
  29192. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29193. /**
  29194. * The Reoriented Normal Mapping method is used to blend normals.
  29195. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29196. */
  29197. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29198. /**
  29199. * Custom callback helping to override the default shader used in the material.
  29200. */
  29201. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29202. /**
  29203. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29204. */
  29205. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29206. /**
  29207. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29208. * This means that the material can keep using a previous shader while a new one is being compiled.
  29209. * This is mostly used when shader parallel compilation is supported (true by default)
  29210. */
  29211. allowShaderHotSwapping: boolean;
  29212. /**
  29213. * The ID of the material
  29214. */
  29215. id: string;
  29216. /**
  29217. * Gets or sets the unique id of the material
  29218. */
  29219. uniqueId: number;
  29220. /**
  29221. * The name of the material
  29222. */
  29223. name: string;
  29224. /**
  29225. * Gets or sets user defined metadata
  29226. */
  29227. metadata: any;
  29228. /**
  29229. * For internal use only. Please do not use.
  29230. */
  29231. reservedDataStore: any;
  29232. /**
  29233. * Specifies if the ready state should be checked on each call
  29234. */
  29235. checkReadyOnEveryCall: boolean;
  29236. /**
  29237. * Specifies if the ready state should be checked once
  29238. */
  29239. checkReadyOnlyOnce: boolean;
  29240. /**
  29241. * The state of the material
  29242. */
  29243. state: string;
  29244. /**
  29245. * If the material can be rendered to several textures with MRT extension
  29246. */
  29247. get canRenderToMRT(): boolean;
  29248. /**
  29249. * The alpha value of the material
  29250. */
  29251. protected _alpha: number;
  29252. /**
  29253. * List of inspectable custom properties (used by the Inspector)
  29254. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29255. */
  29256. inspectableCustomProperties: IInspectable[];
  29257. /**
  29258. * Sets the alpha value of the material
  29259. */
  29260. set alpha(value: number);
  29261. /**
  29262. * Gets the alpha value of the material
  29263. */
  29264. get alpha(): number;
  29265. /**
  29266. * Specifies if back face culling is enabled
  29267. */
  29268. protected _backFaceCulling: boolean;
  29269. /**
  29270. * Sets the back-face culling state
  29271. */
  29272. set backFaceCulling(value: boolean);
  29273. /**
  29274. * Gets the back-face culling state
  29275. */
  29276. get backFaceCulling(): boolean;
  29277. /**
  29278. * Stores the value for side orientation
  29279. */
  29280. sideOrientation: number;
  29281. /**
  29282. * Callback triggered when the material is compiled
  29283. */
  29284. onCompiled: Nullable<(effect: Effect) => void>;
  29285. /**
  29286. * Callback triggered when an error occurs
  29287. */
  29288. onError: Nullable<(effect: Effect, errors: string) => void>;
  29289. /**
  29290. * Callback triggered to get the render target textures
  29291. */
  29292. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29293. /**
  29294. * Gets a boolean indicating that current material needs to register RTT
  29295. */
  29296. get hasRenderTargetTextures(): boolean;
  29297. /**
  29298. * Specifies if the material should be serialized
  29299. */
  29300. doNotSerialize: boolean;
  29301. /**
  29302. * @hidden
  29303. */
  29304. _storeEffectOnSubMeshes: boolean;
  29305. /**
  29306. * Stores the animations for the material
  29307. */
  29308. animations: Nullable<Array<Animation>>;
  29309. /**
  29310. * An event triggered when the material is disposed
  29311. */
  29312. onDisposeObservable: Observable<Material>;
  29313. /**
  29314. * An observer which watches for dispose events
  29315. */
  29316. private _onDisposeObserver;
  29317. private _onUnBindObservable;
  29318. /**
  29319. * Called during a dispose event
  29320. */
  29321. set onDispose(callback: () => void);
  29322. private _onBindObservable;
  29323. /**
  29324. * An event triggered when the material is bound
  29325. */
  29326. get onBindObservable(): Observable<AbstractMesh>;
  29327. /**
  29328. * An observer which watches for bind events
  29329. */
  29330. private _onBindObserver;
  29331. /**
  29332. * Called during a bind event
  29333. */
  29334. set onBind(callback: (Mesh: AbstractMesh) => void);
  29335. /**
  29336. * An event triggered when the material is unbound
  29337. */
  29338. get onUnBindObservable(): Observable<Material>;
  29339. protected _onEffectCreatedObservable: Nullable<Observable<{
  29340. effect: Effect;
  29341. subMesh: Nullable<SubMesh>;
  29342. }>>;
  29343. /**
  29344. * An event triggered when the effect is (re)created
  29345. */
  29346. get onEffectCreatedObservable(): Observable<{
  29347. effect: Effect;
  29348. subMesh: Nullable<SubMesh>;
  29349. }>;
  29350. /**
  29351. * Stores the value of the alpha mode
  29352. */
  29353. private _alphaMode;
  29354. /**
  29355. * Sets the value of the alpha mode.
  29356. *
  29357. * | Value | Type | Description |
  29358. * | --- | --- | --- |
  29359. * | 0 | ALPHA_DISABLE | |
  29360. * | 1 | ALPHA_ADD | |
  29361. * | 2 | ALPHA_COMBINE | |
  29362. * | 3 | ALPHA_SUBTRACT | |
  29363. * | 4 | ALPHA_MULTIPLY | |
  29364. * | 5 | ALPHA_MAXIMIZED | |
  29365. * | 6 | ALPHA_ONEONE | |
  29366. * | 7 | ALPHA_PREMULTIPLIED | |
  29367. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29368. * | 9 | ALPHA_INTERPOLATE | |
  29369. * | 10 | ALPHA_SCREENMODE | |
  29370. *
  29371. */
  29372. set alphaMode(value: number);
  29373. /**
  29374. * Gets the value of the alpha mode
  29375. */
  29376. get alphaMode(): number;
  29377. /**
  29378. * Stores the state of the need depth pre-pass value
  29379. */
  29380. private _needDepthPrePass;
  29381. /**
  29382. * Sets the need depth pre-pass value
  29383. */
  29384. set needDepthPrePass(value: boolean);
  29385. /**
  29386. * Gets the depth pre-pass value
  29387. */
  29388. get needDepthPrePass(): boolean;
  29389. /**
  29390. * Specifies if depth writing should be disabled
  29391. */
  29392. disableDepthWrite: boolean;
  29393. /**
  29394. * Specifies if color writing should be disabled
  29395. */
  29396. disableColorWrite: boolean;
  29397. /**
  29398. * Specifies if depth writing should be forced
  29399. */
  29400. forceDepthWrite: boolean;
  29401. /**
  29402. * Specifies the depth function that should be used. 0 means the default engine function
  29403. */
  29404. depthFunction: number;
  29405. /**
  29406. * Specifies if there should be a separate pass for culling
  29407. */
  29408. separateCullingPass: boolean;
  29409. /**
  29410. * Stores the state specifing if fog should be enabled
  29411. */
  29412. private _fogEnabled;
  29413. /**
  29414. * Sets the state for enabling fog
  29415. */
  29416. set fogEnabled(value: boolean);
  29417. /**
  29418. * Gets the value of the fog enabled state
  29419. */
  29420. get fogEnabled(): boolean;
  29421. /**
  29422. * Stores the size of points
  29423. */
  29424. pointSize: number;
  29425. /**
  29426. * Stores the z offset value
  29427. */
  29428. zOffset: number;
  29429. get wireframe(): boolean;
  29430. /**
  29431. * Sets the state of wireframe mode
  29432. */
  29433. set wireframe(value: boolean);
  29434. /**
  29435. * Gets the value specifying if point clouds are enabled
  29436. */
  29437. get pointsCloud(): boolean;
  29438. /**
  29439. * Sets the state of point cloud mode
  29440. */
  29441. set pointsCloud(value: boolean);
  29442. /**
  29443. * Gets the material fill mode
  29444. */
  29445. get fillMode(): number;
  29446. /**
  29447. * Sets the material fill mode
  29448. */
  29449. set fillMode(value: number);
  29450. /**
  29451. * @hidden
  29452. * Stores the effects for the material
  29453. */
  29454. _effect: Nullable<Effect>;
  29455. /**
  29456. * Specifies if uniform buffers should be used
  29457. */
  29458. private _useUBO;
  29459. /**
  29460. * Stores a reference to the scene
  29461. */
  29462. private _scene;
  29463. /**
  29464. * Stores the fill mode state
  29465. */
  29466. private _fillMode;
  29467. /**
  29468. * Specifies if the depth write state should be cached
  29469. */
  29470. private _cachedDepthWriteState;
  29471. /**
  29472. * Specifies if the color write state should be cached
  29473. */
  29474. private _cachedColorWriteState;
  29475. /**
  29476. * Specifies if the depth function state should be cached
  29477. */
  29478. private _cachedDepthFunctionState;
  29479. /**
  29480. * Stores the uniform buffer
  29481. */
  29482. protected _uniformBuffer: UniformBuffer;
  29483. /** @hidden */
  29484. _indexInSceneMaterialArray: number;
  29485. /** @hidden */
  29486. meshMap: Nullable<{
  29487. [id: string]: AbstractMesh | undefined;
  29488. }>;
  29489. /**
  29490. * Creates a material instance
  29491. * @param name defines the name of the material
  29492. * @param scene defines the scene to reference
  29493. * @param doNotAdd specifies if the material should be added to the scene
  29494. */
  29495. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29496. /**
  29497. * Returns a string representation of the current material
  29498. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29499. * @returns a string with material information
  29500. */
  29501. toString(fullDetails?: boolean): string;
  29502. /**
  29503. * Gets the class name of the material
  29504. * @returns a string with the class name of the material
  29505. */
  29506. getClassName(): string;
  29507. /**
  29508. * Specifies if updates for the material been locked
  29509. */
  29510. get isFrozen(): boolean;
  29511. /**
  29512. * Locks updates for the material
  29513. */
  29514. freeze(): void;
  29515. /**
  29516. * Unlocks updates for the material
  29517. */
  29518. unfreeze(): void;
  29519. /**
  29520. * Specifies if the material is ready to be used
  29521. * @param mesh defines the mesh to check
  29522. * @param useInstances specifies if instances should be used
  29523. * @returns a boolean indicating if the material is ready to be used
  29524. */
  29525. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29526. /**
  29527. * Specifies that the submesh is ready to be used
  29528. * @param mesh defines the mesh to check
  29529. * @param subMesh defines which submesh to check
  29530. * @param useInstances specifies that instances should be used
  29531. * @returns a boolean indicating that the submesh is ready or not
  29532. */
  29533. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29534. /**
  29535. * Returns the material effect
  29536. * @returns the effect associated with the material
  29537. */
  29538. getEffect(): Nullable<Effect>;
  29539. /**
  29540. * Returns the current scene
  29541. * @returns a Scene
  29542. */
  29543. getScene(): Scene;
  29544. /**
  29545. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29546. */
  29547. protected _forceAlphaTest: boolean;
  29548. /**
  29549. * The transparency mode of the material.
  29550. */
  29551. protected _transparencyMode: Nullable<number>;
  29552. /**
  29553. * Gets the current transparency mode.
  29554. */
  29555. get transparencyMode(): Nullable<number>;
  29556. /**
  29557. * Sets the transparency mode of the material.
  29558. *
  29559. * | Value | Type | Description |
  29560. * | ----- | ----------------------------------- | ----------- |
  29561. * | 0 | OPAQUE | |
  29562. * | 1 | ALPHATEST | |
  29563. * | 2 | ALPHABLEND | |
  29564. * | 3 | ALPHATESTANDBLEND | |
  29565. *
  29566. */
  29567. set transparencyMode(value: Nullable<number>);
  29568. /**
  29569. * Returns true if alpha blending should be disabled.
  29570. */
  29571. protected get _disableAlphaBlending(): boolean;
  29572. /**
  29573. * Specifies whether or not this material should be rendered in alpha blend mode.
  29574. * @returns a boolean specifying if alpha blending is needed
  29575. */
  29576. needAlphaBlending(): boolean;
  29577. /**
  29578. * Specifies if the mesh will require alpha blending
  29579. * @param mesh defines the mesh to check
  29580. * @returns a boolean specifying if alpha blending is needed for the mesh
  29581. */
  29582. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29583. /**
  29584. * Specifies whether or not this material should be rendered in alpha test mode.
  29585. * @returns a boolean specifying if an alpha test is needed.
  29586. */
  29587. needAlphaTesting(): boolean;
  29588. /**
  29589. * Specifies if material alpha testing should be turned on for the mesh
  29590. * @param mesh defines the mesh to check
  29591. */
  29592. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29593. /**
  29594. * Gets the texture used for the alpha test
  29595. * @returns the texture to use for alpha testing
  29596. */
  29597. getAlphaTestTexture(): Nullable<BaseTexture>;
  29598. /**
  29599. * Marks the material to indicate that it needs to be re-calculated
  29600. */
  29601. markDirty(): void;
  29602. /** @hidden */
  29603. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29604. /**
  29605. * Binds the material to the mesh
  29606. * @param world defines the world transformation matrix
  29607. * @param mesh defines the mesh to bind the material to
  29608. */
  29609. bind(world: Matrix, mesh?: Mesh): void;
  29610. /**
  29611. * Binds the submesh to the material
  29612. * @param world defines the world transformation matrix
  29613. * @param mesh defines the mesh containing the submesh
  29614. * @param subMesh defines the submesh to bind the material to
  29615. */
  29616. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29617. /**
  29618. * Binds the world matrix to the material
  29619. * @param world defines the world transformation matrix
  29620. */
  29621. bindOnlyWorldMatrix(world: Matrix): void;
  29622. /**
  29623. * Binds the scene's uniform buffer to the effect.
  29624. * @param effect defines the effect to bind to the scene uniform buffer
  29625. * @param sceneUbo defines the uniform buffer storing scene data
  29626. */
  29627. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29628. /**
  29629. * Binds the view matrix to the effect
  29630. * @param effect defines the effect to bind the view matrix to
  29631. */
  29632. bindView(effect: Effect): void;
  29633. /**
  29634. * Binds the view projection matrix to the effect
  29635. * @param effect defines the effect to bind the view projection matrix to
  29636. */
  29637. bindViewProjection(effect: Effect): void;
  29638. /**
  29639. * Processes to execute after binding the material to a mesh
  29640. * @param mesh defines the rendered mesh
  29641. */
  29642. protected _afterBind(mesh?: Mesh): void;
  29643. /**
  29644. * Unbinds the material from the mesh
  29645. */
  29646. unbind(): void;
  29647. /**
  29648. * Gets the active textures from the material
  29649. * @returns an array of textures
  29650. */
  29651. getActiveTextures(): BaseTexture[];
  29652. /**
  29653. * Specifies if the material uses a texture
  29654. * @param texture defines the texture to check against the material
  29655. * @returns a boolean specifying if the material uses the texture
  29656. */
  29657. hasTexture(texture: BaseTexture): boolean;
  29658. /**
  29659. * Makes a duplicate of the material, and gives it a new name
  29660. * @param name defines the new name for the duplicated material
  29661. * @returns the cloned material
  29662. */
  29663. clone(name: string): Nullable<Material>;
  29664. /**
  29665. * Gets the meshes bound to the material
  29666. * @returns an array of meshes bound to the material
  29667. */
  29668. getBindedMeshes(): AbstractMesh[];
  29669. /**
  29670. * Force shader compilation
  29671. * @param mesh defines the mesh associated with this material
  29672. * @param onCompiled defines a function to execute once the material is compiled
  29673. * @param options defines the options to configure the compilation
  29674. * @param onError defines a function to execute if the material fails compiling
  29675. */
  29676. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29677. /**
  29678. * Force shader compilation
  29679. * @param mesh defines the mesh that will use this material
  29680. * @param options defines additional options for compiling the shaders
  29681. * @returns a promise that resolves when the compilation completes
  29682. */
  29683. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29684. private static readonly _AllDirtyCallBack;
  29685. private static readonly _ImageProcessingDirtyCallBack;
  29686. private static readonly _TextureDirtyCallBack;
  29687. private static readonly _FresnelDirtyCallBack;
  29688. private static readonly _MiscDirtyCallBack;
  29689. private static readonly _PrePassDirtyCallBack;
  29690. private static readonly _LightsDirtyCallBack;
  29691. private static readonly _AttributeDirtyCallBack;
  29692. private static _FresnelAndMiscDirtyCallBack;
  29693. private static _TextureAndMiscDirtyCallBack;
  29694. private static readonly _DirtyCallbackArray;
  29695. private static readonly _RunDirtyCallBacks;
  29696. /**
  29697. * Marks a define in the material to indicate that it needs to be re-computed
  29698. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29699. */
  29700. markAsDirty(flag: number): void;
  29701. /**
  29702. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29703. * @param func defines a function which checks material defines against the submeshes
  29704. */
  29705. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29706. /**
  29707. * Indicates that the scene should check if the rendering now needs a prepass
  29708. */
  29709. protected _markScenePrePassDirty(): void;
  29710. /**
  29711. * Indicates that we need to re-calculated for all submeshes
  29712. */
  29713. protected _markAllSubMeshesAsAllDirty(): void;
  29714. /**
  29715. * Indicates that image processing needs to be re-calculated for all submeshes
  29716. */
  29717. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29718. /**
  29719. * Indicates that textures need to be re-calculated for all submeshes
  29720. */
  29721. protected _markAllSubMeshesAsTexturesDirty(): void;
  29722. /**
  29723. * Indicates that fresnel needs to be re-calculated for all submeshes
  29724. */
  29725. protected _markAllSubMeshesAsFresnelDirty(): void;
  29726. /**
  29727. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29728. */
  29729. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29730. /**
  29731. * Indicates that lights need to be re-calculated for all submeshes
  29732. */
  29733. protected _markAllSubMeshesAsLightsDirty(): void;
  29734. /**
  29735. * Indicates that attributes need to be re-calculated for all submeshes
  29736. */
  29737. protected _markAllSubMeshesAsAttributesDirty(): void;
  29738. /**
  29739. * Indicates that misc needs to be re-calculated for all submeshes
  29740. */
  29741. protected _markAllSubMeshesAsMiscDirty(): void;
  29742. /**
  29743. * Indicates that prepass needs to be re-calculated for all submeshes
  29744. */
  29745. protected _markAllSubMeshesAsPrePassDirty(): void;
  29746. /**
  29747. * Indicates that textures and misc need to be re-calculated for all submeshes
  29748. */
  29749. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29750. /**
  29751. * Sets the required values to the prepass renderer.
  29752. * @param prePassRenderer defines the prepass renderer to setup.
  29753. * @returns true if the pre pass is needed.
  29754. */
  29755. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29756. /**
  29757. * Disposes the material
  29758. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29759. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29760. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29761. */
  29762. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29763. /** @hidden */
  29764. private releaseVertexArrayObject;
  29765. /**
  29766. * Serializes this material
  29767. * @returns the serialized material object
  29768. */
  29769. serialize(): any;
  29770. /**
  29771. * Creates a material from parsed material data
  29772. * @param parsedMaterial defines parsed material data
  29773. * @param scene defines the hosting scene
  29774. * @param rootUrl defines the root URL to use to load textures
  29775. * @returns a new material
  29776. */
  29777. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29778. }
  29779. }
  29780. declare module BABYLON {
  29781. /**
  29782. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29783. * separate meshes. This can be use to improve performances.
  29784. * @see https://doc.babylonjs.com/how_to/multi_materials
  29785. */
  29786. export class MultiMaterial extends Material {
  29787. private _subMaterials;
  29788. /**
  29789. * Gets or Sets the list of Materials used within the multi material.
  29790. * They need to be ordered according to the submeshes order in the associated mesh
  29791. */
  29792. get subMaterials(): Nullable<Material>[];
  29793. set subMaterials(value: Nullable<Material>[]);
  29794. /**
  29795. * Function used to align with Node.getChildren()
  29796. * @returns the list of Materials used within the multi material
  29797. */
  29798. getChildren(): Nullable<Material>[];
  29799. /**
  29800. * Instantiates a new Multi Material
  29801. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29802. * separate meshes. This can be use to improve performances.
  29803. * @see https://doc.babylonjs.com/how_to/multi_materials
  29804. * @param name Define the name in the scene
  29805. * @param scene Define the scene the material belongs to
  29806. */
  29807. constructor(name: string, scene: Scene);
  29808. private _hookArray;
  29809. /**
  29810. * Get one of the submaterial by its index in the submaterials array
  29811. * @param index The index to look the sub material at
  29812. * @returns The Material if the index has been defined
  29813. */
  29814. getSubMaterial(index: number): Nullable<Material>;
  29815. /**
  29816. * Get the list of active textures for the whole sub materials list.
  29817. * @returns All the textures that will be used during the rendering
  29818. */
  29819. getActiveTextures(): BaseTexture[];
  29820. /**
  29821. * Gets the current class name of the material e.g. "MultiMaterial"
  29822. * Mainly use in serialization.
  29823. * @returns the class name
  29824. */
  29825. getClassName(): string;
  29826. /**
  29827. * Checks if the material is ready to render the requested sub mesh
  29828. * @param mesh Define the mesh the submesh belongs to
  29829. * @param subMesh Define the sub mesh to look readyness for
  29830. * @param useInstances Define whether or not the material is used with instances
  29831. * @returns true if ready, otherwise false
  29832. */
  29833. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29834. /**
  29835. * Clones the current material and its related sub materials
  29836. * @param name Define the name of the newly cloned material
  29837. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  29838. * @returns the cloned material
  29839. */
  29840. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  29841. /**
  29842. * Serializes the materials into a JSON representation.
  29843. * @returns the JSON representation
  29844. */
  29845. serialize(): any;
  29846. /**
  29847. * Dispose the material and release its associated resources
  29848. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  29849. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  29850. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  29851. */
  29852. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  29853. /**
  29854. * Creates a MultiMaterial from parsed MultiMaterial data.
  29855. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  29856. * @param scene defines the hosting scene
  29857. * @returns a new MultiMaterial
  29858. */
  29859. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  29860. }
  29861. }
  29862. declare module BABYLON {
  29863. /**
  29864. * Defines a subdivision inside a mesh
  29865. */
  29866. export class SubMesh implements ICullable {
  29867. /** the material index to use */
  29868. materialIndex: number;
  29869. /** vertex index start */
  29870. verticesStart: number;
  29871. /** vertices count */
  29872. verticesCount: number;
  29873. /** index start */
  29874. indexStart: number;
  29875. /** indices count */
  29876. indexCount: number;
  29877. /** @hidden */
  29878. _materialDefines: Nullable<MaterialDefines>;
  29879. /** @hidden */
  29880. _materialEffect: Nullable<Effect>;
  29881. /** @hidden */
  29882. _effectOverride: Nullable<Effect>;
  29883. /**
  29884. * Gets material defines used by the effect associated to the sub mesh
  29885. */
  29886. get materialDefines(): Nullable<MaterialDefines>;
  29887. /**
  29888. * Sets material defines used by the effect associated to the sub mesh
  29889. */
  29890. set materialDefines(defines: Nullable<MaterialDefines>);
  29891. /**
  29892. * Gets associated effect
  29893. */
  29894. get effect(): Nullable<Effect>;
  29895. /**
  29896. * Sets associated effect (effect used to render this submesh)
  29897. * @param effect defines the effect to associate with
  29898. * @param defines defines the set of defines used to compile this effect
  29899. */
  29900. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29901. /** @hidden */
  29902. _linesIndexCount: number;
  29903. private _mesh;
  29904. private _renderingMesh;
  29905. private _boundingInfo;
  29906. private _linesIndexBuffer;
  29907. /** @hidden */
  29908. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29909. /** @hidden */
  29910. _trianglePlanes: Plane[];
  29911. /** @hidden */
  29912. _lastColliderTransformMatrix: Nullable<Matrix>;
  29913. /** @hidden */
  29914. _renderId: number;
  29915. /** @hidden */
  29916. _alphaIndex: number;
  29917. /** @hidden */
  29918. _distanceToCamera: number;
  29919. /** @hidden */
  29920. _id: number;
  29921. private _currentMaterial;
  29922. /**
  29923. * Add a new submesh to a mesh
  29924. * @param materialIndex defines the material index to use
  29925. * @param verticesStart defines vertex index start
  29926. * @param verticesCount defines vertices count
  29927. * @param indexStart defines index start
  29928. * @param indexCount defines indices count
  29929. * @param mesh defines the parent mesh
  29930. * @param renderingMesh defines an optional rendering mesh
  29931. * @param createBoundingBox defines if bounding box should be created for this submesh
  29932. * @returns the new submesh
  29933. */
  29934. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29935. /**
  29936. * Creates a new submesh
  29937. * @param materialIndex defines the material index to use
  29938. * @param verticesStart defines vertex index start
  29939. * @param verticesCount defines vertices count
  29940. * @param indexStart defines index start
  29941. * @param indexCount defines indices count
  29942. * @param mesh defines the parent mesh
  29943. * @param renderingMesh defines an optional rendering mesh
  29944. * @param createBoundingBox defines if bounding box should be created for this submesh
  29945. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  29946. */
  29947. constructor(
  29948. /** the material index to use */
  29949. materialIndex: number,
  29950. /** vertex index start */
  29951. verticesStart: number,
  29952. /** vertices count */
  29953. verticesCount: number,
  29954. /** index start */
  29955. indexStart: number,
  29956. /** indices count */
  29957. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  29958. /**
  29959. * Returns true if this submesh covers the entire parent mesh
  29960. * @ignorenaming
  29961. */
  29962. get IsGlobal(): boolean;
  29963. /**
  29964. * Returns the submesh BoudingInfo object
  29965. * @returns current bounding info (or mesh's one if the submesh is global)
  29966. */
  29967. getBoundingInfo(): BoundingInfo;
  29968. /**
  29969. * Sets the submesh BoundingInfo
  29970. * @param boundingInfo defines the new bounding info to use
  29971. * @returns the SubMesh
  29972. */
  29973. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29974. /**
  29975. * Returns the mesh of the current submesh
  29976. * @return the parent mesh
  29977. */
  29978. getMesh(): AbstractMesh;
  29979. /**
  29980. * Returns the rendering mesh of the submesh
  29981. * @returns the rendering mesh (could be different from parent mesh)
  29982. */
  29983. getRenderingMesh(): Mesh;
  29984. /**
  29985. * Returns the replacement mesh of the submesh
  29986. * @returns the replacement mesh (could be different from parent mesh)
  29987. */
  29988. getReplacementMesh(): Nullable<AbstractMesh>;
  29989. /**
  29990. * Returns the effective mesh of the submesh
  29991. * @returns the effective mesh (could be different from parent mesh)
  29992. */
  29993. getEffectiveMesh(): AbstractMesh;
  29994. /**
  29995. * Returns the submesh material
  29996. * @returns null or the current material
  29997. */
  29998. getMaterial(): Nullable<Material>;
  29999. private _IsMultiMaterial;
  30000. /**
  30001. * Sets a new updated BoundingInfo object to the submesh
  30002. * @param data defines an optional position array to use to determine the bounding info
  30003. * @returns the SubMesh
  30004. */
  30005. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30006. /** @hidden */
  30007. _checkCollision(collider: Collider): boolean;
  30008. /**
  30009. * Updates the submesh BoundingInfo
  30010. * @param world defines the world matrix to use to update the bounding info
  30011. * @returns the submesh
  30012. */
  30013. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30014. /**
  30015. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30016. * @param frustumPlanes defines the frustum planes
  30017. * @returns true if the submesh is intersecting with the frustum
  30018. */
  30019. isInFrustum(frustumPlanes: Plane[]): boolean;
  30020. /**
  30021. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30022. * @param frustumPlanes defines the frustum planes
  30023. * @returns true if the submesh is inside the frustum
  30024. */
  30025. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30026. /**
  30027. * Renders the submesh
  30028. * @param enableAlphaMode defines if alpha needs to be used
  30029. * @returns the submesh
  30030. */
  30031. render(enableAlphaMode: boolean): SubMesh;
  30032. /**
  30033. * @hidden
  30034. */
  30035. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30036. /**
  30037. * Checks if the submesh intersects with a ray
  30038. * @param ray defines the ray to test
  30039. * @returns true is the passed ray intersects the submesh bounding box
  30040. */
  30041. canIntersects(ray: Ray): boolean;
  30042. /**
  30043. * Intersects current submesh with a ray
  30044. * @param ray defines the ray to test
  30045. * @param positions defines mesh's positions array
  30046. * @param indices defines mesh's indices array
  30047. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30048. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30049. * @returns intersection info or null if no intersection
  30050. */
  30051. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30052. /** @hidden */
  30053. private _intersectLines;
  30054. /** @hidden */
  30055. private _intersectUnIndexedLines;
  30056. /** @hidden */
  30057. private _intersectTriangles;
  30058. /** @hidden */
  30059. private _intersectUnIndexedTriangles;
  30060. /** @hidden */
  30061. _rebuild(): void;
  30062. /**
  30063. * Creates a new submesh from the passed mesh
  30064. * @param newMesh defines the new hosting mesh
  30065. * @param newRenderingMesh defines an optional rendering mesh
  30066. * @returns the new submesh
  30067. */
  30068. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30069. /**
  30070. * Release associated resources
  30071. */
  30072. dispose(): void;
  30073. /**
  30074. * Gets the class name
  30075. * @returns the string "SubMesh".
  30076. */
  30077. getClassName(): string;
  30078. /**
  30079. * Creates a new submesh from indices data
  30080. * @param materialIndex the index of the main mesh material
  30081. * @param startIndex the index where to start the copy in the mesh indices array
  30082. * @param indexCount the number of indices to copy then from the startIndex
  30083. * @param mesh the main mesh to create the submesh from
  30084. * @param renderingMesh the optional rendering mesh
  30085. * @returns a new submesh
  30086. */
  30087. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30088. }
  30089. }
  30090. declare module BABYLON {
  30091. /**
  30092. * Class used to represent data loading progression
  30093. */
  30094. export class SceneLoaderFlags {
  30095. private static _ForceFullSceneLoadingForIncremental;
  30096. private static _ShowLoadingScreen;
  30097. private static _CleanBoneMatrixWeights;
  30098. private static _loggingLevel;
  30099. /**
  30100. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30101. */
  30102. static get ForceFullSceneLoadingForIncremental(): boolean;
  30103. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30104. /**
  30105. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30106. */
  30107. static get ShowLoadingScreen(): boolean;
  30108. static set ShowLoadingScreen(value: boolean);
  30109. /**
  30110. * Defines the current logging level (while loading the scene)
  30111. * @ignorenaming
  30112. */
  30113. static get loggingLevel(): number;
  30114. static set loggingLevel(value: number);
  30115. /**
  30116. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30117. */
  30118. static get CleanBoneMatrixWeights(): boolean;
  30119. static set CleanBoneMatrixWeights(value: boolean);
  30120. }
  30121. }
  30122. declare module BABYLON {
  30123. /**
  30124. * Class used to store geometry data (vertex buffers + index buffer)
  30125. */
  30126. export class Geometry implements IGetSetVerticesData {
  30127. /**
  30128. * Gets or sets the ID of the geometry
  30129. */
  30130. id: string;
  30131. /**
  30132. * Gets or sets the unique ID of the geometry
  30133. */
  30134. uniqueId: number;
  30135. /**
  30136. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30137. */
  30138. delayLoadState: number;
  30139. /**
  30140. * Gets the file containing the data to load when running in delay load state
  30141. */
  30142. delayLoadingFile: Nullable<string>;
  30143. /**
  30144. * Callback called when the geometry is updated
  30145. */
  30146. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30147. private _scene;
  30148. private _engine;
  30149. private _meshes;
  30150. private _totalVertices;
  30151. /** @hidden */
  30152. _indices: IndicesArray;
  30153. /** @hidden */
  30154. _vertexBuffers: {
  30155. [key: string]: VertexBuffer;
  30156. };
  30157. private _isDisposed;
  30158. private _extend;
  30159. private _boundingBias;
  30160. /** @hidden */
  30161. _delayInfo: Array<string>;
  30162. private _indexBuffer;
  30163. private _indexBufferIsUpdatable;
  30164. /** @hidden */
  30165. _boundingInfo: Nullable<BoundingInfo>;
  30166. /** @hidden */
  30167. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30168. /** @hidden */
  30169. _softwareSkinningFrameId: number;
  30170. private _vertexArrayObjects;
  30171. private _updatable;
  30172. /** @hidden */
  30173. _positions: Nullable<Vector3[]>;
  30174. private _positionsCache;
  30175. /**
  30176. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  30177. */
  30178. get boundingBias(): Vector2;
  30179. /**
  30180. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  30181. */
  30182. set boundingBias(value: Vector2);
  30183. /**
  30184. * Static function used to attach a new empty geometry to a mesh
  30185. * @param mesh defines the mesh to attach the geometry to
  30186. * @returns the new Geometry
  30187. */
  30188. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30189. /** Get the list of meshes using this geometry */
  30190. get meshes(): Mesh[];
  30191. /**
  30192. * If set to true (false by defaut), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  30193. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30194. */
  30195. useBoundingInfoFromGeometry: boolean;
  30196. /**
  30197. * Creates a new geometry
  30198. * @param id defines the unique ID
  30199. * @param scene defines the hosting scene
  30200. * @param vertexData defines the VertexData used to get geometry data
  30201. * @param updatable defines if geometry must be updatable (false by default)
  30202. * @param mesh defines the mesh that will be associated with the geometry
  30203. */
  30204. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30205. /**
  30206. * Gets the current extend of the geometry
  30207. */
  30208. get extend(): {
  30209. minimum: Vector3;
  30210. maximum: Vector3;
  30211. };
  30212. /**
  30213. * Gets the hosting scene
  30214. * @returns the hosting Scene
  30215. */
  30216. getScene(): Scene;
  30217. /**
  30218. * Gets the hosting engine
  30219. * @returns the hosting Engine
  30220. */
  30221. getEngine(): Engine;
  30222. /**
  30223. * Defines if the geometry is ready to use
  30224. * @returns true if the geometry is ready to be used
  30225. */
  30226. isReady(): boolean;
  30227. /**
  30228. * Gets a value indicating that the geometry should not be serialized
  30229. */
  30230. get doNotSerialize(): boolean;
  30231. /** @hidden */
  30232. _rebuild(): void;
  30233. /**
  30234. * Affects all geometry data in one call
  30235. * @param vertexData defines the geometry data
  30236. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30237. */
  30238. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30239. /**
  30240. * Set specific vertex data
  30241. * @param kind defines the data kind (Position, normal, etc...)
  30242. * @param data defines the vertex data to use
  30243. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30244. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30245. */
  30246. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30247. /**
  30248. * Removes a specific vertex data
  30249. * @param kind defines the data kind (Position, normal, etc...)
  30250. */
  30251. removeVerticesData(kind: string): void;
  30252. /**
  30253. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30254. * @param buffer defines the vertex buffer to use
  30255. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30256. */
  30257. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30258. /**
  30259. * Update a specific vertex buffer
  30260. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30261. * It will do nothing if the buffer is not updatable
  30262. * @param kind defines the data kind (Position, normal, etc...)
  30263. * @param data defines the data to use
  30264. * @param offset defines the offset in the target buffer where to store the data
  30265. * @param useBytes set to true if the offset is in bytes
  30266. */
  30267. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30268. /**
  30269. * Update a specific vertex buffer
  30270. * This function will create a new buffer if the current one is not updatable
  30271. * @param kind defines the data kind (Position, normal, etc...)
  30272. * @param data defines the data to use
  30273. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30274. */
  30275. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30276. private _updateBoundingInfo;
  30277. /** @hidden */
  30278. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30279. /**
  30280. * Gets total number of vertices
  30281. * @returns the total number of vertices
  30282. */
  30283. getTotalVertices(): number;
  30284. /**
  30285. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30286. * @param kind defines the data kind (Position, normal, etc...)
  30287. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30288. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30289. * @returns a float array containing vertex data
  30290. */
  30291. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30292. /**
  30293. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30294. * @param kind defines the data kind (Position, normal, etc...)
  30295. * @returns true if the vertex buffer with the specified kind is updatable
  30296. */
  30297. isVertexBufferUpdatable(kind: string): boolean;
  30298. /**
  30299. * Gets a specific vertex buffer
  30300. * @param kind defines the data kind (Position, normal, etc...)
  30301. * @returns a VertexBuffer
  30302. */
  30303. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30304. /**
  30305. * Returns all vertex buffers
  30306. * @return an object holding all vertex buffers indexed by kind
  30307. */
  30308. getVertexBuffers(): Nullable<{
  30309. [key: string]: VertexBuffer;
  30310. }>;
  30311. /**
  30312. * Gets a boolean indicating if specific vertex buffer is present
  30313. * @param kind defines the data kind (Position, normal, etc...)
  30314. * @returns true if data is present
  30315. */
  30316. isVerticesDataPresent(kind: string): boolean;
  30317. /**
  30318. * Gets a list of all attached data kinds (Position, normal, etc...)
  30319. * @returns a list of string containing all kinds
  30320. */
  30321. getVerticesDataKinds(): string[];
  30322. /**
  30323. * Update index buffer
  30324. * @param indices defines the indices to store in the index buffer
  30325. * @param offset defines the offset in the target buffer where to store the data
  30326. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  30327. */
  30328. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30329. /**
  30330. * Creates a new index buffer
  30331. * @param indices defines the indices to store in the index buffer
  30332. * @param totalVertices defines the total number of vertices (could be null)
  30333. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30334. */
  30335. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30336. /**
  30337. * Return the total number of indices
  30338. * @returns the total number of indices
  30339. */
  30340. getTotalIndices(): number;
  30341. /**
  30342. * Gets the index buffer array
  30343. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30344. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30345. * @returns the index buffer array
  30346. */
  30347. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30348. /**
  30349. * Gets the index buffer
  30350. * @return the index buffer
  30351. */
  30352. getIndexBuffer(): Nullable<DataBuffer>;
  30353. /** @hidden */
  30354. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30355. /**
  30356. * Release the associated resources for a specific mesh
  30357. * @param mesh defines the source mesh
  30358. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30359. */
  30360. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30361. /**
  30362. * Apply current geometry to a given mesh
  30363. * @param mesh defines the mesh to apply geometry to
  30364. */
  30365. applyToMesh(mesh: Mesh): void;
  30366. private _updateExtend;
  30367. private _applyToMesh;
  30368. private notifyUpdate;
  30369. /**
  30370. * Load the geometry if it was flagged as delay loaded
  30371. * @param scene defines the hosting scene
  30372. * @param onLoaded defines a callback called when the geometry is loaded
  30373. */
  30374. load(scene: Scene, onLoaded?: () => void): void;
  30375. private _queueLoad;
  30376. /**
  30377. * Invert the geometry to move from a right handed system to a left handed one.
  30378. */
  30379. toLeftHanded(): void;
  30380. /** @hidden */
  30381. _resetPointsArrayCache(): void;
  30382. /** @hidden */
  30383. _generatePointsArray(): boolean;
  30384. /**
  30385. * Gets a value indicating if the geometry is disposed
  30386. * @returns true if the geometry was disposed
  30387. */
  30388. isDisposed(): boolean;
  30389. private _disposeVertexArrayObjects;
  30390. /**
  30391. * Free all associated resources
  30392. */
  30393. dispose(): void;
  30394. /**
  30395. * Clone the current geometry into a new geometry
  30396. * @param id defines the unique ID of the new geometry
  30397. * @returns a new geometry object
  30398. */
  30399. copy(id: string): Geometry;
  30400. /**
  30401. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30402. * @return a JSON representation of the current geometry data (without the vertices data)
  30403. */
  30404. serialize(): any;
  30405. private toNumberArray;
  30406. /**
  30407. * Serialize all vertices data into a JSON oject
  30408. * @returns a JSON representation of the current geometry data
  30409. */
  30410. serializeVerticeData(): any;
  30411. /**
  30412. * Extracts a clone of a mesh geometry
  30413. * @param mesh defines the source mesh
  30414. * @param id defines the unique ID of the new geometry object
  30415. * @returns the new geometry object
  30416. */
  30417. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30418. /**
  30419. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30420. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30421. * Be aware Math.random() could cause collisions, but:
  30422. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  30423. * @returns a string containing a new GUID
  30424. */
  30425. static RandomId(): string;
  30426. /** @hidden */
  30427. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30428. private static _CleanMatricesWeights;
  30429. /**
  30430. * Create a new geometry from persisted data (Using .babylon file format)
  30431. * @param parsedVertexData defines the persisted data
  30432. * @param scene defines the hosting scene
  30433. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30434. * @returns the new geometry object
  30435. */
  30436. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30437. }
  30438. }
  30439. declare module BABYLON {
  30440. /**
  30441. * Define an interface for all classes that will get and set the data on vertices
  30442. */
  30443. export interface IGetSetVerticesData {
  30444. /**
  30445. * Gets a boolean indicating if specific vertex data is present
  30446. * @param kind defines the vertex data kind to use
  30447. * @returns true is data kind is present
  30448. */
  30449. isVerticesDataPresent(kind: string): boolean;
  30450. /**
  30451. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30452. * @param kind defines the data kind (Position, normal, etc...)
  30453. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30454. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30455. * @returns a float array containing vertex data
  30456. */
  30457. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30458. /**
  30459. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  30460. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  30461. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30462. * @returns the indices array or an empty array if the mesh has no geometry
  30463. */
  30464. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30465. /**
  30466. * Set specific vertex data
  30467. * @param kind defines the data kind (Position, normal, etc...)
  30468. * @param data defines the vertex data to use
  30469. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30470. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30471. */
  30472. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  30473. /**
  30474. * Update a specific associated vertex buffer
  30475. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  30476. * - VertexBuffer.PositionKind
  30477. * - VertexBuffer.UVKind
  30478. * - VertexBuffer.UV2Kind
  30479. * - VertexBuffer.UV3Kind
  30480. * - VertexBuffer.UV4Kind
  30481. * - VertexBuffer.UV5Kind
  30482. * - VertexBuffer.UV6Kind
  30483. * - VertexBuffer.ColorKind
  30484. * - VertexBuffer.MatricesIndicesKind
  30485. * - VertexBuffer.MatricesIndicesExtraKind
  30486. * - VertexBuffer.MatricesWeightsKind
  30487. * - VertexBuffer.MatricesWeightsExtraKind
  30488. * @param data defines the data source
  30489. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  30490. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  30491. */
  30492. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  30493. /**
  30494. * Creates a new index buffer
  30495. * @param indices defines the indices to store in the index buffer
  30496. * @param totalVertices defines the total number of vertices (could be null)
  30497. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30498. */
  30499. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  30500. }
  30501. /**
  30502. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  30503. */
  30504. export class VertexData {
  30505. /**
  30506. * Mesh side orientation : usually the external or front surface
  30507. */
  30508. static readonly FRONTSIDE: number;
  30509. /**
  30510. * Mesh side orientation : usually the internal or back surface
  30511. */
  30512. static readonly BACKSIDE: number;
  30513. /**
  30514. * Mesh side orientation : both internal and external or front and back surfaces
  30515. */
  30516. static readonly DOUBLESIDE: number;
  30517. /**
  30518. * Mesh side orientation : by default, `FRONTSIDE`
  30519. */
  30520. static readonly DEFAULTSIDE: number;
  30521. /**
  30522. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  30523. */
  30524. positions: Nullable<FloatArray>;
  30525. /**
  30526. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  30527. */
  30528. normals: Nullable<FloatArray>;
  30529. /**
  30530. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  30531. */
  30532. tangents: Nullable<FloatArray>;
  30533. /**
  30534. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30535. */
  30536. uvs: Nullable<FloatArray>;
  30537. /**
  30538. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30539. */
  30540. uvs2: Nullable<FloatArray>;
  30541. /**
  30542. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30543. */
  30544. uvs3: Nullable<FloatArray>;
  30545. /**
  30546. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30547. */
  30548. uvs4: Nullable<FloatArray>;
  30549. /**
  30550. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30551. */
  30552. uvs5: Nullable<FloatArray>;
  30553. /**
  30554. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30555. */
  30556. uvs6: Nullable<FloatArray>;
  30557. /**
  30558. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  30559. */
  30560. colors: Nullable<FloatArray>;
  30561. /**
  30562. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  30563. */
  30564. matricesIndices: Nullable<FloatArray>;
  30565. /**
  30566. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  30567. */
  30568. matricesWeights: Nullable<FloatArray>;
  30569. /**
  30570. * An array extending the number of possible indices
  30571. */
  30572. matricesIndicesExtra: Nullable<FloatArray>;
  30573. /**
  30574. * An array extending the number of possible weights when the number of indices is extended
  30575. */
  30576. matricesWeightsExtra: Nullable<FloatArray>;
  30577. /**
  30578. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  30579. */
  30580. indices: Nullable<IndicesArray>;
  30581. /**
  30582. * Uses the passed data array to set the set the values for the specified kind of data
  30583. * @param data a linear array of floating numbers
  30584. * @param kind the type of data that is being set, eg positions, colors etc
  30585. */
  30586. set(data: FloatArray, kind: string): void;
  30587. /**
  30588. * Associates the vertexData to the passed Mesh.
  30589. * Sets it as updatable or not (default `false`)
  30590. * @param mesh the mesh the vertexData is applied to
  30591. * @param updatable when used and having the value true allows new data to update the vertexData
  30592. * @returns the VertexData
  30593. */
  30594. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  30595. /**
  30596. * Associates the vertexData to the passed Geometry.
  30597. * Sets it as updatable or not (default `false`)
  30598. * @param geometry the geometry the vertexData is applied to
  30599. * @param updatable when used and having the value true allows new data to update the vertexData
  30600. * @returns VertexData
  30601. */
  30602. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  30603. /**
  30604. * Updates the associated mesh
  30605. * @param mesh the mesh to be updated
  30606. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30607. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  30608. * @returns VertexData
  30609. */
  30610. updateMesh(mesh: Mesh): VertexData;
  30611. /**
  30612. * Updates the associated geometry
  30613. * @param geometry the geometry to be updated
  30614. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30615. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  30616. * @returns VertexData.
  30617. */
  30618. updateGeometry(geometry: Geometry): VertexData;
  30619. private _applyTo;
  30620. private _update;
  30621. /**
  30622. * Transforms each position and each normal of the vertexData according to the passed Matrix
  30623. * @param matrix the transforming matrix
  30624. * @returns the VertexData
  30625. */
  30626. transform(matrix: Matrix): VertexData;
  30627. /**
  30628. * Merges the passed VertexData into the current one
  30629. * @param other the VertexData to be merged into the current one
  30630. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  30631. * @returns the modified VertexData
  30632. */
  30633. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  30634. private _mergeElement;
  30635. private _validate;
  30636. /**
  30637. * Serializes the VertexData
  30638. * @returns a serialized object
  30639. */
  30640. serialize(): any;
  30641. /**
  30642. * Extracts the vertexData from a mesh
  30643. * @param mesh the mesh from which to extract the VertexData
  30644. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  30645. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30646. * @returns the object VertexData associated to the passed mesh
  30647. */
  30648. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30649. /**
  30650. * Extracts the vertexData from the geometry
  30651. * @param geometry the geometry from which to extract the VertexData
  30652. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  30653. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30654. * @returns the object VertexData associated to the passed mesh
  30655. */
  30656. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30657. private static _ExtractFrom;
  30658. /**
  30659. * Creates the VertexData for a Ribbon
  30660. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  30661. * * pathArray array of paths, each of which an array of successive Vector3
  30662. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  30663. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  30664. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  30665. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30666. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30667. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30668. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  30669. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  30670. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  30671. * @returns the VertexData of the ribbon
  30672. */
  30673. static CreateRibbon(options: {
  30674. pathArray: Vector3[][];
  30675. closeArray?: boolean;
  30676. closePath?: boolean;
  30677. offset?: number;
  30678. sideOrientation?: number;
  30679. frontUVs?: Vector4;
  30680. backUVs?: Vector4;
  30681. invertUV?: boolean;
  30682. uvs?: Vector2[];
  30683. colors?: Color4[];
  30684. }): VertexData;
  30685. /**
  30686. * Creates the VertexData for a box
  30687. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30688. * * size sets the width, height and depth of the box to the value of size, optional default 1
  30689. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  30690. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  30691. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  30692. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30693. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30694. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30695. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30696. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30697. * @returns the VertexData of the box
  30698. */
  30699. static CreateBox(options: {
  30700. size?: number;
  30701. width?: number;
  30702. height?: number;
  30703. depth?: number;
  30704. faceUV?: Vector4[];
  30705. faceColors?: Color4[];
  30706. sideOrientation?: number;
  30707. frontUVs?: Vector4;
  30708. backUVs?: Vector4;
  30709. }): VertexData;
  30710. /**
  30711. * Creates the VertexData for a tiled box
  30712. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30713. * * faceTiles sets the pattern, tile size and number of tiles for a face
  30714. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30715. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30716. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30717. * @returns the VertexData of the box
  30718. */
  30719. static CreateTiledBox(options: {
  30720. pattern?: number;
  30721. width?: number;
  30722. height?: number;
  30723. depth?: number;
  30724. tileSize?: number;
  30725. tileWidth?: number;
  30726. tileHeight?: number;
  30727. alignHorizontal?: number;
  30728. alignVertical?: number;
  30729. faceUV?: Vector4[];
  30730. faceColors?: Color4[];
  30731. sideOrientation?: number;
  30732. }): VertexData;
  30733. /**
  30734. * Creates the VertexData for a tiled plane
  30735. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30736. * * pattern a limited pattern arrangement depending on the number
  30737. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  30738. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  30739. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  30740. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30741. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30742. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30743. * @returns the VertexData of the tiled plane
  30744. */
  30745. static CreateTiledPlane(options: {
  30746. pattern?: number;
  30747. tileSize?: number;
  30748. tileWidth?: number;
  30749. tileHeight?: number;
  30750. size?: number;
  30751. width?: number;
  30752. height?: number;
  30753. alignHorizontal?: number;
  30754. alignVertical?: number;
  30755. sideOrientation?: number;
  30756. frontUVs?: Vector4;
  30757. backUVs?: Vector4;
  30758. }): VertexData;
  30759. /**
  30760. * Creates the VertexData for an ellipsoid, defaults to a sphere
  30761. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30762. * * segments sets the number of horizontal strips optional, default 32
  30763. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  30764. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  30765. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  30766. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  30767. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  30768. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  30769. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30770. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30771. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30772. * @returns the VertexData of the ellipsoid
  30773. */
  30774. static CreateSphere(options: {
  30775. segments?: number;
  30776. diameter?: number;
  30777. diameterX?: number;
  30778. diameterY?: number;
  30779. diameterZ?: number;
  30780. arc?: number;
  30781. slice?: number;
  30782. sideOrientation?: number;
  30783. frontUVs?: Vector4;
  30784. backUVs?: Vector4;
  30785. }): VertexData;
  30786. /**
  30787. * Creates the VertexData for a cylinder, cone or prism
  30788. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30789. * * height sets the height (y direction) of the cylinder, optional, default 2
  30790. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  30791. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  30792. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  30793. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30794. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  30795. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  30796. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30797. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30798. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  30799. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  30800. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30801. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30802. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30803. * @returns the VertexData of the cylinder, cone or prism
  30804. */
  30805. static CreateCylinder(options: {
  30806. height?: number;
  30807. diameterTop?: number;
  30808. diameterBottom?: number;
  30809. diameter?: number;
  30810. tessellation?: number;
  30811. subdivisions?: number;
  30812. arc?: number;
  30813. faceColors?: Color4[];
  30814. faceUV?: Vector4[];
  30815. hasRings?: boolean;
  30816. enclose?: boolean;
  30817. sideOrientation?: number;
  30818. frontUVs?: Vector4;
  30819. backUVs?: Vector4;
  30820. }): VertexData;
  30821. /**
  30822. * Creates the VertexData for a torus
  30823. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30824. * * diameter the diameter of the torus, optional default 1
  30825. * * thickness the diameter of the tube forming the torus, optional default 0.5
  30826. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30827. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30828. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30829. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30830. * @returns the VertexData of the torus
  30831. */
  30832. static CreateTorus(options: {
  30833. diameter?: number;
  30834. thickness?: number;
  30835. tessellation?: number;
  30836. sideOrientation?: number;
  30837. frontUVs?: Vector4;
  30838. backUVs?: Vector4;
  30839. }): VertexData;
  30840. /**
  30841. * Creates the VertexData of the LineSystem
  30842. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  30843. * - lines an array of lines, each line being an array of successive Vector3
  30844. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  30845. * @returns the VertexData of the LineSystem
  30846. */
  30847. static CreateLineSystem(options: {
  30848. lines: Vector3[][];
  30849. colors?: Nullable<Color4[][]>;
  30850. }): VertexData;
  30851. /**
  30852. * Create the VertexData for a DashedLines
  30853. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  30854. * - points an array successive Vector3
  30855. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  30856. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  30857. * - dashNb the intended total number of dashes, optional, default 200
  30858. * @returns the VertexData for the DashedLines
  30859. */
  30860. static CreateDashedLines(options: {
  30861. points: Vector3[];
  30862. dashSize?: number;
  30863. gapSize?: number;
  30864. dashNb?: number;
  30865. }): VertexData;
  30866. /**
  30867. * Creates the VertexData for a Ground
  30868. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30869. * - width the width (x direction) of the ground, optional, default 1
  30870. * - height the height (z direction) of the ground, optional, default 1
  30871. * - subdivisions the number of subdivisions per side, optional, default 1
  30872. * @returns the VertexData of the Ground
  30873. */
  30874. static CreateGround(options: {
  30875. width?: number;
  30876. height?: number;
  30877. subdivisions?: number;
  30878. subdivisionsX?: number;
  30879. subdivisionsY?: number;
  30880. }): VertexData;
  30881. /**
  30882. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  30883. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30884. * * xmin the ground minimum X coordinate, optional, default -1
  30885. * * zmin the ground minimum Z coordinate, optional, default -1
  30886. * * xmax the ground maximum X coordinate, optional, default 1
  30887. * * zmax the ground maximum Z coordinate, optional, default 1
  30888. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  30889. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  30890. * @returns the VertexData of the TiledGround
  30891. */
  30892. static CreateTiledGround(options: {
  30893. xmin: number;
  30894. zmin: number;
  30895. xmax: number;
  30896. zmax: number;
  30897. subdivisions?: {
  30898. w: number;
  30899. h: number;
  30900. };
  30901. precision?: {
  30902. w: number;
  30903. h: number;
  30904. };
  30905. }): VertexData;
  30906. /**
  30907. * Creates the VertexData of the Ground designed from a heightmap
  30908. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  30909. * * width the width (x direction) of the ground
  30910. * * height the height (z direction) of the ground
  30911. * * subdivisions the number of subdivisions per side
  30912. * * minHeight the minimum altitude on the ground, optional, default 0
  30913. * * maxHeight the maximum altitude on the ground, optional default 1
  30914. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  30915. * * buffer the array holding the image color data
  30916. * * bufferWidth the width of image
  30917. * * bufferHeight the height of image
  30918. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  30919. * @returns the VertexData of the Ground designed from a heightmap
  30920. */
  30921. static CreateGroundFromHeightMap(options: {
  30922. width: number;
  30923. height: number;
  30924. subdivisions: number;
  30925. minHeight: number;
  30926. maxHeight: number;
  30927. colorFilter: Color3;
  30928. buffer: Uint8Array;
  30929. bufferWidth: number;
  30930. bufferHeight: number;
  30931. alphaFilter: number;
  30932. }): VertexData;
  30933. /**
  30934. * Creates the VertexData for a Plane
  30935. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  30936. * * size sets the width and height of the plane to the value of size, optional default 1
  30937. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  30938. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  30939. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30940. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30941. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30942. * @returns the VertexData of the box
  30943. */
  30944. static CreatePlane(options: {
  30945. size?: number;
  30946. width?: number;
  30947. height?: number;
  30948. sideOrientation?: number;
  30949. frontUVs?: Vector4;
  30950. backUVs?: Vector4;
  30951. }): VertexData;
  30952. /**
  30953. * Creates the VertexData of the Disc or regular Polygon
  30954. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  30955. * * radius the radius of the disc, optional default 0.5
  30956. * * tessellation the number of polygon sides, optional, default 64
  30957. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  30958. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30959. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30960. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30961. * @returns the VertexData of the box
  30962. */
  30963. static CreateDisc(options: {
  30964. radius?: number;
  30965. tessellation?: number;
  30966. arc?: number;
  30967. sideOrientation?: number;
  30968. frontUVs?: Vector4;
  30969. backUVs?: Vector4;
  30970. }): VertexData;
  30971. /**
  30972. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  30973. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  30974. * @param polygon a mesh built from polygonTriangulation.build()
  30975. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30976. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30977. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30978. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30979. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30980. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  30981. * @returns the VertexData of the Polygon
  30982. */
  30983. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  30984. /**
  30985. * Creates the VertexData of the IcoSphere
  30986. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  30987. * * radius the radius of the IcoSphere, optional default 1
  30988. * * radiusX allows stretching in the x direction, optional, default radius
  30989. * * radiusY allows stretching in the y direction, optional, default radius
  30990. * * radiusZ allows stretching in the z direction, optional, default radius
  30991. * * flat when true creates a flat shaded mesh, optional, default true
  30992. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  30993. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30994. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30995. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30996. * @returns the VertexData of the IcoSphere
  30997. */
  30998. static CreateIcoSphere(options: {
  30999. radius?: number;
  31000. radiusX?: number;
  31001. radiusY?: number;
  31002. radiusZ?: number;
  31003. flat?: boolean;
  31004. subdivisions?: number;
  31005. sideOrientation?: number;
  31006. frontUVs?: Vector4;
  31007. backUVs?: Vector4;
  31008. }): VertexData;
  31009. /**
  31010. * Creates the VertexData for a Polyhedron
  31011. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  31012. * * type provided types are:
  31013. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  31014. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  31015. * * size the size of the IcoSphere, optional default 1
  31016. * * sizeX allows stretching in the x direction, optional, default size
  31017. * * sizeY allows stretching in the y direction, optional, default size
  31018. * * sizeZ allows stretching in the z direction, optional, default size
  31019. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  31020. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31021. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31022. * * flat when true creates a flat shaded mesh, optional, default true
  31023. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31024. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31025. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  31026. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  31027. * @returns the VertexData of the Polyhedron
  31028. */
  31029. static CreatePolyhedron(options: {
  31030. type?: number;
  31031. size?: number;
  31032. sizeX?: number;
  31033. sizeY?: number;
  31034. sizeZ?: number;
  31035. custom?: any;
  31036. faceUV?: Vector4[];
  31037. faceColors?: Color4[];
  31038. flat?: boolean;
  31039. sideOrientation?: number;
  31040. frontUVs?: Vector4;
  31041. backUVs?: Vector4;
  31042. }): VertexData;
  31043. /**
  31044. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  31045. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  31046. * @returns the VertexData of the Capsule
  31047. */
  31048. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  31049. /**
  31050. * Creates the VertexData for a TorusKnot
  31051. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  31052. * * radius the radius of the torus knot, optional, default 2
  31053. * * tube the thickness of the tube, optional, default 0.5
  31054. * * radialSegments the number of sides on each tube segments, optional, default 32
  31055. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  31056. * * p the number of windings around the z axis, optional, default 2
  31057. * * q the number of windings around the x axis, optional, default 3
  31058. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31059. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  31060. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  31061. * @returns the VertexData of the Torus Knot
  31062. */
  31063. static CreateTorusKnot(options: {
  31064. radius?: number;
  31065. tube?: number;
  31066. radialSegments?: number;
  31067. tubularSegments?: number;
  31068. p?: number;
  31069. q?: number;
  31070. sideOrientation?: number;
  31071. frontUVs?: Vector4;
  31072. backUVs?: Vector4;
  31073. }): VertexData;
  31074. /**
  31075. * Compute normals for given positions and indices
  31076. * @param positions an array of vertex positions, [...., x, y, z, ......]
  31077. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  31078. * @param normals an array of vertex normals, [...., x, y, z, ......]
  31079. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  31080. * * facetNormals : optional array of facet normals (vector3)
  31081. * * facetPositions : optional array of facet positions (vector3)
  31082. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  31083. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  31084. * * bInfo : optional bounding info, required for facetPartitioning computation
  31085. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  31086. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  31087. * * useRightHandedSystem: optional boolean to for right handed system computation
  31088. * * depthSort : optional boolean to enable the facet depth sort computation
  31089. * * distanceTo : optional Vector3 to compute the facet depth from this location
  31090. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  31091. */
  31092. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  31093. facetNormals?: any;
  31094. facetPositions?: any;
  31095. facetPartitioning?: any;
  31096. ratio?: number;
  31097. bInfo?: any;
  31098. bbSize?: Vector3;
  31099. subDiv?: any;
  31100. useRightHandedSystem?: boolean;
  31101. depthSort?: boolean;
  31102. distanceTo?: Vector3;
  31103. depthSortedFacets?: any;
  31104. }): void;
  31105. /** @hidden */
  31106. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  31107. /**
  31108. * Applies VertexData created from the imported parameters to the geometry
  31109. * @param parsedVertexData the parsed data from an imported file
  31110. * @param geometry the geometry to apply the VertexData to
  31111. */
  31112. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  31113. }
  31114. }
  31115. declare module BABYLON {
  31116. /**
  31117. * Defines a target to use with MorphTargetManager
  31118. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31119. */
  31120. export class MorphTarget implements IAnimatable {
  31121. /** defines the name of the target */
  31122. name: string;
  31123. /**
  31124. * Gets or sets the list of animations
  31125. */
  31126. animations: Animation[];
  31127. private _scene;
  31128. private _positions;
  31129. private _normals;
  31130. private _tangents;
  31131. private _uvs;
  31132. private _influence;
  31133. private _uniqueId;
  31134. /**
  31135. * Observable raised when the influence changes
  31136. */
  31137. onInfluenceChanged: Observable<boolean>;
  31138. /** @hidden */
  31139. _onDataLayoutChanged: Observable<void>;
  31140. /**
  31141. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31142. */
  31143. get influence(): number;
  31144. set influence(influence: number);
  31145. /**
  31146. * Gets or sets the id of the morph Target
  31147. */
  31148. id: string;
  31149. private _animationPropertiesOverride;
  31150. /**
  31151. * Gets or sets the animation properties override
  31152. */
  31153. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31154. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31155. /**
  31156. * Creates a new MorphTarget
  31157. * @param name defines the name of the target
  31158. * @param influence defines the influence to use
  31159. * @param scene defines the scene the morphtarget belongs to
  31160. */
  31161. constructor(
  31162. /** defines the name of the target */
  31163. name: string, influence?: number, scene?: Nullable<Scene>);
  31164. /**
  31165. * Gets the unique ID of this manager
  31166. */
  31167. get uniqueId(): number;
  31168. /**
  31169. * Gets a boolean defining if the target contains position data
  31170. */
  31171. get hasPositions(): boolean;
  31172. /**
  31173. * Gets a boolean defining if the target contains normal data
  31174. */
  31175. get hasNormals(): boolean;
  31176. /**
  31177. * Gets a boolean defining if the target contains tangent data
  31178. */
  31179. get hasTangents(): boolean;
  31180. /**
  31181. * Gets a boolean defining if the target contains texture coordinates data
  31182. */
  31183. get hasUVs(): boolean;
  31184. /**
  31185. * Affects position data to this target
  31186. * @param data defines the position data to use
  31187. */
  31188. setPositions(data: Nullable<FloatArray>): void;
  31189. /**
  31190. * Gets the position data stored in this target
  31191. * @returns a FloatArray containing the position data (or null if not present)
  31192. */
  31193. getPositions(): Nullable<FloatArray>;
  31194. /**
  31195. * Affects normal data to this target
  31196. * @param data defines the normal data to use
  31197. */
  31198. setNormals(data: Nullable<FloatArray>): void;
  31199. /**
  31200. * Gets the normal data stored in this target
  31201. * @returns a FloatArray containing the normal data (or null if not present)
  31202. */
  31203. getNormals(): Nullable<FloatArray>;
  31204. /**
  31205. * Affects tangent data to this target
  31206. * @param data defines the tangent data to use
  31207. */
  31208. setTangents(data: Nullable<FloatArray>): void;
  31209. /**
  31210. * Gets the tangent data stored in this target
  31211. * @returns a FloatArray containing the tangent data (or null if not present)
  31212. */
  31213. getTangents(): Nullable<FloatArray>;
  31214. /**
  31215. * Affects texture coordinates data to this target
  31216. * @param data defines the texture coordinates data to use
  31217. */
  31218. setUVs(data: Nullable<FloatArray>): void;
  31219. /**
  31220. * Gets the texture coordinates data stored in this target
  31221. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31222. */
  31223. getUVs(): Nullable<FloatArray>;
  31224. /**
  31225. * Clone the current target
  31226. * @returns a new MorphTarget
  31227. */
  31228. clone(): MorphTarget;
  31229. /**
  31230. * Serializes the current target into a Serialization object
  31231. * @returns the serialized object
  31232. */
  31233. serialize(): any;
  31234. /**
  31235. * Returns the string "MorphTarget"
  31236. * @returns "MorphTarget"
  31237. */
  31238. getClassName(): string;
  31239. /**
  31240. * Creates a new target from serialized data
  31241. * @param serializationObject defines the serialized data to use
  31242. * @returns a new MorphTarget
  31243. */
  31244. static Parse(serializationObject: any): MorphTarget;
  31245. /**
  31246. * Creates a MorphTarget from mesh data
  31247. * @param mesh defines the source mesh
  31248. * @param name defines the name to use for the new target
  31249. * @param influence defines the influence to attach to the target
  31250. * @returns a new MorphTarget
  31251. */
  31252. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31253. }
  31254. }
  31255. declare module BABYLON {
  31256. /**
  31257. * This class is used to deform meshes using morphing between different targets
  31258. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31259. */
  31260. export class MorphTargetManager {
  31261. private _targets;
  31262. private _targetInfluenceChangedObservers;
  31263. private _targetDataLayoutChangedObservers;
  31264. private _activeTargets;
  31265. private _scene;
  31266. private _influences;
  31267. private _supportsNormals;
  31268. private _supportsTangents;
  31269. private _supportsUVs;
  31270. private _vertexCount;
  31271. private _uniqueId;
  31272. private _tempInfluences;
  31273. /**
  31274. * Gets or sets a boolean indicating if normals must be morphed
  31275. */
  31276. enableNormalMorphing: boolean;
  31277. /**
  31278. * Gets or sets a boolean indicating if tangents must be morphed
  31279. */
  31280. enableTangentMorphing: boolean;
  31281. /**
  31282. * Gets or sets a boolean indicating if UV must be morphed
  31283. */
  31284. enableUVMorphing: boolean;
  31285. /**
  31286. * Creates a new MorphTargetManager
  31287. * @param scene defines the current scene
  31288. */
  31289. constructor(scene?: Nullable<Scene>);
  31290. /**
  31291. * Gets the unique ID of this manager
  31292. */
  31293. get uniqueId(): number;
  31294. /**
  31295. * Gets the number of vertices handled by this manager
  31296. */
  31297. get vertexCount(): number;
  31298. /**
  31299. * Gets a boolean indicating if this manager supports morphing of normals
  31300. */
  31301. get supportsNormals(): boolean;
  31302. /**
  31303. * Gets a boolean indicating if this manager supports morphing of tangents
  31304. */
  31305. get supportsTangents(): boolean;
  31306. /**
  31307. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31308. */
  31309. get supportsUVs(): boolean;
  31310. /**
  31311. * Gets the number of targets stored in this manager
  31312. */
  31313. get numTargets(): number;
  31314. /**
  31315. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31316. */
  31317. get numInfluencers(): number;
  31318. /**
  31319. * Gets the list of influences (one per target)
  31320. */
  31321. get influences(): Float32Array;
  31322. /**
  31323. * Gets the active target at specified index. An active target is a target with an influence > 0
  31324. * @param index defines the index to check
  31325. * @returns the requested target
  31326. */
  31327. getActiveTarget(index: number): MorphTarget;
  31328. /**
  31329. * Gets the target at specified index
  31330. * @param index defines the index to check
  31331. * @returns the requested target
  31332. */
  31333. getTarget(index: number): MorphTarget;
  31334. /**
  31335. * Add a new target to this manager
  31336. * @param target defines the target to add
  31337. */
  31338. addTarget(target: MorphTarget): void;
  31339. /**
  31340. * Removes a target from the manager
  31341. * @param target defines the target to remove
  31342. */
  31343. removeTarget(target: MorphTarget): void;
  31344. /**
  31345. * Clone the current manager
  31346. * @returns a new MorphTargetManager
  31347. */
  31348. clone(): MorphTargetManager;
  31349. /**
  31350. * Serializes the current manager into a Serialization object
  31351. * @returns the serialized object
  31352. */
  31353. serialize(): any;
  31354. private _syncActiveTargets;
  31355. /**
  31356. * Syncrhonize the targets with all the meshes using this morph target manager
  31357. */
  31358. synchronize(): void;
  31359. /**
  31360. * Creates a new MorphTargetManager from serialized data
  31361. * @param serializationObject defines the serialized data
  31362. * @param scene defines the hosting scene
  31363. * @returns the new MorphTargetManager
  31364. */
  31365. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31366. }
  31367. }
  31368. declare module BABYLON {
  31369. /**
  31370. * Class used to represent a specific level of detail of a mesh
  31371. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31372. */
  31373. export class MeshLODLevel {
  31374. /** Defines the distance where this level should start being displayed */
  31375. distance: number;
  31376. /** Defines the mesh to use to render this level */
  31377. mesh: Nullable<Mesh>;
  31378. /**
  31379. * Creates a new LOD level
  31380. * @param distance defines the distance where this level should star being displayed
  31381. * @param mesh defines the mesh to use to render this level
  31382. */
  31383. constructor(
  31384. /** Defines the distance where this level should start being displayed */
  31385. distance: number,
  31386. /** Defines the mesh to use to render this level */
  31387. mesh: Nullable<Mesh>);
  31388. }
  31389. }
  31390. declare module BABYLON {
  31391. /**
  31392. * Helper class used to generate a canvas to manipulate images
  31393. */
  31394. export class CanvasGenerator {
  31395. /**
  31396. * Create a new canvas (or offscreen canvas depending on the context)
  31397. * @param width defines the expected width
  31398. * @param height defines the expected height
  31399. * @return a new canvas or offscreen canvas
  31400. */
  31401. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31402. }
  31403. }
  31404. declare module BABYLON {
  31405. /**
  31406. * Mesh representing the gorund
  31407. */
  31408. export class GroundMesh extends Mesh {
  31409. /** If octree should be generated */
  31410. generateOctree: boolean;
  31411. private _heightQuads;
  31412. /** @hidden */
  31413. _subdivisionsX: number;
  31414. /** @hidden */
  31415. _subdivisionsY: number;
  31416. /** @hidden */
  31417. _width: number;
  31418. /** @hidden */
  31419. _height: number;
  31420. /** @hidden */
  31421. _minX: number;
  31422. /** @hidden */
  31423. _maxX: number;
  31424. /** @hidden */
  31425. _minZ: number;
  31426. /** @hidden */
  31427. _maxZ: number;
  31428. constructor(name: string, scene: Scene);
  31429. /**
  31430. * "GroundMesh"
  31431. * @returns "GroundMesh"
  31432. */
  31433. getClassName(): string;
  31434. /**
  31435. * The minimum of x and y subdivisions
  31436. */
  31437. get subdivisions(): number;
  31438. /**
  31439. * X subdivisions
  31440. */
  31441. get subdivisionsX(): number;
  31442. /**
  31443. * Y subdivisions
  31444. */
  31445. get subdivisionsY(): number;
  31446. /**
  31447. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31448. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31449. * @param chunksCount the number of subdivisions for x and y
  31450. * @param octreeBlocksSize (Default: 32)
  31451. */
  31452. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31453. /**
  31454. * Returns a height (y) value in the Worl system :
  31455. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31456. * @param x x coordinate
  31457. * @param z z coordinate
  31458. * @returns the ground y position if (x, z) are outside the ground surface.
  31459. */
  31460. getHeightAtCoordinates(x: number, z: number): number;
  31461. /**
  31462. * Returns a normalized vector (Vector3) orthogonal to the ground
  31463. * at the ground coordinates (x, z) expressed in the World system.
  31464. * @param x x coordinate
  31465. * @param z z coordinate
  31466. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31467. */
  31468. getNormalAtCoordinates(x: number, z: number): Vector3;
  31469. /**
  31470. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31471. * at the ground coordinates (x, z) expressed in the World system.
  31472. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31473. * @param x x coordinate
  31474. * @param z z coordinate
  31475. * @param ref vector to store the result
  31476. * @returns the GroundMesh.
  31477. */
  31478. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31479. /**
  31480. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31481. * if the ground has been updated.
  31482. * This can be used in the render loop.
  31483. * @returns the GroundMesh.
  31484. */
  31485. updateCoordinateHeights(): GroundMesh;
  31486. private _getFacetAt;
  31487. private _initHeightQuads;
  31488. private _computeHeightQuads;
  31489. /**
  31490. * Serializes this ground mesh
  31491. * @param serializationObject object to write serialization to
  31492. */
  31493. serialize(serializationObject: any): void;
  31494. /**
  31495. * Parses a serialized ground mesh
  31496. * @param parsedMesh the serialized mesh
  31497. * @param scene the scene to create the ground mesh in
  31498. * @returns the created ground mesh
  31499. */
  31500. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31501. }
  31502. }
  31503. declare module BABYLON {
  31504. /**
  31505. * Interface for Physics-Joint data
  31506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31507. */
  31508. export interface PhysicsJointData {
  31509. /**
  31510. * The main pivot of the joint
  31511. */
  31512. mainPivot?: Vector3;
  31513. /**
  31514. * The connected pivot of the joint
  31515. */
  31516. connectedPivot?: Vector3;
  31517. /**
  31518. * The main axis of the joint
  31519. */
  31520. mainAxis?: Vector3;
  31521. /**
  31522. * The connected axis of the joint
  31523. */
  31524. connectedAxis?: Vector3;
  31525. /**
  31526. * The collision of the joint
  31527. */
  31528. collision?: boolean;
  31529. /**
  31530. * Native Oimo/Cannon/Energy data
  31531. */
  31532. nativeParams?: any;
  31533. }
  31534. /**
  31535. * This is a holder class for the physics joint created by the physics plugin
  31536. * It holds a set of functions to control the underlying joint
  31537. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31538. */
  31539. export class PhysicsJoint {
  31540. /**
  31541. * The type of the physics joint
  31542. */
  31543. type: number;
  31544. /**
  31545. * The data for the physics joint
  31546. */
  31547. jointData: PhysicsJointData;
  31548. private _physicsJoint;
  31549. protected _physicsPlugin: IPhysicsEnginePlugin;
  31550. /**
  31551. * Initializes the physics joint
  31552. * @param type The type of the physics joint
  31553. * @param jointData The data for the physics joint
  31554. */
  31555. constructor(
  31556. /**
  31557. * The type of the physics joint
  31558. */
  31559. type: number,
  31560. /**
  31561. * The data for the physics joint
  31562. */
  31563. jointData: PhysicsJointData);
  31564. /**
  31565. * Gets the physics joint
  31566. */
  31567. get physicsJoint(): any;
  31568. /**
  31569. * Sets the physics joint
  31570. */
  31571. set physicsJoint(newJoint: any);
  31572. /**
  31573. * Sets the physics plugin
  31574. */
  31575. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31576. /**
  31577. * Execute a function that is physics-plugin specific.
  31578. * @param {Function} func the function that will be executed.
  31579. * It accepts two parameters: the physics world and the physics joint
  31580. */
  31581. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31582. /**
  31583. * Distance-Joint type
  31584. */
  31585. static DistanceJoint: number;
  31586. /**
  31587. * Hinge-Joint type
  31588. */
  31589. static HingeJoint: number;
  31590. /**
  31591. * Ball-and-Socket joint type
  31592. */
  31593. static BallAndSocketJoint: number;
  31594. /**
  31595. * Wheel-Joint type
  31596. */
  31597. static WheelJoint: number;
  31598. /**
  31599. * Slider-Joint type
  31600. */
  31601. static SliderJoint: number;
  31602. /**
  31603. * Prismatic-Joint type
  31604. */
  31605. static PrismaticJoint: number;
  31606. /**
  31607. * Universal-Joint type
  31608. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31609. */
  31610. static UniversalJoint: number;
  31611. /**
  31612. * Hinge-Joint 2 type
  31613. */
  31614. static Hinge2Joint: number;
  31615. /**
  31616. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31617. */
  31618. static PointToPointJoint: number;
  31619. /**
  31620. * Spring-Joint type
  31621. */
  31622. static SpringJoint: number;
  31623. /**
  31624. * Lock-Joint type
  31625. */
  31626. static LockJoint: number;
  31627. }
  31628. /**
  31629. * A class representing a physics distance joint
  31630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31631. */
  31632. export class DistanceJoint extends PhysicsJoint {
  31633. /**
  31634. *
  31635. * @param jointData The data for the Distance-Joint
  31636. */
  31637. constructor(jointData: DistanceJointData);
  31638. /**
  31639. * Update the predefined distance.
  31640. * @param maxDistance The maximum preferred distance
  31641. * @param minDistance The minimum preferred distance
  31642. */
  31643. updateDistance(maxDistance: number, minDistance?: number): void;
  31644. }
  31645. /**
  31646. * Represents a Motor-Enabled Joint
  31647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31648. */
  31649. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31650. /**
  31651. * Initializes the Motor-Enabled Joint
  31652. * @param type The type of the joint
  31653. * @param jointData The physica joint data for the joint
  31654. */
  31655. constructor(type: number, jointData: PhysicsJointData);
  31656. /**
  31657. * Set the motor values.
  31658. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31659. * @param force the force to apply
  31660. * @param maxForce max force for this motor.
  31661. */
  31662. setMotor(force?: number, maxForce?: number): void;
  31663. /**
  31664. * Set the motor's limits.
  31665. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31666. * @param upperLimit The upper limit of the motor
  31667. * @param lowerLimit The lower limit of the motor
  31668. */
  31669. setLimit(upperLimit: number, lowerLimit?: number): void;
  31670. }
  31671. /**
  31672. * This class represents a single physics Hinge-Joint
  31673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31674. */
  31675. export class HingeJoint extends MotorEnabledJoint {
  31676. /**
  31677. * Initializes the Hinge-Joint
  31678. * @param jointData The joint data for the Hinge-Joint
  31679. */
  31680. constructor(jointData: PhysicsJointData);
  31681. /**
  31682. * Set the motor values.
  31683. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31684. * @param {number} force the force to apply
  31685. * @param {number} maxForce max force for this motor.
  31686. */
  31687. setMotor(force?: number, maxForce?: number): void;
  31688. /**
  31689. * Set the motor's limits.
  31690. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31691. * @param upperLimit The upper limit of the motor
  31692. * @param lowerLimit The lower limit of the motor
  31693. */
  31694. setLimit(upperLimit: number, lowerLimit?: number): void;
  31695. }
  31696. /**
  31697. * This class represents a dual hinge physics joint (same as wheel joint)
  31698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31699. */
  31700. export class Hinge2Joint extends MotorEnabledJoint {
  31701. /**
  31702. * Initializes the Hinge2-Joint
  31703. * @param jointData The joint data for the Hinge2-Joint
  31704. */
  31705. constructor(jointData: PhysicsJointData);
  31706. /**
  31707. * Set the motor values.
  31708. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31709. * @param {number} targetSpeed the speed the motor is to reach
  31710. * @param {number} maxForce max force for this motor.
  31711. * @param {motorIndex} the motor's index, 0 or 1.
  31712. */
  31713. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31714. /**
  31715. * Set the motor limits.
  31716. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31717. * @param {number} upperLimit the upper limit
  31718. * @param {number} lowerLimit lower limit
  31719. * @param {motorIndex} the motor's index, 0 or 1.
  31720. */
  31721. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31722. }
  31723. /**
  31724. * Interface for a motor enabled joint
  31725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31726. */
  31727. export interface IMotorEnabledJoint {
  31728. /**
  31729. * Physics joint
  31730. */
  31731. physicsJoint: any;
  31732. /**
  31733. * Sets the motor of the motor-enabled joint
  31734. * @param force The force of the motor
  31735. * @param maxForce The maximum force of the motor
  31736. * @param motorIndex The index of the motor
  31737. */
  31738. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31739. /**
  31740. * Sets the limit of the motor
  31741. * @param upperLimit The upper limit of the motor
  31742. * @param lowerLimit The lower limit of the motor
  31743. * @param motorIndex The index of the motor
  31744. */
  31745. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31746. }
  31747. /**
  31748. * Joint data for a Distance-Joint
  31749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31750. */
  31751. export interface DistanceJointData extends PhysicsJointData {
  31752. /**
  31753. * Max distance the 2 joint objects can be apart
  31754. */
  31755. maxDistance: number;
  31756. }
  31757. /**
  31758. * Joint data from a spring joint
  31759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31760. */
  31761. export interface SpringJointData extends PhysicsJointData {
  31762. /**
  31763. * Length of the spring
  31764. */
  31765. length: number;
  31766. /**
  31767. * Stiffness of the spring
  31768. */
  31769. stiffness: number;
  31770. /**
  31771. * Damping of the spring
  31772. */
  31773. damping: number;
  31774. /** this callback will be called when applying the force to the impostors. */
  31775. forceApplicationCallback: () => void;
  31776. }
  31777. }
  31778. declare module BABYLON {
  31779. /**
  31780. * Holds the data for the raycast result
  31781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31782. */
  31783. export class PhysicsRaycastResult {
  31784. private _hasHit;
  31785. private _hitDistance;
  31786. private _hitNormalWorld;
  31787. private _hitPointWorld;
  31788. private _rayFromWorld;
  31789. private _rayToWorld;
  31790. /**
  31791. * Gets if there was a hit
  31792. */
  31793. get hasHit(): boolean;
  31794. /**
  31795. * Gets the distance from the hit
  31796. */
  31797. get hitDistance(): number;
  31798. /**
  31799. * Gets the hit normal/direction in the world
  31800. */
  31801. get hitNormalWorld(): Vector3;
  31802. /**
  31803. * Gets the hit point in the world
  31804. */
  31805. get hitPointWorld(): Vector3;
  31806. /**
  31807. * Gets the ray "start point" of the ray in the world
  31808. */
  31809. get rayFromWorld(): Vector3;
  31810. /**
  31811. * Gets the ray "end point" of the ray in the world
  31812. */
  31813. get rayToWorld(): Vector3;
  31814. /**
  31815. * Sets the hit data (normal & point in world space)
  31816. * @param hitNormalWorld defines the normal in world space
  31817. * @param hitPointWorld defines the point in world space
  31818. */
  31819. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31820. /**
  31821. * Sets the distance from the start point to the hit point
  31822. * @param distance
  31823. */
  31824. setHitDistance(distance: number): void;
  31825. /**
  31826. * Calculates the distance manually
  31827. */
  31828. calculateHitDistance(): void;
  31829. /**
  31830. * Resets all the values to default
  31831. * @param from The from point on world space
  31832. * @param to The to point on world space
  31833. */
  31834. reset(from?: Vector3, to?: Vector3): void;
  31835. }
  31836. /**
  31837. * Interface for the size containing width and height
  31838. */
  31839. interface IXYZ {
  31840. /**
  31841. * X
  31842. */
  31843. x: number;
  31844. /**
  31845. * Y
  31846. */
  31847. y: number;
  31848. /**
  31849. * Z
  31850. */
  31851. z: number;
  31852. }
  31853. }
  31854. declare module BABYLON {
  31855. /**
  31856. * Interface used to describe a physics joint
  31857. */
  31858. export interface PhysicsImpostorJoint {
  31859. /** Defines the main impostor to which the joint is linked */
  31860. mainImpostor: PhysicsImpostor;
  31861. /** Defines the impostor that is connected to the main impostor using this joint */
  31862. connectedImpostor: PhysicsImpostor;
  31863. /** Defines the joint itself */
  31864. joint: PhysicsJoint;
  31865. }
  31866. /** @hidden */
  31867. export interface IPhysicsEnginePlugin {
  31868. world: any;
  31869. name: string;
  31870. setGravity(gravity: Vector3): void;
  31871. setTimeStep(timeStep: number): void;
  31872. getTimeStep(): number;
  31873. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31874. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31875. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31876. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31877. removePhysicsBody(impostor: PhysicsImpostor): void;
  31878. generateJoint(joint: PhysicsImpostorJoint): void;
  31879. removeJoint(joint: PhysicsImpostorJoint): void;
  31880. isSupported(): boolean;
  31881. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31882. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31883. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31884. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31885. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31886. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31887. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31888. getBodyMass(impostor: PhysicsImpostor): number;
  31889. getBodyFriction(impostor: PhysicsImpostor): number;
  31890. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31891. getBodyRestitution(impostor: PhysicsImpostor): number;
  31892. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31893. getBodyPressure?(impostor: PhysicsImpostor): number;
  31894. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31895. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31896. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31897. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31898. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31899. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31900. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31901. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31902. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31903. sleepBody(impostor: PhysicsImpostor): void;
  31904. wakeUpBody(impostor: PhysicsImpostor): void;
  31905. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31906. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31907. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31908. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31909. getRadius(impostor: PhysicsImpostor): number;
  31910. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31911. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31912. dispose(): void;
  31913. }
  31914. /**
  31915. * Interface used to define a physics engine
  31916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31917. */
  31918. export interface IPhysicsEngine {
  31919. /**
  31920. * Gets the gravity vector used by the simulation
  31921. */
  31922. gravity: Vector3;
  31923. /**
  31924. * Sets the gravity vector used by the simulation
  31925. * @param gravity defines the gravity vector to use
  31926. */
  31927. setGravity(gravity: Vector3): void;
  31928. /**
  31929. * Set the time step of the physics engine.
  31930. * Default is 1/60.
  31931. * To slow it down, enter 1/600 for example.
  31932. * To speed it up, 1/30
  31933. * @param newTimeStep the new timestep to apply to this world.
  31934. */
  31935. setTimeStep(newTimeStep: number): void;
  31936. /**
  31937. * Get the time step of the physics engine.
  31938. * @returns the current time step
  31939. */
  31940. getTimeStep(): number;
  31941. /**
  31942. * Set the sub time step of the physics engine.
  31943. * Default is 0 meaning there is no sub steps
  31944. * To increase physics resolution precision, set a small value (like 1 ms)
  31945. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31946. */
  31947. setSubTimeStep(subTimeStep: number): void;
  31948. /**
  31949. * Get the sub time step of the physics engine.
  31950. * @returns the current sub time step
  31951. */
  31952. getSubTimeStep(): number;
  31953. /**
  31954. * Release all resources
  31955. */
  31956. dispose(): void;
  31957. /**
  31958. * Gets the name of the current physics plugin
  31959. * @returns the name of the plugin
  31960. */
  31961. getPhysicsPluginName(): string;
  31962. /**
  31963. * Adding a new impostor for the impostor tracking.
  31964. * This will be done by the impostor itself.
  31965. * @param impostor the impostor to add
  31966. */
  31967. addImpostor(impostor: PhysicsImpostor): void;
  31968. /**
  31969. * Remove an impostor from the engine.
  31970. * This impostor and its mesh will not longer be updated by the physics engine.
  31971. * @param impostor the impostor to remove
  31972. */
  31973. removeImpostor(impostor: PhysicsImpostor): void;
  31974. /**
  31975. * Add a joint to the physics engine
  31976. * @param mainImpostor defines the main impostor to which the joint is added.
  31977. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31978. * @param joint defines the joint that will connect both impostors.
  31979. */
  31980. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31981. /**
  31982. * Removes a joint from the simulation
  31983. * @param mainImpostor defines the impostor used with the joint
  31984. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31985. * @param joint defines the joint to remove
  31986. */
  31987. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31988. /**
  31989. * Gets the current plugin used to run the simulation
  31990. * @returns current plugin
  31991. */
  31992. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31993. /**
  31994. * Gets the list of physic impostors
  31995. * @returns an array of PhysicsImpostor
  31996. */
  31997. getImpostors(): Array<PhysicsImpostor>;
  31998. /**
  31999. * Gets the impostor for a physics enabled object
  32000. * @param object defines the object impersonated by the impostor
  32001. * @returns the PhysicsImpostor or null if not found
  32002. */
  32003. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32004. /**
  32005. * Gets the impostor for a physics body object
  32006. * @param body defines physics body used by the impostor
  32007. * @returns the PhysicsImpostor or null if not found
  32008. */
  32009. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32010. /**
  32011. * Does a raycast in the physics world
  32012. * @param from when should the ray start?
  32013. * @param to when should the ray end?
  32014. * @returns PhysicsRaycastResult
  32015. */
  32016. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32017. /**
  32018. * Called by the scene. No need to call it.
  32019. * @param delta defines the timespam between frames
  32020. */
  32021. _step(delta: number): void;
  32022. }
  32023. }
  32024. declare module BABYLON {
  32025. /**
  32026. * The interface for the physics imposter parameters
  32027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32028. */
  32029. export interface PhysicsImpostorParameters {
  32030. /**
  32031. * The mass of the physics imposter
  32032. */
  32033. mass: number;
  32034. /**
  32035. * The friction of the physics imposter
  32036. */
  32037. friction?: number;
  32038. /**
  32039. * The coefficient of restitution of the physics imposter
  32040. */
  32041. restitution?: number;
  32042. /**
  32043. * The native options of the physics imposter
  32044. */
  32045. nativeOptions?: any;
  32046. /**
  32047. * Specifies if the parent should be ignored
  32048. */
  32049. ignoreParent?: boolean;
  32050. /**
  32051. * Specifies if bi-directional transformations should be disabled
  32052. */
  32053. disableBidirectionalTransformation?: boolean;
  32054. /**
  32055. * The pressure inside the physics imposter, soft object only
  32056. */
  32057. pressure?: number;
  32058. /**
  32059. * The stiffness the physics imposter, soft object only
  32060. */
  32061. stiffness?: number;
  32062. /**
  32063. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32064. */
  32065. velocityIterations?: number;
  32066. /**
  32067. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32068. */
  32069. positionIterations?: number;
  32070. /**
  32071. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32072. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32073. * Add to fix multiple points
  32074. */
  32075. fixedPoints?: number;
  32076. /**
  32077. * The collision margin around a soft object
  32078. */
  32079. margin?: number;
  32080. /**
  32081. * The collision margin around a soft object
  32082. */
  32083. damping?: number;
  32084. /**
  32085. * The path for a rope based on an extrusion
  32086. */
  32087. path?: any;
  32088. /**
  32089. * The shape of an extrusion used for a rope based on an extrusion
  32090. */
  32091. shape?: any;
  32092. }
  32093. /**
  32094. * Interface for a physics-enabled object
  32095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32096. */
  32097. export interface IPhysicsEnabledObject {
  32098. /**
  32099. * The position of the physics-enabled object
  32100. */
  32101. position: Vector3;
  32102. /**
  32103. * The rotation of the physics-enabled object
  32104. */
  32105. rotationQuaternion: Nullable<Quaternion>;
  32106. /**
  32107. * The scale of the physics-enabled object
  32108. */
  32109. scaling: Vector3;
  32110. /**
  32111. * The rotation of the physics-enabled object
  32112. */
  32113. rotation?: Vector3;
  32114. /**
  32115. * The parent of the physics-enabled object
  32116. */
  32117. parent?: any;
  32118. /**
  32119. * The bounding info of the physics-enabled object
  32120. * @returns The bounding info of the physics-enabled object
  32121. */
  32122. getBoundingInfo(): BoundingInfo;
  32123. /**
  32124. * Computes the world matrix
  32125. * @param force Specifies if the world matrix should be computed by force
  32126. * @returns A world matrix
  32127. */
  32128. computeWorldMatrix(force: boolean): Matrix;
  32129. /**
  32130. * Gets the world matrix
  32131. * @returns A world matrix
  32132. */
  32133. getWorldMatrix?(): Matrix;
  32134. /**
  32135. * Gets the child meshes
  32136. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32137. * @returns An array of abstract meshes
  32138. */
  32139. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32140. /**
  32141. * Gets the vertex data
  32142. * @param kind The type of vertex data
  32143. * @returns A nullable array of numbers, or a float32 array
  32144. */
  32145. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32146. /**
  32147. * Gets the indices from the mesh
  32148. * @returns A nullable array of index arrays
  32149. */
  32150. getIndices?(): Nullable<IndicesArray>;
  32151. /**
  32152. * Gets the scene from the mesh
  32153. * @returns the indices array or null
  32154. */
  32155. getScene?(): Scene;
  32156. /**
  32157. * Gets the absolute position from the mesh
  32158. * @returns the absolute position
  32159. */
  32160. getAbsolutePosition(): Vector3;
  32161. /**
  32162. * Gets the absolute pivot point from the mesh
  32163. * @returns the absolute pivot point
  32164. */
  32165. getAbsolutePivotPoint(): Vector3;
  32166. /**
  32167. * Rotates the mesh
  32168. * @param axis The axis of rotation
  32169. * @param amount The amount of rotation
  32170. * @param space The space of the rotation
  32171. * @returns The rotation transform node
  32172. */
  32173. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32174. /**
  32175. * Translates the mesh
  32176. * @param axis The axis of translation
  32177. * @param distance The distance of translation
  32178. * @param space The space of the translation
  32179. * @returns The transform node
  32180. */
  32181. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32182. /**
  32183. * Sets the absolute position of the mesh
  32184. * @param absolutePosition The absolute position of the mesh
  32185. * @returns The transform node
  32186. */
  32187. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32188. /**
  32189. * Gets the class name of the mesh
  32190. * @returns The class name
  32191. */
  32192. getClassName(): string;
  32193. }
  32194. /**
  32195. * Represents a physics imposter
  32196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32197. */
  32198. export class PhysicsImpostor {
  32199. /**
  32200. * The physics-enabled object used as the physics imposter
  32201. */
  32202. object: IPhysicsEnabledObject;
  32203. /**
  32204. * The type of the physics imposter
  32205. */
  32206. type: number;
  32207. private _options;
  32208. private _scene?;
  32209. /**
  32210. * The default object size of the imposter
  32211. */
  32212. static DEFAULT_OBJECT_SIZE: Vector3;
  32213. /**
  32214. * The identity quaternion of the imposter
  32215. */
  32216. static IDENTITY_QUATERNION: Quaternion;
  32217. /** @hidden */
  32218. _pluginData: any;
  32219. private _physicsEngine;
  32220. private _physicsBody;
  32221. private _bodyUpdateRequired;
  32222. private _onBeforePhysicsStepCallbacks;
  32223. private _onAfterPhysicsStepCallbacks;
  32224. /** @hidden */
  32225. _onPhysicsCollideCallbacks: Array<{
  32226. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32227. otherImpostors: Array<PhysicsImpostor>;
  32228. }>;
  32229. private _deltaPosition;
  32230. private _deltaRotation;
  32231. private _deltaRotationConjugated;
  32232. /** @hidden */
  32233. _isFromLine: boolean;
  32234. private _parent;
  32235. private _isDisposed;
  32236. private static _tmpVecs;
  32237. private static _tmpQuat;
  32238. /**
  32239. * Specifies if the physics imposter is disposed
  32240. */
  32241. get isDisposed(): boolean;
  32242. /**
  32243. * Gets the mass of the physics imposter
  32244. */
  32245. get mass(): number;
  32246. set mass(value: number);
  32247. /**
  32248. * Gets the coefficient of friction
  32249. */
  32250. get friction(): number;
  32251. /**
  32252. * Sets the coefficient of friction
  32253. */
  32254. set friction(value: number);
  32255. /**
  32256. * Gets the coefficient of restitution
  32257. */
  32258. get restitution(): number;
  32259. /**
  32260. * Sets the coefficient of restitution
  32261. */
  32262. set restitution(value: number);
  32263. /**
  32264. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32265. */
  32266. get pressure(): number;
  32267. /**
  32268. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32269. */
  32270. set pressure(value: number);
  32271. /**
  32272. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32273. */
  32274. get stiffness(): number;
  32275. /**
  32276. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32277. */
  32278. set stiffness(value: number);
  32279. /**
  32280. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32281. */
  32282. get velocityIterations(): number;
  32283. /**
  32284. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32285. */
  32286. set velocityIterations(value: number);
  32287. /**
  32288. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32289. */
  32290. get positionIterations(): number;
  32291. /**
  32292. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32293. */
  32294. set positionIterations(value: number);
  32295. /**
  32296. * The unique id of the physics imposter
  32297. * set by the physics engine when adding this impostor to the array
  32298. */
  32299. uniqueId: number;
  32300. /**
  32301. * @hidden
  32302. */
  32303. soft: boolean;
  32304. /**
  32305. * @hidden
  32306. */
  32307. segments: number;
  32308. private _joints;
  32309. /**
  32310. * Initializes the physics imposter
  32311. * @param object The physics-enabled object used as the physics imposter
  32312. * @param type The type of the physics imposter
  32313. * @param _options The options for the physics imposter
  32314. * @param _scene The Babylon scene
  32315. */
  32316. constructor(
  32317. /**
  32318. * The physics-enabled object used as the physics imposter
  32319. */
  32320. object: IPhysicsEnabledObject,
  32321. /**
  32322. * The type of the physics imposter
  32323. */
  32324. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32325. /**
  32326. * This function will completly initialize this impostor.
  32327. * It will create a new body - but only if this mesh has no parent.
  32328. * If it has, this impostor will not be used other than to define the impostor
  32329. * of the child mesh.
  32330. * @hidden
  32331. */
  32332. _init(): void;
  32333. private _getPhysicsParent;
  32334. /**
  32335. * Should a new body be generated.
  32336. * @returns boolean specifying if body initialization is required
  32337. */
  32338. isBodyInitRequired(): boolean;
  32339. /**
  32340. * Sets the updated scaling
  32341. * @param updated Specifies if the scaling is updated
  32342. */
  32343. setScalingUpdated(): void;
  32344. /**
  32345. * Force a regeneration of this or the parent's impostor's body.
  32346. * Use under cautious - This will remove all joints already implemented.
  32347. */
  32348. forceUpdate(): void;
  32349. /**
  32350. * Gets the body that holds this impostor. Either its own, or its parent.
  32351. */
  32352. get physicsBody(): any;
  32353. /**
  32354. * Get the parent of the physics imposter
  32355. * @returns Physics imposter or null
  32356. */
  32357. get parent(): Nullable<PhysicsImpostor>;
  32358. /**
  32359. * Sets the parent of the physics imposter
  32360. */
  32361. set parent(value: Nullable<PhysicsImpostor>);
  32362. /**
  32363. * Set the physics body. Used mainly by the physics engine/plugin
  32364. */
  32365. set physicsBody(physicsBody: any);
  32366. /**
  32367. * Resets the update flags
  32368. */
  32369. resetUpdateFlags(): void;
  32370. /**
  32371. * Gets the object extend size
  32372. * @returns the object extend size
  32373. */
  32374. getObjectExtendSize(): Vector3;
  32375. /**
  32376. * Gets the object center
  32377. * @returns The object center
  32378. */
  32379. getObjectCenter(): Vector3;
  32380. /**
  32381. * Get a specific parameter from the options parameters
  32382. * @param paramName The object parameter name
  32383. * @returns The object parameter
  32384. */
  32385. getParam(paramName: string): any;
  32386. /**
  32387. * Sets a specific parameter in the options given to the physics plugin
  32388. * @param paramName The parameter name
  32389. * @param value The value of the parameter
  32390. */
  32391. setParam(paramName: string, value: number): void;
  32392. /**
  32393. * Specifically change the body's mass option. Won't recreate the physics body object
  32394. * @param mass The mass of the physics imposter
  32395. */
  32396. setMass(mass: number): void;
  32397. /**
  32398. * Gets the linear velocity
  32399. * @returns linear velocity or null
  32400. */
  32401. getLinearVelocity(): Nullable<Vector3>;
  32402. /**
  32403. * Sets the linear velocity
  32404. * @param velocity linear velocity or null
  32405. */
  32406. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32407. /**
  32408. * Gets the angular velocity
  32409. * @returns angular velocity or null
  32410. */
  32411. getAngularVelocity(): Nullable<Vector3>;
  32412. /**
  32413. * Sets the angular velocity
  32414. * @param velocity The velocity or null
  32415. */
  32416. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32417. /**
  32418. * Execute a function with the physics plugin native code
  32419. * Provide a function the will have two variables - the world object and the physics body object
  32420. * @param func The function to execute with the physics plugin native code
  32421. */
  32422. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32423. /**
  32424. * Register a function that will be executed before the physics world is stepping forward
  32425. * @param func The function to execute before the physics world is stepped forward
  32426. */
  32427. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32428. /**
  32429. * Unregister a function that will be executed before the physics world is stepping forward
  32430. * @param func The function to execute before the physics world is stepped forward
  32431. */
  32432. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32433. /**
  32434. * Register a function that will be executed after the physics step
  32435. * @param func The function to execute after physics step
  32436. */
  32437. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32438. /**
  32439. * Unregisters a function that will be executed after the physics step
  32440. * @param func The function to execute after physics step
  32441. */
  32442. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32443. /**
  32444. * register a function that will be executed when this impostor collides against a different body
  32445. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32446. * @param func Callback that is executed on collision
  32447. */
  32448. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32449. /**
  32450. * Unregisters the physics imposter on contact
  32451. * @param collideAgainst The physics object to collide against
  32452. * @param func Callback to execute on collision
  32453. */
  32454. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32455. private _tmpQuat;
  32456. private _tmpQuat2;
  32457. /**
  32458. * Get the parent rotation
  32459. * @returns The parent rotation
  32460. */
  32461. getParentsRotation(): Quaternion;
  32462. /**
  32463. * this function is executed by the physics engine.
  32464. */
  32465. beforeStep: () => void;
  32466. /**
  32467. * this function is executed by the physics engine
  32468. */
  32469. afterStep: () => void;
  32470. /**
  32471. * Legacy collision detection event support
  32472. */
  32473. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32474. /**
  32475. * event and body object due to cannon's event-based architecture.
  32476. */
  32477. onCollide: (e: {
  32478. body: any;
  32479. point: Nullable<Vector3>;
  32480. }) => void;
  32481. /**
  32482. * Apply a force
  32483. * @param force The force to apply
  32484. * @param contactPoint The contact point for the force
  32485. * @returns The physics imposter
  32486. */
  32487. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32488. /**
  32489. * Apply an impulse
  32490. * @param force The impulse force
  32491. * @param contactPoint The contact point for the impulse force
  32492. * @returns The physics imposter
  32493. */
  32494. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32495. /**
  32496. * A help function to create a joint
  32497. * @param otherImpostor A physics imposter used to create a joint
  32498. * @param jointType The type of joint
  32499. * @param jointData The data for the joint
  32500. * @returns The physics imposter
  32501. */
  32502. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32503. /**
  32504. * Add a joint to this impostor with a different impostor
  32505. * @param otherImpostor A physics imposter used to add a joint
  32506. * @param joint The joint to add
  32507. * @returns The physics imposter
  32508. */
  32509. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32510. /**
  32511. * Add an anchor to a cloth impostor
  32512. * @param otherImpostor rigid impostor to anchor to
  32513. * @param width ratio across width from 0 to 1
  32514. * @param height ratio up height from 0 to 1
  32515. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32516. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32517. * @returns impostor the soft imposter
  32518. */
  32519. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32520. /**
  32521. * Add a hook to a rope impostor
  32522. * @param otherImpostor rigid impostor to anchor to
  32523. * @param length ratio across rope from 0 to 1
  32524. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32525. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32526. * @returns impostor the rope imposter
  32527. */
  32528. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32529. /**
  32530. * Will keep this body still, in a sleep mode.
  32531. * @returns the physics imposter
  32532. */
  32533. sleep(): PhysicsImpostor;
  32534. /**
  32535. * Wake the body up.
  32536. * @returns The physics imposter
  32537. */
  32538. wakeUp(): PhysicsImpostor;
  32539. /**
  32540. * Clones the physics imposter
  32541. * @param newObject The physics imposter clones to this physics-enabled object
  32542. * @returns A nullable physics imposter
  32543. */
  32544. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32545. /**
  32546. * Disposes the physics imposter
  32547. */
  32548. dispose(): void;
  32549. /**
  32550. * Sets the delta position
  32551. * @param position The delta position amount
  32552. */
  32553. setDeltaPosition(position: Vector3): void;
  32554. /**
  32555. * Sets the delta rotation
  32556. * @param rotation The delta rotation amount
  32557. */
  32558. setDeltaRotation(rotation: Quaternion): void;
  32559. /**
  32560. * Gets the box size of the physics imposter and stores the result in the input parameter
  32561. * @param result Stores the box size
  32562. * @returns The physics imposter
  32563. */
  32564. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32565. /**
  32566. * Gets the radius of the physics imposter
  32567. * @returns Radius of the physics imposter
  32568. */
  32569. getRadius(): number;
  32570. /**
  32571. * Sync a bone with this impostor
  32572. * @param bone The bone to sync to the impostor.
  32573. * @param boneMesh The mesh that the bone is influencing.
  32574. * @param jointPivot The pivot of the joint / bone in local space.
  32575. * @param distToJoint Optional distance from the impostor to the joint.
  32576. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32577. */
  32578. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32579. /**
  32580. * Sync impostor to a bone
  32581. * @param bone The bone that the impostor will be synced to.
  32582. * @param boneMesh The mesh that the bone is influencing.
  32583. * @param jointPivot The pivot of the joint / bone in local space.
  32584. * @param distToJoint Optional distance from the impostor to the joint.
  32585. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32586. * @param boneAxis Optional vector3 axis the bone is aligned with
  32587. */
  32588. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32589. /**
  32590. * No-Imposter type
  32591. */
  32592. static NoImpostor: number;
  32593. /**
  32594. * Sphere-Imposter type
  32595. */
  32596. static SphereImpostor: number;
  32597. /**
  32598. * Box-Imposter type
  32599. */
  32600. static BoxImpostor: number;
  32601. /**
  32602. * Plane-Imposter type
  32603. */
  32604. static PlaneImpostor: number;
  32605. /**
  32606. * Mesh-imposter type
  32607. */
  32608. static MeshImpostor: number;
  32609. /**
  32610. * Capsule-Impostor type (Ammo.js plugin only)
  32611. */
  32612. static CapsuleImpostor: number;
  32613. /**
  32614. * Cylinder-Imposter type
  32615. */
  32616. static CylinderImpostor: number;
  32617. /**
  32618. * Particle-Imposter type
  32619. */
  32620. static ParticleImpostor: number;
  32621. /**
  32622. * Heightmap-Imposter type
  32623. */
  32624. static HeightmapImpostor: number;
  32625. /**
  32626. * ConvexHull-Impostor type (Ammo.js plugin only)
  32627. */
  32628. static ConvexHullImpostor: number;
  32629. /**
  32630. * Custom-Imposter type (Ammo.js plugin only)
  32631. */
  32632. static CustomImpostor: number;
  32633. /**
  32634. * Rope-Imposter type
  32635. */
  32636. static RopeImpostor: number;
  32637. /**
  32638. * Cloth-Imposter type
  32639. */
  32640. static ClothImpostor: number;
  32641. /**
  32642. * Softbody-Imposter type
  32643. */
  32644. static SoftbodyImpostor: number;
  32645. }
  32646. }
  32647. declare module BABYLON {
  32648. /**
  32649. * @hidden
  32650. **/
  32651. export class _CreationDataStorage {
  32652. closePath?: boolean;
  32653. closeArray?: boolean;
  32654. idx: number[];
  32655. dashSize: number;
  32656. gapSize: number;
  32657. path3D: Path3D;
  32658. pathArray: Vector3[][];
  32659. arc: number;
  32660. radius: number;
  32661. cap: number;
  32662. tessellation: number;
  32663. }
  32664. /**
  32665. * @hidden
  32666. **/
  32667. class _InstanceDataStorage {
  32668. visibleInstances: any;
  32669. batchCache: _InstancesBatch;
  32670. instancesBufferSize: number;
  32671. instancesBuffer: Nullable<Buffer>;
  32672. instancesData: Float32Array;
  32673. overridenInstanceCount: number;
  32674. isFrozen: boolean;
  32675. previousBatch: Nullable<_InstancesBatch>;
  32676. hardwareInstancedRendering: boolean;
  32677. sideOrientation: number;
  32678. manualUpdate: boolean;
  32679. previousRenderId: number;
  32680. }
  32681. /**
  32682. * @hidden
  32683. **/
  32684. export class _InstancesBatch {
  32685. mustReturn: boolean;
  32686. visibleInstances: Nullable<InstancedMesh[]>[];
  32687. renderSelf: boolean[];
  32688. hardwareInstancedRendering: boolean[];
  32689. }
  32690. /**
  32691. * @hidden
  32692. **/
  32693. class _ThinInstanceDataStorage {
  32694. instancesCount: number;
  32695. matrixBuffer: Nullable<Buffer>;
  32696. matrixBufferSize: number;
  32697. matrixData: Nullable<Float32Array>;
  32698. boundingVectors: Array<Vector3>;
  32699. worldMatrices: Nullable<Matrix[]>;
  32700. }
  32701. /**
  32702. * Class used to represent renderable models
  32703. */
  32704. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32705. /**
  32706. * Mesh side orientation : usually the external or front surface
  32707. */
  32708. static readonly FRONTSIDE: number;
  32709. /**
  32710. * Mesh side orientation : usually the internal or back surface
  32711. */
  32712. static readonly BACKSIDE: number;
  32713. /**
  32714. * Mesh side orientation : both internal and external or front and back surfaces
  32715. */
  32716. static readonly DOUBLESIDE: number;
  32717. /**
  32718. * Mesh side orientation : by default, `FRONTSIDE`
  32719. */
  32720. static readonly DEFAULTSIDE: number;
  32721. /**
  32722. * Mesh cap setting : no cap
  32723. */
  32724. static readonly NO_CAP: number;
  32725. /**
  32726. * Mesh cap setting : one cap at the beginning of the mesh
  32727. */
  32728. static readonly CAP_START: number;
  32729. /**
  32730. * Mesh cap setting : one cap at the end of the mesh
  32731. */
  32732. static readonly CAP_END: number;
  32733. /**
  32734. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32735. */
  32736. static readonly CAP_ALL: number;
  32737. /**
  32738. * Mesh pattern setting : no flip or rotate
  32739. */
  32740. static readonly NO_FLIP: number;
  32741. /**
  32742. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32743. */
  32744. static readonly FLIP_TILE: number;
  32745. /**
  32746. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32747. */
  32748. static readonly ROTATE_TILE: number;
  32749. /**
  32750. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32751. */
  32752. static readonly FLIP_ROW: number;
  32753. /**
  32754. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32755. */
  32756. static readonly ROTATE_ROW: number;
  32757. /**
  32758. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32759. */
  32760. static readonly FLIP_N_ROTATE_TILE: number;
  32761. /**
  32762. * Mesh pattern setting : rotate pattern and rotate
  32763. */
  32764. static readonly FLIP_N_ROTATE_ROW: number;
  32765. /**
  32766. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32767. */
  32768. static readonly CENTER: number;
  32769. /**
  32770. * Mesh tile positioning : part tiles on left
  32771. */
  32772. static readonly LEFT: number;
  32773. /**
  32774. * Mesh tile positioning : part tiles on right
  32775. */
  32776. static readonly RIGHT: number;
  32777. /**
  32778. * Mesh tile positioning : part tiles on top
  32779. */
  32780. static readonly TOP: number;
  32781. /**
  32782. * Mesh tile positioning : part tiles on bottom
  32783. */
  32784. static readonly BOTTOM: number;
  32785. /**
  32786. * Gets the default side orientation.
  32787. * @param orientation the orientation to value to attempt to get
  32788. * @returns the default orientation
  32789. * @hidden
  32790. */
  32791. static _GetDefaultSideOrientation(orientation?: number): number;
  32792. private _internalMeshDataInfo;
  32793. get computeBonesUsingShaders(): boolean;
  32794. set computeBonesUsingShaders(value: boolean);
  32795. /**
  32796. * An event triggered before rendering the mesh
  32797. */
  32798. get onBeforeRenderObservable(): Observable<Mesh>;
  32799. /**
  32800. * An event triggered before binding the mesh
  32801. */
  32802. get onBeforeBindObservable(): Observable<Mesh>;
  32803. /**
  32804. * An event triggered after rendering the mesh
  32805. */
  32806. get onAfterRenderObservable(): Observable<Mesh>;
  32807. /**
  32808. * An event triggered before drawing the mesh
  32809. */
  32810. get onBeforeDrawObservable(): Observable<Mesh>;
  32811. private _onBeforeDrawObserver;
  32812. /**
  32813. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32814. */
  32815. set onBeforeDraw(callback: () => void);
  32816. get hasInstances(): boolean;
  32817. get hasThinInstances(): boolean;
  32818. /**
  32819. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32820. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32821. */
  32822. delayLoadState: number;
  32823. /**
  32824. * Gets the list of instances created from this mesh
  32825. * it is not supposed to be modified manually.
  32826. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32827. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32828. */
  32829. instances: InstancedMesh[];
  32830. /**
  32831. * Gets the file containing delay loading data for this mesh
  32832. */
  32833. delayLoadingFile: string;
  32834. /** @hidden */
  32835. _binaryInfo: any;
  32836. /**
  32837. * User defined function used to change how LOD level selection is done
  32838. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32839. */
  32840. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32841. /**
  32842. * Gets or sets the morph target manager
  32843. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32844. */
  32845. get morphTargetManager(): Nullable<MorphTargetManager>;
  32846. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32847. /** @hidden */
  32848. _creationDataStorage: Nullable<_CreationDataStorage>;
  32849. /** @hidden */
  32850. _geometry: Nullable<Geometry>;
  32851. /** @hidden */
  32852. _delayInfo: Array<string>;
  32853. /** @hidden */
  32854. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32855. /** @hidden */
  32856. _instanceDataStorage: _InstanceDataStorage;
  32857. /** @hidden */
  32858. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32859. private _effectiveMaterial;
  32860. /** @hidden */
  32861. _shouldGenerateFlatShading: boolean;
  32862. /** @hidden */
  32863. _originalBuilderSideOrientation: number;
  32864. /**
  32865. * Use this property to change the original side orientation defined at construction time
  32866. */
  32867. overrideMaterialSideOrientation: Nullable<number>;
  32868. /**
  32869. * Gets the source mesh (the one used to clone this one from)
  32870. */
  32871. get source(): Nullable<Mesh>;
  32872. /**
  32873. * Gets the list of clones of this mesh
  32874. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32875. * Note that useClonedMeshMap=true is the default setting
  32876. */
  32877. get cloneMeshMap(): Nullable<{
  32878. [id: string]: Mesh | undefined;
  32879. }>;
  32880. /**
  32881. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32882. */
  32883. get isUnIndexed(): boolean;
  32884. set isUnIndexed(value: boolean);
  32885. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32886. get worldMatrixInstancedBuffer(): Float32Array;
  32887. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32888. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32889. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32890. /**
  32891. * @constructor
  32892. * @param name The value used by scene.getMeshByName() to do a lookup.
  32893. * @param scene The scene to add this mesh to.
  32894. * @param parent The parent of this mesh, if it has one
  32895. * @param source An optional Mesh from which geometry is shared, cloned.
  32896. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32897. * When false, achieved by calling a clone(), also passing False.
  32898. * This will make creation of children, recursive.
  32899. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32900. */
  32901. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32902. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32903. doNotInstantiate: boolean;
  32904. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32905. /**
  32906. * Gets the class name
  32907. * @returns the string "Mesh".
  32908. */
  32909. getClassName(): string;
  32910. /** @hidden */
  32911. get _isMesh(): boolean;
  32912. /**
  32913. * Returns a description of this mesh
  32914. * @param fullDetails define if full details about this mesh must be used
  32915. * @returns a descriptive string representing this mesh
  32916. */
  32917. toString(fullDetails?: boolean): string;
  32918. /** @hidden */
  32919. _unBindEffect(): void;
  32920. /**
  32921. * Gets a boolean indicating if this mesh has LOD
  32922. */
  32923. get hasLODLevels(): boolean;
  32924. /**
  32925. * Gets the list of MeshLODLevel associated with the current mesh
  32926. * @returns an array of MeshLODLevel
  32927. */
  32928. getLODLevels(): MeshLODLevel[];
  32929. private _sortLODLevels;
  32930. /**
  32931. * Add a mesh as LOD level triggered at the given distance.
  32932. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32933. * @param distance The distance from the center of the object to show this level
  32934. * @param mesh The mesh to be added as LOD level (can be null)
  32935. * @return This mesh (for chaining)
  32936. */
  32937. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32938. /**
  32939. * Returns the LOD level mesh at the passed distance or null if not found.
  32940. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32941. * @param distance The distance from the center of the object to show this level
  32942. * @returns a Mesh or `null`
  32943. */
  32944. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32945. /**
  32946. * Remove a mesh from the LOD array
  32947. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32948. * @param mesh defines the mesh to be removed
  32949. * @return This mesh (for chaining)
  32950. */
  32951. removeLODLevel(mesh: Mesh): Mesh;
  32952. /**
  32953. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32954. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32955. * @param camera defines the camera to use to compute distance
  32956. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32957. * @return This mesh (for chaining)
  32958. */
  32959. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32960. /**
  32961. * Gets the mesh internal Geometry object
  32962. */
  32963. get geometry(): Nullable<Geometry>;
  32964. /**
  32965. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32966. * @returns the total number of vertices
  32967. */
  32968. getTotalVertices(): number;
  32969. /**
  32970. * Returns the content of an associated vertex buffer
  32971. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32972. * - VertexBuffer.PositionKind
  32973. * - VertexBuffer.UVKind
  32974. * - VertexBuffer.UV2Kind
  32975. * - VertexBuffer.UV3Kind
  32976. * - VertexBuffer.UV4Kind
  32977. * - VertexBuffer.UV5Kind
  32978. * - VertexBuffer.UV6Kind
  32979. * - VertexBuffer.ColorKind
  32980. * - VertexBuffer.MatricesIndicesKind
  32981. * - VertexBuffer.MatricesIndicesExtraKind
  32982. * - VertexBuffer.MatricesWeightsKind
  32983. * - VertexBuffer.MatricesWeightsExtraKind
  32984. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  32985. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32986. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32987. */
  32988. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32989. /**
  32990. * Returns the mesh VertexBuffer object from the requested `kind`
  32991. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32992. * - VertexBuffer.PositionKind
  32993. * - VertexBuffer.NormalKind
  32994. * - VertexBuffer.UVKind
  32995. * - VertexBuffer.UV2Kind
  32996. * - VertexBuffer.UV3Kind
  32997. * - VertexBuffer.UV4Kind
  32998. * - VertexBuffer.UV5Kind
  32999. * - VertexBuffer.UV6Kind
  33000. * - VertexBuffer.ColorKind
  33001. * - VertexBuffer.MatricesIndicesKind
  33002. * - VertexBuffer.MatricesIndicesExtraKind
  33003. * - VertexBuffer.MatricesWeightsKind
  33004. * - VertexBuffer.MatricesWeightsExtraKind
  33005. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33006. */
  33007. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33008. /**
  33009. * Tests if a specific vertex buffer is associated with this mesh
  33010. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33011. * - VertexBuffer.PositionKind
  33012. * - VertexBuffer.NormalKind
  33013. * - VertexBuffer.UVKind
  33014. * - VertexBuffer.UV2Kind
  33015. * - VertexBuffer.UV3Kind
  33016. * - VertexBuffer.UV4Kind
  33017. * - VertexBuffer.UV5Kind
  33018. * - VertexBuffer.UV6Kind
  33019. * - VertexBuffer.ColorKind
  33020. * - VertexBuffer.MatricesIndicesKind
  33021. * - VertexBuffer.MatricesIndicesExtraKind
  33022. * - VertexBuffer.MatricesWeightsKind
  33023. * - VertexBuffer.MatricesWeightsExtraKind
  33024. * @returns a boolean
  33025. */
  33026. isVerticesDataPresent(kind: string): boolean;
  33027. /**
  33028. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33029. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33030. * - VertexBuffer.PositionKind
  33031. * - VertexBuffer.UVKind
  33032. * - VertexBuffer.UV2Kind
  33033. * - VertexBuffer.UV3Kind
  33034. * - VertexBuffer.UV4Kind
  33035. * - VertexBuffer.UV5Kind
  33036. * - VertexBuffer.UV6Kind
  33037. * - VertexBuffer.ColorKind
  33038. * - VertexBuffer.MatricesIndicesKind
  33039. * - VertexBuffer.MatricesIndicesExtraKind
  33040. * - VertexBuffer.MatricesWeightsKind
  33041. * - VertexBuffer.MatricesWeightsExtraKind
  33042. * @returns a boolean
  33043. */
  33044. isVertexBufferUpdatable(kind: string): boolean;
  33045. /**
  33046. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33047. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33048. * - VertexBuffer.PositionKind
  33049. * - VertexBuffer.NormalKind
  33050. * - VertexBuffer.UVKind
  33051. * - VertexBuffer.UV2Kind
  33052. * - VertexBuffer.UV3Kind
  33053. * - VertexBuffer.UV4Kind
  33054. * - VertexBuffer.UV5Kind
  33055. * - VertexBuffer.UV6Kind
  33056. * - VertexBuffer.ColorKind
  33057. * - VertexBuffer.MatricesIndicesKind
  33058. * - VertexBuffer.MatricesIndicesExtraKind
  33059. * - VertexBuffer.MatricesWeightsKind
  33060. * - VertexBuffer.MatricesWeightsExtraKind
  33061. * @returns an array of strings
  33062. */
  33063. getVerticesDataKinds(): string[];
  33064. /**
  33065. * Returns a positive integer : the total number of indices in this mesh geometry.
  33066. * @returns the numner of indices or zero if the mesh has no geometry.
  33067. */
  33068. getTotalIndices(): number;
  33069. /**
  33070. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33071. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  33072. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33073. * @returns the indices array or an empty array if the mesh has no geometry
  33074. */
  33075. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33076. get isBlocked(): boolean;
  33077. /**
  33078. * Determine if the current mesh is ready to be rendered
  33079. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33080. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33081. * @returns true if all associated assets are ready (material, textures, shaders)
  33082. */
  33083. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33084. /**
  33085. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  33086. */
  33087. get areNormalsFrozen(): boolean;
  33088. /**
  33089. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  33090. * @returns the current mesh
  33091. */
  33092. freezeNormals(): Mesh;
  33093. /**
  33094. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  33095. * @returns the current mesh
  33096. */
  33097. unfreezeNormals(): Mesh;
  33098. /**
  33099. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33100. */
  33101. set overridenInstanceCount(count: number);
  33102. /** @hidden */
  33103. _preActivate(): Mesh;
  33104. /** @hidden */
  33105. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33106. /** @hidden */
  33107. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33108. protected _afterComputeWorldMatrix(): void;
  33109. /** @hidden */
  33110. _postActivate(): void;
  33111. /**
  33112. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33113. * This means the mesh underlying bounding box and sphere are recomputed.
  33114. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33115. * @returns the current mesh
  33116. */
  33117. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33118. /** @hidden */
  33119. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33120. /**
  33121. * This function will subdivide the mesh into multiple submeshes
  33122. * @param count defines the expected number of submeshes
  33123. */
  33124. subdivide(count: number): void;
  33125. /**
  33126. * Copy a FloatArray into a specific associated vertex buffer
  33127. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33128. * - VertexBuffer.PositionKind
  33129. * - VertexBuffer.UVKind
  33130. * - VertexBuffer.UV2Kind
  33131. * - VertexBuffer.UV3Kind
  33132. * - VertexBuffer.UV4Kind
  33133. * - VertexBuffer.UV5Kind
  33134. * - VertexBuffer.UV6Kind
  33135. * - VertexBuffer.ColorKind
  33136. * - VertexBuffer.MatricesIndicesKind
  33137. * - VertexBuffer.MatricesIndicesExtraKind
  33138. * - VertexBuffer.MatricesWeightsKind
  33139. * - VertexBuffer.MatricesWeightsExtraKind
  33140. * @param data defines the data source
  33141. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33142. * @param stride defines the data stride size (can be null)
  33143. * @returns the current mesh
  33144. */
  33145. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33146. /**
  33147. * Delete a vertex buffer associated with this mesh
  33148. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33149. * - VertexBuffer.PositionKind
  33150. * - VertexBuffer.UVKind
  33151. * - VertexBuffer.UV2Kind
  33152. * - VertexBuffer.UV3Kind
  33153. * - VertexBuffer.UV4Kind
  33154. * - VertexBuffer.UV5Kind
  33155. * - VertexBuffer.UV6Kind
  33156. * - VertexBuffer.ColorKind
  33157. * - VertexBuffer.MatricesIndicesKind
  33158. * - VertexBuffer.MatricesIndicesExtraKind
  33159. * - VertexBuffer.MatricesWeightsKind
  33160. * - VertexBuffer.MatricesWeightsExtraKind
  33161. */
  33162. removeVerticesData(kind: string): void;
  33163. /**
  33164. * Flags an associated vertex buffer as updatable
  33165. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33166. * - VertexBuffer.PositionKind
  33167. * - VertexBuffer.UVKind
  33168. * - VertexBuffer.UV2Kind
  33169. * - VertexBuffer.UV3Kind
  33170. * - VertexBuffer.UV4Kind
  33171. * - VertexBuffer.UV5Kind
  33172. * - VertexBuffer.UV6Kind
  33173. * - VertexBuffer.ColorKind
  33174. * - VertexBuffer.MatricesIndicesKind
  33175. * - VertexBuffer.MatricesIndicesExtraKind
  33176. * - VertexBuffer.MatricesWeightsKind
  33177. * - VertexBuffer.MatricesWeightsExtraKind
  33178. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33179. */
  33180. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33181. /**
  33182. * Sets the mesh global Vertex Buffer
  33183. * @param buffer defines the buffer to use
  33184. * @returns the current mesh
  33185. */
  33186. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33187. /**
  33188. * Update a specific associated vertex buffer
  33189. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33190. * - VertexBuffer.PositionKind
  33191. * - VertexBuffer.UVKind
  33192. * - VertexBuffer.UV2Kind
  33193. * - VertexBuffer.UV3Kind
  33194. * - VertexBuffer.UV4Kind
  33195. * - VertexBuffer.UV5Kind
  33196. * - VertexBuffer.UV6Kind
  33197. * - VertexBuffer.ColorKind
  33198. * - VertexBuffer.MatricesIndicesKind
  33199. * - VertexBuffer.MatricesIndicesExtraKind
  33200. * - VertexBuffer.MatricesWeightsKind
  33201. * - VertexBuffer.MatricesWeightsExtraKind
  33202. * @param data defines the data source
  33203. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33204. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  33205. * @returns the current mesh
  33206. */
  33207. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33208. /**
  33209. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33210. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33211. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33212. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33213. * @returns the current mesh
  33214. */
  33215. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33216. /**
  33217. * Creates a un-shared specific occurence of the geometry for the mesh.
  33218. * @returns the current mesh
  33219. */
  33220. makeGeometryUnique(): Mesh;
  33221. /**
  33222. * Set the index buffer of this mesh
  33223. * @param indices defines the source data
  33224. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33225. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33226. * @returns the current mesh
  33227. */
  33228. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33229. /**
  33230. * Update the current index buffer
  33231. * @param indices defines the source data
  33232. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33233. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  33234. * @returns the current mesh
  33235. */
  33236. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33237. /**
  33238. * Invert the geometry to move from a right handed system to a left handed one.
  33239. * @returns the current mesh
  33240. */
  33241. toLeftHanded(): Mesh;
  33242. /** @hidden */
  33243. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33244. /** @hidden */
  33245. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33246. /**
  33247. * Registers for this mesh a javascript function called just before the rendering process
  33248. * @param func defines the function to call before rendering this mesh
  33249. * @returns the current mesh
  33250. */
  33251. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33252. /**
  33253. * Disposes a previously registered javascript function called before the rendering
  33254. * @param func defines the function to remove
  33255. * @returns the current mesh
  33256. */
  33257. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33258. /**
  33259. * Registers for this mesh a javascript function called just after the rendering is complete
  33260. * @param func defines the function to call after rendering this mesh
  33261. * @returns the current mesh
  33262. */
  33263. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33264. /**
  33265. * Disposes a previously registered javascript function called after the rendering.
  33266. * @param func defines the function to remove
  33267. * @returns the current mesh
  33268. */
  33269. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33270. /** @hidden */
  33271. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33272. /** @hidden */
  33273. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33274. /** @hidden */
  33275. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33276. /** @hidden */
  33277. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33278. /** @hidden */
  33279. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33280. /** @hidden */
  33281. _rebuild(): void;
  33282. /** @hidden */
  33283. _freeze(): void;
  33284. /** @hidden */
  33285. _unFreeze(): void;
  33286. /**
  33287. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  33288. * @param subMesh defines the subMesh to render
  33289. * @param enableAlphaMode defines if alpha mode can be changed
  33290. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33291. * @returns the current mesh
  33292. */
  33293. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33294. private _onBeforeDraw;
  33295. /**
  33296. * Renormalize the mesh and patch it up if there are no weights
  33297. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33298. * However in the case of zero weights then we set just a single influence to 1.
  33299. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33300. */
  33301. cleanMatrixWeights(): void;
  33302. private normalizeSkinFourWeights;
  33303. private normalizeSkinWeightsAndExtra;
  33304. /**
  33305. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33306. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33307. * the user know there was an issue with importing the mesh
  33308. * @returns a validation object with skinned, valid and report string
  33309. */
  33310. validateSkinning(): {
  33311. skinned: boolean;
  33312. valid: boolean;
  33313. report: string;
  33314. };
  33315. /** @hidden */
  33316. _checkDelayState(): Mesh;
  33317. private _queueLoad;
  33318. /**
  33319. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33320. * A mesh is in the frustum if its bounding box intersects the frustum
  33321. * @param frustumPlanes defines the frustum to test
  33322. * @returns true if the mesh is in the frustum planes
  33323. */
  33324. isInFrustum(frustumPlanes: Plane[]): boolean;
  33325. /**
  33326. * Sets the mesh material by the material or multiMaterial `id` property
  33327. * @param id is a string identifying the material or the multiMaterial
  33328. * @returns the current mesh
  33329. */
  33330. setMaterialByID(id: string): Mesh;
  33331. /**
  33332. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33333. * @returns an array of IAnimatable
  33334. */
  33335. getAnimatables(): IAnimatable[];
  33336. /**
  33337. * Modifies the mesh geometry according to the passed transformation matrix.
  33338. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33339. * The mesh normals are modified using the same transformation.
  33340. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33341. * @param transform defines the transform matrix to use
  33342. * @see https://doc.babylonjs.com/resources/baking_transformations
  33343. * @returns the current mesh
  33344. */
  33345. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33346. /**
  33347. * Modifies the mesh geometry according to its own current World Matrix.
  33348. * The mesh World Matrix is then reset.
  33349. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33350. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33351. * @see https://doc.babylonjs.com/resources/baking_transformations
  33352. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33353. * @returns the current mesh
  33354. */
  33355. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33356. /** @hidden */
  33357. get _positions(): Nullable<Vector3[]>;
  33358. /** @hidden */
  33359. _resetPointsArrayCache(): Mesh;
  33360. /** @hidden */
  33361. _generatePointsArray(): boolean;
  33362. /**
  33363. * Returns a new Mesh object generated from the current mesh properties.
  33364. * This method must not get confused with createInstance()
  33365. * @param name is a string, the name given to the new mesh
  33366. * @param newParent can be any Node object (default `null`)
  33367. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33368. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33369. * @returns a new mesh
  33370. */
  33371. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33372. /**
  33373. * Releases resources associated with this mesh.
  33374. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33375. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33376. */
  33377. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33378. /** @hidden */
  33379. _disposeInstanceSpecificData(): void;
  33380. /** @hidden */
  33381. _disposeThinInstanceSpecificData(): void;
  33382. /**
  33383. * Modifies the mesh geometry according to a displacement map.
  33384. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  33385. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33386. * @param url is a string, the URL from the image file is to be downloaded.
  33387. * @param minHeight is the lower limit of the displacement.
  33388. * @param maxHeight is the upper limit of the displacement.
  33389. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  33390. * @param uvOffset is an optional vector2 used to offset UV.
  33391. * @param uvScale is an optional vector2 used to scale UV.
  33392. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  33393. * @returns the Mesh.
  33394. */
  33395. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33396. /**
  33397. * Modifies the mesh geometry according to a displacementMap buffer.
  33398. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  33399. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33400. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33401. * @param heightMapWidth is the width of the buffer image.
  33402. * @param heightMapHeight is the height of the buffer image.
  33403. * @param minHeight is the lower limit of the displacement.
  33404. * @param maxHeight is the upper limit of the displacement.
  33405. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  33406. * @param uvOffset is an optional vector2 used to offset UV.
  33407. * @param uvScale is an optional vector2 used to scale UV.
  33408. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  33409. * @returns the Mesh.
  33410. */
  33411. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33412. /**
  33413. * Modify the mesh to get a flat shading rendering.
  33414. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33415. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33416. * @returns current mesh
  33417. */
  33418. convertToFlatShadedMesh(): Mesh;
  33419. /**
  33420. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33421. * In other words, more vertices, no more indices and a single bigger VBO.
  33422. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33423. * @returns current mesh
  33424. */
  33425. convertToUnIndexedMesh(): Mesh;
  33426. /**
  33427. * Inverses facet orientations.
  33428. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33429. * @param flipNormals will also inverts the normals
  33430. * @returns current mesh
  33431. */
  33432. flipFaces(flipNormals?: boolean): Mesh;
  33433. /**
  33434. * Increase the number of facets and hence vertices in a mesh
  33435. * Vertex normals are interpolated from existing vertex normals
  33436. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33437. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33438. */
  33439. increaseVertices(numberPerEdge: number): void;
  33440. /**
  33441. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33442. * This will undo any application of covertToFlatShadedMesh
  33443. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33444. */
  33445. forceSharedVertices(): void;
  33446. /** @hidden */
  33447. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33448. /** @hidden */
  33449. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33450. /**
  33451. * Creates a new InstancedMesh object from the mesh model.
  33452. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33453. * @param name defines the name of the new instance
  33454. * @returns a new InstancedMesh
  33455. */
  33456. createInstance(name: string): InstancedMesh;
  33457. /**
  33458. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33459. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33460. * @returns the current mesh
  33461. */
  33462. synchronizeInstances(): Mesh;
  33463. /**
  33464. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33465. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33466. * This should be used together with the simplification to avoid disappearing triangles.
  33467. * @param successCallback an optional success callback to be called after the optimization finished.
  33468. * @returns the current mesh
  33469. */
  33470. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33471. /**
  33472. * Serialize current mesh
  33473. * @param serializationObject defines the object which will receive the serialization data
  33474. */
  33475. serialize(serializationObject: any): void;
  33476. /** @hidden */
  33477. _syncGeometryWithMorphTargetManager(): void;
  33478. /** @hidden */
  33479. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33480. /**
  33481. * Returns a new Mesh object parsed from the source provided.
  33482. * @param parsedMesh is the source
  33483. * @param scene defines the hosting scene
  33484. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33485. * @returns a new Mesh
  33486. */
  33487. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33488. /**
  33489. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33491. * @param name defines the name of the mesh to create
  33492. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33493. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33494. * @param closePath creates a seam between the first and the last points of each path of the path array
  33495. * @param offset is taken in account only if the `pathArray` is containing a single path
  33496. * @param scene defines the hosting scene
  33497. * @param updatable defines if the mesh must be flagged as updatable
  33498. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33499. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  33500. * @returns a new Mesh
  33501. */
  33502. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33503. /**
  33504. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33505. * @param name defines the name of the mesh to create
  33506. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33507. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  33508. * @param scene defines the hosting scene
  33509. * @param updatable defines if the mesh must be flagged as updatable
  33510. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33511. * @returns a new Mesh
  33512. */
  33513. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33514. /**
  33515. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33516. * @param name defines the name of the mesh to create
  33517. * @param size sets the size (float) of each box side (default 1)
  33518. * @param scene defines the hosting scene
  33519. * @param updatable defines if the mesh must be flagged as updatable
  33520. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33521. * @returns a new Mesh
  33522. */
  33523. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33524. /**
  33525. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33526. * @param name defines the name of the mesh to create
  33527. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33528. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33529. * @param scene defines the hosting scene
  33530. * @param updatable defines if the mesh must be flagged as updatable
  33531. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33532. * @returns a new Mesh
  33533. */
  33534. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33535. /**
  33536. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33537. * @param name defines the name of the mesh to create
  33538. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33539. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33540. * @param scene defines the hosting scene
  33541. * @returns a new Mesh
  33542. */
  33543. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33544. /**
  33545. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33546. * @param name defines the name of the mesh to create
  33547. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33548. * @param diameterTop set the top cap diameter (floats, default 1)
  33549. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33550. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33551. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33552. * @param scene defines the hosting scene
  33553. * @param updatable defines if the mesh must be flagged as updatable
  33554. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33555. * @returns a new Mesh
  33556. */
  33557. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33558. /**
  33559. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33560. * @param name defines the name of the mesh to create
  33561. * @param diameter sets the diameter size (float) of the torus (default 1)
  33562. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33563. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33564. * @param scene defines the hosting scene
  33565. * @param updatable defines if the mesh must be flagged as updatable
  33566. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33567. * @returns a new Mesh
  33568. */
  33569. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33570. /**
  33571. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33572. * @param name defines the name of the mesh to create
  33573. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33574. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33575. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33576. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33577. * @param p the number of windings on X axis (positive integers, default 2)
  33578. * @param q the number of windings on Y axis (positive integers, default 3)
  33579. * @param scene defines the hosting scene
  33580. * @param updatable defines if the mesh must be flagged as updatable
  33581. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33582. * @returns a new Mesh
  33583. */
  33584. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33585. /**
  33586. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33587. * @param name defines the name of the mesh to create
  33588. * @param points is an array successive Vector3
  33589. * @param scene defines the hosting scene
  33590. * @param updatable defines if the mesh must be flagged as updatable
  33591. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  33592. * @returns a new Mesh
  33593. */
  33594. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33595. /**
  33596. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33597. * @param name defines the name of the mesh to create
  33598. * @param points is an array successive Vector3
  33599. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33600. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33601. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33602. * @param scene defines the hosting scene
  33603. * @param updatable defines if the mesh must be flagged as updatable
  33604. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  33605. * @returns a new Mesh
  33606. */
  33607. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33608. /**
  33609. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33610. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33611. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  33612. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33613. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33614. * Remember you can only change the shape positions, not their number when updating a polygon.
  33615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33616. * @param name defines the name of the mesh to create
  33617. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  33618. * @param scene defines the hosting scene
  33619. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33620. * @param updatable defines if the mesh must be flagged as updatable
  33621. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33622. * @param earcutInjection can be used to inject your own earcut reference
  33623. * @returns a new Mesh
  33624. */
  33625. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33626. /**
  33627. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33628. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33629. * @param name defines the name of the mesh to create
  33630. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  33631. * @param depth defines the height of extrusion
  33632. * @param scene defines the hosting scene
  33633. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33634. * @param updatable defines if the mesh must be flagged as updatable
  33635. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33636. * @param earcutInjection can be used to inject your own earcut reference
  33637. * @returns a new Mesh
  33638. */
  33639. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33640. /**
  33641. * Creates an extruded shape mesh.
  33642. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  33643. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33644. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33645. * @param name defines the name of the mesh to create
  33646. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  33647. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33648. * @param scale is the value to scale the shape
  33649. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  33650. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  33651. * @param scene defines the hosting scene
  33652. * @param updatable defines if the mesh must be flagged as updatable
  33653. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33654. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  33655. * @returns a new Mesh
  33656. */
  33657. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33658. /**
  33659. * Creates an custom extruded shape mesh.
  33660. * The custom extrusion is a parametric shape.
  33661. * It has no predefined shape. Its final shape will depend on the input parameters.
  33662. * Please consider using the same method from the MeshBuilder class instead
  33663. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33664. * @param name defines the name of the mesh to create
  33665. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  33666. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33667. * @param scaleFunction is a custom Javascript function called on each path point
  33668. * @param rotationFunction is a custom Javascript function called on each path point
  33669. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33670. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33671. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  33672. * @param scene defines the hosting scene
  33673. * @param updatable defines if the mesh must be flagged as updatable
  33674. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33675. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  33676. * @returns a new Mesh
  33677. */
  33678. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33679. /**
  33680. * Creates lathe mesh.
  33681. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33682. * Please consider using the same method from the MeshBuilder class instead
  33683. * @param name defines the name of the mesh to create
  33684. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  33685. * @param radius is the radius value of the lathe
  33686. * @param tessellation is the side number of the lathe.
  33687. * @param scene defines the hosting scene
  33688. * @param updatable defines if the mesh must be flagged as updatable
  33689. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33690. * @returns a new Mesh
  33691. */
  33692. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33693. /**
  33694. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33695. * @param name defines the name of the mesh to create
  33696. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33697. * @param scene defines the hosting scene
  33698. * @param updatable defines if the mesh must be flagged as updatable
  33699. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33700. * @returns a new Mesh
  33701. */
  33702. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33703. /**
  33704. * Creates a ground mesh.
  33705. * Please consider using the same method from the MeshBuilder class instead
  33706. * @param name defines the name of the mesh to create
  33707. * @param width set the width of the ground
  33708. * @param height set the height of the ground
  33709. * @param subdivisions sets the number of subdivisions per side
  33710. * @param scene defines the hosting scene
  33711. * @param updatable defines if the mesh must be flagged as updatable
  33712. * @returns a new Mesh
  33713. */
  33714. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33715. /**
  33716. * Creates a tiled ground mesh.
  33717. * Please consider using the same method from the MeshBuilder class instead
  33718. * @param name defines the name of the mesh to create
  33719. * @param xmin set the ground minimum X coordinate
  33720. * @param zmin set the ground minimum Y coordinate
  33721. * @param xmax set the ground maximum X coordinate
  33722. * @param zmax set the ground maximum Z coordinate
  33723. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  33724. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  33725. * @param scene defines the hosting scene
  33726. * @param updatable defines if the mesh must be flagged as updatable
  33727. * @returns a new Mesh
  33728. */
  33729. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33730. w: number;
  33731. h: number;
  33732. }, precision: {
  33733. w: number;
  33734. h: number;
  33735. }, scene: Scene, updatable?: boolean): Mesh;
  33736. /**
  33737. * Creates a ground mesh from a height map.
  33738. * Please consider using the same method from the MeshBuilder class instead
  33739. * @see https://doc.babylonjs.com/babylon101/height_map
  33740. * @param name defines the name of the mesh to create
  33741. * @param url sets the URL of the height map image resource
  33742. * @param width set the ground width size
  33743. * @param height set the ground height size
  33744. * @param subdivisions sets the number of subdivision per side
  33745. * @param minHeight is the minimum altitude on the ground
  33746. * @param maxHeight is the maximum altitude on the ground
  33747. * @param scene defines the hosting scene
  33748. * @param updatable defines if the mesh must be flagged as updatable
  33749. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33750. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33751. * @returns a new Mesh
  33752. */
  33753. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  33754. /**
  33755. * Creates a tube mesh.
  33756. * The tube is a parametric shape.
  33757. * It has no predefined shape. Its final shape will depend on the input parameters.
  33758. * Please consider using the same method from the MeshBuilder class instead
  33759. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33760. * @param name defines the name of the mesh to create
  33761. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33762. * @param radius sets the tube radius size
  33763. * @param tessellation is the number of sides on the tubular surface
  33764. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  33765. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  33766. * @param scene defines the hosting scene
  33767. * @param updatable defines if the mesh must be flagged as updatable
  33768. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33769. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  33770. * @returns a new Mesh
  33771. */
  33772. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33773. (i: number, distance: number): number;
  33774. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33775. /**
  33776. * Creates a polyhedron mesh.
  33777. * Please consider using the same method from the MeshBuilder class instead.
  33778. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  33779. * * The parameter `size` (positive float, default 1) sets the polygon size
  33780. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33781. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  33782. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  33783. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  33784. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  33785. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  33786. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  33788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33789. * @param name defines the name of the mesh to create
  33790. * @param options defines the options used to create the mesh
  33791. * @param scene defines the hosting scene
  33792. * @returns a new Mesh
  33793. */
  33794. static CreatePolyhedron(name: string, options: {
  33795. type?: number;
  33796. size?: number;
  33797. sizeX?: number;
  33798. sizeY?: number;
  33799. sizeZ?: number;
  33800. custom?: any;
  33801. faceUV?: Vector4[];
  33802. faceColors?: Color4[];
  33803. updatable?: boolean;
  33804. sideOrientation?: number;
  33805. }, scene: Scene): Mesh;
  33806. /**
  33807. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33808. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33809. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  33810. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33811. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  33812. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33813. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  33814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33815. * @param name defines the name of the mesh
  33816. * @param options defines the options used to create the mesh
  33817. * @param scene defines the hosting scene
  33818. * @returns a new Mesh
  33819. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33820. */
  33821. static CreateIcoSphere(name: string, options: {
  33822. radius?: number;
  33823. flat?: boolean;
  33824. subdivisions?: number;
  33825. sideOrientation?: number;
  33826. updatable?: boolean;
  33827. }, scene: Scene): Mesh;
  33828. /**
  33829. * Creates a decal mesh.
  33830. * Please consider using the same method from the MeshBuilder class instead.
  33831. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33832. * @param name defines the name of the mesh
  33833. * @param sourceMesh defines the mesh receiving the decal
  33834. * @param position sets the position of the decal in world coordinates
  33835. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33836. * @param size sets the decal scaling
  33837. * @param angle sets the angle to rotate the decal
  33838. * @returns a new Mesh
  33839. */
  33840. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33841. /** Creates a Capsule Mesh
  33842. * @param name defines the name of the mesh.
  33843. * @param options the constructors options used to shape the mesh.
  33844. * @param scene defines the scene the mesh is scoped to.
  33845. * @returns the capsule mesh
  33846. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33847. */
  33848. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33849. /**
  33850. * Prepare internal position array for software CPU skinning
  33851. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33852. */
  33853. setPositionsForCPUSkinning(): Float32Array;
  33854. /**
  33855. * Prepare internal normal array for software CPU skinning
  33856. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33857. */
  33858. setNormalsForCPUSkinning(): Float32Array;
  33859. /**
  33860. * Updates the vertex buffer by applying transformation from the bones
  33861. * @param skeleton defines the skeleton to apply to current mesh
  33862. * @returns the current mesh
  33863. */
  33864. applySkeleton(skeleton: Skeleton): Mesh;
  33865. /**
  33866. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  33867. * @param meshes defines the list of meshes to scan
  33868. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33869. */
  33870. static MinMax(meshes: AbstractMesh[]): {
  33871. min: Vector3;
  33872. max: Vector3;
  33873. };
  33874. /**
  33875. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33876. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33877. * @returns a vector3
  33878. */
  33879. static Center(meshesOrMinMaxVector: {
  33880. min: Vector3;
  33881. max: Vector3;
  33882. } | AbstractMesh[]): Vector3;
  33883. /**
  33884. * Merge the array of meshes into a single mesh for performance reasons.
  33885. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33886. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33887. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33888. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33889. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33890. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33891. * @returns a new mesh
  33892. */
  33893. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33894. /** @hidden */
  33895. addInstance(instance: InstancedMesh): void;
  33896. /** @hidden */
  33897. removeInstance(instance: InstancedMesh): void;
  33898. }
  33899. }
  33900. declare module BABYLON {
  33901. /**
  33902. * This is the base class of all the camera used in the application.
  33903. * @see https://doc.babylonjs.com/features/cameras
  33904. */
  33905. export class Camera extends Node {
  33906. /** @hidden */
  33907. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  33908. /**
  33909. * This is the default projection mode used by the cameras.
  33910. * It helps recreating a feeling of perspective and better appreciate depth.
  33911. * This is the best way to simulate real life cameras.
  33912. */
  33913. static readonly PERSPECTIVE_CAMERA: number;
  33914. /**
  33915. * This helps creating camera with an orthographic mode.
  33916. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  33917. */
  33918. static readonly ORTHOGRAPHIC_CAMERA: number;
  33919. /**
  33920. * This is the default FOV mode for perspective cameras.
  33921. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  33922. */
  33923. static readonly FOVMODE_VERTICAL_FIXED: number;
  33924. /**
  33925. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  33926. */
  33927. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  33928. /**
  33929. * This specifies ther is no need for a camera rig.
  33930. * Basically only one eye is rendered corresponding to the camera.
  33931. */
  33932. static readonly RIG_MODE_NONE: number;
  33933. /**
  33934. * Simulates a camera Rig with one blue eye and one red eye.
  33935. * This can be use with 3d blue and red glasses.
  33936. */
  33937. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  33938. /**
  33939. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  33940. */
  33941. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  33942. /**
  33943. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  33944. */
  33945. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  33946. /**
  33947. * Defines that both eyes of the camera will be rendered over under each other.
  33948. */
  33949. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  33950. /**
  33951. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  33952. */
  33953. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  33954. /**
  33955. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  33956. */
  33957. static readonly RIG_MODE_VR: number;
  33958. /**
  33959. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  33960. */
  33961. static readonly RIG_MODE_WEBVR: number;
  33962. /**
  33963. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  33964. */
  33965. static readonly RIG_MODE_CUSTOM: number;
  33966. /**
  33967. * Defines if by default attaching controls should prevent the default javascript event to continue.
  33968. */
  33969. static ForceAttachControlToAlwaysPreventDefault: boolean;
  33970. /**
  33971. * Define the input manager associated with the camera.
  33972. */
  33973. inputs: CameraInputsManager<Camera>;
  33974. /** @hidden */
  33975. _position: Vector3;
  33976. /**
  33977. * Define the current local position of the camera in the scene
  33978. */
  33979. get position(): Vector3;
  33980. set position(newPosition: Vector3);
  33981. protected _upVector: Vector3;
  33982. /**
  33983. * The vector the camera should consider as up.
  33984. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  33985. */
  33986. set upVector(vec: Vector3);
  33987. get upVector(): Vector3;
  33988. /**
  33989. * Define the current limit on the left side for an orthographic camera
  33990. * In scene unit
  33991. */
  33992. orthoLeft: Nullable<number>;
  33993. /**
  33994. * Define the current limit on the right side for an orthographic camera
  33995. * In scene unit
  33996. */
  33997. orthoRight: Nullable<number>;
  33998. /**
  33999. * Define the current limit on the bottom side for an orthographic camera
  34000. * In scene unit
  34001. */
  34002. orthoBottom: Nullable<number>;
  34003. /**
  34004. * Define the current limit on the top side for an orthographic camera
  34005. * In scene unit
  34006. */
  34007. orthoTop: Nullable<number>;
  34008. /**
  34009. * Field Of View is set in Radians. (default is 0.8)
  34010. */
  34011. fov: number;
  34012. /**
  34013. * Define the minimum distance the camera can see from.
  34014. * This is important to note that the depth buffer are not infinite and the closer it starts
  34015. * the more your scene might encounter depth fighting issue.
  34016. */
  34017. minZ: number;
  34018. /**
  34019. * Define the maximum distance the camera can see to.
  34020. * This is important to note that the depth buffer are not infinite and the further it end
  34021. * the more your scene might encounter depth fighting issue.
  34022. */
  34023. maxZ: number;
  34024. /**
  34025. * Define the default inertia of the camera.
  34026. * This helps giving a smooth feeling to the camera movement.
  34027. */
  34028. inertia: number;
  34029. /**
  34030. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  34031. */
  34032. mode: number;
  34033. /**
  34034. * Define whether the camera is intermediate.
  34035. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  34036. */
  34037. isIntermediate: boolean;
  34038. /**
  34039. * Define the viewport of the camera.
  34040. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  34041. */
  34042. viewport: Viewport;
  34043. /**
  34044. * Restricts the camera to viewing objects with the same layerMask.
  34045. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  34046. */
  34047. layerMask: number;
  34048. /**
  34049. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  34050. */
  34051. fovMode: number;
  34052. /**
  34053. * Rig mode of the camera.
  34054. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  34055. * This is normally controlled byt the camera themselves as internal use.
  34056. */
  34057. cameraRigMode: number;
  34058. /**
  34059. * Defines the distance between both "eyes" in case of a RIG
  34060. */
  34061. interaxialDistance: number;
  34062. /**
  34063. * Defines if stereoscopic rendering is done side by side or over under.
  34064. */
  34065. isStereoscopicSideBySide: boolean;
  34066. /**
  34067. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  34068. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  34069. * else in the scene. (Eg. security camera)
  34070. *
  34071. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  34072. */
  34073. customRenderTargets: RenderTargetTexture[];
  34074. /**
  34075. * When set, the camera will render to this render target instead of the default canvas
  34076. *
  34077. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  34078. */
  34079. outputRenderTarget: Nullable<RenderTargetTexture>;
  34080. /**
  34081. * Observable triggered when the camera view matrix has changed.
  34082. */
  34083. onViewMatrixChangedObservable: Observable<Camera>;
  34084. /**
  34085. * Observable triggered when the camera Projection matrix has changed.
  34086. */
  34087. onProjectionMatrixChangedObservable: Observable<Camera>;
  34088. /**
  34089. * Observable triggered when the inputs have been processed.
  34090. */
  34091. onAfterCheckInputsObservable: Observable<Camera>;
  34092. /**
  34093. * Observable triggered when reset has been called and applied to the camera.
  34094. */
  34095. onRestoreStateObservable: Observable<Camera>;
  34096. /**
  34097. * Is this camera a part of a rig system?
  34098. */
  34099. isRigCamera: boolean;
  34100. /**
  34101. * If isRigCamera set to true this will be set with the parent camera.
  34102. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  34103. */
  34104. rigParent?: Camera;
  34105. /** @hidden */
  34106. _cameraRigParams: any;
  34107. /** @hidden */
  34108. _rigCameras: Camera[];
  34109. /** @hidden */
  34110. _rigPostProcess: Nullable<PostProcess>;
  34111. protected _webvrViewMatrix: Matrix;
  34112. /** @hidden */
  34113. _skipRendering: boolean;
  34114. /** @hidden */
  34115. _projectionMatrix: Matrix;
  34116. /** @hidden */
  34117. _postProcesses: Nullable<PostProcess>[];
  34118. /** @hidden */
  34119. _activeMeshes: SmartArray<AbstractMesh>;
  34120. protected _globalPosition: Vector3;
  34121. /** @hidden */
  34122. _computedViewMatrix: Matrix;
  34123. private _doNotComputeProjectionMatrix;
  34124. private _transformMatrix;
  34125. private _frustumPlanes;
  34126. private _refreshFrustumPlanes;
  34127. private _storedFov;
  34128. private _stateStored;
  34129. /**
  34130. * Instantiates a new camera object.
  34131. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  34132. * @see https://doc.babylonjs.com/features/cameras
  34133. * @param name Defines the name of the camera in the scene
  34134. * @param position Defines the position of the camera
  34135. * @param scene Defines the scene the camera belongs too
  34136. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  34137. */
  34138. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34139. /**
  34140. * Store current camera state (fov, position, etc..)
  34141. * @returns the camera
  34142. */
  34143. storeState(): Camera;
  34144. /**
  34145. * Restores the camera state values if it has been stored. You must call storeState() first
  34146. */
  34147. protected _restoreStateValues(): boolean;
  34148. /**
  34149. * Restored camera state. You must call storeState() first.
  34150. * @returns true if restored and false otherwise
  34151. */
  34152. restoreState(): boolean;
  34153. /**
  34154. * Gets the class name of the camera.
  34155. * @returns the class name
  34156. */
  34157. getClassName(): string;
  34158. /** @hidden */
  34159. readonly _isCamera: boolean;
  34160. /**
  34161. * Gets a string representation of the camera useful for debug purpose.
  34162. * @param fullDetails Defines that a more verboe level of logging is required
  34163. * @returns the string representation
  34164. */
  34165. toString(fullDetails?: boolean): string;
  34166. /**
  34167. * Gets the current world space position of the camera.
  34168. */
  34169. get globalPosition(): Vector3;
  34170. /**
  34171. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  34172. * @returns the active meshe list
  34173. */
  34174. getActiveMeshes(): SmartArray<AbstractMesh>;
  34175. /**
  34176. * Check whether a mesh is part of the current active mesh list of the camera
  34177. * @param mesh Defines the mesh to check
  34178. * @returns true if active, false otherwise
  34179. */
  34180. isActiveMesh(mesh: Mesh): boolean;
  34181. /**
  34182. * Is this camera ready to be used/rendered
  34183. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  34184. * @return true if the camera is ready
  34185. */
  34186. isReady(completeCheck?: boolean): boolean;
  34187. /** @hidden */
  34188. _initCache(): void;
  34189. /** @hidden */
  34190. _updateCache(ignoreParentClass?: boolean): void;
  34191. /** @hidden */
  34192. _isSynchronized(): boolean;
  34193. /** @hidden */
  34194. _isSynchronizedViewMatrix(): boolean;
  34195. /** @hidden */
  34196. _isSynchronizedProjectionMatrix(): boolean;
  34197. /**
  34198. * Attach the input controls to a specific dom element to get the input from.
  34199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34200. */
  34201. attachControl(noPreventDefault?: boolean): void;
  34202. /**
  34203. * Detach the current controls from the specified dom element.
  34204. */
  34205. detachControl(): void;
  34206. /**
  34207. * Update the camera state according to the different inputs gathered during the frame.
  34208. */
  34209. update(): void;
  34210. /** @hidden */
  34211. _checkInputs(): void;
  34212. /** @hidden */
  34213. get rigCameras(): Camera[];
  34214. /**
  34215. * Gets the post process used by the rig cameras
  34216. */
  34217. get rigPostProcess(): Nullable<PostProcess>;
  34218. /**
  34219. * Internal, gets the first post proces.
  34220. * @returns the first post process to be run on this camera.
  34221. */
  34222. _getFirstPostProcess(): Nullable<PostProcess>;
  34223. private _cascadePostProcessesToRigCams;
  34224. /**
  34225. * Attach a post process to the camera.
  34226. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  34227. * @param postProcess The post process to attach to the camera
  34228. * @param insertAt The position of the post process in case several of them are in use in the scene
  34229. * @returns the position the post process has been inserted at
  34230. */
  34231. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  34232. /**
  34233. * Detach a post process to the camera.
  34234. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  34235. * @param postProcess The post process to detach from the camera
  34236. */
  34237. detachPostProcess(postProcess: PostProcess): void;
  34238. /**
  34239. * Gets the current world matrix of the camera
  34240. */
  34241. getWorldMatrix(): Matrix;
  34242. /** @hidden */
  34243. _getViewMatrix(): Matrix;
  34244. /**
  34245. * Gets the current view matrix of the camera.
  34246. * @param force forces the camera to recompute the matrix without looking at the cached state
  34247. * @returns the view matrix
  34248. */
  34249. getViewMatrix(force?: boolean): Matrix;
  34250. /**
  34251. * Freeze the projection matrix.
  34252. * It will prevent the cache check of the camera projection compute and can speed up perf
  34253. * if no parameter of the camera are meant to change
  34254. * @param projection Defines manually a projection if necessary
  34255. */
  34256. freezeProjectionMatrix(projection?: Matrix): void;
  34257. /**
  34258. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  34259. */
  34260. unfreezeProjectionMatrix(): void;
  34261. /**
  34262. * Gets the current projection matrix of the camera.
  34263. * @param force forces the camera to recompute the matrix without looking at the cached state
  34264. * @returns the projection matrix
  34265. */
  34266. getProjectionMatrix(force?: boolean): Matrix;
  34267. /**
  34268. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  34269. * @returns a Matrix
  34270. */
  34271. getTransformationMatrix(): Matrix;
  34272. private _updateFrustumPlanes;
  34273. /**
  34274. * Checks if a cullable object (mesh...) is in the camera frustum
  34275. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  34276. * @param target The object to check
  34277. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  34278. * @returns true if the object is in frustum otherwise false
  34279. */
  34280. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  34281. /**
  34282. * Checks if a cullable object (mesh...) is in the camera frustum
  34283. * Unlike isInFrustum this cheks the full bounding box
  34284. * @param target The object to check
  34285. * @returns true if the object is in frustum otherwise false
  34286. */
  34287. isCompletelyInFrustum(target: ICullable): boolean;
  34288. /**
  34289. * Gets a ray in the forward direction from the camera.
  34290. * @param length Defines the length of the ray to create
  34291. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34292. * @param origin Defines the start point of the ray which defaults to the camera position
  34293. * @returns the forward ray
  34294. */
  34295. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34296. /**
  34297. * Gets a ray in the forward direction from the camera.
  34298. * @param refRay the ray to (re)use when setting the values
  34299. * @param length Defines the length of the ray to create
  34300. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34301. * @param origin Defines the start point of the ray which defaults to the camera position
  34302. * @returns the forward ray
  34303. */
  34304. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34305. /**
  34306. * Releases resources associated with this node.
  34307. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34308. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34309. */
  34310. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34311. /** @hidden */
  34312. _isLeftCamera: boolean;
  34313. /**
  34314. * Gets the left camera of a rig setup in case of Rigged Camera
  34315. */
  34316. get isLeftCamera(): boolean;
  34317. /** @hidden */
  34318. _isRightCamera: boolean;
  34319. /**
  34320. * Gets the right camera of a rig setup in case of Rigged Camera
  34321. */
  34322. get isRightCamera(): boolean;
  34323. /**
  34324. * Gets the left camera of a rig setup in case of Rigged Camera
  34325. */
  34326. get leftCamera(): Nullable<FreeCamera>;
  34327. /**
  34328. * Gets the right camera of a rig setup in case of Rigged Camera
  34329. */
  34330. get rightCamera(): Nullable<FreeCamera>;
  34331. /**
  34332. * Gets the left camera target of a rig setup in case of Rigged Camera
  34333. * @returns the target position
  34334. */
  34335. getLeftTarget(): Nullable<Vector3>;
  34336. /**
  34337. * Gets the right camera target of a rig setup in case of Rigged Camera
  34338. * @returns the target position
  34339. */
  34340. getRightTarget(): Nullable<Vector3>;
  34341. /**
  34342. * @hidden
  34343. */
  34344. setCameraRigMode(mode: number, rigParams: any): void;
  34345. /** @hidden */
  34346. static _setStereoscopicRigMode(camera: Camera): void;
  34347. /** @hidden */
  34348. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  34349. /** @hidden */
  34350. static _setVRRigMode(camera: Camera, rigParams: any): void;
  34351. /** @hidden */
  34352. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  34353. /** @hidden */
  34354. _getVRProjectionMatrix(): Matrix;
  34355. protected _updateCameraRotationMatrix(): void;
  34356. protected _updateWebVRCameraRotationMatrix(): void;
  34357. /**
  34358. * This function MUST be overwritten by the different WebVR cameras available.
  34359. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34360. * @hidden
  34361. */
  34362. _getWebVRProjectionMatrix(): Matrix;
  34363. /**
  34364. * This function MUST be overwritten by the different WebVR cameras available.
  34365. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34366. * @hidden
  34367. */
  34368. _getWebVRViewMatrix(): Matrix;
  34369. /** @hidden */
  34370. setCameraRigParameter(name: string, value: any): void;
  34371. /**
  34372. * needs to be overridden by children so sub has required properties to be copied
  34373. * @hidden
  34374. */
  34375. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  34376. /**
  34377. * May need to be overridden by children
  34378. * @hidden
  34379. */
  34380. _updateRigCameras(): void;
  34381. /** @hidden */
  34382. _setupInputs(): void;
  34383. /**
  34384. * Serialiaze the camera setup to a json represention
  34385. * @returns the JSON representation
  34386. */
  34387. serialize(): any;
  34388. /**
  34389. * Clones the current camera.
  34390. * @param name The cloned camera name
  34391. * @returns the cloned camera
  34392. */
  34393. clone(name: string): Camera;
  34394. /**
  34395. * Gets the direction of the camera relative to a given local axis.
  34396. * @param localAxis Defines the reference axis to provide a relative direction.
  34397. * @return the direction
  34398. */
  34399. getDirection(localAxis: Vector3): Vector3;
  34400. /**
  34401. * Returns the current camera absolute rotation
  34402. */
  34403. get absoluteRotation(): Quaternion;
  34404. /**
  34405. * Gets the direction of the camera relative to a given local axis into a passed vector.
  34406. * @param localAxis Defines the reference axis to provide a relative direction.
  34407. * @param result Defines the vector to store the result in
  34408. */
  34409. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  34410. /**
  34411. * Gets a camera constructor for a given camera type
  34412. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  34413. * @param name The name of the camera the result will be able to instantiate
  34414. * @param scene The scene the result will construct the camera in
  34415. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  34416. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  34417. * @returns a factory method to construc the camera
  34418. */
  34419. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  34420. /**
  34421. * Compute the world matrix of the camera.
  34422. * @returns the camera world matrix
  34423. */
  34424. computeWorldMatrix(): Matrix;
  34425. /**
  34426. * Parse a JSON and creates the camera from the parsed information
  34427. * @param parsedCamera The JSON to parse
  34428. * @param scene The scene to instantiate the camera in
  34429. * @returns the newly constructed camera
  34430. */
  34431. static Parse(parsedCamera: any, scene: Scene): Camera;
  34432. }
  34433. }
  34434. declare module BABYLON {
  34435. /**
  34436. * Class containing static functions to help procedurally build meshes
  34437. */
  34438. export class DiscBuilder {
  34439. /**
  34440. * Creates a plane polygonal mesh. By default, this is a disc
  34441. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34442. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  34443. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  34444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34445. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34447. * @param name defines the name of the mesh
  34448. * @param options defines the options used to create the mesh
  34449. * @param scene defines the hosting scene
  34450. * @returns the plane polygonal mesh
  34451. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34452. */
  34453. static CreateDisc(name: string, options: {
  34454. radius?: number;
  34455. tessellation?: number;
  34456. arc?: number;
  34457. updatable?: boolean;
  34458. sideOrientation?: number;
  34459. frontUVs?: Vector4;
  34460. backUVs?: Vector4;
  34461. }, scene?: Nullable<Scene>): Mesh;
  34462. }
  34463. }
  34464. declare module BABYLON {
  34465. /**
  34466. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34467. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  34468. * The SPS is also a particle system. It provides some methods to manage the particles.
  34469. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34470. *
  34471. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34472. */
  34473. export class SolidParticleSystem implements IDisposable {
  34474. /**
  34475. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34476. * Example : var p = SPS.particles[i];
  34477. */
  34478. particles: SolidParticle[];
  34479. /**
  34480. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34481. */
  34482. nbParticles: number;
  34483. /**
  34484. * If the particles must ever face the camera (default false). Useful for planar particles.
  34485. */
  34486. billboard: boolean;
  34487. /**
  34488. * Recompute normals when adding a shape
  34489. */
  34490. recomputeNormals: boolean;
  34491. /**
  34492. * This a counter ofr your own usage. It's not set by any SPS functions.
  34493. */
  34494. counter: number;
  34495. /**
  34496. * The SPS name. This name is also given to the underlying mesh.
  34497. */
  34498. name: string;
  34499. /**
  34500. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34501. */
  34502. mesh: Mesh;
  34503. /**
  34504. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34505. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34506. */
  34507. vars: any;
  34508. /**
  34509. * This array is populated when the SPS is set as 'pickable'.
  34510. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34511. * Each element of this array is an object `{idx: int, faceId: int}`.
  34512. * `idx` is the picked particle index in the `SPS.particles` array
  34513. * `faceId` is the picked face index counted within this particle.
  34514. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34515. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34516. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34517. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34518. */
  34519. pickedParticles: {
  34520. idx: number;
  34521. faceId: number;
  34522. }[];
  34523. /**
  34524. * This array is populated when the SPS is set as 'pickable'
  34525. * Each key of this array is a submesh index.
  34526. * Each element of this array is a second array defined like this :
  34527. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34528. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34529. * `idx` is the picked particle index in the `SPS.particles` array
  34530. * `faceId` is the picked face index counted within this particle.
  34531. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34532. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34533. */
  34534. pickedBySubMesh: {
  34535. idx: number;
  34536. faceId: number;
  34537. }[][];
  34538. /**
  34539. * This array is populated when `enableDepthSort` is set to true.
  34540. * Each element of this array is an instance of the class DepthSortedParticle.
  34541. */
  34542. depthSortedParticles: DepthSortedParticle[];
  34543. /**
  34544. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34545. * @hidden
  34546. */
  34547. _bSphereOnly: boolean;
  34548. /**
  34549. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34550. * @hidden
  34551. */
  34552. _bSphereRadiusFactor: number;
  34553. private _scene;
  34554. private _positions;
  34555. private _indices;
  34556. private _normals;
  34557. private _colors;
  34558. private _uvs;
  34559. private _indices32;
  34560. private _positions32;
  34561. private _normals32;
  34562. private _fixedNormal32;
  34563. private _colors32;
  34564. private _uvs32;
  34565. private _index;
  34566. private _updatable;
  34567. private _pickable;
  34568. private _isVisibilityBoxLocked;
  34569. private _alwaysVisible;
  34570. private _depthSort;
  34571. private _expandable;
  34572. private _shapeCounter;
  34573. private _copy;
  34574. private _color;
  34575. private _computeParticleColor;
  34576. private _computeParticleTexture;
  34577. private _computeParticleRotation;
  34578. private _computeParticleVertex;
  34579. private _computeBoundingBox;
  34580. private _depthSortParticles;
  34581. private _camera;
  34582. private _mustUnrotateFixedNormals;
  34583. private _particlesIntersect;
  34584. private _needs32Bits;
  34585. private _isNotBuilt;
  34586. private _lastParticleId;
  34587. private _idxOfId;
  34588. private _multimaterialEnabled;
  34589. private _useModelMaterial;
  34590. private _indicesByMaterial;
  34591. private _materialIndexes;
  34592. private _depthSortFunction;
  34593. private _materialSortFunction;
  34594. private _materials;
  34595. private _multimaterial;
  34596. private _materialIndexesById;
  34597. private _defaultMaterial;
  34598. private _autoUpdateSubMeshes;
  34599. private _tmpVertex;
  34600. /**
  34601. * Creates a SPS (Solid Particle System) object.
  34602. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34603. * @param scene (Scene) is the scene in which the SPS is added.
  34604. * @param options defines the options of the sps e.g.
  34605. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34606. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34607. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34608. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  34609. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34610. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34611. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34612. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34613. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34614. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34615. */
  34616. constructor(name: string, scene: Scene, options?: {
  34617. updatable?: boolean;
  34618. isPickable?: boolean;
  34619. enableDepthSort?: boolean;
  34620. particleIntersection?: boolean;
  34621. boundingSphereOnly?: boolean;
  34622. bSphereRadiusFactor?: number;
  34623. expandable?: boolean;
  34624. useModelMaterial?: boolean;
  34625. enableMultiMaterial?: boolean;
  34626. });
  34627. /**
  34628. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34629. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34630. * @returns the created mesh
  34631. */
  34632. buildMesh(): Mesh;
  34633. /**
  34634. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34635. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34636. * Thus the particles generated from `digest()` have their property `position` set yet.
  34637. * @param mesh ( Mesh ) is the mesh to be digested
  34638. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  34639. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34640. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34641. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34642. * @returns the current SPS
  34643. */
  34644. digest(mesh: Mesh, options?: {
  34645. facetNb?: number;
  34646. number?: number;
  34647. delta?: number;
  34648. storage?: [];
  34649. }): SolidParticleSystem;
  34650. /**
  34651. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34652. * @hidden
  34653. */
  34654. private _unrotateFixedNormals;
  34655. /**
  34656. * Resets the temporary working copy particle
  34657. * @hidden
  34658. */
  34659. private _resetCopy;
  34660. /**
  34661. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34662. * @param p the current index in the positions array to be updated
  34663. * @param ind the current index in the indices array
  34664. * @param shape a Vector3 array, the shape geometry
  34665. * @param positions the positions array to be updated
  34666. * @param meshInd the shape indices array
  34667. * @param indices the indices array to be updated
  34668. * @param meshUV the shape uv array
  34669. * @param uvs the uv array to be updated
  34670. * @param meshCol the shape color array
  34671. * @param colors the color array to be updated
  34672. * @param meshNor the shape normals array
  34673. * @param normals the normals array to be updated
  34674. * @param idx the particle index
  34675. * @param idxInShape the particle index in its shape
  34676. * @param options the addShape() method passed options
  34677. * @model the particle model
  34678. * @hidden
  34679. */
  34680. private _meshBuilder;
  34681. /**
  34682. * Returns a shape Vector3 array from positions float array
  34683. * @param positions float array
  34684. * @returns a vector3 array
  34685. * @hidden
  34686. */
  34687. private _posToShape;
  34688. /**
  34689. * Returns a shapeUV array from a float uvs (array deep copy)
  34690. * @param uvs as a float array
  34691. * @returns a shapeUV array
  34692. * @hidden
  34693. */
  34694. private _uvsToShapeUV;
  34695. /**
  34696. * Adds a new particle object in the particles array
  34697. * @param idx particle index in particles array
  34698. * @param id particle id
  34699. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34700. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34701. * @param model particle ModelShape object
  34702. * @param shapeId model shape identifier
  34703. * @param idxInShape index of the particle in the current model
  34704. * @param bInfo model bounding info object
  34705. * @param storage target storage array, if any
  34706. * @hidden
  34707. */
  34708. private _addParticle;
  34709. /**
  34710. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34711. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34712. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34713. * @param nb (positive integer) the number of particles to be created from this model
  34714. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34715. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34716. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34717. * @returns the number of shapes in the system
  34718. */
  34719. addShape(mesh: Mesh, nb: number, options?: {
  34720. positionFunction?: any;
  34721. vertexFunction?: any;
  34722. storage?: [];
  34723. }): number;
  34724. /**
  34725. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34726. * @hidden
  34727. */
  34728. private _rebuildParticle;
  34729. /**
  34730. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34731. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  34732. * @returns the SPS.
  34733. */
  34734. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34735. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34736. * Returns an array with the removed particles.
  34737. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  34738. * The SPS can't be empty so at least one particle needs to remain in place.
  34739. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34740. * @param start index of the first particle to remove
  34741. * @param end index of the last particle to remove (included)
  34742. * @returns an array populated with the removed particles
  34743. */
  34744. removeParticles(start: number, end: number): SolidParticle[];
  34745. /**
  34746. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34747. * @param solidParticleArray an array populated with Solid Particles objects
  34748. * @returns the SPS
  34749. */
  34750. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34751. /**
  34752. * Creates a new particle and modifies the SPS mesh geometry :
  34753. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34754. * - calls _addParticle() to populate the particle array
  34755. * factorized code from addShape() and insertParticlesFromArray()
  34756. * @param idx particle index in the particles array
  34757. * @param i particle index in its shape
  34758. * @param modelShape particle ModelShape object
  34759. * @param shape shape vertex array
  34760. * @param meshInd shape indices array
  34761. * @param meshUV shape uv array
  34762. * @param meshCol shape color array
  34763. * @param meshNor shape normals array
  34764. * @param bbInfo shape bounding info
  34765. * @param storage target particle storage
  34766. * @options addShape() passed options
  34767. * @hidden
  34768. */
  34769. private _insertNewParticle;
  34770. /**
  34771. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34772. * This method calls `updateParticle()` for each particle of the SPS.
  34773. * For an animated SPS, it is usually called within the render loop.
  34774. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  34775. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34776. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34777. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34778. * @returns the SPS.
  34779. */
  34780. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34781. /**
  34782. * Disposes the SPS.
  34783. */
  34784. dispose(): void;
  34785. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34786. * idx is the particle index in the SPS
  34787. * faceId is the picked face index counted within this particle.
  34788. * Returns null if the pickInfo can't identify a picked particle.
  34789. * @param pickingInfo (PickingInfo object)
  34790. * @returns {idx: number, faceId: number} or null
  34791. */
  34792. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34793. idx: number;
  34794. faceId: number;
  34795. }>;
  34796. /**
  34797. * Returns a SolidParticle object from its identifier : particle.id
  34798. * @param id (integer) the particle Id
  34799. * @returns the searched particle or null if not found in the SPS.
  34800. */
  34801. getParticleById(id: number): Nullable<SolidParticle>;
  34802. /**
  34803. * Returns a new array populated with the particles having the passed shapeId.
  34804. * @param shapeId (integer) the shape identifier
  34805. * @returns a new solid particle array
  34806. */
  34807. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34808. /**
  34809. * Populates the passed array "ref" with the particles having the passed shapeId.
  34810. * @param shapeId the shape identifier
  34811. * @returns the SPS
  34812. * @param ref
  34813. */
  34814. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34815. /**
  34816. * Computes the required SubMeshes according the materials assigned to the particles.
  34817. * @returns the solid particle system.
  34818. * Does nothing if called before the SPS mesh is built.
  34819. */
  34820. computeSubMeshes(): SolidParticleSystem;
  34821. /**
  34822. * Sorts the solid particles by material when MultiMaterial is enabled.
  34823. * Updates the indices32 array.
  34824. * Updates the indicesByMaterial array.
  34825. * Updates the mesh indices array.
  34826. * @returns the SPS
  34827. * @hidden
  34828. */
  34829. private _sortParticlesByMaterial;
  34830. /**
  34831. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34832. * @hidden
  34833. */
  34834. private _setMaterialIndexesById;
  34835. /**
  34836. * Returns an array with unique values of Materials from the passed array
  34837. * @param array the material array to be checked and filtered
  34838. * @hidden
  34839. */
  34840. private _filterUniqueMaterialId;
  34841. /**
  34842. * Sets a new Standard Material as _defaultMaterial if not already set.
  34843. * @hidden
  34844. */
  34845. private _setDefaultMaterial;
  34846. /**
  34847. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34848. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34849. * @returns the SPS.
  34850. */
  34851. refreshVisibleSize(): SolidParticleSystem;
  34852. /**
  34853. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34854. * @param size the size (float) of the visibility box
  34855. * note : this doesn't lock the SPS mesh bounding box.
  34856. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34857. */
  34858. setVisibilityBox(size: number): void;
  34859. /**
  34860. * Gets whether the SPS as always visible or not
  34861. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34862. */
  34863. get isAlwaysVisible(): boolean;
  34864. /**
  34865. * Sets the SPS as always visible or not
  34866. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34867. */
  34868. set isAlwaysVisible(val: boolean);
  34869. /**
  34870. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34871. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34872. */
  34873. set isVisibilityBoxLocked(val: boolean);
  34874. /**
  34875. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34876. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34877. */
  34878. get isVisibilityBoxLocked(): boolean;
  34879. /**
  34880. * Tells to `setParticles()` to compute the particle rotations or not.
  34881. * Default value : true. The SPS is faster when it's set to false.
  34882. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34883. */
  34884. set computeParticleRotation(val: boolean);
  34885. /**
  34886. * Tells to `setParticles()` to compute the particle colors or not.
  34887. * Default value : true. The SPS is faster when it's set to false.
  34888. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34889. */
  34890. set computeParticleColor(val: boolean);
  34891. set computeParticleTexture(val: boolean);
  34892. /**
  34893. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34894. * Default value : false. The SPS is faster when it's set to false.
  34895. * Note : the particle custom vertex positions aren't stored values.
  34896. */
  34897. set computeParticleVertex(val: boolean);
  34898. /**
  34899. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34900. */
  34901. set computeBoundingBox(val: boolean);
  34902. /**
  34903. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34904. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34905. * Default : `true`
  34906. */
  34907. set depthSortParticles(val: boolean);
  34908. /**
  34909. * Gets if `setParticles()` computes the particle rotations or not.
  34910. * Default value : true. The SPS is faster when it's set to false.
  34911. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34912. */
  34913. get computeParticleRotation(): boolean;
  34914. /**
  34915. * Gets if `setParticles()` computes the particle colors or not.
  34916. * Default value : true. The SPS is faster when it's set to false.
  34917. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34918. */
  34919. get computeParticleColor(): boolean;
  34920. /**
  34921. * Gets if `setParticles()` computes the particle textures or not.
  34922. * Default value : true. The SPS is faster when it's set to false.
  34923. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34924. */
  34925. get computeParticleTexture(): boolean;
  34926. /**
  34927. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34928. * Default value : false. The SPS is faster when it's set to false.
  34929. * Note : the particle custom vertex positions aren't stored values.
  34930. */
  34931. get computeParticleVertex(): boolean;
  34932. /**
  34933. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34934. */
  34935. get computeBoundingBox(): boolean;
  34936. /**
  34937. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34938. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34939. * Default : `true`
  34940. */
  34941. get depthSortParticles(): boolean;
  34942. /**
  34943. * Gets if the SPS is created as expandable at construction time.
  34944. * Default : `false`
  34945. */
  34946. get expandable(): boolean;
  34947. /**
  34948. * Gets if the SPS supports the Multi Materials
  34949. */
  34950. get multimaterialEnabled(): boolean;
  34951. /**
  34952. * Gets if the SPS uses the model materials for its own multimaterial.
  34953. */
  34954. get useModelMaterial(): boolean;
  34955. /**
  34956. * The SPS used material array.
  34957. */
  34958. get materials(): Material[];
  34959. /**
  34960. * Sets the SPS MultiMaterial from the passed materials.
  34961. * Note : the passed array is internally copied and not used then by reference.
  34962. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34963. */
  34964. setMultiMaterial(materials: Material[]): void;
  34965. /**
  34966. * The SPS computed multimaterial object
  34967. */
  34968. get multimaterial(): MultiMaterial;
  34969. set multimaterial(mm: MultiMaterial);
  34970. /**
  34971. * If the subMeshes must be updated on the next call to setParticles()
  34972. */
  34973. get autoUpdateSubMeshes(): boolean;
  34974. set autoUpdateSubMeshes(val: boolean);
  34975. /**
  34976. * This function does nothing. It may be overwritten to set all the particle first values.
  34977. * The SPS doesn't call this function, you may have to call it by your own.
  34978. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34979. */
  34980. initParticles(): void;
  34981. /**
  34982. * This function does nothing. It may be overwritten to recycle a particle.
  34983. * The SPS doesn't call this function, you may have to call it by your own.
  34984. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34985. * @param particle The particle to recycle
  34986. * @returns the recycled particle
  34987. */
  34988. recycleParticle(particle: SolidParticle): SolidParticle;
  34989. /**
  34990. * Updates a particle : this function should be overwritten by the user.
  34991. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34992. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34993. * @example : just set a particle position or velocity and recycle conditions
  34994. * @param particle The particle to update
  34995. * @returns the updated particle
  34996. */
  34997. updateParticle(particle: SolidParticle): SolidParticle;
  34998. /**
  34999. * Updates a vertex of a particle : it can be overwritten by the user.
  35000. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35001. * @param particle the current particle
  35002. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35003. * @param pt the index of the current vertex in the particle shape
  35004. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35005. * @example : just set a vertex particle position or color
  35006. * @returns the sps
  35007. */
  35008. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35009. /**
  35010. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35011. * This does nothing and may be overwritten by the user.
  35012. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35013. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35014. * @param update the boolean update value actually passed to setParticles()
  35015. */
  35016. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35017. /**
  35018. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35019. * This will be passed three parameters.
  35020. * This does nothing and may be overwritten by the user.
  35021. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35022. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35023. * @param update the boolean update value actually passed to setParticles()
  35024. */
  35025. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35026. }
  35027. }
  35028. declare module BABYLON {
  35029. /**
  35030. * Represents one particle of a solid particle system.
  35031. */
  35032. export class SolidParticle {
  35033. /**
  35034. * particle global index
  35035. */
  35036. idx: number;
  35037. /**
  35038. * particle identifier
  35039. */
  35040. id: number;
  35041. /**
  35042. * The color of the particle
  35043. */
  35044. color: Nullable<Color4>;
  35045. /**
  35046. * The world space position of the particle.
  35047. */
  35048. position: Vector3;
  35049. /**
  35050. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35051. */
  35052. rotation: Vector3;
  35053. /**
  35054. * The world space rotation quaternion of the particle.
  35055. */
  35056. rotationQuaternion: Nullable<Quaternion>;
  35057. /**
  35058. * The scaling of the particle.
  35059. */
  35060. scaling: Vector3;
  35061. /**
  35062. * The uvs of the particle.
  35063. */
  35064. uvs: Vector4;
  35065. /**
  35066. * The current speed of the particle.
  35067. */
  35068. velocity: Vector3;
  35069. /**
  35070. * The pivot point in the particle local space.
  35071. */
  35072. pivot: Vector3;
  35073. /**
  35074. * Must the particle be translated from its pivot point in its local space ?
  35075. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35076. * Default : false
  35077. */
  35078. translateFromPivot: boolean;
  35079. /**
  35080. * Is the particle active or not ?
  35081. */
  35082. alive: boolean;
  35083. /**
  35084. * Is the particle visible or not ?
  35085. */
  35086. isVisible: boolean;
  35087. /**
  35088. * Index of this particle in the global "positions" array (Internal use)
  35089. * @hidden
  35090. */
  35091. _pos: number;
  35092. /**
  35093. * @hidden Index of this particle in the global "indices" array (Internal use)
  35094. */
  35095. _ind: number;
  35096. /**
  35097. * @hidden ModelShape of this particle (Internal use)
  35098. */
  35099. _model: ModelShape;
  35100. /**
  35101. * ModelShape id of this particle
  35102. */
  35103. shapeId: number;
  35104. /**
  35105. * Index of the particle in its shape id
  35106. */
  35107. idxInShape: number;
  35108. /**
  35109. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35110. */
  35111. _modelBoundingInfo: BoundingInfo;
  35112. /**
  35113. * @hidden Particle BoundingInfo object (Internal use)
  35114. */
  35115. _boundingInfo: BoundingInfo;
  35116. /**
  35117. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35118. */
  35119. _sps: SolidParticleSystem;
  35120. /**
  35121. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35122. */
  35123. _stillInvisible: boolean;
  35124. /**
  35125. * @hidden Last computed particle rotation matrix
  35126. */
  35127. _rotationMatrix: number[];
  35128. /**
  35129. * Parent particle Id, if any.
  35130. * Default null.
  35131. */
  35132. parentId: Nullable<number>;
  35133. /**
  35134. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35135. */
  35136. materialIndex: Nullable<number>;
  35137. /**
  35138. * Custom object or properties.
  35139. */
  35140. props: Nullable<any>;
  35141. /**
  35142. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35143. * The possible values are :
  35144. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35145. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35146. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35147. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35148. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35149. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35150. * */
  35151. cullingStrategy: number;
  35152. /**
  35153. * @hidden Internal global position in the SPS.
  35154. */
  35155. _globalPosition: Vector3;
  35156. /**
  35157. * Creates a Solid Particle object.
  35158. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35159. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35160. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35161. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35162. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35163. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35164. * @param shapeId (integer) is the model shape identifier in the SPS.
  35165. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35166. * @param sps defines the sps it is associated to
  35167. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35168. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35169. */
  35170. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35171. /**
  35172. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35173. * @param target the particle target
  35174. * @returns the current particle
  35175. */
  35176. copyToRef(target: SolidParticle): SolidParticle;
  35177. /**
  35178. * Legacy support, changed scale to scaling
  35179. */
  35180. get scale(): Vector3;
  35181. /**
  35182. * Legacy support, changed scale to scaling
  35183. */
  35184. set scale(scale: Vector3);
  35185. /**
  35186. * Legacy support, changed quaternion to rotationQuaternion
  35187. */
  35188. get quaternion(): Nullable<Quaternion>;
  35189. /**
  35190. * Legacy support, changed quaternion to rotationQuaternion
  35191. */
  35192. set quaternion(q: Nullable<Quaternion>);
  35193. /**
  35194. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35195. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35196. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35197. * @returns true if it intersects
  35198. */
  35199. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35200. /**
  35201. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35202. * A particle is in the frustum if its bounding box intersects the frustum
  35203. * @param frustumPlanes defines the frustum to test
  35204. * @returns true if the particle is in the frustum planes
  35205. */
  35206. isInFrustum(frustumPlanes: Plane[]): boolean;
  35207. /**
  35208. * get the rotation matrix of the particle
  35209. * @hidden
  35210. */
  35211. getRotationMatrix(m: Matrix): void;
  35212. }
  35213. /**
  35214. * Represents the shape of the model used by one particle of a solid particle system.
  35215. * SPS internal tool, don't use it manually.
  35216. */
  35217. export class ModelShape {
  35218. /**
  35219. * The shape id
  35220. * @hidden
  35221. */
  35222. shapeID: number;
  35223. /**
  35224. * flat array of model positions (internal use)
  35225. * @hidden
  35226. */
  35227. _shape: Vector3[];
  35228. /**
  35229. * flat array of model UVs (internal use)
  35230. * @hidden
  35231. */
  35232. _shapeUV: number[];
  35233. /**
  35234. * color array of the model
  35235. * @hidden
  35236. */
  35237. _shapeColors: number[];
  35238. /**
  35239. * indices array of the model
  35240. * @hidden
  35241. */
  35242. _indices: number[];
  35243. /**
  35244. * normals array of the model
  35245. * @hidden
  35246. */
  35247. _normals: number[];
  35248. /**
  35249. * length of the shape in the model indices array (internal use)
  35250. * @hidden
  35251. */
  35252. _indicesLength: number;
  35253. /**
  35254. * Custom position function (internal use)
  35255. * @hidden
  35256. */
  35257. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35258. /**
  35259. * Custom vertex function (internal use)
  35260. * @hidden
  35261. */
  35262. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35263. /**
  35264. * Model material (internal use)
  35265. * @hidden
  35266. */
  35267. _material: Nullable<Material>;
  35268. /**
  35269. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  35270. * SPS internal tool, don't use it manually.
  35271. * @hidden
  35272. */
  35273. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  35274. }
  35275. /**
  35276. * Represents a Depth Sorted Particle in the solid particle system.
  35277. * @hidden
  35278. */
  35279. export class DepthSortedParticle {
  35280. /**
  35281. * Particle index
  35282. */
  35283. idx: number;
  35284. /**
  35285. * Index of the particle in the "indices" array
  35286. */
  35287. ind: number;
  35288. /**
  35289. * Length of the particle shape in the "indices" array
  35290. */
  35291. indicesLength: number;
  35292. /**
  35293. * Squared distance from the particle to the camera
  35294. */
  35295. sqDistance: number;
  35296. /**
  35297. * Material index when used with MultiMaterials
  35298. */
  35299. materialIndex: number;
  35300. /**
  35301. * Creates a new sorted particle
  35302. * @param materialIndex
  35303. */
  35304. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35305. }
  35306. /**
  35307. * Represents a solid particle vertex
  35308. */
  35309. export class SolidParticleVertex {
  35310. /**
  35311. * Vertex position
  35312. */
  35313. position: Vector3;
  35314. /**
  35315. * Vertex color
  35316. */
  35317. color: Color4;
  35318. /**
  35319. * Vertex UV
  35320. */
  35321. uv: Vector2;
  35322. /**
  35323. * Creates a new solid particle vertex
  35324. */
  35325. constructor();
  35326. /** Vertex x coordinate */
  35327. get x(): number;
  35328. set x(val: number);
  35329. /** Vertex y coordinate */
  35330. get y(): number;
  35331. set y(val: number);
  35332. /** Vertex z coordinate */
  35333. get z(): number;
  35334. set z(val: number);
  35335. }
  35336. }
  35337. declare module BABYLON {
  35338. /**
  35339. * @hidden
  35340. */
  35341. export class _MeshCollisionData {
  35342. _checkCollisions: boolean;
  35343. _collisionMask: number;
  35344. _collisionGroup: number;
  35345. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35346. _collider: Nullable<Collider>;
  35347. _oldPositionForCollisions: Vector3;
  35348. _diffPositionForCollisions: Vector3;
  35349. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35350. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35351. _collisionResponse: boolean;
  35352. }
  35353. }
  35354. declare module BABYLON {
  35355. /** @hidden */
  35356. class _FacetDataStorage {
  35357. facetPositions: Vector3[];
  35358. facetNormals: Vector3[];
  35359. facetPartitioning: number[][];
  35360. facetNb: number;
  35361. partitioningSubdivisions: number;
  35362. partitioningBBoxRatio: number;
  35363. facetDataEnabled: boolean;
  35364. facetParameters: any;
  35365. bbSize: Vector3;
  35366. subDiv: {
  35367. max: number;
  35368. X: number;
  35369. Y: number;
  35370. Z: number;
  35371. };
  35372. facetDepthSort: boolean;
  35373. facetDepthSortEnabled: boolean;
  35374. depthSortedIndices: IndicesArray;
  35375. depthSortedFacets: {
  35376. ind: number;
  35377. sqDistance: number;
  35378. }[];
  35379. facetDepthSortFunction: (f1: {
  35380. ind: number;
  35381. sqDistance: number;
  35382. }, f2: {
  35383. ind: number;
  35384. sqDistance: number;
  35385. }) => number;
  35386. facetDepthSortFrom: Vector3;
  35387. facetDepthSortOrigin: Vector3;
  35388. invertedMatrix: Matrix;
  35389. }
  35390. /**
  35391. * @hidden
  35392. **/
  35393. class _InternalAbstractMeshDataInfo {
  35394. _hasVertexAlpha: boolean;
  35395. _useVertexColors: boolean;
  35396. _numBoneInfluencers: number;
  35397. _applyFog: boolean;
  35398. _receiveShadows: boolean;
  35399. _facetData: _FacetDataStorage;
  35400. _visibility: number;
  35401. _skeleton: Nullable<Skeleton>;
  35402. _layerMask: number;
  35403. _computeBonesUsingShaders: boolean;
  35404. _isActive: boolean;
  35405. _onlyForInstances: boolean;
  35406. _isActiveIntermediate: boolean;
  35407. _onlyForInstancesIntermediate: boolean;
  35408. _actAsRegularMesh: boolean;
  35409. _currentLOD: Nullable<AbstractMesh>;
  35410. }
  35411. /**
  35412. * Class used to store all common mesh properties
  35413. */
  35414. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35415. /** No occlusion */
  35416. static OCCLUSION_TYPE_NONE: number;
  35417. /** Occlusion set to optimisitic */
  35418. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35419. /** Occlusion set to strict */
  35420. static OCCLUSION_TYPE_STRICT: number;
  35421. /** Use an accurante occlusion algorithm */
  35422. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35423. /** Use a conservative occlusion algorithm */
  35424. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35425. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35426. * Test order :
  35427. * Is the bounding sphere outside the frustum ?
  35428. * If not, are the bounding box vertices outside the frustum ?
  35429. * It not, then the cullable object is in the frustum.
  35430. */
  35431. static readonly CULLINGSTRATEGY_STANDARD: number;
  35432. /** Culling strategy : Bounding Sphere Only.
  35433. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35434. * It's also less accurate than the standard because some not visible objects can still be selected.
  35435. * Test : is the bounding sphere outside the frustum ?
  35436. * If not, then the cullable object is in the frustum.
  35437. */
  35438. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35439. /** Culling strategy : Optimistic Inclusion.
  35440. * This in an inclusion test first, then the standard exclusion test.
  35441. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35442. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  35443. * Anyway, it's as accurate as the standard strategy.
  35444. * Test :
  35445. * Is the cullable object bounding sphere center in the frustum ?
  35446. * If not, apply the default culling strategy.
  35447. */
  35448. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35449. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35450. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35451. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35452. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  35453. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35454. * Test :
  35455. * Is the cullable object bounding sphere center in the frustum ?
  35456. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35457. */
  35458. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35459. /**
  35460. * No billboard
  35461. */
  35462. static get BILLBOARDMODE_NONE(): number;
  35463. /** Billboard on X axis */
  35464. static get BILLBOARDMODE_X(): number;
  35465. /** Billboard on Y axis */
  35466. static get BILLBOARDMODE_Y(): number;
  35467. /** Billboard on Z axis */
  35468. static get BILLBOARDMODE_Z(): number;
  35469. /** Billboard on all axes */
  35470. static get BILLBOARDMODE_ALL(): number;
  35471. /** Billboard on using position instead of orientation */
  35472. static get BILLBOARDMODE_USE_POSITION(): number;
  35473. /** @hidden */
  35474. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35475. /**
  35476. * The culling strategy to use to check whether the mesh must be rendered or not.
  35477. * This value can be changed at any time and will be used on the next render mesh selection.
  35478. * The possible values are :
  35479. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35480. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35481. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35482. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35483. * Please read each static variable documentation to get details about the culling process.
  35484. * */
  35485. cullingStrategy: number;
  35486. /**
  35487. * Gets the number of facets in the mesh
  35488. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35489. */
  35490. get facetNb(): number;
  35491. /**
  35492. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35493. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35494. */
  35495. get partitioningSubdivisions(): number;
  35496. set partitioningSubdivisions(nb: number);
  35497. /**
  35498. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35499. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35500. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35501. */
  35502. get partitioningBBoxRatio(): number;
  35503. set partitioningBBoxRatio(ratio: number);
  35504. /**
  35505. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35506. * Works only for updatable meshes.
  35507. * Doesn't work with multi-materials
  35508. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35509. */
  35510. get mustDepthSortFacets(): boolean;
  35511. set mustDepthSortFacets(sort: boolean);
  35512. /**
  35513. * The location (Vector3) where the facet depth sort must be computed from.
  35514. * By default, the active camera position.
  35515. * Used only when facet depth sort is enabled
  35516. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35517. */
  35518. get facetDepthSortFrom(): Vector3;
  35519. set facetDepthSortFrom(location: Vector3);
  35520. /**
  35521. * gets a boolean indicating if facetData is enabled
  35522. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35523. */
  35524. get isFacetDataEnabled(): boolean;
  35525. /** @hidden */
  35526. _updateNonUniformScalingState(value: boolean): boolean;
  35527. /**
  35528. * An event triggered when this mesh collides with another one
  35529. */
  35530. onCollideObservable: Observable<AbstractMesh>;
  35531. /** Set a function to call when this mesh collides with another one */
  35532. set onCollide(callback: () => void);
  35533. /**
  35534. * An event triggered when the collision's position changes
  35535. */
  35536. onCollisionPositionChangeObservable: Observable<Vector3>;
  35537. /** Set a function to call when the collision's position changes */
  35538. set onCollisionPositionChange(callback: () => void);
  35539. /**
  35540. * An event triggered when material is changed
  35541. */
  35542. onMaterialChangedObservable: Observable<AbstractMesh>;
  35543. /**
  35544. * Gets or sets the orientation for POV movement & rotation
  35545. */
  35546. definedFacingForward: boolean;
  35547. /** @hidden */
  35548. _occlusionQuery: Nullable<WebGLQuery>;
  35549. /** @hidden */
  35550. _renderingGroup: Nullable<RenderingGroup>;
  35551. /**
  35552. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35553. */
  35554. get visibility(): number;
  35555. /**
  35556. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35557. */
  35558. set visibility(value: number);
  35559. /** Gets or sets the alpha index used to sort transparent meshes
  35560. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35561. */
  35562. alphaIndex: number;
  35563. /**
  35564. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35565. */
  35566. isVisible: boolean;
  35567. /**
  35568. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35569. */
  35570. isPickable: boolean;
  35571. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35572. showSubMeshesBoundingBox: boolean;
  35573. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35574. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35575. */
  35576. isBlocker: boolean;
  35577. /**
  35578. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35579. */
  35580. enablePointerMoveEvents: boolean;
  35581. private _renderingGroupId;
  35582. /**
  35583. * Specifies the rendering group id for this mesh (0 by default)
  35584. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35585. */
  35586. get renderingGroupId(): number;
  35587. set renderingGroupId(value: number);
  35588. private _material;
  35589. /** Gets or sets current material */
  35590. get material(): Nullable<Material>;
  35591. set material(value: Nullable<Material>);
  35592. /**
  35593. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35594. * @see https://doc.babylonjs.com/babylon101/shadows
  35595. */
  35596. get receiveShadows(): boolean;
  35597. set receiveShadows(value: boolean);
  35598. /** Defines color to use when rendering outline */
  35599. outlineColor: Color3;
  35600. /** Define width to use when rendering outline */
  35601. outlineWidth: number;
  35602. /** Defines color to use when rendering overlay */
  35603. overlayColor: Color3;
  35604. /** Defines alpha to use when rendering overlay */
  35605. overlayAlpha: number;
  35606. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35607. get hasVertexAlpha(): boolean;
  35608. set hasVertexAlpha(value: boolean);
  35609. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  35610. get useVertexColors(): boolean;
  35611. set useVertexColors(value: boolean);
  35612. /**
  35613. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35614. */
  35615. get computeBonesUsingShaders(): boolean;
  35616. set computeBonesUsingShaders(value: boolean);
  35617. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35618. get numBoneInfluencers(): number;
  35619. set numBoneInfluencers(value: number);
  35620. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35621. get applyFog(): boolean;
  35622. set applyFog(value: boolean);
  35623. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35624. useOctreeForRenderingSelection: boolean;
  35625. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35626. useOctreeForPicking: boolean;
  35627. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35628. useOctreeForCollisions: boolean;
  35629. /**
  35630. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35631. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35632. */
  35633. get layerMask(): number;
  35634. set layerMask(value: number);
  35635. /**
  35636. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35637. */
  35638. alwaysSelectAsActiveMesh: boolean;
  35639. /**
  35640. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35641. */
  35642. doNotSyncBoundingInfo: boolean;
  35643. /**
  35644. * Gets or sets the current action manager
  35645. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35646. */
  35647. actionManager: Nullable<AbstractActionManager>;
  35648. private _meshCollisionData;
  35649. /**
  35650. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35651. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35652. */
  35653. ellipsoid: Vector3;
  35654. /**
  35655. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35656. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35657. */
  35658. ellipsoidOffset: Vector3;
  35659. /**
  35660. * Gets or sets a collision mask used to mask collisions (default is -1).
  35661. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35662. */
  35663. get collisionMask(): number;
  35664. set collisionMask(mask: number);
  35665. /**
  35666. * Gets or sets a collision response flag (default is true).
  35667. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35668. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35669. * to respond to the collision.
  35670. */
  35671. get collisionResponse(): boolean;
  35672. set collisionResponse(response: boolean);
  35673. /**
  35674. * Gets or sets the current collision group mask (-1 by default).
  35675. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35676. */
  35677. get collisionGroup(): number;
  35678. set collisionGroup(mask: number);
  35679. /**
  35680. * Gets or sets current surrounding meshes (null by default).
  35681. *
  35682. * By default collision detection is tested against every mesh in the scene.
  35683. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35684. * meshes will be tested for the collision.
  35685. *
  35686. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35687. */
  35688. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35689. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35690. /**
  35691. * Defines edge width used when edgesRenderer is enabled
  35692. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35693. */
  35694. edgesWidth: number;
  35695. /**
  35696. * Defines edge color used when edgesRenderer is enabled
  35697. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35698. */
  35699. edgesColor: Color4;
  35700. /** @hidden */
  35701. _edgesRenderer: Nullable<IEdgesRenderer>;
  35702. /** @hidden */
  35703. _masterMesh: Nullable<AbstractMesh>;
  35704. /** @hidden */
  35705. _boundingInfo: Nullable<BoundingInfo>;
  35706. /** @hidden */
  35707. _renderId: number;
  35708. /**
  35709. * Gets or sets the list of subMeshes
  35710. * @see https://doc.babylonjs.com/how_to/multi_materials
  35711. */
  35712. subMeshes: SubMesh[];
  35713. /** @hidden */
  35714. _intersectionsInProgress: AbstractMesh[];
  35715. /** @hidden */
  35716. _unIndexed: boolean;
  35717. /** @hidden */
  35718. _lightSources: Light[];
  35719. /** Gets the list of lights affecting that mesh */
  35720. get lightSources(): Light[];
  35721. /** @hidden */
  35722. get _positions(): Nullable<Vector3[]>;
  35723. /** @hidden */
  35724. _waitingData: {
  35725. lods: Nullable<any>;
  35726. actions: Nullable<any>;
  35727. freezeWorldMatrix: Nullable<boolean>;
  35728. };
  35729. /** @hidden */
  35730. _bonesTransformMatrices: Nullable<Float32Array>;
  35731. /** @hidden */
  35732. _transformMatrixTexture: Nullable<RawTexture>;
  35733. /**
  35734. * Gets or sets a skeleton to apply skining transformations
  35735. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35736. */
  35737. set skeleton(value: Nullable<Skeleton>);
  35738. get skeleton(): Nullable<Skeleton>;
  35739. /**
  35740. * An event triggered when the mesh is rebuilt.
  35741. */
  35742. onRebuildObservable: Observable<AbstractMesh>;
  35743. /**
  35744. * Creates a new AbstractMesh
  35745. * @param name defines the name of the mesh
  35746. * @param scene defines the hosting scene
  35747. */
  35748. constructor(name: string, scene?: Nullable<Scene>);
  35749. /**
  35750. * Returns the string "AbstractMesh"
  35751. * @returns "AbstractMesh"
  35752. */
  35753. getClassName(): string;
  35754. /**
  35755. * Gets a string representation of the current mesh
  35756. * @param fullDetails defines a boolean indicating if full details must be included
  35757. * @returns a string representation of the current mesh
  35758. */
  35759. toString(fullDetails?: boolean): string;
  35760. /**
  35761. * @hidden
  35762. */
  35763. protected _getEffectiveParent(): Nullable<Node>;
  35764. /** @hidden */
  35765. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35766. /** @hidden */
  35767. _rebuild(): void;
  35768. /** @hidden */
  35769. _resyncLightSources(): void;
  35770. /** @hidden */
  35771. _resyncLightSource(light: Light): void;
  35772. /** @hidden */
  35773. _unBindEffect(): void;
  35774. /** @hidden */
  35775. _removeLightSource(light: Light, dispose: boolean): void;
  35776. private _markSubMeshesAsDirty;
  35777. /** @hidden */
  35778. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35779. /** @hidden */
  35780. _markSubMeshesAsAttributesDirty(): void;
  35781. /** @hidden */
  35782. _markSubMeshesAsMiscDirty(): void;
  35783. /**
  35784. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35785. */
  35786. get scaling(): Vector3;
  35787. set scaling(newScaling: Vector3);
  35788. /**
  35789. * Returns true if the mesh is blocked. Implemented by child classes
  35790. */
  35791. get isBlocked(): boolean;
  35792. /**
  35793. * Returns the mesh itself by default. Implemented by child classes
  35794. * @param camera defines the camera to use to pick the right LOD level
  35795. * @returns the currentAbstractMesh
  35796. */
  35797. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35798. /**
  35799. * Returns 0 by default. Implemented by child classes
  35800. * @returns an integer
  35801. */
  35802. getTotalVertices(): number;
  35803. /**
  35804. * Returns a positive integer : the total number of indices in this mesh geometry.
  35805. * @returns the numner of indices or zero if the mesh has no geometry.
  35806. */
  35807. getTotalIndices(): number;
  35808. /**
  35809. * Returns null by default. Implemented by child classes
  35810. * @returns null
  35811. */
  35812. getIndices(): Nullable<IndicesArray>;
  35813. /**
  35814. * Returns the array of the requested vertex data kind. Implemented by child classes
  35815. * @param kind defines the vertex data kind to use
  35816. * @returns null
  35817. */
  35818. getVerticesData(kind: string): Nullable<FloatArray>;
  35819. /**
  35820. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35821. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35822. * Note that a new underlying VertexBuffer object is created each call.
  35823. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35824. * @param kind defines vertex data kind:
  35825. * * VertexBuffer.PositionKind
  35826. * * VertexBuffer.UVKind
  35827. * * VertexBuffer.UV2Kind
  35828. * * VertexBuffer.UV3Kind
  35829. * * VertexBuffer.UV4Kind
  35830. * * VertexBuffer.UV5Kind
  35831. * * VertexBuffer.UV6Kind
  35832. * * VertexBuffer.ColorKind
  35833. * * VertexBuffer.MatricesIndicesKind
  35834. * * VertexBuffer.MatricesIndicesExtraKind
  35835. * * VertexBuffer.MatricesWeightsKind
  35836. * * VertexBuffer.MatricesWeightsExtraKind
  35837. * @param data defines the data source
  35838. * @param updatable defines if the data must be flagged as updatable (or static)
  35839. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  35840. * @returns the current mesh
  35841. */
  35842. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35843. /**
  35844. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35845. * If the mesh has no geometry, it is simply returned as it is.
  35846. * @param kind defines vertex data kind:
  35847. * * VertexBuffer.PositionKind
  35848. * * VertexBuffer.UVKind
  35849. * * VertexBuffer.UV2Kind
  35850. * * VertexBuffer.UV3Kind
  35851. * * VertexBuffer.UV4Kind
  35852. * * VertexBuffer.UV5Kind
  35853. * * VertexBuffer.UV6Kind
  35854. * * VertexBuffer.ColorKind
  35855. * * VertexBuffer.MatricesIndicesKind
  35856. * * VertexBuffer.MatricesIndicesExtraKind
  35857. * * VertexBuffer.MatricesWeightsKind
  35858. * * VertexBuffer.MatricesWeightsExtraKind
  35859. * @param data defines the data source
  35860. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  35861. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35862. * @returns the current mesh
  35863. */
  35864. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35865. /**
  35866. * Sets the mesh indices,
  35867. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35868. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35869. * @param totalVertices Defines the total number of vertices
  35870. * @returns the current mesh
  35871. */
  35872. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35873. /**
  35874. * Gets a boolean indicating if specific vertex data is present
  35875. * @param kind defines the vertex data kind to use
  35876. * @returns true is data kind is present
  35877. */
  35878. isVerticesDataPresent(kind: string): boolean;
  35879. /**
  35880. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35881. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35882. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35883. * @returns a BoundingInfo
  35884. */
  35885. getBoundingInfo(): BoundingInfo;
  35886. /**
  35887. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35888. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35889. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35890. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35891. * @returns the current mesh
  35892. */
  35893. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35894. /**
  35895. * Overwrite the current bounding info
  35896. * @param boundingInfo defines the new bounding info
  35897. * @returns the current mesh
  35898. */
  35899. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35900. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35901. get useBones(): boolean;
  35902. /** @hidden */
  35903. _preActivate(): void;
  35904. /** @hidden */
  35905. _preActivateForIntermediateRendering(renderId: number): void;
  35906. /** @hidden */
  35907. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35908. /** @hidden */
  35909. _postActivate(): void;
  35910. /** @hidden */
  35911. _freeze(): void;
  35912. /** @hidden */
  35913. _unFreeze(): void;
  35914. /**
  35915. * Gets the current world matrix
  35916. * @returns a Matrix
  35917. */
  35918. getWorldMatrix(): Matrix;
  35919. /** @hidden */
  35920. _getWorldMatrixDeterminant(): number;
  35921. /**
  35922. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35923. */
  35924. get isAnInstance(): boolean;
  35925. /**
  35926. * Gets a boolean indicating if this mesh has instances
  35927. */
  35928. get hasInstances(): boolean;
  35929. /**
  35930. * Gets a boolean indicating if this mesh has thin instances
  35931. */
  35932. get hasThinInstances(): boolean;
  35933. /**
  35934. * Perform relative position change from the point of view of behind the front of the mesh.
  35935. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35936. * Supports definition of mesh facing forward or backward
  35937. * @param amountRight defines the distance on the right axis
  35938. * @param amountUp defines the distance on the up axis
  35939. * @param amountForward defines the distance on the forward axis
  35940. * @returns the current mesh
  35941. */
  35942. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35943. /**
  35944. * Calculate relative position change from the point of view of behind the front of the mesh.
  35945. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35946. * Supports definition of mesh facing forward or backward
  35947. * @param amountRight defines the distance on the right axis
  35948. * @param amountUp defines the distance on the up axis
  35949. * @param amountForward defines the distance on the forward axis
  35950. * @returns the new displacement vector
  35951. */
  35952. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35953. /**
  35954. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35955. * Supports definition of mesh facing forward or backward
  35956. * @param flipBack defines the flip
  35957. * @param twirlClockwise defines the twirl
  35958. * @param tiltRight defines the tilt
  35959. * @returns the current mesh
  35960. */
  35961. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35962. /**
  35963. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35964. * Supports definition of mesh facing forward or backward.
  35965. * @param flipBack defines the flip
  35966. * @param twirlClockwise defines the twirl
  35967. * @param tiltRight defines the tilt
  35968. * @returns the new rotation vector
  35969. */
  35970. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35971. /**
  35972. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35973. * This means the mesh underlying bounding box and sphere are recomputed.
  35974. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35975. * @returns the current mesh
  35976. */
  35977. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35978. /** @hidden */
  35979. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35980. /** @hidden */
  35981. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35982. /** @hidden */
  35983. _updateBoundingInfo(): AbstractMesh;
  35984. /** @hidden */
  35985. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35986. /** @hidden */
  35987. protected _afterComputeWorldMatrix(): void;
  35988. /** @hidden */
  35989. get _effectiveMesh(): AbstractMesh;
  35990. /**
  35991. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35992. * A mesh is in the frustum if its bounding box intersects the frustum
  35993. * @param frustumPlanes defines the frustum to test
  35994. * @returns true if the mesh is in the frustum planes
  35995. */
  35996. isInFrustum(frustumPlanes: Plane[]): boolean;
  35997. /**
  35998. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35999. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36000. * @param frustumPlanes defines the frustum to test
  36001. * @returns true if the mesh is completely in the frustum planes
  36002. */
  36003. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36004. /**
  36005. * True if the mesh intersects another mesh or a SolidParticle object
  36006. * @param mesh defines a target mesh or SolidParticle to test
  36007. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  36008. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36009. * @returns true if there is an intersection
  36010. */
  36011. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36012. /**
  36013. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36014. * @param point defines the point to test
  36015. * @returns true if there is an intersection
  36016. */
  36017. intersectsPoint(point: Vector3): boolean;
  36018. /**
  36019. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36020. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36021. */
  36022. get checkCollisions(): boolean;
  36023. set checkCollisions(collisionEnabled: boolean);
  36024. /**
  36025. * Gets Collider object used to compute collisions (not physics)
  36026. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36027. */
  36028. get collider(): Nullable<Collider>;
  36029. /**
  36030. * Move the mesh using collision engine
  36031. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36032. * @param displacement defines the requested displacement vector
  36033. * @returns the current mesh
  36034. */
  36035. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36036. private _onCollisionPositionChange;
  36037. /** @hidden */
  36038. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36039. /** @hidden */
  36040. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36041. /** @hidden */
  36042. _checkCollision(collider: Collider): AbstractMesh;
  36043. /** @hidden */
  36044. _generatePointsArray(): boolean;
  36045. /**
  36046. * Checks if the passed Ray intersects with the mesh
  36047. * @param ray defines the ray to use
  36048. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36049. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36050. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36051. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36052. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36053. * @returns the picking info
  36054. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36055. */
  36056. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36057. /**
  36058. * Clones the current mesh
  36059. * @param name defines the mesh name
  36060. * @param newParent defines the new mesh parent
  36061. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36062. * @returns the new mesh
  36063. */
  36064. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36065. /**
  36066. * Disposes all the submeshes of the current meshnp
  36067. * @returns the current mesh
  36068. */
  36069. releaseSubMeshes(): AbstractMesh;
  36070. /**
  36071. * Releases resources associated with this abstract mesh.
  36072. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36073. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36074. */
  36075. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36076. /**
  36077. * Adds the passed mesh as a child to the current mesh
  36078. * @param mesh defines the child mesh
  36079. * @returns the current mesh
  36080. */
  36081. addChild(mesh: AbstractMesh): AbstractMesh;
  36082. /**
  36083. * Removes the passed mesh from the current mesh children list
  36084. * @param mesh defines the child mesh
  36085. * @returns the current mesh
  36086. */
  36087. removeChild(mesh: AbstractMesh): AbstractMesh;
  36088. /** @hidden */
  36089. private _initFacetData;
  36090. /**
  36091. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36092. * This method can be called within the render loop.
  36093. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  36094. * @returns the current mesh
  36095. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36096. */
  36097. updateFacetData(): AbstractMesh;
  36098. /**
  36099. * Returns the facetLocalNormals array.
  36100. * The normals are expressed in the mesh local spac
  36101. * @returns an array of Vector3
  36102. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36103. */
  36104. getFacetLocalNormals(): Vector3[];
  36105. /**
  36106. * Returns the facetLocalPositions array.
  36107. * The facet positions are expressed in the mesh local space
  36108. * @returns an array of Vector3
  36109. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36110. */
  36111. getFacetLocalPositions(): Vector3[];
  36112. /**
  36113. * Returns the facetLocalPartioning array
  36114. * @returns an array of array of numbers
  36115. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36116. */
  36117. getFacetLocalPartitioning(): number[][];
  36118. /**
  36119. * Returns the i-th facet position in the world system.
  36120. * This method allocates a new Vector3 per call
  36121. * @param i defines the facet index
  36122. * @returns a new Vector3
  36123. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36124. */
  36125. getFacetPosition(i: number): Vector3;
  36126. /**
  36127. * Sets the reference Vector3 with the i-th facet position in the world system
  36128. * @param i defines the facet index
  36129. * @param ref defines the target vector
  36130. * @returns the current mesh
  36131. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36132. */
  36133. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36134. /**
  36135. * Returns the i-th facet normal in the world system.
  36136. * This method allocates a new Vector3 per call
  36137. * @param i defines the facet index
  36138. * @returns a new Vector3
  36139. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36140. */
  36141. getFacetNormal(i: number): Vector3;
  36142. /**
  36143. * Sets the reference Vector3 with the i-th facet normal in the world system
  36144. * @param i defines the facet index
  36145. * @param ref defines the target vector
  36146. * @returns the current mesh
  36147. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36148. */
  36149. getFacetNormalToRef(i: number, ref: Vector3): this;
  36150. /**
  36151. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  36152. * @param x defines x coordinate
  36153. * @param y defines y coordinate
  36154. * @param z defines z coordinate
  36155. * @returns the array of facet indexes
  36156. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36157. */
  36158. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36159. /**
  36160. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36161. * @param projected sets as the (x,y,z) world projection on the facet
  36162. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  36163. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  36164. * @param x defines x coordinate
  36165. * @param y defines y coordinate
  36166. * @param z defines z coordinate
  36167. * @returns the face index if found (or null instead)
  36168. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36169. */
  36170. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36171. /**
  36172. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36173. * @param projected sets as the (x,y,z) local projection on the facet
  36174. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  36175. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  36176. * @param x defines x coordinate
  36177. * @param y defines y coordinate
  36178. * @param z defines z coordinate
  36179. * @returns the face index if found (or null instead)
  36180. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36181. */
  36182. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36183. /**
  36184. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36185. * @returns the parameters
  36186. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36187. */
  36188. getFacetDataParameters(): any;
  36189. /**
  36190. * Disables the feature FacetData and frees the related memory
  36191. * @returns the current mesh
  36192. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36193. */
  36194. disableFacetData(): AbstractMesh;
  36195. /**
  36196. * Updates the AbstractMesh indices array
  36197. * @param indices defines the data source
  36198. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36199. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  36200. * @returns the current mesh
  36201. */
  36202. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36203. /**
  36204. * Creates new normals data for the mesh
  36205. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36206. * @returns the current mesh
  36207. */
  36208. createNormals(updatable: boolean): AbstractMesh;
  36209. /**
  36210. * Align the mesh with a normal
  36211. * @param normal defines the normal to use
  36212. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36213. * @returns the current mesh
  36214. */
  36215. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  36216. /** @hidden */
  36217. _checkOcclusionQuery(): boolean;
  36218. /**
  36219. * Disables the mesh edge rendering mode
  36220. * @returns the currentAbstractMesh
  36221. */
  36222. disableEdgesRendering(): AbstractMesh;
  36223. /**
  36224. * Enables the edge rendering mode on the mesh.
  36225. * This mode makes the mesh edges visible
  36226. * @param epsilon defines the maximal distance between two angles to detect a face
  36227. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36228. * @returns the currentAbstractMesh
  36229. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36230. */
  36231. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36232. /**
  36233. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  36234. * @returns an array of particle systems in the scene that use the mesh as an emitter
  36235. */
  36236. getConnectedParticleSystems(): IParticleSystem[];
  36237. }
  36238. }
  36239. declare module BABYLON {
  36240. /**
  36241. * Interface used to define ActionEvent
  36242. */
  36243. export interface IActionEvent {
  36244. /** The mesh or sprite that triggered the action */
  36245. source: any;
  36246. /** The X mouse cursor position at the time of the event */
  36247. pointerX: number;
  36248. /** The Y mouse cursor position at the time of the event */
  36249. pointerY: number;
  36250. /** The mesh that is currently pointed at (can be null) */
  36251. meshUnderPointer: Nullable<AbstractMesh>;
  36252. /** the original (browser) event that triggered the ActionEvent */
  36253. sourceEvent?: any;
  36254. /** additional data for the event */
  36255. additionalData?: any;
  36256. }
  36257. /**
  36258. * ActionEvent is the event being sent when an action is triggered.
  36259. */
  36260. export class ActionEvent implements IActionEvent {
  36261. /** The mesh or sprite that triggered the action */
  36262. source: any;
  36263. /** The X mouse cursor position at the time of the event */
  36264. pointerX: number;
  36265. /** The Y mouse cursor position at the time of the event */
  36266. pointerY: number;
  36267. /** The mesh that is currently pointed at (can be null) */
  36268. meshUnderPointer: Nullable<AbstractMesh>;
  36269. /** the original (browser) event that triggered the ActionEvent */
  36270. sourceEvent?: any;
  36271. /** additional data for the event */
  36272. additionalData?: any;
  36273. /**
  36274. * Creates a new ActionEvent
  36275. * @param source The mesh or sprite that triggered the action
  36276. * @param pointerX The X mouse cursor position at the time of the event
  36277. * @param pointerY The Y mouse cursor position at the time of the event
  36278. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36279. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36280. * @param additionalData additional data for the event
  36281. */
  36282. constructor(
  36283. /** The mesh or sprite that triggered the action */
  36284. source: any,
  36285. /** The X mouse cursor position at the time of the event */
  36286. pointerX: number,
  36287. /** The Y mouse cursor position at the time of the event */
  36288. pointerY: number,
  36289. /** The mesh that is currently pointed at (can be null) */
  36290. meshUnderPointer: Nullable<AbstractMesh>,
  36291. /** the original (browser) event that triggered the ActionEvent */
  36292. sourceEvent?: any,
  36293. /** additional data for the event */
  36294. additionalData?: any);
  36295. /**
  36296. * Helper function to auto-create an ActionEvent from a source mesh.
  36297. * @param source The source mesh that triggered the event
  36298. * @param evt The original (browser) event
  36299. * @param additionalData additional data for the event
  36300. * @returns the new ActionEvent
  36301. */
  36302. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36303. /**
  36304. * Helper function to auto-create an ActionEvent from a source sprite
  36305. * @param source The source sprite that triggered the event
  36306. * @param scene Scene associated with the sprite
  36307. * @param evt The original (browser) event
  36308. * @param additionalData additional data for the event
  36309. * @returns the new ActionEvent
  36310. */
  36311. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36312. /**
  36313. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36314. * @param scene the scene where the event occurred
  36315. * @param evt The original (browser) event
  36316. * @returns the new ActionEvent
  36317. */
  36318. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36319. /**
  36320. * Helper function to auto-create an ActionEvent from a primitive
  36321. * @param prim defines the target primitive
  36322. * @param pointerPos defines the pointer position
  36323. * @param evt The original (browser) event
  36324. * @param additionalData additional data for the event
  36325. * @returns the new ActionEvent
  36326. */
  36327. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36328. }
  36329. }
  36330. declare module BABYLON {
  36331. /**
  36332. * Abstract class used to decouple action Manager from scene and meshes.
  36333. * Do not instantiate.
  36334. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36335. */
  36336. export abstract class AbstractActionManager implements IDisposable {
  36337. /** Gets the list of active triggers */
  36338. static Triggers: {
  36339. [key: string]: number;
  36340. };
  36341. /** Gets the cursor to use when hovering items */
  36342. hoverCursor: string;
  36343. /** Gets the list of actions */
  36344. actions: IAction[];
  36345. /**
  36346. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36347. */
  36348. isRecursive: boolean;
  36349. /**
  36350. * Releases all associated resources
  36351. */
  36352. abstract dispose(): void;
  36353. /**
  36354. * Does this action manager has pointer triggers
  36355. */
  36356. abstract get hasPointerTriggers(): boolean;
  36357. /**
  36358. * Does this action manager has pick triggers
  36359. */
  36360. abstract get hasPickTriggers(): boolean;
  36361. /**
  36362. * Process a specific trigger
  36363. * @param trigger defines the trigger to process
  36364. * @param evt defines the event details to be processed
  36365. */
  36366. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36367. /**
  36368. * Does this action manager handles actions of any of the given triggers
  36369. * @param triggers defines the triggers to be tested
  36370. * @return a boolean indicating whether one (or more) of the triggers is handled
  36371. */
  36372. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36373. /**
  36374. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36375. * speed.
  36376. * @param triggerA defines the trigger to be tested
  36377. * @param triggerB defines the trigger to be tested
  36378. * @return a boolean indicating whether one (or more) of the triggers is handled
  36379. */
  36380. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36381. /**
  36382. * Does this action manager handles actions of a given trigger
  36383. * @param trigger defines the trigger to be tested
  36384. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36385. * @return whether the trigger is handled
  36386. */
  36387. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36388. /**
  36389. * Serialize this manager to a JSON object
  36390. * @param name defines the property name to store this manager
  36391. * @returns a JSON representation of this manager
  36392. */
  36393. abstract serialize(name: string): any;
  36394. /**
  36395. * Registers an action to this action manager
  36396. * @param action defines the action to be registered
  36397. * @return the action amended (prepared) after registration
  36398. */
  36399. abstract registerAction(action: IAction): Nullable<IAction>;
  36400. /**
  36401. * Unregisters an action to this action manager
  36402. * @param action defines the action to be unregistered
  36403. * @return a boolean indicating whether the action has been unregistered
  36404. */
  36405. abstract unregisterAction(action: IAction): Boolean;
  36406. /**
  36407. * Does exist one action manager with at least one trigger
  36408. **/
  36409. static get HasTriggers(): boolean;
  36410. /**
  36411. * Does exist one action manager with at least one pick trigger
  36412. **/
  36413. static get HasPickTriggers(): boolean;
  36414. /**
  36415. * Does exist one action manager that handles actions of a given trigger
  36416. * @param trigger defines the trigger to be tested
  36417. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36418. **/
  36419. static HasSpecificTrigger(trigger: number): boolean;
  36420. }
  36421. }
  36422. declare module BABYLON {
  36423. /**
  36424. * Defines how a node can be built from a string name.
  36425. */
  36426. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36427. /**
  36428. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36429. */
  36430. export class Node implements IBehaviorAware<Node> {
  36431. /** @hidden */
  36432. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36433. private static _NodeConstructors;
  36434. /**
  36435. * Add a new node constructor
  36436. * @param type defines the type name of the node to construct
  36437. * @param constructorFunc defines the constructor function
  36438. */
  36439. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36440. /**
  36441. * Returns a node constructor based on type name
  36442. * @param type defines the type name
  36443. * @param name defines the new node name
  36444. * @param scene defines the hosting scene
  36445. * @param options defines optional options to transmit to constructors
  36446. * @returns the new constructor or null
  36447. */
  36448. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36449. /**
  36450. * Gets or sets the name of the node
  36451. */
  36452. name: string;
  36453. /**
  36454. * Gets or sets the id of the node
  36455. */
  36456. id: string;
  36457. /**
  36458. * Gets or sets the unique id of the node
  36459. */
  36460. uniqueId: number;
  36461. /**
  36462. * Gets or sets a string used to store user defined state for the node
  36463. */
  36464. state: string;
  36465. /**
  36466. * Gets or sets an object used to store user defined information for the node
  36467. */
  36468. metadata: any;
  36469. /**
  36470. * For internal use only. Please do not use.
  36471. */
  36472. reservedDataStore: any;
  36473. /**
  36474. * List of inspectable custom properties (used by the Inspector)
  36475. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36476. */
  36477. inspectableCustomProperties: IInspectable[];
  36478. private _doNotSerialize;
  36479. /**
  36480. * Gets or sets a boolean used to define if the node must be serialized
  36481. */
  36482. get doNotSerialize(): boolean;
  36483. set doNotSerialize(value: boolean);
  36484. /** @hidden */
  36485. _isDisposed: boolean;
  36486. /**
  36487. * Gets a list of Animations associated with the node
  36488. */
  36489. animations: Animation[];
  36490. protected _ranges: {
  36491. [name: string]: Nullable<AnimationRange>;
  36492. };
  36493. /**
  36494. * Callback raised when the node is ready to be used
  36495. */
  36496. onReady: Nullable<(node: Node) => void>;
  36497. private _isEnabled;
  36498. private _isParentEnabled;
  36499. private _isReady;
  36500. /** @hidden */
  36501. _currentRenderId: number;
  36502. private _parentUpdateId;
  36503. /** @hidden */
  36504. _childUpdateId: number;
  36505. /** @hidden */
  36506. _waitingParentId: Nullable<string>;
  36507. /** @hidden */
  36508. _scene: Scene;
  36509. /** @hidden */
  36510. _cache: any;
  36511. private _parentNode;
  36512. private _children;
  36513. /** @hidden */
  36514. _worldMatrix: Matrix;
  36515. /** @hidden */
  36516. _worldMatrixDeterminant: number;
  36517. /** @hidden */
  36518. _worldMatrixDeterminantIsDirty: boolean;
  36519. /** @hidden */
  36520. private _sceneRootNodesIndex;
  36521. /**
  36522. * Gets a boolean indicating if the node has been disposed
  36523. * @returns true if the node was disposed
  36524. */
  36525. isDisposed(): boolean;
  36526. /**
  36527. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36528. * @see https://doc.babylonjs.com/how_to/parenting
  36529. */
  36530. set parent(parent: Nullable<Node>);
  36531. get parent(): Nullable<Node>;
  36532. /** @hidden */
  36533. _addToSceneRootNodes(): void;
  36534. /** @hidden */
  36535. _removeFromSceneRootNodes(): void;
  36536. private _animationPropertiesOverride;
  36537. /**
  36538. * Gets or sets the animation properties override
  36539. */
  36540. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36541. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36542. /**
  36543. * Gets a string identifying the name of the class
  36544. * @returns "Node" string
  36545. */
  36546. getClassName(): string;
  36547. /** @hidden */
  36548. readonly _isNode: boolean;
  36549. /**
  36550. * An event triggered when the mesh is disposed
  36551. */
  36552. onDisposeObservable: Observable<Node>;
  36553. private _onDisposeObserver;
  36554. /**
  36555. * Sets a callback that will be raised when the node will be disposed
  36556. */
  36557. set onDispose(callback: () => void);
  36558. /**
  36559. * Creates a new Node
  36560. * @param name the name and id to be given to this node
  36561. * @param scene the scene this node will be added to
  36562. */
  36563. constructor(name: string, scene?: Nullable<Scene>);
  36564. /**
  36565. * Gets the scene of the node
  36566. * @returns a scene
  36567. */
  36568. getScene(): Scene;
  36569. /**
  36570. * Gets the engine of the node
  36571. * @returns a Engine
  36572. */
  36573. getEngine(): Engine;
  36574. private _behaviors;
  36575. /**
  36576. * Attach a behavior to the node
  36577. * @see https://doc.babylonjs.com/features/behaviour
  36578. * @param behavior defines the behavior to attach
  36579. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36580. * @returns the current Node
  36581. */
  36582. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36583. /**
  36584. * Remove an attached behavior
  36585. * @see https://doc.babylonjs.com/features/behaviour
  36586. * @param behavior defines the behavior to attach
  36587. * @returns the current Node
  36588. */
  36589. removeBehavior(behavior: Behavior<Node>): Node;
  36590. /**
  36591. * Gets the list of attached behaviors
  36592. * @see https://doc.babylonjs.com/features/behaviour
  36593. */
  36594. get behaviors(): Behavior<Node>[];
  36595. /**
  36596. * Gets an attached behavior by name
  36597. * @param name defines the name of the behavior to look for
  36598. * @see https://doc.babylonjs.com/features/behaviour
  36599. * @returns null if behavior was not found else the requested behavior
  36600. */
  36601. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36602. /**
  36603. * Returns the latest update of the World matrix
  36604. * @returns a Matrix
  36605. */
  36606. getWorldMatrix(): Matrix;
  36607. /** @hidden */
  36608. _getWorldMatrixDeterminant(): number;
  36609. /**
  36610. * Returns directly the latest state of the mesh World matrix.
  36611. * A Matrix is returned.
  36612. */
  36613. get worldMatrixFromCache(): Matrix;
  36614. /** @hidden */
  36615. _initCache(): void;
  36616. /** @hidden */
  36617. updateCache(force?: boolean): void;
  36618. /** @hidden */
  36619. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36620. /** @hidden */
  36621. _updateCache(ignoreParentClass?: boolean): void;
  36622. /** @hidden */
  36623. _isSynchronized(): boolean;
  36624. /** @hidden */
  36625. _markSyncedWithParent(): void;
  36626. /** @hidden */
  36627. isSynchronizedWithParent(): boolean;
  36628. /** @hidden */
  36629. isSynchronized(): boolean;
  36630. /**
  36631. * Is this node ready to be used/rendered
  36632. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36633. * @return true if the node is ready
  36634. */
  36635. isReady(completeCheck?: boolean): boolean;
  36636. /**
  36637. * Is this node enabled?
  36638. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  36639. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  36640. * @return whether this node (and its parent) is enabled
  36641. */
  36642. isEnabled(checkAncestors?: boolean): boolean;
  36643. /** @hidden */
  36644. protected _syncParentEnabledState(): void;
  36645. /**
  36646. * Set the enabled state of this node
  36647. * @param value defines the new enabled state
  36648. */
  36649. setEnabled(value: boolean): void;
  36650. /**
  36651. * Is this node a descendant of the given node?
  36652. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36653. * @param ancestor defines the parent node to inspect
  36654. * @returns a boolean indicating if this node is a descendant of the given node
  36655. */
  36656. isDescendantOf(ancestor: Node): boolean;
  36657. /** @hidden */
  36658. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36659. /**
  36660. * Will return all nodes that have this node as ascendant
  36661. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  36662. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  36663. * @return all children nodes of all types
  36664. */
  36665. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36666. /**
  36667. * Get all child-meshes of this node
  36668. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  36669. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  36670. * @returns an array of AbstractMesh
  36671. */
  36672. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36673. /**
  36674. * Get all direct children of this node
  36675. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  36676. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  36677. * @returns an array of Node
  36678. */
  36679. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36680. /** @hidden */
  36681. _setReady(state: boolean): void;
  36682. /**
  36683. * Get an animation by name
  36684. * @param name defines the name of the animation to look for
  36685. * @returns null if not found else the requested animation
  36686. */
  36687. getAnimationByName(name: string): Nullable<Animation>;
  36688. /**
  36689. * Creates an animation range for this node
  36690. * @param name defines the name of the range
  36691. * @param from defines the starting key
  36692. * @param to defines the end key
  36693. */
  36694. createAnimationRange(name: string, from: number, to: number): void;
  36695. /**
  36696. * Delete a specific animation range
  36697. * @param name defines the name of the range to delete
  36698. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36699. */
  36700. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36701. /**
  36702. * Get an animation range by name
  36703. * @param name defines the name of the animation range to look for
  36704. * @returns null if not found else the requested animation range
  36705. */
  36706. getAnimationRange(name: string): Nullable<AnimationRange>;
  36707. /**
  36708. * Gets the list of all animation ranges defined on this node
  36709. * @returns an array
  36710. */
  36711. getAnimationRanges(): Nullable<AnimationRange>[];
  36712. /**
  36713. * Will start the animation sequence
  36714. * @param name defines the range frames for animation sequence
  36715. * @param loop defines if the animation should loop (false by default)
  36716. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36717. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36718. * @returns the object created for this animation. If range does not exist, it will return null
  36719. */
  36720. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36721. /**
  36722. * Serialize animation ranges into a JSON compatible object
  36723. * @returns serialization object
  36724. */
  36725. serializeAnimationRanges(): any;
  36726. /**
  36727. * Computes the world matrix of the node
  36728. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36729. * @returns the world matrix
  36730. */
  36731. computeWorldMatrix(force?: boolean): Matrix;
  36732. /**
  36733. * Releases resources associated with this node.
  36734. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36735. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36736. */
  36737. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36738. /**
  36739. * Parse animation range data from a serialization object and store them into a given node
  36740. * @param node defines where to store the animation ranges
  36741. * @param parsedNode defines the serialization object to read data from
  36742. * @param scene defines the hosting scene
  36743. */
  36744. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36745. /**
  36746. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36747. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36748. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  36749. * @returns the new bounding vectors
  36750. */
  36751. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36752. min: Vector3;
  36753. max: Vector3;
  36754. };
  36755. }
  36756. }
  36757. declare module BABYLON {
  36758. /**
  36759. * @hidden
  36760. */
  36761. export class _IAnimationState {
  36762. key: number;
  36763. repeatCount: number;
  36764. workValue?: any;
  36765. loopMode?: number;
  36766. offsetValue?: any;
  36767. highLimitValue?: any;
  36768. }
  36769. /**
  36770. * Class used to store any kind of animation
  36771. */
  36772. export class Animation {
  36773. /**Name of the animation */
  36774. name: string;
  36775. /**Property to animate */
  36776. targetProperty: string;
  36777. /**The frames per second of the animation */
  36778. framePerSecond: number;
  36779. /**The data type of the animation */
  36780. dataType: number;
  36781. /**The loop mode of the animation */
  36782. loopMode?: number | undefined;
  36783. /**Specifies if blending should be enabled */
  36784. enableBlending?: boolean | undefined;
  36785. /**
  36786. * Use matrix interpolation instead of using direct key value when animating matrices
  36787. */
  36788. static AllowMatricesInterpolation: boolean;
  36789. /**
  36790. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36791. */
  36792. static AllowMatrixDecomposeForInterpolation: boolean;
  36793. /** Define the Url to load snippets */
  36794. static SnippetUrl: string;
  36795. /** Snippet ID if the animation was created from the snippet server */
  36796. snippetId: string;
  36797. /**
  36798. * Stores the key frames of the animation
  36799. */
  36800. private _keys;
  36801. /**
  36802. * Stores the easing function of the animation
  36803. */
  36804. private _easingFunction;
  36805. /**
  36806. * @hidden Internal use only
  36807. */
  36808. _runtimeAnimations: RuntimeAnimation[];
  36809. /**
  36810. * The set of event that will be linked to this animation
  36811. */
  36812. private _events;
  36813. /**
  36814. * Stores an array of target property paths
  36815. */
  36816. targetPropertyPath: string[];
  36817. /**
  36818. * Stores the blending speed of the animation
  36819. */
  36820. blendingSpeed: number;
  36821. /**
  36822. * Stores the animation ranges for the animation
  36823. */
  36824. private _ranges;
  36825. /**
  36826. * @hidden Internal use
  36827. */
  36828. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36829. /**
  36830. * Sets up an animation
  36831. * @param property The property to animate
  36832. * @param animationType The animation type to apply
  36833. * @param framePerSecond The frames per second of the animation
  36834. * @param easingFunction The easing function used in the animation
  36835. * @returns The created animation
  36836. */
  36837. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36838. /**
  36839. * Create and start an animation on a node
  36840. * @param name defines the name of the global animation that will be run on all nodes
  36841. * @param node defines the root node where the animation will take place
  36842. * @param targetProperty defines property to animate
  36843. * @param framePerSecond defines the number of frame per second yo use
  36844. * @param totalFrame defines the number of frames in total
  36845. * @param from defines the initial value
  36846. * @param to defines the final value
  36847. * @param loopMode defines which loop mode you want to use (off by default)
  36848. * @param easingFunction defines the easing function to use (linear by default)
  36849. * @param onAnimationEnd defines the callback to call when animation end
  36850. * @returns the animatable created for this animation
  36851. */
  36852. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36853. /**
  36854. * Create and start an animation on a node and its descendants
  36855. * @param name defines the name of the global animation that will be run on all nodes
  36856. * @param node defines the root node where the animation will take place
  36857. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  36858. * @param targetProperty defines property to animate
  36859. * @param framePerSecond defines the number of frame per second to use
  36860. * @param totalFrame defines the number of frames in total
  36861. * @param from defines the initial value
  36862. * @param to defines the final value
  36863. * @param loopMode defines which loop mode you want to use (off by default)
  36864. * @param easingFunction defines the easing function to use (linear by default)
  36865. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36866. * @returns the list of animatables created for all nodes
  36867. * @example https://www.babylonjs-playground.com/#MH0VLI
  36868. */
  36869. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  36870. /**
  36871. * Creates a new animation, merges it with the existing animations and starts it
  36872. * @param name Name of the animation
  36873. * @param node Node which contains the scene that begins the animations
  36874. * @param targetProperty Specifies which property to animate
  36875. * @param framePerSecond The frames per second of the animation
  36876. * @param totalFrame The total number of frames
  36877. * @param from The frame at the beginning of the animation
  36878. * @param to The frame at the end of the animation
  36879. * @param loopMode Specifies the loop mode of the animation
  36880. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36881. * @param onAnimationEnd Callback to run once the animation is complete
  36882. * @returns Nullable animation
  36883. */
  36884. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36885. /**
  36886. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36887. * @param sourceAnimation defines the Animation containing keyframes to convert
  36888. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36889. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36890. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36891. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36892. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36893. */
  36894. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36895. /**
  36896. * Transition property of an host to the target Value
  36897. * @param property The property to transition
  36898. * @param targetValue The target Value of the property
  36899. * @param host The object where the property to animate belongs
  36900. * @param scene Scene used to run the animation
  36901. * @param frameRate Framerate (in frame/s) to use
  36902. * @param transition The transition type we want to use
  36903. * @param duration The duration of the animation, in milliseconds
  36904. * @param onAnimationEnd Callback trigger at the end of the animation
  36905. * @returns Nullable animation
  36906. */
  36907. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36908. /**
  36909. * Return the array of runtime animations currently using this animation
  36910. */
  36911. get runtimeAnimations(): RuntimeAnimation[];
  36912. /**
  36913. * Specifies if any of the runtime animations are currently running
  36914. */
  36915. get hasRunningRuntimeAnimations(): boolean;
  36916. /**
  36917. * Initializes the animation
  36918. * @param name Name of the animation
  36919. * @param targetProperty Property to animate
  36920. * @param framePerSecond The frames per second of the animation
  36921. * @param dataType The data type of the animation
  36922. * @param loopMode The loop mode of the animation
  36923. * @param enableBlending Specifies if blending should be enabled
  36924. */
  36925. constructor(
  36926. /**Name of the animation */
  36927. name: string,
  36928. /**Property to animate */
  36929. targetProperty: string,
  36930. /**The frames per second of the animation */
  36931. framePerSecond: number,
  36932. /**The data type of the animation */
  36933. dataType: number,
  36934. /**The loop mode of the animation */
  36935. loopMode?: number | undefined,
  36936. /**Specifies if blending should be enabled */
  36937. enableBlending?: boolean | undefined);
  36938. /**
  36939. * Converts the animation to a string
  36940. * @param fullDetails support for multiple levels of logging within scene loading
  36941. * @returns String form of the animation
  36942. */
  36943. toString(fullDetails?: boolean): string;
  36944. /**
  36945. * Add an event to this animation
  36946. * @param event Event to add
  36947. */
  36948. addEvent(event: AnimationEvent): void;
  36949. /**
  36950. * Remove all events found at the given frame
  36951. * @param frame The frame to remove events from
  36952. */
  36953. removeEvents(frame: number): void;
  36954. /**
  36955. * Retrieves all the events from the animation
  36956. * @returns Events from the animation
  36957. */
  36958. getEvents(): AnimationEvent[];
  36959. /**
  36960. * Creates an animation range
  36961. * @param name Name of the animation range
  36962. * @param from Starting frame of the animation range
  36963. * @param to Ending frame of the animation
  36964. */
  36965. createRange(name: string, from: number, to: number): void;
  36966. /**
  36967. * Deletes an animation range by name
  36968. * @param name Name of the animation range to delete
  36969. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36970. */
  36971. deleteRange(name: string, deleteFrames?: boolean): void;
  36972. /**
  36973. * Gets the animation range by name, or null if not defined
  36974. * @param name Name of the animation range
  36975. * @returns Nullable animation range
  36976. */
  36977. getRange(name: string): Nullable<AnimationRange>;
  36978. /**
  36979. * Gets the key frames from the animation
  36980. * @returns The key frames of the animation
  36981. */
  36982. getKeys(): Array<IAnimationKey>;
  36983. /**
  36984. * Gets the highest frame rate of the animation
  36985. * @returns Highest frame rate of the animation
  36986. */
  36987. getHighestFrame(): number;
  36988. /**
  36989. * Gets the easing function of the animation
  36990. * @returns Easing function of the animation
  36991. */
  36992. getEasingFunction(): IEasingFunction;
  36993. /**
  36994. * Sets the easing function of the animation
  36995. * @param easingFunction A custom mathematical formula for animation
  36996. */
  36997. setEasingFunction(easingFunction: EasingFunction): void;
  36998. /**
  36999. * Interpolates a scalar linearly
  37000. * @param startValue Start value of the animation curve
  37001. * @param endValue End value of the animation curve
  37002. * @param gradient Scalar amount to interpolate
  37003. * @returns Interpolated scalar value
  37004. */
  37005. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37006. /**
  37007. * Interpolates a scalar cubically
  37008. * @param startValue Start value of the animation curve
  37009. * @param outTangent End tangent of the animation
  37010. * @param endValue End value of the animation curve
  37011. * @param inTangent Start tangent of the animation curve
  37012. * @param gradient Scalar amount to interpolate
  37013. * @returns Interpolated scalar value
  37014. */
  37015. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37016. /**
  37017. * Interpolates a quaternion using a spherical linear interpolation
  37018. * @param startValue Start value of the animation curve
  37019. * @param endValue End value of the animation curve
  37020. * @param gradient Scalar amount to interpolate
  37021. * @returns Interpolated quaternion value
  37022. */
  37023. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37024. /**
  37025. * Interpolates a quaternion cubically
  37026. * @param startValue Start value of the animation curve
  37027. * @param outTangent End tangent of the animation curve
  37028. * @param endValue End value of the animation curve
  37029. * @param inTangent Start tangent of the animation curve
  37030. * @param gradient Scalar amount to interpolate
  37031. * @returns Interpolated quaternion value
  37032. */
  37033. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37034. /**
  37035. * Interpolates a Vector3 linearl
  37036. * @param startValue Start value of the animation curve
  37037. * @param endValue End value of the animation curve
  37038. * @param gradient Scalar amount to interpolate
  37039. * @returns Interpolated scalar value
  37040. */
  37041. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37042. /**
  37043. * Interpolates a Vector3 cubically
  37044. * @param startValue Start value of the animation curve
  37045. * @param outTangent End tangent of the animation
  37046. * @param endValue End value of the animation curve
  37047. * @param inTangent Start tangent of the animation curve
  37048. * @param gradient Scalar amount to interpolate
  37049. * @returns InterpolatedVector3 value
  37050. */
  37051. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37052. /**
  37053. * Interpolates a Vector2 linearly
  37054. * @param startValue Start value of the animation curve
  37055. * @param endValue End value of the animation curve
  37056. * @param gradient Scalar amount to interpolate
  37057. * @returns Interpolated Vector2 value
  37058. */
  37059. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37060. /**
  37061. * Interpolates a Vector2 cubically
  37062. * @param startValue Start value of the animation curve
  37063. * @param outTangent End tangent of the animation
  37064. * @param endValue End value of the animation curve
  37065. * @param inTangent Start tangent of the animation curve
  37066. * @param gradient Scalar amount to interpolate
  37067. * @returns Interpolated Vector2 value
  37068. */
  37069. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37070. /**
  37071. * Interpolates a size linearly
  37072. * @param startValue Start value of the animation curve
  37073. * @param endValue End value of the animation curve
  37074. * @param gradient Scalar amount to interpolate
  37075. * @returns Interpolated Size value
  37076. */
  37077. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37078. /**
  37079. * Interpolates a Color3 linearly
  37080. * @param startValue Start value of the animation curve
  37081. * @param endValue End value of the animation curve
  37082. * @param gradient Scalar amount to interpolate
  37083. * @returns Interpolated Color3 value
  37084. */
  37085. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37086. /**
  37087. * Interpolates a Color4 linearly
  37088. * @param startValue Start value of the animation curve
  37089. * @param endValue End value of the animation curve
  37090. * @param gradient Scalar amount to interpolate
  37091. * @returns Interpolated Color3 value
  37092. */
  37093. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37094. /**
  37095. * @hidden Internal use only
  37096. */
  37097. _getKeyValue(value: any): any;
  37098. /**
  37099. * @hidden Internal use only
  37100. */
  37101. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37102. /**
  37103. * Defines the function to use to interpolate matrices
  37104. * @param startValue defines the start matrix
  37105. * @param endValue defines the end matrix
  37106. * @param gradient defines the gradient between both matrices
  37107. * @param result defines an optional target matrix where to store the interpolation
  37108. * @returns the interpolated matrix
  37109. */
  37110. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37111. /**
  37112. * Makes a copy of the animation
  37113. * @returns Cloned animation
  37114. */
  37115. clone(): Animation;
  37116. /**
  37117. * Sets the key frames of the animation
  37118. * @param values The animation key frames to set
  37119. */
  37120. setKeys(values: Array<IAnimationKey>): void;
  37121. /**
  37122. * Serializes the animation to an object
  37123. * @returns Serialized object
  37124. */
  37125. serialize(): any;
  37126. /**
  37127. * Float animation type
  37128. */
  37129. static readonly ANIMATIONTYPE_FLOAT: number;
  37130. /**
  37131. * Vector3 animation type
  37132. */
  37133. static readonly ANIMATIONTYPE_VECTOR3: number;
  37134. /**
  37135. * Quaternion animation type
  37136. */
  37137. static readonly ANIMATIONTYPE_QUATERNION: number;
  37138. /**
  37139. * Matrix animation type
  37140. */
  37141. static readonly ANIMATIONTYPE_MATRIX: number;
  37142. /**
  37143. * Color3 animation type
  37144. */
  37145. static readonly ANIMATIONTYPE_COLOR3: number;
  37146. /**
  37147. * Color3 animation type
  37148. */
  37149. static readonly ANIMATIONTYPE_COLOR4: number;
  37150. /**
  37151. * Vector2 animation type
  37152. */
  37153. static readonly ANIMATIONTYPE_VECTOR2: number;
  37154. /**
  37155. * Size animation type
  37156. */
  37157. static readonly ANIMATIONTYPE_SIZE: number;
  37158. /**
  37159. * Relative Loop Mode
  37160. */
  37161. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37162. /**
  37163. * Cycle Loop Mode
  37164. */
  37165. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37166. /**
  37167. * Constant Loop Mode
  37168. */
  37169. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37170. /** @hidden */
  37171. static _UniversalLerp(left: any, right: any, amount: number): any;
  37172. /**
  37173. * Parses an animation object and creates an animation
  37174. * @param parsedAnimation Parsed animation object
  37175. * @returns Animation object
  37176. */
  37177. static Parse(parsedAnimation: any): Animation;
  37178. /**
  37179. * Appends the serialized animations from the source animations
  37180. * @param source Source containing the animations
  37181. * @param destination Target to store the animations
  37182. */
  37183. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37184. /**
  37185. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37186. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37187. * @param url defines the url to load from
  37188. * @returns a promise that will resolve to the new animation or an array of animations
  37189. */
  37190. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37191. /**
  37192. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37193. * @param snippetId defines the snippet to load
  37194. * @returns a promise that will resolve to the new animation or a new array of animations
  37195. */
  37196. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37197. }
  37198. }
  37199. declare module BABYLON {
  37200. /**
  37201. * Interface containing an array of animations
  37202. */
  37203. export interface IAnimatable {
  37204. /**
  37205. * Array of animations
  37206. */
  37207. animations: Nullable<Array<Animation>>;
  37208. }
  37209. }
  37210. declare module BABYLON {
  37211. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37212. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37213. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37214. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37215. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37216. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37217. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37218. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37219. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37220. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37221. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37222. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37223. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37224. /**
  37225. * Decorator used to define property that can be serialized as reference to a camera
  37226. * @param sourceName defines the name of the property to decorate
  37227. */
  37228. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37229. /**
  37230. * Class used to help serialization objects
  37231. */
  37232. export class SerializationHelper {
  37233. /** @hidden */
  37234. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  37235. /** @hidden */
  37236. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  37237. /** @hidden */
  37238. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  37239. /** @hidden */
  37240. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  37241. /**
  37242. * Appends the serialized animations from the source animations
  37243. * @param source Source containing the animations
  37244. * @param destination Target to store the animations
  37245. */
  37246. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37247. /**
  37248. * Static function used to serialized a specific entity
  37249. * @param entity defines the entity to serialize
  37250. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37251. * @returns a JSON compatible object representing the serialization of the entity
  37252. */
  37253. static Serialize<T>(entity: T, serializationObject?: any): any;
  37254. /**
  37255. * Creates a new entity from a serialization data object
  37256. * @param creationFunction defines a function used to instanciated the new entity
  37257. * @param source defines the source serialization data
  37258. * @param scene defines the hosting scene
  37259. * @param rootUrl defines the root url for resources
  37260. * @returns a new entity
  37261. */
  37262. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37263. /**
  37264. * Clones an object
  37265. * @param creationFunction defines the function used to instanciate the new object
  37266. * @param source defines the source object
  37267. * @returns the cloned object
  37268. */
  37269. static Clone<T>(creationFunction: () => T, source: T): T;
  37270. /**
  37271. * Instanciates a new object based on a source one (some data will be shared between both object)
  37272. * @param creationFunction defines the function used to instanciate the new object
  37273. * @param source defines the source object
  37274. * @returns the new object
  37275. */
  37276. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37277. }
  37278. }
  37279. declare module BABYLON {
  37280. /**
  37281. * Base class of all the textures in babylon.
  37282. * It groups all the common properties the materials, post process, lights... might need
  37283. * in order to make a correct use of the texture.
  37284. */
  37285. export class BaseTexture implements IAnimatable {
  37286. /**
  37287. * Default anisotropic filtering level for the application.
  37288. * It is set to 4 as a good tradeoff between perf and quality.
  37289. */
  37290. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  37291. /**
  37292. * Gets or sets the unique id of the texture
  37293. */
  37294. uniqueId: number;
  37295. /**
  37296. * Define the name of the texture.
  37297. */
  37298. name: string;
  37299. /**
  37300. * Gets or sets an object used to store user defined information.
  37301. */
  37302. metadata: any;
  37303. /**
  37304. * For internal use only. Please do not use.
  37305. */
  37306. reservedDataStore: any;
  37307. private _hasAlpha;
  37308. /**
  37309. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  37310. */
  37311. set hasAlpha(value: boolean);
  37312. get hasAlpha(): boolean;
  37313. /**
  37314. * Defines if the alpha value should be determined via the rgb values.
  37315. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  37316. */
  37317. getAlphaFromRGB: boolean;
  37318. /**
  37319. * Intensity or strength of the texture.
  37320. * It is commonly used by materials to fine tune the intensity of the texture
  37321. */
  37322. level: number;
  37323. /**
  37324. * Define the UV chanel to use starting from 0 and defaulting to 0.
  37325. * This is part of the texture as textures usually maps to one uv set.
  37326. */
  37327. coordinatesIndex: number;
  37328. protected _coordinatesMode: number;
  37329. /**
  37330. * How a texture is mapped.
  37331. *
  37332. * | Value | Type | Description |
  37333. * | ----- | ----------------------------------- | ----------- |
  37334. * | 0 | EXPLICIT_MODE | |
  37335. * | 1 | SPHERICAL_MODE | |
  37336. * | 2 | PLANAR_MODE | |
  37337. * | 3 | CUBIC_MODE | |
  37338. * | 4 | PROJECTION_MODE | |
  37339. * | 5 | SKYBOX_MODE | |
  37340. * | 6 | INVCUBIC_MODE | |
  37341. * | 7 | EQUIRECTANGULAR_MODE | |
  37342. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  37343. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  37344. */
  37345. set coordinatesMode(value: number);
  37346. get coordinatesMode(): number;
  37347. private _wrapU;
  37348. /**
  37349. * | Value | Type | Description |
  37350. * | ----- | ------------------ | ----------- |
  37351. * | 0 | CLAMP_ADDRESSMODE | |
  37352. * | 1 | WRAP_ADDRESSMODE | |
  37353. * | 2 | MIRROR_ADDRESSMODE | |
  37354. */
  37355. get wrapU(): number;
  37356. set wrapU(value: number);
  37357. private _wrapV;
  37358. /**
  37359. * | Value | Type | Description |
  37360. * | ----- | ------------------ | ----------- |
  37361. * | 0 | CLAMP_ADDRESSMODE | |
  37362. * | 1 | WRAP_ADDRESSMODE | |
  37363. * | 2 | MIRROR_ADDRESSMODE | |
  37364. */
  37365. get wrapV(): number;
  37366. set wrapV(value: number);
  37367. /**
  37368. * | Value | Type | Description |
  37369. * | ----- | ------------------ | ----------- |
  37370. * | 0 | CLAMP_ADDRESSMODE | |
  37371. * | 1 | WRAP_ADDRESSMODE | |
  37372. * | 2 | MIRROR_ADDRESSMODE | |
  37373. */
  37374. wrapR: number;
  37375. /**
  37376. * With compliant hardware and browser (supporting anisotropic filtering)
  37377. * this defines the level of anisotropic filtering in the texture.
  37378. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  37379. */
  37380. anisotropicFilteringLevel: number;
  37381. /**
  37382. * Define if the texture is a cube texture or if false a 2d texture.
  37383. */
  37384. get isCube(): boolean;
  37385. set isCube(value: boolean);
  37386. /**
  37387. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  37388. */
  37389. get is3D(): boolean;
  37390. set is3D(value: boolean);
  37391. /**
  37392. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  37393. */
  37394. get is2DArray(): boolean;
  37395. set is2DArray(value: boolean);
  37396. private _gammaSpace;
  37397. /**
  37398. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  37399. * HDR texture are usually stored in linear space.
  37400. * This only impacts the PBR and Background materials
  37401. */
  37402. get gammaSpace(): boolean;
  37403. set gammaSpace(gamma: boolean);
  37404. /**
  37405. * Gets or sets whether or not the texture contains RGBD data.
  37406. */
  37407. get isRGBD(): boolean;
  37408. set isRGBD(value: boolean);
  37409. /**
  37410. * Is Z inverted in the texture (useful in a cube texture).
  37411. */
  37412. invertZ: boolean;
  37413. /**
  37414. * Are mip maps generated for this texture or not.
  37415. */
  37416. get noMipmap(): boolean;
  37417. /**
  37418. * @hidden
  37419. */
  37420. lodLevelInAlpha: boolean;
  37421. /**
  37422. * With prefiltered texture, defined the offset used during the prefiltering steps.
  37423. */
  37424. get lodGenerationOffset(): number;
  37425. set lodGenerationOffset(value: number);
  37426. /**
  37427. * With prefiltered texture, defined the scale used during the prefiltering steps.
  37428. */
  37429. get lodGenerationScale(): number;
  37430. set lodGenerationScale(value: number);
  37431. /**
  37432. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  37433. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  37434. * average roughness values.
  37435. */
  37436. get linearSpecularLOD(): boolean;
  37437. set linearSpecularLOD(value: boolean);
  37438. /**
  37439. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  37440. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  37441. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  37442. */
  37443. get irradianceTexture(): Nullable<BaseTexture>;
  37444. set irradianceTexture(value: Nullable<BaseTexture>);
  37445. /**
  37446. * Define if the texture is a render target.
  37447. */
  37448. isRenderTarget: boolean;
  37449. /**
  37450. * Define the unique id of the texture in the scene.
  37451. */
  37452. get uid(): string;
  37453. /** @hidden */
  37454. _prefiltered: boolean;
  37455. /**
  37456. * Return a string representation of the texture.
  37457. * @returns the texture as a string
  37458. */
  37459. toString(): string;
  37460. /**
  37461. * Get the class name of the texture.
  37462. * @returns "BaseTexture"
  37463. */
  37464. getClassName(): string;
  37465. /**
  37466. * Define the list of animation attached to the texture.
  37467. */
  37468. animations: Animation[];
  37469. /**
  37470. * An event triggered when the texture is disposed.
  37471. */
  37472. onDisposeObservable: Observable<BaseTexture>;
  37473. private _onDisposeObserver;
  37474. /**
  37475. * Callback triggered when the texture has been disposed.
  37476. * Kept for back compatibility, you can use the onDisposeObservable instead.
  37477. */
  37478. set onDispose(callback: () => void);
  37479. /**
  37480. * Define the current state of the loading sequence when in delayed load mode.
  37481. */
  37482. delayLoadState: number;
  37483. protected _scene: Nullable<Scene>;
  37484. protected _engine: Nullable<ThinEngine>;
  37485. /** @hidden */
  37486. _texture: Nullable<InternalTexture>;
  37487. private _uid;
  37488. /**
  37489. * Define if the texture is preventinga material to render or not.
  37490. * If not and the texture is not ready, the engine will use a default black texture instead.
  37491. */
  37492. get isBlocking(): boolean;
  37493. /**
  37494. * Instantiates a new BaseTexture.
  37495. * Base class of all the textures in babylon.
  37496. * It groups all the common properties the materials, post process, lights... might need
  37497. * in order to make a correct use of the texture.
  37498. * @param sceneOrEngine Define the scene or engine the texture blongs to
  37499. */
  37500. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  37501. /**
  37502. * Get the scene the texture belongs to.
  37503. * @returns the scene or null if undefined
  37504. */
  37505. getScene(): Nullable<Scene>;
  37506. /** @hidden */
  37507. protected _getEngine(): Nullable<ThinEngine>;
  37508. /**
  37509. * Checks if the texture has the same transform matrix than another texture
  37510. * @param texture texture to check against
  37511. * @returns true if the transforms are the same, else false
  37512. */
  37513. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  37514. /**
  37515. * Get the texture transform matrix used to offset tile the texture for istance.
  37516. * @returns the transformation matrix
  37517. */
  37518. getTextureMatrix(): Matrix;
  37519. /**
  37520. * Get the texture reflection matrix used to rotate/transform the reflection.
  37521. * @returns the reflection matrix
  37522. */
  37523. getReflectionTextureMatrix(): Matrix;
  37524. /**
  37525. * Get the underlying lower level texture from Babylon.
  37526. * @returns the insternal texture
  37527. */
  37528. getInternalTexture(): Nullable<InternalTexture>;
  37529. /**
  37530. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  37531. * @returns true if ready or not blocking
  37532. */
  37533. isReadyOrNotBlocking(): boolean;
  37534. /**
  37535. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  37536. * @returns true if fully ready
  37537. */
  37538. isReady(): boolean;
  37539. private _cachedSize;
  37540. /**
  37541. * Get the size of the texture.
  37542. * @returns the texture size.
  37543. */
  37544. getSize(): ISize;
  37545. /**
  37546. * Get the base size of the texture.
  37547. * It can be different from the size if the texture has been resized for POT for instance
  37548. * @returns the base size
  37549. */
  37550. getBaseSize(): ISize;
  37551. /**
  37552. * Update the sampling mode of the texture.
  37553. * Default is Trilinear mode.
  37554. *
  37555. * | Value | Type | Description |
  37556. * | ----- | ------------------ | ----------- |
  37557. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37558. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37559. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37560. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37561. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37562. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37563. * | 7 | NEAREST_LINEAR | |
  37564. * | 8 | NEAREST_NEAREST | |
  37565. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37566. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37567. * | 11 | LINEAR_LINEAR | |
  37568. * | 12 | LINEAR_NEAREST | |
  37569. *
  37570. * > _mag_: magnification filter (close to the viewer)
  37571. * > _min_: minification filter (far from the viewer)
  37572. * > _mip_: filter used between mip map levels
  37573. *@param samplingMode Define the new sampling mode of the texture
  37574. */
  37575. updateSamplingMode(samplingMode: number): void;
  37576. /**
  37577. * Scales the texture if is `canRescale()`
  37578. * @param ratio the resize factor we want to use to rescale
  37579. */
  37580. scale(ratio: number): void;
  37581. /**
  37582. * Get if the texture can rescale.
  37583. */
  37584. get canRescale(): boolean;
  37585. /** @hidden */
  37586. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  37587. /** @hidden */
  37588. _rebuild(): void;
  37589. /**
  37590. * Triggers the load sequence in delayed load mode.
  37591. */
  37592. delayLoad(): void;
  37593. /**
  37594. * Clones the texture.
  37595. * @returns the cloned texture
  37596. */
  37597. clone(): Nullable<BaseTexture>;
  37598. /**
  37599. * Get the texture underlying type (INT, FLOAT...)
  37600. */
  37601. get textureType(): number;
  37602. /**
  37603. * Get the texture underlying format (RGB, RGBA...)
  37604. */
  37605. get textureFormat(): number;
  37606. /**
  37607. * Indicates that textures need to be re-calculated for all materials
  37608. */
  37609. protected _markAllSubMeshesAsTexturesDirty(): void;
  37610. /**
  37611. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  37612. * This will returns an RGBA array buffer containing either in values (0-255) or
  37613. * float values (0-1) depending of the underlying buffer type.
  37614. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  37615. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  37616. * @param buffer defines a user defined buffer to fill with data (can be null)
  37617. * @returns The Array buffer containing the pixels data.
  37618. */
  37619. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  37620. /**
  37621. * Release and destroy the underlying lower level texture aka internalTexture.
  37622. */
  37623. releaseInternalTexture(): void;
  37624. /** @hidden */
  37625. get _lodTextureHigh(): Nullable<BaseTexture>;
  37626. /** @hidden */
  37627. get _lodTextureMid(): Nullable<BaseTexture>;
  37628. /** @hidden */
  37629. get _lodTextureLow(): Nullable<BaseTexture>;
  37630. /**
  37631. * Dispose the texture and release its associated resources.
  37632. */
  37633. dispose(): void;
  37634. /**
  37635. * Serialize the texture into a JSON representation that can be parsed later on.
  37636. * @returns the JSON representation of the texture
  37637. */
  37638. serialize(): any;
  37639. /**
  37640. * Helper function to be called back once a list of texture contains only ready textures.
  37641. * @param textures Define the list of textures to wait for
  37642. * @param callback Define the callback triggered once the entire list will be ready
  37643. */
  37644. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37645. private static _isScene;
  37646. }
  37647. }
  37648. declare module BABYLON {
  37649. /**
  37650. * Options to be used when creating an effect.
  37651. */
  37652. export interface IEffectCreationOptions {
  37653. /**
  37654. * Atrributes that will be used in the shader.
  37655. */
  37656. attributes: string[];
  37657. /**
  37658. * Uniform varible names that will be set in the shader.
  37659. */
  37660. uniformsNames: string[];
  37661. /**
  37662. * Uniform buffer variable names that will be set in the shader.
  37663. */
  37664. uniformBuffersNames: string[];
  37665. /**
  37666. * Sampler texture variable names that will be set in the shader.
  37667. */
  37668. samplers: string[];
  37669. /**
  37670. * Define statements that will be set in the shader.
  37671. */
  37672. defines: any;
  37673. /**
  37674. * Possible fallbacks for this effect to improve performance when needed.
  37675. */
  37676. fallbacks: Nullable<IEffectFallbacks>;
  37677. /**
  37678. * Callback that will be called when the shader is compiled.
  37679. */
  37680. onCompiled: Nullable<(effect: Effect) => void>;
  37681. /**
  37682. * Callback that will be called if an error occurs during shader compilation.
  37683. */
  37684. onError: Nullable<(effect: Effect, errors: string) => void>;
  37685. /**
  37686. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37687. */
  37688. indexParameters?: any;
  37689. /**
  37690. * Max number of lights that can be used in the shader.
  37691. */
  37692. maxSimultaneousLights?: number;
  37693. /**
  37694. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37695. */
  37696. transformFeedbackVaryings?: Nullable<string[]>;
  37697. /**
  37698. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  37699. */
  37700. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37701. /**
  37702. * Is this effect rendering to several color attachments ?
  37703. */
  37704. multiTarget?: boolean;
  37705. }
  37706. /**
  37707. * Effect containing vertex and fragment shader that can be executed on an object.
  37708. */
  37709. export class Effect implements IDisposable {
  37710. /**
  37711. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37712. */
  37713. static ShadersRepository: string;
  37714. /**
  37715. * Enable logging of the shader code when a compilation error occurs
  37716. */
  37717. static LogShaderCodeOnCompilationError: boolean;
  37718. /**
  37719. * Name of the effect.
  37720. */
  37721. name: any;
  37722. /**
  37723. * String container all the define statements that should be set on the shader.
  37724. */
  37725. defines: string;
  37726. /**
  37727. * Callback that will be called when the shader is compiled.
  37728. */
  37729. onCompiled: Nullable<(effect: Effect) => void>;
  37730. /**
  37731. * Callback that will be called if an error occurs during shader compilation.
  37732. */
  37733. onError: Nullable<(effect: Effect, errors: string) => void>;
  37734. /**
  37735. * Callback that will be called when effect is bound.
  37736. */
  37737. onBind: Nullable<(effect: Effect) => void>;
  37738. /**
  37739. * Unique ID of the effect.
  37740. */
  37741. uniqueId: number;
  37742. /**
  37743. * Observable that will be called when the shader is compiled.
  37744. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  37745. */
  37746. onCompileObservable: Observable<Effect>;
  37747. /**
  37748. * Observable that will be called if an error occurs during shader compilation.
  37749. */
  37750. onErrorObservable: Observable<Effect>;
  37751. /** @hidden */
  37752. _onBindObservable: Nullable<Observable<Effect>>;
  37753. /**
  37754. * @hidden
  37755. * Specifies if the effect was previously ready
  37756. */
  37757. _wasPreviouslyReady: boolean;
  37758. /**
  37759. * Observable that will be called when effect is bound.
  37760. */
  37761. get onBindObservable(): Observable<Effect>;
  37762. /** @hidden */
  37763. _bonesComputationForcedToCPU: boolean;
  37764. /** @hidden */
  37765. _multiTarget: boolean;
  37766. private static _uniqueIdSeed;
  37767. private _engine;
  37768. private _uniformBuffersNames;
  37769. private _uniformBuffersNamesList;
  37770. private _uniformsNames;
  37771. private _samplerList;
  37772. private _samplers;
  37773. private _isReady;
  37774. private _compilationError;
  37775. private _allFallbacksProcessed;
  37776. private _attributesNames;
  37777. private _attributes;
  37778. private _attributeLocationByName;
  37779. private _uniforms;
  37780. /**
  37781. * Key for the effect.
  37782. * @hidden
  37783. */
  37784. _key: string;
  37785. private _indexParameters;
  37786. private _fallbacks;
  37787. private _vertexSourceCode;
  37788. private _fragmentSourceCode;
  37789. private _vertexSourceCodeOverride;
  37790. private _fragmentSourceCodeOverride;
  37791. private _transformFeedbackVaryings;
  37792. /**
  37793. * Compiled shader to webGL program.
  37794. * @hidden
  37795. */
  37796. _pipelineContext: Nullable<IPipelineContext>;
  37797. private _valueCache;
  37798. private static _baseCache;
  37799. /**
  37800. * Instantiates an effect.
  37801. * An effect can be used to create/manage/execute vertex and fragment shaders.
  37802. * @param baseName Name of the effect.
  37803. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  37804. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  37805. * @param samplers List of sampler variables that will be passed to the shader.
  37806. * @param engine Engine to be used to render the effect
  37807. * @param defines Define statements to be added to the shader.
  37808. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  37809. * @param onCompiled Callback that will be called when the shader is compiled.
  37810. * @param onError Callback that will be called if an error occurs during shader compilation.
  37811. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37812. */
  37813. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  37814. private _useFinalCode;
  37815. /**
  37816. * Unique key for this effect
  37817. */
  37818. get key(): string;
  37819. /**
  37820. * If the effect has been compiled and prepared.
  37821. * @returns if the effect is compiled and prepared.
  37822. */
  37823. isReady(): boolean;
  37824. private _isReadyInternal;
  37825. /**
  37826. * The engine the effect was initialized with.
  37827. * @returns the engine.
  37828. */
  37829. getEngine(): Engine;
  37830. /**
  37831. * The pipeline context for this effect
  37832. * @returns the associated pipeline context
  37833. */
  37834. getPipelineContext(): Nullable<IPipelineContext>;
  37835. /**
  37836. * The set of names of attribute variables for the shader.
  37837. * @returns An array of attribute names.
  37838. */
  37839. getAttributesNames(): string[];
  37840. /**
  37841. * Returns the attribute at the given index.
  37842. * @param index The index of the attribute.
  37843. * @returns The location of the attribute.
  37844. */
  37845. getAttributeLocation(index: number): number;
  37846. /**
  37847. * Returns the attribute based on the name of the variable.
  37848. * @param name of the attribute to look up.
  37849. * @returns the attribute location.
  37850. */
  37851. getAttributeLocationByName(name: string): number;
  37852. /**
  37853. * The number of attributes.
  37854. * @returns the numnber of attributes.
  37855. */
  37856. getAttributesCount(): number;
  37857. /**
  37858. * Gets the index of a uniform variable.
  37859. * @param uniformName of the uniform to look up.
  37860. * @returns the index.
  37861. */
  37862. getUniformIndex(uniformName: string): number;
  37863. /**
  37864. * Returns the attribute based on the name of the variable.
  37865. * @param uniformName of the uniform to look up.
  37866. * @returns the location of the uniform.
  37867. */
  37868. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  37869. /**
  37870. * Returns an array of sampler variable names
  37871. * @returns The array of sampler variable names.
  37872. */
  37873. getSamplers(): string[];
  37874. /**
  37875. * Returns an array of uniform variable names
  37876. * @returns The array of uniform variable names.
  37877. */
  37878. getUniformNames(): string[];
  37879. /**
  37880. * Returns an array of uniform buffer variable names
  37881. * @returns The array of uniform buffer variable names.
  37882. */
  37883. getUniformBuffersNames(): string[];
  37884. /**
  37885. * Returns the index parameters used to create the effect
  37886. * @returns The index parameters object
  37887. */
  37888. getIndexParameters(): any;
  37889. /**
  37890. * The error from the last compilation.
  37891. * @returns the error string.
  37892. */
  37893. getCompilationError(): string;
  37894. /**
  37895. * Gets a boolean indicating that all fallbacks were used during compilation
  37896. * @returns true if all fallbacks were used
  37897. */
  37898. allFallbacksProcessed(): boolean;
  37899. /**
  37900. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  37901. * @param func The callback to be used.
  37902. */
  37903. executeWhenCompiled(func: (effect: Effect) => void): void;
  37904. private _checkIsReady;
  37905. private _loadShader;
  37906. /**
  37907. * Gets the vertex shader source code of this effect
  37908. */
  37909. get vertexSourceCode(): string;
  37910. /**
  37911. * Gets the fragment shader source code of this effect
  37912. */
  37913. get fragmentSourceCode(): string;
  37914. /**
  37915. * Recompiles the webGL program
  37916. * @param vertexSourceCode The source code for the vertex shader.
  37917. * @param fragmentSourceCode The source code for the fragment shader.
  37918. * @param onCompiled Callback called when completed.
  37919. * @param onError Callback called on error.
  37920. * @hidden
  37921. */
  37922. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  37923. /**
  37924. * Prepares the effect
  37925. * @hidden
  37926. */
  37927. _prepareEffect(): void;
  37928. private _getShaderCodeAndErrorLine;
  37929. private _processCompilationErrors;
  37930. /**
  37931. * Checks if the effect is supported. (Must be called after compilation)
  37932. */
  37933. get isSupported(): boolean;
  37934. /**
  37935. * Binds a texture to the engine to be used as output of the shader.
  37936. * @param channel Name of the output variable.
  37937. * @param texture Texture to bind.
  37938. * @hidden
  37939. */
  37940. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  37941. /**
  37942. * Sets a texture on the engine to be used in the shader.
  37943. * @param channel Name of the sampler variable.
  37944. * @param texture Texture to set.
  37945. */
  37946. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  37947. /**
  37948. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  37949. * @param channel Name of the sampler variable.
  37950. * @param texture Texture to set.
  37951. */
  37952. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  37953. /**
  37954. * Sets an array of textures on the engine to be used in the shader.
  37955. * @param channel Name of the variable.
  37956. * @param textures Textures to set.
  37957. */
  37958. setTextureArray(channel: string, textures: BaseTexture[]): void;
  37959. /**
  37960. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  37961. * @param channel Name of the sampler variable.
  37962. * @param postProcess Post process to get the input texture from.
  37963. */
  37964. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  37965. /**
  37966. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  37967. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  37968. * @param channel Name of the sampler variable.
  37969. * @param postProcess Post process to get the output texture from.
  37970. */
  37971. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  37972. /** @hidden */
  37973. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  37974. /** @hidden */
  37975. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  37976. /** @hidden */
  37977. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  37978. /** @hidden */
  37979. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  37980. /**
  37981. * Binds a buffer to a uniform.
  37982. * @param buffer Buffer to bind.
  37983. * @param name Name of the uniform variable to bind to.
  37984. */
  37985. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  37986. /**
  37987. * Binds block to a uniform.
  37988. * @param blockName Name of the block to bind.
  37989. * @param index Index to bind.
  37990. */
  37991. bindUniformBlock(blockName: string, index: number): void;
  37992. /**
  37993. * Sets an interger value on a uniform variable.
  37994. * @param uniformName Name of the variable.
  37995. * @param value Value to be set.
  37996. * @returns this effect.
  37997. */
  37998. setInt(uniformName: string, value: number): Effect;
  37999. /**
  38000. * Sets an int array on a uniform variable.
  38001. * @param uniformName Name of the variable.
  38002. * @param array array to be set.
  38003. * @returns this effect.
  38004. */
  38005. setIntArray(uniformName: string, array: Int32Array): Effect;
  38006. /**
  38007. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  38008. * @param uniformName Name of the variable.
  38009. * @param array array to be set.
  38010. * @returns this effect.
  38011. */
  38012. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38013. /**
  38014. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  38015. * @param uniformName Name of the variable.
  38016. * @param array array to be set.
  38017. * @returns this effect.
  38018. */
  38019. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38020. /**
  38021. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  38022. * @param uniformName Name of the variable.
  38023. * @param array array to be set.
  38024. * @returns this effect.
  38025. */
  38026. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38027. /**
  38028. * Sets an float array on a uniform variable.
  38029. * @param uniformName Name of the variable.
  38030. * @param array array to be set.
  38031. * @returns this effect.
  38032. */
  38033. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38034. /**
  38035. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  38036. * @param uniformName Name of the variable.
  38037. * @param array array to be set.
  38038. * @returns this effect.
  38039. */
  38040. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38041. /**
  38042. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  38043. * @param uniformName Name of the variable.
  38044. * @param array array to be set.
  38045. * @returns this effect.
  38046. */
  38047. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38048. /**
  38049. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  38050. * @param uniformName Name of the variable.
  38051. * @param array array to be set.
  38052. * @returns this effect.
  38053. */
  38054. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38055. /**
  38056. * Sets an array on a uniform variable.
  38057. * @param uniformName Name of the variable.
  38058. * @param array array to be set.
  38059. * @returns this effect.
  38060. */
  38061. setArray(uniformName: string, array: number[]): Effect;
  38062. /**
  38063. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  38064. * @param uniformName Name of the variable.
  38065. * @param array array to be set.
  38066. * @returns this effect.
  38067. */
  38068. setArray2(uniformName: string, array: number[]): Effect;
  38069. /**
  38070. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  38071. * @param uniformName Name of the variable.
  38072. * @param array array to be set.
  38073. * @returns this effect.
  38074. */
  38075. setArray3(uniformName: string, array: number[]): Effect;
  38076. /**
  38077. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  38078. * @param uniformName Name of the variable.
  38079. * @param array array to be set.
  38080. * @returns this effect.
  38081. */
  38082. setArray4(uniformName: string, array: number[]): Effect;
  38083. /**
  38084. * Sets matrices on a uniform variable.
  38085. * @param uniformName Name of the variable.
  38086. * @param matrices matrices to be set.
  38087. * @returns this effect.
  38088. */
  38089. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38090. /**
  38091. * Sets matrix on a uniform variable.
  38092. * @param uniformName Name of the variable.
  38093. * @param matrix matrix to be set.
  38094. * @returns this effect.
  38095. */
  38096. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38097. /**
  38098. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  38099. * @param uniformName Name of the variable.
  38100. * @param matrix matrix to be set.
  38101. * @returns this effect.
  38102. */
  38103. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38104. /**
  38105. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38106. * @param uniformName Name of the variable.
  38107. * @param matrix matrix to be set.
  38108. * @returns this effect.
  38109. */
  38110. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38111. /**
  38112. * Sets a float on a uniform variable.
  38113. * @param uniformName Name of the variable.
  38114. * @param value value to be set.
  38115. * @returns this effect.
  38116. */
  38117. setFloat(uniformName: string, value: number): Effect;
  38118. /**
  38119. * Sets a boolean on a uniform variable.
  38120. * @param uniformName Name of the variable.
  38121. * @param bool value to be set.
  38122. * @returns this effect.
  38123. */
  38124. setBool(uniformName: string, bool: boolean): Effect;
  38125. /**
  38126. * Sets a Vector2 on a uniform variable.
  38127. * @param uniformName Name of the variable.
  38128. * @param vector2 vector2 to be set.
  38129. * @returns this effect.
  38130. */
  38131. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38132. /**
  38133. * Sets a float2 on a uniform variable.
  38134. * @param uniformName Name of the variable.
  38135. * @param x First float in float2.
  38136. * @param y Second float in float2.
  38137. * @returns this effect.
  38138. */
  38139. setFloat2(uniformName: string, x: number, y: number): Effect;
  38140. /**
  38141. * Sets a Vector3 on a uniform variable.
  38142. * @param uniformName Name of the variable.
  38143. * @param vector3 Value to be set.
  38144. * @returns this effect.
  38145. */
  38146. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38147. /**
  38148. * Sets a float3 on a uniform variable.
  38149. * @param uniformName Name of the variable.
  38150. * @param x First float in float3.
  38151. * @param y Second float in float3.
  38152. * @param z Third float in float3.
  38153. * @returns this effect.
  38154. */
  38155. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38156. /**
  38157. * Sets a Vector4 on a uniform variable.
  38158. * @param uniformName Name of the variable.
  38159. * @param vector4 Value to be set.
  38160. * @returns this effect.
  38161. */
  38162. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38163. /**
  38164. * Sets a float4 on a uniform variable.
  38165. * @param uniformName Name of the variable.
  38166. * @param x First float in float4.
  38167. * @param y Second float in float4.
  38168. * @param z Third float in float4.
  38169. * @param w Fourth float in float4.
  38170. * @returns this effect.
  38171. */
  38172. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38173. /**
  38174. * Sets a Color3 on a uniform variable.
  38175. * @param uniformName Name of the variable.
  38176. * @param color3 Value to be set.
  38177. * @returns this effect.
  38178. */
  38179. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38180. /**
  38181. * Sets a Color4 on a uniform variable.
  38182. * @param uniformName Name of the variable.
  38183. * @param color3 Value to be set.
  38184. * @param alpha Alpha value to be set.
  38185. * @returns this effect.
  38186. */
  38187. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38188. /**
  38189. * Sets a Color4 on a uniform variable
  38190. * @param uniformName defines the name of the variable
  38191. * @param color4 defines the value to be set
  38192. * @returns this effect.
  38193. */
  38194. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38195. /** Release all associated resources */
  38196. dispose(): void;
  38197. /**
  38198. * This function will add a new shader to the shader store
  38199. * @param name the name of the shader
  38200. * @param pixelShader optional pixel shader content
  38201. * @param vertexShader optional vertex shader content
  38202. */
  38203. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38204. /**
  38205. * Store of each shader (The can be looked up using effect.key)
  38206. */
  38207. static ShadersStore: {
  38208. [key: string]: string;
  38209. };
  38210. /**
  38211. * Store of each included file for a shader (The can be looked up using effect.key)
  38212. */
  38213. static IncludesShadersStore: {
  38214. [key: string]: string;
  38215. };
  38216. /**
  38217. * Resets the cache of effects.
  38218. */
  38219. static ResetCache(): void;
  38220. }
  38221. }
  38222. declare module BABYLON {
  38223. /**
  38224. * Interface used to describe the capabilities of the engine relatively to the current browser
  38225. */
  38226. export interface EngineCapabilities {
  38227. /** Maximum textures units per fragment shader */
  38228. maxTexturesImageUnits: number;
  38229. /** Maximum texture units per vertex shader */
  38230. maxVertexTextureImageUnits: number;
  38231. /** Maximum textures units in the entire pipeline */
  38232. maxCombinedTexturesImageUnits: number;
  38233. /** Maximum texture size */
  38234. maxTextureSize: number;
  38235. /** Maximum texture samples */
  38236. maxSamples?: number;
  38237. /** Maximum cube texture size */
  38238. maxCubemapTextureSize: number;
  38239. /** Maximum render texture size */
  38240. maxRenderTextureSize: number;
  38241. /** Maximum number of vertex attributes */
  38242. maxVertexAttribs: number;
  38243. /** Maximum number of varyings */
  38244. maxVaryingVectors: number;
  38245. /** Maximum number of uniforms per vertex shader */
  38246. maxVertexUniformVectors: number;
  38247. /** Maximum number of uniforms per fragment shader */
  38248. maxFragmentUniformVectors: number;
  38249. /** Defines if standard derivates (dx/dy) are supported */
  38250. standardDerivatives: boolean;
  38251. /** Defines if s3tc texture compression is supported */
  38252. s3tc?: WEBGL_compressed_texture_s3tc;
  38253. /** Defines if pvrtc texture compression is supported */
  38254. pvrtc: any;
  38255. /** Defines if etc1 texture compression is supported */
  38256. etc1: any;
  38257. /** Defines if etc2 texture compression is supported */
  38258. etc2: any;
  38259. /** Defines if astc texture compression is supported */
  38260. astc: any;
  38261. /** Defines if bptc texture compression is supported */
  38262. bptc: any;
  38263. /** Defines if float textures are supported */
  38264. textureFloat: boolean;
  38265. /** Defines if vertex array objects are supported */
  38266. vertexArrayObject: boolean;
  38267. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38268. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38269. /** Gets the maximum level of anisotropy supported */
  38270. maxAnisotropy: number;
  38271. /** Defines if instancing is supported */
  38272. instancedArrays: boolean;
  38273. /** Defines if 32 bits indices are supported */
  38274. uintIndices: boolean;
  38275. /** Defines if high precision shaders are supported */
  38276. highPrecisionShaderSupported: boolean;
  38277. /** Defines if depth reading in the fragment shader is supported */
  38278. fragmentDepthSupported: boolean;
  38279. /** Defines if float texture linear filtering is supported*/
  38280. textureFloatLinearFiltering: boolean;
  38281. /** Defines if rendering to float textures is supported */
  38282. textureFloatRender: boolean;
  38283. /** Defines if half float textures are supported*/
  38284. textureHalfFloat: boolean;
  38285. /** Defines if half float texture linear filtering is supported*/
  38286. textureHalfFloatLinearFiltering: boolean;
  38287. /** Defines if rendering to half float textures is supported */
  38288. textureHalfFloatRender: boolean;
  38289. /** Defines if textureLOD shader command is supported */
  38290. textureLOD: boolean;
  38291. /** Defines if draw buffers extension is supported */
  38292. drawBuffersExtension: boolean;
  38293. /** Defines if depth textures are supported */
  38294. depthTextureExtension: boolean;
  38295. /** Defines if float color buffer are supported */
  38296. colorBufferFloat: boolean;
  38297. /** Gets disjoint timer query extension (null if not supported) */
  38298. timerQuery?: EXT_disjoint_timer_query;
  38299. /** Defines if timestamp can be used with timer query */
  38300. canUseTimestampForTimerQuery: boolean;
  38301. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38302. multiview?: any;
  38303. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38304. oculusMultiview?: any;
  38305. /** Function used to let the system compiles shaders in background */
  38306. parallelShaderCompile?: {
  38307. COMPLETION_STATUS_KHR: number;
  38308. };
  38309. /** Max number of texture samples for MSAA */
  38310. maxMSAASamples: number;
  38311. /** Defines if the blend min max extension is supported */
  38312. blendMinMax: boolean;
  38313. }
  38314. }
  38315. declare module BABYLON {
  38316. /**
  38317. * @hidden
  38318. **/
  38319. export class DepthCullingState {
  38320. private _isDepthTestDirty;
  38321. private _isDepthMaskDirty;
  38322. private _isDepthFuncDirty;
  38323. private _isCullFaceDirty;
  38324. private _isCullDirty;
  38325. private _isZOffsetDirty;
  38326. private _isFrontFaceDirty;
  38327. private _depthTest;
  38328. private _depthMask;
  38329. private _depthFunc;
  38330. private _cull;
  38331. private _cullFace;
  38332. private _zOffset;
  38333. private _frontFace;
  38334. /**
  38335. * Initializes the state.
  38336. */
  38337. constructor();
  38338. get isDirty(): boolean;
  38339. get zOffset(): number;
  38340. set zOffset(value: number);
  38341. get cullFace(): Nullable<number>;
  38342. set cullFace(value: Nullable<number>);
  38343. get cull(): Nullable<boolean>;
  38344. set cull(value: Nullable<boolean>);
  38345. get depthFunc(): Nullable<number>;
  38346. set depthFunc(value: Nullable<number>);
  38347. get depthMask(): boolean;
  38348. set depthMask(value: boolean);
  38349. get depthTest(): boolean;
  38350. set depthTest(value: boolean);
  38351. get frontFace(): Nullable<number>;
  38352. set frontFace(value: Nullable<number>);
  38353. reset(): void;
  38354. apply(gl: WebGLRenderingContext): void;
  38355. }
  38356. }
  38357. declare module BABYLON {
  38358. /**
  38359. * @hidden
  38360. **/
  38361. export class StencilState {
  38362. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  38363. static readonly ALWAYS: number;
  38364. /** Passed to stencilOperation to specify that stencil value must be kept */
  38365. static readonly KEEP: number;
  38366. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38367. static readonly REPLACE: number;
  38368. private _isStencilTestDirty;
  38369. private _isStencilMaskDirty;
  38370. private _isStencilFuncDirty;
  38371. private _isStencilOpDirty;
  38372. private _stencilTest;
  38373. private _stencilMask;
  38374. private _stencilFunc;
  38375. private _stencilFuncRef;
  38376. private _stencilFuncMask;
  38377. private _stencilOpStencilFail;
  38378. private _stencilOpDepthFail;
  38379. private _stencilOpStencilDepthPass;
  38380. get isDirty(): boolean;
  38381. get stencilFunc(): number;
  38382. set stencilFunc(value: number);
  38383. get stencilFuncRef(): number;
  38384. set stencilFuncRef(value: number);
  38385. get stencilFuncMask(): number;
  38386. set stencilFuncMask(value: number);
  38387. get stencilOpStencilFail(): number;
  38388. set stencilOpStencilFail(value: number);
  38389. get stencilOpDepthFail(): number;
  38390. set stencilOpDepthFail(value: number);
  38391. get stencilOpStencilDepthPass(): number;
  38392. set stencilOpStencilDepthPass(value: number);
  38393. get stencilMask(): number;
  38394. set stencilMask(value: number);
  38395. get stencilTest(): boolean;
  38396. set stencilTest(value: boolean);
  38397. constructor();
  38398. reset(): void;
  38399. apply(gl: WebGLRenderingContext): void;
  38400. }
  38401. }
  38402. declare module BABYLON {
  38403. /**
  38404. * @hidden
  38405. **/
  38406. export class AlphaState {
  38407. private _isAlphaBlendDirty;
  38408. private _isBlendFunctionParametersDirty;
  38409. private _isBlendEquationParametersDirty;
  38410. private _isBlendConstantsDirty;
  38411. private _alphaBlend;
  38412. private _blendFunctionParameters;
  38413. private _blendEquationParameters;
  38414. private _blendConstants;
  38415. /**
  38416. * Initializes the state.
  38417. */
  38418. constructor();
  38419. get isDirty(): boolean;
  38420. get alphaBlend(): boolean;
  38421. set alphaBlend(value: boolean);
  38422. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38423. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38424. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38425. reset(): void;
  38426. apply(gl: WebGLRenderingContext): void;
  38427. }
  38428. }
  38429. declare module BABYLON {
  38430. /** @hidden */
  38431. export class WebGLShaderProcessor implements IShaderProcessor {
  38432. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38433. }
  38434. }
  38435. declare module BABYLON {
  38436. /** @hidden */
  38437. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38438. attributeProcessor(attribute: string): string;
  38439. varyingProcessor(varying: string, isFragment: boolean): string;
  38440. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38441. }
  38442. }
  38443. declare module BABYLON {
  38444. /**
  38445. * Interface for attribute information associated with buffer instanciation
  38446. */
  38447. export interface InstancingAttributeInfo {
  38448. /**
  38449. * Name of the GLSL attribute
  38450. * if attribute index is not specified, this is used to retrieve the index from the effect
  38451. */
  38452. attributeName: string;
  38453. /**
  38454. * Index/offset of the attribute in the vertex shader
  38455. * if not specified, this will be computes from the name.
  38456. */
  38457. index?: number;
  38458. /**
  38459. * size of the attribute, 1, 2, 3 or 4
  38460. */
  38461. attributeSize: number;
  38462. /**
  38463. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38464. */
  38465. offset: number;
  38466. /**
  38467. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38468. * default to 1
  38469. */
  38470. divisor?: number;
  38471. /**
  38472. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38473. * default is FLOAT
  38474. */
  38475. attributeType?: number;
  38476. /**
  38477. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38478. */
  38479. normalized?: boolean;
  38480. }
  38481. }
  38482. declare module BABYLON {
  38483. interface ThinEngine {
  38484. /**
  38485. * Update a video texture
  38486. * @param texture defines the texture to update
  38487. * @param video defines the video element to use
  38488. * @param invertY defines if data must be stored with Y axis inverted
  38489. */
  38490. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38491. }
  38492. }
  38493. declare module BABYLON {
  38494. interface ThinEngine {
  38495. /**
  38496. * Creates a dynamic texture
  38497. * @param width defines the width of the texture
  38498. * @param height defines the height of the texture
  38499. * @param generateMipMaps defines if the engine should generate the mip levels
  38500. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38501. * @returns the dynamic texture inside an InternalTexture
  38502. */
  38503. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38504. /**
  38505. * Update the content of a dynamic texture
  38506. * @param texture defines the texture to update
  38507. * @param canvas defines the canvas containing the source
  38508. * @param invertY defines if data must be stored with Y axis inverted
  38509. * @param premulAlpha defines if alpha is stored as premultiplied
  38510. * @param format defines the format of the data
  38511. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38512. */
  38513. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38514. }
  38515. }
  38516. declare module BABYLON {
  38517. /**
  38518. * Settings for finer control over video usage
  38519. */
  38520. export interface VideoTextureSettings {
  38521. /**
  38522. * Applies `autoplay` to video, if specified
  38523. */
  38524. autoPlay?: boolean;
  38525. /**
  38526. * Applies `muted` to video, if specified
  38527. */
  38528. muted?: boolean;
  38529. /**
  38530. * Applies `loop` to video, if specified
  38531. */
  38532. loop?: boolean;
  38533. /**
  38534. * Automatically updates internal texture from video at every frame in the render loop
  38535. */
  38536. autoUpdateTexture: boolean;
  38537. /**
  38538. * Image src displayed during the video loading or until the user interacts with the video.
  38539. */
  38540. poster?: string;
  38541. }
  38542. /**
  38543. * If you want to display a video in your scene, this is the special texture for that.
  38544. * This special texture works similar to other textures, with the exception of a few parameters.
  38545. * @see https://doc.babylonjs.com/how_to/video_texture
  38546. */
  38547. export class VideoTexture extends Texture {
  38548. /**
  38549. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38550. */
  38551. readonly autoUpdateTexture: boolean;
  38552. /**
  38553. * The video instance used by the texture internally
  38554. */
  38555. readonly video: HTMLVideoElement;
  38556. private _onUserActionRequestedObservable;
  38557. /**
  38558. * Event triggerd when a dom action is required by the user to play the video.
  38559. * This happens due to recent changes in browser policies preventing video to auto start.
  38560. */
  38561. get onUserActionRequestedObservable(): Observable<Texture>;
  38562. private _generateMipMaps;
  38563. private _stillImageCaptured;
  38564. private _displayingPosterTexture;
  38565. private _settings;
  38566. private _createInternalTextureOnEvent;
  38567. private _frameId;
  38568. private _currentSrc;
  38569. /**
  38570. * Creates a video texture.
  38571. * If you want to display a video in your scene, this is the special texture for that.
  38572. * This special texture works similar to other textures, with the exception of a few parameters.
  38573. * @see https://doc.babylonjs.com/how_to/video_texture
  38574. * @param name optional name, will detect from video source, if not defined
  38575. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38576. * @param scene is obviously the current scene.
  38577. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38578. * @param invertY is false by default but can be used to invert video on Y axis
  38579. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38580. * @param settings allows finer control over video usage
  38581. */
  38582. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38583. private _getName;
  38584. private _getVideo;
  38585. private _createInternalTexture;
  38586. private reset;
  38587. /**
  38588. * @hidden Internal method to initiate `update`.
  38589. */
  38590. _rebuild(): void;
  38591. /**
  38592. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38593. */
  38594. update(): void;
  38595. /**
  38596. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38597. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38598. */
  38599. updateTexture(isVisible: boolean): void;
  38600. protected _updateInternalTexture: () => void;
  38601. /**
  38602. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38603. * @param url New url.
  38604. */
  38605. updateURL(url: string): void;
  38606. /**
  38607. * Clones the texture.
  38608. * @returns the cloned texture
  38609. */
  38610. clone(): VideoTexture;
  38611. /**
  38612. * Dispose the texture and release its associated resources.
  38613. */
  38614. dispose(): void;
  38615. /**
  38616. * Creates a video texture straight from a stream.
  38617. * @param scene Define the scene the texture should be created in
  38618. * @param stream Define the stream the texture should be created from
  38619. * @returns The created video texture as a promise
  38620. */
  38621. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38622. /**
  38623. * Creates a video texture straight from your WebCam video feed.
  38624. * @param scene Define the scene the texture should be created in
  38625. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38626. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38627. * @returns The created video texture as a promise
  38628. */
  38629. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38630. minWidth: number;
  38631. maxWidth: number;
  38632. minHeight: number;
  38633. maxHeight: number;
  38634. deviceId: string;
  38635. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38636. /**
  38637. * Creates a video texture straight from your WebCam video feed.
  38638. * @param scene Define the scene the texture should be created in
  38639. * @param onReady Define a callback to triggered once the texture will be ready
  38640. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38641. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38642. */
  38643. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38644. minWidth: number;
  38645. maxWidth: number;
  38646. minHeight: number;
  38647. maxHeight: number;
  38648. deviceId: string;
  38649. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38650. }
  38651. }
  38652. declare module BABYLON {
  38653. /**
  38654. * Defines the interface used by objects working like Scene
  38655. * @hidden
  38656. */
  38657. export interface ISceneLike {
  38658. _addPendingData(data: any): void;
  38659. _removePendingData(data: any): void;
  38660. offlineProvider: IOfflineProvider;
  38661. }
  38662. /**
  38663. * Information about the current host
  38664. */
  38665. export interface HostInformation {
  38666. /**
  38667. * Defines if the current host is a mobile
  38668. */
  38669. isMobile: boolean;
  38670. }
  38671. /** Interface defining initialization parameters for Engine class */
  38672. export interface EngineOptions extends WebGLContextAttributes {
  38673. /**
  38674. * Defines if the engine should no exceed a specified device ratio
  38675. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38676. */
  38677. limitDeviceRatio?: number;
  38678. /**
  38679. * Defines if webvr should be enabled automatically
  38680. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38681. */
  38682. autoEnableWebVR?: boolean;
  38683. /**
  38684. * Defines if webgl2 should be turned off even if supported
  38685. * @see https://doc.babylonjs.com/features/webgl2
  38686. */
  38687. disableWebGL2Support?: boolean;
  38688. /**
  38689. * Defines if webaudio should be initialized as well
  38690. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38691. */
  38692. audioEngine?: boolean;
  38693. /**
  38694. * Defines if animations should run using a deterministic lock step
  38695. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38696. */
  38697. deterministicLockstep?: boolean;
  38698. /** Defines the maximum steps to use with deterministic lock step mode */
  38699. lockstepMaxSteps?: number;
  38700. /** Defines the seconds between each deterministic lock step */
  38701. timeStep?: number;
  38702. /**
  38703. * Defines that engine should ignore context lost events
  38704. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38705. */
  38706. doNotHandleContextLost?: boolean;
  38707. /**
  38708. * Defines that engine should ignore modifying touch action attribute and style
  38709. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  38710. */
  38711. doNotHandleTouchAction?: boolean;
  38712. /**
  38713. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  38714. */
  38715. useHighPrecisionFloats?: boolean;
  38716. /**
  38717. * Make the canvas XR Compatible for XR sessions
  38718. */
  38719. xrCompatible?: boolean;
  38720. /**
  38721. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  38722. */
  38723. useHighPrecisionMatrix?: boolean;
  38724. /**
  38725. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  38726. */
  38727. failIfMajorPerformanceCaveat?: boolean;
  38728. }
  38729. /**
  38730. * The base engine class (root of all engines)
  38731. */
  38732. export class ThinEngine {
  38733. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  38734. static ExceptionList: ({
  38735. key: string;
  38736. capture: string;
  38737. captureConstraint: number;
  38738. targets: string[];
  38739. } | {
  38740. key: string;
  38741. capture: null;
  38742. captureConstraint: null;
  38743. targets: string[];
  38744. })[];
  38745. /** @hidden */
  38746. static _TextureLoaders: IInternalTextureLoader[];
  38747. /**
  38748. * Returns the current npm package of the sdk
  38749. */
  38750. static get NpmPackage(): string;
  38751. /**
  38752. * Returns the current version of the framework
  38753. */
  38754. static get Version(): string;
  38755. /**
  38756. * Returns a string describing the current engine
  38757. */
  38758. get description(): string;
  38759. /**
  38760. * Gets or sets the epsilon value used by collision engine
  38761. */
  38762. static CollisionsEpsilon: number;
  38763. /**
  38764. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38765. */
  38766. static get ShadersRepository(): string;
  38767. static set ShadersRepository(value: string);
  38768. /** @hidden */
  38769. _shaderProcessor: IShaderProcessor;
  38770. /**
  38771. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  38772. */
  38773. forcePOTTextures: boolean;
  38774. /**
  38775. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  38776. */
  38777. isFullscreen: boolean;
  38778. /**
  38779. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  38780. */
  38781. cullBackFaces: boolean;
  38782. /**
  38783. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  38784. */
  38785. renderEvenInBackground: boolean;
  38786. /**
  38787. * Gets or sets a boolean indicating that cache can be kept between frames
  38788. */
  38789. preventCacheWipeBetweenFrames: boolean;
  38790. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  38791. validateShaderPrograms: boolean;
  38792. /**
  38793. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  38794. * This can provide greater z depth for distant objects.
  38795. */
  38796. useReverseDepthBuffer: boolean;
  38797. /**
  38798. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  38799. */
  38800. disableUniformBuffers: boolean;
  38801. /** @hidden */
  38802. _uniformBuffers: UniformBuffer[];
  38803. /**
  38804. * Gets a boolean indicating that the engine supports uniform buffers
  38805. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  38806. */
  38807. get supportsUniformBuffers(): boolean;
  38808. /** @hidden */
  38809. _gl: WebGLRenderingContext;
  38810. /** @hidden */
  38811. _webGLVersion: number;
  38812. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  38813. protected _windowIsBackground: boolean;
  38814. protected _creationOptions: EngineOptions;
  38815. protected _highPrecisionShadersAllowed: boolean;
  38816. /** @hidden */
  38817. get _shouldUseHighPrecisionShader(): boolean;
  38818. /**
  38819. * Gets a boolean indicating that only power of 2 textures are supported
  38820. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  38821. */
  38822. get needPOTTextures(): boolean;
  38823. /** @hidden */
  38824. _badOS: boolean;
  38825. /** @hidden */
  38826. _badDesktopOS: boolean;
  38827. private _hardwareScalingLevel;
  38828. /** @hidden */
  38829. _caps: EngineCapabilities;
  38830. private _isStencilEnable;
  38831. private _glVersion;
  38832. private _glRenderer;
  38833. private _glVendor;
  38834. /** @hidden */
  38835. _videoTextureSupported: boolean;
  38836. protected _renderingQueueLaunched: boolean;
  38837. protected _activeRenderLoops: (() => void)[];
  38838. /**
  38839. * Observable signaled when a context lost event is raised
  38840. */
  38841. onContextLostObservable: Observable<ThinEngine>;
  38842. /**
  38843. * Observable signaled when a context restored event is raised
  38844. */
  38845. onContextRestoredObservable: Observable<ThinEngine>;
  38846. private _onContextLost;
  38847. private _onContextRestored;
  38848. protected _contextWasLost: boolean;
  38849. /** @hidden */
  38850. _doNotHandleContextLost: boolean;
  38851. /**
  38852. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  38853. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  38854. */
  38855. get doNotHandleContextLost(): boolean;
  38856. set doNotHandleContextLost(value: boolean);
  38857. /**
  38858. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  38859. */
  38860. disableVertexArrayObjects: boolean;
  38861. /** @hidden */
  38862. protected _colorWrite: boolean;
  38863. /** @hidden */
  38864. protected _colorWriteChanged: boolean;
  38865. /** @hidden */
  38866. protected _depthCullingState: DepthCullingState;
  38867. /** @hidden */
  38868. protected _stencilState: StencilState;
  38869. /** @hidden */
  38870. _alphaState: AlphaState;
  38871. /** @hidden */
  38872. _alphaMode: number;
  38873. /** @hidden */
  38874. _alphaEquation: number;
  38875. /** @hidden */
  38876. _internalTexturesCache: InternalTexture[];
  38877. /** @hidden */
  38878. protected _activeChannel: number;
  38879. private _currentTextureChannel;
  38880. /** @hidden */
  38881. protected _boundTexturesCache: {
  38882. [key: string]: Nullable<InternalTexture>;
  38883. };
  38884. /** @hidden */
  38885. protected _currentEffect: Nullable<Effect>;
  38886. /** @hidden */
  38887. protected _currentProgram: Nullable<WebGLProgram>;
  38888. private _compiledEffects;
  38889. private _vertexAttribArraysEnabled;
  38890. /** @hidden */
  38891. protected _cachedViewport: Nullable<IViewportLike>;
  38892. private _cachedVertexArrayObject;
  38893. /** @hidden */
  38894. protected _cachedVertexBuffers: any;
  38895. /** @hidden */
  38896. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  38897. /** @hidden */
  38898. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  38899. /** @hidden */
  38900. _currentRenderTarget: Nullable<InternalTexture>;
  38901. private _uintIndicesCurrentlySet;
  38902. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  38903. /** @hidden */
  38904. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  38905. /** @hidden */
  38906. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  38907. private _currentBufferPointers;
  38908. private _currentInstanceLocations;
  38909. private _currentInstanceBuffers;
  38910. private _textureUnits;
  38911. /** @hidden */
  38912. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38913. /** @hidden */
  38914. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38915. /** @hidden */
  38916. _boundRenderFunction: any;
  38917. private _vaoRecordInProgress;
  38918. private _mustWipeVertexAttributes;
  38919. private _emptyTexture;
  38920. private _emptyCubeTexture;
  38921. private _emptyTexture3D;
  38922. private _emptyTexture2DArray;
  38923. /** @hidden */
  38924. _frameHandler: number;
  38925. private _nextFreeTextureSlots;
  38926. private _maxSimultaneousTextures;
  38927. private _activeRequests;
  38928. /** @hidden */
  38929. _transformTextureUrl: Nullable<(url: string) => string>;
  38930. /**
  38931. * Gets information about the current host
  38932. */
  38933. hostInformation: HostInformation;
  38934. protected get _supportsHardwareTextureRescaling(): boolean;
  38935. private _framebufferDimensionsObject;
  38936. /**
  38937. * sets the object from which width and height will be taken from when getting render width and height
  38938. * Will fallback to the gl object
  38939. * @param dimensions the framebuffer width and height that will be used.
  38940. */
  38941. set framebufferDimensionsObject(dimensions: Nullable<{
  38942. framebufferWidth: number;
  38943. framebufferHeight: number;
  38944. }>);
  38945. /**
  38946. * Gets the current viewport
  38947. */
  38948. get currentViewport(): Nullable<IViewportLike>;
  38949. /**
  38950. * Gets the default empty texture
  38951. */
  38952. get emptyTexture(): InternalTexture;
  38953. /**
  38954. * Gets the default empty 3D texture
  38955. */
  38956. get emptyTexture3D(): InternalTexture;
  38957. /**
  38958. * Gets the default empty 2D array texture
  38959. */
  38960. get emptyTexture2DArray(): InternalTexture;
  38961. /**
  38962. * Gets the default empty cube texture
  38963. */
  38964. get emptyCubeTexture(): InternalTexture;
  38965. /**
  38966. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  38967. */
  38968. readonly premultipliedAlpha: boolean;
  38969. /**
  38970. * Observable event triggered before each texture is initialized
  38971. */
  38972. onBeforeTextureInitObservable: Observable<Texture>;
  38973. /**
  38974. * Creates a new engine
  38975. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  38976. * @param antialias defines enable antialiasing (default: false)
  38977. * @param options defines further options to be sent to the getContext() function
  38978. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38979. */
  38980. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38981. private _rebuildInternalTextures;
  38982. private _rebuildEffects;
  38983. /**
  38984. * Gets a boolean indicating if all created effects are ready
  38985. * @returns true if all effects are ready
  38986. */
  38987. areAllEffectsReady(): boolean;
  38988. protected _rebuildBuffers(): void;
  38989. protected _initGLContext(): void;
  38990. /**
  38991. * Gets version of the current webGL context
  38992. */
  38993. get webGLVersion(): number;
  38994. /**
  38995. * Gets a string identifying the name of the class
  38996. * @returns "Engine" string
  38997. */
  38998. getClassName(): string;
  38999. /**
  39000. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39001. */
  39002. get isStencilEnable(): boolean;
  39003. /** @hidden */
  39004. _prepareWorkingCanvas(): void;
  39005. /**
  39006. * Reset the texture cache to empty state
  39007. */
  39008. resetTextureCache(): void;
  39009. /**
  39010. * Gets an object containing information about the current webGL context
  39011. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39012. */
  39013. getGlInfo(): {
  39014. vendor: string;
  39015. renderer: string;
  39016. version: string;
  39017. };
  39018. /**
  39019. * Defines the hardware scaling level.
  39020. * By default the hardware scaling level is computed from the window device ratio.
  39021. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  39022. * @param level defines the level to use
  39023. */
  39024. setHardwareScalingLevel(level: number): void;
  39025. /**
  39026. * Gets the current hardware scaling level.
  39027. * By default the hardware scaling level is computed from the window device ratio.
  39028. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  39029. * @returns a number indicating the current hardware scaling level
  39030. */
  39031. getHardwareScalingLevel(): number;
  39032. /**
  39033. * Gets the list of loaded textures
  39034. * @returns an array containing all loaded textures
  39035. */
  39036. getLoadedTexturesCache(): InternalTexture[];
  39037. /**
  39038. * Gets the object containing all engine capabilities
  39039. * @returns the EngineCapabilities object
  39040. */
  39041. getCaps(): EngineCapabilities;
  39042. /**
  39043. * stop executing a render loop function and remove it from the execution array
  39044. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39045. */
  39046. stopRenderLoop(renderFunction?: () => void): void;
  39047. /** @hidden */
  39048. _renderLoop(): void;
  39049. /**
  39050. * Gets the HTML canvas attached with the current webGL context
  39051. * @returns a HTML canvas
  39052. */
  39053. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39054. /**
  39055. * Gets host window
  39056. * @returns the host window object
  39057. */
  39058. getHostWindow(): Nullable<Window>;
  39059. /**
  39060. * Gets the current render width
  39061. * @param useScreen defines if screen size must be used (or the current render target if any)
  39062. * @returns a number defining the current render width
  39063. */
  39064. getRenderWidth(useScreen?: boolean): number;
  39065. /**
  39066. * Gets the current render height
  39067. * @param useScreen defines if screen size must be used (or the current render target if any)
  39068. * @returns a number defining the current render height
  39069. */
  39070. getRenderHeight(useScreen?: boolean): number;
  39071. /**
  39072. * Can be used to override the current requestAnimationFrame requester.
  39073. * @hidden
  39074. */
  39075. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39076. /**
  39077. * Register and execute a render loop. The engine can have more than one render function
  39078. * @param renderFunction defines the function to continuously execute
  39079. */
  39080. runRenderLoop(renderFunction: () => void): void;
  39081. /**
  39082. * Clear the current render buffer or the current render target (if any is set up)
  39083. * @param color defines the color to use
  39084. * @param backBuffer defines if the back buffer must be cleared
  39085. * @param depth defines if the depth buffer must be cleared
  39086. * @param stencil defines if the stencil buffer must be cleared
  39087. */
  39088. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39089. private _viewportCached;
  39090. /** @hidden */
  39091. _viewport(x: number, y: number, width: number, height: number): void;
  39092. /**
  39093. * Set the WebGL's viewport
  39094. * @param viewport defines the viewport element to be used
  39095. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39096. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39097. */
  39098. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39099. /**
  39100. * Begin a new frame
  39101. */
  39102. beginFrame(): void;
  39103. /**
  39104. * Enf the current frame
  39105. */
  39106. endFrame(): void;
  39107. /**
  39108. * Resize the view according to the canvas' size
  39109. */
  39110. resize(): void;
  39111. /**
  39112. * Force a specific size of the canvas
  39113. * @param width defines the new canvas' width
  39114. * @param height defines the new canvas' height
  39115. * @returns true if the size was changed
  39116. */
  39117. setSize(width: number, height: number): boolean;
  39118. /**
  39119. * Binds the frame buffer to the specified texture.
  39120. * @param texture The texture to render to or null for the default canvas
  39121. * @param faceIndex The face of the texture to render to in case of cube texture
  39122. * @param requiredWidth The width of the target to render to
  39123. * @param requiredHeight The height of the target to render to
  39124. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39125. * @param lodLevel defines the lod level to bind to the frame buffer
  39126. * @param layer defines the 2d array index to bind to frame buffer to
  39127. */
  39128. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39129. /** @hidden */
  39130. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39131. /**
  39132. * Unbind the current render target texture from the webGL context
  39133. * @param texture defines the render target texture to unbind
  39134. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39135. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39136. */
  39137. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39138. /**
  39139. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39140. */
  39141. flushFramebuffer(): void;
  39142. /**
  39143. * Unbind the current render target and bind the default framebuffer
  39144. */
  39145. restoreDefaultFramebuffer(): void;
  39146. /** @hidden */
  39147. protected _resetVertexBufferBinding(): void;
  39148. /**
  39149. * Creates a vertex buffer
  39150. * @param data the data for the vertex buffer
  39151. * @returns the new WebGL static buffer
  39152. */
  39153. createVertexBuffer(data: DataArray): DataBuffer;
  39154. private _createVertexBuffer;
  39155. /**
  39156. * Creates a dynamic vertex buffer
  39157. * @param data the data for the dynamic vertex buffer
  39158. * @returns the new WebGL dynamic buffer
  39159. */
  39160. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39161. protected _resetIndexBufferBinding(): void;
  39162. /**
  39163. * Creates a new index buffer
  39164. * @param indices defines the content of the index buffer
  39165. * @param updatable defines if the index buffer must be updatable
  39166. * @returns a new webGL buffer
  39167. */
  39168. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39169. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39170. /**
  39171. * Bind a webGL buffer to the webGL context
  39172. * @param buffer defines the buffer to bind
  39173. */
  39174. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39175. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39176. private bindBuffer;
  39177. /**
  39178. * update the bound buffer with the given data
  39179. * @param data defines the data to update
  39180. */
  39181. updateArrayBuffer(data: Float32Array): void;
  39182. private _vertexAttribPointer;
  39183. /** @hidden */
  39184. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39185. private _bindVertexBuffersAttributes;
  39186. /**
  39187. * Records a vertex array object
  39188. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39189. * @param vertexBuffers defines the list of vertex buffers to store
  39190. * @param indexBuffer defines the index buffer to store
  39191. * @param effect defines the effect to store
  39192. * @returns the new vertex array object
  39193. */
  39194. recordVertexArrayObject(vertexBuffers: {
  39195. [key: string]: VertexBuffer;
  39196. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39197. /**
  39198. * Bind a specific vertex array object
  39199. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39200. * @param vertexArrayObject defines the vertex array object to bind
  39201. * @param indexBuffer defines the index buffer to bind
  39202. */
  39203. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39204. /**
  39205. * Bind webGl buffers directly to the webGL context
  39206. * @param vertexBuffer defines the vertex buffer to bind
  39207. * @param indexBuffer defines the index buffer to bind
  39208. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39209. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39210. * @param effect defines the effect associated with the vertex buffer
  39211. */
  39212. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39213. private _unbindVertexArrayObject;
  39214. /**
  39215. * Bind a list of vertex buffers to the webGL context
  39216. * @param vertexBuffers defines the list of vertex buffers to bind
  39217. * @param indexBuffer defines the index buffer to bind
  39218. * @param effect defines the effect associated with the vertex buffers
  39219. */
  39220. bindBuffers(vertexBuffers: {
  39221. [key: string]: Nullable<VertexBuffer>;
  39222. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39223. /**
  39224. * Unbind all instance attributes
  39225. */
  39226. unbindInstanceAttributes(): void;
  39227. /**
  39228. * Release and free the memory of a vertex array object
  39229. * @param vao defines the vertex array object to delete
  39230. */
  39231. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39232. /** @hidden */
  39233. _releaseBuffer(buffer: DataBuffer): boolean;
  39234. protected _deleteBuffer(buffer: DataBuffer): void;
  39235. /**
  39236. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39237. * @param instancesBuffer defines the webGL buffer to update and bind
  39238. * @param data defines the data to store in the buffer
  39239. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39240. */
  39241. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39242. /**
  39243. * Bind the content of a webGL buffer used with instantiation
  39244. * @param instancesBuffer defines the webGL buffer to bind
  39245. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39246. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39247. */
  39248. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39249. /**
  39250. * Disable the instance attribute corresponding to the name in parameter
  39251. * @param name defines the name of the attribute to disable
  39252. */
  39253. disableInstanceAttributeByName(name: string): void;
  39254. /**
  39255. * Disable the instance attribute corresponding to the location in parameter
  39256. * @param attributeLocation defines the attribute location of the attribute to disable
  39257. */
  39258. disableInstanceAttribute(attributeLocation: number): void;
  39259. /**
  39260. * Disable the attribute corresponding to the location in parameter
  39261. * @param attributeLocation defines the attribute location of the attribute to disable
  39262. */
  39263. disableAttributeByIndex(attributeLocation: number): void;
  39264. /**
  39265. * Send a draw order
  39266. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39267. * @param indexStart defines the starting index
  39268. * @param indexCount defines the number of index to draw
  39269. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39270. */
  39271. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39272. /**
  39273. * Draw a list of points
  39274. * @param verticesStart defines the index of first vertex to draw
  39275. * @param verticesCount defines the count of vertices to draw
  39276. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39277. */
  39278. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39279. /**
  39280. * Draw a list of unindexed primitives
  39281. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39282. * @param verticesStart defines the index of first vertex to draw
  39283. * @param verticesCount defines the count of vertices to draw
  39284. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39285. */
  39286. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39287. /**
  39288. * Draw a list of indexed primitives
  39289. * @param fillMode defines the primitive to use
  39290. * @param indexStart defines the starting index
  39291. * @param indexCount defines the number of index to draw
  39292. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39293. */
  39294. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39295. /**
  39296. * Draw a list of unindexed primitives
  39297. * @param fillMode defines the primitive to use
  39298. * @param verticesStart defines the index of first vertex to draw
  39299. * @param verticesCount defines the count of vertices to draw
  39300. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39301. */
  39302. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39303. private _drawMode;
  39304. /** @hidden */
  39305. protected _reportDrawCall(): void;
  39306. /** @hidden */
  39307. _releaseEffect(effect: Effect): void;
  39308. /** @hidden */
  39309. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39310. /**
  39311. * Create a new effect (used to store vertex/fragment shaders)
  39312. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39313. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39314. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39315. * @param samplers defines an array of string used to represent textures
  39316. * @param defines defines the string containing the defines to use to compile the shaders
  39317. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39318. * @param onCompiled defines a function to call when the effect creation is successful
  39319. * @param onError defines a function to call when the effect creation has failed
  39320. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39321. * @returns the new Effect
  39322. */
  39323. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  39324. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39325. private _compileShader;
  39326. private _compileRawShader;
  39327. /** @hidden */
  39328. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39329. /**
  39330. * Directly creates a webGL program
  39331. * @param pipelineContext defines the pipeline context to attach to
  39332. * @param vertexCode defines the vertex shader code to use
  39333. * @param fragmentCode defines the fragment shader code to use
  39334. * @param context defines the webGL context to use (if not set, the current one will be used)
  39335. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39336. * @returns the new webGL program
  39337. */
  39338. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39339. /**
  39340. * Creates a webGL program
  39341. * @param pipelineContext defines the pipeline context to attach to
  39342. * @param vertexCode defines the vertex shader code to use
  39343. * @param fragmentCode defines the fragment shader code to use
  39344. * @param defines defines the string containing the defines to use to compile the shaders
  39345. * @param context defines the webGL context to use (if not set, the current one will be used)
  39346. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39347. * @returns the new webGL program
  39348. */
  39349. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39350. /**
  39351. * Creates a new pipeline context
  39352. * @returns the new pipeline
  39353. */
  39354. createPipelineContext(): IPipelineContext;
  39355. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39356. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39357. /** @hidden */
  39358. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39359. /** @hidden */
  39360. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39361. /** @hidden */
  39362. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39363. /**
  39364. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39365. * @param pipelineContext defines the pipeline context to use
  39366. * @param uniformsNames defines the list of uniform names
  39367. * @returns an array of webGL uniform locations
  39368. */
  39369. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39370. /**
  39371. * Gets the lsit of active attributes for a given webGL program
  39372. * @param pipelineContext defines the pipeline context to use
  39373. * @param attributesNames defines the list of attribute names to get
  39374. * @returns an array of indices indicating the offset of each attribute
  39375. */
  39376. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39377. /**
  39378. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39379. * @param effect defines the effect to activate
  39380. */
  39381. enableEffect(effect: Nullable<Effect>): void;
  39382. /**
  39383. * Set the value of an uniform to a number (int)
  39384. * @param uniform defines the webGL uniform location where to store the value
  39385. * @param value defines the int number to store
  39386. * @returns true if the value was set
  39387. */
  39388. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39389. /**
  39390. * Set the value of an uniform to an array of int32
  39391. * @param uniform defines the webGL uniform location where to store the value
  39392. * @param array defines the array of int32 to store
  39393. * @returns true if the value was set
  39394. */
  39395. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39396. /**
  39397. * Set the value of an uniform to an array of int32 (stored as vec2)
  39398. * @param uniform defines the webGL uniform location where to store the value
  39399. * @param array defines the array of int32 to store
  39400. * @returns true if the value was set
  39401. */
  39402. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39403. /**
  39404. * Set the value of an uniform to an array of int32 (stored as vec3)
  39405. * @param uniform defines the webGL uniform location where to store the value
  39406. * @param array defines the array of int32 to store
  39407. * @returns true if the value was set
  39408. */
  39409. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39410. /**
  39411. * Set the value of an uniform to an array of int32 (stored as vec4)
  39412. * @param uniform defines the webGL uniform location where to store the value
  39413. * @param array defines the array of int32 to store
  39414. * @returns true if the value was set
  39415. */
  39416. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39417. /**
  39418. * Set the value of an uniform to an array of number
  39419. * @param uniform defines the webGL uniform location where to store the value
  39420. * @param array defines the array of number to store
  39421. * @returns true if the value was set
  39422. */
  39423. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39424. /**
  39425. * Set the value of an uniform to an array of number (stored as vec2)
  39426. * @param uniform defines the webGL uniform location where to store the value
  39427. * @param array defines the array of number to store
  39428. * @returns true if the value was set
  39429. */
  39430. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39431. /**
  39432. * Set the value of an uniform to an array of number (stored as vec3)
  39433. * @param uniform defines the webGL uniform location where to store the value
  39434. * @param array defines the array of number to store
  39435. * @returns true if the value was set
  39436. */
  39437. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39438. /**
  39439. * Set the value of an uniform to an array of number (stored as vec4)
  39440. * @param uniform defines the webGL uniform location where to store the value
  39441. * @param array defines the array of number to store
  39442. * @returns true if the value was set
  39443. */
  39444. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39445. /**
  39446. * Set the value of an uniform to an array of float32 (stored as matrices)
  39447. * @param uniform defines the webGL uniform location where to store the value
  39448. * @param matrices defines the array of float32 to store
  39449. * @returns true if the value was set
  39450. */
  39451. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39452. /**
  39453. * Set the value of an uniform to a matrix (3x3)
  39454. * @param uniform defines the webGL uniform location where to store the value
  39455. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39456. * @returns true if the value was set
  39457. */
  39458. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39459. /**
  39460. * Set the value of an uniform to a matrix (2x2)
  39461. * @param uniform defines the webGL uniform location where to store the value
  39462. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39463. * @returns true if the value was set
  39464. */
  39465. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39466. /**
  39467. * Set the value of an uniform to a number (float)
  39468. * @param uniform defines the webGL uniform location where to store the value
  39469. * @param value defines the float number to store
  39470. * @returns true if the value was transfered
  39471. */
  39472. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39473. /**
  39474. * Set the value of an uniform to a vec2
  39475. * @param uniform defines the webGL uniform location where to store the value
  39476. * @param x defines the 1st component of the value
  39477. * @param y defines the 2nd component of the value
  39478. * @returns true if the value was set
  39479. */
  39480. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39481. /**
  39482. * Set the value of an uniform to a vec3
  39483. * @param uniform defines the webGL uniform location where to store the value
  39484. * @param x defines the 1st component of the value
  39485. * @param y defines the 2nd component of the value
  39486. * @param z defines the 3rd component of the value
  39487. * @returns true if the value was set
  39488. */
  39489. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39490. /**
  39491. * Set the value of an uniform to a vec4
  39492. * @param uniform defines the webGL uniform location where to store the value
  39493. * @param x defines the 1st component of the value
  39494. * @param y defines the 2nd component of the value
  39495. * @param z defines the 3rd component of the value
  39496. * @param w defines the 4th component of the value
  39497. * @returns true if the value was set
  39498. */
  39499. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39500. /**
  39501. * Apply all cached states (depth, culling, stencil and alpha)
  39502. */
  39503. applyStates(): void;
  39504. /**
  39505. * Enable or disable color writing
  39506. * @param enable defines the state to set
  39507. */
  39508. setColorWrite(enable: boolean): void;
  39509. /**
  39510. * Gets a boolean indicating if color writing is enabled
  39511. * @returns the current color writing state
  39512. */
  39513. getColorWrite(): boolean;
  39514. /**
  39515. * Gets the depth culling state manager
  39516. */
  39517. get depthCullingState(): DepthCullingState;
  39518. /**
  39519. * Gets the alpha state manager
  39520. */
  39521. get alphaState(): AlphaState;
  39522. /**
  39523. * Gets the stencil state manager
  39524. */
  39525. get stencilState(): StencilState;
  39526. /**
  39527. * Clears the list of texture accessible through engine.
  39528. * This can help preventing texture load conflict due to name collision.
  39529. */
  39530. clearInternalTexturesCache(): void;
  39531. /**
  39532. * Force the entire cache to be cleared
  39533. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39534. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39535. */
  39536. wipeCaches(bruteForce?: boolean): void;
  39537. /** @hidden */
  39538. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39539. min: number;
  39540. mag: number;
  39541. };
  39542. /** @hidden */
  39543. _createTexture(): WebGLTexture;
  39544. /**
  39545. * Usually called from Texture.ts.
  39546. * Passed information to create a WebGLTexture
  39547. * @param url defines a value which contains one of the following:
  39548. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39549. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39550. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39551. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39552. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  39553. * @param scene needed for loading to the correct scene
  39554. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39555. * @param onLoad optional callback to be called upon successful completion
  39556. * @param onError optional callback to be called upon failure
  39557. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  39558. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39559. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39560. * @param forcedExtension defines the extension to use to pick the right loader
  39561. * @param mimeType defines an optional mime type
  39562. * @param loaderOptions options to be passed to the loader
  39563. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39564. */
  39565. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  39566. /**
  39567. * Loads an image as an HTMLImageElement.
  39568. * @param input url string, ArrayBuffer, or Blob to load
  39569. * @param onLoad callback called when the image successfully loads
  39570. * @param onError callback called when the image fails to load
  39571. * @param offlineProvider offline provider for caching
  39572. * @param mimeType optional mime type
  39573. * @returns the HTMLImageElement of the loaded image
  39574. * @hidden
  39575. */
  39576. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39577. /**
  39578. * @hidden
  39579. */
  39580. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39581. private _unpackFlipYCached;
  39582. /**
  39583. * In case you are sharing the context with other applications, it might
  39584. * be interested to not cache the unpack flip y state to ensure a consistent
  39585. * value would be set.
  39586. */
  39587. enableUnpackFlipYCached: boolean;
  39588. /** @hidden */
  39589. _unpackFlipY(value: boolean): void;
  39590. /** @hidden */
  39591. _getUnpackAlignement(): number;
  39592. private _getTextureTarget;
  39593. /**
  39594. * Update the sampling mode of a given texture
  39595. * @param samplingMode defines the required sampling mode
  39596. * @param texture defines the texture to update
  39597. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39598. */
  39599. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39600. /**
  39601. * Update the sampling mode of a given texture
  39602. * @param texture defines the texture to update
  39603. * @param wrapU defines the texture wrap mode of the u coordinates
  39604. * @param wrapV defines the texture wrap mode of the v coordinates
  39605. * @param wrapR defines the texture wrap mode of the r coordinates
  39606. */
  39607. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39608. /** @hidden */
  39609. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39610. width: number;
  39611. height: number;
  39612. layers?: number;
  39613. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39614. /** @hidden */
  39615. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39616. /** @hidden */
  39617. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39618. /**
  39619. * Update a portion of an internal texture
  39620. * @param texture defines the texture to update
  39621. * @param imageData defines the data to store into the texture
  39622. * @param xOffset defines the x coordinates of the update rectangle
  39623. * @param yOffset defines the y coordinates of the update rectangle
  39624. * @param width defines the width of the update rectangle
  39625. * @param height defines the height of the update rectangle
  39626. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39627. * @param lod defines the lod level to update (0 by default)
  39628. */
  39629. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39630. /** @hidden */
  39631. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39632. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39633. private _prepareWebGLTexture;
  39634. /** @hidden */
  39635. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39636. private _getDepthStencilBuffer;
  39637. /** @hidden */
  39638. _releaseFramebufferObjects(texture: InternalTexture): void;
  39639. /** @hidden */
  39640. _releaseTexture(texture: InternalTexture): void;
  39641. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39642. protected _setProgram(program: WebGLProgram): void;
  39643. protected _boundUniforms: {
  39644. [key: number]: WebGLUniformLocation;
  39645. };
  39646. /**
  39647. * Binds an effect to the webGL context
  39648. * @param effect defines the effect to bind
  39649. */
  39650. bindSamplers(effect: Effect): void;
  39651. private _activateCurrentTexture;
  39652. /** @hidden */
  39653. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39654. /** @hidden */
  39655. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39656. /**
  39657. * Unbind all textures from the webGL context
  39658. */
  39659. unbindAllTextures(): void;
  39660. /**
  39661. * Sets a texture to the according uniform.
  39662. * @param channel The texture channel
  39663. * @param uniform The uniform to set
  39664. * @param texture The texture to apply
  39665. */
  39666. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  39667. private _bindSamplerUniformToChannel;
  39668. private _getTextureWrapMode;
  39669. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39670. /**
  39671. * Sets an array of texture to the webGL context
  39672. * @param channel defines the channel where the texture array must be set
  39673. * @param uniform defines the associated uniform location
  39674. * @param textures defines the array of textures to bind
  39675. */
  39676. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  39677. /** @hidden */
  39678. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39679. private _setTextureParameterFloat;
  39680. private _setTextureParameterInteger;
  39681. /**
  39682. * Unbind all vertex attributes from the webGL context
  39683. */
  39684. unbindAllAttributes(): void;
  39685. /**
  39686. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  39687. */
  39688. releaseEffects(): void;
  39689. /**
  39690. * Dispose and release all associated resources
  39691. */
  39692. dispose(): void;
  39693. /**
  39694. * Attach a new callback raised when context lost event is fired
  39695. * @param callback defines the callback to call
  39696. */
  39697. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39698. /**
  39699. * Attach a new callback raised when context restored event is fired
  39700. * @param callback defines the callback to call
  39701. */
  39702. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39703. /**
  39704. * Get the current error code of the webGL context
  39705. * @returns the error code
  39706. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39707. */
  39708. getError(): number;
  39709. private _canRenderToFloatFramebuffer;
  39710. private _canRenderToHalfFloatFramebuffer;
  39711. private _canRenderToFramebuffer;
  39712. /** @hidden */
  39713. _getWebGLTextureType(type: number): number;
  39714. /** @hidden */
  39715. _getInternalFormat(format: number): number;
  39716. /** @hidden */
  39717. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  39718. /** @hidden */
  39719. _getRGBAMultiSampleBufferFormat(type: number): number;
  39720. /** @hidden */
  39721. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  39722. /**
  39723. * Loads a file from a url
  39724. * @param url url to load
  39725. * @param onSuccess callback called when the file successfully loads
  39726. * @param onProgress callback called while file is loading (if the server supports this mode)
  39727. * @param offlineProvider defines the offline provider for caching
  39728. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39729. * @param onError callback called when the file fails to load
  39730. * @returns a file request object
  39731. * @hidden
  39732. */
  39733. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  39734. /**
  39735. * Reads pixels from the current frame buffer. Please note that this function can be slow
  39736. * @param x defines the x coordinate of the rectangle where pixels must be read
  39737. * @param y defines the y coordinate of the rectangle where pixels must be read
  39738. * @param width defines the width of the rectangle where pixels must be read
  39739. * @param height defines the height of the rectangle where pixels must be read
  39740. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  39741. * @returns a Uint8Array containing RGBA colors
  39742. */
  39743. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  39744. private static _IsSupported;
  39745. private static _HasMajorPerformanceCaveat;
  39746. /**
  39747. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39748. */
  39749. static get IsSupported(): boolean;
  39750. /**
  39751. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39752. * @returns true if the engine can be created
  39753. * @ignorenaming
  39754. */
  39755. static isSupported(): boolean;
  39756. /**
  39757. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  39758. */
  39759. static get HasMajorPerformanceCaveat(): boolean;
  39760. /**
  39761. * Find the next highest power of two.
  39762. * @param x Number to start search from.
  39763. * @return Next highest power of two.
  39764. */
  39765. static CeilingPOT(x: number): number;
  39766. /**
  39767. * Find the next lowest power of two.
  39768. * @param x Number to start search from.
  39769. * @return Next lowest power of two.
  39770. */
  39771. static FloorPOT(x: number): number;
  39772. /**
  39773. * Find the nearest power of two.
  39774. * @param x Number to start search from.
  39775. * @return Next nearest power of two.
  39776. */
  39777. static NearestPOT(x: number): number;
  39778. /**
  39779. * Get the closest exponent of two
  39780. * @param value defines the value to approximate
  39781. * @param max defines the maximum value to return
  39782. * @param mode defines how to define the closest value
  39783. * @returns closest exponent of two of the given value
  39784. */
  39785. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39786. /**
  39787. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39788. * @param func - the function to be called
  39789. * @param requester - the object that will request the next frame. Falls back to window.
  39790. * @returns frame number
  39791. */
  39792. static QueueNewFrame(func: () => void, requester?: any): number;
  39793. /**
  39794. * Gets host document
  39795. * @returns the host document object
  39796. */
  39797. getHostDocument(): Nullable<Document>;
  39798. }
  39799. }
  39800. declare module BABYLON {
  39801. /**
  39802. * Defines the source of the internal texture
  39803. */
  39804. export enum InternalTextureSource {
  39805. /**
  39806. * The source of the texture data is unknown
  39807. */
  39808. Unknown = 0,
  39809. /**
  39810. * Texture data comes from an URL
  39811. */
  39812. Url = 1,
  39813. /**
  39814. * Texture data is only used for temporary storage
  39815. */
  39816. Temp = 2,
  39817. /**
  39818. * Texture data comes from raw data (ArrayBuffer)
  39819. */
  39820. Raw = 3,
  39821. /**
  39822. * Texture content is dynamic (video or dynamic texture)
  39823. */
  39824. Dynamic = 4,
  39825. /**
  39826. * Texture content is generated by rendering to it
  39827. */
  39828. RenderTarget = 5,
  39829. /**
  39830. * Texture content is part of a multi render target process
  39831. */
  39832. MultiRenderTarget = 6,
  39833. /**
  39834. * Texture data comes from a cube data file
  39835. */
  39836. Cube = 7,
  39837. /**
  39838. * Texture data comes from a raw cube data
  39839. */
  39840. CubeRaw = 8,
  39841. /**
  39842. * Texture data come from a prefiltered cube data file
  39843. */
  39844. CubePrefiltered = 9,
  39845. /**
  39846. * Texture content is raw 3D data
  39847. */
  39848. Raw3D = 10,
  39849. /**
  39850. * Texture content is raw 2D array data
  39851. */
  39852. Raw2DArray = 11,
  39853. /**
  39854. * Texture content is a depth texture
  39855. */
  39856. Depth = 12,
  39857. /**
  39858. * Texture data comes from a raw cube data encoded with RGBD
  39859. */
  39860. CubeRawRGBD = 13
  39861. }
  39862. /**
  39863. * Class used to store data associated with WebGL texture data for the engine
  39864. * This class should not be used directly
  39865. */
  39866. export class InternalTexture {
  39867. /** @hidden */
  39868. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  39869. /**
  39870. * Defines if the texture is ready
  39871. */
  39872. isReady: boolean;
  39873. /**
  39874. * Defines if the texture is a cube texture
  39875. */
  39876. isCube: boolean;
  39877. /**
  39878. * Defines if the texture contains 3D data
  39879. */
  39880. is3D: boolean;
  39881. /**
  39882. * Defines if the texture contains 2D array data
  39883. */
  39884. is2DArray: boolean;
  39885. /**
  39886. * Defines if the texture contains multiview data
  39887. */
  39888. isMultiview: boolean;
  39889. /**
  39890. * Gets the URL used to load this texture
  39891. */
  39892. url: string;
  39893. /**
  39894. * Gets the sampling mode of the texture
  39895. */
  39896. samplingMode: number;
  39897. /**
  39898. * Gets a boolean indicating if the texture needs mipmaps generation
  39899. */
  39900. generateMipMaps: boolean;
  39901. /**
  39902. * Gets the number of samples used by the texture (WebGL2+ only)
  39903. */
  39904. samples: number;
  39905. /**
  39906. * Gets the type of the texture (int, float...)
  39907. */
  39908. type: number;
  39909. /**
  39910. * Gets the format of the texture (RGB, RGBA...)
  39911. */
  39912. format: number;
  39913. /**
  39914. * Observable called when the texture is loaded
  39915. */
  39916. onLoadedObservable: Observable<InternalTexture>;
  39917. /**
  39918. * Gets the width of the texture
  39919. */
  39920. width: number;
  39921. /**
  39922. * Gets the height of the texture
  39923. */
  39924. height: number;
  39925. /**
  39926. * Gets the depth of the texture
  39927. */
  39928. depth: number;
  39929. /**
  39930. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  39931. */
  39932. baseWidth: number;
  39933. /**
  39934. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  39935. */
  39936. baseHeight: number;
  39937. /**
  39938. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  39939. */
  39940. baseDepth: number;
  39941. /**
  39942. * Gets a boolean indicating if the texture is inverted on Y axis
  39943. */
  39944. invertY: boolean;
  39945. /** @hidden */
  39946. _invertVScale: boolean;
  39947. /** @hidden */
  39948. _associatedChannel: number;
  39949. /** @hidden */
  39950. _source: InternalTextureSource;
  39951. /** @hidden */
  39952. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  39953. /** @hidden */
  39954. _bufferView: Nullable<ArrayBufferView>;
  39955. /** @hidden */
  39956. _bufferViewArray: Nullable<ArrayBufferView[]>;
  39957. /** @hidden */
  39958. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  39959. /** @hidden */
  39960. _size: number;
  39961. /** @hidden */
  39962. _extension: string;
  39963. /** @hidden */
  39964. _files: Nullable<string[]>;
  39965. /** @hidden */
  39966. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39967. /** @hidden */
  39968. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39969. /** @hidden */
  39970. _framebuffer: Nullable<WebGLFramebuffer>;
  39971. /** @hidden */
  39972. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  39973. /** @hidden */
  39974. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  39975. /** @hidden */
  39976. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  39977. /** @hidden */
  39978. _attachments: Nullable<number[]>;
  39979. /** @hidden */
  39980. _textureArray: Nullable<InternalTexture[]>;
  39981. /** @hidden */
  39982. _cachedCoordinatesMode: Nullable<number>;
  39983. /** @hidden */
  39984. _cachedWrapU: Nullable<number>;
  39985. /** @hidden */
  39986. _cachedWrapV: Nullable<number>;
  39987. /** @hidden */
  39988. _cachedWrapR: Nullable<number>;
  39989. /** @hidden */
  39990. _cachedAnisotropicFilteringLevel: Nullable<number>;
  39991. /** @hidden */
  39992. _isDisabled: boolean;
  39993. /** @hidden */
  39994. _compression: Nullable<string>;
  39995. /** @hidden */
  39996. _generateStencilBuffer: boolean;
  39997. /** @hidden */
  39998. _generateDepthBuffer: boolean;
  39999. /** @hidden */
  40000. _comparisonFunction: number;
  40001. /** @hidden */
  40002. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40003. /** @hidden */
  40004. _lodGenerationScale: number;
  40005. /** @hidden */
  40006. _lodGenerationOffset: number;
  40007. /** @hidden */
  40008. _depthStencilTexture: Nullable<InternalTexture>;
  40009. /** @hidden */
  40010. _colorTextureArray: Nullable<WebGLTexture>;
  40011. /** @hidden */
  40012. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40013. /** @hidden */
  40014. _lodTextureHigh: Nullable<BaseTexture>;
  40015. /** @hidden */
  40016. _lodTextureMid: Nullable<BaseTexture>;
  40017. /** @hidden */
  40018. _lodTextureLow: Nullable<BaseTexture>;
  40019. /** @hidden */
  40020. _isRGBD: boolean;
  40021. /** @hidden */
  40022. _linearSpecularLOD: boolean;
  40023. /** @hidden */
  40024. _irradianceTexture: Nullable<BaseTexture>;
  40025. /** @hidden */
  40026. _webGLTexture: Nullable<WebGLTexture>;
  40027. /** @hidden */
  40028. _references: number;
  40029. /** @hidden */
  40030. _gammaSpace: Nullable<boolean>;
  40031. private _engine;
  40032. /**
  40033. * Gets the Engine the texture belongs to.
  40034. * @returns The babylon engine
  40035. */
  40036. getEngine(): ThinEngine;
  40037. /**
  40038. * Gets the data source type of the texture
  40039. */
  40040. get source(): InternalTextureSource;
  40041. /**
  40042. * Creates a new InternalTexture
  40043. * @param engine defines the engine to use
  40044. * @param source defines the type of data that will be used
  40045. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40046. */
  40047. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40048. /**
  40049. * Increments the number of references (ie. the number of Texture that point to it)
  40050. */
  40051. incrementReferences(): void;
  40052. /**
  40053. * Change the size of the texture (not the size of the content)
  40054. * @param width defines the new width
  40055. * @param height defines the new height
  40056. * @param depth defines the new depth (1 by default)
  40057. */
  40058. updateSize(width: int, height: int, depth?: int): void;
  40059. /** @hidden */
  40060. _rebuild(): void;
  40061. /** @hidden */
  40062. _swapAndDie(target: InternalTexture): void;
  40063. /**
  40064. * Dispose the current allocated resources
  40065. */
  40066. dispose(): void;
  40067. }
  40068. }
  40069. declare module BABYLON {
  40070. /**
  40071. * Interface used to present a loading screen while loading a scene
  40072. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40073. */
  40074. export interface ILoadingScreen {
  40075. /**
  40076. * Function called to display the loading screen
  40077. */
  40078. displayLoadingUI: () => void;
  40079. /**
  40080. * Function called to hide the loading screen
  40081. */
  40082. hideLoadingUI: () => void;
  40083. /**
  40084. * Gets or sets the color to use for the background
  40085. */
  40086. loadingUIBackgroundColor: string;
  40087. /**
  40088. * Gets or sets the text to display while loading
  40089. */
  40090. loadingUIText: string;
  40091. }
  40092. /**
  40093. * Class used for the default loading screen
  40094. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40095. */
  40096. export class DefaultLoadingScreen implements ILoadingScreen {
  40097. private _renderingCanvas;
  40098. private _loadingText;
  40099. private _loadingDivBackgroundColor;
  40100. private _loadingDiv;
  40101. private _loadingTextDiv;
  40102. /** Gets or sets the logo url to use for the default loading screen */
  40103. static DefaultLogoUrl: string;
  40104. /** Gets or sets the spinner url to use for the default loading screen */
  40105. static DefaultSpinnerUrl: string;
  40106. /**
  40107. * Creates a new default loading screen
  40108. * @param _renderingCanvas defines the canvas used to render the scene
  40109. * @param _loadingText defines the default text to display
  40110. * @param _loadingDivBackgroundColor defines the default background color
  40111. */
  40112. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40113. /**
  40114. * Function called to display the loading screen
  40115. */
  40116. displayLoadingUI(): void;
  40117. /**
  40118. * Function called to hide the loading screen
  40119. */
  40120. hideLoadingUI(): void;
  40121. /**
  40122. * Gets or sets the text to display while loading
  40123. */
  40124. set loadingUIText(text: string);
  40125. get loadingUIText(): string;
  40126. /**
  40127. * Gets or sets the color to use for the background
  40128. */
  40129. get loadingUIBackgroundColor(): string;
  40130. set loadingUIBackgroundColor(color: string);
  40131. private _resizeLoadingUI;
  40132. }
  40133. }
  40134. declare module BABYLON {
  40135. /**
  40136. * Interface for any object that can request an animation frame
  40137. */
  40138. export interface ICustomAnimationFrameRequester {
  40139. /**
  40140. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40141. */
  40142. renderFunction?: Function;
  40143. /**
  40144. * Called to request the next frame to render to
  40145. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40146. */
  40147. requestAnimationFrame: Function;
  40148. /**
  40149. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40150. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40151. */
  40152. requestID?: number;
  40153. }
  40154. }
  40155. declare module BABYLON {
  40156. /**
  40157. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40158. */
  40159. export class PerformanceMonitor {
  40160. private _enabled;
  40161. private _rollingFrameTime;
  40162. private _lastFrameTimeMs;
  40163. /**
  40164. * constructor
  40165. * @param frameSampleSize The number of samples required to saturate the sliding window
  40166. */
  40167. constructor(frameSampleSize?: number);
  40168. /**
  40169. * Samples current frame
  40170. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40171. */
  40172. sampleFrame(timeMs?: number): void;
  40173. /**
  40174. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40175. */
  40176. get averageFrameTime(): number;
  40177. /**
  40178. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40179. */
  40180. get averageFrameTimeVariance(): number;
  40181. /**
  40182. * Returns the frame time of the most recent frame
  40183. */
  40184. get instantaneousFrameTime(): number;
  40185. /**
  40186. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40187. */
  40188. get averageFPS(): number;
  40189. /**
  40190. * Returns the average framerate in frames per second using the most recent frame time
  40191. */
  40192. get instantaneousFPS(): number;
  40193. /**
  40194. * Returns true if enough samples have been taken to completely fill the sliding window
  40195. */
  40196. get isSaturated(): boolean;
  40197. /**
  40198. * Enables contributions to the sliding window sample set
  40199. */
  40200. enable(): void;
  40201. /**
  40202. * Disables contributions to the sliding window sample set
  40203. * Samples will not be interpolated over the disabled period
  40204. */
  40205. disable(): void;
  40206. /**
  40207. * Returns true if sampling is enabled
  40208. */
  40209. get isEnabled(): boolean;
  40210. /**
  40211. * Resets performance monitor
  40212. */
  40213. reset(): void;
  40214. }
  40215. /**
  40216. * RollingAverage
  40217. *
  40218. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40219. */
  40220. export class RollingAverage {
  40221. /**
  40222. * Current average
  40223. */
  40224. average: number;
  40225. /**
  40226. * Current variance
  40227. */
  40228. variance: number;
  40229. protected _samples: Array<number>;
  40230. protected _sampleCount: number;
  40231. protected _pos: number;
  40232. protected _m2: number;
  40233. /**
  40234. * constructor
  40235. * @param length The number of samples required to saturate the sliding window
  40236. */
  40237. constructor(length: number);
  40238. /**
  40239. * Adds a sample to the sample set
  40240. * @param v The sample value
  40241. */
  40242. add(v: number): void;
  40243. /**
  40244. * Returns previously added values or null if outside of history or outside the sliding window domain
  40245. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40246. * @return Value previously recorded with add() or null if outside of range
  40247. */
  40248. history(i: number): number;
  40249. /**
  40250. * Returns true if enough samples have been taken to completely fill the sliding window
  40251. * @return true if sample-set saturated
  40252. */
  40253. isSaturated(): boolean;
  40254. /**
  40255. * Resets the rolling average (equivalent to 0 samples taken so far)
  40256. */
  40257. reset(): void;
  40258. /**
  40259. * Wraps a value around the sample range boundaries
  40260. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40261. * @return Wrapped position in sample range
  40262. */
  40263. protected _wrapPosition(i: number): number;
  40264. }
  40265. }
  40266. declare module BABYLON {
  40267. /**
  40268. * This class is used to track a performance counter which is number based.
  40269. * The user has access to many properties which give statistics of different nature.
  40270. *
  40271. * The implementer can track two kinds of Performance Counter: time and count.
  40272. * 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.
  40273. * 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.
  40274. */
  40275. export class PerfCounter {
  40276. /**
  40277. * Gets or sets a global boolean to turn on and off all the counters
  40278. */
  40279. static Enabled: boolean;
  40280. /**
  40281. * Returns the smallest value ever
  40282. */
  40283. get min(): number;
  40284. /**
  40285. * Returns the biggest value ever
  40286. */
  40287. get max(): number;
  40288. /**
  40289. * Returns the average value since the performance counter is running
  40290. */
  40291. get average(): number;
  40292. /**
  40293. * Returns the average value of the last second the counter was monitored
  40294. */
  40295. get lastSecAverage(): number;
  40296. /**
  40297. * Returns the current value
  40298. */
  40299. get current(): number;
  40300. /**
  40301. * Gets the accumulated total
  40302. */
  40303. get total(): number;
  40304. /**
  40305. * Gets the total value count
  40306. */
  40307. get count(): number;
  40308. /**
  40309. * Creates a new counter
  40310. */
  40311. constructor();
  40312. /**
  40313. * Call this method to start monitoring a new frame.
  40314. * 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.
  40315. */
  40316. fetchNewFrame(): void;
  40317. /**
  40318. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40319. * @param newCount the count value to add to the monitored count
  40320. * @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.
  40321. */
  40322. addCount(newCount: number, fetchResult: boolean): void;
  40323. /**
  40324. * Start monitoring this performance counter
  40325. */
  40326. beginMonitoring(): void;
  40327. /**
  40328. * Compute the time lapsed since the previous beginMonitoring() call.
  40329. * @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
  40330. */
  40331. endMonitoring(newFrame?: boolean): void;
  40332. private _fetchResult;
  40333. private _startMonitoringTime;
  40334. private _min;
  40335. private _max;
  40336. private _average;
  40337. private _current;
  40338. private _totalValueCount;
  40339. private _totalAccumulated;
  40340. private _lastSecAverage;
  40341. private _lastSecAccumulated;
  40342. private _lastSecTime;
  40343. private _lastSecValueCount;
  40344. }
  40345. }
  40346. declare module BABYLON {
  40347. interface ThinEngine {
  40348. /** @hidden */
  40349. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40350. }
  40351. }
  40352. declare module BABYLON {
  40353. /**
  40354. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40355. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40356. */
  40357. export class Analyser {
  40358. /**
  40359. * Gets or sets the smoothing
  40360. * @ignorenaming
  40361. */
  40362. SMOOTHING: number;
  40363. /**
  40364. * Gets or sets the FFT table size
  40365. * @ignorenaming
  40366. */
  40367. FFT_SIZE: number;
  40368. /**
  40369. * Gets or sets the bar graph amplitude
  40370. * @ignorenaming
  40371. */
  40372. BARGRAPHAMPLITUDE: number;
  40373. /**
  40374. * Gets or sets the position of the debug canvas
  40375. * @ignorenaming
  40376. */
  40377. DEBUGCANVASPOS: {
  40378. x: number;
  40379. y: number;
  40380. };
  40381. /**
  40382. * Gets or sets the debug canvas size
  40383. * @ignorenaming
  40384. */
  40385. DEBUGCANVASSIZE: {
  40386. width: number;
  40387. height: number;
  40388. };
  40389. private _byteFreqs;
  40390. private _byteTime;
  40391. private _floatFreqs;
  40392. private _webAudioAnalyser;
  40393. private _debugCanvas;
  40394. private _debugCanvasContext;
  40395. private _scene;
  40396. private _registerFunc;
  40397. private _audioEngine;
  40398. /**
  40399. * Creates a new analyser
  40400. * @param scene defines hosting scene
  40401. */
  40402. constructor(scene: Scene);
  40403. /**
  40404. * Get the number of data values you will have to play with for the visualization
  40405. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40406. * @returns a number
  40407. */
  40408. getFrequencyBinCount(): number;
  40409. /**
  40410. * Gets the current frequency data as a byte array
  40411. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40412. * @returns a Uint8Array
  40413. */
  40414. getByteFrequencyData(): Uint8Array;
  40415. /**
  40416. * Gets the current waveform as a byte array
  40417. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40418. * @returns a Uint8Array
  40419. */
  40420. getByteTimeDomainData(): Uint8Array;
  40421. /**
  40422. * Gets the current frequency data as a float array
  40423. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40424. * @returns a Float32Array
  40425. */
  40426. getFloatFrequencyData(): Float32Array;
  40427. /**
  40428. * Renders the debug canvas
  40429. */
  40430. drawDebugCanvas(): void;
  40431. /**
  40432. * Stops rendering the debug canvas and removes it
  40433. */
  40434. stopDebugCanvas(): void;
  40435. /**
  40436. * Connects two audio nodes
  40437. * @param inputAudioNode defines first node to connect
  40438. * @param outputAudioNode defines second node to connect
  40439. */
  40440. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40441. /**
  40442. * Releases all associated resources
  40443. */
  40444. dispose(): void;
  40445. }
  40446. }
  40447. declare module BABYLON {
  40448. /**
  40449. * This represents an audio engine and it is responsible
  40450. * to play, synchronize and analyse sounds throughout the application.
  40451. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40452. */
  40453. export interface IAudioEngine extends IDisposable {
  40454. /**
  40455. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40456. */
  40457. readonly canUseWebAudio: boolean;
  40458. /**
  40459. * Gets the current AudioContext if available.
  40460. */
  40461. readonly audioContext: Nullable<AudioContext>;
  40462. /**
  40463. * The master gain node defines the global audio volume of your audio engine.
  40464. */
  40465. readonly masterGain: GainNode;
  40466. /**
  40467. * Gets whether or not mp3 are supported by your browser.
  40468. */
  40469. readonly isMP3supported: boolean;
  40470. /**
  40471. * Gets whether or not ogg are supported by your browser.
  40472. */
  40473. readonly isOGGsupported: boolean;
  40474. /**
  40475. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40476. * @ignoreNaming
  40477. */
  40478. WarnedWebAudioUnsupported: boolean;
  40479. /**
  40480. * Defines if the audio engine relies on a custom unlocked button.
  40481. * In this case, the embedded button will not be displayed.
  40482. */
  40483. useCustomUnlockedButton: boolean;
  40484. /**
  40485. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40486. */
  40487. readonly unlocked: boolean;
  40488. /**
  40489. * Event raised when audio has been unlocked on the browser.
  40490. */
  40491. onAudioUnlockedObservable: Observable<IAudioEngine>;
  40492. /**
  40493. * Event raised when audio has been locked on the browser.
  40494. */
  40495. onAudioLockedObservable: Observable<IAudioEngine>;
  40496. /**
  40497. * Flags the audio engine in Locked state.
  40498. * This happens due to new browser policies preventing audio to autoplay.
  40499. */
  40500. lock(): void;
  40501. /**
  40502. * Unlocks the audio engine once a user action has been done on the dom.
  40503. * This is helpful to resume play once browser policies have been satisfied.
  40504. */
  40505. unlock(): void;
  40506. /**
  40507. * Gets the global volume sets on the master gain.
  40508. * @returns the global volume if set or -1 otherwise
  40509. */
  40510. getGlobalVolume(): number;
  40511. /**
  40512. * Sets the global volume of your experience (sets on the master gain).
  40513. * @param newVolume Defines the new global volume of the application
  40514. */
  40515. setGlobalVolume(newVolume: number): void;
  40516. /**
  40517. * Connect the audio engine to an audio analyser allowing some amazing
  40518. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40519. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40520. * @param analyser The analyser to connect to the engine
  40521. */
  40522. connectToAnalyser(analyser: Analyser): void;
  40523. }
  40524. }
  40525. declare module BABYLON {
  40526. /**
  40527. * Defines the interface used by display changed events
  40528. */
  40529. export interface IDisplayChangedEventArgs {
  40530. /** Gets the vrDisplay object (if any) */
  40531. vrDisplay: Nullable<any>;
  40532. /** Gets a boolean indicating if webVR is supported */
  40533. vrSupported: boolean;
  40534. }
  40535. /**
  40536. * Defines the interface used by objects containing a viewport (like a camera)
  40537. */
  40538. interface IViewportOwnerLike {
  40539. /**
  40540. * Gets or sets the viewport
  40541. */
  40542. viewport: IViewportLike;
  40543. }
  40544. /**
  40545. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40546. */
  40547. export class Engine extends ThinEngine {
  40548. /** Defines that alpha blending is disabled */
  40549. static readonly ALPHA_DISABLE: number;
  40550. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40551. static readonly ALPHA_ADD: number;
  40552. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40553. static readonly ALPHA_COMBINE: number;
  40554. /** Defines that alpha blending to DEST - SRC * DEST */
  40555. static readonly ALPHA_SUBTRACT: number;
  40556. /** Defines that alpha blending to SRC * DEST */
  40557. static readonly ALPHA_MULTIPLY: number;
  40558. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40559. static readonly ALPHA_MAXIMIZED: number;
  40560. /** Defines that alpha blending to SRC + DEST */
  40561. static readonly ALPHA_ONEONE: number;
  40562. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40563. static readonly ALPHA_PREMULTIPLIED: number;
  40564. /**
  40565. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40566. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40567. */
  40568. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40569. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40570. static readonly ALPHA_INTERPOLATE: number;
  40571. /**
  40572. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40573. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40574. */
  40575. static readonly ALPHA_SCREENMODE: number;
  40576. /** Defines that the ressource is not delayed*/
  40577. static readonly DELAYLOADSTATE_NONE: number;
  40578. /** Defines that the ressource was successfully delay loaded */
  40579. static readonly DELAYLOADSTATE_LOADED: number;
  40580. /** Defines that the ressource is currently delay loading */
  40581. static readonly DELAYLOADSTATE_LOADING: number;
  40582. /** Defines that the ressource is delayed and has not started loading */
  40583. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40584. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40585. static readonly NEVER: number;
  40586. /** 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 */
  40587. static readonly ALWAYS: number;
  40588. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40589. static readonly LESS: number;
  40590. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40591. static readonly EQUAL: number;
  40592. /** 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 */
  40593. static readonly LEQUAL: number;
  40594. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40595. static readonly GREATER: number;
  40596. /** 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 */
  40597. static readonly GEQUAL: number;
  40598. /** 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 */
  40599. static readonly NOTEQUAL: number;
  40600. /** Passed to stencilOperation to specify that stencil value must be kept */
  40601. static readonly KEEP: number;
  40602. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40603. static readonly REPLACE: number;
  40604. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40605. static readonly INCR: number;
  40606. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40607. static readonly DECR: number;
  40608. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40609. static readonly INVERT: number;
  40610. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40611. static readonly INCR_WRAP: number;
  40612. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40613. static readonly DECR_WRAP: number;
  40614. /** Texture is not repeating outside of 0..1 UVs */
  40615. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40616. /** Texture is repeating outside of 0..1 UVs */
  40617. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40618. /** Texture is repeating and mirrored */
  40619. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40620. /** ALPHA */
  40621. static readonly TEXTUREFORMAT_ALPHA: number;
  40622. /** LUMINANCE */
  40623. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40624. /** LUMINANCE_ALPHA */
  40625. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40626. /** RGB */
  40627. static readonly TEXTUREFORMAT_RGB: number;
  40628. /** RGBA */
  40629. static readonly TEXTUREFORMAT_RGBA: number;
  40630. /** RED */
  40631. static readonly TEXTUREFORMAT_RED: number;
  40632. /** RED (2nd reference) */
  40633. static readonly TEXTUREFORMAT_R: number;
  40634. /** RG */
  40635. static readonly TEXTUREFORMAT_RG: number;
  40636. /** RED_INTEGER */
  40637. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40638. /** RED_INTEGER (2nd reference) */
  40639. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40640. /** RG_INTEGER */
  40641. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40642. /** RGB_INTEGER */
  40643. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40644. /** RGBA_INTEGER */
  40645. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40646. /** UNSIGNED_BYTE */
  40647. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40648. /** UNSIGNED_BYTE (2nd reference) */
  40649. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40650. /** FLOAT */
  40651. static readonly TEXTURETYPE_FLOAT: number;
  40652. /** HALF_FLOAT */
  40653. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40654. /** BYTE */
  40655. static readonly TEXTURETYPE_BYTE: number;
  40656. /** SHORT */
  40657. static readonly TEXTURETYPE_SHORT: number;
  40658. /** UNSIGNED_SHORT */
  40659. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40660. /** INT */
  40661. static readonly TEXTURETYPE_INT: number;
  40662. /** UNSIGNED_INT */
  40663. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40664. /** UNSIGNED_SHORT_4_4_4_4 */
  40665. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40666. /** UNSIGNED_SHORT_5_5_5_1 */
  40667. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40668. /** UNSIGNED_SHORT_5_6_5 */
  40669. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40670. /** UNSIGNED_INT_2_10_10_10_REV */
  40671. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40672. /** UNSIGNED_INT_24_8 */
  40673. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40674. /** UNSIGNED_INT_10F_11F_11F_REV */
  40675. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40676. /** UNSIGNED_INT_5_9_9_9_REV */
  40677. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40678. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40679. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40680. /** nearest is mag = nearest and min = nearest and mip = linear */
  40681. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40682. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40683. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40684. /** Trilinear is mag = linear and min = linear and mip = linear */
  40685. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40686. /** nearest is mag = nearest and min = nearest and mip = linear */
  40687. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40688. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40689. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40690. /** Trilinear is mag = linear and min = linear and mip = linear */
  40691. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40692. /** mag = nearest and min = nearest and mip = nearest */
  40693. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40694. /** mag = nearest and min = linear and mip = nearest */
  40695. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40696. /** mag = nearest and min = linear and mip = linear */
  40697. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40698. /** mag = nearest and min = linear and mip = none */
  40699. static readonly TEXTURE_NEAREST_LINEAR: number;
  40700. /** mag = nearest and min = nearest and mip = none */
  40701. static readonly TEXTURE_NEAREST_NEAREST: number;
  40702. /** mag = linear and min = nearest and mip = nearest */
  40703. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40704. /** mag = linear and min = nearest and mip = linear */
  40705. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  40706. /** mag = linear and min = linear and mip = none */
  40707. static readonly TEXTURE_LINEAR_LINEAR: number;
  40708. /** mag = linear and min = nearest and mip = none */
  40709. static readonly TEXTURE_LINEAR_NEAREST: number;
  40710. /** Explicit coordinates mode */
  40711. static readonly TEXTURE_EXPLICIT_MODE: number;
  40712. /** Spherical coordinates mode */
  40713. static readonly TEXTURE_SPHERICAL_MODE: number;
  40714. /** Planar coordinates mode */
  40715. static readonly TEXTURE_PLANAR_MODE: number;
  40716. /** Cubic coordinates mode */
  40717. static readonly TEXTURE_CUBIC_MODE: number;
  40718. /** Projection coordinates mode */
  40719. static readonly TEXTURE_PROJECTION_MODE: number;
  40720. /** Skybox coordinates mode */
  40721. static readonly TEXTURE_SKYBOX_MODE: number;
  40722. /** Inverse Cubic coordinates mode */
  40723. static readonly TEXTURE_INVCUBIC_MODE: number;
  40724. /** Equirectangular coordinates mode */
  40725. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  40726. /** Equirectangular Fixed coordinates mode */
  40727. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  40728. /** Equirectangular Fixed Mirrored coordinates mode */
  40729. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  40730. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  40731. static readonly SCALEMODE_FLOOR: number;
  40732. /** Defines that texture rescaling will look for the nearest power of 2 size */
  40733. static readonly SCALEMODE_NEAREST: number;
  40734. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  40735. static readonly SCALEMODE_CEILING: number;
  40736. /**
  40737. * Returns the current npm package of the sdk
  40738. */
  40739. static get NpmPackage(): string;
  40740. /**
  40741. * Returns the current version of the framework
  40742. */
  40743. static get Version(): string;
  40744. /** Gets the list of created engines */
  40745. static get Instances(): Engine[];
  40746. /**
  40747. * Gets the latest created engine
  40748. */
  40749. static get LastCreatedEngine(): Nullable<Engine>;
  40750. /**
  40751. * Gets the latest created scene
  40752. */
  40753. static get LastCreatedScene(): Nullable<Scene>;
  40754. /**
  40755. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  40756. * @param flag defines which part of the materials must be marked as dirty
  40757. * @param predicate defines a predicate used to filter which materials should be affected
  40758. */
  40759. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40760. /**
  40761. * Method called to create the default loading screen.
  40762. * This can be overriden in your own app.
  40763. * @param canvas The rendering canvas element
  40764. * @returns The loading screen
  40765. */
  40766. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  40767. /**
  40768. * Method called to create the default rescale post process on each engine.
  40769. */
  40770. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  40771. /**
  40772. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  40773. **/
  40774. enableOfflineSupport: boolean;
  40775. /**
  40776. * 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)
  40777. **/
  40778. disableManifestCheck: boolean;
  40779. /**
  40780. * Gets the list of created scenes
  40781. */
  40782. scenes: Scene[];
  40783. /**
  40784. * Event raised when a new scene is created
  40785. */
  40786. onNewSceneAddedObservable: Observable<Scene>;
  40787. /**
  40788. * Gets the list of created postprocesses
  40789. */
  40790. postProcesses: PostProcess[];
  40791. /**
  40792. * Gets a boolean indicating if the pointer is currently locked
  40793. */
  40794. isPointerLock: boolean;
  40795. /**
  40796. * Observable event triggered each time the rendering canvas is resized
  40797. */
  40798. onResizeObservable: Observable<Engine>;
  40799. /**
  40800. * Observable event triggered each time the canvas loses focus
  40801. */
  40802. onCanvasBlurObservable: Observable<Engine>;
  40803. /**
  40804. * Observable event triggered each time the canvas gains focus
  40805. */
  40806. onCanvasFocusObservable: Observable<Engine>;
  40807. /**
  40808. * Observable event triggered each time the canvas receives pointerout event
  40809. */
  40810. onCanvasPointerOutObservable: Observable<PointerEvent>;
  40811. /**
  40812. * Observable raised when the engine begins a new frame
  40813. */
  40814. onBeginFrameObservable: Observable<Engine>;
  40815. /**
  40816. * If set, will be used to request the next animation frame for the render loop
  40817. */
  40818. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  40819. /**
  40820. * Observable raised when the engine ends the current frame
  40821. */
  40822. onEndFrameObservable: Observable<Engine>;
  40823. /**
  40824. * Observable raised when the engine is about to compile a shader
  40825. */
  40826. onBeforeShaderCompilationObservable: Observable<Engine>;
  40827. /**
  40828. * Observable raised when the engine has jsut compiled a shader
  40829. */
  40830. onAfterShaderCompilationObservable: Observable<Engine>;
  40831. /**
  40832. * Gets the audio engine
  40833. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40834. * @ignorenaming
  40835. */
  40836. static audioEngine: IAudioEngine;
  40837. /**
  40838. * Default AudioEngine factory responsible of creating the Audio Engine.
  40839. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  40840. */
  40841. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  40842. /**
  40843. * Default offline support factory responsible of creating a tool used to store data locally.
  40844. * By default, this will create a Database object if the workload has been embedded.
  40845. */
  40846. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  40847. private _loadingScreen;
  40848. private _pointerLockRequested;
  40849. private _rescalePostProcess;
  40850. private _deterministicLockstep;
  40851. private _lockstepMaxSteps;
  40852. private _timeStep;
  40853. protected get _supportsHardwareTextureRescaling(): boolean;
  40854. private _fps;
  40855. private _deltaTime;
  40856. /** @hidden */
  40857. _drawCalls: PerfCounter;
  40858. /** 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 */
  40859. canvasTabIndex: number;
  40860. /**
  40861. * Turn this value on if you want to pause FPS computation when in background
  40862. */
  40863. disablePerformanceMonitorInBackground: boolean;
  40864. private _performanceMonitor;
  40865. /**
  40866. * Gets the performance monitor attached to this engine
  40867. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40868. */
  40869. get performanceMonitor(): PerformanceMonitor;
  40870. private _onFocus;
  40871. private _onBlur;
  40872. private _onCanvasPointerOut;
  40873. private _onCanvasBlur;
  40874. private _onCanvasFocus;
  40875. private _onFullscreenChange;
  40876. private _onPointerLockChange;
  40877. /**
  40878. * Gets the HTML element used to attach event listeners
  40879. * @returns a HTML element
  40880. */
  40881. getInputElement(): Nullable<HTMLElement>;
  40882. /**
  40883. * Creates a new engine
  40884. * @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
  40885. * @param antialias defines enable antialiasing (default: false)
  40886. * @param options defines further options to be sent to the getContext() function
  40887. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40888. */
  40889. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40890. /**
  40891. * Gets current aspect ratio
  40892. * @param viewportOwner defines the camera to use to get the aspect ratio
  40893. * @param useScreen defines if screen size must be used (or the current render target if any)
  40894. * @returns a number defining the aspect ratio
  40895. */
  40896. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  40897. /**
  40898. * Gets current screen aspect ratio
  40899. * @returns a number defining the aspect ratio
  40900. */
  40901. getScreenAspectRatio(): number;
  40902. /**
  40903. * Gets the client rect of the HTML canvas attached with the current webGL context
  40904. * @returns a client rectanglee
  40905. */
  40906. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  40907. /**
  40908. * Gets the client rect of the HTML element used for events
  40909. * @returns a client rectanglee
  40910. */
  40911. getInputElementClientRect(): Nullable<ClientRect>;
  40912. /**
  40913. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  40914. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40915. * @returns true if engine is in deterministic lock step mode
  40916. */
  40917. isDeterministicLockStep(): boolean;
  40918. /**
  40919. * Gets the max steps when engine is running in deterministic lock step
  40920. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40921. * @returns the max steps
  40922. */
  40923. getLockstepMaxSteps(): number;
  40924. /**
  40925. * Returns the time in ms between steps when using deterministic lock step.
  40926. * @returns time step in (ms)
  40927. */
  40928. getTimeStep(): number;
  40929. /**
  40930. * Force the mipmap generation for the given render target texture
  40931. * @param texture defines the render target texture to use
  40932. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  40933. */
  40934. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  40935. /** States */
  40936. /**
  40937. * Set various states to the webGL context
  40938. * @param culling defines backface culling state
  40939. * @param zOffset defines the value to apply to zOffset (0 by default)
  40940. * @param force defines if states must be applied even if cache is up to date
  40941. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  40942. */
  40943. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40944. /**
  40945. * Set the z offset to apply to current rendering
  40946. * @param value defines the offset to apply
  40947. */
  40948. setZOffset(value: number): void;
  40949. /**
  40950. * Gets the current value of the zOffset
  40951. * @returns the current zOffset state
  40952. */
  40953. getZOffset(): number;
  40954. /**
  40955. * Enable or disable depth buffering
  40956. * @param enable defines the state to set
  40957. */
  40958. setDepthBuffer(enable: boolean): void;
  40959. /**
  40960. * Gets a boolean indicating if depth writing is enabled
  40961. * @returns the current depth writing state
  40962. */
  40963. getDepthWrite(): boolean;
  40964. /**
  40965. * Enable or disable depth writing
  40966. * @param enable defines the state to set
  40967. */
  40968. setDepthWrite(enable: boolean): void;
  40969. /**
  40970. * Gets a boolean indicating if stencil buffer is enabled
  40971. * @returns the current stencil buffer state
  40972. */
  40973. getStencilBuffer(): boolean;
  40974. /**
  40975. * Enable or disable the stencil buffer
  40976. * @param enable defines if the stencil buffer must be enabled or disabled
  40977. */
  40978. setStencilBuffer(enable: boolean): void;
  40979. /**
  40980. * Gets the current stencil mask
  40981. * @returns a number defining the new stencil mask to use
  40982. */
  40983. getStencilMask(): number;
  40984. /**
  40985. * Sets the current stencil mask
  40986. * @param mask defines the new stencil mask to use
  40987. */
  40988. setStencilMask(mask: number): void;
  40989. /**
  40990. * Gets the current stencil function
  40991. * @returns a number defining the stencil function to use
  40992. */
  40993. getStencilFunction(): number;
  40994. /**
  40995. * Gets the current stencil reference value
  40996. * @returns a number defining the stencil reference value to use
  40997. */
  40998. getStencilFunctionReference(): number;
  40999. /**
  41000. * Gets the current stencil mask
  41001. * @returns a number defining the stencil mask to use
  41002. */
  41003. getStencilFunctionMask(): number;
  41004. /**
  41005. * Sets the current stencil function
  41006. * @param stencilFunc defines the new stencil function to use
  41007. */
  41008. setStencilFunction(stencilFunc: number): void;
  41009. /**
  41010. * Sets the current stencil reference
  41011. * @param reference defines the new stencil reference to use
  41012. */
  41013. setStencilFunctionReference(reference: number): void;
  41014. /**
  41015. * Sets the current stencil mask
  41016. * @param mask defines the new stencil mask to use
  41017. */
  41018. setStencilFunctionMask(mask: number): void;
  41019. /**
  41020. * Gets the current stencil operation when stencil fails
  41021. * @returns a number defining stencil operation to use when stencil fails
  41022. */
  41023. getStencilOperationFail(): number;
  41024. /**
  41025. * Gets the current stencil operation when depth fails
  41026. * @returns a number defining stencil operation to use when depth fails
  41027. */
  41028. getStencilOperationDepthFail(): number;
  41029. /**
  41030. * Gets the current stencil operation when stencil passes
  41031. * @returns a number defining stencil operation to use when stencil passes
  41032. */
  41033. getStencilOperationPass(): number;
  41034. /**
  41035. * Sets the stencil operation to use when stencil fails
  41036. * @param operation defines the stencil operation to use when stencil fails
  41037. */
  41038. setStencilOperationFail(operation: number): void;
  41039. /**
  41040. * Sets the stencil operation to use when depth fails
  41041. * @param operation defines the stencil operation to use when depth fails
  41042. */
  41043. setStencilOperationDepthFail(operation: number): void;
  41044. /**
  41045. * Sets the stencil operation to use when stencil passes
  41046. * @param operation defines the stencil operation to use when stencil passes
  41047. */
  41048. setStencilOperationPass(operation: number): void;
  41049. /**
  41050. * Sets a boolean indicating if the dithering state is enabled or disabled
  41051. * @param value defines the dithering state
  41052. */
  41053. setDitheringState(value: boolean): void;
  41054. /**
  41055. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41056. * @param value defines the rasterizer state
  41057. */
  41058. setRasterizerState(value: boolean): void;
  41059. /**
  41060. * Gets the current depth function
  41061. * @returns a number defining the depth function
  41062. */
  41063. getDepthFunction(): Nullable<number>;
  41064. /**
  41065. * Sets the current depth function
  41066. * @param depthFunc defines the function to use
  41067. */
  41068. setDepthFunction(depthFunc: number): void;
  41069. /**
  41070. * Sets the current depth function to GREATER
  41071. */
  41072. setDepthFunctionToGreater(): void;
  41073. /**
  41074. * Sets the current depth function to GEQUAL
  41075. */
  41076. setDepthFunctionToGreaterOrEqual(): void;
  41077. /**
  41078. * Sets the current depth function to LESS
  41079. */
  41080. setDepthFunctionToLess(): void;
  41081. /**
  41082. * Sets the current depth function to LEQUAL
  41083. */
  41084. setDepthFunctionToLessOrEqual(): void;
  41085. private _cachedStencilBuffer;
  41086. private _cachedStencilFunction;
  41087. private _cachedStencilMask;
  41088. private _cachedStencilOperationPass;
  41089. private _cachedStencilOperationFail;
  41090. private _cachedStencilOperationDepthFail;
  41091. private _cachedStencilReference;
  41092. /**
  41093. * Caches the the state of the stencil buffer
  41094. */
  41095. cacheStencilState(): void;
  41096. /**
  41097. * Restores the state of the stencil buffer
  41098. */
  41099. restoreStencilState(): void;
  41100. /**
  41101. * Directly set the WebGL Viewport
  41102. * @param x defines the x coordinate of the viewport (in screen space)
  41103. * @param y defines the y coordinate of the viewport (in screen space)
  41104. * @param width defines the width of the viewport (in screen space)
  41105. * @param height defines the height of the viewport (in screen space)
  41106. * @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
  41107. */
  41108. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41109. /**
  41110. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41111. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41112. * @param y defines the y-coordinate of the corner of the clear rectangle
  41113. * @param width defines the width of the clear rectangle
  41114. * @param height defines the height of the clear rectangle
  41115. * @param clearColor defines the clear color
  41116. */
  41117. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41118. /**
  41119. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41120. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41121. * @param y defines the y-coordinate of the corner of the clear rectangle
  41122. * @param width defines the width of the clear rectangle
  41123. * @param height defines the height of the clear rectangle
  41124. */
  41125. enableScissor(x: number, y: number, width: number, height: number): void;
  41126. /**
  41127. * Disable previously set scissor test rectangle
  41128. */
  41129. disableScissor(): void;
  41130. protected _reportDrawCall(): void;
  41131. /**
  41132. * Initializes a webVR display and starts listening to display change events
  41133. * The onVRDisplayChangedObservable will be notified upon these changes
  41134. * @returns The onVRDisplayChangedObservable
  41135. */
  41136. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41137. /** @hidden */
  41138. _prepareVRComponent(): void;
  41139. /** @hidden */
  41140. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41141. /** @hidden */
  41142. _submitVRFrame(): void;
  41143. /**
  41144. * Call this function to leave webVR mode
  41145. * Will do nothing if webVR is not supported or if there is no webVR device
  41146. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41147. */
  41148. disableVR(): void;
  41149. /**
  41150. * Gets a boolean indicating that the system is in VR mode and is presenting
  41151. * @returns true if VR mode is engaged
  41152. */
  41153. isVRPresenting(): boolean;
  41154. /** @hidden */
  41155. _requestVRFrame(): void;
  41156. /** @hidden */
  41157. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41158. /**
  41159. * Gets the source code of the vertex shader associated with a specific webGL program
  41160. * @param program defines the program to use
  41161. * @returns a string containing the source code of the vertex shader associated with the program
  41162. */
  41163. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41164. /**
  41165. * Gets the source code of the fragment shader associated with a specific webGL program
  41166. * @param program defines the program to use
  41167. * @returns a string containing the source code of the fragment shader associated with the program
  41168. */
  41169. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41170. /**
  41171. * Sets a depth stencil texture from a render target to the according uniform.
  41172. * @param channel The texture channel
  41173. * @param uniform The uniform to set
  41174. * @param texture The render target texture containing the depth stencil texture to apply
  41175. */
  41176. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41177. /**
  41178. * Sets a texture to the webGL context from a postprocess
  41179. * @param channel defines the channel to use
  41180. * @param postProcess defines the source postprocess
  41181. */
  41182. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41183. /**
  41184. * Binds the output of the passed in post process to the texture channel specified
  41185. * @param channel The channel the texture should be bound to
  41186. * @param postProcess The post process which's output should be bound
  41187. */
  41188. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41189. protected _rebuildBuffers(): void;
  41190. /** @hidden */
  41191. _renderFrame(): void;
  41192. _renderLoop(): void;
  41193. /** @hidden */
  41194. _renderViews(): boolean;
  41195. /**
  41196. * Toggle full screen mode
  41197. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41198. */
  41199. switchFullscreen(requestPointerLock: boolean): void;
  41200. /**
  41201. * Enters full screen mode
  41202. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41203. */
  41204. enterFullscreen(requestPointerLock: boolean): void;
  41205. /**
  41206. * Exits full screen mode
  41207. */
  41208. exitFullscreen(): void;
  41209. /**
  41210. * Enters Pointerlock mode
  41211. */
  41212. enterPointerlock(): void;
  41213. /**
  41214. * Exits Pointerlock mode
  41215. */
  41216. exitPointerlock(): void;
  41217. /**
  41218. * Begin a new frame
  41219. */
  41220. beginFrame(): void;
  41221. /**
  41222. * Enf the current frame
  41223. */
  41224. endFrame(): void;
  41225. resize(): void;
  41226. /**
  41227. * Force a specific size of the canvas
  41228. * @param width defines the new canvas' width
  41229. * @param height defines the new canvas' height
  41230. * @returns true if the size was changed
  41231. */
  41232. setSize(width: number, height: number): boolean;
  41233. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41234. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41235. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41236. _releaseTexture(texture: InternalTexture): void;
  41237. /**
  41238. * @hidden
  41239. * Rescales a texture
  41240. * @param source input texutre
  41241. * @param destination destination texture
  41242. * @param scene scene to use to render the resize
  41243. * @param internalFormat format to use when resizing
  41244. * @param onComplete callback to be called when resize has completed
  41245. */
  41246. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41247. /**
  41248. * Gets the current framerate
  41249. * @returns a number representing the framerate
  41250. */
  41251. getFps(): number;
  41252. /**
  41253. * Gets the time spent between current and previous frame
  41254. * @returns a number representing the delta time in ms
  41255. */
  41256. getDeltaTime(): number;
  41257. private _measureFps;
  41258. /** @hidden */
  41259. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41260. /**
  41261. * Updates the sample count of a render target texture
  41262. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41263. * @param texture defines the texture to update
  41264. * @param samples defines the sample count to set
  41265. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41266. */
  41267. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41268. /**
  41269. * Updates a depth texture Comparison Mode and Function.
  41270. * If the comparison Function is equal to 0, the mode will be set to none.
  41271. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41272. * @param texture The texture to set the comparison function for
  41273. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41274. */
  41275. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41276. /**
  41277. * Creates a webGL buffer to use with instanciation
  41278. * @param capacity defines the size of the buffer
  41279. * @returns the webGL buffer
  41280. */
  41281. createInstancesBuffer(capacity: number): DataBuffer;
  41282. /**
  41283. * Delete a webGL buffer used with instanciation
  41284. * @param buffer defines the webGL buffer to delete
  41285. */
  41286. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41287. private _clientWaitAsync;
  41288. /** @hidden */
  41289. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41290. dispose(): void;
  41291. private _disableTouchAction;
  41292. /**
  41293. * Display the loading screen
  41294. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41295. */
  41296. displayLoadingUI(): void;
  41297. /**
  41298. * Hide the loading screen
  41299. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41300. */
  41301. hideLoadingUI(): void;
  41302. /**
  41303. * Gets the current loading screen object
  41304. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41305. */
  41306. get loadingScreen(): ILoadingScreen;
  41307. /**
  41308. * Sets the current loading screen object
  41309. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41310. */
  41311. set loadingScreen(loadingScreen: ILoadingScreen);
  41312. /**
  41313. * Sets the current loading screen text
  41314. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41315. */
  41316. set loadingUIText(text: string);
  41317. /**
  41318. * Sets the current loading screen background color
  41319. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41320. */
  41321. set loadingUIBackgroundColor(color: string);
  41322. /** Pointerlock and fullscreen */
  41323. /**
  41324. * Ask the browser to promote the current element to pointerlock mode
  41325. * @param element defines the DOM element to promote
  41326. */
  41327. static _RequestPointerlock(element: HTMLElement): void;
  41328. /**
  41329. * Asks the browser to exit pointerlock mode
  41330. */
  41331. static _ExitPointerlock(): void;
  41332. /**
  41333. * Ask the browser to promote the current element to fullscreen rendering mode
  41334. * @param element defines the DOM element to promote
  41335. */
  41336. static _RequestFullscreen(element: HTMLElement): void;
  41337. /**
  41338. * Asks the browser to exit fullscreen mode
  41339. */
  41340. static _ExitFullscreen(): void;
  41341. }
  41342. }
  41343. declare module BABYLON {
  41344. /**
  41345. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41346. * during the life time of the application.
  41347. */
  41348. export class EngineStore {
  41349. /** Gets the list of created engines */
  41350. static Instances: Engine[];
  41351. /** @hidden */
  41352. static _LastCreatedScene: Nullable<Scene>;
  41353. /**
  41354. * Gets the latest created engine
  41355. */
  41356. static get LastCreatedEngine(): Nullable<Engine>;
  41357. /**
  41358. * Gets the latest created scene
  41359. */
  41360. static get LastCreatedScene(): Nullable<Scene>;
  41361. /**
  41362. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41363. * @ignorenaming
  41364. */
  41365. static UseFallbackTexture: boolean;
  41366. /**
  41367. * Texture content used if a texture cannot loaded
  41368. * @ignorenaming
  41369. */
  41370. static FallbackTexture: string;
  41371. }
  41372. }
  41373. declare module BABYLON {
  41374. /**
  41375. * Helper class that provides a small promise polyfill
  41376. */
  41377. export class PromisePolyfill {
  41378. /**
  41379. * Static function used to check if the polyfill is required
  41380. * If this is the case then the function will inject the polyfill to window.Promise
  41381. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41382. */
  41383. static Apply(force?: boolean): void;
  41384. }
  41385. }
  41386. declare module BABYLON {
  41387. /**
  41388. * Interface for screenshot methods with describe argument called `size` as object with options
  41389. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41390. */
  41391. export interface IScreenshotSize {
  41392. /**
  41393. * number in pixels for canvas height
  41394. */
  41395. height?: number;
  41396. /**
  41397. * multiplier allowing render at a higher or lower resolution
  41398. * If value is defined then height and width will be ignored and taken from camera
  41399. */
  41400. precision?: number;
  41401. /**
  41402. * number in pixels for canvas width
  41403. */
  41404. width?: number;
  41405. }
  41406. }
  41407. declare module BABYLON {
  41408. interface IColor4Like {
  41409. r: float;
  41410. g: float;
  41411. b: float;
  41412. a: float;
  41413. }
  41414. /**
  41415. * Class containing a set of static utilities functions
  41416. */
  41417. export class Tools {
  41418. /**
  41419. * Gets or sets the base URL to use to load assets
  41420. */
  41421. static get BaseUrl(): string;
  41422. static set BaseUrl(value: string);
  41423. /**
  41424. * Enable/Disable Custom HTTP Request Headers globally.
  41425. * default = false
  41426. * @see CustomRequestHeaders
  41427. */
  41428. static UseCustomRequestHeaders: boolean;
  41429. /**
  41430. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41431. * i.e. when loading files, where the server/service expects an Authorization header
  41432. */
  41433. static CustomRequestHeaders: {
  41434. [key: string]: string;
  41435. };
  41436. /**
  41437. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41438. */
  41439. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41440. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41441. /**
  41442. * Default behaviour for cors in the application.
  41443. * It can be a string if the expected behavior is identical in the entire app.
  41444. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41445. */
  41446. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41447. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41448. /**
  41449. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41450. * @ignorenaming
  41451. */
  41452. static get UseFallbackTexture(): boolean;
  41453. static set UseFallbackTexture(value: boolean);
  41454. /**
  41455. * Use this object to register external classes like custom textures or material
  41456. * to allow the laoders to instantiate them
  41457. */
  41458. static get RegisteredExternalClasses(): {
  41459. [key: string]: Object;
  41460. };
  41461. static set RegisteredExternalClasses(classes: {
  41462. [key: string]: Object;
  41463. });
  41464. /**
  41465. * Texture content used if a texture cannot loaded
  41466. * @ignorenaming
  41467. */
  41468. static get fallbackTexture(): string;
  41469. static set fallbackTexture(value: string);
  41470. /**
  41471. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41472. * @param u defines the coordinate on X axis
  41473. * @param v defines the coordinate on Y axis
  41474. * @param width defines the width of the source data
  41475. * @param height defines the height of the source data
  41476. * @param pixels defines the source byte array
  41477. * @param color defines the output color
  41478. */
  41479. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41480. /**
  41481. * Interpolates between a and b via alpha
  41482. * @param a The lower value (returned when alpha = 0)
  41483. * @param b The upper value (returned when alpha = 1)
  41484. * @param alpha The interpolation-factor
  41485. * @return The mixed value
  41486. */
  41487. static Mix(a: number, b: number, alpha: number): number;
  41488. /**
  41489. * Tries to instantiate a new object from a given class name
  41490. * @param className defines the class name to instantiate
  41491. * @returns the new object or null if the system was not able to do the instantiation
  41492. */
  41493. static Instantiate(className: string): any;
  41494. /**
  41495. * Provides a slice function that will work even on IE
  41496. * @param data defines the array to slice
  41497. * @param start defines the start of the data (optional)
  41498. * @param end defines the end of the data (optional)
  41499. * @returns the new sliced array
  41500. */
  41501. static Slice<T>(data: T, start?: number, end?: number): T;
  41502. /**
  41503. * Provides a slice function that will work even on IE
  41504. * The difference between this and Slice is that this will force-convert to array
  41505. * @param data defines the array to slice
  41506. * @param start defines the start of the data (optional)
  41507. * @param end defines the end of the data (optional)
  41508. * @returns the new sliced array
  41509. */
  41510. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41511. /**
  41512. * Polyfill for setImmediate
  41513. * @param action defines the action to execute after the current execution block
  41514. */
  41515. static SetImmediate(action: () => void): void;
  41516. /**
  41517. * Function indicating if a number is an exponent of 2
  41518. * @param value defines the value to test
  41519. * @returns true if the value is an exponent of 2
  41520. */
  41521. static IsExponentOfTwo(value: number): boolean;
  41522. private static _tmpFloatArray;
  41523. /**
  41524. * Returns the nearest 32-bit single precision float representation of a Number
  41525. * @param value A Number. If the parameter is of a different type, it will get converted
  41526. * to a number or to NaN if it cannot be converted
  41527. * @returns number
  41528. */
  41529. static FloatRound(value: number): number;
  41530. /**
  41531. * Extracts the filename from a path
  41532. * @param path defines the path to use
  41533. * @returns the filename
  41534. */
  41535. static GetFilename(path: string): string;
  41536. /**
  41537. * Extracts the "folder" part of a path (everything before the filename).
  41538. * @param uri The URI to extract the info from
  41539. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41540. * @returns The "folder" part of the path
  41541. */
  41542. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41543. /**
  41544. * Extracts text content from a DOM element hierarchy
  41545. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41546. */
  41547. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41548. /**
  41549. * Convert an angle in radians to degrees
  41550. * @param angle defines the angle to convert
  41551. * @returns the angle in degrees
  41552. */
  41553. static ToDegrees(angle: number): number;
  41554. /**
  41555. * Convert an angle in degrees to radians
  41556. * @param angle defines the angle to convert
  41557. * @returns the angle in radians
  41558. */
  41559. static ToRadians(angle: number): number;
  41560. /**
  41561. * Returns an array if obj is not an array
  41562. * @param obj defines the object to evaluate as an array
  41563. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41564. * @returns either obj directly if obj is an array or a new array containing obj
  41565. */
  41566. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41567. /**
  41568. * Gets the pointer prefix to use
  41569. * @param engine defines the engine we are finding the prefix for
  41570. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41571. */
  41572. static GetPointerPrefix(engine: Engine): string;
  41573. /**
  41574. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41575. * @param url define the url we are trying
  41576. * @param element define the dom element where to configure the cors policy
  41577. */
  41578. static SetCorsBehavior(url: string | string[], element: {
  41579. crossOrigin: string | null;
  41580. }): void;
  41581. /**
  41582. * Removes unwanted characters from an url
  41583. * @param url defines the url to clean
  41584. * @returns the cleaned url
  41585. */
  41586. static CleanUrl(url: string): string;
  41587. /**
  41588. * Gets or sets a function used to pre-process url before using them to load assets
  41589. */
  41590. static get PreprocessUrl(): (url: string) => string;
  41591. static set PreprocessUrl(processor: (url: string) => string);
  41592. /**
  41593. * Loads an image as an HTMLImageElement.
  41594. * @param input url string, ArrayBuffer, or Blob to load
  41595. * @param onLoad callback called when the image successfully loads
  41596. * @param onError callback called when the image fails to load
  41597. * @param offlineProvider offline provider for caching
  41598. * @param mimeType optional mime type
  41599. * @returns the HTMLImageElement of the loaded image
  41600. */
  41601. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41602. /**
  41603. * Loads a file from a url
  41604. * @param url url string, ArrayBuffer, or Blob to load
  41605. * @param onSuccess callback called when the file successfully loads
  41606. * @param onProgress callback called while file is loading (if the server supports this mode)
  41607. * @param offlineProvider defines the offline provider for caching
  41608. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41609. * @param onError callback called when the file fails to load
  41610. * @returns a file request object
  41611. */
  41612. 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;
  41613. /**
  41614. * Loads a file from a url
  41615. * @param url the file url to load
  41616. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41617. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41618. */
  41619. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41620. /**
  41621. * Load a script (identified by an url). When the url returns, the
  41622. * content of this file is added into a new script element, attached to the DOM (body element)
  41623. * @param scriptUrl defines the url of the script to laod
  41624. * @param onSuccess defines the callback called when the script is loaded
  41625. * @param onError defines the callback to call if an error occurs
  41626. * @param scriptId defines the id of the script element
  41627. */
  41628. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41629. /**
  41630. * Load an asynchronous script (identified by an url). When the url returns, the
  41631. * content of this file is added into a new script element, attached to the DOM (body element)
  41632. * @param scriptUrl defines the url of the script to laod
  41633. * @param scriptId defines the id of the script element
  41634. * @returns a promise request object
  41635. */
  41636. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41637. /**
  41638. * Loads a file from a blob
  41639. * @param fileToLoad defines the blob to use
  41640. * @param callback defines the callback to call when data is loaded
  41641. * @param progressCallback defines the callback to call during loading process
  41642. * @returns a file request object
  41643. */
  41644. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41645. /**
  41646. * Reads a file from a File object
  41647. * @param file defines the file to load
  41648. * @param onSuccess defines the callback to call when data is loaded
  41649. * @param onProgress defines the callback to call during loading process
  41650. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41651. * @param onError defines the callback to call when an error occurs
  41652. * @returns a file request object
  41653. */
  41654. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41655. /**
  41656. * Creates a data url from a given string content
  41657. * @param content defines the content to convert
  41658. * @returns the new data url link
  41659. */
  41660. static FileAsURL(content: string): string;
  41661. /**
  41662. * Format the given number to a specific decimal format
  41663. * @param value defines the number to format
  41664. * @param decimals defines the number of decimals to use
  41665. * @returns the formatted string
  41666. */
  41667. static Format(value: number, decimals?: number): string;
  41668. /**
  41669. * Tries to copy an object by duplicating every property
  41670. * @param source defines the source object
  41671. * @param destination defines the target object
  41672. * @param doNotCopyList defines a list of properties to avoid
  41673. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41674. */
  41675. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41676. /**
  41677. * Gets a boolean indicating if the given object has no own property
  41678. * @param obj defines the object to test
  41679. * @returns true if object has no own property
  41680. */
  41681. static IsEmpty(obj: any): boolean;
  41682. /**
  41683. * Function used to register events at window level
  41684. * @param windowElement defines the Window object to use
  41685. * @param events defines the events to register
  41686. */
  41687. static RegisterTopRootEvents(windowElement: Window, events: {
  41688. name: string;
  41689. handler: Nullable<(e: FocusEvent) => any>;
  41690. }[]): void;
  41691. /**
  41692. * Function used to unregister events from window level
  41693. * @param windowElement defines the Window object to use
  41694. * @param events defines the events to unregister
  41695. */
  41696. static UnregisterTopRootEvents(windowElement: Window, events: {
  41697. name: string;
  41698. handler: Nullable<(e: FocusEvent) => any>;
  41699. }[]): void;
  41700. /**
  41701. * @ignore
  41702. */
  41703. static _ScreenshotCanvas: HTMLCanvasElement;
  41704. /**
  41705. * Dumps the current bound framebuffer
  41706. * @param width defines the rendering width
  41707. * @param height defines the rendering height
  41708. * @param engine defines the hosting engine
  41709. * @param successCallback defines the callback triggered once the data are available
  41710. * @param mimeType defines the mime type of the result
  41711. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  41712. */
  41713. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41714. /**
  41715. * Converts the canvas data to blob.
  41716. * This acts as a polyfill for browsers not supporting the to blob function.
  41717. * @param canvas Defines the canvas to extract the data from
  41718. * @param successCallback Defines the callback triggered once the data are available
  41719. * @param mimeType Defines the mime type of the result
  41720. */
  41721. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  41722. /**
  41723. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  41724. * @param successCallback defines the callback triggered once the data are available
  41725. * @param mimeType defines the mime type of the result
  41726. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  41727. */
  41728. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41729. /**
  41730. * Downloads a blob in the browser
  41731. * @param blob defines the blob to download
  41732. * @param fileName defines the name of the downloaded file
  41733. */
  41734. static Download(blob: Blob, fileName: string): void;
  41735. /**
  41736. * Will return the right value of the noPreventDefault variable
  41737. * Needed to keep backwards compatibility to the old API.
  41738. *
  41739. * @param args arguments passed to the attachControl function
  41740. * @returns the correct value for noPreventDefault
  41741. */
  41742. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  41743. /**
  41744. * Captures a screenshot of the current rendering
  41745. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41746. * @param engine defines the rendering engine
  41747. * @param camera defines the source camera
  41748. * @param size This parameter can be set to a single number or to an object with the
  41749. * following (optional) properties: precision, width, height. If a single number is passed,
  41750. * it will be used for both width and height. If an object is passed, the screenshot size
  41751. * will be derived from the parameters. The precision property is a multiplier allowing
  41752. * rendering at a higher or lower resolution
  41753. * @param successCallback defines the callback receives a single parameter which contains the
  41754. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41755. * src parameter of an <img> to display it
  41756. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41757. * Check your browser for supported MIME types
  41758. */
  41759. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  41760. /**
  41761. * Captures a screenshot of the current rendering
  41762. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41763. * @param engine defines the rendering engine
  41764. * @param camera defines the source camera
  41765. * @param size This parameter can be set to a single number or to an object with the
  41766. * following (optional) properties: precision, width, height. If a single number is passed,
  41767. * it will be used for both width and height. If an object is passed, the screenshot size
  41768. * will be derived from the parameters. The precision property is a multiplier allowing
  41769. * rendering at a higher or lower resolution
  41770. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41771. * Check your browser for supported MIME types
  41772. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41773. * to the src parameter of an <img> to display it
  41774. */
  41775. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  41776. /**
  41777. * Generates an image screenshot from the specified camera.
  41778. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41779. * @param engine The engine to use for rendering
  41780. * @param camera The camera to use for rendering
  41781. * @param size This parameter can be set to a single number or to an object with the
  41782. * following (optional) properties: precision, width, height. If a single number is passed,
  41783. * it will be used for both width and height. If an object is passed, the screenshot size
  41784. * will be derived from the parameters. The precision property is a multiplier allowing
  41785. * rendering at a higher or lower resolution
  41786. * @param successCallback The callback receives a single parameter which contains the
  41787. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41788. * src parameter of an <img> to display it
  41789. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41790. * Check your browser for supported MIME types
  41791. * @param samples Texture samples (default: 1)
  41792. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41793. * @param fileName A name for for the downloaded file.
  41794. */
  41795. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  41796. /**
  41797. * Generates an image screenshot from the specified camera.
  41798. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41799. * @param engine The engine to use for rendering
  41800. * @param camera The camera to use for rendering
  41801. * @param size This parameter can be set to a single number or to an object with the
  41802. * following (optional) properties: precision, width, height. If a single number is passed,
  41803. * it will be used for both width and height. If an object is passed, the screenshot size
  41804. * will be derived from the parameters. The precision property is a multiplier allowing
  41805. * rendering at a higher or lower resolution
  41806. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41807. * Check your browser for supported MIME types
  41808. * @param samples Texture samples (default: 1)
  41809. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41810. * @param fileName A name for for the downloaded file.
  41811. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41812. * to the src parameter of an <img> to display it
  41813. */
  41814. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  41815. /**
  41816. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  41817. * Be aware Math.random() could cause collisions, but:
  41818. * "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"
  41819. * @returns a pseudo random id
  41820. */
  41821. static RandomId(): string;
  41822. /**
  41823. * Test if the given uri is a base64 string
  41824. * @param uri The uri to test
  41825. * @return True if the uri is a base64 string or false otherwise
  41826. */
  41827. static IsBase64(uri: string): boolean;
  41828. /**
  41829. * Decode the given base64 uri.
  41830. * @param uri The uri to decode
  41831. * @return The decoded base64 data.
  41832. */
  41833. static DecodeBase64(uri: string): ArrayBuffer;
  41834. /**
  41835. * Gets the absolute url.
  41836. * @param url the input url
  41837. * @return the absolute url
  41838. */
  41839. static GetAbsoluteUrl(url: string): string;
  41840. /**
  41841. * No log
  41842. */
  41843. static readonly NoneLogLevel: number;
  41844. /**
  41845. * Only message logs
  41846. */
  41847. static readonly MessageLogLevel: number;
  41848. /**
  41849. * Only warning logs
  41850. */
  41851. static readonly WarningLogLevel: number;
  41852. /**
  41853. * Only error logs
  41854. */
  41855. static readonly ErrorLogLevel: number;
  41856. /**
  41857. * All logs
  41858. */
  41859. static readonly AllLogLevel: number;
  41860. /**
  41861. * Gets a value indicating the number of loading errors
  41862. * @ignorenaming
  41863. */
  41864. static get errorsCount(): number;
  41865. /**
  41866. * Callback called when a new log is added
  41867. */
  41868. static OnNewCacheEntry: (entry: string) => void;
  41869. /**
  41870. * Log a message to the console
  41871. * @param message defines the message to log
  41872. */
  41873. static Log(message: string): void;
  41874. /**
  41875. * Write a warning message to the console
  41876. * @param message defines the message to log
  41877. */
  41878. static Warn(message: string): void;
  41879. /**
  41880. * Write an error message to the console
  41881. * @param message defines the message to log
  41882. */
  41883. static Error(message: string): void;
  41884. /**
  41885. * Gets current log cache (list of logs)
  41886. */
  41887. static get LogCache(): string;
  41888. /**
  41889. * Clears the log cache
  41890. */
  41891. static ClearLogCache(): void;
  41892. /**
  41893. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  41894. */
  41895. static set LogLevels(level: number);
  41896. /**
  41897. * Checks if the window object exists
  41898. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  41899. */
  41900. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  41901. /**
  41902. * No performance log
  41903. */
  41904. static readonly PerformanceNoneLogLevel: number;
  41905. /**
  41906. * Use user marks to log performance
  41907. */
  41908. static readonly PerformanceUserMarkLogLevel: number;
  41909. /**
  41910. * Log performance to the console
  41911. */
  41912. static readonly PerformanceConsoleLogLevel: number;
  41913. private static _performance;
  41914. /**
  41915. * Sets the current performance log level
  41916. */
  41917. static set PerformanceLogLevel(level: number);
  41918. private static _StartPerformanceCounterDisabled;
  41919. private static _EndPerformanceCounterDisabled;
  41920. private static _StartUserMark;
  41921. private static _EndUserMark;
  41922. private static _StartPerformanceConsole;
  41923. private static _EndPerformanceConsole;
  41924. /**
  41925. * Starts a performance counter
  41926. */
  41927. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41928. /**
  41929. * Ends a specific performance coutner
  41930. */
  41931. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41932. /**
  41933. * Gets either window.performance.now() if supported or Date.now() else
  41934. */
  41935. static get Now(): number;
  41936. /**
  41937. * This method will return the name of the class used to create the instance of the given object.
  41938. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  41939. * @param object the object to get the class name from
  41940. * @param isType defines if the object is actually a type
  41941. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  41942. */
  41943. static GetClassName(object: any, isType?: boolean): string;
  41944. /**
  41945. * Gets the first element of an array satisfying a given predicate
  41946. * @param array defines the array to browse
  41947. * @param predicate defines the predicate to use
  41948. * @returns null if not found or the element
  41949. */
  41950. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  41951. /**
  41952. * This method will return the name of the full name of the class, including its owning module (if any).
  41953. * 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).
  41954. * @param object the object to get the class name from
  41955. * @param isType defines if the object is actually a type
  41956. * @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.
  41957. * @ignorenaming
  41958. */
  41959. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  41960. /**
  41961. * Returns a promise that resolves after the given amount of time.
  41962. * @param delay Number of milliseconds to delay
  41963. * @returns Promise that resolves after the given amount of time
  41964. */
  41965. static DelayAsync(delay: number): Promise<void>;
  41966. /**
  41967. * Utility function to detect if the current user agent is Safari
  41968. * @returns whether or not the current user agent is safari
  41969. */
  41970. static IsSafari(): boolean;
  41971. }
  41972. /**
  41973. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  41974. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  41975. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  41976. * @param name The name of the class, case should be preserved
  41977. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  41978. */
  41979. export function className(name: string, module?: string): (target: Object) => void;
  41980. /**
  41981. * An implementation of a loop for asynchronous functions.
  41982. */
  41983. export class AsyncLoop {
  41984. /**
  41985. * Defines the number of iterations for the loop
  41986. */
  41987. iterations: number;
  41988. /**
  41989. * Defines the current index of the loop.
  41990. */
  41991. index: number;
  41992. private _done;
  41993. private _fn;
  41994. private _successCallback;
  41995. /**
  41996. * Constructor.
  41997. * @param iterations the number of iterations.
  41998. * @param func the function to run each iteration
  41999. * @param successCallback the callback that will be called upon succesful execution
  42000. * @param offset starting offset.
  42001. */
  42002. constructor(
  42003. /**
  42004. * Defines the number of iterations for the loop
  42005. */
  42006. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42007. /**
  42008. * Execute the next iteration. Must be called after the last iteration was finished.
  42009. */
  42010. executeNext(): void;
  42011. /**
  42012. * Break the loop and run the success callback.
  42013. */
  42014. breakLoop(): void;
  42015. /**
  42016. * Create and run an async loop.
  42017. * @param iterations the number of iterations.
  42018. * @param fn the function to run each iteration
  42019. * @param successCallback the callback that will be called upon succesful execution
  42020. * @param offset starting offset.
  42021. * @returns the created async loop object
  42022. */
  42023. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42024. /**
  42025. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42026. * @param iterations total number of iterations
  42027. * @param syncedIterations number of synchronous iterations in each async iteration.
  42028. * @param fn the function to call each iteration.
  42029. * @param callback a success call back that will be called when iterating stops.
  42030. * @param breakFunction a break condition (optional)
  42031. * @param timeout timeout settings for the setTimeout function. default - 0.
  42032. * @returns the created async loop object
  42033. */
  42034. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42035. }
  42036. }
  42037. declare module BABYLON {
  42038. /**
  42039. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42040. * The underlying implementation relies on an associative array to ensure the best performances.
  42041. * The value can be anything including 'null' but except 'undefined'
  42042. */
  42043. export class StringDictionary<T> {
  42044. /**
  42045. * This will clear this dictionary and copy the content from the 'source' one.
  42046. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42047. * @param source the dictionary to take the content from and copy to this dictionary
  42048. */
  42049. copyFrom(source: StringDictionary<T>): void;
  42050. /**
  42051. * Get a value based from its key
  42052. * @param key the given key to get the matching value from
  42053. * @return the value if found, otherwise undefined is returned
  42054. */
  42055. get(key: string): T | undefined;
  42056. /**
  42057. * Get a value from its key or add it if it doesn't exist.
  42058. * This method will ensure you that a given key/data will be present in the dictionary.
  42059. * @param key the given key to get the matching value from
  42060. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42061. * The factory will only be invoked if there's no data for the given key.
  42062. * @return the value corresponding to the key.
  42063. */
  42064. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42065. /**
  42066. * Get a value from its key if present in the dictionary otherwise add it
  42067. * @param key the key to get the value from
  42068. * @param val if there's no such key/value pair in the dictionary add it with this value
  42069. * @return the value corresponding to the key
  42070. */
  42071. getOrAdd(key: string, val: T): T;
  42072. /**
  42073. * Check if there's a given key in the dictionary
  42074. * @param key the key to check for
  42075. * @return true if the key is present, false otherwise
  42076. */
  42077. contains(key: string): boolean;
  42078. /**
  42079. * Add a new key and its corresponding value
  42080. * @param key the key to add
  42081. * @param value the value corresponding to the key
  42082. * @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
  42083. */
  42084. add(key: string, value: T): boolean;
  42085. /**
  42086. * Update a specific value associated to a key
  42087. * @param key defines the key to use
  42088. * @param value defines the value to store
  42089. * @returns true if the value was updated (or false if the key was not found)
  42090. */
  42091. set(key: string, value: T): boolean;
  42092. /**
  42093. * Get the element of the given key and remove it from the dictionary
  42094. * @param key defines the key to search
  42095. * @returns the value associated with the key or null if not found
  42096. */
  42097. getAndRemove(key: string): Nullable<T>;
  42098. /**
  42099. * Remove a key/value from the dictionary.
  42100. * @param key the key to remove
  42101. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42102. */
  42103. remove(key: string): boolean;
  42104. /**
  42105. * Clear the whole content of the dictionary
  42106. */
  42107. clear(): void;
  42108. /**
  42109. * Gets the current count
  42110. */
  42111. get count(): number;
  42112. /**
  42113. * Execute a callback on each key/val of the dictionary.
  42114. * Note that you can remove any element in this dictionary in the callback implementation
  42115. * @param callback the callback to execute on a given key/value pair
  42116. */
  42117. forEach(callback: (key: string, val: T) => void): void;
  42118. /**
  42119. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42120. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42121. * Note that you can remove any element in this dictionary in the callback implementation
  42122. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42123. * @returns the first item
  42124. */
  42125. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42126. private _count;
  42127. private _data;
  42128. }
  42129. }
  42130. declare module BABYLON {
  42131. /** @hidden */
  42132. export interface ICollisionCoordinator {
  42133. createCollider(): Collider;
  42134. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42135. init(scene: Scene): void;
  42136. }
  42137. /** @hidden */
  42138. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42139. private _scene;
  42140. private _scaledPosition;
  42141. private _scaledVelocity;
  42142. private _finalPosition;
  42143. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42144. createCollider(): Collider;
  42145. init(scene: Scene): void;
  42146. private _collideWithWorld;
  42147. }
  42148. }
  42149. declare module BABYLON {
  42150. /**
  42151. * Class used to manage all inputs for the scene.
  42152. */
  42153. export class InputManager {
  42154. /** The distance in pixel that you have to move to prevent some events */
  42155. static DragMovementThreshold: number;
  42156. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42157. static LongPressDelay: number;
  42158. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42159. static DoubleClickDelay: number;
  42160. /** If you need to check double click without raising a single click at first click, enable this flag */
  42161. static ExclusiveDoubleClickMode: boolean;
  42162. /** 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. */
  42163. private _alreadyAttached;
  42164. private _alreadyAttachedTo;
  42165. private _wheelEventName;
  42166. private _onPointerMove;
  42167. private _onPointerDown;
  42168. private _onPointerUp;
  42169. private _initClickEvent;
  42170. private _initActionManager;
  42171. private _delayedSimpleClick;
  42172. private _delayedSimpleClickTimeout;
  42173. private _previousDelayedSimpleClickTimeout;
  42174. private _meshPickProceed;
  42175. private _previousButtonPressed;
  42176. private _currentPickResult;
  42177. private _previousPickResult;
  42178. private _totalPointersPressed;
  42179. private _doubleClickOccured;
  42180. private _pointerOverMesh;
  42181. private _pickedDownMesh;
  42182. private _pickedUpMesh;
  42183. private _pointerX;
  42184. private _pointerY;
  42185. private _unTranslatedPointerX;
  42186. private _unTranslatedPointerY;
  42187. private _startingPointerPosition;
  42188. private _previousStartingPointerPosition;
  42189. private _startingPointerTime;
  42190. private _previousStartingPointerTime;
  42191. private _pointerCaptures;
  42192. private _meshUnderPointerId;
  42193. private _onKeyDown;
  42194. private _onKeyUp;
  42195. private _keyboardIsAttached;
  42196. private _onCanvasFocusObserver;
  42197. private _onCanvasBlurObserver;
  42198. private _scene;
  42199. /**
  42200. * Creates a new InputManager
  42201. * @param scene defines the hosting scene
  42202. */
  42203. constructor(scene: Scene);
  42204. /**
  42205. * Gets the mesh that is currently under the pointer
  42206. */
  42207. get meshUnderPointer(): Nullable<AbstractMesh>;
  42208. /**
  42209. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42210. * @param pointerId the pointer id to use
  42211. * @returns The mesh under this pointer id or null if not found
  42212. */
  42213. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42214. /**
  42215. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42216. */
  42217. get unTranslatedPointer(): Vector2;
  42218. /**
  42219. * Gets or sets the current on-screen X position of the pointer
  42220. */
  42221. get pointerX(): number;
  42222. set pointerX(value: number);
  42223. /**
  42224. * Gets or sets the current on-screen Y position of the pointer
  42225. */
  42226. get pointerY(): number;
  42227. set pointerY(value: number);
  42228. private _updatePointerPosition;
  42229. private _processPointerMove;
  42230. private _setRayOnPointerInfo;
  42231. private _checkPrePointerObservable;
  42232. /**
  42233. * Use this method to simulate a pointer move on a mesh
  42234. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42235. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42236. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42237. */
  42238. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42239. /**
  42240. * Use this method to simulate a pointer down on a mesh
  42241. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42242. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42243. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42244. */
  42245. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42246. private _processPointerDown;
  42247. /** @hidden */
  42248. _isPointerSwiping(): boolean;
  42249. /**
  42250. * Use this method to simulate a pointer up on a mesh
  42251. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42252. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42253. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42254. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42255. */
  42256. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42257. private _processPointerUp;
  42258. /**
  42259. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42260. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42261. * @returns true if the pointer was captured
  42262. */
  42263. isPointerCaptured(pointerId?: number): boolean;
  42264. /**
  42265. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42266. * @param attachUp defines if you want to attach events to pointerup
  42267. * @param attachDown defines if you want to attach events to pointerdown
  42268. * @param attachMove defines if you want to attach events to pointermove
  42269. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42270. */
  42271. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42272. /**
  42273. * Detaches all event handlers
  42274. */
  42275. detachControl(): void;
  42276. /**
  42277. * Force the value of meshUnderPointer
  42278. * @param mesh defines the mesh to use
  42279. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42280. */
  42281. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42282. /**
  42283. * Gets the mesh under the pointer
  42284. * @returns a Mesh or null if no mesh is under the pointer
  42285. */
  42286. getPointerOverMesh(): Nullable<AbstractMesh>;
  42287. }
  42288. }
  42289. declare module BABYLON {
  42290. /**
  42291. * This class defines the direct association between an animation and a target
  42292. */
  42293. export class TargetedAnimation {
  42294. /**
  42295. * Animation to perform
  42296. */
  42297. animation: Animation;
  42298. /**
  42299. * Target to animate
  42300. */
  42301. target: any;
  42302. /**
  42303. * Returns the string "TargetedAnimation"
  42304. * @returns "TargetedAnimation"
  42305. */
  42306. getClassName(): string;
  42307. /**
  42308. * Serialize the object
  42309. * @returns the JSON object representing the current entity
  42310. */
  42311. serialize(): any;
  42312. }
  42313. /**
  42314. * Use this class to create coordinated animations on multiple targets
  42315. */
  42316. export class AnimationGroup implements IDisposable {
  42317. /** The name of the animation group */
  42318. name: string;
  42319. private _scene;
  42320. private _targetedAnimations;
  42321. private _animatables;
  42322. private _from;
  42323. private _to;
  42324. private _isStarted;
  42325. private _isPaused;
  42326. private _speedRatio;
  42327. private _loopAnimation;
  42328. private _isAdditive;
  42329. /**
  42330. * Gets or sets the unique id of the node
  42331. */
  42332. uniqueId: number;
  42333. /**
  42334. * This observable will notify when one animation have ended
  42335. */
  42336. onAnimationEndObservable: Observable<TargetedAnimation>;
  42337. /**
  42338. * Observer raised when one animation loops
  42339. */
  42340. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42341. /**
  42342. * Observer raised when all animations have looped
  42343. */
  42344. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42345. /**
  42346. * This observable will notify when all animations have ended.
  42347. */
  42348. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42349. /**
  42350. * This observable will notify when all animations have paused.
  42351. */
  42352. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42353. /**
  42354. * This observable will notify when all animations are playing.
  42355. */
  42356. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42357. /**
  42358. * Gets the first frame
  42359. */
  42360. get from(): number;
  42361. /**
  42362. * Gets the last frame
  42363. */
  42364. get to(): number;
  42365. /**
  42366. * Define if the animations are started
  42367. */
  42368. get isStarted(): boolean;
  42369. /**
  42370. * Gets a value indicating that the current group is playing
  42371. */
  42372. get isPlaying(): boolean;
  42373. /**
  42374. * Gets or sets the speed ratio to use for all animations
  42375. */
  42376. get speedRatio(): number;
  42377. /**
  42378. * Gets or sets the speed ratio to use for all animations
  42379. */
  42380. set speedRatio(value: number);
  42381. /**
  42382. * Gets or sets if all animations should loop or not
  42383. */
  42384. get loopAnimation(): boolean;
  42385. set loopAnimation(value: boolean);
  42386. /**
  42387. * Gets or sets if all animations should be evaluated additively
  42388. */
  42389. get isAdditive(): boolean;
  42390. set isAdditive(value: boolean);
  42391. /**
  42392. * Gets the targeted animations for this animation group
  42393. */
  42394. get targetedAnimations(): Array<TargetedAnimation>;
  42395. /**
  42396. * returning the list of animatables controlled by this animation group.
  42397. */
  42398. get animatables(): Array<Animatable>;
  42399. /**
  42400. * Gets the list of target animations
  42401. */
  42402. get children(): TargetedAnimation[];
  42403. /**
  42404. * Instantiates a new Animation Group.
  42405. * This helps managing several animations at once.
  42406. * @see https://doc.babylonjs.com/how_to/group
  42407. * @param name Defines the name of the group
  42408. * @param scene Defines the scene the group belongs to
  42409. */
  42410. constructor(
  42411. /** The name of the animation group */
  42412. name: string, scene?: Nullable<Scene>);
  42413. /**
  42414. * Add an animation (with its target) in the group
  42415. * @param animation defines the animation we want to add
  42416. * @param target defines the target of the animation
  42417. * @returns the TargetedAnimation object
  42418. */
  42419. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42420. /**
  42421. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42422. * It can add constant keys at begin or end
  42423. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42424. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42425. * @returns the animation group
  42426. */
  42427. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42428. private _animationLoopCount;
  42429. private _animationLoopFlags;
  42430. private _processLoop;
  42431. /**
  42432. * Start all animations on given targets
  42433. * @param loop defines if animations must loop
  42434. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42435. * @param from defines the from key (optional)
  42436. * @param to defines the to key (optional)
  42437. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42438. * @returns the current animation group
  42439. */
  42440. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42441. /**
  42442. * Pause all animations
  42443. * @returns the animation group
  42444. */
  42445. pause(): AnimationGroup;
  42446. /**
  42447. * Play all animations to initial state
  42448. * This function will start() the animations if they were not started or will restart() them if they were paused
  42449. * @param loop defines if animations must loop
  42450. * @returns the animation group
  42451. */
  42452. play(loop?: boolean): AnimationGroup;
  42453. /**
  42454. * Reset all animations to initial state
  42455. * @returns the animation group
  42456. */
  42457. reset(): AnimationGroup;
  42458. /**
  42459. * Restart animations from key 0
  42460. * @returns the animation group
  42461. */
  42462. restart(): AnimationGroup;
  42463. /**
  42464. * Stop all animations
  42465. * @returns the animation group
  42466. */
  42467. stop(): AnimationGroup;
  42468. /**
  42469. * Set animation weight for all animatables
  42470. * @param weight defines the weight to use
  42471. * @return the animationGroup
  42472. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42473. */
  42474. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42475. /**
  42476. * Synchronize and normalize all animatables with a source animatable
  42477. * @param root defines the root animatable to synchronize with
  42478. * @return the animationGroup
  42479. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42480. */
  42481. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42482. /**
  42483. * Goes to a specific frame in this animation group
  42484. * @param frame the frame number to go to
  42485. * @return the animationGroup
  42486. */
  42487. goToFrame(frame: number): AnimationGroup;
  42488. /**
  42489. * Dispose all associated resources
  42490. */
  42491. dispose(): void;
  42492. private _checkAnimationGroupEnded;
  42493. /**
  42494. * Clone the current animation group and returns a copy
  42495. * @param newName defines the name of the new group
  42496. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42497. * @returns the new aniamtion group
  42498. */
  42499. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42500. /**
  42501. * Serializes the animationGroup to an object
  42502. * @returns Serialized object
  42503. */
  42504. serialize(): any;
  42505. /**
  42506. * Returns a new AnimationGroup object parsed from the source provided.
  42507. * @param parsedAnimationGroup defines the source
  42508. * @param scene defines the scene that will receive the animationGroup
  42509. * @returns a new AnimationGroup
  42510. */
  42511. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42512. /**
  42513. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42514. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42515. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42516. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42517. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42518. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42519. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42520. */
  42521. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42522. /**
  42523. * Returns the string "AnimationGroup"
  42524. * @returns "AnimationGroup"
  42525. */
  42526. getClassName(): string;
  42527. /**
  42528. * Creates a detailled string about the object
  42529. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42530. * @returns a string representing the object
  42531. */
  42532. toString(fullDetails?: boolean): string;
  42533. }
  42534. }
  42535. declare module BABYLON {
  42536. /**
  42537. * Define an interface for all classes that will hold resources
  42538. */
  42539. export interface IDisposable {
  42540. /**
  42541. * Releases all held resources
  42542. */
  42543. dispose(): void;
  42544. }
  42545. /** Interface defining initialization parameters for Scene class */
  42546. export interface SceneOptions {
  42547. /**
  42548. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42549. * It will improve performance when the number of geometries becomes important.
  42550. */
  42551. useGeometryUniqueIdsMap?: boolean;
  42552. /**
  42553. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42554. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42555. */
  42556. useMaterialMeshMap?: boolean;
  42557. /**
  42558. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42559. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42560. */
  42561. useClonedMeshMap?: boolean;
  42562. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42563. virtual?: boolean;
  42564. }
  42565. /**
  42566. * Represents a scene to be rendered by the engine.
  42567. * @see https://doc.babylonjs.com/features/scene
  42568. */
  42569. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42570. /** The fog is deactivated */
  42571. static readonly FOGMODE_NONE: number;
  42572. /** The fog density is following an exponential function */
  42573. static readonly FOGMODE_EXP: number;
  42574. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42575. static readonly FOGMODE_EXP2: number;
  42576. /** The fog density is following a linear function. */
  42577. static readonly FOGMODE_LINEAR: number;
  42578. /**
  42579. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42580. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42581. */
  42582. static MinDeltaTime: number;
  42583. /**
  42584. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42585. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42586. */
  42587. static MaxDeltaTime: number;
  42588. /**
  42589. * Factory used to create the default material.
  42590. * @param name The name of the material to create
  42591. * @param scene The scene to create the material for
  42592. * @returns The default material
  42593. */
  42594. static DefaultMaterialFactory(scene: Scene): Material;
  42595. /**
  42596. * Factory used to create the a collision coordinator.
  42597. * @returns The collision coordinator
  42598. */
  42599. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42600. /** @hidden */
  42601. _inputManager: InputManager;
  42602. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42603. cameraToUseForPointers: Nullable<Camera>;
  42604. /** @hidden */
  42605. readonly _isScene: boolean;
  42606. /** @hidden */
  42607. _blockEntityCollection: boolean;
  42608. /**
  42609. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42610. */
  42611. autoClear: boolean;
  42612. /**
  42613. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42614. */
  42615. autoClearDepthAndStencil: boolean;
  42616. /**
  42617. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42618. */
  42619. clearColor: Color4;
  42620. /**
  42621. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42622. */
  42623. ambientColor: Color3;
  42624. /**
  42625. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42626. * It should only be one of the following (if not the default embedded one):
  42627. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42628. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42629. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42630. * The material properties need to be setup according to the type of texture in use.
  42631. */
  42632. environmentBRDFTexture: BaseTexture;
  42633. /**
  42634. * Texture used in all pbr material as the reflection texture.
  42635. * As in the majority of the scene they are the same (exception for multi room and so on),
  42636. * this is easier to reference from here than from all the materials.
  42637. */
  42638. get environmentTexture(): Nullable<BaseTexture>;
  42639. /**
  42640. * Texture used in all pbr material as the reflection texture.
  42641. * As in the majority of the scene they are the same (exception for multi room and so on),
  42642. * this is easier to set here than in all the materials.
  42643. */
  42644. set environmentTexture(value: Nullable<BaseTexture>);
  42645. /** @hidden */
  42646. protected _environmentIntensity: number;
  42647. /**
  42648. * Intensity of the environment in all pbr material.
  42649. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42650. * As in the majority of the scene they are the same (exception for multi room and so on),
  42651. * this is easier to reference from here than from all the materials.
  42652. */
  42653. get environmentIntensity(): number;
  42654. /**
  42655. * Intensity of the environment in all pbr material.
  42656. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42657. * As in the majority of the scene they are the same (exception for multi room and so on),
  42658. * this is easier to set here than in all the materials.
  42659. */
  42660. set environmentIntensity(value: number);
  42661. /** @hidden */
  42662. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42663. /**
  42664. * Default image processing configuration used either in the rendering
  42665. * Forward main pass or through the imageProcessingPostProcess if present.
  42666. * As in the majority of the scene they are the same (exception for multi camera),
  42667. * this is easier to reference from here than from all the materials and post process.
  42668. *
  42669. * No setter as we it is a shared configuration, you can set the values instead.
  42670. */
  42671. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42672. private _forceWireframe;
  42673. /**
  42674. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42675. */
  42676. set forceWireframe(value: boolean);
  42677. get forceWireframe(): boolean;
  42678. private _skipFrustumClipping;
  42679. /**
  42680. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42681. */
  42682. set skipFrustumClipping(value: boolean);
  42683. get skipFrustumClipping(): boolean;
  42684. private _forcePointsCloud;
  42685. /**
  42686. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42687. */
  42688. set forcePointsCloud(value: boolean);
  42689. get forcePointsCloud(): boolean;
  42690. /**
  42691. * Gets or sets the active clipplane 1
  42692. */
  42693. clipPlane: Nullable<Plane>;
  42694. /**
  42695. * Gets or sets the active clipplane 2
  42696. */
  42697. clipPlane2: Nullable<Plane>;
  42698. /**
  42699. * Gets or sets the active clipplane 3
  42700. */
  42701. clipPlane3: Nullable<Plane>;
  42702. /**
  42703. * Gets or sets the active clipplane 4
  42704. */
  42705. clipPlane4: Nullable<Plane>;
  42706. /**
  42707. * Gets or sets the active clipplane 5
  42708. */
  42709. clipPlane5: Nullable<Plane>;
  42710. /**
  42711. * Gets or sets the active clipplane 6
  42712. */
  42713. clipPlane6: Nullable<Plane>;
  42714. /**
  42715. * Gets or sets a boolean indicating if animations are enabled
  42716. */
  42717. animationsEnabled: boolean;
  42718. private _animationPropertiesOverride;
  42719. /**
  42720. * Gets or sets the animation properties override
  42721. */
  42722. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  42723. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  42724. /**
  42725. * Gets or sets a boolean indicating if a constant deltatime has to be used
  42726. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  42727. */
  42728. useConstantAnimationDeltaTime: boolean;
  42729. /**
  42730. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  42731. * Please note that it requires to run a ray cast through the scene on every frame
  42732. */
  42733. constantlyUpdateMeshUnderPointer: boolean;
  42734. /**
  42735. * Defines the HTML cursor to use when hovering over interactive elements
  42736. */
  42737. hoverCursor: string;
  42738. /**
  42739. * Defines the HTML default cursor to use (empty by default)
  42740. */
  42741. defaultCursor: string;
  42742. /**
  42743. * Defines whether cursors are handled by the scene.
  42744. */
  42745. doNotHandleCursors: boolean;
  42746. /**
  42747. * This is used to call preventDefault() on pointer down
  42748. * in order to block unwanted artifacts like system double clicks
  42749. */
  42750. preventDefaultOnPointerDown: boolean;
  42751. /**
  42752. * This is used to call preventDefault() on pointer up
  42753. * in order to block unwanted artifacts like system double clicks
  42754. */
  42755. preventDefaultOnPointerUp: boolean;
  42756. /**
  42757. * Gets or sets user defined metadata
  42758. */
  42759. metadata: any;
  42760. /**
  42761. * For internal use only. Please do not use.
  42762. */
  42763. reservedDataStore: any;
  42764. /**
  42765. * Gets the name of the plugin used to load this scene (null by default)
  42766. */
  42767. loadingPluginName: string;
  42768. /**
  42769. * Use this array to add regular expressions used to disable offline support for specific urls
  42770. */
  42771. disableOfflineSupportExceptionRules: RegExp[];
  42772. /**
  42773. * An event triggered when the scene is disposed.
  42774. */
  42775. onDisposeObservable: Observable<Scene>;
  42776. private _onDisposeObserver;
  42777. /** Sets a function to be executed when this scene is disposed. */
  42778. set onDispose(callback: () => void);
  42779. /**
  42780. * An event triggered before rendering the scene (right after animations and physics)
  42781. */
  42782. onBeforeRenderObservable: Observable<Scene>;
  42783. private _onBeforeRenderObserver;
  42784. /** Sets a function to be executed before rendering this scene */
  42785. set beforeRender(callback: Nullable<() => void>);
  42786. /**
  42787. * An event triggered after rendering the scene
  42788. */
  42789. onAfterRenderObservable: Observable<Scene>;
  42790. /**
  42791. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  42792. */
  42793. onAfterRenderCameraObservable: Observable<Camera>;
  42794. private _onAfterRenderObserver;
  42795. /** Sets a function to be executed after rendering this scene */
  42796. set afterRender(callback: Nullable<() => void>);
  42797. /**
  42798. * An event triggered before animating the scene
  42799. */
  42800. onBeforeAnimationsObservable: Observable<Scene>;
  42801. /**
  42802. * An event triggered after animations processing
  42803. */
  42804. onAfterAnimationsObservable: Observable<Scene>;
  42805. /**
  42806. * An event triggered before draw calls are ready to be sent
  42807. */
  42808. onBeforeDrawPhaseObservable: Observable<Scene>;
  42809. /**
  42810. * An event triggered after draw calls have been sent
  42811. */
  42812. onAfterDrawPhaseObservable: Observable<Scene>;
  42813. /**
  42814. * An event triggered when the scene is ready
  42815. */
  42816. onReadyObservable: Observable<Scene>;
  42817. /**
  42818. * An event triggered before rendering a camera
  42819. */
  42820. onBeforeCameraRenderObservable: Observable<Camera>;
  42821. private _onBeforeCameraRenderObserver;
  42822. /** Sets a function to be executed before rendering a camera*/
  42823. set beforeCameraRender(callback: () => void);
  42824. /**
  42825. * An event triggered after rendering a camera
  42826. */
  42827. onAfterCameraRenderObservable: Observable<Camera>;
  42828. private _onAfterCameraRenderObserver;
  42829. /** Sets a function to be executed after rendering a camera*/
  42830. set afterCameraRender(callback: () => void);
  42831. /**
  42832. * An event triggered when active meshes evaluation is about to start
  42833. */
  42834. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  42835. /**
  42836. * An event triggered when active meshes evaluation is done
  42837. */
  42838. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  42839. /**
  42840. * An event triggered when particles rendering is about to start
  42841. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42842. */
  42843. onBeforeParticlesRenderingObservable: Observable<Scene>;
  42844. /**
  42845. * An event triggered when particles rendering is done
  42846. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42847. */
  42848. onAfterParticlesRenderingObservable: Observable<Scene>;
  42849. /**
  42850. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  42851. */
  42852. onDataLoadedObservable: Observable<Scene>;
  42853. /**
  42854. * An event triggered when a camera is created
  42855. */
  42856. onNewCameraAddedObservable: Observable<Camera>;
  42857. /**
  42858. * An event triggered when a camera is removed
  42859. */
  42860. onCameraRemovedObservable: Observable<Camera>;
  42861. /**
  42862. * An event triggered when a light is created
  42863. */
  42864. onNewLightAddedObservable: Observable<Light>;
  42865. /**
  42866. * An event triggered when a light is removed
  42867. */
  42868. onLightRemovedObservable: Observable<Light>;
  42869. /**
  42870. * An event triggered when a geometry is created
  42871. */
  42872. onNewGeometryAddedObservable: Observable<Geometry>;
  42873. /**
  42874. * An event triggered when a geometry is removed
  42875. */
  42876. onGeometryRemovedObservable: Observable<Geometry>;
  42877. /**
  42878. * An event triggered when a transform node is created
  42879. */
  42880. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  42881. /**
  42882. * An event triggered when a transform node is removed
  42883. */
  42884. onTransformNodeRemovedObservable: Observable<TransformNode>;
  42885. /**
  42886. * An event triggered when a mesh is created
  42887. */
  42888. onNewMeshAddedObservable: Observable<AbstractMesh>;
  42889. /**
  42890. * An event triggered when a mesh is removed
  42891. */
  42892. onMeshRemovedObservable: Observable<AbstractMesh>;
  42893. /**
  42894. * An event triggered when a skeleton is created
  42895. */
  42896. onNewSkeletonAddedObservable: Observable<Skeleton>;
  42897. /**
  42898. * An event triggered when a skeleton is removed
  42899. */
  42900. onSkeletonRemovedObservable: Observable<Skeleton>;
  42901. /**
  42902. * An event triggered when a material is created
  42903. */
  42904. onNewMaterialAddedObservable: Observable<Material>;
  42905. /**
  42906. * An event triggered when a material is removed
  42907. */
  42908. onMaterialRemovedObservable: Observable<Material>;
  42909. /**
  42910. * An event triggered when a texture is created
  42911. */
  42912. onNewTextureAddedObservable: Observable<BaseTexture>;
  42913. /**
  42914. * An event triggered when a texture is removed
  42915. */
  42916. onTextureRemovedObservable: Observable<BaseTexture>;
  42917. /**
  42918. * An event triggered when render targets are about to be rendered
  42919. * Can happen multiple times per frame.
  42920. */
  42921. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  42922. /**
  42923. * An event triggered when render targets were rendered.
  42924. * Can happen multiple times per frame.
  42925. */
  42926. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  42927. /**
  42928. * An event triggered before calculating deterministic simulation step
  42929. */
  42930. onBeforeStepObservable: Observable<Scene>;
  42931. /**
  42932. * An event triggered after calculating deterministic simulation step
  42933. */
  42934. onAfterStepObservable: Observable<Scene>;
  42935. /**
  42936. * An event triggered when the activeCamera property is updated
  42937. */
  42938. onActiveCameraChanged: Observable<Scene>;
  42939. /**
  42940. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  42941. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42942. * 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)
  42943. */
  42944. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42945. /**
  42946. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  42947. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42948. * 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)
  42949. */
  42950. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42951. /**
  42952. * This Observable will when a mesh has been imported into the scene.
  42953. */
  42954. onMeshImportedObservable: Observable<AbstractMesh>;
  42955. /**
  42956. * This Observable will when an animation file has been imported into the scene.
  42957. */
  42958. onAnimationFileImportedObservable: Observable<Scene>;
  42959. /**
  42960. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  42961. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  42962. */
  42963. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  42964. /** @hidden */
  42965. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  42966. /**
  42967. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  42968. */
  42969. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  42970. /**
  42971. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  42972. */
  42973. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  42974. /**
  42975. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  42976. */
  42977. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  42978. /** Callback called when a pointer move is detected */
  42979. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  42980. /** Callback called when a pointer down is detected */
  42981. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  42982. /** Callback called when a pointer up is detected */
  42983. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  42984. /** Callback called when a pointer pick is detected */
  42985. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  42986. /**
  42987. * 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).
  42988. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  42989. */
  42990. onPrePointerObservable: Observable<PointerInfoPre>;
  42991. /**
  42992. * Observable event triggered each time an input event is received from the rendering canvas
  42993. */
  42994. onPointerObservable: Observable<PointerInfo>;
  42995. /**
  42996. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  42997. */
  42998. get unTranslatedPointer(): Vector2;
  42999. /**
  43000. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43001. */
  43002. static get DragMovementThreshold(): number;
  43003. static set DragMovementThreshold(value: number);
  43004. /**
  43005. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43006. */
  43007. static get LongPressDelay(): number;
  43008. static set LongPressDelay(value: number);
  43009. /**
  43010. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43011. */
  43012. static get DoubleClickDelay(): number;
  43013. static set DoubleClickDelay(value: number);
  43014. /** If you need to check double click without raising a single click at first click, enable this flag */
  43015. static get ExclusiveDoubleClickMode(): boolean;
  43016. static set ExclusiveDoubleClickMode(value: boolean);
  43017. /** @hidden */
  43018. _mirroredCameraPosition: Nullable<Vector3>;
  43019. /**
  43020. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43021. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43022. */
  43023. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43024. /**
  43025. * Observable event triggered each time an keyboard event is received from the hosting window
  43026. */
  43027. onKeyboardObservable: Observable<KeyboardInfo>;
  43028. private _useRightHandedSystem;
  43029. /**
  43030. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43031. */
  43032. set useRightHandedSystem(value: boolean);
  43033. get useRightHandedSystem(): boolean;
  43034. private _timeAccumulator;
  43035. private _currentStepId;
  43036. private _currentInternalStep;
  43037. /**
  43038. * Sets the step Id used by deterministic lock step
  43039. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43040. * @param newStepId defines the step Id
  43041. */
  43042. setStepId(newStepId: number): void;
  43043. /**
  43044. * Gets the step Id used by deterministic lock step
  43045. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43046. * @returns the step Id
  43047. */
  43048. getStepId(): number;
  43049. /**
  43050. * Gets the internal step used by deterministic lock step
  43051. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43052. * @returns the internal step
  43053. */
  43054. getInternalStep(): number;
  43055. private _fogEnabled;
  43056. /**
  43057. * Gets or sets a boolean indicating if fog is enabled on this scene
  43058. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43059. * (Default is true)
  43060. */
  43061. set fogEnabled(value: boolean);
  43062. get fogEnabled(): boolean;
  43063. private _fogMode;
  43064. /**
  43065. * Gets or sets the fog mode to use
  43066. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43067. * | mode | value |
  43068. * | --- | --- |
  43069. * | FOGMODE_NONE | 0 |
  43070. * | FOGMODE_EXP | 1 |
  43071. * | FOGMODE_EXP2 | 2 |
  43072. * | FOGMODE_LINEAR | 3 |
  43073. */
  43074. set fogMode(value: number);
  43075. get fogMode(): number;
  43076. /**
  43077. * Gets or sets the fog color to use
  43078. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43079. * (Default is Color3(0.2, 0.2, 0.3))
  43080. */
  43081. fogColor: Color3;
  43082. /**
  43083. * Gets or sets the fog density to use
  43084. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43085. * (Default is 0.1)
  43086. */
  43087. fogDensity: number;
  43088. /**
  43089. * Gets or sets the fog start distance to use
  43090. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43091. * (Default is 0)
  43092. */
  43093. fogStart: number;
  43094. /**
  43095. * Gets or sets the fog end distance to use
  43096. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43097. * (Default is 1000)
  43098. */
  43099. fogEnd: number;
  43100. /**
  43101. * Flag indicating that the frame buffer binding is handled by another component
  43102. */
  43103. prePass: boolean;
  43104. private _shadowsEnabled;
  43105. /**
  43106. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43107. */
  43108. set shadowsEnabled(value: boolean);
  43109. get shadowsEnabled(): boolean;
  43110. private _lightsEnabled;
  43111. /**
  43112. * Gets or sets a boolean indicating if lights are enabled on this scene
  43113. */
  43114. set lightsEnabled(value: boolean);
  43115. get lightsEnabled(): boolean;
  43116. /** All of the active cameras added to this scene. */
  43117. activeCameras: Camera[];
  43118. /** @hidden */
  43119. _activeCamera: Nullable<Camera>;
  43120. /** Gets or sets the current active camera */
  43121. get activeCamera(): Nullable<Camera>;
  43122. set activeCamera(value: Nullable<Camera>);
  43123. private _defaultMaterial;
  43124. /** The default material used on meshes when no material is affected */
  43125. get defaultMaterial(): Material;
  43126. /** The default material used on meshes when no material is affected */
  43127. set defaultMaterial(value: Material);
  43128. private _texturesEnabled;
  43129. /**
  43130. * Gets or sets a boolean indicating if textures are enabled on this scene
  43131. */
  43132. set texturesEnabled(value: boolean);
  43133. get texturesEnabled(): boolean;
  43134. /**
  43135. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43136. */
  43137. physicsEnabled: boolean;
  43138. /**
  43139. * Gets or sets a boolean indicating if particles are enabled on this scene
  43140. */
  43141. particlesEnabled: boolean;
  43142. /**
  43143. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43144. */
  43145. spritesEnabled: boolean;
  43146. private _skeletonsEnabled;
  43147. /**
  43148. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43149. */
  43150. set skeletonsEnabled(value: boolean);
  43151. get skeletonsEnabled(): boolean;
  43152. /**
  43153. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43154. */
  43155. lensFlaresEnabled: boolean;
  43156. /**
  43157. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43158. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43159. */
  43160. collisionsEnabled: boolean;
  43161. private _collisionCoordinator;
  43162. /** @hidden */
  43163. get collisionCoordinator(): ICollisionCoordinator;
  43164. /**
  43165. * Defines the gravity applied to this scene (used only for collisions)
  43166. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43167. */
  43168. gravity: Vector3;
  43169. /**
  43170. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43171. */
  43172. postProcessesEnabled: boolean;
  43173. /**
  43174. * Gets the current postprocess manager
  43175. */
  43176. postProcessManager: PostProcessManager;
  43177. /**
  43178. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43179. */
  43180. renderTargetsEnabled: boolean;
  43181. /**
  43182. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43183. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43184. */
  43185. dumpNextRenderTargets: boolean;
  43186. /**
  43187. * The list of user defined render targets added to the scene
  43188. */
  43189. customRenderTargets: RenderTargetTexture[];
  43190. /**
  43191. * Defines if texture loading must be delayed
  43192. * If true, textures will only be loaded when they need to be rendered
  43193. */
  43194. useDelayedTextureLoading: boolean;
  43195. /**
  43196. * Gets the list of meshes imported to the scene through SceneLoader
  43197. */
  43198. importedMeshesFiles: String[];
  43199. /**
  43200. * Gets or sets a boolean indicating if probes are enabled on this scene
  43201. */
  43202. probesEnabled: boolean;
  43203. /**
  43204. * Gets or sets the current offline provider to use to store scene data
  43205. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43206. */
  43207. offlineProvider: IOfflineProvider;
  43208. /**
  43209. * Gets or sets the action manager associated with the scene
  43210. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43211. */
  43212. actionManager: AbstractActionManager;
  43213. private _meshesForIntersections;
  43214. /**
  43215. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43216. */
  43217. proceduralTexturesEnabled: boolean;
  43218. private _engine;
  43219. private _totalVertices;
  43220. /** @hidden */
  43221. _activeIndices: PerfCounter;
  43222. /** @hidden */
  43223. _activeParticles: PerfCounter;
  43224. /** @hidden */
  43225. _activeBones: PerfCounter;
  43226. private _animationRatio;
  43227. /** @hidden */
  43228. _animationTimeLast: number;
  43229. /** @hidden */
  43230. _animationTime: number;
  43231. /**
  43232. * Gets or sets a general scale for animation speed
  43233. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43234. */
  43235. animationTimeScale: number;
  43236. /** @hidden */
  43237. _cachedMaterial: Nullable<Material>;
  43238. /** @hidden */
  43239. _cachedEffect: Nullable<Effect>;
  43240. /** @hidden */
  43241. _cachedVisibility: Nullable<number>;
  43242. private _renderId;
  43243. private _frameId;
  43244. private _executeWhenReadyTimeoutId;
  43245. private _intermediateRendering;
  43246. private _viewUpdateFlag;
  43247. private _projectionUpdateFlag;
  43248. /** @hidden */
  43249. _toBeDisposed: Nullable<IDisposable>[];
  43250. private _activeRequests;
  43251. /** @hidden */
  43252. _pendingData: any[];
  43253. private _isDisposed;
  43254. /**
  43255. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43256. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43257. */
  43258. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43259. private _activeMeshes;
  43260. private _processedMaterials;
  43261. private _renderTargets;
  43262. /** @hidden */
  43263. _activeParticleSystems: SmartArray<IParticleSystem>;
  43264. private _activeSkeletons;
  43265. private _softwareSkinnedMeshes;
  43266. private _renderingManager;
  43267. /** @hidden */
  43268. _activeAnimatables: Animatable[];
  43269. private _transformMatrix;
  43270. private _sceneUbo;
  43271. /** @hidden */
  43272. _viewMatrix: Matrix;
  43273. private _projectionMatrix;
  43274. /** @hidden */
  43275. _forcedViewPosition: Nullable<Vector3>;
  43276. /** @hidden */
  43277. _frustumPlanes: Plane[];
  43278. /**
  43279. * Gets the list of frustum planes (built from the active camera)
  43280. */
  43281. get frustumPlanes(): Plane[];
  43282. /**
  43283. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43284. * This is useful if there are more lights that the maximum simulteanous authorized
  43285. */
  43286. requireLightSorting: boolean;
  43287. /** @hidden */
  43288. readonly useMaterialMeshMap: boolean;
  43289. /** @hidden */
  43290. readonly useClonedMeshMap: boolean;
  43291. private _externalData;
  43292. private _uid;
  43293. /**
  43294. * @hidden
  43295. * Backing store of defined scene components.
  43296. */
  43297. _components: ISceneComponent[];
  43298. /**
  43299. * @hidden
  43300. * Backing store of defined scene components.
  43301. */
  43302. _serializableComponents: ISceneSerializableComponent[];
  43303. /**
  43304. * List of components to register on the next registration step.
  43305. */
  43306. private _transientComponents;
  43307. /**
  43308. * Registers the transient components if needed.
  43309. */
  43310. private _registerTransientComponents;
  43311. /**
  43312. * @hidden
  43313. * Add a component to the scene.
  43314. * Note that the ccomponent could be registered on th next frame if this is called after
  43315. * the register component stage.
  43316. * @param component Defines the component to add to the scene
  43317. */
  43318. _addComponent(component: ISceneComponent): void;
  43319. /**
  43320. * @hidden
  43321. * Gets a component from the scene.
  43322. * @param name defines the name of the component to retrieve
  43323. * @returns the component or null if not present
  43324. */
  43325. _getComponent(name: string): Nullable<ISceneComponent>;
  43326. /**
  43327. * @hidden
  43328. * Defines the actions happening before camera updates.
  43329. */
  43330. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43331. /**
  43332. * @hidden
  43333. * Defines the actions happening before clear the canvas.
  43334. */
  43335. _beforeClearStage: Stage<SimpleStageAction>;
  43336. /**
  43337. * @hidden
  43338. * Defines the actions when collecting render targets for the frame.
  43339. */
  43340. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43341. /**
  43342. * @hidden
  43343. * Defines the actions happening for one camera in the frame.
  43344. */
  43345. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43346. /**
  43347. * @hidden
  43348. * Defines the actions happening during the per mesh ready checks.
  43349. */
  43350. _isReadyForMeshStage: Stage<MeshStageAction>;
  43351. /**
  43352. * @hidden
  43353. * Defines the actions happening before evaluate active mesh checks.
  43354. */
  43355. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43356. /**
  43357. * @hidden
  43358. * Defines the actions happening during the evaluate sub mesh checks.
  43359. */
  43360. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43361. /**
  43362. * @hidden
  43363. * Defines the actions happening during the active mesh stage.
  43364. */
  43365. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43366. /**
  43367. * @hidden
  43368. * Defines the actions happening during the per camera render target step.
  43369. */
  43370. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43371. /**
  43372. * @hidden
  43373. * Defines the actions happening just before the active camera is drawing.
  43374. */
  43375. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43376. /**
  43377. * @hidden
  43378. * Defines the actions happening just before a render target is drawing.
  43379. */
  43380. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43381. /**
  43382. * @hidden
  43383. * Defines the actions happening just before a rendering group is drawing.
  43384. */
  43385. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43386. /**
  43387. * @hidden
  43388. * Defines the actions happening just before a mesh is drawing.
  43389. */
  43390. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43391. /**
  43392. * @hidden
  43393. * Defines the actions happening just after a mesh has been drawn.
  43394. */
  43395. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43396. /**
  43397. * @hidden
  43398. * Defines the actions happening just after a rendering group has been drawn.
  43399. */
  43400. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43401. /**
  43402. * @hidden
  43403. * Defines the actions happening just after the active camera has been drawn.
  43404. */
  43405. _afterCameraDrawStage: Stage<CameraStageAction>;
  43406. /**
  43407. * @hidden
  43408. * Defines the actions happening just after a render target has been drawn.
  43409. */
  43410. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43411. /**
  43412. * @hidden
  43413. * Defines the actions happening just after rendering all cameras and computing intersections.
  43414. */
  43415. _afterRenderStage: Stage<SimpleStageAction>;
  43416. /**
  43417. * @hidden
  43418. * Defines the actions happening when a pointer move event happens.
  43419. */
  43420. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43421. /**
  43422. * @hidden
  43423. * Defines the actions happening when a pointer down event happens.
  43424. */
  43425. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43426. /**
  43427. * @hidden
  43428. * Defines the actions happening when a pointer up event happens.
  43429. */
  43430. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43431. /**
  43432. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43433. */
  43434. private geometriesByUniqueId;
  43435. /**
  43436. * Creates a new Scene
  43437. * @param engine defines the engine to use to render this scene
  43438. * @param options defines the scene options
  43439. */
  43440. constructor(engine: Engine, options?: SceneOptions);
  43441. /**
  43442. * Gets a string identifying the name of the class
  43443. * @returns "Scene" string
  43444. */
  43445. getClassName(): string;
  43446. private _defaultMeshCandidates;
  43447. /**
  43448. * @hidden
  43449. */
  43450. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43451. private _defaultSubMeshCandidates;
  43452. /**
  43453. * @hidden
  43454. */
  43455. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43456. /**
  43457. * Sets the default candidate providers for the scene.
  43458. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43459. * and getCollidingSubMeshCandidates to their default function
  43460. */
  43461. setDefaultCandidateProviders(): void;
  43462. /**
  43463. * Gets the mesh that is currently under the pointer
  43464. */
  43465. get meshUnderPointer(): Nullable<AbstractMesh>;
  43466. /**
  43467. * Gets or sets the current on-screen X position of the pointer
  43468. */
  43469. get pointerX(): number;
  43470. set pointerX(value: number);
  43471. /**
  43472. * Gets or sets the current on-screen Y position of the pointer
  43473. */
  43474. get pointerY(): number;
  43475. set pointerY(value: number);
  43476. /**
  43477. * Gets the cached material (ie. the latest rendered one)
  43478. * @returns the cached material
  43479. */
  43480. getCachedMaterial(): Nullable<Material>;
  43481. /**
  43482. * Gets the cached effect (ie. the latest rendered one)
  43483. * @returns the cached effect
  43484. */
  43485. getCachedEffect(): Nullable<Effect>;
  43486. /**
  43487. * Gets the cached visibility state (ie. the latest rendered one)
  43488. * @returns the cached visibility state
  43489. */
  43490. getCachedVisibility(): Nullable<number>;
  43491. /**
  43492. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43493. * @param material defines the current material
  43494. * @param effect defines the current effect
  43495. * @param visibility defines the current visibility state
  43496. * @returns true if one parameter is not cached
  43497. */
  43498. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43499. /**
  43500. * Gets the engine associated with the scene
  43501. * @returns an Engine
  43502. */
  43503. getEngine(): Engine;
  43504. /**
  43505. * Gets the total number of vertices rendered per frame
  43506. * @returns the total number of vertices rendered per frame
  43507. */
  43508. getTotalVertices(): number;
  43509. /**
  43510. * Gets the performance counter for total vertices
  43511. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43512. */
  43513. get totalVerticesPerfCounter(): PerfCounter;
  43514. /**
  43515. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43516. * @returns the total number of active indices rendered per frame
  43517. */
  43518. getActiveIndices(): number;
  43519. /**
  43520. * Gets the performance counter for active indices
  43521. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43522. */
  43523. get totalActiveIndicesPerfCounter(): PerfCounter;
  43524. /**
  43525. * Gets the total number of active particles rendered per frame
  43526. * @returns the total number of active particles rendered per frame
  43527. */
  43528. getActiveParticles(): number;
  43529. /**
  43530. * Gets the performance counter for active particles
  43531. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43532. */
  43533. get activeParticlesPerfCounter(): PerfCounter;
  43534. /**
  43535. * Gets the total number of active bones rendered per frame
  43536. * @returns the total number of active bones rendered per frame
  43537. */
  43538. getActiveBones(): number;
  43539. /**
  43540. * Gets the performance counter for active bones
  43541. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43542. */
  43543. get activeBonesPerfCounter(): PerfCounter;
  43544. /**
  43545. * Gets the array of active meshes
  43546. * @returns an array of AbstractMesh
  43547. */
  43548. getActiveMeshes(): SmartArray<AbstractMesh>;
  43549. /**
  43550. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43551. * @returns a number
  43552. */
  43553. getAnimationRatio(): number;
  43554. /**
  43555. * Gets an unique Id for the current render phase
  43556. * @returns a number
  43557. */
  43558. getRenderId(): number;
  43559. /**
  43560. * Gets an unique Id for the current frame
  43561. * @returns a number
  43562. */
  43563. getFrameId(): number;
  43564. /** Call this function if you want to manually increment the render Id*/
  43565. incrementRenderId(): void;
  43566. private _createUbo;
  43567. /**
  43568. * Use this method to simulate a pointer move on a mesh
  43569. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43570. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43571. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43572. * @returns the current scene
  43573. */
  43574. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43575. /**
  43576. * Use this method to simulate a pointer down on a mesh
  43577. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43578. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43579. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43580. * @returns the current scene
  43581. */
  43582. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43583. /**
  43584. * Use this method to simulate a pointer up on a mesh
  43585. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43586. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43587. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43588. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43589. * @returns the current scene
  43590. */
  43591. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43592. /**
  43593. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43594. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43595. * @returns true if the pointer was captured
  43596. */
  43597. isPointerCaptured(pointerId?: number): boolean;
  43598. /**
  43599. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43600. * @param attachUp defines if you want to attach events to pointerup
  43601. * @param attachDown defines if you want to attach events to pointerdown
  43602. * @param attachMove defines if you want to attach events to pointermove
  43603. */
  43604. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43605. /** Detaches all event handlers*/
  43606. detachControl(): void;
  43607. /**
  43608. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43609. * Delay loaded resources are not taking in account
  43610. * @return true if all required resources are ready
  43611. */
  43612. isReady(): boolean;
  43613. /** Resets all cached information relative to material (including effect and visibility) */
  43614. resetCachedMaterial(): void;
  43615. /**
  43616. * Registers a function to be called before every frame render
  43617. * @param func defines the function to register
  43618. */
  43619. registerBeforeRender(func: () => void): void;
  43620. /**
  43621. * Unregisters a function called before every frame render
  43622. * @param func defines the function to unregister
  43623. */
  43624. unregisterBeforeRender(func: () => void): void;
  43625. /**
  43626. * Registers a function to be called after every frame render
  43627. * @param func defines the function to register
  43628. */
  43629. registerAfterRender(func: () => void): void;
  43630. /**
  43631. * Unregisters a function called after every frame render
  43632. * @param func defines the function to unregister
  43633. */
  43634. unregisterAfterRender(func: () => void): void;
  43635. private _executeOnceBeforeRender;
  43636. /**
  43637. * The provided function will run before render once and will be disposed afterwards.
  43638. * A timeout delay can be provided so that the function will be executed in N ms.
  43639. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43640. * @param func The function to be executed.
  43641. * @param timeout optional delay in ms
  43642. */
  43643. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43644. /** @hidden */
  43645. _addPendingData(data: any): void;
  43646. /** @hidden */
  43647. _removePendingData(data: any): void;
  43648. /**
  43649. * Returns the number of items waiting to be loaded
  43650. * @returns the number of items waiting to be loaded
  43651. */
  43652. getWaitingItemsCount(): number;
  43653. /**
  43654. * Returns a boolean indicating if the scene is still loading data
  43655. */
  43656. get isLoading(): boolean;
  43657. /**
  43658. * Registers a function to be executed when the scene is ready
  43659. * @param {Function} func - the function to be executed
  43660. */
  43661. executeWhenReady(func: () => void): void;
  43662. /**
  43663. * Returns a promise that resolves when the scene is ready
  43664. * @returns A promise that resolves when the scene is ready
  43665. */
  43666. whenReadyAsync(): Promise<void>;
  43667. /** @hidden */
  43668. _checkIsReady(): void;
  43669. /**
  43670. * Gets all animatable attached to the scene
  43671. */
  43672. get animatables(): Animatable[];
  43673. /**
  43674. * Resets the last animation time frame.
  43675. * Useful to override when animations start running when loading a scene for the first time.
  43676. */
  43677. resetLastAnimationTimeFrame(): void;
  43678. /**
  43679. * Gets the current view matrix
  43680. * @returns a Matrix
  43681. */
  43682. getViewMatrix(): Matrix;
  43683. /**
  43684. * Gets the current projection matrix
  43685. * @returns a Matrix
  43686. */
  43687. getProjectionMatrix(): Matrix;
  43688. /**
  43689. * Gets the current transform matrix
  43690. * @returns a Matrix made of View * Projection
  43691. */
  43692. getTransformMatrix(): Matrix;
  43693. /**
  43694. * Sets the current transform matrix
  43695. * @param viewL defines the View matrix to use
  43696. * @param projectionL defines the Projection matrix to use
  43697. * @param viewR defines the right View matrix to use (if provided)
  43698. * @param projectionR defines the right Projection matrix to use (if provided)
  43699. */
  43700. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  43701. /**
  43702. * Gets the uniform buffer used to store scene data
  43703. * @returns a UniformBuffer
  43704. */
  43705. getSceneUniformBuffer(): UniformBuffer;
  43706. /**
  43707. * Gets an unique (relatively to the current scene) Id
  43708. * @returns an unique number for the scene
  43709. */
  43710. getUniqueId(): number;
  43711. /**
  43712. * Add a mesh to the list of scene's meshes
  43713. * @param newMesh defines the mesh to add
  43714. * @param recursive if all child meshes should also be added to the scene
  43715. */
  43716. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  43717. /**
  43718. * Remove a mesh for the list of scene's meshes
  43719. * @param toRemove defines the mesh to remove
  43720. * @param recursive if all child meshes should also be removed from the scene
  43721. * @returns the index where the mesh was in the mesh list
  43722. */
  43723. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  43724. /**
  43725. * Add a transform node to the list of scene's transform nodes
  43726. * @param newTransformNode defines the transform node to add
  43727. */
  43728. addTransformNode(newTransformNode: TransformNode): void;
  43729. /**
  43730. * Remove a transform node for the list of scene's transform nodes
  43731. * @param toRemove defines the transform node to remove
  43732. * @returns the index where the transform node was in the transform node list
  43733. */
  43734. removeTransformNode(toRemove: TransformNode): number;
  43735. /**
  43736. * Remove a skeleton for the list of scene's skeletons
  43737. * @param toRemove defines the skeleton to remove
  43738. * @returns the index where the skeleton was in the skeleton list
  43739. */
  43740. removeSkeleton(toRemove: Skeleton): number;
  43741. /**
  43742. * Remove a morph target for the list of scene's morph targets
  43743. * @param toRemove defines the morph target to remove
  43744. * @returns the index where the morph target was in the morph target list
  43745. */
  43746. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  43747. /**
  43748. * Remove a light for the list of scene's lights
  43749. * @param toRemove defines the light to remove
  43750. * @returns the index where the light was in the light list
  43751. */
  43752. removeLight(toRemove: Light): number;
  43753. /**
  43754. * Remove a camera for the list of scene's cameras
  43755. * @param toRemove defines the camera to remove
  43756. * @returns the index where the camera was in the camera list
  43757. */
  43758. removeCamera(toRemove: Camera): number;
  43759. /**
  43760. * Remove a particle system for the list of scene's particle systems
  43761. * @param toRemove defines the particle system to remove
  43762. * @returns the index where the particle system was in the particle system list
  43763. */
  43764. removeParticleSystem(toRemove: IParticleSystem): number;
  43765. /**
  43766. * Remove a animation for the list of scene's animations
  43767. * @param toRemove defines the animation to remove
  43768. * @returns the index where the animation was in the animation list
  43769. */
  43770. removeAnimation(toRemove: Animation): number;
  43771. /**
  43772. * Will stop the animation of the given target
  43773. * @param target - the target
  43774. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  43775. * @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)
  43776. */
  43777. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  43778. /**
  43779. * Removes the given animation group from this scene.
  43780. * @param toRemove The animation group to remove
  43781. * @returns The index of the removed animation group
  43782. */
  43783. removeAnimationGroup(toRemove: AnimationGroup): number;
  43784. /**
  43785. * Removes the given multi-material from this scene.
  43786. * @param toRemove The multi-material to remove
  43787. * @returns The index of the removed multi-material
  43788. */
  43789. removeMultiMaterial(toRemove: MultiMaterial): number;
  43790. /**
  43791. * Removes the given material from this scene.
  43792. * @param toRemove The material to remove
  43793. * @returns The index of the removed material
  43794. */
  43795. removeMaterial(toRemove: Material): number;
  43796. /**
  43797. * Removes the given action manager from this scene.
  43798. * @param toRemove The action manager to remove
  43799. * @returns The index of the removed action manager
  43800. */
  43801. removeActionManager(toRemove: AbstractActionManager): number;
  43802. /**
  43803. * Removes the given texture from this scene.
  43804. * @param toRemove The texture to remove
  43805. * @returns The index of the removed texture
  43806. */
  43807. removeTexture(toRemove: BaseTexture): number;
  43808. /**
  43809. * Adds the given light to this scene
  43810. * @param newLight The light to add
  43811. */
  43812. addLight(newLight: Light): void;
  43813. /**
  43814. * Sorts the list list based on light priorities
  43815. */
  43816. sortLightsByPriority(): void;
  43817. /**
  43818. * Adds the given camera to this scene
  43819. * @param newCamera The camera to add
  43820. */
  43821. addCamera(newCamera: Camera): void;
  43822. /**
  43823. * Adds the given skeleton to this scene
  43824. * @param newSkeleton The skeleton to add
  43825. */
  43826. addSkeleton(newSkeleton: Skeleton): void;
  43827. /**
  43828. * Adds the given particle system to this scene
  43829. * @param newParticleSystem The particle system to add
  43830. */
  43831. addParticleSystem(newParticleSystem: IParticleSystem): void;
  43832. /**
  43833. * Adds the given animation to this scene
  43834. * @param newAnimation The animation to add
  43835. */
  43836. addAnimation(newAnimation: Animation): void;
  43837. /**
  43838. * Adds the given animation group to this scene.
  43839. * @param newAnimationGroup The animation group to add
  43840. */
  43841. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  43842. /**
  43843. * Adds the given multi-material to this scene
  43844. * @param newMultiMaterial The multi-material to add
  43845. */
  43846. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  43847. /**
  43848. * Adds the given material to this scene
  43849. * @param newMaterial The material to add
  43850. */
  43851. addMaterial(newMaterial: Material): void;
  43852. /**
  43853. * Adds the given morph target to this scene
  43854. * @param newMorphTargetManager The morph target to add
  43855. */
  43856. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  43857. /**
  43858. * Adds the given geometry to this scene
  43859. * @param newGeometry The geometry to add
  43860. */
  43861. addGeometry(newGeometry: Geometry): void;
  43862. /**
  43863. * Adds the given action manager to this scene
  43864. * @param newActionManager The action manager to add
  43865. */
  43866. addActionManager(newActionManager: AbstractActionManager): void;
  43867. /**
  43868. * Adds the given texture to this scene.
  43869. * @param newTexture The texture to add
  43870. */
  43871. addTexture(newTexture: BaseTexture): void;
  43872. /**
  43873. * Switch active camera
  43874. * @param newCamera defines the new active camera
  43875. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  43876. */
  43877. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  43878. /**
  43879. * sets the active camera of the scene using its ID
  43880. * @param id defines the camera's ID
  43881. * @return the new active camera or null if none found.
  43882. */
  43883. setActiveCameraByID(id: string): Nullable<Camera>;
  43884. /**
  43885. * sets the active camera of the scene using its name
  43886. * @param name defines the camera's name
  43887. * @returns the new active camera or null if none found.
  43888. */
  43889. setActiveCameraByName(name: string): Nullable<Camera>;
  43890. /**
  43891. * get an animation group using its name
  43892. * @param name defines the material's name
  43893. * @return the animation group or null if none found.
  43894. */
  43895. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  43896. /**
  43897. * Get a material using its unique id
  43898. * @param uniqueId defines the material's unique id
  43899. * @return the material or null if none found.
  43900. */
  43901. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  43902. /**
  43903. * get a material using its id
  43904. * @param id defines the material's ID
  43905. * @return the material or null if none found.
  43906. */
  43907. getMaterialByID(id: string): Nullable<Material>;
  43908. /**
  43909. * Gets a the last added material using a given id
  43910. * @param id defines the material's ID
  43911. * @return the last material with the given id or null if none found.
  43912. */
  43913. getLastMaterialByID(id: string): Nullable<Material>;
  43914. /**
  43915. * Gets a material using its name
  43916. * @param name defines the material's name
  43917. * @return the material or null if none found.
  43918. */
  43919. getMaterialByName(name: string): Nullable<Material>;
  43920. /**
  43921. * Get a texture using its unique id
  43922. * @param uniqueId defines the texture's unique id
  43923. * @return the texture or null if none found.
  43924. */
  43925. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  43926. /**
  43927. * Gets a camera using its id
  43928. * @param id defines the id to look for
  43929. * @returns the camera or null if not found
  43930. */
  43931. getCameraByID(id: string): Nullable<Camera>;
  43932. /**
  43933. * Gets a camera using its unique id
  43934. * @param uniqueId defines the unique id to look for
  43935. * @returns the camera or null if not found
  43936. */
  43937. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  43938. /**
  43939. * Gets a camera using its name
  43940. * @param name defines the camera's name
  43941. * @return the camera or null if none found.
  43942. */
  43943. getCameraByName(name: string): Nullable<Camera>;
  43944. /**
  43945. * Gets a bone using its id
  43946. * @param id defines the bone's id
  43947. * @return the bone or null if not found
  43948. */
  43949. getBoneByID(id: string): Nullable<Bone>;
  43950. /**
  43951. * Gets a bone using its id
  43952. * @param name defines the bone's name
  43953. * @return the bone or null if not found
  43954. */
  43955. getBoneByName(name: string): Nullable<Bone>;
  43956. /**
  43957. * Gets a light node using its name
  43958. * @param name defines the the light's name
  43959. * @return the light or null if none found.
  43960. */
  43961. getLightByName(name: string): Nullable<Light>;
  43962. /**
  43963. * Gets a light node using its id
  43964. * @param id defines the light's id
  43965. * @return the light or null if none found.
  43966. */
  43967. getLightByID(id: string): Nullable<Light>;
  43968. /**
  43969. * Gets a light node using its scene-generated unique ID
  43970. * @param uniqueId defines the light's unique id
  43971. * @return the light or null if none found.
  43972. */
  43973. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  43974. /**
  43975. * Gets a particle system by id
  43976. * @param id defines the particle system id
  43977. * @return the corresponding system or null if none found
  43978. */
  43979. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  43980. /**
  43981. * Gets a geometry using its ID
  43982. * @param id defines the geometry's id
  43983. * @return the geometry or null if none found.
  43984. */
  43985. getGeometryByID(id: string): Nullable<Geometry>;
  43986. private _getGeometryByUniqueID;
  43987. /**
  43988. * Add a new geometry to this scene
  43989. * @param geometry defines the geometry to be added to the scene.
  43990. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  43991. * @return a boolean defining if the geometry was added or not
  43992. */
  43993. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  43994. /**
  43995. * Removes an existing geometry
  43996. * @param geometry defines the geometry to be removed from the scene
  43997. * @return a boolean defining if the geometry was removed or not
  43998. */
  43999. removeGeometry(geometry: Geometry): boolean;
  44000. /**
  44001. * Gets the list of geometries attached to the scene
  44002. * @returns an array of Geometry
  44003. */
  44004. getGeometries(): Geometry[];
  44005. /**
  44006. * Gets the first added mesh found of a given ID
  44007. * @param id defines the id to search for
  44008. * @return the mesh found or null if not found at all
  44009. */
  44010. getMeshByID(id: string): Nullable<AbstractMesh>;
  44011. /**
  44012. * Gets a list of meshes using their id
  44013. * @param id defines the id to search for
  44014. * @returns a list of meshes
  44015. */
  44016. getMeshesByID(id: string): Array<AbstractMesh>;
  44017. /**
  44018. * Gets the first added transform node found of a given ID
  44019. * @param id defines the id to search for
  44020. * @return the found transform node or null if not found at all.
  44021. */
  44022. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44023. /**
  44024. * Gets a transform node with its auto-generated unique id
  44025. * @param uniqueId efines the unique id to search for
  44026. * @return the found transform node or null if not found at all.
  44027. */
  44028. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44029. /**
  44030. * Gets a list of transform nodes using their id
  44031. * @param id defines the id to search for
  44032. * @returns a list of transform nodes
  44033. */
  44034. getTransformNodesByID(id: string): Array<TransformNode>;
  44035. /**
  44036. * Gets a mesh with its auto-generated unique id
  44037. * @param uniqueId defines the unique id to search for
  44038. * @return the found mesh or null if not found at all.
  44039. */
  44040. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44041. /**
  44042. * Gets a the last added mesh using a given id
  44043. * @param id defines the id to search for
  44044. * @return the found mesh or null if not found at all.
  44045. */
  44046. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44047. /**
  44048. * Gets a the last added node (Mesh, Camera, Light) using a given id
  44049. * @param id defines the id to search for
  44050. * @return the found node or null if not found at all
  44051. */
  44052. getLastEntryByID(id: string): Nullable<Node>;
  44053. /**
  44054. * Gets a node (Mesh, Camera, Light) using a given id
  44055. * @param id defines the id to search for
  44056. * @return the found node or null if not found at all
  44057. */
  44058. getNodeByID(id: string): Nullable<Node>;
  44059. /**
  44060. * Gets a node (Mesh, Camera, Light) using a given name
  44061. * @param name defines the name to search for
  44062. * @return the found node or null if not found at all.
  44063. */
  44064. getNodeByName(name: string): Nullable<Node>;
  44065. /**
  44066. * Gets a mesh using a given name
  44067. * @param name defines the name to search for
  44068. * @return the found mesh or null if not found at all.
  44069. */
  44070. getMeshByName(name: string): Nullable<AbstractMesh>;
  44071. /**
  44072. * Gets a transform node using a given name
  44073. * @param name defines the name to search for
  44074. * @return the found transform node or null if not found at all.
  44075. */
  44076. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44077. /**
  44078. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  44079. * @param id defines the id to search for
  44080. * @return the found skeleton or null if not found at all.
  44081. */
  44082. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44083. /**
  44084. * Gets a skeleton using a given auto generated unique id
  44085. * @param uniqueId defines the unique id to search for
  44086. * @return the found skeleton or null if not found at all.
  44087. */
  44088. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44089. /**
  44090. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44091. * @param id defines the id to search for
  44092. * @return the found skeleton or null if not found at all.
  44093. */
  44094. getSkeletonById(id: string): Nullable<Skeleton>;
  44095. /**
  44096. * Gets a skeleton using a given name
  44097. * @param name defines the name to search for
  44098. * @return the found skeleton or null if not found at all.
  44099. */
  44100. getSkeletonByName(name: string): Nullable<Skeleton>;
  44101. /**
  44102. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44103. * @param id defines the id to search for
  44104. * @return the found morph target manager or null if not found at all.
  44105. */
  44106. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44107. /**
  44108. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44109. * @param id defines the id to search for
  44110. * @return the found morph target or null if not found at all.
  44111. */
  44112. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44113. /**
  44114. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  44115. * @param name defines the name to search for
  44116. * @return the found morph target or null if not found at all.
  44117. */
  44118. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44119. /**
  44120. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44121. * @param name defines the name to search for
  44122. * @return the found post process or null if not found at all.
  44123. */
  44124. getPostProcessByName(name: string): Nullable<PostProcess>;
  44125. /**
  44126. * Gets a boolean indicating if the given mesh is active
  44127. * @param mesh defines the mesh to look for
  44128. * @returns true if the mesh is in the active list
  44129. */
  44130. isActiveMesh(mesh: AbstractMesh): boolean;
  44131. /**
  44132. * Return a unique id as a string which can serve as an identifier for the scene
  44133. */
  44134. get uid(): string;
  44135. /**
  44136. * Add an externaly attached data from its key.
  44137. * This method call will fail and return false, if such key already exists.
  44138. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44139. * @param key the unique key that identifies the data
  44140. * @param data the data object to associate to the key for this Engine instance
  44141. * @return true if no such key were already present and the data was added successfully, false otherwise
  44142. */
  44143. addExternalData<T>(key: string, data: T): boolean;
  44144. /**
  44145. * Get an externaly attached data from its key
  44146. * @param key the unique key that identifies the data
  44147. * @return the associated data, if present (can be null), or undefined if not present
  44148. */
  44149. getExternalData<T>(key: string): Nullable<T>;
  44150. /**
  44151. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44152. * @param key the unique key that identifies the data
  44153. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44154. * @return the associated data, can be null if the factory returned null.
  44155. */
  44156. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44157. /**
  44158. * Remove an externaly attached data from the Engine instance
  44159. * @param key the unique key that identifies the data
  44160. * @return true if the data was successfully removed, false if it doesn't exist
  44161. */
  44162. removeExternalData(key: string): boolean;
  44163. private _evaluateSubMesh;
  44164. /**
  44165. * Clear the processed materials smart array preventing retention point in material dispose.
  44166. */
  44167. freeProcessedMaterials(): void;
  44168. private _preventFreeActiveMeshesAndRenderingGroups;
  44169. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44170. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44171. * when disposing several meshes in a row or a hierarchy of meshes.
  44172. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44173. */
  44174. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44175. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44176. /**
  44177. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44178. */
  44179. freeActiveMeshes(): void;
  44180. /**
  44181. * Clear the info related to rendering groups preventing retention points during dispose.
  44182. */
  44183. freeRenderingGroups(): void;
  44184. /** @hidden */
  44185. _isInIntermediateRendering(): boolean;
  44186. /**
  44187. * Lambda returning the list of potentially active meshes.
  44188. */
  44189. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44190. /**
  44191. * Lambda returning the list of potentially active sub meshes.
  44192. */
  44193. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44194. /**
  44195. * Lambda returning the list of potentially intersecting sub meshes.
  44196. */
  44197. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44198. /**
  44199. * Lambda returning the list of potentially colliding sub meshes.
  44200. */
  44201. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44202. private _activeMeshesFrozen;
  44203. private _skipEvaluateActiveMeshesCompletely;
  44204. /**
  44205. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44206. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44207. * @param onSuccess optional success callback
  44208. * @param onError optional error callback
  44209. * @returns the current scene
  44210. */
  44211. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44212. /**
  44213. * Use this function to restart evaluating active meshes on every frame
  44214. * @returns the current scene
  44215. */
  44216. unfreezeActiveMeshes(): Scene;
  44217. private _evaluateActiveMeshes;
  44218. private _activeMesh;
  44219. /**
  44220. * Update the transform matrix to update from the current active camera
  44221. * @param force defines a boolean used to force the update even if cache is up to date
  44222. */
  44223. updateTransformMatrix(force?: boolean): void;
  44224. private _bindFrameBuffer;
  44225. /** @hidden */
  44226. _allowPostProcessClearColor: boolean;
  44227. /** @hidden */
  44228. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44229. private _processSubCameras;
  44230. private _checkIntersections;
  44231. /** @hidden */
  44232. _advancePhysicsEngineStep(step: number): void;
  44233. /**
  44234. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44235. */
  44236. getDeterministicFrameTime: () => number;
  44237. /** @hidden */
  44238. _animate(): void;
  44239. /** Execute all animations (for a frame) */
  44240. animate(): void;
  44241. /**
  44242. * Render the scene
  44243. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44244. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44245. */
  44246. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44247. /**
  44248. * Freeze all materials
  44249. * A frozen material will not be updatable but should be faster to render
  44250. */
  44251. freezeMaterials(): void;
  44252. /**
  44253. * Unfreeze all materials
  44254. * A frozen material will not be updatable but should be faster to render
  44255. */
  44256. unfreezeMaterials(): void;
  44257. /**
  44258. * Releases all held ressources
  44259. */
  44260. dispose(): void;
  44261. /**
  44262. * Gets if the scene is already disposed
  44263. */
  44264. get isDisposed(): boolean;
  44265. /**
  44266. * Call this function to reduce memory footprint of the scene.
  44267. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44268. */
  44269. clearCachedVertexData(): void;
  44270. /**
  44271. * This function will remove the local cached buffer data from texture.
  44272. * It will save memory but will prevent the texture from being rebuilt
  44273. */
  44274. cleanCachedTextureBuffer(): void;
  44275. /**
  44276. * Get the world extend vectors with an optional filter
  44277. *
  44278. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44279. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44280. */
  44281. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44282. min: Vector3;
  44283. max: Vector3;
  44284. };
  44285. /**
  44286. * Creates a ray that can be used to pick in the scene
  44287. * @param x defines the x coordinate of the origin (on-screen)
  44288. * @param y defines the y coordinate of the origin (on-screen)
  44289. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44290. * @param camera defines the camera to use for the picking
  44291. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44292. * @returns a Ray
  44293. */
  44294. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44295. /**
  44296. * Creates a ray that can be used to pick in the scene
  44297. * @param x defines the x coordinate of the origin (on-screen)
  44298. * @param y defines the y coordinate of the origin (on-screen)
  44299. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44300. * @param result defines the ray where to store the picking ray
  44301. * @param camera defines the camera to use for the picking
  44302. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44303. * @returns the current scene
  44304. */
  44305. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44306. /**
  44307. * Creates a ray that can be used to pick in the scene
  44308. * @param x defines the x coordinate of the origin (on-screen)
  44309. * @param y defines the y coordinate of the origin (on-screen)
  44310. * @param camera defines the camera to use for the picking
  44311. * @returns a Ray
  44312. */
  44313. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44314. /**
  44315. * Creates a ray that can be used to pick in the scene
  44316. * @param x defines the x coordinate of the origin (on-screen)
  44317. * @param y defines the y coordinate of the origin (on-screen)
  44318. * @param result defines the ray where to store the picking ray
  44319. * @param camera defines the camera to use for the picking
  44320. * @returns the current scene
  44321. */
  44322. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44323. /** Launch a ray to try to pick a mesh in the scene
  44324. * @param x position on screen
  44325. * @param y position on screen
  44326. * @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
  44327. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44328. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44329. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44330. * @returns a PickingInfo
  44331. */
  44332. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44333. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44334. * @param x position on screen
  44335. * @param y position on screen
  44336. * @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
  44337. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44338. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44339. * @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)
  44340. */
  44341. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44342. /** Use the given ray to pick a mesh in the scene
  44343. * @param ray The ray to use to pick meshes
  44344. * @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
  44345. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44346. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44347. * @returns a PickingInfo
  44348. */
  44349. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44350. /**
  44351. * Launch a ray to try to pick a mesh in the scene
  44352. * @param x X position on screen
  44353. * @param y Y position on screen
  44354. * @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
  44355. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44356. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44357. * @returns an array of PickingInfo
  44358. */
  44359. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44360. /**
  44361. * Launch a ray to try to pick a mesh in the scene
  44362. * @param ray Ray to use
  44363. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  44364. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44365. * @returns an array of PickingInfo
  44366. */
  44367. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44368. /**
  44369. * Force the value of meshUnderPointer
  44370. * @param mesh defines the mesh to use
  44371. * @param pointerId optional pointer id when using more than one pointer
  44372. */
  44373. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44374. /**
  44375. * Gets the mesh under the pointer
  44376. * @returns a Mesh or null if no mesh is under the pointer
  44377. */
  44378. getPointerOverMesh(): Nullable<AbstractMesh>;
  44379. /** @hidden */
  44380. _rebuildGeometries(): void;
  44381. /** @hidden */
  44382. _rebuildTextures(): void;
  44383. private _getByTags;
  44384. /**
  44385. * Get a list of meshes by tags
  44386. * @param tagsQuery defines the tags query to use
  44387. * @param forEach defines a predicate used to filter results
  44388. * @returns an array of Mesh
  44389. */
  44390. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44391. /**
  44392. * Get a list of cameras by tags
  44393. * @param tagsQuery defines the tags query to use
  44394. * @param forEach defines a predicate used to filter results
  44395. * @returns an array of Camera
  44396. */
  44397. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44398. /**
  44399. * Get a list of lights by tags
  44400. * @param tagsQuery defines the tags query to use
  44401. * @param forEach defines a predicate used to filter results
  44402. * @returns an array of Light
  44403. */
  44404. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44405. /**
  44406. * Get a list of materials by tags
  44407. * @param tagsQuery defines the tags query to use
  44408. * @param forEach defines a predicate used to filter results
  44409. * @returns an array of Material
  44410. */
  44411. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44412. /**
  44413. * Get a list of transform nodes by tags
  44414. * @param tagsQuery defines the tags query to use
  44415. * @param forEach defines a predicate used to filter results
  44416. * @returns an array of TransformNode
  44417. */
  44418. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44419. /**
  44420. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44421. * This allowed control for front to back rendering or reversly depending of the special needs.
  44422. *
  44423. * @param renderingGroupId The rendering group id corresponding to its index
  44424. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44425. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44426. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44427. */
  44428. 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;
  44429. /**
  44430. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44431. *
  44432. * @param renderingGroupId The rendering group id corresponding to its index
  44433. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44434. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44435. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44436. */
  44437. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44438. /**
  44439. * Gets the current auto clear configuration for one rendering group of the rendering
  44440. * manager.
  44441. * @param index the rendering group index to get the information for
  44442. * @returns The auto clear setup for the requested rendering group
  44443. */
  44444. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44445. private _blockMaterialDirtyMechanism;
  44446. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44447. get blockMaterialDirtyMechanism(): boolean;
  44448. set blockMaterialDirtyMechanism(value: boolean);
  44449. /**
  44450. * Will flag all materials as dirty to trigger new shader compilation
  44451. * @param flag defines the flag used to specify which material part must be marked as dirty
  44452. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44453. */
  44454. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44455. /** @hidden */
  44456. _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;
  44457. /** @hidden */
  44458. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44459. /** @hidden */
  44460. _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;
  44461. /** @hidden */
  44462. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44463. /** @hidden */
  44464. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44465. /** @hidden */
  44466. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44467. }
  44468. }
  44469. declare module BABYLON {
  44470. /**
  44471. * Set of assets to keep when moving a scene into an asset container.
  44472. */
  44473. export class KeepAssets extends AbstractScene {
  44474. }
  44475. /**
  44476. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44477. */
  44478. export class InstantiatedEntries {
  44479. /**
  44480. * List of new root nodes (eg. nodes with no parent)
  44481. */
  44482. rootNodes: TransformNode[];
  44483. /**
  44484. * List of new skeletons
  44485. */
  44486. skeletons: Skeleton[];
  44487. /**
  44488. * List of new animation groups
  44489. */
  44490. animationGroups: AnimationGroup[];
  44491. }
  44492. /**
  44493. * Container with a set of assets that can be added or removed from a scene.
  44494. */
  44495. export class AssetContainer extends AbstractScene {
  44496. private _wasAddedToScene;
  44497. /**
  44498. * The scene the AssetContainer belongs to.
  44499. */
  44500. scene: Scene;
  44501. /**
  44502. * Instantiates an AssetContainer.
  44503. * @param scene The scene the AssetContainer belongs to.
  44504. */
  44505. constructor(scene: Scene);
  44506. /**
  44507. * Instantiate or clone all meshes and add the new ones to the scene.
  44508. * Skeletons and animation groups will all be cloned
  44509. * @param nameFunction defines an optional function used to get new names for clones
  44510. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44511. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44512. */
  44513. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44514. /**
  44515. * Adds all the assets from the container to the scene.
  44516. */
  44517. addAllToScene(): void;
  44518. /**
  44519. * Removes all the assets in the container from the scene
  44520. */
  44521. removeAllFromScene(): void;
  44522. /**
  44523. * Disposes all the assets in the container
  44524. */
  44525. dispose(): void;
  44526. private _moveAssets;
  44527. /**
  44528. * Removes all the assets contained in the scene and adds them to the container.
  44529. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44530. */
  44531. moveAllFromScene(keepAssets?: KeepAssets): void;
  44532. /**
  44533. * 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.
  44534. * @returns the root mesh
  44535. */
  44536. createRootMesh(): Mesh;
  44537. /**
  44538. * Merge animations (direct and animation groups) from this asset container into a scene
  44539. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44540. * @param animatables set of animatables to retarget to a node from the scene
  44541. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44542. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44543. */
  44544. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44545. }
  44546. }
  44547. declare module BABYLON {
  44548. /**
  44549. * Defines how the parser contract is defined.
  44550. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44551. */
  44552. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44553. /**
  44554. * Defines how the individual parser contract is defined.
  44555. * These parser can parse an individual asset
  44556. */
  44557. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44558. /**
  44559. * Base class of the scene acting as a container for the different elements composing a scene.
  44560. * This class is dynamically extended by the different components of the scene increasing
  44561. * flexibility and reducing coupling
  44562. */
  44563. export abstract class AbstractScene {
  44564. /**
  44565. * Stores the list of available parsers in the application.
  44566. */
  44567. private static _BabylonFileParsers;
  44568. /**
  44569. * Stores the list of available individual parsers in the application.
  44570. */
  44571. private static _IndividualBabylonFileParsers;
  44572. /**
  44573. * Adds a parser in the list of available ones
  44574. * @param name Defines the name of the parser
  44575. * @param parser Defines the parser to add
  44576. */
  44577. static AddParser(name: string, parser: BabylonFileParser): void;
  44578. /**
  44579. * Gets a general parser from the list of avaialble ones
  44580. * @param name Defines the name of the parser
  44581. * @returns the requested parser or null
  44582. */
  44583. static GetParser(name: string): Nullable<BabylonFileParser>;
  44584. /**
  44585. * Adds n individual parser in the list of available ones
  44586. * @param name Defines the name of the parser
  44587. * @param parser Defines the parser to add
  44588. */
  44589. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44590. /**
  44591. * Gets an individual parser from the list of avaialble ones
  44592. * @param name Defines the name of the parser
  44593. * @returns the requested parser or null
  44594. */
  44595. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44596. /**
  44597. * Parser json data and populate both a scene and its associated container object
  44598. * @param jsonData Defines the data to parse
  44599. * @param scene Defines the scene to parse the data for
  44600. * @param container Defines the container attached to the parsing sequence
  44601. * @param rootUrl Defines the root url of the data
  44602. */
  44603. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44604. /**
  44605. * Gets the list of root nodes (ie. nodes with no parent)
  44606. */
  44607. rootNodes: Node[];
  44608. /** All of the cameras added to this scene
  44609. * @see https://doc.babylonjs.com/babylon101/cameras
  44610. */
  44611. cameras: Camera[];
  44612. /**
  44613. * All of the lights added to this scene
  44614. * @see https://doc.babylonjs.com/babylon101/lights
  44615. */
  44616. lights: Light[];
  44617. /**
  44618. * All of the (abstract) meshes added to this scene
  44619. */
  44620. meshes: AbstractMesh[];
  44621. /**
  44622. * The list of skeletons added to the scene
  44623. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44624. */
  44625. skeletons: Skeleton[];
  44626. /**
  44627. * All of the particle systems added to this scene
  44628. * @see https://doc.babylonjs.com/babylon101/particles
  44629. */
  44630. particleSystems: IParticleSystem[];
  44631. /**
  44632. * Gets a list of Animations associated with the scene
  44633. */
  44634. animations: Animation[];
  44635. /**
  44636. * All of the animation groups added to this scene
  44637. * @see https://doc.babylonjs.com/how_to/group
  44638. */
  44639. animationGroups: AnimationGroup[];
  44640. /**
  44641. * All of the multi-materials added to this scene
  44642. * @see https://doc.babylonjs.com/how_to/multi_materials
  44643. */
  44644. multiMaterials: MultiMaterial[];
  44645. /**
  44646. * All of the materials added to this scene
  44647. * In the context of a Scene, it is not supposed to be modified manually.
  44648. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44649. * Note also that the order of the Material within the array is not significant and might change.
  44650. * @see https://doc.babylonjs.com/babylon101/materials
  44651. */
  44652. materials: Material[];
  44653. /**
  44654. * The list of morph target managers added to the scene
  44655. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44656. */
  44657. morphTargetManagers: MorphTargetManager[];
  44658. /**
  44659. * The list of geometries used in the scene.
  44660. */
  44661. geometries: Geometry[];
  44662. /**
  44663. * All of the tranform nodes added to this scene
  44664. * In the context of a Scene, it is not supposed to be modified manually.
  44665. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44666. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44667. * @see https://doc.babylonjs.com/how_to/transformnode
  44668. */
  44669. transformNodes: TransformNode[];
  44670. /**
  44671. * ActionManagers available on the scene.
  44672. */
  44673. actionManagers: AbstractActionManager[];
  44674. /**
  44675. * Textures to keep.
  44676. */
  44677. textures: BaseTexture[];
  44678. /** @hidden */
  44679. protected _environmentTexture: Nullable<BaseTexture>;
  44680. /**
  44681. * Texture used in all pbr material as the reflection texture.
  44682. * As in the majority of the scene they are the same (exception for multi room and so on),
  44683. * this is easier to reference from here than from all the materials.
  44684. */
  44685. get environmentTexture(): Nullable<BaseTexture>;
  44686. set environmentTexture(value: Nullable<BaseTexture>);
  44687. /**
  44688. * The list of postprocesses added to the scene
  44689. */
  44690. postProcesses: PostProcess[];
  44691. /**
  44692. * @returns all meshes, lights, cameras, transformNodes and bones
  44693. */
  44694. getNodes(): Array<Node>;
  44695. }
  44696. }
  44697. declare module BABYLON {
  44698. /**
  44699. * Interface used to define options for Sound class
  44700. */
  44701. export interface ISoundOptions {
  44702. /**
  44703. * Does the sound autoplay once loaded.
  44704. */
  44705. autoplay?: boolean;
  44706. /**
  44707. * Does the sound loop after it finishes playing once.
  44708. */
  44709. loop?: boolean;
  44710. /**
  44711. * Sound's volume
  44712. */
  44713. volume?: number;
  44714. /**
  44715. * Is it a spatial sound?
  44716. */
  44717. spatialSound?: boolean;
  44718. /**
  44719. * Maximum distance to hear that sound
  44720. */
  44721. maxDistance?: number;
  44722. /**
  44723. * Uses user defined attenuation function
  44724. */
  44725. useCustomAttenuation?: boolean;
  44726. /**
  44727. * Define the roll off factor of spatial sounds.
  44728. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44729. */
  44730. rolloffFactor?: number;
  44731. /**
  44732. * Define the reference distance the sound should be heard perfectly.
  44733. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44734. */
  44735. refDistance?: number;
  44736. /**
  44737. * Define the distance attenuation model the sound will follow.
  44738. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44739. */
  44740. distanceModel?: string;
  44741. /**
  44742. * Defines the playback speed (1 by default)
  44743. */
  44744. playbackRate?: number;
  44745. /**
  44746. * Defines if the sound is from a streaming source
  44747. */
  44748. streaming?: boolean;
  44749. /**
  44750. * Defines an optional length (in seconds) inside the sound file
  44751. */
  44752. length?: number;
  44753. /**
  44754. * Defines an optional offset (in seconds) inside the sound file
  44755. */
  44756. offset?: number;
  44757. /**
  44758. * If true, URLs will not be required to state the audio file codec to use.
  44759. */
  44760. skipCodecCheck?: boolean;
  44761. }
  44762. }
  44763. declare module BABYLON {
  44764. /**
  44765. * Defines a sound that can be played in the application.
  44766. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  44767. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44768. */
  44769. export class Sound {
  44770. /**
  44771. * The name of the sound in the scene.
  44772. */
  44773. name: string;
  44774. /**
  44775. * Does the sound autoplay once loaded.
  44776. */
  44777. autoplay: boolean;
  44778. /**
  44779. * Does the sound loop after it finishes playing once.
  44780. */
  44781. loop: boolean;
  44782. /**
  44783. * Does the sound use a custom attenuation curve to simulate the falloff
  44784. * happening when the source gets further away from the camera.
  44785. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44786. */
  44787. useCustomAttenuation: boolean;
  44788. /**
  44789. * The sound track id this sound belongs to.
  44790. */
  44791. soundTrackId: number;
  44792. /**
  44793. * Is this sound currently played.
  44794. */
  44795. isPlaying: boolean;
  44796. /**
  44797. * Is this sound currently paused.
  44798. */
  44799. isPaused: boolean;
  44800. /**
  44801. * Does this sound enables spatial sound.
  44802. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44803. */
  44804. spatialSound: boolean;
  44805. /**
  44806. * Define the reference distance the sound should be heard perfectly.
  44807. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44808. */
  44809. refDistance: number;
  44810. /**
  44811. * Define the roll off factor of spatial sounds.
  44812. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44813. */
  44814. rolloffFactor: number;
  44815. /**
  44816. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  44817. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44818. */
  44819. maxDistance: number;
  44820. /**
  44821. * Define the distance attenuation model the sound will follow.
  44822. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44823. */
  44824. distanceModel: string;
  44825. /**
  44826. * @hidden
  44827. * Back Compat
  44828. **/
  44829. onended: () => any;
  44830. /**
  44831. * Gets or sets an object used to store user defined information for the sound.
  44832. */
  44833. metadata: any;
  44834. /**
  44835. * Observable event when the current playing sound finishes.
  44836. */
  44837. onEndedObservable: Observable<Sound>;
  44838. /**
  44839. * Gets the current time for the sound.
  44840. */
  44841. get currentTime(): number;
  44842. private _panningModel;
  44843. private _playbackRate;
  44844. private _streaming;
  44845. private _startTime;
  44846. private _startOffset;
  44847. private _position;
  44848. /** @hidden */
  44849. _positionInEmitterSpace: boolean;
  44850. private _localDirection;
  44851. private _volume;
  44852. private _isReadyToPlay;
  44853. private _isDirectional;
  44854. private _readyToPlayCallback;
  44855. private _audioBuffer;
  44856. private _soundSource;
  44857. private _streamingSource;
  44858. private _soundPanner;
  44859. private _soundGain;
  44860. private _inputAudioNode;
  44861. private _outputAudioNode;
  44862. private _coneInnerAngle;
  44863. private _coneOuterAngle;
  44864. private _coneOuterGain;
  44865. private _scene;
  44866. private _connectedTransformNode;
  44867. private _customAttenuationFunction;
  44868. private _registerFunc;
  44869. private _isOutputConnected;
  44870. private _htmlAudioElement;
  44871. private _urlType;
  44872. private _length?;
  44873. private _offset?;
  44874. /** @hidden */
  44875. static _SceneComponentInitialization: (scene: Scene) => void;
  44876. /**
  44877. * Create a sound and attach it to a scene
  44878. * @param name Name of your sound
  44879. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  44880. * @param scene defines the scene the sound belongs to
  44881. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  44882. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  44883. */
  44884. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  44885. /**
  44886. * Release the sound and its associated resources
  44887. */
  44888. dispose(): void;
  44889. /**
  44890. * Gets if the sounds is ready to be played or not.
  44891. * @returns true if ready, otherwise false
  44892. */
  44893. isReady(): boolean;
  44894. private _soundLoaded;
  44895. /**
  44896. * Sets the data of the sound from an audiobuffer
  44897. * @param audioBuffer The audioBuffer containing the data
  44898. */
  44899. setAudioBuffer(audioBuffer: AudioBuffer): void;
  44900. /**
  44901. * Updates the current sounds options such as maxdistance, loop...
  44902. * @param options A JSON object containing values named as the object properties
  44903. */
  44904. updateOptions(options: ISoundOptions): void;
  44905. private _createSpatialParameters;
  44906. private _updateSpatialParameters;
  44907. /**
  44908. * Switch the panning model to HRTF:
  44909. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  44910. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44911. */
  44912. switchPanningModelToHRTF(): void;
  44913. /**
  44914. * Switch the panning model to Equal Power:
  44915. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  44916. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44917. */
  44918. switchPanningModelToEqualPower(): void;
  44919. private _switchPanningModel;
  44920. /**
  44921. * Connect this sound to a sound track audio node like gain...
  44922. * @param soundTrackAudioNode the sound track audio node to connect to
  44923. */
  44924. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  44925. /**
  44926. * Transform this sound into a directional source
  44927. * @param coneInnerAngle Size of the inner cone in degree
  44928. * @param coneOuterAngle Size of the outer cone in degree
  44929. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  44930. */
  44931. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  44932. /**
  44933. * Gets or sets the inner angle for the directional cone.
  44934. */
  44935. get directionalConeInnerAngle(): number;
  44936. /**
  44937. * Gets or sets the inner angle for the directional cone.
  44938. */
  44939. set directionalConeInnerAngle(value: number);
  44940. /**
  44941. * Gets or sets the outer angle for the directional cone.
  44942. */
  44943. get directionalConeOuterAngle(): number;
  44944. /**
  44945. * Gets or sets the outer angle for the directional cone.
  44946. */
  44947. set directionalConeOuterAngle(value: number);
  44948. /**
  44949. * Sets the position of the emitter if spatial sound is enabled
  44950. * @param newPosition Defines the new posisiton
  44951. */
  44952. setPosition(newPosition: Vector3): void;
  44953. /**
  44954. * Sets the local direction of the emitter if spatial sound is enabled
  44955. * @param newLocalDirection Defines the new local direction
  44956. */
  44957. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  44958. private _updateDirection;
  44959. /** @hidden */
  44960. updateDistanceFromListener(): void;
  44961. /**
  44962. * Sets a new custom attenuation function for the sound.
  44963. * @param callback Defines the function used for the attenuation
  44964. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44965. */
  44966. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  44967. /**
  44968. * Play the sound
  44969. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  44970. * @param offset (optional) Start the sound at a specific time in seconds
  44971. * @param length (optional) Sound duration (in seconds)
  44972. */
  44973. play(time?: number, offset?: number, length?: number): void;
  44974. private _onended;
  44975. /**
  44976. * Stop the sound
  44977. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  44978. */
  44979. stop(time?: number): void;
  44980. /**
  44981. * Put the sound in pause
  44982. */
  44983. pause(): void;
  44984. /**
  44985. * Sets a dedicated volume for this sounds
  44986. * @param newVolume Define the new volume of the sound
  44987. * @param time Define time for gradual change to new volume
  44988. */
  44989. setVolume(newVolume: number, time?: number): void;
  44990. /**
  44991. * Set the sound play back rate
  44992. * @param newPlaybackRate Define the playback rate the sound should be played at
  44993. */
  44994. setPlaybackRate(newPlaybackRate: number): void;
  44995. /**
  44996. * Gets the volume of the sound.
  44997. * @returns the volume of the sound
  44998. */
  44999. getVolume(): number;
  45000. /**
  45001. * Attach the sound to a dedicated mesh
  45002. * @param transformNode The transform node to connect the sound with
  45003. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45004. */
  45005. attachToMesh(transformNode: TransformNode): void;
  45006. /**
  45007. * Detach the sound from the previously attached mesh
  45008. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45009. */
  45010. detachFromMesh(): void;
  45011. private _onRegisterAfterWorldMatrixUpdate;
  45012. /**
  45013. * Clone the current sound in the scene.
  45014. * @returns the new sound clone
  45015. */
  45016. clone(): Nullable<Sound>;
  45017. /**
  45018. * Gets the current underlying audio buffer containing the data
  45019. * @returns the audio buffer
  45020. */
  45021. getAudioBuffer(): Nullable<AudioBuffer>;
  45022. /**
  45023. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45024. * @returns the source node
  45025. */
  45026. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45027. /**
  45028. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45029. * @returns the gain node
  45030. */
  45031. getSoundGain(): Nullable<GainNode>;
  45032. /**
  45033. * Serializes the Sound in a JSON representation
  45034. * @returns the JSON representation of the sound
  45035. */
  45036. serialize(): any;
  45037. /**
  45038. * Parse a JSON representation of a sound to innstantiate in a given scene
  45039. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45040. * @param scene Define the scene the new parsed sound should be created in
  45041. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45042. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45043. * @returns the newly parsed sound
  45044. */
  45045. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45046. }
  45047. }
  45048. declare module BABYLON {
  45049. /**
  45050. * This defines an action helpful to play a defined sound on a triggered action.
  45051. */
  45052. export class PlaySoundAction extends Action {
  45053. private _sound;
  45054. /**
  45055. * Instantiate the action
  45056. * @param triggerOptions defines the trigger options
  45057. * @param sound defines the sound to play
  45058. * @param condition defines the trigger related conditions
  45059. */
  45060. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45061. /** @hidden */
  45062. _prepare(): void;
  45063. /**
  45064. * Execute the action and play the sound.
  45065. */
  45066. execute(): void;
  45067. /**
  45068. * Serializes the actions and its related information.
  45069. * @param parent defines the object to serialize in
  45070. * @returns the serialized object
  45071. */
  45072. serialize(parent: any): any;
  45073. }
  45074. /**
  45075. * This defines an action helpful to stop a defined sound on a triggered action.
  45076. */
  45077. export class StopSoundAction extends Action {
  45078. private _sound;
  45079. /**
  45080. * Instantiate the action
  45081. * @param triggerOptions defines the trigger options
  45082. * @param sound defines the sound to stop
  45083. * @param condition defines the trigger related conditions
  45084. */
  45085. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45086. /** @hidden */
  45087. _prepare(): void;
  45088. /**
  45089. * Execute the action and stop the sound.
  45090. */
  45091. execute(): void;
  45092. /**
  45093. * Serializes the actions and its related information.
  45094. * @param parent defines the object to serialize in
  45095. * @returns the serialized object
  45096. */
  45097. serialize(parent: any): any;
  45098. }
  45099. }
  45100. declare module BABYLON {
  45101. /**
  45102. * This defines an action responsible to change the value of a property
  45103. * by interpolating between its current value and the newly set one once triggered.
  45104. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45105. */
  45106. export class InterpolateValueAction extends Action {
  45107. /**
  45108. * Defines the path of the property where the value should be interpolated
  45109. */
  45110. propertyPath: string;
  45111. /**
  45112. * Defines the target value at the end of the interpolation.
  45113. */
  45114. value: any;
  45115. /**
  45116. * Defines the time it will take for the property to interpolate to the value.
  45117. */
  45118. duration: number;
  45119. /**
  45120. * Defines if the other scene animations should be stopped when the action has been triggered
  45121. */
  45122. stopOtherAnimations?: boolean;
  45123. /**
  45124. * Defines a callback raised once the interpolation animation has been done.
  45125. */
  45126. onInterpolationDone?: () => void;
  45127. /**
  45128. * Observable triggered once the interpolation animation has been done.
  45129. */
  45130. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45131. private _target;
  45132. private _effectiveTarget;
  45133. private _property;
  45134. /**
  45135. * Instantiate the action
  45136. * @param triggerOptions defines the trigger options
  45137. * @param target defines the object containing the value to interpolate
  45138. * @param propertyPath defines the path to the property in the target object
  45139. * @param value defines the target value at the end of the interpolation
  45140. * @param duration deines the time it will take for the property to interpolate to the value.
  45141. * @param condition defines the trigger related conditions
  45142. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45143. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45144. */
  45145. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45146. /** @hidden */
  45147. _prepare(): void;
  45148. /**
  45149. * Execute the action starts the value interpolation.
  45150. */
  45151. execute(): void;
  45152. /**
  45153. * Serializes the actions and its related information.
  45154. * @param parent defines the object to serialize in
  45155. * @returns the serialized object
  45156. */
  45157. serialize(parent: any): any;
  45158. }
  45159. }
  45160. declare module BABYLON {
  45161. /**
  45162. * This represents the default audio engine used in babylon.
  45163. * It is responsible to play, synchronize and analyse sounds throughout the application.
  45164. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45165. */
  45166. export class AudioEngine implements IAudioEngine {
  45167. private _audioContext;
  45168. private _audioContextInitialized;
  45169. private _muteButton;
  45170. private _hostElement;
  45171. /**
  45172. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  45173. */
  45174. canUseWebAudio: boolean;
  45175. /**
  45176. * The master gain node defines the global audio volume of your audio engine.
  45177. */
  45178. masterGain: GainNode;
  45179. /**
  45180. * Defines if Babylon should emit a warning if WebAudio is not supported.
  45181. * @ignoreNaming
  45182. */
  45183. WarnedWebAudioUnsupported: boolean;
  45184. /**
  45185. * Gets whether or not mp3 are supported by your browser.
  45186. */
  45187. isMP3supported: boolean;
  45188. /**
  45189. * Gets whether or not ogg are supported by your browser.
  45190. */
  45191. isOGGsupported: boolean;
  45192. /**
  45193. * Gets whether audio has been unlocked on the device.
  45194. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  45195. * a user interaction has happened.
  45196. */
  45197. unlocked: boolean;
  45198. /**
  45199. * Defines if the audio engine relies on a custom unlocked button.
  45200. * In this case, the embedded button will not be displayed.
  45201. */
  45202. useCustomUnlockedButton: boolean;
  45203. /**
  45204. * Event raised when audio has been unlocked on the browser.
  45205. */
  45206. onAudioUnlockedObservable: Observable<IAudioEngine>;
  45207. /**
  45208. * Event raised when audio has been locked on the browser.
  45209. */
  45210. onAudioLockedObservable: Observable<IAudioEngine>;
  45211. /**
  45212. * Gets the current AudioContext if available.
  45213. */
  45214. get audioContext(): Nullable<AudioContext>;
  45215. private _connectedAnalyser;
  45216. /**
  45217. * Instantiates a new audio engine.
  45218. *
  45219. * There should be only one per page as some browsers restrict the number
  45220. * of audio contexts you can create.
  45221. * @param hostElement defines the host element where to display the mute icon if necessary
  45222. */
  45223. constructor(hostElement?: Nullable<HTMLElement>);
  45224. /**
  45225. * Flags the audio engine in Locked state.
  45226. * This happens due to new browser policies preventing audio to autoplay.
  45227. */
  45228. lock(): void;
  45229. /**
  45230. * Unlocks the audio engine once a user action has been done on the dom.
  45231. * This is helpful to resume play once browser policies have been satisfied.
  45232. */
  45233. unlock(): void;
  45234. private _resumeAudioContext;
  45235. private _initializeAudioContext;
  45236. private _tryToRun;
  45237. private _triggerRunningState;
  45238. private _triggerSuspendedState;
  45239. private _displayMuteButton;
  45240. private _moveButtonToTopLeft;
  45241. private _onResize;
  45242. private _hideMuteButton;
  45243. /**
  45244. * Destroy and release the resources associated with the audio ccontext.
  45245. */
  45246. dispose(): void;
  45247. /**
  45248. * Gets the global volume sets on the master gain.
  45249. * @returns the global volume if set or -1 otherwise
  45250. */
  45251. getGlobalVolume(): number;
  45252. /**
  45253. * Sets the global volume of your experience (sets on the master gain).
  45254. * @param newVolume Defines the new global volume of the application
  45255. */
  45256. setGlobalVolume(newVolume: number): void;
  45257. /**
  45258. * Connect the audio engine to an audio analyser allowing some amazing
  45259. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45260. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45261. * @param analyser The analyser to connect to the engine
  45262. */
  45263. connectToAnalyser(analyser: Analyser): void;
  45264. }
  45265. }
  45266. declare module BABYLON {
  45267. /**
  45268. * Options allowed during the creation of a sound track.
  45269. */
  45270. export interface ISoundTrackOptions {
  45271. /**
  45272. * The volume the sound track should take during creation
  45273. */
  45274. volume?: number;
  45275. /**
  45276. * Define if the sound track is the main sound track of the scene
  45277. */
  45278. mainTrack?: boolean;
  45279. }
  45280. /**
  45281. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45282. * It will be also used in a future release to apply effects on a specific track.
  45283. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45284. */
  45285. export class SoundTrack {
  45286. /**
  45287. * The unique identifier of the sound track in the scene.
  45288. */
  45289. id: number;
  45290. /**
  45291. * The list of sounds included in the sound track.
  45292. */
  45293. soundCollection: Array<Sound>;
  45294. private _outputAudioNode;
  45295. private _scene;
  45296. private _connectedAnalyser;
  45297. private _options;
  45298. private _isInitialized;
  45299. /**
  45300. * Creates a new sound track.
  45301. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45302. * @param scene Define the scene the sound track belongs to
  45303. * @param options
  45304. */
  45305. constructor(scene: Scene, options?: ISoundTrackOptions);
  45306. private _initializeSoundTrackAudioGraph;
  45307. /**
  45308. * Release the sound track and its associated resources
  45309. */
  45310. dispose(): void;
  45311. /**
  45312. * Adds a sound to this sound track
  45313. * @param sound define the cound to add
  45314. * @ignoreNaming
  45315. */
  45316. addSound(sound: Sound): void;
  45317. /**
  45318. * Removes a sound to this sound track
  45319. * @param sound define the cound to remove
  45320. * @ignoreNaming
  45321. */
  45322. removeSound(sound: Sound): void;
  45323. /**
  45324. * Set a global volume for the full sound track.
  45325. * @param newVolume Define the new volume of the sound track
  45326. */
  45327. setVolume(newVolume: number): void;
  45328. /**
  45329. * Switch the panning model to HRTF:
  45330. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45331. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45332. */
  45333. switchPanningModelToHRTF(): void;
  45334. /**
  45335. * Switch the panning model to Equal Power:
  45336. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45337. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45338. */
  45339. switchPanningModelToEqualPower(): void;
  45340. /**
  45341. * Connect the sound track to an audio analyser allowing some amazing
  45342. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45343. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45344. * @param analyser The analyser to connect to the engine
  45345. */
  45346. connectToAnalyser(analyser: Analyser): void;
  45347. }
  45348. }
  45349. declare module BABYLON {
  45350. interface AbstractScene {
  45351. /**
  45352. * The list of sounds used in the scene.
  45353. */
  45354. sounds: Nullable<Array<Sound>>;
  45355. }
  45356. interface Scene {
  45357. /**
  45358. * @hidden
  45359. * Backing field
  45360. */
  45361. _mainSoundTrack: SoundTrack;
  45362. /**
  45363. * The main sound track played by the scene.
  45364. * It cotains your primary collection of sounds.
  45365. */
  45366. mainSoundTrack: SoundTrack;
  45367. /**
  45368. * The list of sound tracks added to the scene
  45369. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45370. */
  45371. soundTracks: Nullable<Array<SoundTrack>>;
  45372. /**
  45373. * Gets a sound using a given name
  45374. * @param name defines the name to search for
  45375. * @return the found sound or null if not found at all.
  45376. */
  45377. getSoundByName(name: string): Nullable<Sound>;
  45378. /**
  45379. * Gets or sets if audio support is enabled
  45380. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45381. */
  45382. audioEnabled: boolean;
  45383. /**
  45384. * Gets or sets if audio will be output to headphones
  45385. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45386. */
  45387. headphone: boolean;
  45388. /**
  45389. * Gets or sets custom audio listener position provider
  45390. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45391. */
  45392. audioListenerPositionProvider: Nullable<() => Vector3>;
  45393. /**
  45394. * Gets or sets a refresh rate when using 3D audio positioning
  45395. */
  45396. audioPositioningRefreshRate: number;
  45397. }
  45398. /**
  45399. * Defines the sound scene component responsible to manage any sounds
  45400. * in a given scene.
  45401. */
  45402. export class AudioSceneComponent implements ISceneSerializableComponent {
  45403. private static _CameraDirectionLH;
  45404. private static _CameraDirectionRH;
  45405. /**
  45406. * The component name helpfull to identify the component in the list of scene components.
  45407. */
  45408. readonly name: string;
  45409. /**
  45410. * The scene the component belongs to.
  45411. */
  45412. scene: Scene;
  45413. private _audioEnabled;
  45414. /**
  45415. * Gets whether audio is enabled or not.
  45416. * Please use related enable/disable method to switch state.
  45417. */
  45418. get audioEnabled(): boolean;
  45419. private _headphone;
  45420. /**
  45421. * Gets whether audio is outputing to headphone or not.
  45422. * Please use the according Switch methods to change output.
  45423. */
  45424. get headphone(): boolean;
  45425. /**
  45426. * Gets or sets a refresh rate when using 3D audio positioning
  45427. */
  45428. audioPositioningRefreshRate: number;
  45429. private _audioListenerPositionProvider;
  45430. /**
  45431. * Gets the current audio listener position provider
  45432. */
  45433. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45434. /**
  45435. * Sets a custom listener position for all sounds in the scene
  45436. * By default, this is the position of the first active camera
  45437. */
  45438. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45439. /**
  45440. * Creates a new instance of the component for the given scene
  45441. * @param scene Defines the scene to register the component in
  45442. */
  45443. constructor(scene: Scene);
  45444. /**
  45445. * Registers the component in a given scene
  45446. */
  45447. register(): void;
  45448. /**
  45449. * Rebuilds the elements related to this component in case of
  45450. * context lost for instance.
  45451. */
  45452. rebuild(): void;
  45453. /**
  45454. * Serializes the component data to the specified json object
  45455. * @param serializationObject The object to serialize to
  45456. */
  45457. serialize(serializationObject: any): void;
  45458. /**
  45459. * Adds all the elements from the container to the scene
  45460. * @param container the container holding the elements
  45461. */
  45462. addFromContainer(container: AbstractScene): void;
  45463. /**
  45464. * Removes all the elements in the container from the scene
  45465. * @param container contains the elements to remove
  45466. * @param dispose if the removed element should be disposed (default: false)
  45467. */
  45468. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45469. /**
  45470. * Disposes the component and the associated ressources.
  45471. */
  45472. dispose(): void;
  45473. /**
  45474. * Disables audio in the associated scene.
  45475. */
  45476. disableAudio(): void;
  45477. /**
  45478. * Enables audio in the associated scene.
  45479. */
  45480. enableAudio(): void;
  45481. /**
  45482. * Switch audio to headphone output.
  45483. */
  45484. switchAudioModeForHeadphones(): void;
  45485. /**
  45486. * Switch audio to normal speakers.
  45487. */
  45488. switchAudioModeForNormalSpeakers(): void;
  45489. private _cachedCameraDirection;
  45490. private _cachedCameraPosition;
  45491. private _lastCheck;
  45492. private _afterRender;
  45493. }
  45494. }
  45495. declare module BABYLON {
  45496. /**
  45497. * Wraps one or more Sound objects and selects one with random weight for playback.
  45498. */
  45499. export class WeightedSound {
  45500. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45501. loop: boolean;
  45502. private _coneInnerAngle;
  45503. private _coneOuterAngle;
  45504. private _volume;
  45505. /** A Sound is currently playing. */
  45506. isPlaying: boolean;
  45507. /** A Sound is currently paused. */
  45508. isPaused: boolean;
  45509. private _sounds;
  45510. private _weights;
  45511. private _currentIndex?;
  45512. /**
  45513. * Creates a new WeightedSound from the list of sounds given.
  45514. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45515. * @param sounds Array of Sounds that will be selected from.
  45516. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45517. */
  45518. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45519. /**
  45520. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45521. */
  45522. get directionalConeInnerAngle(): number;
  45523. /**
  45524. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45525. */
  45526. set directionalConeInnerAngle(value: number);
  45527. /**
  45528. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45529. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45530. */
  45531. get directionalConeOuterAngle(): number;
  45532. /**
  45533. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45534. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45535. */
  45536. set directionalConeOuterAngle(value: number);
  45537. /**
  45538. * Playback volume.
  45539. */
  45540. get volume(): number;
  45541. /**
  45542. * Playback volume.
  45543. */
  45544. set volume(value: number);
  45545. private _onended;
  45546. /**
  45547. * Suspend playback
  45548. */
  45549. pause(): void;
  45550. /**
  45551. * Stop playback
  45552. */
  45553. stop(): void;
  45554. /**
  45555. * Start playback.
  45556. * @param startOffset Position the clip head at a specific time in seconds.
  45557. */
  45558. play(startOffset?: number): void;
  45559. }
  45560. }
  45561. declare module BABYLON {
  45562. /**
  45563. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45564. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45565. */
  45566. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45567. /**
  45568. * Gets the name of the behavior.
  45569. */
  45570. get name(): string;
  45571. /**
  45572. * The easing function used by animations
  45573. */
  45574. static EasingFunction: BackEase;
  45575. /**
  45576. * The easing mode used by animations
  45577. */
  45578. static EasingMode: number;
  45579. /**
  45580. * The duration of the animation, in milliseconds
  45581. */
  45582. transitionDuration: number;
  45583. /**
  45584. * Length of the distance animated by the transition when lower radius is reached
  45585. */
  45586. lowerRadiusTransitionRange: number;
  45587. /**
  45588. * Length of the distance animated by the transition when upper radius is reached
  45589. */
  45590. upperRadiusTransitionRange: number;
  45591. private _autoTransitionRange;
  45592. /**
  45593. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45594. */
  45595. get autoTransitionRange(): boolean;
  45596. /**
  45597. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45598. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45599. */
  45600. set autoTransitionRange(value: boolean);
  45601. private _attachedCamera;
  45602. private _onAfterCheckInputsObserver;
  45603. private _onMeshTargetChangedObserver;
  45604. /**
  45605. * Initializes the behavior.
  45606. */
  45607. init(): void;
  45608. /**
  45609. * Attaches the behavior to its arc rotate camera.
  45610. * @param camera Defines the camera to attach the behavior to
  45611. */
  45612. attach(camera: ArcRotateCamera): void;
  45613. /**
  45614. * Detaches the behavior from its current arc rotate camera.
  45615. */
  45616. detach(): void;
  45617. private _radiusIsAnimating;
  45618. private _radiusBounceTransition;
  45619. private _animatables;
  45620. private _cachedWheelPrecision;
  45621. /**
  45622. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45623. * @param radiusLimit The limit to check against.
  45624. * @return Bool to indicate if at limit.
  45625. */
  45626. private _isRadiusAtLimit;
  45627. /**
  45628. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45629. * @param radiusDelta The delta by which to animate to. Can be negative.
  45630. */
  45631. private _applyBoundRadiusAnimation;
  45632. /**
  45633. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45634. */
  45635. protected _clearAnimationLocks(): void;
  45636. /**
  45637. * Stops and removes all animations that have been applied to the camera
  45638. */
  45639. stopAllAnimations(): void;
  45640. }
  45641. }
  45642. declare module BABYLON {
  45643. /**
  45644. * 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.
  45645. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45646. */
  45647. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45648. /**
  45649. * Gets the name of the behavior.
  45650. */
  45651. get name(): string;
  45652. private _mode;
  45653. private _radiusScale;
  45654. private _positionScale;
  45655. private _defaultElevation;
  45656. private _elevationReturnTime;
  45657. private _elevationReturnWaitTime;
  45658. private _zoomStopsAnimation;
  45659. private _framingTime;
  45660. /**
  45661. * The easing function used by animations
  45662. */
  45663. static EasingFunction: ExponentialEase;
  45664. /**
  45665. * The easing mode used by animations
  45666. */
  45667. static EasingMode: number;
  45668. /**
  45669. * Sets the current mode used by the behavior
  45670. */
  45671. set mode(mode: number);
  45672. /**
  45673. * Gets current mode used by the behavior.
  45674. */
  45675. get mode(): number;
  45676. /**
  45677. * Sets the scale applied to the radius (1 by default)
  45678. */
  45679. set radiusScale(radius: number);
  45680. /**
  45681. * Gets the scale applied to the radius
  45682. */
  45683. get radiusScale(): number;
  45684. /**
  45685. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45686. */
  45687. set positionScale(scale: number);
  45688. /**
  45689. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45690. */
  45691. get positionScale(): number;
  45692. /**
  45693. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45694. * behaviour is triggered, in radians.
  45695. */
  45696. set defaultElevation(elevation: number);
  45697. /**
  45698. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45699. * behaviour is triggered, in radians.
  45700. */
  45701. get defaultElevation(): number;
  45702. /**
  45703. * Sets the time (in milliseconds) taken to return to the default beta position.
  45704. * Negative value indicates camera should not return to default.
  45705. */
  45706. set elevationReturnTime(speed: number);
  45707. /**
  45708. * Gets the time (in milliseconds) taken to return to the default beta position.
  45709. * Negative value indicates camera should not return to default.
  45710. */
  45711. get elevationReturnTime(): number;
  45712. /**
  45713. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45714. */
  45715. set elevationReturnWaitTime(time: number);
  45716. /**
  45717. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45718. */
  45719. get elevationReturnWaitTime(): number;
  45720. /**
  45721. * Sets the flag that indicates if user zooming should stop animation.
  45722. */
  45723. set zoomStopsAnimation(flag: boolean);
  45724. /**
  45725. * Gets the flag that indicates if user zooming should stop animation.
  45726. */
  45727. get zoomStopsAnimation(): boolean;
  45728. /**
  45729. * Sets the transition time when framing the mesh, in milliseconds
  45730. */
  45731. set framingTime(time: number);
  45732. /**
  45733. * Gets the transition time when framing the mesh, in milliseconds
  45734. */
  45735. get framingTime(): number;
  45736. /**
  45737. * Define if the behavior should automatically change the configured
  45738. * camera limits and sensibilities.
  45739. */
  45740. autoCorrectCameraLimitsAndSensibility: boolean;
  45741. private _onPrePointerObservableObserver;
  45742. private _onAfterCheckInputsObserver;
  45743. private _onMeshTargetChangedObserver;
  45744. private _attachedCamera;
  45745. private _isPointerDown;
  45746. private _lastInteractionTime;
  45747. /**
  45748. * Initializes the behavior.
  45749. */
  45750. init(): void;
  45751. /**
  45752. * Attaches the behavior to its arc rotate camera.
  45753. * @param camera Defines the camera to attach the behavior to
  45754. */
  45755. attach(camera: ArcRotateCamera): void;
  45756. /**
  45757. * Detaches the behavior from its current arc rotate camera.
  45758. */
  45759. detach(): void;
  45760. private _animatables;
  45761. private _betaIsAnimating;
  45762. private _betaTransition;
  45763. private _radiusTransition;
  45764. private _vectorTransition;
  45765. /**
  45766. * Targets the given mesh and updates zoom level accordingly.
  45767. * @param mesh The mesh to target.
  45768. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45769. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45770. */
  45771. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45772. /**
  45773. * Targets the given mesh with its children and updates zoom level accordingly.
  45774. * @param mesh The mesh to target.
  45775. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45776. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45777. */
  45778. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45779. /**
  45780. * Targets the given meshes with their children and updates zoom level accordingly.
  45781. * @param meshes The mesh to target.
  45782. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45783. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45784. */
  45785. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45786. /**
  45787. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  45788. * @param minimumWorld Determines the smaller position of the bounding box extend
  45789. * @param maximumWorld Determines the bigger position of the bounding box extend
  45790. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45791. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45792. */
  45793. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45794. /**
  45795. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  45796. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  45797. * frustum width.
  45798. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  45799. * to fully enclose the mesh in the viewing frustum.
  45800. */
  45801. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  45802. /**
  45803. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  45804. * is automatically returned to its default position (expected to be above ground plane).
  45805. */
  45806. private _maintainCameraAboveGround;
  45807. /**
  45808. * Returns the frustum slope based on the canvas ratio and camera FOV
  45809. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  45810. */
  45811. private _getFrustumSlope;
  45812. /**
  45813. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  45814. */
  45815. private _clearAnimationLocks;
  45816. /**
  45817. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45818. */
  45819. private _applyUserInteraction;
  45820. /**
  45821. * Stops and removes all animations that have been applied to the camera
  45822. */
  45823. stopAllAnimations(): void;
  45824. /**
  45825. * Gets a value indicating if the user is moving the camera
  45826. */
  45827. get isUserIsMoving(): boolean;
  45828. /**
  45829. * The camera can move all the way towards the mesh.
  45830. */
  45831. static IgnoreBoundsSizeMode: number;
  45832. /**
  45833. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  45834. */
  45835. static FitFrustumSidesMode: number;
  45836. }
  45837. }
  45838. declare module BABYLON {
  45839. /**
  45840. * Base class for Camera Pointer Inputs.
  45841. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  45842. * for example usage.
  45843. */
  45844. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  45845. /**
  45846. * Defines the camera the input is attached to.
  45847. */
  45848. abstract camera: Camera;
  45849. /**
  45850. * Whether keyboard modifier keys are pressed at time of last mouse event.
  45851. */
  45852. protected _altKey: boolean;
  45853. protected _ctrlKey: boolean;
  45854. protected _metaKey: boolean;
  45855. protected _shiftKey: boolean;
  45856. /**
  45857. * Which mouse buttons were pressed at time of last mouse event.
  45858. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  45859. */
  45860. protected _buttonsPressed: number;
  45861. /**
  45862. * Defines the buttons associated with the input to handle camera move.
  45863. */
  45864. buttons: number[];
  45865. /**
  45866. * Attach the input controls to a specific dom element to get the input from.
  45867. * @param element Defines the element the controls should be listened from
  45868. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45869. */
  45870. attachControl(noPreventDefault?: boolean): void;
  45871. /**
  45872. * Detach the current controls from the specified dom element.
  45873. */
  45874. detachControl(): void;
  45875. /**
  45876. * Gets the class name of the current input.
  45877. * @returns the class name
  45878. */
  45879. getClassName(): string;
  45880. /**
  45881. * Get the friendly name associated with the input class.
  45882. * @returns the input friendly name
  45883. */
  45884. getSimpleName(): string;
  45885. /**
  45886. * Called on pointer POINTERDOUBLETAP event.
  45887. * Override this method to provide functionality on POINTERDOUBLETAP event.
  45888. */
  45889. protected onDoubleTap(type: string): void;
  45890. /**
  45891. * Called on pointer POINTERMOVE event if only a single touch is active.
  45892. * Override this method to provide functionality.
  45893. */
  45894. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45895. /**
  45896. * Called on pointer POINTERMOVE event if multiple touches are active.
  45897. * Override this method to provide functionality.
  45898. */
  45899. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45900. /**
  45901. * Called on JS contextmenu event.
  45902. * Override this method to provide functionality.
  45903. */
  45904. protected onContextMenu(evt: PointerEvent): void;
  45905. /**
  45906. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45907. * press.
  45908. * Override this method to provide functionality.
  45909. */
  45910. protected onButtonDown(evt: PointerEvent): void;
  45911. /**
  45912. * Called each time a new POINTERUP event occurs. Ie, for each button
  45913. * release.
  45914. * Override this method to provide functionality.
  45915. */
  45916. protected onButtonUp(evt: PointerEvent): void;
  45917. /**
  45918. * Called when window becomes inactive.
  45919. * Override this method to provide functionality.
  45920. */
  45921. protected onLostFocus(): void;
  45922. private _pointerInput;
  45923. private _observer;
  45924. private _onLostFocus;
  45925. private pointA;
  45926. private pointB;
  45927. }
  45928. }
  45929. declare module BABYLON {
  45930. /**
  45931. * Manage the pointers inputs to control an arc rotate camera.
  45932. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45933. */
  45934. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  45935. /**
  45936. * Defines the camera the input is attached to.
  45937. */
  45938. camera: ArcRotateCamera;
  45939. /**
  45940. * Gets the class name of the current input.
  45941. * @returns the class name
  45942. */
  45943. getClassName(): string;
  45944. /**
  45945. * Defines the buttons associated with the input to handle camera move.
  45946. */
  45947. buttons: number[];
  45948. /**
  45949. * Defines the pointer angular sensibility along the X axis or how fast is
  45950. * the camera rotating.
  45951. */
  45952. angularSensibilityX: number;
  45953. /**
  45954. * Defines the pointer angular sensibility along the Y axis or how fast is
  45955. * the camera rotating.
  45956. */
  45957. angularSensibilityY: number;
  45958. /**
  45959. * Defines the pointer pinch precision or how fast is the camera zooming.
  45960. */
  45961. pinchPrecision: number;
  45962. /**
  45963. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45964. * from 0.
  45965. * It defines the percentage of current camera.radius to use as delta when
  45966. * pinch zoom is used.
  45967. */
  45968. pinchDeltaPercentage: number;
  45969. /**
  45970. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  45971. * that any object in the plane at the camera's target point will scale
  45972. * perfectly with finger motion.
  45973. * Overrides pinchDeltaPercentage and pinchPrecision.
  45974. */
  45975. useNaturalPinchZoom: boolean;
  45976. /**
  45977. * Defines the pointer panning sensibility or how fast is the camera moving.
  45978. */
  45979. panningSensibility: number;
  45980. /**
  45981. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  45982. */
  45983. multiTouchPanning: boolean;
  45984. /**
  45985. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  45986. * zoom (pinch) through multitouch.
  45987. */
  45988. multiTouchPanAndZoom: boolean;
  45989. /**
  45990. * Revers pinch action direction.
  45991. */
  45992. pinchInwards: boolean;
  45993. private _isPanClick;
  45994. private _twoFingerActivityCount;
  45995. private _isPinching;
  45996. /**
  45997. * Called on pointer POINTERMOVE event if only a single touch is active.
  45998. */
  45999. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46000. /**
  46001. * Called on pointer POINTERDOUBLETAP event.
  46002. */
  46003. protected onDoubleTap(type: string): void;
  46004. /**
  46005. * Called on pointer POINTERMOVE event if multiple touches are active.
  46006. */
  46007. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46008. /**
  46009. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46010. * press.
  46011. */
  46012. protected onButtonDown(evt: PointerEvent): void;
  46013. /**
  46014. * Called each time a new POINTERUP event occurs. Ie, for each button
  46015. * release.
  46016. */
  46017. protected onButtonUp(evt: PointerEvent): void;
  46018. /**
  46019. * Called when window becomes inactive.
  46020. */
  46021. protected onLostFocus(): void;
  46022. }
  46023. }
  46024. declare module BABYLON {
  46025. /**
  46026. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46027. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46028. */
  46029. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46030. /**
  46031. * Defines the camera the input is attached to.
  46032. */
  46033. camera: ArcRotateCamera;
  46034. /**
  46035. * Defines the list of key codes associated with the up action (increase alpha)
  46036. */
  46037. keysUp: number[];
  46038. /**
  46039. * Defines the list of key codes associated with the down action (decrease alpha)
  46040. */
  46041. keysDown: number[];
  46042. /**
  46043. * Defines the list of key codes associated with the left action (increase beta)
  46044. */
  46045. keysLeft: number[];
  46046. /**
  46047. * Defines the list of key codes associated with the right action (decrease beta)
  46048. */
  46049. keysRight: number[];
  46050. /**
  46051. * Defines the list of key codes associated with the reset action.
  46052. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46053. */
  46054. keysReset: number[];
  46055. /**
  46056. * Defines the panning sensibility of the inputs.
  46057. * (How fast is the camera panning)
  46058. */
  46059. panningSensibility: number;
  46060. /**
  46061. * Defines the zooming sensibility of the inputs.
  46062. * (How fast is the camera zooming)
  46063. */
  46064. zoomingSensibility: number;
  46065. /**
  46066. * Defines whether maintaining the alt key down switch the movement mode from
  46067. * orientation to zoom.
  46068. */
  46069. useAltToZoom: boolean;
  46070. /**
  46071. * Rotation speed of the camera
  46072. */
  46073. angularSpeed: number;
  46074. private _keys;
  46075. private _ctrlPressed;
  46076. private _altPressed;
  46077. private _onCanvasBlurObserver;
  46078. private _onKeyboardObserver;
  46079. private _engine;
  46080. private _scene;
  46081. /**
  46082. * Attach the input controls to a specific dom element to get the input from.
  46083. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46084. */
  46085. attachControl(noPreventDefault?: boolean): void;
  46086. /**
  46087. * Detach the current controls from the specified dom element.
  46088. */
  46089. detachControl(): void;
  46090. /**
  46091. * Update the current camera state depending on the inputs that have been used this frame.
  46092. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46093. */
  46094. checkInputs(): void;
  46095. /**
  46096. * Gets the class name of the current intput.
  46097. * @returns the class name
  46098. */
  46099. getClassName(): string;
  46100. /**
  46101. * Get the friendly name associated with the input class.
  46102. * @returns the input friendly name
  46103. */
  46104. getSimpleName(): string;
  46105. }
  46106. }
  46107. declare module BABYLON {
  46108. /**
  46109. * Manage the mouse wheel inputs to control an arc rotate camera.
  46110. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46111. */
  46112. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46113. /**
  46114. * Defines the camera the input is attached to.
  46115. */
  46116. camera: ArcRotateCamera;
  46117. /**
  46118. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46119. */
  46120. wheelPrecision: number;
  46121. /**
  46122. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46123. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46124. */
  46125. wheelDeltaPercentage: number;
  46126. private _wheel;
  46127. private _observer;
  46128. private computeDeltaFromMouseWheelLegacyEvent;
  46129. /**
  46130. * Attach the input controls to a specific dom element to get the input from.
  46131. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46132. */
  46133. attachControl(noPreventDefault?: boolean): void;
  46134. /**
  46135. * Detach the current controls from the specified dom element.
  46136. */
  46137. detachControl(): void;
  46138. /**
  46139. * Gets the class name of the current intput.
  46140. * @returns the class name
  46141. */
  46142. getClassName(): string;
  46143. /**
  46144. * Get the friendly name associated with the input class.
  46145. * @returns the input friendly name
  46146. */
  46147. getSimpleName(): string;
  46148. }
  46149. }
  46150. declare module BABYLON {
  46151. /**
  46152. * Default Inputs manager for the ArcRotateCamera.
  46153. * It groups all the default supported inputs for ease of use.
  46154. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46155. */
  46156. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46157. /**
  46158. * Instantiates a new ArcRotateCameraInputsManager.
  46159. * @param camera Defines the camera the inputs belong to
  46160. */
  46161. constructor(camera: ArcRotateCamera);
  46162. /**
  46163. * Add mouse wheel input support to the input manager.
  46164. * @returns the current input manager
  46165. */
  46166. addMouseWheel(): ArcRotateCameraInputsManager;
  46167. /**
  46168. * Add pointers input support to the input manager.
  46169. * @returns the current input manager
  46170. */
  46171. addPointers(): ArcRotateCameraInputsManager;
  46172. /**
  46173. * Add keyboard input support to the input manager.
  46174. * @returns the current input manager
  46175. */
  46176. addKeyboard(): ArcRotateCameraInputsManager;
  46177. }
  46178. }
  46179. declare module BABYLON {
  46180. /**
  46181. * This represents an orbital type of camera.
  46182. *
  46183. * 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.
  46184. * 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.
  46185. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46186. */
  46187. export class ArcRotateCamera extends TargetCamera {
  46188. /**
  46189. * Defines the rotation angle of the camera along the longitudinal axis.
  46190. */
  46191. alpha: number;
  46192. /**
  46193. * Defines the rotation angle of the camera along the latitudinal axis.
  46194. */
  46195. beta: number;
  46196. /**
  46197. * Defines the radius of the camera from it s target point.
  46198. */
  46199. radius: number;
  46200. protected _target: Vector3;
  46201. protected _targetHost: Nullable<AbstractMesh>;
  46202. /**
  46203. * Defines the target point of the camera.
  46204. * The camera looks towards it form the radius distance.
  46205. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46206. */
  46207. get target(): Vector3;
  46208. set target(value: Vector3);
  46209. /**
  46210. * Define the current local position of the camera in the scene
  46211. */
  46212. get position(): Vector3;
  46213. set position(newPosition: Vector3);
  46214. protected _upToYMatrix: Matrix;
  46215. protected _YToUpMatrix: Matrix;
  46216. /**
  46217. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46218. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46219. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46220. */
  46221. set upVector(vec: Vector3);
  46222. get upVector(): Vector3;
  46223. /**
  46224. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46225. */
  46226. setMatUp(): void;
  46227. /**
  46228. * Current inertia value on the longitudinal axis.
  46229. * The bigger this number the longer it will take for the camera to stop.
  46230. */
  46231. inertialAlphaOffset: number;
  46232. /**
  46233. * Current inertia value on the latitudinal axis.
  46234. * The bigger this number the longer it will take for the camera to stop.
  46235. */
  46236. inertialBetaOffset: number;
  46237. /**
  46238. * Current inertia value on the radius axis.
  46239. * The bigger this number the longer it will take for the camera to stop.
  46240. */
  46241. inertialRadiusOffset: number;
  46242. /**
  46243. * Minimum allowed angle on the longitudinal axis.
  46244. * This can help limiting how the Camera is able to move in the scene.
  46245. */
  46246. lowerAlphaLimit: Nullable<number>;
  46247. /**
  46248. * Maximum allowed angle on the longitudinal axis.
  46249. * This can help limiting how the Camera is able to move in the scene.
  46250. */
  46251. upperAlphaLimit: Nullable<number>;
  46252. /**
  46253. * Minimum allowed angle on the latitudinal axis.
  46254. * This can help limiting how the Camera is able to move in the scene.
  46255. */
  46256. lowerBetaLimit: number;
  46257. /**
  46258. * Maximum allowed angle on the latitudinal axis.
  46259. * This can help limiting how the Camera is able to move in the scene.
  46260. */
  46261. upperBetaLimit: number;
  46262. /**
  46263. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46264. * This can help limiting how the Camera is able to move in the scene.
  46265. */
  46266. lowerRadiusLimit: Nullable<number>;
  46267. /**
  46268. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46269. * This can help limiting how the Camera is able to move in the scene.
  46270. */
  46271. upperRadiusLimit: Nullable<number>;
  46272. /**
  46273. * Defines the current inertia value used during panning of the camera along the X axis.
  46274. */
  46275. inertialPanningX: number;
  46276. /**
  46277. * Defines the current inertia value used during panning of the camera along the Y axis.
  46278. */
  46279. inertialPanningY: number;
  46280. /**
  46281. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46282. * Basically if your fingers moves away from more than this distance you will be considered
  46283. * in pinch mode.
  46284. */
  46285. pinchToPanMaxDistance: number;
  46286. /**
  46287. * Defines the maximum distance the camera can pan.
  46288. * This could help keeping the cammera always in your scene.
  46289. */
  46290. panningDistanceLimit: Nullable<number>;
  46291. /**
  46292. * Defines the target of the camera before paning.
  46293. */
  46294. panningOriginTarget: Vector3;
  46295. /**
  46296. * Defines the value of the inertia used during panning.
  46297. * 0 would mean stop inertia and one would mean no decelleration at all.
  46298. */
  46299. panningInertia: number;
  46300. /**
  46301. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46302. */
  46303. get angularSensibilityX(): number;
  46304. set angularSensibilityX(value: number);
  46305. /**
  46306. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46307. */
  46308. get angularSensibilityY(): number;
  46309. set angularSensibilityY(value: number);
  46310. /**
  46311. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46312. */
  46313. get pinchPrecision(): number;
  46314. set pinchPrecision(value: number);
  46315. /**
  46316. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46317. * It will be used instead of pinchDeltaPrecision if different from 0.
  46318. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46319. */
  46320. get pinchDeltaPercentage(): number;
  46321. set pinchDeltaPercentage(value: number);
  46322. /**
  46323. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46324. * and pinch delta percentage.
  46325. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46326. * that any object in the plane at the camera's target point will scale
  46327. * perfectly with finger motion.
  46328. */
  46329. get useNaturalPinchZoom(): boolean;
  46330. set useNaturalPinchZoom(value: boolean);
  46331. /**
  46332. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46333. */
  46334. get panningSensibility(): number;
  46335. set panningSensibility(value: number);
  46336. /**
  46337. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46338. */
  46339. get keysUp(): number[];
  46340. set keysUp(value: number[]);
  46341. /**
  46342. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46343. */
  46344. get keysDown(): number[];
  46345. set keysDown(value: number[]);
  46346. /**
  46347. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46348. */
  46349. get keysLeft(): number[];
  46350. set keysLeft(value: number[]);
  46351. /**
  46352. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46353. */
  46354. get keysRight(): number[];
  46355. set keysRight(value: number[]);
  46356. /**
  46357. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46358. */
  46359. get wheelPrecision(): number;
  46360. set wheelPrecision(value: number);
  46361. /**
  46362. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46363. * It will be used instead of pinchDeltaPrecision if different from 0.
  46364. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46365. */
  46366. get wheelDeltaPercentage(): number;
  46367. set wheelDeltaPercentage(value: number);
  46368. /**
  46369. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46370. */
  46371. zoomOnFactor: number;
  46372. /**
  46373. * Defines a screen offset for the camera position.
  46374. */
  46375. targetScreenOffset: Vector2;
  46376. /**
  46377. * Allows the camera to be completely reversed.
  46378. * If false the camera can not arrive upside down.
  46379. */
  46380. allowUpsideDown: boolean;
  46381. /**
  46382. * Define if double tap/click is used to restore the previously saved state of the camera.
  46383. */
  46384. useInputToRestoreState: boolean;
  46385. /** @hidden */
  46386. _viewMatrix: Matrix;
  46387. /** @hidden */
  46388. _useCtrlForPanning: boolean;
  46389. /** @hidden */
  46390. _panningMouseButton: number;
  46391. /**
  46392. * Defines the input associated to the camera.
  46393. */
  46394. inputs: ArcRotateCameraInputsManager;
  46395. /** @hidden */
  46396. _reset: () => void;
  46397. /**
  46398. * Defines the allowed panning axis.
  46399. */
  46400. panningAxis: Vector3;
  46401. protected _localDirection: Vector3;
  46402. protected _transformedDirection: Vector3;
  46403. private _bouncingBehavior;
  46404. /**
  46405. * Gets the bouncing behavior of the camera if it has been enabled.
  46406. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46407. */
  46408. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46409. /**
  46410. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46411. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46412. */
  46413. get useBouncingBehavior(): boolean;
  46414. set useBouncingBehavior(value: boolean);
  46415. private _framingBehavior;
  46416. /**
  46417. * Gets the framing behavior of the camera if it has been enabled.
  46418. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46419. */
  46420. get framingBehavior(): Nullable<FramingBehavior>;
  46421. /**
  46422. * Defines if the framing behavior of the camera is enabled on the camera.
  46423. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46424. */
  46425. get useFramingBehavior(): boolean;
  46426. set useFramingBehavior(value: boolean);
  46427. private _autoRotationBehavior;
  46428. /**
  46429. * Gets the auto rotation behavior of the camera if it has been enabled.
  46430. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46431. */
  46432. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46433. /**
  46434. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46435. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46436. */
  46437. get useAutoRotationBehavior(): boolean;
  46438. set useAutoRotationBehavior(value: boolean);
  46439. /**
  46440. * Observable triggered when the mesh target has been changed on the camera.
  46441. */
  46442. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46443. /**
  46444. * Event raised when the camera is colliding with a mesh.
  46445. */
  46446. onCollide: (collidedMesh: AbstractMesh) => void;
  46447. /**
  46448. * Defines whether the camera should check collision with the objects oh the scene.
  46449. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46450. */
  46451. checkCollisions: boolean;
  46452. /**
  46453. * Defines the collision radius of the camera.
  46454. * This simulates a sphere around the camera.
  46455. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46456. */
  46457. collisionRadius: Vector3;
  46458. protected _collider: Collider;
  46459. protected _previousPosition: Vector3;
  46460. protected _collisionVelocity: Vector3;
  46461. protected _newPosition: Vector3;
  46462. protected _previousAlpha: number;
  46463. protected _previousBeta: number;
  46464. protected _previousRadius: number;
  46465. protected _collisionTriggered: boolean;
  46466. protected _targetBoundingCenter: Nullable<Vector3>;
  46467. private _computationVector;
  46468. /**
  46469. * Instantiates a new ArcRotateCamera in a given scene
  46470. * @param name Defines the name of the camera
  46471. * @param alpha Defines the camera rotation along the logitudinal axis
  46472. * @param beta Defines the camera rotation along the latitudinal axis
  46473. * @param radius Defines the camera distance from its target
  46474. * @param target Defines the camera target
  46475. * @param scene Defines the scene the camera belongs to
  46476. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46477. */
  46478. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46479. /** @hidden */
  46480. _initCache(): void;
  46481. /** @hidden */
  46482. _updateCache(ignoreParentClass?: boolean): void;
  46483. protected _getTargetPosition(): Vector3;
  46484. private _storedAlpha;
  46485. private _storedBeta;
  46486. private _storedRadius;
  46487. private _storedTarget;
  46488. private _storedTargetScreenOffset;
  46489. /**
  46490. * Stores the current state of the camera (alpha, beta, radius and target)
  46491. * @returns the camera itself
  46492. */
  46493. storeState(): Camera;
  46494. /**
  46495. * @hidden
  46496. * Restored camera state. You must call storeState() first
  46497. */
  46498. _restoreStateValues(): boolean;
  46499. /** @hidden */
  46500. _isSynchronizedViewMatrix(): boolean;
  46501. /**
  46502. * Attached controls to the current camera.
  46503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46504. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46505. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46506. */
  46507. attachControl(noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  46508. /**
  46509. * Detach the current controls from the camera.
  46510. * The camera will stop reacting to inputs.
  46511. */
  46512. detachControl(): void;
  46513. /** @hidden */
  46514. _checkInputs(): void;
  46515. protected _checkLimits(): void;
  46516. /**
  46517. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46518. */
  46519. rebuildAnglesAndRadius(): void;
  46520. /**
  46521. * Use a position to define the current camera related information like alpha, beta and radius
  46522. * @param position Defines the position to set the camera at
  46523. */
  46524. setPosition(position: Vector3): void;
  46525. /**
  46526. * Defines the target the camera should look at.
  46527. * This will automatically adapt alpha beta and radius to fit within the new target.
  46528. * @param target Defines the new target as a Vector or a mesh
  46529. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46530. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46531. */
  46532. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46533. /** @hidden */
  46534. _getViewMatrix(): Matrix;
  46535. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46536. /**
  46537. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46538. * @param meshes Defines the mesh to zoom on
  46539. * @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)
  46540. */
  46541. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46542. /**
  46543. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46544. * The target will be changed but the radius
  46545. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46546. * @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)
  46547. */
  46548. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46549. min: Vector3;
  46550. max: Vector3;
  46551. distance: number;
  46552. }, doNotUpdateMaxZ?: boolean): void;
  46553. /**
  46554. * @override
  46555. * Override Camera.createRigCamera
  46556. */
  46557. createRigCamera(name: string, cameraIndex: number): Camera;
  46558. /**
  46559. * @hidden
  46560. * @override
  46561. * Override Camera._updateRigCameras
  46562. */
  46563. _updateRigCameras(): void;
  46564. /**
  46565. * Destroy the camera and release the current resources hold by it.
  46566. */
  46567. dispose(): void;
  46568. /**
  46569. * Gets the current object class name.
  46570. * @return the class name
  46571. */
  46572. getClassName(): string;
  46573. }
  46574. }
  46575. declare module BABYLON {
  46576. /**
  46577. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46578. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46579. */
  46580. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46581. /**
  46582. * Gets the name of the behavior.
  46583. */
  46584. get name(): string;
  46585. private _zoomStopsAnimation;
  46586. private _idleRotationSpeed;
  46587. private _idleRotationWaitTime;
  46588. private _idleRotationSpinupTime;
  46589. /**
  46590. * Sets the flag that indicates if user zooming should stop animation.
  46591. */
  46592. set zoomStopsAnimation(flag: boolean);
  46593. /**
  46594. * Gets the flag that indicates if user zooming should stop animation.
  46595. */
  46596. get zoomStopsAnimation(): boolean;
  46597. /**
  46598. * Sets the default speed at which the camera rotates around the model.
  46599. */
  46600. set idleRotationSpeed(speed: number);
  46601. /**
  46602. * Gets the default speed at which the camera rotates around the model.
  46603. */
  46604. get idleRotationSpeed(): number;
  46605. /**
  46606. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46607. */
  46608. set idleRotationWaitTime(time: number);
  46609. /**
  46610. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46611. */
  46612. get idleRotationWaitTime(): number;
  46613. /**
  46614. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46615. */
  46616. set idleRotationSpinupTime(time: number);
  46617. /**
  46618. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46619. */
  46620. get idleRotationSpinupTime(): number;
  46621. /**
  46622. * Gets a value indicating if the camera is currently rotating because of this behavior
  46623. */
  46624. get rotationInProgress(): boolean;
  46625. private _onPrePointerObservableObserver;
  46626. private _onAfterCheckInputsObserver;
  46627. private _attachedCamera;
  46628. private _isPointerDown;
  46629. private _lastFrameTime;
  46630. private _lastInteractionTime;
  46631. private _cameraRotationSpeed;
  46632. /**
  46633. * Initializes the behavior.
  46634. */
  46635. init(): void;
  46636. /**
  46637. * Attaches the behavior to its arc rotate camera.
  46638. * @param camera Defines the camera to attach the behavior to
  46639. */
  46640. attach(camera: ArcRotateCamera): void;
  46641. /**
  46642. * Detaches the behavior from its current arc rotate camera.
  46643. */
  46644. detach(): void;
  46645. /**
  46646. * Returns true if user is scrolling.
  46647. * @return true if user is scrolling.
  46648. */
  46649. private _userIsZooming;
  46650. private _lastFrameRadius;
  46651. private _shouldAnimationStopForInteraction;
  46652. /**
  46653. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46654. */
  46655. private _applyUserInteraction;
  46656. private _userIsMoving;
  46657. }
  46658. }
  46659. declare module BABYLON {
  46660. /**
  46661. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46662. */
  46663. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46664. private ui;
  46665. /**
  46666. * The name of the behavior
  46667. */
  46668. name: string;
  46669. /**
  46670. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  46671. */
  46672. distanceAwayFromFace: number;
  46673. /**
  46674. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  46675. */
  46676. distanceAwayFromBottomOfFace: number;
  46677. private _faceVectors;
  46678. private _target;
  46679. private _scene;
  46680. private _onRenderObserver;
  46681. private _tmpMatrix;
  46682. private _tmpVector;
  46683. /**
  46684. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  46685. * @param ui The transform node that should be attched to the mesh
  46686. */
  46687. constructor(ui: TransformNode);
  46688. /**
  46689. * Initializes the behavior
  46690. */
  46691. init(): void;
  46692. private _closestFace;
  46693. private _zeroVector;
  46694. private _lookAtTmpMatrix;
  46695. private _lookAtToRef;
  46696. /**
  46697. * Attaches the AttachToBoxBehavior to the passed in mesh
  46698. * @param target The mesh that the specified node will be attached to
  46699. */
  46700. attach(target: Mesh): void;
  46701. /**
  46702. * Detaches the behavior from the mesh
  46703. */
  46704. detach(): void;
  46705. }
  46706. }
  46707. declare module BABYLON {
  46708. /**
  46709. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  46710. */
  46711. export class FadeInOutBehavior implements Behavior<Mesh> {
  46712. /**
  46713. * Time in milliseconds to delay before fading in (Default: 0)
  46714. */
  46715. delay: number;
  46716. /**
  46717. * Time in milliseconds for the mesh to fade in (Default: 300)
  46718. */
  46719. fadeInTime: number;
  46720. private _millisecondsPerFrame;
  46721. private _hovered;
  46722. private _hoverValue;
  46723. private _ownerNode;
  46724. /**
  46725. * Instatiates the FadeInOutBehavior
  46726. */
  46727. constructor();
  46728. /**
  46729. * The name of the behavior
  46730. */
  46731. get name(): string;
  46732. /**
  46733. * Initializes the behavior
  46734. */
  46735. init(): void;
  46736. /**
  46737. * Attaches the fade behavior on the passed in mesh
  46738. * @param ownerNode The mesh that will be faded in/out once attached
  46739. */
  46740. attach(ownerNode: Mesh): void;
  46741. /**
  46742. * Detaches the behavior from the mesh
  46743. */
  46744. detach(): void;
  46745. /**
  46746. * Triggers the mesh to begin fading in or out
  46747. * @param value if the object should fade in or out (true to fade in)
  46748. */
  46749. fadeIn(value: boolean): void;
  46750. private _update;
  46751. private _setAllVisibility;
  46752. }
  46753. }
  46754. declare module BABYLON {
  46755. /**
  46756. * Class containing a set of static utilities functions for managing Pivots
  46757. * @hidden
  46758. */
  46759. export class PivotTools {
  46760. private static _PivotCached;
  46761. private static _OldPivotPoint;
  46762. private static _PivotTranslation;
  46763. private static _PivotTmpVector;
  46764. private static _PivotPostMultiplyPivotMatrix;
  46765. /** @hidden */
  46766. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  46767. /** @hidden */
  46768. static _RestorePivotPoint(mesh: AbstractMesh): void;
  46769. }
  46770. }
  46771. declare module BABYLON {
  46772. /**
  46773. * Class containing static functions to help procedurally build meshes
  46774. */
  46775. export class PlaneBuilder {
  46776. /**
  46777. * Creates a plane mesh
  46778. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46779. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46780. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46782. * * 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
  46783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46784. * @param name defines the name of the mesh
  46785. * @param options defines the options used to create the mesh
  46786. * @param scene defines the hosting scene
  46787. * @returns the plane mesh
  46788. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46789. */
  46790. static CreatePlane(name: string, options: {
  46791. size?: number;
  46792. width?: number;
  46793. height?: number;
  46794. sideOrientation?: number;
  46795. frontUVs?: Vector4;
  46796. backUVs?: Vector4;
  46797. updatable?: boolean;
  46798. sourcePlane?: Plane;
  46799. }, scene?: Nullable<Scene>): Mesh;
  46800. }
  46801. }
  46802. declare module BABYLON {
  46803. /**
  46804. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  46805. */
  46806. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  46807. private static _AnyMouseID;
  46808. /**
  46809. * Abstract mesh the behavior is set on
  46810. */
  46811. attachedNode: AbstractMesh;
  46812. private _dragPlane;
  46813. private _scene;
  46814. private _pointerObserver;
  46815. private _beforeRenderObserver;
  46816. private static _planeScene;
  46817. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  46818. /**
  46819. * 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)
  46820. */
  46821. maxDragAngle: number;
  46822. /**
  46823. * @hidden
  46824. */
  46825. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  46826. /**
  46827. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46828. */
  46829. currentDraggingPointerID: number;
  46830. /**
  46831. * The last position where the pointer hit the drag plane in world space
  46832. */
  46833. lastDragPosition: Vector3;
  46834. /**
  46835. * If the behavior is currently in a dragging state
  46836. */
  46837. dragging: boolean;
  46838. /**
  46839. * 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)
  46840. */
  46841. dragDeltaRatio: number;
  46842. /**
  46843. * If the drag plane orientation should be updated during the dragging (Default: true)
  46844. */
  46845. updateDragPlane: boolean;
  46846. private _debugMode;
  46847. private _moving;
  46848. /**
  46849. * Fires each time the attached mesh is dragged with the pointer
  46850. * * delta between last drag position and current drag position in world space
  46851. * * dragDistance along the drag axis
  46852. * * dragPlaneNormal normal of the current drag plane used during the drag
  46853. * * dragPlanePoint in world space where the drag intersects the drag plane
  46854. */
  46855. onDragObservable: Observable<{
  46856. delta: Vector3;
  46857. dragPlanePoint: Vector3;
  46858. dragPlaneNormal: Vector3;
  46859. dragDistance: number;
  46860. pointerId: number;
  46861. }>;
  46862. /**
  46863. * Fires each time a drag begins (eg. mouse down on mesh)
  46864. */
  46865. onDragStartObservable: Observable<{
  46866. dragPlanePoint: Vector3;
  46867. pointerId: number;
  46868. }>;
  46869. /**
  46870. * Fires each time a drag ends (eg. mouse release after drag)
  46871. */
  46872. onDragEndObservable: Observable<{
  46873. dragPlanePoint: Vector3;
  46874. pointerId: number;
  46875. }>;
  46876. /**
  46877. * If the attached mesh should be moved when dragged
  46878. */
  46879. moveAttached: boolean;
  46880. /**
  46881. * If the drag behavior will react to drag events (Default: true)
  46882. */
  46883. enabled: boolean;
  46884. /**
  46885. * If pointer events should start and release the drag (Default: true)
  46886. */
  46887. startAndReleaseDragOnPointerEvents: boolean;
  46888. /**
  46889. * If camera controls should be detached during the drag
  46890. */
  46891. detachCameraControls: boolean;
  46892. /**
  46893. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  46894. */
  46895. useObjectOrientationForDragging: boolean;
  46896. private _options;
  46897. /**
  46898. * Gets the options used by the behavior
  46899. */
  46900. get options(): {
  46901. dragAxis?: Vector3;
  46902. dragPlaneNormal?: Vector3;
  46903. };
  46904. /**
  46905. * Sets the options used by the behavior
  46906. */
  46907. set options(options: {
  46908. dragAxis?: Vector3;
  46909. dragPlaneNormal?: Vector3;
  46910. });
  46911. /**
  46912. * Creates a pointer drag behavior that can be attached to a mesh
  46913. * @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)
  46914. */
  46915. constructor(options?: {
  46916. dragAxis?: Vector3;
  46917. dragPlaneNormal?: Vector3;
  46918. });
  46919. /**
  46920. * Predicate to determine if it is valid to move the object to a new position when it is moved
  46921. */
  46922. validateDrag: (targetPosition: Vector3) => boolean;
  46923. /**
  46924. * The name of the behavior
  46925. */
  46926. get name(): string;
  46927. /**
  46928. * Initializes the behavior
  46929. */
  46930. init(): void;
  46931. private _tmpVector;
  46932. private _alternatePickedPoint;
  46933. private _worldDragAxis;
  46934. private _targetPosition;
  46935. private _attachedElement;
  46936. /**
  46937. * Attaches the drag behavior the passed in mesh
  46938. * @param ownerNode The mesh that will be dragged around once attached
  46939. * @param predicate Predicate to use for pick filtering
  46940. */
  46941. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  46942. /**
  46943. * Force relase the drag action by code.
  46944. */
  46945. releaseDrag(): void;
  46946. private _startDragRay;
  46947. private _lastPointerRay;
  46948. /**
  46949. * Simulates the start of a pointer drag event on the behavior
  46950. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  46951. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  46952. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  46953. */
  46954. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46955. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46956. private _dragDelta;
  46957. protected _moveDrag(ray: Ray): void;
  46958. private _pickWithRayOnDragPlane;
  46959. private _pointA;
  46960. private _pointC;
  46961. private _localAxis;
  46962. private _lookAt;
  46963. private _updateDragPlanePosition;
  46964. /**
  46965. * Detaches the behavior from the mesh
  46966. */
  46967. detach(): void;
  46968. }
  46969. }
  46970. declare module BABYLON {
  46971. /**
  46972. * A behavior that when attached to a mesh will allow the mesh to be scaled
  46973. */
  46974. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  46975. private _dragBehaviorA;
  46976. private _dragBehaviorB;
  46977. private _startDistance;
  46978. private _initialScale;
  46979. private _targetScale;
  46980. private _ownerNode;
  46981. private _sceneRenderObserver;
  46982. /**
  46983. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  46984. */
  46985. constructor();
  46986. /**
  46987. * The name of the behavior
  46988. */
  46989. get name(): string;
  46990. /**
  46991. * Initializes the behavior
  46992. */
  46993. init(): void;
  46994. private _getCurrentDistance;
  46995. /**
  46996. * Attaches the scale behavior the passed in mesh
  46997. * @param ownerNode The mesh that will be scaled around once attached
  46998. */
  46999. attach(ownerNode: Mesh): void;
  47000. /**
  47001. * Detaches the behavior from the mesh
  47002. */
  47003. detach(): void;
  47004. }
  47005. }
  47006. declare module BABYLON {
  47007. /**
  47008. * 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
  47009. */
  47010. export class SixDofDragBehavior implements Behavior<Mesh> {
  47011. private static _virtualScene;
  47012. private _ownerNode;
  47013. private _sceneRenderObserver;
  47014. private _scene;
  47015. private _targetPosition;
  47016. private _virtualOriginMesh;
  47017. private _virtualDragMesh;
  47018. private _pointerObserver;
  47019. private _moving;
  47020. private _startingOrientation;
  47021. private _attachedElement;
  47022. /**
  47023. * 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)
  47024. */
  47025. private zDragFactor;
  47026. /**
  47027. * If the object should rotate to face the drag origin
  47028. */
  47029. rotateDraggedObject: boolean;
  47030. /**
  47031. * If the behavior is currently in a dragging state
  47032. */
  47033. dragging: boolean;
  47034. /**
  47035. * 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)
  47036. */
  47037. dragDeltaRatio: number;
  47038. /**
  47039. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47040. */
  47041. currentDraggingPointerID: number;
  47042. /**
  47043. * If camera controls should be detached during the drag
  47044. */
  47045. detachCameraControls: boolean;
  47046. /**
  47047. * Fires each time a drag starts
  47048. */
  47049. onDragStartObservable: Observable<{}>;
  47050. /**
  47051. * Fires each time a drag ends (eg. mouse release after drag)
  47052. */
  47053. onDragEndObservable: Observable<{}>;
  47054. /**
  47055. * 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
  47056. */
  47057. constructor();
  47058. /**
  47059. * The name of the behavior
  47060. */
  47061. get name(): string;
  47062. /**
  47063. * Initializes the behavior
  47064. */
  47065. init(): void;
  47066. /**
  47067. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47068. */
  47069. private get _pointerCamera();
  47070. /**
  47071. * Attaches the scale behavior the passed in mesh
  47072. * @param ownerNode The mesh that will be scaled around once attached
  47073. */
  47074. attach(ownerNode: Mesh): void;
  47075. /**
  47076. * Detaches the behavior from the mesh
  47077. */
  47078. detach(): void;
  47079. }
  47080. }
  47081. declare module BABYLON {
  47082. /**
  47083. * Class used to apply inverse kinematics to bones
  47084. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47085. */
  47086. export class BoneIKController {
  47087. private static _tmpVecs;
  47088. private static _tmpQuat;
  47089. private static _tmpMats;
  47090. /**
  47091. * Gets or sets the target mesh
  47092. */
  47093. targetMesh: AbstractMesh;
  47094. /** Gets or sets the mesh used as pole */
  47095. poleTargetMesh: AbstractMesh;
  47096. /**
  47097. * Gets or sets the bone used as pole
  47098. */
  47099. poleTargetBone: Nullable<Bone>;
  47100. /**
  47101. * Gets or sets the target position
  47102. */
  47103. targetPosition: Vector3;
  47104. /**
  47105. * Gets or sets the pole target position
  47106. */
  47107. poleTargetPosition: Vector3;
  47108. /**
  47109. * Gets or sets the pole target local offset
  47110. */
  47111. poleTargetLocalOffset: Vector3;
  47112. /**
  47113. * Gets or sets the pole angle
  47114. */
  47115. poleAngle: number;
  47116. /**
  47117. * Gets or sets the mesh associated with the controller
  47118. */
  47119. mesh: AbstractMesh;
  47120. /**
  47121. * 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)
  47122. */
  47123. slerpAmount: number;
  47124. private _bone1Quat;
  47125. private _bone1Mat;
  47126. private _bone2Ang;
  47127. private _bone1;
  47128. private _bone2;
  47129. private _bone1Length;
  47130. private _bone2Length;
  47131. private _maxAngle;
  47132. private _maxReach;
  47133. private _rightHandedSystem;
  47134. private _bendAxis;
  47135. private _slerping;
  47136. private _adjustRoll;
  47137. /**
  47138. * Gets or sets maximum allowed angle
  47139. */
  47140. get maxAngle(): number;
  47141. set maxAngle(value: number);
  47142. /**
  47143. * Creates a new BoneIKController
  47144. * @param mesh defines the mesh to control
  47145. * @param bone defines the bone to control
  47146. * @param options defines options to set up the controller
  47147. */
  47148. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47149. targetMesh?: AbstractMesh;
  47150. poleTargetMesh?: AbstractMesh;
  47151. poleTargetBone?: Bone;
  47152. poleTargetLocalOffset?: Vector3;
  47153. poleAngle?: number;
  47154. bendAxis?: Vector3;
  47155. maxAngle?: number;
  47156. slerpAmount?: number;
  47157. });
  47158. private _setMaxAngle;
  47159. /**
  47160. * Force the controller to update the bones
  47161. */
  47162. update(): void;
  47163. }
  47164. }
  47165. declare module BABYLON {
  47166. /**
  47167. * Class used to make a bone look toward a point in space
  47168. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47169. */
  47170. export class BoneLookController {
  47171. private static _tmpVecs;
  47172. private static _tmpQuat;
  47173. private static _tmpMats;
  47174. /**
  47175. * The target Vector3 that the bone will look at
  47176. */
  47177. target: Vector3;
  47178. /**
  47179. * The mesh that the bone is attached to
  47180. */
  47181. mesh: AbstractMesh;
  47182. /**
  47183. * The bone that will be looking to the target
  47184. */
  47185. bone: Bone;
  47186. /**
  47187. * The up axis of the coordinate system that is used when the bone is rotated
  47188. */
  47189. upAxis: Vector3;
  47190. /**
  47191. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47192. */
  47193. upAxisSpace: Space;
  47194. /**
  47195. * Used to make an adjustment to the yaw of the bone
  47196. */
  47197. adjustYaw: number;
  47198. /**
  47199. * Used to make an adjustment to the pitch of the bone
  47200. */
  47201. adjustPitch: number;
  47202. /**
  47203. * Used to make an adjustment to the roll of the bone
  47204. */
  47205. adjustRoll: number;
  47206. /**
  47207. * 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)
  47208. */
  47209. slerpAmount: number;
  47210. private _minYaw;
  47211. private _maxYaw;
  47212. private _minPitch;
  47213. private _maxPitch;
  47214. private _minYawSin;
  47215. private _minYawCos;
  47216. private _maxYawSin;
  47217. private _maxYawCos;
  47218. private _midYawConstraint;
  47219. private _minPitchTan;
  47220. private _maxPitchTan;
  47221. private _boneQuat;
  47222. private _slerping;
  47223. private _transformYawPitch;
  47224. private _transformYawPitchInv;
  47225. private _firstFrameSkipped;
  47226. private _yawRange;
  47227. private _fowardAxis;
  47228. /**
  47229. * Gets or sets the minimum yaw angle that the bone can look to
  47230. */
  47231. get minYaw(): number;
  47232. set minYaw(value: number);
  47233. /**
  47234. * Gets or sets the maximum yaw angle that the bone can look to
  47235. */
  47236. get maxYaw(): number;
  47237. set maxYaw(value: number);
  47238. /**
  47239. * Gets or sets the minimum pitch angle that the bone can look to
  47240. */
  47241. get minPitch(): number;
  47242. set minPitch(value: number);
  47243. /**
  47244. * Gets or sets the maximum pitch angle that the bone can look to
  47245. */
  47246. get maxPitch(): number;
  47247. set maxPitch(value: number);
  47248. /**
  47249. * Create a BoneLookController
  47250. * @param mesh the mesh that the bone belongs to
  47251. * @param bone the bone that will be looking to the target
  47252. * @param target the target Vector3 to look at
  47253. * @param options optional settings:
  47254. * * maxYaw: the maximum angle the bone will yaw to
  47255. * * minYaw: the minimum angle the bone will yaw to
  47256. * * maxPitch: the maximum angle the bone will pitch to
  47257. * * minPitch: the minimum angle the bone will yaw to
  47258. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47259. * * upAxis: the up axis of the coordinate system
  47260. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47261. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47262. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47263. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47264. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47265. * * adjustRoll: used to make an adjustment to the roll of the bone
  47266. **/
  47267. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47268. maxYaw?: number;
  47269. minYaw?: number;
  47270. maxPitch?: number;
  47271. minPitch?: number;
  47272. slerpAmount?: number;
  47273. upAxis?: Vector3;
  47274. upAxisSpace?: Space;
  47275. yawAxis?: Vector3;
  47276. pitchAxis?: Vector3;
  47277. adjustYaw?: number;
  47278. adjustPitch?: number;
  47279. adjustRoll?: number;
  47280. });
  47281. /**
  47282. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47283. */
  47284. update(): void;
  47285. private _getAngleDiff;
  47286. private _getAngleBetween;
  47287. private _isAngleBetween;
  47288. }
  47289. }
  47290. declare module BABYLON {
  47291. /**
  47292. * Manage the gamepad inputs to control an arc rotate camera.
  47293. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47294. */
  47295. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47296. /**
  47297. * Defines the camera the input is attached to.
  47298. */
  47299. camera: ArcRotateCamera;
  47300. /**
  47301. * Defines the gamepad the input is gathering event from.
  47302. */
  47303. gamepad: Nullable<Gamepad>;
  47304. /**
  47305. * Defines the gamepad rotation sensiblity.
  47306. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47307. */
  47308. gamepadRotationSensibility: number;
  47309. /**
  47310. * Defines the gamepad move sensiblity.
  47311. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47312. */
  47313. gamepadMoveSensibility: number;
  47314. private _yAxisScale;
  47315. /**
  47316. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47317. */
  47318. get invertYAxis(): boolean;
  47319. set invertYAxis(value: boolean);
  47320. private _onGamepadConnectedObserver;
  47321. private _onGamepadDisconnectedObserver;
  47322. /**
  47323. * Attach the input controls to a specific dom element to get the input from.
  47324. */
  47325. attachControl(): void;
  47326. /**
  47327. * Detach the current controls from the specified dom element.
  47328. * @param element Defines the element to stop listening the inputs from
  47329. */
  47330. detachControl(): void;
  47331. /**
  47332. * Update the current camera state depending on the inputs that have been used this frame.
  47333. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47334. */
  47335. checkInputs(): void;
  47336. /**
  47337. * Gets the class name of the current intput.
  47338. * @returns the class name
  47339. */
  47340. getClassName(): string;
  47341. /**
  47342. * Get the friendly name associated with the input class.
  47343. * @returns the input friendly name
  47344. */
  47345. getSimpleName(): string;
  47346. }
  47347. }
  47348. declare module BABYLON {
  47349. interface ArcRotateCameraInputsManager {
  47350. /**
  47351. * Add orientation input support to the input manager.
  47352. * @returns the current input manager
  47353. */
  47354. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47355. }
  47356. /**
  47357. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47358. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47359. */
  47360. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47361. /**
  47362. * Defines the camera the input is attached to.
  47363. */
  47364. camera: ArcRotateCamera;
  47365. /**
  47366. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47367. */
  47368. alphaCorrection: number;
  47369. /**
  47370. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47371. */
  47372. gammaCorrection: number;
  47373. private _alpha;
  47374. private _gamma;
  47375. private _dirty;
  47376. private _deviceOrientationHandler;
  47377. /**
  47378. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47379. */
  47380. constructor();
  47381. /**
  47382. * Attach the input controls to a specific dom element to get the input from.
  47383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47384. */
  47385. attachControl(noPreventDefault?: boolean): void;
  47386. /** @hidden */
  47387. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47388. /**
  47389. * Update the current camera state depending on the inputs that have been used this frame.
  47390. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47391. */
  47392. checkInputs(): void;
  47393. /**
  47394. * Detach the current controls from the specified dom element.
  47395. */
  47396. detachControl(): void;
  47397. /**
  47398. * Gets the class name of the current intput.
  47399. * @returns the class name
  47400. */
  47401. getClassName(): string;
  47402. /**
  47403. * Get the friendly name associated with the input class.
  47404. * @returns the input friendly name
  47405. */
  47406. getSimpleName(): string;
  47407. }
  47408. }
  47409. declare module BABYLON {
  47410. /**
  47411. * Listen to mouse events to control the camera.
  47412. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47413. */
  47414. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47415. /**
  47416. * Defines the camera the input is attached to.
  47417. */
  47418. camera: FlyCamera;
  47419. /**
  47420. * Defines if touch is enabled. (Default is true.)
  47421. */
  47422. touchEnabled: boolean;
  47423. /**
  47424. * Defines the buttons associated with the input to handle camera rotation.
  47425. */
  47426. buttons: number[];
  47427. /**
  47428. * Assign buttons for Yaw control.
  47429. */
  47430. buttonsYaw: number[];
  47431. /**
  47432. * Assign buttons for Pitch control.
  47433. */
  47434. buttonsPitch: number[];
  47435. /**
  47436. * Assign buttons for Roll control.
  47437. */
  47438. buttonsRoll: number[];
  47439. /**
  47440. * Detect if any button is being pressed while mouse is moved.
  47441. * -1 = Mouse locked.
  47442. * 0 = Left button.
  47443. * 1 = Middle Button.
  47444. * 2 = Right Button.
  47445. */
  47446. activeButton: number;
  47447. /**
  47448. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47449. * Higher values reduce its sensitivity.
  47450. */
  47451. angularSensibility: number;
  47452. private _observer;
  47453. private _rollObserver;
  47454. private previousPosition;
  47455. private noPreventDefault;
  47456. private element;
  47457. /**
  47458. * Listen to mouse events to control the camera.
  47459. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47460. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47461. */
  47462. constructor(touchEnabled?: boolean);
  47463. /**
  47464. * Attach the mouse control to the HTML DOM element.
  47465. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47466. */
  47467. attachControl(noPreventDefault?: boolean): void;
  47468. /**
  47469. * Detach the current controls from the specified dom element.
  47470. */
  47471. detachControl(): void;
  47472. /**
  47473. * Gets the class name of the current input.
  47474. * @returns the class name.
  47475. */
  47476. getClassName(): string;
  47477. /**
  47478. * Get the friendly name associated with the input class.
  47479. * @returns the input's friendly name.
  47480. */
  47481. getSimpleName(): string;
  47482. private _pointerInput;
  47483. private _onMouseMove;
  47484. /**
  47485. * Rotate camera by mouse offset.
  47486. */
  47487. private rotateCamera;
  47488. }
  47489. }
  47490. declare module BABYLON {
  47491. /**
  47492. * Default Inputs manager for the FlyCamera.
  47493. * It groups all the default supported inputs for ease of use.
  47494. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47495. */
  47496. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47497. /**
  47498. * Instantiates a new FlyCameraInputsManager.
  47499. * @param camera Defines the camera the inputs belong to.
  47500. */
  47501. constructor(camera: FlyCamera);
  47502. /**
  47503. * Add keyboard input support to the input manager.
  47504. * @returns the new FlyCameraKeyboardMoveInput().
  47505. */
  47506. addKeyboard(): FlyCameraInputsManager;
  47507. /**
  47508. * Add mouse input support to the input manager.
  47509. * @param touchEnabled Enable touch screen support.
  47510. * @returns the new FlyCameraMouseInput().
  47511. */
  47512. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47513. }
  47514. }
  47515. declare module BABYLON {
  47516. /**
  47517. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47518. * such as in a 3D Space Shooter or a Flight Simulator.
  47519. */
  47520. export class FlyCamera extends TargetCamera {
  47521. /**
  47522. * Define the collision ellipsoid of the camera.
  47523. * This is helpful for simulating a camera body, like a player's body.
  47524. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47525. */
  47526. ellipsoid: Vector3;
  47527. /**
  47528. * Define an offset for the position of the ellipsoid around the camera.
  47529. * This can be helpful if the camera is attached away from the player's body center,
  47530. * such as at its head.
  47531. */
  47532. ellipsoidOffset: Vector3;
  47533. /**
  47534. * Enable or disable collisions of the camera with the rest of the scene objects.
  47535. */
  47536. checkCollisions: boolean;
  47537. /**
  47538. * Enable or disable gravity on the camera.
  47539. */
  47540. applyGravity: boolean;
  47541. /**
  47542. * Define the current direction the camera is moving to.
  47543. */
  47544. cameraDirection: Vector3;
  47545. /**
  47546. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47547. * This overrides and empties cameraRotation.
  47548. */
  47549. rotationQuaternion: Quaternion;
  47550. /**
  47551. * Track Roll to maintain the wanted Rolling when looking around.
  47552. */
  47553. _trackRoll: number;
  47554. /**
  47555. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47556. */
  47557. rollCorrect: number;
  47558. /**
  47559. * Mimic a banked turn, Rolling the camera when Yawing.
  47560. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47561. */
  47562. bankedTurn: boolean;
  47563. /**
  47564. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47565. */
  47566. bankedTurnLimit: number;
  47567. /**
  47568. * Value of 0 disables the banked Roll.
  47569. * Value of 1 is equal to the Yaw angle in radians.
  47570. */
  47571. bankedTurnMultiplier: number;
  47572. /**
  47573. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47574. */
  47575. inputs: FlyCameraInputsManager;
  47576. /**
  47577. * Gets the input sensibility for mouse input.
  47578. * Higher values reduce sensitivity.
  47579. */
  47580. get angularSensibility(): number;
  47581. /**
  47582. * Sets the input sensibility for a mouse input.
  47583. * Higher values reduce sensitivity.
  47584. */
  47585. set angularSensibility(value: number);
  47586. /**
  47587. * Get the keys for camera movement forward.
  47588. */
  47589. get keysForward(): number[];
  47590. /**
  47591. * Set the keys for camera movement forward.
  47592. */
  47593. set keysForward(value: number[]);
  47594. /**
  47595. * Get the keys for camera movement backward.
  47596. */
  47597. get keysBackward(): number[];
  47598. set keysBackward(value: number[]);
  47599. /**
  47600. * Get the keys for camera movement up.
  47601. */
  47602. get keysUp(): number[];
  47603. /**
  47604. * Set the keys for camera movement up.
  47605. */
  47606. set keysUp(value: number[]);
  47607. /**
  47608. * Get the keys for camera movement down.
  47609. */
  47610. get keysDown(): number[];
  47611. /**
  47612. * Set the keys for camera movement down.
  47613. */
  47614. set keysDown(value: number[]);
  47615. /**
  47616. * Get the keys for camera movement left.
  47617. */
  47618. get keysLeft(): number[];
  47619. /**
  47620. * Set the keys for camera movement left.
  47621. */
  47622. set keysLeft(value: number[]);
  47623. /**
  47624. * Set the keys for camera movement right.
  47625. */
  47626. get keysRight(): number[];
  47627. /**
  47628. * Set the keys for camera movement right.
  47629. */
  47630. set keysRight(value: number[]);
  47631. /**
  47632. * Event raised when the camera collides with a mesh in the scene.
  47633. */
  47634. onCollide: (collidedMesh: AbstractMesh) => void;
  47635. private _collider;
  47636. private _needMoveForGravity;
  47637. private _oldPosition;
  47638. private _diffPosition;
  47639. private _newPosition;
  47640. /** @hidden */
  47641. _localDirection: Vector3;
  47642. /** @hidden */
  47643. _transformedDirection: Vector3;
  47644. /**
  47645. * Instantiates a FlyCamera.
  47646. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47647. * such as in a 3D Space Shooter or a Flight Simulator.
  47648. * @param name Define the name of the camera in the scene.
  47649. * @param position Define the starting position of the camera in the scene.
  47650. * @param scene Define the scene the camera belongs to.
  47651. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47652. */
  47653. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47654. /**
  47655. * Attach a control to the HTML DOM element.
  47656. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  47657. */
  47658. attachControl(noPreventDefault?: boolean): void;
  47659. /**
  47660. * Detach a control from the HTML DOM element.
  47661. * The camera will stop reacting to that input.
  47662. */
  47663. detachControl(): void;
  47664. private _collisionMask;
  47665. /**
  47666. * Get the mask that the camera ignores in collision events.
  47667. */
  47668. get collisionMask(): number;
  47669. /**
  47670. * Set the mask that the camera ignores in collision events.
  47671. */
  47672. set collisionMask(mask: number);
  47673. /** @hidden */
  47674. _collideWithWorld(displacement: Vector3): void;
  47675. /** @hidden */
  47676. private _onCollisionPositionChange;
  47677. /** @hidden */
  47678. _checkInputs(): void;
  47679. /** @hidden */
  47680. _decideIfNeedsToMove(): boolean;
  47681. /** @hidden */
  47682. _updatePosition(): void;
  47683. /**
  47684. * Restore the Roll to its target value at the rate specified.
  47685. * @param rate - Higher means slower restoring.
  47686. * @hidden
  47687. */
  47688. restoreRoll(rate: number): void;
  47689. /**
  47690. * Destroy the camera and release the current resources held by it.
  47691. */
  47692. dispose(): void;
  47693. /**
  47694. * Get the current object class name.
  47695. * @returns the class name.
  47696. */
  47697. getClassName(): string;
  47698. }
  47699. }
  47700. declare module BABYLON {
  47701. /**
  47702. * Listen to keyboard events to control the camera.
  47703. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47704. */
  47705. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  47706. /**
  47707. * Defines the camera the input is attached to.
  47708. */
  47709. camera: FlyCamera;
  47710. /**
  47711. * The list of keyboard keys used to control the forward move of the camera.
  47712. */
  47713. keysForward: number[];
  47714. /**
  47715. * The list of keyboard keys used to control the backward move of the camera.
  47716. */
  47717. keysBackward: number[];
  47718. /**
  47719. * The list of keyboard keys used to control the forward move of the camera.
  47720. */
  47721. keysUp: number[];
  47722. /**
  47723. * The list of keyboard keys used to control the backward move of the camera.
  47724. */
  47725. keysDown: number[];
  47726. /**
  47727. * The list of keyboard keys used to control the right strafe move of the camera.
  47728. */
  47729. keysRight: number[];
  47730. /**
  47731. * The list of keyboard keys used to control the left strafe move of the camera.
  47732. */
  47733. keysLeft: number[];
  47734. private _keys;
  47735. private _onCanvasBlurObserver;
  47736. private _onKeyboardObserver;
  47737. private _engine;
  47738. private _scene;
  47739. /**
  47740. * Attach the input controls to a specific dom element to get the input from.
  47741. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47742. */
  47743. attachControl(noPreventDefault?: boolean): void;
  47744. /**
  47745. * Detach the current controls from the specified dom element.
  47746. */
  47747. detachControl(): void;
  47748. /**
  47749. * Gets the class name of the current intput.
  47750. * @returns the class name
  47751. */
  47752. getClassName(): string;
  47753. /** @hidden */
  47754. _onLostFocus(e: FocusEvent): void;
  47755. /**
  47756. * Get the friendly name associated with the input class.
  47757. * @returns the input friendly name
  47758. */
  47759. getSimpleName(): string;
  47760. /**
  47761. * Update the current camera state depending on the inputs that have been used this frame.
  47762. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47763. */
  47764. checkInputs(): void;
  47765. }
  47766. }
  47767. declare module BABYLON {
  47768. /**
  47769. * Manage the mouse wheel inputs to control a follow camera.
  47770. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47771. */
  47772. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  47773. /**
  47774. * Defines the camera the input is attached to.
  47775. */
  47776. camera: FollowCamera;
  47777. /**
  47778. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  47779. */
  47780. axisControlRadius: boolean;
  47781. /**
  47782. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  47783. */
  47784. axisControlHeight: boolean;
  47785. /**
  47786. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  47787. */
  47788. axisControlRotation: boolean;
  47789. /**
  47790. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  47791. * relation to mouseWheel events.
  47792. */
  47793. wheelPrecision: number;
  47794. /**
  47795. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47796. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47797. */
  47798. wheelDeltaPercentage: number;
  47799. private _wheel;
  47800. private _observer;
  47801. /**
  47802. * Attach the input controls to a specific dom element to get the input from.
  47803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47804. */
  47805. attachControl(noPreventDefault?: boolean): void;
  47806. /**
  47807. * Detach the current controls from the specified dom element.
  47808. */
  47809. detachControl(): void;
  47810. /**
  47811. * Gets the class name of the current intput.
  47812. * @returns the class name
  47813. */
  47814. getClassName(): string;
  47815. /**
  47816. * Get the friendly name associated with the input class.
  47817. * @returns the input friendly name
  47818. */
  47819. getSimpleName(): string;
  47820. }
  47821. }
  47822. declare module BABYLON {
  47823. /**
  47824. * Manage the pointers inputs to control an follow camera.
  47825. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47826. */
  47827. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  47828. /**
  47829. * Defines the camera the input is attached to.
  47830. */
  47831. camera: FollowCamera;
  47832. /**
  47833. * Gets the class name of the current input.
  47834. * @returns the class name
  47835. */
  47836. getClassName(): string;
  47837. /**
  47838. * Defines the pointer angular sensibility along the X axis or how fast is
  47839. * the camera rotating.
  47840. * A negative number will reverse the axis direction.
  47841. */
  47842. angularSensibilityX: number;
  47843. /**
  47844. * Defines the pointer angular sensibility along the Y axis or how fast is
  47845. * the camera rotating.
  47846. * A negative number will reverse the axis direction.
  47847. */
  47848. angularSensibilityY: number;
  47849. /**
  47850. * Defines the pointer pinch precision or how fast is the camera zooming.
  47851. * A negative number will reverse the axis direction.
  47852. */
  47853. pinchPrecision: number;
  47854. /**
  47855. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47856. * from 0.
  47857. * It defines the percentage of current camera.radius to use as delta when
  47858. * pinch zoom is used.
  47859. */
  47860. pinchDeltaPercentage: number;
  47861. /**
  47862. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  47863. */
  47864. axisXControlRadius: boolean;
  47865. /**
  47866. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  47867. */
  47868. axisXControlHeight: boolean;
  47869. /**
  47870. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  47871. */
  47872. axisXControlRotation: boolean;
  47873. /**
  47874. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  47875. */
  47876. axisYControlRadius: boolean;
  47877. /**
  47878. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  47879. */
  47880. axisYControlHeight: boolean;
  47881. /**
  47882. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  47883. */
  47884. axisYControlRotation: boolean;
  47885. /**
  47886. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  47887. */
  47888. axisPinchControlRadius: boolean;
  47889. /**
  47890. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  47891. */
  47892. axisPinchControlHeight: boolean;
  47893. /**
  47894. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  47895. */
  47896. axisPinchControlRotation: boolean;
  47897. /**
  47898. * Log error messages if basic misconfiguration has occurred.
  47899. */
  47900. warningEnable: boolean;
  47901. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47902. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47903. private _warningCounter;
  47904. private _warning;
  47905. }
  47906. }
  47907. declare module BABYLON {
  47908. /**
  47909. * Default Inputs manager for the FollowCamera.
  47910. * It groups all the default supported inputs for ease of use.
  47911. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47912. */
  47913. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  47914. /**
  47915. * Instantiates a new FollowCameraInputsManager.
  47916. * @param camera Defines the camera the inputs belong to
  47917. */
  47918. constructor(camera: FollowCamera);
  47919. /**
  47920. * Add keyboard input support to the input manager.
  47921. * @returns the current input manager
  47922. */
  47923. addKeyboard(): FollowCameraInputsManager;
  47924. /**
  47925. * Add mouse wheel input support to the input manager.
  47926. * @returns the current input manager
  47927. */
  47928. addMouseWheel(): FollowCameraInputsManager;
  47929. /**
  47930. * Add pointers input support to the input manager.
  47931. * @returns the current input manager
  47932. */
  47933. addPointers(): FollowCameraInputsManager;
  47934. /**
  47935. * Add orientation input support to the input manager.
  47936. * @returns the current input manager
  47937. */
  47938. addVRDeviceOrientation(): FollowCameraInputsManager;
  47939. }
  47940. }
  47941. declare module BABYLON {
  47942. /**
  47943. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  47944. * an arc rotate version arcFollowCamera are available.
  47945. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47946. */
  47947. export class FollowCamera extends TargetCamera {
  47948. /**
  47949. * Distance the follow camera should follow an object at
  47950. */
  47951. radius: number;
  47952. /**
  47953. * Minimum allowed distance of the camera to the axis of rotation
  47954. * (The camera can not get closer).
  47955. * This can help limiting how the Camera is able to move in the scene.
  47956. */
  47957. lowerRadiusLimit: Nullable<number>;
  47958. /**
  47959. * Maximum allowed distance of the camera to the axis of rotation
  47960. * (The camera can not get further).
  47961. * This can help limiting how the Camera is able to move in the scene.
  47962. */
  47963. upperRadiusLimit: Nullable<number>;
  47964. /**
  47965. * Define a rotation offset between the camera and the object it follows
  47966. */
  47967. rotationOffset: number;
  47968. /**
  47969. * Minimum allowed angle to camera position relative to target object.
  47970. * This can help limiting how the Camera is able to move in the scene.
  47971. */
  47972. lowerRotationOffsetLimit: Nullable<number>;
  47973. /**
  47974. * Maximum allowed angle to camera position relative to target object.
  47975. * This can help limiting how the Camera is able to move in the scene.
  47976. */
  47977. upperRotationOffsetLimit: Nullable<number>;
  47978. /**
  47979. * Define a height offset between the camera and the object it follows.
  47980. * It can help following an object from the top (like a car chaing a plane)
  47981. */
  47982. heightOffset: number;
  47983. /**
  47984. * Minimum allowed height of camera position relative to target object.
  47985. * This can help limiting how the Camera is able to move in the scene.
  47986. */
  47987. lowerHeightOffsetLimit: Nullable<number>;
  47988. /**
  47989. * Maximum allowed height of camera position relative to target object.
  47990. * This can help limiting how the Camera is able to move in the scene.
  47991. */
  47992. upperHeightOffsetLimit: Nullable<number>;
  47993. /**
  47994. * Define how fast the camera can accelerate to follow it s target.
  47995. */
  47996. cameraAcceleration: number;
  47997. /**
  47998. * Define the speed limit of the camera following an object.
  47999. */
  48000. maxCameraSpeed: number;
  48001. /**
  48002. * Define the target of the camera.
  48003. */
  48004. lockedTarget: Nullable<AbstractMesh>;
  48005. /**
  48006. * Defines the input associated with the camera.
  48007. */
  48008. inputs: FollowCameraInputsManager;
  48009. /**
  48010. * Instantiates the follow camera.
  48011. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48012. * @param name Define the name of the camera in the scene
  48013. * @param position Define the position of the camera
  48014. * @param scene Define the scene the camera belong to
  48015. * @param lockedTarget Define the target of the camera
  48016. */
  48017. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48018. private _follow;
  48019. /**
  48020. * Attached controls to the current camera.
  48021. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48022. */
  48023. attachControl(noPreventDefault?: boolean): void;
  48024. /**
  48025. * Detach the current controls from the camera.
  48026. * The camera will stop reacting to inputs.
  48027. */
  48028. detachControl(): void;
  48029. /** @hidden */
  48030. _checkInputs(): void;
  48031. private _checkLimits;
  48032. /**
  48033. * Gets the camera class name.
  48034. * @returns the class name
  48035. */
  48036. getClassName(): string;
  48037. }
  48038. /**
  48039. * Arc Rotate version of the follow camera.
  48040. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48041. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48042. */
  48043. export class ArcFollowCamera extends TargetCamera {
  48044. /** The longitudinal angle of the camera */
  48045. alpha: number;
  48046. /** The latitudinal angle of the camera */
  48047. beta: number;
  48048. /** The radius of the camera from its target */
  48049. radius: number;
  48050. private _cartesianCoordinates;
  48051. /** Define the camera target (the mesh it should follow) */
  48052. private _meshTarget;
  48053. /**
  48054. * Instantiates a new ArcFollowCamera
  48055. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48056. * @param name Define the name of the camera
  48057. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48058. * @param beta Define the rotation angle of the camera around the elevation axis
  48059. * @param radius Define the radius of the camera from its target point
  48060. * @param target Define the target of the camera
  48061. * @param scene Define the scene the camera belongs to
  48062. */
  48063. constructor(name: string,
  48064. /** The longitudinal angle of the camera */
  48065. alpha: number,
  48066. /** The latitudinal angle of the camera */
  48067. beta: number,
  48068. /** The radius of the camera from its target */
  48069. radius: number,
  48070. /** Define the camera target (the mesh it should follow) */
  48071. target: Nullable<AbstractMesh>, scene: Scene);
  48072. private _follow;
  48073. /** @hidden */
  48074. _checkInputs(): void;
  48075. /**
  48076. * Returns the class name of the object.
  48077. * It is mostly used internally for serialization purposes.
  48078. */
  48079. getClassName(): string;
  48080. }
  48081. }
  48082. declare module BABYLON {
  48083. /**
  48084. * Manage the keyboard inputs to control the movement of a follow camera.
  48085. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48086. */
  48087. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48088. /**
  48089. * Defines the camera the input is attached to.
  48090. */
  48091. camera: FollowCamera;
  48092. /**
  48093. * Defines the list of key codes associated with the up action (increase heightOffset)
  48094. */
  48095. keysHeightOffsetIncr: number[];
  48096. /**
  48097. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48098. */
  48099. keysHeightOffsetDecr: number[];
  48100. /**
  48101. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48102. */
  48103. keysHeightOffsetModifierAlt: boolean;
  48104. /**
  48105. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48106. */
  48107. keysHeightOffsetModifierCtrl: boolean;
  48108. /**
  48109. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48110. */
  48111. keysHeightOffsetModifierShift: boolean;
  48112. /**
  48113. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48114. */
  48115. keysRotationOffsetIncr: number[];
  48116. /**
  48117. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48118. */
  48119. keysRotationOffsetDecr: number[];
  48120. /**
  48121. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48122. */
  48123. keysRotationOffsetModifierAlt: boolean;
  48124. /**
  48125. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48126. */
  48127. keysRotationOffsetModifierCtrl: boolean;
  48128. /**
  48129. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48130. */
  48131. keysRotationOffsetModifierShift: boolean;
  48132. /**
  48133. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48134. */
  48135. keysRadiusIncr: number[];
  48136. /**
  48137. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48138. */
  48139. keysRadiusDecr: number[];
  48140. /**
  48141. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48142. */
  48143. keysRadiusModifierAlt: boolean;
  48144. /**
  48145. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48146. */
  48147. keysRadiusModifierCtrl: boolean;
  48148. /**
  48149. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48150. */
  48151. keysRadiusModifierShift: boolean;
  48152. /**
  48153. * Defines the rate of change of heightOffset.
  48154. */
  48155. heightSensibility: number;
  48156. /**
  48157. * Defines the rate of change of rotationOffset.
  48158. */
  48159. rotationSensibility: number;
  48160. /**
  48161. * Defines the rate of change of radius.
  48162. */
  48163. radiusSensibility: number;
  48164. private _keys;
  48165. private _ctrlPressed;
  48166. private _altPressed;
  48167. private _shiftPressed;
  48168. private _onCanvasBlurObserver;
  48169. private _onKeyboardObserver;
  48170. private _engine;
  48171. private _scene;
  48172. /**
  48173. * Attach the input controls to a specific dom element to get the input from.
  48174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48175. */
  48176. attachControl(noPreventDefault?: boolean): void;
  48177. /**
  48178. * Detach the current controls from the specified dom element.
  48179. */
  48180. detachControl(): void;
  48181. /**
  48182. * Update the current camera state depending on the inputs that have been used this frame.
  48183. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48184. */
  48185. checkInputs(): void;
  48186. /**
  48187. * Gets the class name of the current input.
  48188. * @returns the class name
  48189. */
  48190. getClassName(): string;
  48191. /**
  48192. * Get the friendly name associated with the input class.
  48193. * @returns the input friendly name
  48194. */
  48195. getSimpleName(): string;
  48196. /**
  48197. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48198. * allow modification of the heightOffset value.
  48199. */
  48200. private _modifierHeightOffset;
  48201. /**
  48202. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48203. * allow modification of the rotationOffset value.
  48204. */
  48205. private _modifierRotationOffset;
  48206. /**
  48207. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48208. * allow modification of the radius value.
  48209. */
  48210. private _modifierRadius;
  48211. }
  48212. }
  48213. declare module BABYLON {
  48214. interface FreeCameraInputsManager {
  48215. /**
  48216. * @hidden
  48217. */
  48218. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48219. /**
  48220. * Add orientation input support to the input manager.
  48221. * @returns the current input manager
  48222. */
  48223. addDeviceOrientation(): FreeCameraInputsManager;
  48224. }
  48225. /**
  48226. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48227. * Screen rotation is taken into account.
  48228. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48229. */
  48230. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48231. private _camera;
  48232. private _screenOrientationAngle;
  48233. private _constantTranform;
  48234. private _screenQuaternion;
  48235. private _alpha;
  48236. private _beta;
  48237. private _gamma;
  48238. /**
  48239. * Can be used to detect if a device orientation sensor is available on a device
  48240. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48241. * @returns a promise that will resolve on orientation change
  48242. */
  48243. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  48244. /**
  48245. * @hidden
  48246. */
  48247. _onDeviceOrientationChangedObservable: Observable<void>;
  48248. /**
  48249. * Instantiates a new input
  48250. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48251. */
  48252. constructor();
  48253. /**
  48254. * Define the camera controlled by the input.
  48255. */
  48256. get camera(): FreeCamera;
  48257. set camera(camera: FreeCamera);
  48258. /**
  48259. * Attach the input controls to a specific dom element to get the input from.
  48260. */
  48261. attachControl(): void;
  48262. private _orientationChanged;
  48263. private _deviceOrientation;
  48264. /**
  48265. * Detach the current controls from the specified dom element.
  48266. */
  48267. detachControl(): void;
  48268. /**
  48269. * Update the current camera state depending on the inputs that have been used this frame.
  48270. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48271. */
  48272. checkInputs(): void;
  48273. /**
  48274. * Gets the class name of the current intput.
  48275. * @returns the class name
  48276. */
  48277. getClassName(): string;
  48278. /**
  48279. * Get the friendly name associated with the input class.
  48280. * @returns the input friendly name
  48281. */
  48282. getSimpleName(): string;
  48283. }
  48284. }
  48285. declare module BABYLON {
  48286. /**
  48287. * Manage the gamepad inputs to control a free camera.
  48288. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48289. */
  48290. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48291. /**
  48292. * Define the camera the input is attached to.
  48293. */
  48294. camera: FreeCamera;
  48295. /**
  48296. * Define the Gamepad controlling the input
  48297. */
  48298. gamepad: Nullable<Gamepad>;
  48299. /**
  48300. * Defines the gamepad rotation sensiblity.
  48301. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48302. */
  48303. gamepadAngularSensibility: number;
  48304. /**
  48305. * Defines the gamepad move sensiblity.
  48306. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48307. */
  48308. gamepadMoveSensibility: number;
  48309. private _yAxisScale;
  48310. /**
  48311. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48312. */
  48313. get invertYAxis(): boolean;
  48314. set invertYAxis(value: boolean);
  48315. private _onGamepadConnectedObserver;
  48316. private _onGamepadDisconnectedObserver;
  48317. private _cameraTransform;
  48318. private _deltaTransform;
  48319. private _vector3;
  48320. private _vector2;
  48321. /**
  48322. * Attach the input controls to a specific dom element to get the input from.
  48323. */
  48324. attachControl(): void;
  48325. /**
  48326. * Detach the current controls from the specified dom element.
  48327. */
  48328. detachControl(): void;
  48329. /**
  48330. * Update the current camera state depending on the inputs that have been used this frame.
  48331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48332. */
  48333. checkInputs(): void;
  48334. /**
  48335. * Gets the class name of the current intput.
  48336. * @returns the class name
  48337. */
  48338. getClassName(): string;
  48339. /**
  48340. * Get the friendly name associated with the input class.
  48341. * @returns the input friendly name
  48342. */
  48343. getSimpleName(): string;
  48344. }
  48345. }
  48346. declare module BABYLON {
  48347. /**
  48348. * Defines the potential axis of a Joystick
  48349. */
  48350. export enum JoystickAxis {
  48351. /** X axis */
  48352. X = 0,
  48353. /** Y axis */
  48354. Y = 1,
  48355. /** Z axis */
  48356. Z = 2
  48357. }
  48358. /**
  48359. * Represents the different customization options available
  48360. * for VirtualJoystick
  48361. */
  48362. interface VirtualJoystickCustomizations {
  48363. /**
  48364. * Size of the joystick's puck
  48365. */
  48366. puckSize: number;
  48367. /**
  48368. * Size of the joystick's container
  48369. */
  48370. containerSize: number;
  48371. /**
  48372. * Color of the joystick && puck
  48373. */
  48374. color: string;
  48375. /**
  48376. * Image URL for the joystick's puck
  48377. */
  48378. puckImage?: string;
  48379. /**
  48380. * Image URL for the joystick's container
  48381. */
  48382. containerImage?: string;
  48383. /**
  48384. * Defines the unmoving position of the joystick container
  48385. */
  48386. position?: {
  48387. x: number;
  48388. y: number;
  48389. };
  48390. /**
  48391. * Defines whether or not the joystick container is always visible
  48392. */
  48393. alwaysVisible: boolean;
  48394. /**
  48395. * Defines whether or not to limit the movement of the puck to the joystick's container
  48396. */
  48397. limitToContainer: boolean;
  48398. }
  48399. /**
  48400. * Class used to define virtual joystick (used in touch mode)
  48401. */
  48402. export class VirtualJoystick {
  48403. /**
  48404. * Gets or sets a boolean indicating that left and right values must be inverted
  48405. */
  48406. reverseLeftRight: boolean;
  48407. /**
  48408. * Gets or sets a boolean indicating that up and down values must be inverted
  48409. */
  48410. reverseUpDown: boolean;
  48411. /**
  48412. * Gets the offset value for the position (ie. the change of the position value)
  48413. */
  48414. deltaPosition: Vector3;
  48415. /**
  48416. * Gets a boolean indicating if the virtual joystick was pressed
  48417. */
  48418. pressed: boolean;
  48419. /**
  48420. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48421. */
  48422. static Canvas: Nullable<HTMLCanvasElement>;
  48423. /**
  48424. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48425. */
  48426. limitToContainer: boolean;
  48427. private static _globalJoystickIndex;
  48428. private static _alwaysVisibleSticks;
  48429. private static vjCanvasContext;
  48430. private static vjCanvasWidth;
  48431. private static vjCanvasHeight;
  48432. private static halfWidth;
  48433. private static _GetDefaultOptions;
  48434. private _action;
  48435. private _axisTargetedByLeftAndRight;
  48436. private _axisTargetedByUpAndDown;
  48437. private _joystickSensibility;
  48438. private _inversedSensibility;
  48439. private _joystickPointerID;
  48440. private _joystickColor;
  48441. private _joystickPointerPos;
  48442. private _joystickPreviousPointerPos;
  48443. private _joystickPointerStartPos;
  48444. private _deltaJoystickVector;
  48445. private _leftJoystick;
  48446. private _touches;
  48447. private _joystickPosition;
  48448. private _alwaysVisible;
  48449. private _puckImage;
  48450. private _containerImage;
  48451. private _joystickPuckSize;
  48452. private _joystickContainerSize;
  48453. private _clearPuckSize;
  48454. private _clearContainerSize;
  48455. private _clearPuckSizeOffset;
  48456. private _clearContainerSizeOffset;
  48457. private _onPointerDownHandlerRef;
  48458. private _onPointerMoveHandlerRef;
  48459. private _onPointerUpHandlerRef;
  48460. private _onResize;
  48461. /**
  48462. * Creates a new virtual joystick
  48463. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48464. * @param customizations Defines the options we want to customize the VirtualJoystick
  48465. */
  48466. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48467. /**
  48468. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48469. * @param newJoystickSensibility defines the new sensibility
  48470. */
  48471. setJoystickSensibility(newJoystickSensibility: number): void;
  48472. private _onPointerDown;
  48473. private _onPointerMove;
  48474. private _onPointerUp;
  48475. /**
  48476. * Change the color of the virtual joystick
  48477. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48478. */
  48479. setJoystickColor(newColor: string): void;
  48480. /**
  48481. * Size of the joystick's container
  48482. */
  48483. set containerSize(newSize: number);
  48484. get containerSize(): number;
  48485. /**
  48486. * Size of the joystick's puck
  48487. */
  48488. set puckSize(newSize: number);
  48489. get puckSize(): number;
  48490. /**
  48491. * Clears the set position of the joystick
  48492. */
  48493. clearPosition(): void;
  48494. /**
  48495. * Defines whether or not the joystick container is always visible
  48496. */
  48497. set alwaysVisible(value: boolean);
  48498. get alwaysVisible(): boolean;
  48499. /**
  48500. * Sets the constant position of the Joystick container
  48501. * @param x X axis coordinate
  48502. * @param y Y axis coordinate
  48503. */
  48504. setPosition(x: number, y: number): void;
  48505. /**
  48506. * Defines a callback to call when the joystick is touched
  48507. * @param action defines the callback
  48508. */
  48509. setActionOnTouch(action: () => any): void;
  48510. /**
  48511. * Defines which axis you'd like to control for left & right
  48512. * @param axis defines the axis to use
  48513. */
  48514. setAxisForLeftRight(axis: JoystickAxis): void;
  48515. /**
  48516. * Defines which axis you'd like to control for up & down
  48517. * @param axis defines the axis to use
  48518. */
  48519. setAxisForUpDown(axis: JoystickAxis): void;
  48520. /**
  48521. * Clears the canvas from the previous puck / container draw
  48522. */
  48523. private _clearPreviousDraw;
  48524. /**
  48525. * Loads `urlPath` to be used for the container's image
  48526. * @param urlPath defines the urlPath of an image to use
  48527. */
  48528. setContainerImage(urlPath: string): void;
  48529. /**
  48530. * Loads `urlPath` to be used for the puck's image
  48531. * @param urlPath defines the urlPath of an image to use
  48532. */
  48533. setPuckImage(urlPath: string): void;
  48534. /**
  48535. * Draws the Virtual Joystick's container
  48536. */
  48537. private _drawContainer;
  48538. /**
  48539. * Draws the Virtual Joystick's puck
  48540. */
  48541. private _drawPuck;
  48542. private _drawVirtualJoystick;
  48543. /**
  48544. * Release internal HTML canvas
  48545. */
  48546. releaseCanvas(): void;
  48547. }
  48548. }
  48549. declare module BABYLON {
  48550. interface FreeCameraInputsManager {
  48551. /**
  48552. * Add virtual joystick input support to the input manager.
  48553. * @returns the current input manager
  48554. */
  48555. addVirtualJoystick(): FreeCameraInputsManager;
  48556. }
  48557. /**
  48558. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48559. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48560. */
  48561. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48562. /**
  48563. * Defines the camera the input is attached to.
  48564. */
  48565. camera: FreeCamera;
  48566. private _leftjoystick;
  48567. private _rightjoystick;
  48568. /**
  48569. * Gets the left stick of the virtual joystick.
  48570. * @returns The virtual Joystick
  48571. */
  48572. getLeftJoystick(): VirtualJoystick;
  48573. /**
  48574. * Gets the right stick of the virtual joystick.
  48575. * @returns The virtual Joystick
  48576. */
  48577. getRightJoystick(): VirtualJoystick;
  48578. /**
  48579. * Update the current camera state depending on the inputs that have been used this frame.
  48580. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48581. */
  48582. checkInputs(): void;
  48583. /**
  48584. * Attach the input controls to a specific dom element to get the input from.
  48585. */
  48586. attachControl(): void;
  48587. /**
  48588. * Detach the current controls from the specified dom element.
  48589. */
  48590. detachControl(): void;
  48591. /**
  48592. * Gets the class name of the current intput.
  48593. * @returns the class name
  48594. */
  48595. getClassName(): string;
  48596. /**
  48597. * Get the friendly name associated with the input class.
  48598. * @returns the input friendly name
  48599. */
  48600. getSimpleName(): string;
  48601. }
  48602. }
  48603. declare module BABYLON {
  48604. /**
  48605. * This represents a FPS type of camera controlled by touch.
  48606. * This is like a universal camera minus the Gamepad controls.
  48607. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48608. */
  48609. export class TouchCamera extends FreeCamera {
  48610. /**
  48611. * Defines the touch sensibility for rotation.
  48612. * The higher the faster.
  48613. */
  48614. get touchAngularSensibility(): number;
  48615. set touchAngularSensibility(value: number);
  48616. /**
  48617. * Defines the touch sensibility for move.
  48618. * The higher the faster.
  48619. */
  48620. get touchMoveSensibility(): number;
  48621. set touchMoveSensibility(value: number);
  48622. /**
  48623. * Instantiates a new touch camera.
  48624. * This represents a FPS type of camera controlled by touch.
  48625. * This is like a universal camera minus the Gamepad controls.
  48626. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48627. * @param name Define the name of the camera in the scene
  48628. * @param position Define the start position of the camera in the scene
  48629. * @param scene Define the scene the camera belongs to
  48630. */
  48631. constructor(name: string, position: Vector3, scene: Scene);
  48632. /**
  48633. * Gets the current object class name.
  48634. * @return the class name
  48635. */
  48636. getClassName(): string;
  48637. /** @hidden */
  48638. _setupInputs(): void;
  48639. }
  48640. }
  48641. declare module BABYLON {
  48642. /**
  48643. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48644. * being tilted forward or back and left or right.
  48645. */
  48646. export class DeviceOrientationCamera extends FreeCamera {
  48647. private _initialQuaternion;
  48648. private _quaternionCache;
  48649. private _tmpDragQuaternion;
  48650. private _disablePointerInputWhenUsingDeviceOrientation;
  48651. /**
  48652. * Creates a new device orientation camera
  48653. * @param name The name of the camera
  48654. * @param position The start position camera
  48655. * @param scene The scene the camera belongs to
  48656. */
  48657. constructor(name: string, position: Vector3, scene: Scene);
  48658. /**
  48659. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48660. */
  48661. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48662. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48663. private _dragFactor;
  48664. /**
  48665. * Enabled turning on the y axis when the orientation sensor is active
  48666. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  48667. */
  48668. enableHorizontalDragging(dragFactor?: number): void;
  48669. /**
  48670. * Gets the current instance class name ("DeviceOrientationCamera").
  48671. * This helps avoiding instanceof at run time.
  48672. * @returns the class name
  48673. */
  48674. getClassName(): string;
  48675. /**
  48676. * @hidden
  48677. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  48678. */
  48679. _checkInputs(): void;
  48680. /**
  48681. * Reset the camera to its default orientation on the specified axis only.
  48682. * @param axis The axis to reset
  48683. */
  48684. resetToCurrentRotation(axis?: Axis): void;
  48685. }
  48686. }
  48687. declare module BABYLON {
  48688. /**
  48689. * Defines supported buttons for XBox360 compatible gamepads
  48690. */
  48691. export enum Xbox360Button {
  48692. /** A */
  48693. A = 0,
  48694. /** B */
  48695. B = 1,
  48696. /** X */
  48697. X = 2,
  48698. /** Y */
  48699. Y = 3,
  48700. /** Left button */
  48701. LB = 4,
  48702. /** Right button */
  48703. RB = 5,
  48704. /** Back */
  48705. Back = 8,
  48706. /** Start */
  48707. Start = 9,
  48708. /** Left stick */
  48709. LeftStick = 10,
  48710. /** Right stick */
  48711. RightStick = 11
  48712. }
  48713. /** Defines values for XBox360 DPad */
  48714. export enum Xbox360Dpad {
  48715. /** Up */
  48716. Up = 12,
  48717. /** Down */
  48718. Down = 13,
  48719. /** Left */
  48720. Left = 14,
  48721. /** Right */
  48722. Right = 15
  48723. }
  48724. /**
  48725. * Defines a XBox360 gamepad
  48726. */
  48727. export class Xbox360Pad extends Gamepad {
  48728. private _leftTrigger;
  48729. private _rightTrigger;
  48730. private _onlefttriggerchanged;
  48731. private _onrighttriggerchanged;
  48732. private _onbuttondown;
  48733. private _onbuttonup;
  48734. private _ondpaddown;
  48735. private _ondpadup;
  48736. /** Observable raised when a button is pressed */
  48737. onButtonDownObservable: Observable<Xbox360Button>;
  48738. /** Observable raised when a button is released */
  48739. onButtonUpObservable: Observable<Xbox360Button>;
  48740. /** Observable raised when a pad is pressed */
  48741. onPadDownObservable: Observable<Xbox360Dpad>;
  48742. /** Observable raised when a pad is released */
  48743. onPadUpObservable: Observable<Xbox360Dpad>;
  48744. private _buttonA;
  48745. private _buttonB;
  48746. private _buttonX;
  48747. private _buttonY;
  48748. private _buttonBack;
  48749. private _buttonStart;
  48750. private _buttonLB;
  48751. private _buttonRB;
  48752. private _buttonLeftStick;
  48753. private _buttonRightStick;
  48754. private _dPadUp;
  48755. private _dPadDown;
  48756. private _dPadLeft;
  48757. private _dPadRight;
  48758. private _isXboxOnePad;
  48759. /**
  48760. * Creates a new XBox360 gamepad object
  48761. * @param id defines the id of this gamepad
  48762. * @param index defines its index
  48763. * @param gamepad defines the internal HTML gamepad object
  48764. * @param xboxOne defines if it is a XBox One gamepad
  48765. */
  48766. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  48767. /**
  48768. * Defines the callback to call when left trigger is pressed
  48769. * @param callback defines the callback to use
  48770. */
  48771. onlefttriggerchanged(callback: (value: number) => void): void;
  48772. /**
  48773. * Defines the callback to call when right trigger is pressed
  48774. * @param callback defines the callback to use
  48775. */
  48776. onrighttriggerchanged(callback: (value: number) => void): void;
  48777. /**
  48778. * Gets the left trigger value
  48779. */
  48780. get leftTrigger(): number;
  48781. /**
  48782. * Sets the left trigger value
  48783. */
  48784. set leftTrigger(newValue: number);
  48785. /**
  48786. * Gets the right trigger value
  48787. */
  48788. get rightTrigger(): number;
  48789. /**
  48790. * Sets the right trigger value
  48791. */
  48792. set rightTrigger(newValue: number);
  48793. /**
  48794. * Defines the callback to call when a button is pressed
  48795. * @param callback defines the callback to use
  48796. */
  48797. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  48798. /**
  48799. * Defines the callback to call when a button is released
  48800. * @param callback defines the callback to use
  48801. */
  48802. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  48803. /**
  48804. * Defines the callback to call when a pad is pressed
  48805. * @param callback defines the callback to use
  48806. */
  48807. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  48808. /**
  48809. * Defines the callback to call when a pad is released
  48810. * @param callback defines the callback to use
  48811. */
  48812. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  48813. private _setButtonValue;
  48814. private _setDPadValue;
  48815. /**
  48816. * Gets the value of the `A` button
  48817. */
  48818. get buttonA(): number;
  48819. /**
  48820. * Sets the value of the `A` button
  48821. */
  48822. set buttonA(value: number);
  48823. /**
  48824. * Gets the value of the `B` button
  48825. */
  48826. get buttonB(): number;
  48827. /**
  48828. * Sets the value of the `B` button
  48829. */
  48830. set buttonB(value: number);
  48831. /**
  48832. * Gets the value of the `X` button
  48833. */
  48834. get buttonX(): number;
  48835. /**
  48836. * Sets the value of the `X` button
  48837. */
  48838. set buttonX(value: number);
  48839. /**
  48840. * Gets the value of the `Y` button
  48841. */
  48842. get buttonY(): number;
  48843. /**
  48844. * Sets the value of the `Y` button
  48845. */
  48846. set buttonY(value: number);
  48847. /**
  48848. * Gets the value of the `Start` button
  48849. */
  48850. get buttonStart(): number;
  48851. /**
  48852. * Sets the value of the `Start` button
  48853. */
  48854. set buttonStart(value: number);
  48855. /**
  48856. * Gets the value of the `Back` button
  48857. */
  48858. get buttonBack(): number;
  48859. /**
  48860. * Sets the value of the `Back` button
  48861. */
  48862. set buttonBack(value: number);
  48863. /**
  48864. * Gets the value of the `Left` button
  48865. */
  48866. get buttonLB(): number;
  48867. /**
  48868. * Sets the value of the `Left` button
  48869. */
  48870. set buttonLB(value: number);
  48871. /**
  48872. * Gets the value of the `Right` button
  48873. */
  48874. get buttonRB(): number;
  48875. /**
  48876. * Sets the value of the `Right` button
  48877. */
  48878. set buttonRB(value: number);
  48879. /**
  48880. * Gets the value of the Left joystick
  48881. */
  48882. get buttonLeftStick(): number;
  48883. /**
  48884. * Sets the value of the Left joystick
  48885. */
  48886. set buttonLeftStick(value: number);
  48887. /**
  48888. * Gets the value of the Right joystick
  48889. */
  48890. get buttonRightStick(): number;
  48891. /**
  48892. * Sets the value of the Right joystick
  48893. */
  48894. set buttonRightStick(value: number);
  48895. /**
  48896. * Gets the value of D-pad up
  48897. */
  48898. get dPadUp(): number;
  48899. /**
  48900. * Sets the value of D-pad up
  48901. */
  48902. set dPadUp(value: number);
  48903. /**
  48904. * Gets the value of D-pad down
  48905. */
  48906. get dPadDown(): number;
  48907. /**
  48908. * Sets the value of D-pad down
  48909. */
  48910. set dPadDown(value: number);
  48911. /**
  48912. * Gets the value of D-pad left
  48913. */
  48914. get dPadLeft(): number;
  48915. /**
  48916. * Sets the value of D-pad left
  48917. */
  48918. set dPadLeft(value: number);
  48919. /**
  48920. * Gets the value of D-pad right
  48921. */
  48922. get dPadRight(): number;
  48923. /**
  48924. * Sets the value of D-pad right
  48925. */
  48926. set dPadRight(value: number);
  48927. /**
  48928. * Force the gamepad to synchronize with device values
  48929. */
  48930. update(): void;
  48931. /**
  48932. * Disposes the gamepad
  48933. */
  48934. dispose(): void;
  48935. }
  48936. }
  48937. declare module BABYLON {
  48938. /**
  48939. * Defines supported buttons for DualShock compatible gamepads
  48940. */
  48941. export enum DualShockButton {
  48942. /** Cross */
  48943. Cross = 0,
  48944. /** Circle */
  48945. Circle = 1,
  48946. /** Square */
  48947. Square = 2,
  48948. /** Triangle */
  48949. Triangle = 3,
  48950. /** L1 */
  48951. L1 = 4,
  48952. /** R1 */
  48953. R1 = 5,
  48954. /** Share */
  48955. Share = 8,
  48956. /** Options */
  48957. Options = 9,
  48958. /** Left stick */
  48959. LeftStick = 10,
  48960. /** Right stick */
  48961. RightStick = 11
  48962. }
  48963. /** Defines values for DualShock DPad */
  48964. export enum DualShockDpad {
  48965. /** Up */
  48966. Up = 12,
  48967. /** Down */
  48968. Down = 13,
  48969. /** Left */
  48970. Left = 14,
  48971. /** Right */
  48972. Right = 15
  48973. }
  48974. /**
  48975. * Defines a DualShock gamepad
  48976. */
  48977. export class DualShockPad extends Gamepad {
  48978. private _leftTrigger;
  48979. private _rightTrigger;
  48980. private _onlefttriggerchanged;
  48981. private _onrighttriggerchanged;
  48982. private _onbuttondown;
  48983. private _onbuttonup;
  48984. private _ondpaddown;
  48985. private _ondpadup;
  48986. /** Observable raised when a button is pressed */
  48987. onButtonDownObservable: Observable<DualShockButton>;
  48988. /** Observable raised when a button is released */
  48989. onButtonUpObservable: Observable<DualShockButton>;
  48990. /** Observable raised when a pad is pressed */
  48991. onPadDownObservable: Observable<DualShockDpad>;
  48992. /** Observable raised when a pad is released */
  48993. onPadUpObservable: Observable<DualShockDpad>;
  48994. private _buttonCross;
  48995. private _buttonCircle;
  48996. private _buttonSquare;
  48997. private _buttonTriangle;
  48998. private _buttonShare;
  48999. private _buttonOptions;
  49000. private _buttonL1;
  49001. private _buttonR1;
  49002. private _buttonLeftStick;
  49003. private _buttonRightStick;
  49004. private _dPadUp;
  49005. private _dPadDown;
  49006. private _dPadLeft;
  49007. private _dPadRight;
  49008. /**
  49009. * Creates a new DualShock gamepad object
  49010. * @param id defines the id of this gamepad
  49011. * @param index defines its index
  49012. * @param gamepad defines the internal HTML gamepad object
  49013. */
  49014. constructor(id: string, index: number, gamepad: any);
  49015. /**
  49016. * Defines the callback to call when left trigger is pressed
  49017. * @param callback defines the callback to use
  49018. */
  49019. onlefttriggerchanged(callback: (value: number) => void): void;
  49020. /**
  49021. * Defines the callback to call when right trigger is pressed
  49022. * @param callback defines the callback to use
  49023. */
  49024. onrighttriggerchanged(callback: (value: number) => void): void;
  49025. /**
  49026. * Gets the left trigger value
  49027. */
  49028. get leftTrigger(): number;
  49029. /**
  49030. * Sets the left trigger value
  49031. */
  49032. set leftTrigger(newValue: number);
  49033. /**
  49034. * Gets the right trigger value
  49035. */
  49036. get rightTrigger(): number;
  49037. /**
  49038. * Sets the right trigger value
  49039. */
  49040. set rightTrigger(newValue: number);
  49041. /**
  49042. * Defines the callback to call when a button is pressed
  49043. * @param callback defines the callback to use
  49044. */
  49045. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49046. /**
  49047. * Defines the callback to call when a button is released
  49048. * @param callback defines the callback to use
  49049. */
  49050. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49051. /**
  49052. * Defines the callback to call when a pad is pressed
  49053. * @param callback defines the callback to use
  49054. */
  49055. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49056. /**
  49057. * Defines the callback to call when a pad is released
  49058. * @param callback defines the callback to use
  49059. */
  49060. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49061. private _setButtonValue;
  49062. private _setDPadValue;
  49063. /**
  49064. * Gets the value of the `Cross` button
  49065. */
  49066. get buttonCross(): number;
  49067. /**
  49068. * Sets the value of the `Cross` button
  49069. */
  49070. set buttonCross(value: number);
  49071. /**
  49072. * Gets the value of the `Circle` button
  49073. */
  49074. get buttonCircle(): number;
  49075. /**
  49076. * Sets the value of the `Circle` button
  49077. */
  49078. set buttonCircle(value: number);
  49079. /**
  49080. * Gets the value of the `Square` button
  49081. */
  49082. get buttonSquare(): number;
  49083. /**
  49084. * Sets the value of the `Square` button
  49085. */
  49086. set buttonSquare(value: number);
  49087. /**
  49088. * Gets the value of the `Triangle` button
  49089. */
  49090. get buttonTriangle(): number;
  49091. /**
  49092. * Sets the value of the `Triangle` button
  49093. */
  49094. set buttonTriangle(value: number);
  49095. /**
  49096. * Gets the value of the `Options` button
  49097. */
  49098. get buttonOptions(): number;
  49099. /**
  49100. * Sets the value of the `Options` button
  49101. */
  49102. set buttonOptions(value: number);
  49103. /**
  49104. * Gets the value of the `Share` button
  49105. */
  49106. get buttonShare(): number;
  49107. /**
  49108. * Sets the value of the `Share` button
  49109. */
  49110. set buttonShare(value: number);
  49111. /**
  49112. * Gets the value of the `L1` button
  49113. */
  49114. get buttonL1(): number;
  49115. /**
  49116. * Sets the value of the `L1` button
  49117. */
  49118. set buttonL1(value: number);
  49119. /**
  49120. * Gets the value of the `R1` button
  49121. */
  49122. get buttonR1(): number;
  49123. /**
  49124. * Sets the value of the `R1` button
  49125. */
  49126. set buttonR1(value: number);
  49127. /**
  49128. * Gets the value of the Left joystick
  49129. */
  49130. get buttonLeftStick(): number;
  49131. /**
  49132. * Sets the value of the Left joystick
  49133. */
  49134. set buttonLeftStick(value: number);
  49135. /**
  49136. * Gets the value of the Right joystick
  49137. */
  49138. get buttonRightStick(): number;
  49139. /**
  49140. * Sets the value of the Right joystick
  49141. */
  49142. set buttonRightStick(value: number);
  49143. /**
  49144. * Gets the value of D-pad up
  49145. */
  49146. get dPadUp(): number;
  49147. /**
  49148. * Sets the value of D-pad up
  49149. */
  49150. set dPadUp(value: number);
  49151. /**
  49152. * Gets the value of D-pad down
  49153. */
  49154. get dPadDown(): number;
  49155. /**
  49156. * Sets the value of D-pad down
  49157. */
  49158. set dPadDown(value: number);
  49159. /**
  49160. * Gets the value of D-pad left
  49161. */
  49162. get dPadLeft(): number;
  49163. /**
  49164. * Sets the value of D-pad left
  49165. */
  49166. set dPadLeft(value: number);
  49167. /**
  49168. * Gets the value of D-pad right
  49169. */
  49170. get dPadRight(): number;
  49171. /**
  49172. * Sets the value of D-pad right
  49173. */
  49174. set dPadRight(value: number);
  49175. /**
  49176. * Force the gamepad to synchronize with device values
  49177. */
  49178. update(): void;
  49179. /**
  49180. * Disposes the gamepad
  49181. */
  49182. dispose(): void;
  49183. }
  49184. }
  49185. declare module BABYLON {
  49186. /**
  49187. * Manager for handling gamepads
  49188. */
  49189. export class GamepadManager {
  49190. private _scene?;
  49191. private _babylonGamepads;
  49192. private _oneGamepadConnected;
  49193. /** @hidden */
  49194. _isMonitoring: boolean;
  49195. private _gamepadEventSupported;
  49196. private _gamepadSupport?;
  49197. /**
  49198. * observable to be triggered when the gamepad controller has been connected
  49199. */
  49200. onGamepadConnectedObservable: Observable<Gamepad>;
  49201. /**
  49202. * observable to be triggered when the gamepad controller has been disconnected
  49203. */
  49204. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49205. private _onGamepadConnectedEvent;
  49206. private _onGamepadDisconnectedEvent;
  49207. /**
  49208. * Initializes the gamepad manager
  49209. * @param _scene BabylonJS scene
  49210. */
  49211. constructor(_scene?: Scene | undefined);
  49212. /**
  49213. * The gamepads in the game pad manager
  49214. */
  49215. get gamepads(): Gamepad[];
  49216. /**
  49217. * Get the gamepad controllers based on type
  49218. * @param type The type of gamepad controller
  49219. * @returns Nullable gamepad
  49220. */
  49221. getGamepadByType(type?: number): Nullable<Gamepad>;
  49222. /**
  49223. * Disposes the gamepad manager
  49224. */
  49225. dispose(): void;
  49226. private _addNewGamepad;
  49227. private _startMonitoringGamepads;
  49228. private _stopMonitoringGamepads;
  49229. /** @hidden */
  49230. _checkGamepadsStatus(): void;
  49231. private _updateGamepadObjects;
  49232. }
  49233. }
  49234. declare module BABYLON {
  49235. interface Scene {
  49236. /** @hidden */
  49237. _gamepadManager: Nullable<GamepadManager>;
  49238. /**
  49239. * Gets the gamepad manager associated with the scene
  49240. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49241. */
  49242. gamepadManager: GamepadManager;
  49243. }
  49244. /**
  49245. * Interface representing a free camera inputs manager
  49246. */
  49247. interface FreeCameraInputsManager {
  49248. /**
  49249. * Adds gamepad input support to the FreeCameraInputsManager.
  49250. * @returns the FreeCameraInputsManager
  49251. */
  49252. addGamepad(): FreeCameraInputsManager;
  49253. }
  49254. /**
  49255. * Interface representing an arc rotate camera inputs manager
  49256. */
  49257. interface ArcRotateCameraInputsManager {
  49258. /**
  49259. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49260. * @returns the camera inputs manager
  49261. */
  49262. addGamepad(): ArcRotateCameraInputsManager;
  49263. }
  49264. /**
  49265. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49266. */
  49267. export class GamepadSystemSceneComponent implements ISceneComponent {
  49268. /**
  49269. * The component name helpfull to identify the component in the list of scene components.
  49270. */
  49271. readonly name: string;
  49272. /**
  49273. * The scene the component belongs to.
  49274. */
  49275. scene: Scene;
  49276. /**
  49277. * Creates a new instance of the component for the given scene
  49278. * @param scene Defines the scene to register the component in
  49279. */
  49280. constructor(scene: Scene);
  49281. /**
  49282. * Registers the component in a given scene
  49283. */
  49284. register(): void;
  49285. /**
  49286. * Rebuilds the elements related to this component in case of
  49287. * context lost for instance.
  49288. */
  49289. rebuild(): void;
  49290. /**
  49291. * Disposes the component and the associated ressources
  49292. */
  49293. dispose(): void;
  49294. private _beforeCameraUpdate;
  49295. }
  49296. }
  49297. declare module BABYLON {
  49298. /**
  49299. * 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,
  49300. * which still works and will still be found in many Playgrounds.
  49301. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49302. */
  49303. export class UniversalCamera extends TouchCamera {
  49304. /**
  49305. * Defines the gamepad rotation sensiblity.
  49306. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49307. */
  49308. get gamepadAngularSensibility(): number;
  49309. set gamepadAngularSensibility(value: number);
  49310. /**
  49311. * Defines the gamepad move sensiblity.
  49312. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49313. */
  49314. get gamepadMoveSensibility(): number;
  49315. set gamepadMoveSensibility(value: number);
  49316. /**
  49317. * 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,
  49318. * which still works and will still be found in many Playgrounds.
  49319. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49320. * @param name Define the name of the camera in the scene
  49321. * @param position Define the start position of the camera in the scene
  49322. * @param scene Define the scene the camera belongs to
  49323. */
  49324. constructor(name: string, position: Vector3, scene: Scene);
  49325. /**
  49326. * Gets the current object class name.
  49327. * @return the class name
  49328. */
  49329. getClassName(): string;
  49330. }
  49331. }
  49332. declare module BABYLON {
  49333. /**
  49334. * This represents a FPS type of camera. This is only here for back compat purpose.
  49335. * Please use the UniversalCamera instead as both are identical.
  49336. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49337. */
  49338. export class GamepadCamera extends UniversalCamera {
  49339. /**
  49340. * Instantiates a new Gamepad Camera
  49341. * This represents a FPS type of camera. This is only here for back compat purpose.
  49342. * Please use the UniversalCamera instead as both are identical.
  49343. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49344. * @param name Define the name of the camera in the scene
  49345. * @param position Define the start position of the camera in the scene
  49346. * @param scene Define the scene the camera belongs to
  49347. */
  49348. constructor(name: string, position: Vector3, scene: Scene);
  49349. /**
  49350. * Gets the current object class name.
  49351. * @return the class name
  49352. */
  49353. getClassName(): string;
  49354. }
  49355. }
  49356. declare module BABYLON {
  49357. /** @hidden */
  49358. export var passPixelShader: {
  49359. name: string;
  49360. shader: string;
  49361. };
  49362. }
  49363. declare module BABYLON {
  49364. /** @hidden */
  49365. export var passCubePixelShader: {
  49366. name: string;
  49367. shader: string;
  49368. };
  49369. }
  49370. declare module BABYLON {
  49371. /**
  49372. * PassPostProcess which produces an output the same as it's input
  49373. */
  49374. export class PassPostProcess extends PostProcess {
  49375. /**
  49376. * Gets a string identifying the name of the class
  49377. * @returns "PassPostProcess" string
  49378. */
  49379. getClassName(): string;
  49380. /**
  49381. * Creates the PassPostProcess
  49382. * @param name The name of the effect.
  49383. * @param options The required width/height ratio to downsize to before computing the render pass.
  49384. * @param camera The camera to apply the render pass to.
  49385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49386. * @param engine The engine which the post process will be applied. (default: current engine)
  49387. * @param reusable If the post process can be reused on the same frame. (default: false)
  49388. * @param textureType The type of texture to be used when performing the post processing.
  49389. * @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)
  49390. */
  49391. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49392. /** @hidden */
  49393. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49394. }
  49395. /**
  49396. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49397. */
  49398. export class PassCubePostProcess extends PostProcess {
  49399. private _face;
  49400. /**
  49401. * Gets or sets the cube face to display.
  49402. * * 0 is +X
  49403. * * 1 is -X
  49404. * * 2 is +Y
  49405. * * 3 is -Y
  49406. * * 4 is +Z
  49407. * * 5 is -Z
  49408. */
  49409. get face(): number;
  49410. set face(value: number);
  49411. /**
  49412. * Gets a string identifying the name of the class
  49413. * @returns "PassCubePostProcess" string
  49414. */
  49415. getClassName(): string;
  49416. /**
  49417. * Creates the PassCubePostProcess
  49418. * @param name The name of the effect.
  49419. * @param options The required width/height ratio to downsize to before computing the render pass.
  49420. * @param camera The camera to apply the render pass to.
  49421. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49422. * @param engine The engine which the post process will be applied. (default: current engine)
  49423. * @param reusable If the post process can be reused on the same frame. (default: false)
  49424. * @param textureType The type of texture to be used when performing the post processing.
  49425. * @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)
  49426. */
  49427. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49428. /** @hidden */
  49429. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49430. }
  49431. }
  49432. declare module BABYLON {
  49433. /** @hidden */
  49434. export var anaglyphPixelShader: {
  49435. name: string;
  49436. shader: string;
  49437. };
  49438. }
  49439. declare module BABYLON {
  49440. /**
  49441. * Postprocess used to generate anaglyphic rendering
  49442. */
  49443. export class AnaglyphPostProcess extends PostProcess {
  49444. private _passedProcess;
  49445. /**
  49446. * Gets a string identifying the name of the class
  49447. * @returns "AnaglyphPostProcess" string
  49448. */
  49449. getClassName(): string;
  49450. /**
  49451. * Creates a new AnaglyphPostProcess
  49452. * @param name defines postprocess name
  49453. * @param options defines creation options or target ratio scale
  49454. * @param rigCameras defines cameras using this postprocess
  49455. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49456. * @param engine defines hosting engine
  49457. * @param reusable defines if the postprocess will be reused multiple times per frame
  49458. */
  49459. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49460. }
  49461. }
  49462. declare module BABYLON {
  49463. /**
  49464. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49465. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49466. */
  49467. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49468. /**
  49469. * Creates a new AnaglyphArcRotateCamera
  49470. * @param name defines camera name
  49471. * @param alpha defines alpha angle (in radians)
  49472. * @param beta defines beta angle (in radians)
  49473. * @param radius defines radius
  49474. * @param target defines camera target
  49475. * @param interaxialDistance defines distance between each color axis
  49476. * @param scene defines the hosting scene
  49477. */
  49478. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49479. /**
  49480. * Gets camera class name
  49481. * @returns AnaglyphArcRotateCamera
  49482. */
  49483. getClassName(): string;
  49484. }
  49485. }
  49486. declare module BABYLON {
  49487. /**
  49488. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49489. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49490. */
  49491. export class AnaglyphFreeCamera extends FreeCamera {
  49492. /**
  49493. * Creates a new AnaglyphFreeCamera
  49494. * @param name defines camera name
  49495. * @param position defines initial position
  49496. * @param interaxialDistance defines distance between each color axis
  49497. * @param scene defines the hosting scene
  49498. */
  49499. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49500. /**
  49501. * Gets camera class name
  49502. * @returns AnaglyphFreeCamera
  49503. */
  49504. getClassName(): string;
  49505. }
  49506. }
  49507. declare module BABYLON {
  49508. /**
  49509. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49510. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49511. */
  49512. export class AnaglyphGamepadCamera extends GamepadCamera {
  49513. /**
  49514. * Creates a new AnaglyphGamepadCamera
  49515. * @param name defines camera name
  49516. * @param position defines initial position
  49517. * @param interaxialDistance defines distance between each color axis
  49518. * @param scene defines the hosting scene
  49519. */
  49520. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49521. /**
  49522. * Gets camera class name
  49523. * @returns AnaglyphGamepadCamera
  49524. */
  49525. getClassName(): string;
  49526. }
  49527. }
  49528. declare module BABYLON {
  49529. /**
  49530. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49531. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49532. */
  49533. export class AnaglyphUniversalCamera extends UniversalCamera {
  49534. /**
  49535. * Creates a new AnaglyphUniversalCamera
  49536. * @param name defines camera name
  49537. * @param position defines initial position
  49538. * @param interaxialDistance defines distance between each color axis
  49539. * @param scene defines the hosting scene
  49540. */
  49541. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49542. /**
  49543. * Gets camera class name
  49544. * @returns AnaglyphUniversalCamera
  49545. */
  49546. getClassName(): string;
  49547. }
  49548. }
  49549. declare module BABYLON {
  49550. /**
  49551. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49552. * @see https://doc.babylonjs.com/features/cameras
  49553. */
  49554. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49555. /**
  49556. * Creates a new StereoscopicArcRotateCamera
  49557. * @param name defines camera name
  49558. * @param alpha defines alpha angle (in radians)
  49559. * @param beta defines beta angle (in radians)
  49560. * @param radius defines radius
  49561. * @param target defines camera target
  49562. * @param interaxialDistance defines distance between each color axis
  49563. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49564. * @param scene defines the hosting scene
  49565. */
  49566. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49567. /**
  49568. * Gets camera class name
  49569. * @returns StereoscopicArcRotateCamera
  49570. */
  49571. getClassName(): string;
  49572. }
  49573. }
  49574. declare module BABYLON {
  49575. /**
  49576. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49577. * @see https://doc.babylonjs.com/features/cameras
  49578. */
  49579. export class StereoscopicFreeCamera extends FreeCamera {
  49580. /**
  49581. * Creates a new StereoscopicFreeCamera
  49582. * @param name defines camera name
  49583. * @param position defines initial position
  49584. * @param interaxialDistance defines distance between each color axis
  49585. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49586. * @param scene defines the hosting scene
  49587. */
  49588. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49589. /**
  49590. * Gets camera class name
  49591. * @returns StereoscopicFreeCamera
  49592. */
  49593. getClassName(): string;
  49594. }
  49595. }
  49596. declare module BABYLON {
  49597. /**
  49598. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49599. * @see https://doc.babylonjs.com/features/cameras
  49600. */
  49601. export class StereoscopicGamepadCamera extends GamepadCamera {
  49602. /**
  49603. * Creates a new StereoscopicGamepadCamera
  49604. * @param name defines camera name
  49605. * @param position defines initial position
  49606. * @param interaxialDistance defines distance between each color axis
  49607. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49608. * @param scene defines the hosting scene
  49609. */
  49610. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49611. /**
  49612. * Gets camera class name
  49613. * @returns StereoscopicGamepadCamera
  49614. */
  49615. getClassName(): string;
  49616. }
  49617. }
  49618. declare module BABYLON {
  49619. /**
  49620. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49621. * @see https://doc.babylonjs.com/features/cameras
  49622. */
  49623. export class StereoscopicUniversalCamera extends UniversalCamera {
  49624. /**
  49625. * Creates a new StereoscopicUniversalCamera
  49626. * @param name defines camera name
  49627. * @param position defines initial position
  49628. * @param interaxialDistance defines distance between each color axis
  49629. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49630. * @param scene defines the hosting scene
  49631. */
  49632. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49633. /**
  49634. * Gets camera class name
  49635. * @returns StereoscopicUniversalCamera
  49636. */
  49637. getClassName(): string;
  49638. }
  49639. }
  49640. declare module BABYLON {
  49641. /**
  49642. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49643. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49644. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49645. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49646. */
  49647. export class VirtualJoysticksCamera extends FreeCamera {
  49648. /**
  49649. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49650. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49651. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49652. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49653. * @param name Define the name of the camera in the scene
  49654. * @param position Define the start position of the camera in the scene
  49655. * @param scene Define the scene the camera belongs to
  49656. */
  49657. constructor(name: string, position: Vector3, scene: Scene);
  49658. /**
  49659. * Gets the current object class name.
  49660. * @return the class name
  49661. */
  49662. getClassName(): string;
  49663. }
  49664. }
  49665. declare module BABYLON {
  49666. /**
  49667. * This represents all the required metrics to create a VR camera.
  49668. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  49669. */
  49670. export class VRCameraMetrics {
  49671. /**
  49672. * Define the horizontal resolution off the screen.
  49673. */
  49674. hResolution: number;
  49675. /**
  49676. * Define the vertical resolution off the screen.
  49677. */
  49678. vResolution: number;
  49679. /**
  49680. * Define the horizontal screen size.
  49681. */
  49682. hScreenSize: number;
  49683. /**
  49684. * Define the vertical screen size.
  49685. */
  49686. vScreenSize: number;
  49687. /**
  49688. * Define the vertical screen center position.
  49689. */
  49690. vScreenCenter: number;
  49691. /**
  49692. * Define the distance of the eyes to the screen.
  49693. */
  49694. eyeToScreenDistance: number;
  49695. /**
  49696. * Define the distance between both lenses
  49697. */
  49698. lensSeparationDistance: number;
  49699. /**
  49700. * Define the distance between both viewer's eyes.
  49701. */
  49702. interpupillaryDistance: number;
  49703. /**
  49704. * Define the distortion factor of the VR postprocess.
  49705. * Please, touch with care.
  49706. */
  49707. distortionK: number[];
  49708. /**
  49709. * Define the chromatic aberration correction factors for the VR post process.
  49710. */
  49711. chromaAbCorrection: number[];
  49712. /**
  49713. * Define the scale factor of the post process.
  49714. * The smaller the better but the slower.
  49715. */
  49716. postProcessScaleFactor: number;
  49717. /**
  49718. * Define an offset for the lens center.
  49719. */
  49720. lensCenterOffset: number;
  49721. /**
  49722. * Define if the current vr camera should compensate the distortion of the lense or not.
  49723. */
  49724. compensateDistortion: boolean;
  49725. /**
  49726. * Defines if multiview should be enabled when rendering (Default: false)
  49727. */
  49728. multiviewEnabled: boolean;
  49729. /**
  49730. * Gets the rendering aspect ratio based on the provided resolutions.
  49731. */
  49732. get aspectRatio(): number;
  49733. /**
  49734. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  49735. */
  49736. get aspectRatioFov(): number;
  49737. /**
  49738. * @hidden
  49739. */
  49740. get leftHMatrix(): Matrix;
  49741. /**
  49742. * @hidden
  49743. */
  49744. get rightHMatrix(): Matrix;
  49745. /**
  49746. * @hidden
  49747. */
  49748. get leftPreViewMatrix(): Matrix;
  49749. /**
  49750. * @hidden
  49751. */
  49752. get rightPreViewMatrix(): Matrix;
  49753. /**
  49754. * Get the default VRMetrics based on the most generic setup.
  49755. * @returns the default vr metrics
  49756. */
  49757. static GetDefault(): VRCameraMetrics;
  49758. }
  49759. }
  49760. declare module BABYLON {
  49761. /** @hidden */
  49762. export var vrDistortionCorrectionPixelShader: {
  49763. name: string;
  49764. shader: string;
  49765. };
  49766. }
  49767. declare module BABYLON {
  49768. /**
  49769. * VRDistortionCorrectionPostProcess used for mobile VR
  49770. */
  49771. export class VRDistortionCorrectionPostProcess extends PostProcess {
  49772. private _isRightEye;
  49773. private _distortionFactors;
  49774. private _postProcessScaleFactor;
  49775. private _lensCenterOffset;
  49776. private _scaleIn;
  49777. private _scaleFactor;
  49778. private _lensCenter;
  49779. /**
  49780. * Gets a string identifying the name of the class
  49781. * @returns "VRDistortionCorrectionPostProcess" string
  49782. */
  49783. getClassName(): string;
  49784. /**
  49785. * Initializes the VRDistortionCorrectionPostProcess
  49786. * @param name The name of the effect.
  49787. * @param camera The camera to apply the render pass to.
  49788. * @param isRightEye If this is for the right eye distortion
  49789. * @param vrMetrics All the required metrics for the VR camera
  49790. */
  49791. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  49792. }
  49793. }
  49794. declare module BABYLON {
  49795. /**
  49796. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  49797. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49798. */
  49799. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  49800. /**
  49801. * Creates a new VRDeviceOrientationArcRotateCamera
  49802. * @param name defines camera name
  49803. * @param alpha defines the camera rotation along the logitudinal axis
  49804. * @param beta defines the camera rotation along the latitudinal axis
  49805. * @param radius defines the camera distance from its target
  49806. * @param target defines the camera target
  49807. * @param scene defines the scene the camera belongs to
  49808. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49809. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49810. */
  49811. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49812. /**
  49813. * Gets camera class name
  49814. * @returns VRDeviceOrientationArcRotateCamera
  49815. */
  49816. getClassName(): string;
  49817. }
  49818. }
  49819. declare module BABYLON {
  49820. /**
  49821. * Camera used to simulate VR rendering (based on FreeCamera)
  49822. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49823. */
  49824. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  49825. /**
  49826. * Creates a new VRDeviceOrientationFreeCamera
  49827. * @param name defines camera name
  49828. * @param position defines the start position of the camera
  49829. * @param scene defines the scene the camera belongs to
  49830. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49831. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49832. */
  49833. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49834. /**
  49835. * Gets camera class name
  49836. * @returns VRDeviceOrientationFreeCamera
  49837. */
  49838. getClassName(): string;
  49839. }
  49840. }
  49841. declare module BABYLON {
  49842. /**
  49843. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  49844. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49845. */
  49846. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  49847. /**
  49848. * Creates a new VRDeviceOrientationGamepadCamera
  49849. * @param name defines camera name
  49850. * @param position defines the start position of the camera
  49851. * @param scene defines the scene the camera belongs to
  49852. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49853. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49854. */
  49855. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49856. /**
  49857. * Gets camera class name
  49858. * @returns VRDeviceOrientationGamepadCamera
  49859. */
  49860. getClassName(): string;
  49861. }
  49862. }
  49863. declare module BABYLON {
  49864. /**
  49865. * A class extending Texture allowing drawing on a texture
  49866. * @see https://doc.babylonjs.com/how_to/dynamictexture
  49867. */
  49868. export class DynamicTexture extends Texture {
  49869. private _generateMipMaps;
  49870. private _canvas;
  49871. private _context;
  49872. /**
  49873. * Creates a DynamicTexture
  49874. * @param name defines the name of the texture
  49875. * @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
  49876. * @param scene defines the scene where you want the texture
  49877. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  49878. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  49879. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  49880. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  49881. */
  49882. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  49883. /**
  49884. * Get the current class name of the texture useful for serialization or dynamic coding.
  49885. * @returns "DynamicTexture"
  49886. */
  49887. getClassName(): string;
  49888. /**
  49889. * Gets the current state of canRescale
  49890. */
  49891. get canRescale(): boolean;
  49892. private _recreate;
  49893. /**
  49894. * Scales the texture
  49895. * @param ratio the scale factor to apply to both width and height
  49896. */
  49897. scale(ratio: number): void;
  49898. /**
  49899. * Resizes the texture
  49900. * @param width the new width
  49901. * @param height the new height
  49902. */
  49903. scaleTo(width: number, height: number): void;
  49904. /**
  49905. * Gets the context of the canvas used by the texture
  49906. * @returns the canvas context of the dynamic texture
  49907. */
  49908. getContext(): CanvasRenderingContext2D;
  49909. /**
  49910. * Clears the texture
  49911. */
  49912. clear(): void;
  49913. /**
  49914. * Updates the texture
  49915. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49916. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  49917. */
  49918. update(invertY?: boolean, premulAlpha?: boolean): void;
  49919. /**
  49920. * Draws text onto the texture
  49921. * @param text defines the text to be drawn
  49922. * @param x defines the placement of the text from the left
  49923. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  49924. * @param font defines the font to be used with font-style, font-size, font-name
  49925. * @param color defines the color used for the text
  49926. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  49927. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49928. * @param update defines whether texture is immediately update (default is true)
  49929. */
  49930. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  49931. /**
  49932. * Clones the texture
  49933. * @returns the clone of the texture.
  49934. */
  49935. clone(): DynamicTexture;
  49936. /**
  49937. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  49938. * @returns a serialized dynamic texture object
  49939. */
  49940. serialize(): any;
  49941. private _IsCanvasElement;
  49942. /** @hidden */
  49943. _rebuild(): void;
  49944. }
  49945. }
  49946. declare module BABYLON {
  49947. /**
  49948. * Class containing static functions to help procedurally build meshes
  49949. */
  49950. export class GroundBuilder {
  49951. /**
  49952. * Creates a ground mesh
  49953. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49954. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49956. * @param name defines the name of the mesh
  49957. * @param options defines the options used to create the mesh
  49958. * @param scene defines the hosting scene
  49959. * @returns the ground mesh
  49960. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49961. */
  49962. static CreateGround(name: string, options: {
  49963. width?: number;
  49964. height?: number;
  49965. subdivisions?: number;
  49966. subdivisionsX?: number;
  49967. subdivisionsY?: number;
  49968. updatable?: boolean;
  49969. }, scene: any): Mesh;
  49970. /**
  49971. * Creates a tiled ground mesh
  49972. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49973. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49974. * * 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
  49975. * * 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
  49976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49977. * @param name defines the name of the mesh
  49978. * @param options defines the options used to create the mesh
  49979. * @param scene defines the hosting scene
  49980. * @returns the tiled ground mesh
  49981. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49982. */
  49983. static CreateTiledGround(name: string, options: {
  49984. xmin: number;
  49985. zmin: number;
  49986. xmax: number;
  49987. zmax: number;
  49988. subdivisions?: {
  49989. w: number;
  49990. h: number;
  49991. };
  49992. precision?: {
  49993. w: number;
  49994. h: number;
  49995. };
  49996. updatable?: boolean;
  49997. }, scene?: Nullable<Scene>): Mesh;
  49998. /**
  49999. * Creates a ground mesh from a height map
  50000. * * The parameter `url` sets the URL of the height map image resource.
  50001. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50002. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50003. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50004. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50005. * * 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.
  50006. * * 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).
  50007. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50009. * @param name defines the name of the mesh
  50010. * @param url defines the url to the height map
  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/babylon101/height_map
  50015. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50016. */
  50017. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50018. width?: number;
  50019. height?: number;
  50020. subdivisions?: number;
  50021. minHeight?: number;
  50022. maxHeight?: number;
  50023. colorFilter?: Color3;
  50024. alphaFilter?: number;
  50025. updatable?: boolean;
  50026. onReady?: (mesh: GroundMesh) => void;
  50027. }, scene?: Nullable<Scene>): GroundMesh;
  50028. }
  50029. }
  50030. declare module BABYLON {
  50031. /**
  50032. * Class containing static functions to help procedurally build meshes
  50033. */
  50034. export class TorusBuilder {
  50035. /**
  50036. * Creates a torus mesh
  50037. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50038. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50039. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50041. * * 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
  50042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50043. * @param name defines the name of the mesh
  50044. * @param options defines the options used to create the mesh
  50045. * @param scene defines the hosting scene
  50046. * @returns the torus mesh
  50047. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50048. */
  50049. static CreateTorus(name: string, options: {
  50050. diameter?: number;
  50051. thickness?: number;
  50052. tessellation?: number;
  50053. updatable?: boolean;
  50054. sideOrientation?: number;
  50055. frontUVs?: Vector4;
  50056. backUVs?: Vector4;
  50057. }, scene: any): Mesh;
  50058. }
  50059. }
  50060. declare module BABYLON {
  50061. /**
  50062. * Class containing static functions to help procedurally build meshes
  50063. */
  50064. export class CylinderBuilder {
  50065. /**
  50066. * Creates a cylinder or a cone mesh
  50067. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50068. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50069. * * 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.
  50070. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50071. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50072. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50073. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50074. * * 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).
  50075. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50076. * * 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).
  50077. * * 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
  50078. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50079. * * 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
  50080. * * 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.
  50081. * * If `enclose` is false, a ring surface is one element.
  50082. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50083. * * 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
  50084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50085. * * 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
  50086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50087. * @param name defines the name of the mesh
  50088. * @param options defines the options used to create the mesh
  50089. * @param scene defines the hosting scene
  50090. * @returns the cylinder mesh
  50091. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50092. */
  50093. static CreateCylinder(name: string, options: {
  50094. height?: number;
  50095. diameterTop?: number;
  50096. diameterBottom?: number;
  50097. diameter?: number;
  50098. tessellation?: number;
  50099. subdivisions?: number;
  50100. arc?: number;
  50101. faceColors?: Color4[];
  50102. faceUV?: Vector4[];
  50103. updatable?: boolean;
  50104. hasRings?: boolean;
  50105. enclose?: boolean;
  50106. cap?: number;
  50107. sideOrientation?: number;
  50108. frontUVs?: Vector4;
  50109. backUVs?: Vector4;
  50110. }, scene: any): Mesh;
  50111. }
  50112. }
  50113. declare module BABYLON {
  50114. /**
  50115. * States of the webXR experience
  50116. */
  50117. export enum WebXRState {
  50118. /**
  50119. * Transitioning to being in XR mode
  50120. */
  50121. ENTERING_XR = 0,
  50122. /**
  50123. * Transitioning to non XR mode
  50124. */
  50125. EXITING_XR = 1,
  50126. /**
  50127. * In XR mode and presenting
  50128. */
  50129. IN_XR = 2,
  50130. /**
  50131. * Not entered XR mode
  50132. */
  50133. NOT_IN_XR = 3
  50134. }
  50135. /**
  50136. * The state of the XR camera's tracking
  50137. */
  50138. export enum WebXRTrackingState {
  50139. /**
  50140. * No transformation received, device is not being tracked
  50141. */
  50142. NOT_TRACKING = 0,
  50143. /**
  50144. * Tracking lost - using emulated position
  50145. */
  50146. TRACKING_LOST = 1,
  50147. /**
  50148. * Transformation tracking works normally
  50149. */
  50150. TRACKING = 2
  50151. }
  50152. /**
  50153. * Abstraction of the XR render target
  50154. */
  50155. export interface WebXRRenderTarget extends IDisposable {
  50156. /**
  50157. * xrpresent context of the canvas which can be used to display/mirror xr content
  50158. */
  50159. canvasContext: WebGLRenderingContext;
  50160. /**
  50161. * xr layer for the canvas
  50162. */
  50163. xrLayer: Nullable<XRWebGLLayer>;
  50164. /**
  50165. * Initializes the xr layer for the session
  50166. * @param xrSession xr session
  50167. * @returns a promise that will resolve once the XR Layer has been created
  50168. */
  50169. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50170. }
  50171. }
  50172. declare module BABYLON {
  50173. /**
  50174. * COnfiguration object for WebXR output canvas
  50175. */
  50176. export class WebXRManagedOutputCanvasOptions {
  50177. /**
  50178. * An optional canvas in case you wish to create it yourself and provide it here.
  50179. * If not provided, a new canvas will be created
  50180. */
  50181. canvasElement?: HTMLCanvasElement;
  50182. /**
  50183. * Options for this XR Layer output
  50184. */
  50185. canvasOptions?: XRWebGLLayerInit;
  50186. /**
  50187. * CSS styling for a newly created canvas (if not provided)
  50188. */
  50189. newCanvasCssStyle?: string;
  50190. /**
  50191. * Get the default values of the configuration object
  50192. * @param engine defines the engine to use (can be null)
  50193. * @returns default values of this configuration object
  50194. */
  50195. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50196. }
  50197. /**
  50198. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50199. */
  50200. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50201. private _options;
  50202. private _canvas;
  50203. private _engine;
  50204. private _originalCanvasSize;
  50205. /**
  50206. * Rendering context of the canvas which can be used to display/mirror xr content
  50207. */
  50208. canvasContext: WebGLRenderingContext;
  50209. /**
  50210. * xr layer for the canvas
  50211. */
  50212. xrLayer: Nullable<XRWebGLLayer>;
  50213. /**
  50214. * Obseervers registered here will be triggered when the xr layer was initialized
  50215. */
  50216. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50217. /**
  50218. * Initializes the canvas to be added/removed upon entering/exiting xr
  50219. * @param _xrSessionManager The XR Session manager
  50220. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50221. */
  50222. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50223. /**
  50224. * Disposes of the object
  50225. */
  50226. dispose(): void;
  50227. /**
  50228. * Initializes the xr layer for the session
  50229. * @param xrSession xr session
  50230. * @returns a promise that will resolve once the XR Layer has been created
  50231. */
  50232. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50233. private _addCanvas;
  50234. private _removeCanvas;
  50235. private _setCanvasSize;
  50236. private _setManagedOutputCanvas;
  50237. }
  50238. }
  50239. declare module BABYLON {
  50240. /**
  50241. * Manages an XRSession to work with Babylon's engine
  50242. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50243. */
  50244. export class WebXRSessionManager implements IDisposable {
  50245. /** The scene which the session should be created for */
  50246. scene: Scene;
  50247. private _referenceSpace;
  50248. private _rttProvider;
  50249. private _sessionEnded;
  50250. private _xrNavigator;
  50251. private baseLayer;
  50252. /**
  50253. * The base reference space from which the session started. good if you want to reset your
  50254. * reference space
  50255. */
  50256. baseReferenceSpace: XRReferenceSpace;
  50257. /**
  50258. * Current XR frame
  50259. */
  50260. currentFrame: Nullable<XRFrame>;
  50261. /** WebXR timestamp updated every frame */
  50262. currentTimestamp: number;
  50263. /**
  50264. * Used just in case of a failure to initialize an immersive session.
  50265. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50266. */
  50267. defaultHeightCompensation: number;
  50268. /**
  50269. * Fires every time a new xrFrame arrives which can be used to update the camera
  50270. */
  50271. onXRFrameObservable: Observable<XRFrame>;
  50272. /**
  50273. * Fires when the reference space changed
  50274. */
  50275. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50276. /**
  50277. * Fires when the xr session is ended either by the device or manually done
  50278. */
  50279. onXRSessionEnded: Observable<any>;
  50280. /**
  50281. * Fires when the xr session is ended either by the device or manually done
  50282. */
  50283. onXRSessionInit: Observable<XRSession>;
  50284. /**
  50285. * Underlying xr session
  50286. */
  50287. session: XRSession;
  50288. /**
  50289. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50290. * or get the offset the player is currently at.
  50291. */
  50292. viewerReferenceSpace: XRReferenceSpace;
  50293. /**
  50294. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50295. * @param scene The scene which the session should be created for
  50296. */
  50297. constructor(
  50298. /** The scene which the session should be created for */
  50299. scene: Scene);
  50300. /**
  50301. * The current reference space used in this session. This reference space can constantly change!
  50302. * It is mainly used to offset the camera's position.
  50303. */
  50304. get referenceSpace(): XRReferenceSpace;
  50305. /**
  50306. * Set a new reference space and triggers the observable
  50307. */
  50308. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50309. /**
  50310. * Disposes of the session manager
  50311. */
  50312. dispose(): void;
  50313. /**
  50314. * Stops the xrSession and restores the render loop
  50315. * @returns Promise which resolves after it exits XR
  50316. */
  50317. exitXRAsync(): Promise<void>;
  50318. /**
  50319. * Gets the correct render target texture to be rendered this frame for this eye
  50320. * @param eye the eye for which to get the render target
  50321. * @returns the render target for the specified eye
  50322. */
  50323. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50324. /**
  50325. * Creates a WebXRRenderTarget object for the XR session
  50326. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50327. * @param options optional options to provide when creating a new render target
  50328. * @returns a WebXR render target to which the session can render
  50329. */
  50330. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50331. /**
  50332. * Initializes the manager
  50333. * After initialization enterXR can be called to start an XR session
  50334. * @returns Promise which resolves after it is initialized
  50335. */
  50336. initializeAsync(): Promise<void>;
  50337. /**
  50338. * Initializes an xr session
  50339. * @param xrSessionMode mode to initialize
  50340. * @param xrSessionInit defines optional and required values to pass to the session builder
  50341. * @returns a promise which will resolve once the session has been initialized
  50342. */
  50343. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50344. /**
  50345. * Checks if a session would be supported for the creation options specified
  50346. * @param sessionMode session mode to check if supported eg. immersive-vr
  50347. * @returns A Promise that resolves to true if supported and false if not
  50348. */
  50349. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50350. /**
  50351. * Resets the reference space to the one started the session
  50352. */
  50353. resetReferenceSpace(): void;
  50354. /**
  50355. * Starts rendering to the xr layer
  50356. */
  50357. runXRRenderLoop(): void;
  50358. /**
  50359. * Sets the reference space on the xr session
  50360. * @param referenceSpaceType space to set
  50361. * @returns a promise that will resolve once the reference space has been set
  50362. */
  50363. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50364. /**
  50365. * Updates the render state of the session
  50366. * @param state state to set
  50367. * @returns a promise that resolves once the render state has been updated
  50368. */
  50369. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50370. /**
  50371. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50372. * @param sessionMode defines the session to test
  50373. * @returns a promise with boolean as final value
  50374. */
  50375. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50376. private _createRenderTargetTexture;
  50377. }
  50378. }
  50379. declare module BABYLON {
  50380. /**
  50381. * WebXR Camera which holds the views for the xrSession
  50382. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50383. */
  50384. export class WebXRCamera extends FreeCamera {
  50385. private _xrSessionManager;
  50386. private _firstFrame;
  50387. private _referenceQuaternion;
  50388. private _referencedPosition;
  50389. private _xrInvPositionCache;
  50390. private _xrInvQuaternionCache;
  50391. private _trackingState;
  50392. /**
  50393. * Observable raised before camera teleportation
  50394. */
  50395. onBeforeCameraTeleport: Observable<Vector3>;
  50396. /**
  50397. * Observable raised after camera teleportation
  50398. */
  50399. onAfterCameraTeleport: Observable<Vector3>;
  50400. /**
  50401. * Notifies when the camera's tracking state has changed.
  50402. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50403. */
  50404. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50405. /**
  50406. * Should position compensation execute on first frame.
  50407. * This is used when copying the position from a native (non XR) camera
  50408. */
  50409. compensateOnFirstFrame: boolean;
  50410. /**
  50411. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50412. * @param name the name of the camera
  50413. * @param scene the scene to add the camera to
  50414. * @param _xrSessionManager a constructed xr session manager
  50415. */
  50416. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50417. /**
  50418. * Get the current XR tracking state of the camera
  50419. */
  50420. get trackingState(): WebXRTrackingState;
  50421. private _setTrackingState;
  50422. /**
  50423. * Return the user's height, unrelated to the current ground.
  50424. * This will be the y position of this camera, when ground level is 0.
  50425. */
  50426. get realWorldHeight(): number;
  50427. /** @hidden */
  50428. _updateForDualEyeDebugging(): void;
  50429. /**
  50430. * Sets this camera's transformation based on a non-vr camera
  50431. * @param otherCamera the non-vr camera to copy the transformation from
  50432. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50433. */
  50434. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50435. /**
  50436. * Gets the current instance class name ("WebXRCamera").
  50437. * @returns the class name
  50438. */
  50439. getClassName(): string;
  50440. private _rotate180;
  50441. private _updateFromXRSession;
  50442. private _updateNumberOfRigCameras;
  50443. private _updateReferenceSpace;
  50444. private _updateReferenceSpaceOffset;
  50445. }
  50446. }
  50447. declare module BABYLON {
  50448. /**
  50449. * Defining the interface required for a (webxr) feature
  50450. */
  50451. export interface IWebXRFeature extends IDisposable {
  50452. /**
  50453. * Is this feature attached
  50454. */
  50455. attached: boolean;
  50456. /**
  50457. * Should auto-attach be disabled?
  50458. */
  50459. disableAutoAttach: boolean;
  50460. /**
  50461. * Attach the feature to the session
  50462. * Will usually be called by the features manager
  50463. *
  50464. * @param force should attachment be forced (even when already attached)
  50465. * @returns true if successful.
  50466. */
  50467. attach(force?: boolean): boolean;
  50468. /**
  50469. * Detach the feature from the session
  50470. * Will usually be called by the features manager
  50471. *
  50472. * @returns true if successful.
  50473. */
  50474. detach(): boolean;
  50475. /**
  50476. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50477. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50478. *
  50479. * @returns whether or not the feature is compatible in this environment
  50480. */
  50481. isCompatible(): boolean;
  50482. /**
  50483. * Was this feature disposed;
  50484. */
  50485. isDisposed: boolean;
  50486. /**
  50487. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50488. */
  50489. xrNativeFeatureName?: string;
  50490. /**
  50491. * A list of (Babylon WebXR) features this feature depends on
  50492. */
  50493. dependsOn?: string[];
  50494. }
  50495. /**
  50496. * A list of the currently available features without referencing them
  50497. */
  50498. export class WebXRFeatureName {
  50499. /**
  50500. * The name of the anchor system feature
  50501. */
  50502. static readonly ANCHOR_SYSTEM: string;
  50503. /**
  50504. * The name of the background remover feature
  50505. */
  50506. static readonly BACKGROUND_REMOVER: string;
  50507. /**
  50508. * The name of the hit test feature
  50509. */
  50510. static readonly HIT_TEST: string;
  50511. /**
  50512. * physics impostors for xr controllers feature
  50513. */
  50514. static readonly PHYSICS_CONTROLLERS: string;
  50515. /**
  50516. * The name of the plane detection feature
  50517. */
  50518. static readonly PLANE_DETECTION: string;
  50519. /**
  50520. * The name of the pointer selection feature
  50521. */
  50522. static readonly POINTER_SELECTION: string;
  50523. /**
  50524. * The name of the teleportation feature
  50525. */
  50526. static readonly TELEPORTATION: string;
  50527. /**
  50528. * The name of the feature points feature.
  50529. */
  50530. static readonly FEATURE_POINTS: string;
  50531. /**
  50532. * The name of the hand tracking feature.
  50533. */
  50534. static readonly HAND_TRACKING: string;
  50535. }
  50536. /**
  50537. * Defining the constructor of a feature. Used to register the modules.
  50538. */
  50539. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50540. /**
  50541. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50542. * It is mainly used in AR sessions.
  50543. *
  50544. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50545. */
  50546. export class WebXRFeaturesManager implements IDisposable {
  50547. private _xrSessionManager;
  50548. private static readonly _AvailableFeatures;
  50549. private _features;
  50550. /**
  50551. * constructs a new features manages.
  50552. *
  50553. * @param _xrSessionManager an instance of WebXRSessionManager
  50554. */
  50555. constructor(_xrSessionManager: WebXRSessionManager);
  50556. /**
  50557. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50558. * Mainly used internally.
  50559. *
  50560. * @param featureName the name of the feature to register
  50561. * @param constructorFunction the function used to construct the module
  50562. * @param version the (babylon) version of the module
  50563. * @param stable is that a stable version of this module
  50564. */
  50565. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50566. /**
  50567. * Returns a constructor of a specific feature.
  50568. *
  50569. * @param featureName the name of the feature to construct
  50570. * @param version the version of the feature to load
  50571. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50572. * @param options optional options provided to the module.
  50573. * @returns a function that, when called, will return a new instance of this feature
  50574. */
  50575. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50576. /**
  50577. * Can be used to return the list of features currently registered
  50578. *
  50579. * @returns an Array of available features
  50580. */
  50581. static GetAvailableFeatures(): string[];
  50582. /**
  50583. * Gets the versions available for a specific feature
  50584. * @param featureName the name of the feature
  50585. * @returns an array with the available versions
  50586. */
  50587. static GetAvailableVersions(featureName: string): string[];
  50588. /**
  50589. * Return the latest unstable version of this feature
  50590. * @param featureName the name of the feature to search
  50591. * @returns the version number. if not found will return -1
  50592. */
  50593. static GetLatestVersionOfFeature(featureName: string): number;
  50594. /**
  50595. * Return the latest stable version of this feature
  50596. * @param featureName the name of the feature to search
  50597. * @returns the version number. if not found will return -1
  50598. */
  50599. static GetStableVersionOfFeature(featureName: string): number;
  50600. /**
  50601. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50602. * Can be used during a session to start a feature
  50603. * @param featureName the name of feature to attach
  50604. */
  50605. attachFeature(featureName: string): void;
  50606. /**
  50607. * Can be used inside a session or when the session ends to detach a specific feature
  50608. * @param featureName the name of the feature to detach
  50609. */
  50610. detachFeature(featureName: string): void;
  50611. /**
  50612. * Used to disable an already-enabled feature
  50613. * The feature will be disposed and will be recreated once enabled.
  50614. * @param featureName the feature to disable
  50615. * @returns true if disable was successful
  50616. */
  50617. disableFeature(featureName: string | {
  50618. Name: string;
  50619. }): boolean;
  50620. /**
  50621. * dispose this features manager
  50622. */
  50623. dispose(): void;
  50624. /**
  50625. * 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.
  50626. * 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.
  50627. *
  50628. * @param featureName the name of the feature to load or the class of the feature
  50629. * @param version optional version to load. if not provided the latest version will be enabled
  50630. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50631. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50632. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50633. * @returns a new constructed feature or throws an error if feature not found.
  50634. */
  50635. enableFeature(featureName: string | {
  50636. Name: string;
  50637. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50638. /**
  50639. * get the implementation of an enabled feature.
  50640. * @param featureName the name of the feature to load
  50641. * @returns the feature class, if found
  50642. */
  50643. getEnabledFeature(featureName: string): IWebXRFeature;
  50644. /**
  50645. * Get the list of enabled features
  50646. * @returns an array of enabled features
  50647. */
  50648. getEnabledFeatures(): string[];
  50649. /**
  50650. * This function will exten the session creation configuration object with enabled features.
  50651. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50652. * according to the defined "required" variable, provided during enableFeature call
  50653. * @param xrSessionInit the xr Session init object to extend
  50654. *
  50655. * @returns an extended XRSessionInit object
  50656. */
  50657. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50658. }
  50659. }
  50660. declare module BABYLON {
  50661. /**
  50662. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50663. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50664. */
  50665. export class WebXRExperienceHelper implements IDisposable {
  50666. private scene;
  50667. private _nonVRCamera;
  50668. private _originalSceneAutoClear;
  50669. private _supported;
  50670. /**
  50671. * Camera used to render xr content
  50672. */
  50673. camera: WebXRCamera;
  50674. /** A features manager for this xr session */
  50675. featuresManager: WebXRFeaturesManager;
  50676. /**
  50677. * Observers registered here will be triggered after the camera's initial transformation is set
  50678. * This can be used to set a different ground level or an extra rotation.
  50679. *
  50680. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  50681. * to the position set after this observable is done executing.
  50682. */
  50683. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  50684. /**
  50685. * Fires when the state of the experience helper has changed
  50686. */
  50687. onStateChangedObservable: Observable<WebXRState>;
  50688. /** Session manager used to keep track of xr session */
  50689. sessionManager: WebXRSessionManager;
  50690. /**
  50691. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  50692. */
  50693. state: WebXRState;
  50694. /**
  50695. * Creates a WebXRExperienceHelper
  50696. * @param scene The scene the helper should be created in
  50697. */
  50698. private constructor();
  50699. /**
  50700. * Creates the experience helper
  50701. * @param scene the scene to attach the experience helper to
  50702. * @returns a promise for the experience helper
  50703. */
  50704. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  50705. /**
  50706. * Disposes of the experience helper
  50707. */
  50708. dispose(): void;
  50709. /**
  50710. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  50711. * @param sessionMode options for the XR session
  50712. * @param referenceSpaceType frame of reference of the XR session
  50713. * @param renderTarget the output canvas that will be used to enter XR mode
  50714. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  50715. * @returns promise that resolves after xr mode has entered
  50716. */
  50717. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  50718. /**
  50719. * Exits XR mode and returns the scene to its original state
  50720. * @returns promise that resolves after xr mode has exited
  50721. */
  50722. exitXRAsync(): Promise<void>;
  50723. private _nonXRToXRCamera;
  50724. private _setState;
  50725. }
  50726. }
  50727. declare module BABYLON {
  50728. /**
  50729. * X-Y values for axes in WebXR
  50730. */
  50731. export interface IWebXRMotionControllerAxesValue {
  50732. /**
  50733. * The value of the x axis
  50734. */
  50735. x: number;
  50736. /**
  50737. * The value of the y-axis
  50738. */
  50739. y: number;
  50740. }
  50741. /**
  50742. * changed / previous values for the values of this component
  50743. */
  50744. export interface IWebXRMotionControllerComponentChangesValues<T> {
  50745. /**
  50746. * current (this frame) value
  50747. */
  50748. current: T;
  50749. /**
  50750. * previous (last change) value
  50751. */
  50752. previous: T;
  50753. }
  50754. /**
  50755. * Represents changes in the component between current frame and last values recorded
  50756. */
  50757. export interface IWebXRMotionControllerComponentChanges {
  50758. /**
  50759. * will be populated with previous and current values if axes changed
  50760. */
  50761. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  50762. /**
  50763. * will be populated with previous and current values if pressed changed
  50764. */
  50765. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50766. /**
  50767. * will be populated with previous and current values if touched changed
  50768. */
  50769. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50770. /**
  50771. * will be populated with previous and current values if value changed
  50772. */
  50773. value?: IWebXRMotionControllerComponentChangesValues<number>;
  50774. }
  50775. /**
  50776. * This class represents a single component (for example button or thumbstick) of a motion controller
  50777. */
  50778. export class WebXRControllerComponent implements IDisposable {
  50779. /**
  50780. * the id of this component
  50781. */
  50782. id: string;
  50783. /**
  50784. * the type of the component
  50785. */
  50786. type: MotionControllerComponentType;
  50787. private _buttonIndex;
  50788. private _axesIndices;
  50789. private _axes;
  50790. private _changes;
  50791. private _currentValue;
  50792. private _hasChanges;
  50793. private _pressed;
  50794. private _touched;
  50795. /**
  50796. * button component type
  50797. */
  50798. static BUTTON_TYPE: MotionControllerComponentType;
  50799. /**
  50800. * squeeze component type
  50801. */
  50802. static SQUEEZE_TYPE: MotionControllerComponentType;
  50803. /**
  50804. * Thumbstick component type
  50805. */
  50806. static THUMBSTICK_TYPE: MotionControllerComponentType;
  50807. /**
  50808. * Touchpad component type
  50809. */
  50810. static TOUCHPAD_TYPE: MotionControllerComponentType;
  50811. /**
  50812. * trigger component type
  50813. */
  50814. static TRIGGER_TYPE: MotionControllerComponentType;
  50815. /**
  50816. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  50817. * the axes data changes
  50818. */
  50819. onAxisValueChangedObservable: Observable<{
  50820. x: number;
  50821. y: number;
  50822. }>;
  50823. /**
  50824. * Observers registered here will be triggered when the state of a button changes
  50825. * State change is either pressed / touched / value
  50826. */
  50827. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  50828. /**
  50829. * Creates a new component for a motion controller.
  50830. * It is created by the motion controller itself
  50831. *
  50832. * @param id the id of this component
  50833. * @param type the type of the component
  50834. * @param _buttonIndex index in the buttons array of the gamepad
  50835. * @param _axesIndices indices of the values in the axes array of the gamepad
  50836. */
  50837. constructor(
  50838. /**
  50839. * the id of this component
  50840. */
  50841. id: string,
  50842. /**
  50843. * the type of the component
  50844. */
  50845. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  50846. /**
  50847. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  50848. */
  50849. get axes(): IWebXRMotionControllerAxesValue;
  50850. /**
  50851. * Get the changes. Elements will be populated only if they changed with their previous and current value
  50852. */
  50853. get changes(): IWebXRMotionControllerComponentChanges;
  50854. /**
  50855. * Return whether or not the component changed the last frame
  50856. */
  50857. get hasChanges(): boolean;
  50858. /**
  50859. * is the button currently pressed
  50860. */
  50861. get pressed(): boolean;
  50862. /**
  50863. * is the button currently touched
  50864. */
  50865. get touched(): boolean;
  50866. /**
  50867. * Get the current value of this component
  50868. */
  50869. get value(): number;
  50870. /**
  50871. * Dispose this component
  50872. */
  50873. dispose(): void;
  50874. /**
  50875. * Are there axes correlating to this component
  50876. * @return true is axes data is available
  50877. */
  50878. isAxes(): boolean;
  50879. /**
  50880. * Is this component a button (hence - pressable)
  50881. * @returns true if can be pressed
  50882. */
  50883. isButton(): boolean;
  50884. /**
  50885. * update this component using the gamepad object it is in. Called on every frame
  50886. * @param nativeController the native gamepad controller object
  50887. */
  50888. update(nativeController: IMinimalMotionControllerObject): void;
  50889. }
  50890. }
  50891. declare module BABYLON {
  50892. /**
  50893. * Interface used to represent data loading progression
  50894. */
  50895. export interface ISceneLoaderProgressEvent {
  50896. /**
  50897. * Defines if data length to load can be evaluated
  50898. */
  50899. readonly lengthComputable: boolean;
  50900. /**
  50901. * Defines the loaded data length
  50902. */
  50903. readonly loaded: number;
  50904. /**
  50905. * Defines the data length to load
  50906. */
  50907. readonly total: number;
  50908. }
  50909. /**
  50910. * Interface used by SceneLoader plugins to define supported file extensions
  50911. */
  50912. export interface ISceneLoaderPluginExtensions {
  50913. /**
  50914. * Defines the list of supported extensions
  50915. */
  50916. [extension: string]: {
  50917. isBinary: boolean;
  50918. };
  50919. }
  50920. /**
  50921. * Interface used by SceneLoader plugin factory
  50922. */
  50923. export interface ISceneLoaderPluginFactory {
  50924. /**
  50925. * Defines the name of the factory
  50926. */
  50927. name: string;
  50928. /**
  50929. * Function called to create a new plugin
  50930. * @return the new plugin
  50931. */
  50932. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  50933. /**
  50934. * The callback that returns true if the data can be directly loaded.
  50935. * @param data string containing the file data
  50936. * @returns if the data can be loaded directly
  50937. */
  50938. canDirectLoad?(data: string): boolean;
  50939. }
  50940. /**
  50941. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  50942. */
  50943. export interface ISceneLoaderPluginBase {
  50944. /**
  50945. * The friendly name of this plugin.
  50946. */
  50947. name: string;
  50948. /**
  50949. * The file extensions supported by this plugin.
  50950. */
  50951. extensions: string | ISceneLoaderPluginExtensions;
  50952. /**
  50953. * The callback called when loading from a url.
  50954. * @param scene scene loading this url
  50955. * @param url url to load
  50956. * @param onSuccess callback called when the file successfully loads
  50957. * @param onProgress callback called while file is loading (if the server supports this mode)
  50958. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  50959. * @param onError callback called when the file fails to load
  50960. * @returns a file request object
  50961. */
  50962. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50963. /**
  50964. * The callback called when loading from a file object.
  50965. * @param scene scene loading this file
  50966. * @param file defines the file to load
  50967. * @param onSuccess defines the callback to call when data is loaded
  50968. * @param onProgress defines the callback to call during loading process
  50969. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  50970. * @param onError defines the callback to call when an error occurs
  50971. * @returns a file request object
  50972. */
  50973. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50974. /**
  50975. * The callback that returns true if the data can be directly loaded.
  50976. * @param data string containing the file data
  50977. * @returns if the data can be loaded directly
  50978. */
  50979. canDirectLoad?(data: string): boolean;
  50980. /**
  50981. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  50982. * @param scene scene loading this data
  50983. * @param data string containing the data
  50984. * @returns data to pass to the plugin
  50985. */
  50986. directLoad?(scene: Scene, data: string): any;
  50987. /**
  50988. * The callback that allows custom handling of the root url based on the response url.
  50989. * @param rootUrl the original root url
  50990. * @param responseURL the response url if available
  50991. * @returns the new root url
  50992. */
  50993. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  50994. }
  50995. /**
  50996. * Interface used to define a SceneLoader plugin
  50997. */
  50998. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  50999. /**
  51000. * Import meshes into a scene.
  51001. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51002. * @param scene The scene to import into
  51003. * @param data The data to import
  51004. * @param rootUrl The root url for scene and resources
  51005. * @param meshes The meshes array to import into
  51006. * @param particleSystems The particle systems array to import into
  51007. * @param skeletons The skeletons array to import into
  51008. * @param onError The callback when import fails
  51009. * @returns True if successful or false otherwise
  51010. */
  51011. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51012. /**
  51013. * Load into a scene.
  51014. * @param scene The scene to load into
  51015. * @param data The data to import
  51016. * @param rootUrl The root url for scene and resources
  51017. * @param onError The callback when import fails
  51018. * @returns True if successful or false otherwise
  51019. */
  51020. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51021. /**
  51022. * Load into an asset container.
  51023. * @param scene The scene to load into
  51024. * @param data The data to import
  51025. * @param rootUrl The root url for scene and resources
  51026. * @param onError The callback when import fails
  51027. * @returns The loaded asset container
  51028. */
  51029. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51030. }
  51031. /**
  51032. * Interface used to define an async SceneLoader plugin
  51033. */
  51034. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51035. /**
  51036. * Import meshes into a scene.
  51037. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51038. * @param scene The scene to import into
  51039. * @param data The data to import
  51040. * @param rootUrl The root url for scene and resources
  51041. * @param onProgress The callback when the load progresses
  51042. * @param fileName Defines the name of the file to load
  51043. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  51044. */
  51045. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  51046. meshes: AbstractMesh[];
  51047. particleSystems: IParticleSystem[];
  51048. skeletons: Skeleton[];
  51049. animationGroups: AnimationGroup[];
  51050. }>;
  51051. /**
  51052. * Load into a scene.
  51053. * @param scene The scene to load into
  51054. * @param data The data to import
  51055. * @param rootUrl The root url for scene and resources
  51056. * @param onProgress The callback when the load progresses
  51057. * @param fileName Defines the name of the file to load
  51058. * @returns Nothing
  51059. */
  51060. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51061. /**
  51062. * Load into an asset container.
  51063. * @param scene The scene to load into
  51064. * @param data The data to import
  51065. * @param rootUrl The root url for scene and resources
  51066. * @param onProgress The callback when the load progresses
  51067. * @param fileName Defines the name of the file to load
  51068. * @returns The loaded asset container
  51069. */
  51070. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51071. }
  51072. /**
  51073. * Mode that determines how to handle old animation groups before loading new ones.
  51074. */
  51075. export enum SceneLoaderAnimationGroupLoadingMode {
  51076. /**
  51077. * Reset all old animations to initial state then dispose them.
  51078. */
  51079. Clean = 0,
  51080. /**
  51081. * Stop all old animations.
  51082. */
  51083. Stop = 1,
  51084. /**
  51085. * Restart old animations from first frame.
  51086. */
  51087. Sync = 2,
  51088. /**
  51089. * Old animations remains untouched.
  51090. */
  51091. NoSync = 3
  51092. }
  51093. /**
  51094. * Defines a plugin registered by the SceneLoader
  51095. */
  51096. interface IRegisteredPlugin {
  51097. /**
  51098. * Defines the plugin to use
  51099. */
  51100. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51101. /**
  51102. * Defines if the plugin supports binary data
  51103. */
  51104. isBinary: boolean;
  51105. }
  51106. /**
  51107. * Class used to load scene from various file formats using registered plugins
  51108. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51109. */
  51110. export class SceneLoader {
  51111. /**
  51112. * No logging while loading
  51113. */
  51114. static readonly NO_LOGGING: number;
  51115. /**
  51116. * Minimal logging while loading
  51117. */
  51118. static readonly MINIMAL_LOGGING: number;
  51119. /**
  51120. * Summary logging while loading
  51121. */
  51122. static readonly SUMMARY_LOGGING: number;
  51123. /**
  51124. * Detailled logging while loading
  51125. */
  51126. static readonly DETAILED_LOGGING: number;
  51127. /**
  51128. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51129. */
  51130. static get ForceFullSceneLoadingForIncremental(): boolean;
  51131. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51132. /**
  51133. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51134. */
  51135. static get ShowLoadingScreen(): boolean;
  51136. static set ShowLoadingScreen(value: boolean);
  51137. /**
  51138. * Defines the current logging level (while loading the scene)
  51139. * @ignorenaming
  51140. */
  51141. static get loggingLevel(): number;
  51142. static set loggingLevel(value: number);
  51143. /**
  51144. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51145. */
  51146. static get CleanBoneMatrixWeights(): boolean;
  51147. static set CleanBoneMatrixWeights(value: boolean);
  51148. /**
  51149. * Event raised when a plugin is used to load a scene
  51150. */
  51151. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51152. private static _registeredPlugins;
  51153. private static _showingLoadingScreen;
  51154. /**
  51155. * Gets the default plugin (used to load Babylon files)
  51156. * @returns the .babylon plugin
  51157. */
  51158. static GetDefaultPlugin(): IRegisteredPlugin;
  51159. private static _GetPluginForExtension;
  51160. private static _GetPluginForDirectLoad;
  51161. private static _GetPluginForFilename;
  51162. private static _GetDirectLoad;
  51163. private static _LoadData;
  51164. private static _GetFileInfo;
  51165. /**
  51166. * Gets a plugin that can load the given extension
  51167. * @param extension defines the extension to load
  51168. * @returns a plugin or null if none works
  51169. */
  51170. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51171. /**
  51172. * Gets a boolean indicating that the given extension can be loaded
  51173. * @param extension defines the extension to load
  51174. * @returns true if the extension is supported
  51175. */
  51176. static IsPluginForExtensionAvailable(extension: string): boolean;
  51177. /**
  51178. * Adds a new plugin to the list of registered plugins
  51179. * @param plugin defines the plugin to add
  51180. */
  51181. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51182. /**
  51183. * Import meshes into a scene
  51184. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51185. * @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)
  51186. * @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)
  51187. * @param scene the instance of BABYLON.Scene to append to
  51188. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51189. * @param onProgress a callback with a progress event for each file being loaded
  51190. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51191. * @param pluginExtension the extension used to determine the plugin
  51192. * @returns The loaded plugin
  51193. */
  51194. 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>;
  51195. /**
  51196. * Import meshes into a scene
  51197. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51198. * @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)
  51199. * @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)
  51200. * @param scene the instance of BABYLON.Scene to append to
  51201. * @param onProgress a callback with a progress event for each file being loaded
  51202. * @param pluginExtension the extension used to determine the plugin
  51203. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51204. */
  51205. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  51206. meshes: AbstractMesh[];
  51207. particleSystems: IParticleSystem[];
  51208. skeletons: Skeleton[];
  51209. animationGroups: AnimationGroup[];
  51210. }>;
  51211. /**
  51212. * Load a scene
  51213. * @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)
  51214. * @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)
  51215. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51216. * @param onSuccess a callback with the scene when import succeeds
  51217. * @param onProgress a callback with a progress event for each file being loaded
  51218. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51219. * @param pluginExtension the extension used to determine the plugin
  51220. * @returns The loaded plugin
  51221. */
  51222. 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>;
  51223. /**
  51224. * Load a scene
  51225. * @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)
  51226. * @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)
  51227. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51228. * @param onProgress a callback with a progress event for each file being loaded
  51229. * @param pluginExtension the extension used to determine the plugin
  51230. * @returns The loaded scene
  51231. */
  51232. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51233. /**
  51234. * Append a scene
  51235. * @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)
  51236. * @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)
  51237. * @param scene is the instance of BABYLON.Scene to append to
  51238. * @param onSuccess a callback with the scene when import succeeds
  51239. * @param onProgress a callback with a progress event for each file being loaded
  51240. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51241. * @param pluginExtension the extension used to determine the plugin
  51242. * @returns The loaded plugin
  51243. */
  51244. 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>;
  51245. /**
  51246. * Append a scene
  51247. * @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)
  51248. * @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)
  51249. * @param scene is the instance of BABYLON.Scene to append to
  51250. * @param onProgress a callback with a progress event for each file being loaded
  51251. * @param pluginExtension the extension used to determine the plugin
  51252. * @returns The given scene
  51253. */
  51254. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51255. /**
  51256. * Load a scene into an asset container
  51257. * @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)
  51258. * @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)
  51259. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51260. * @param onSuccess a callback with the scene when import succeeds
  51261. * @param onProgress a callback with a progress event for each file being loaded
  51262. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51263. * @param pluginExtension the extension used to determine the plugin
  51264. * @returns The loaded plugin
  51265. */
  51266. 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>;
  51267. /**
  51268. * Load a scene into an asset container
  51269. * @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)
  51270. * @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)
  51271. * @param scene is the instance of Scene to append to
  51272. * @param onProgress a callback with a progress event for each file being loaded
  51273. * @param pluginExtension the extension used to determine the plugin
  51274. * @returns The loaded asset container
  51275. */
  51276. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51277. /**
  51278. * Import animations from a file into 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 scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51282. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51283. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51284. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51285. * @param onSuccess a callback with the scene when import succeeds
  51286. * @param onProgress a callback with a progress event for each file being loaded
  51287. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51288. * @param pluginExtension the extension used to determine the plugin
  51289. */
  51290. 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;
  51291. /**
  51292. * Import animations from a file into a scene
  51293. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  51294. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  51295. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51296. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51297. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51298. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51299. * @param onSuccess a callback with the scene when import succeeds
  51300. * @param onProgress a callback with a progress event for each file being loaded
  51301. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51302. * @param pluginExtension the extension used to determine the plugin
  51303. * @returns the updated scene with imported animations
  51304. */
  51305. 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>;
  51306. }
  51307. }
  51308. declare module BABYLON {
  51309. /**
  51310. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51311. */
  51312. export type MotionControllerHandedness = "none" | "left" | "right";
  51313. /**
  51314. * The type of components available in motion controllers.
  51315. * This is not the name of the component.
  51316. */
  51317. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51318. /**
  51319. * The state of a controller component
  51320. */
  51321. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51322. /**
  51323. * The schema of motion controller layout.
  51324. * No object will be initialized using this interface
  51325. * This is used just to define the profile.
  51326. */
  51327. export interface IMotionControllerLayout {
  51328. /**
  51329. * Path to load the assets. Usually relative to the base path
  51330. */
  51331. assetPath: string;
  51332. /**
  51333. * Available components (unsorted)
  51334. */
  51335. components: {
  51336. /**
  51337. * A map of component Ids
  51338. */
  51339. [componentId: string]: {
  51340. /**
  51341. * The type of input the component outputs
  51342. */
  51343. type: MotionControllerComponentType;
  51344. /**
  51345. * The indices of this component in the gamepad object
  51346. */
  51347. gamepadIndices: {
  51348. /**
  51349. * Index of button
  51350. */
  51351. button?: number;
  51352. /**
  51353. * If available, index of x-axis
  51354. */
  51355. xAxis?: number;
  51356. /**
  51357. * If available, index of y-axis
  51358. */
  51359. yAxis?: number;
  51360. };
  51361. /**
  51362. * The mesh's root node name
  51363. */
  51364. rootNodeName: string;
  51365. /**
  51366. * Animation definitions for this model
  51367. */
  51368. visualResponses: {
  51369. [stateKey: string]: {
  51370. /**
  51371. * What property will be animated
  51372. */
  51373. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51374. /**
  51375. * What states influence this visual response
  51376. */
  51377. states: MotionControllerComponentStateType[];
  51378. /**
  51379. * Type of animation - movement or visibility
  51380. */
  51381. valueNodeProperty: "transform" | "visibility";
  51382. /**
  51383. * Base node name to move. Its position will be calculated according to the min and max nodes
  51384. */
  51385. valueNodeName?: string;
  51386. /**
  51387. * Minimum movement node
  51388. */
  51389. minNodeName?: string;
  51390. /**
  51391. * Max movement node
  51392. */
  51393. maxNodeName?: string;
  51394. };
  51395. };
  51396. /**
  51397. * If touch enabled, what is the name of node to display user feedback
  51398. */
  51399. touchPointNodeName?: string;
  51400. };
  51401. };
  51402. /**
  51403. * Is it xr standard mapping or not
  51404. */
  51405. gamepadMapping: "" | "xr-standard";
  51406. /**
  51407. * Base root node of this entire model
  51408. */
  51409. rootNodeName: string;
  51410. /**
  51411. * Defines the main button component id
  51412. */
  51413. selectComponentId: string;
  51414. }
  51415. /**
  51416. * A definition for the layout map in the input profile
  51417. */
  51418. export interface IMotionControllerLayoutMap {
  51419. /**
  51420. * Layouts with handedness type as a key
  51421. */
  51422. [handedness: string]: IMotionControllerLayout;
  51423. }
  51424. /**
  51425. * The XR Input profile schema
  51426. * Profiles can be found here:
  51427. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51428. */
  51429. export interface IMotionControllerProfile {
  51430. /**
  51431. * fallback profiles for this profileId
  51432. */
  51433. fallbackProfileIds: string[];
  51434. /**
  51435. * The layout map, with handedness as key
  51436. */
  51437. layouts: IMotionControllerLayoutMap;
  51438. /**
  51439. * The id of this profile
  51440. * correlates to the profile(s) in the xrInput.profiles array
  51441. */
  51442. profileId: string;
  51443. }
  51444. /**
  51445. * A helper-interface for the 3 meshes needed for controller button animation
  51446. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51447. */
  51448. export interface IMotionControllerButtonMeshMap {
  51449. /**
  51450. * the mesh that defines the pressed value mesh position.
  51451. * This is used to find the max-position of this button
  51452. */
  51453. pressedMesh: AbstractMesh;
  51454. /**
  51455. * the mesh that defines the unpressed value mesh position.
  51456. * This is used to find the min (or initial) position of this button
  51457. */
  51458. unpressedMesh: AbstractMesh;
  51459. /**
  51460. * The mesh that will be changed when value changes
  51461. */
  51462. valueMesh: AbstractMesh;
  51463. }
  51464. /**
  51465. * A helper-interface for the 3 meshes needed for controller axis animation.
  51466. * This will be expanded when touchpad animations are fully supported
  51467. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51468. */
  51469. export interface IMotionControllerMeshMap {
  51470. /**
  51471. * the mesh that defines the maximum value mesh position.
  51472. */
  51473. maxMesh?: AbstractMesh;
  51474. /**
  51475. * the mesh that defines the minimum value mesh position.
  51476. */
  51477. minMesh?: AbstractMesh;
  51478. /**
  51479. * The mesh that will be changed when axis value changes
  51480. */
  51481. valueMesh?: AbstractMesh;
  51482. }
  51483. /**
  51484. * The elements needed for change-detection of the gamepad objects in motion controllers
  51485. */
  51486. export interface IMinimalMotionControllerObject {
  51487. /**
  51488. * Available axes of this controller
  51489. */
  51490. axes: number[];
  51491. /**
  51492. * An array of available buttons
  51493. */
  51494. buttons: Array<{
  51495. /**
  51496. * Value of the button/trigger
  51497. */
  51498. value: number;
  51499. /**
  51500. * If the button/trigger is currently touched
  51501. */
  51502. touched: boolean;
  51503. /**
  51504. * If the button/trigger is currently pressed
  51505. */
  51506. pressed: boolean;
  51507. }>;
  51508. /**
  51509. * EXPERIMENTAL haptic support.
  51510. */
  51511. hapticActuators?: Array<{
  51512. pulse: (value: number, duration: number) => Promise<boolean>;
  51513. }>;
  51514. }
  51515. /**
  51516. * An Abstract Motion controller
  51517. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51518. * Each component has an observable to check for changes in value and state
  51519. */
  51520. export abstract class WebXRAbstractMotionController implements IDisposable {
  51521. protected scene: Scene;
  51522. protected layout: IMotionControllerLayout;
  51523. /**
  51524. * The gamepad object correlating to this controller
  51525. */
  51526. gamepadObject: IMinimalMotionControllerObject;
  51527. /**
  51528. * handedness (left/right/none) of this controller
  51529. */
  51530. handedness: MotionControllerHandedness;
  51531. private _initComponent;
  51532. private _modelReady;
  51533. /**
  51534. * A map of components (WebXRControllerComponent) in this motion controller
  51535. * Components have a ComponentType and can also have both button and axis definitions
  51536. */
  51537. readonly components: {
  51538. [id: string]: WebXRControllerComponent;
  51539. };
  51540. /**
  51541. * Disable the model's animation. Can be set at any time.
  51542. */
  51543. disableAnimation: boolean;
  51544. /**
  51545. * Observers registered here will be triggered when the model of this controller is done loading
  51546. */
  51547. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51548. /**
  51549. * The profile id of this motion controller
  51550. */
  51551. abstract profileId: string;
  51552. /**
  51553. * The root mesh of the model. It is null if the model was not yet initialized
  51554. */
  51555. rootMesh: Nullable<AbstractMesh>;
  51556. /**
  51557. * constructs a new abstract motion controller
  51558. * @param scene the scene to which the model of the controller will be added
  51559. * @param layout The profile layout to load
  51560. * @param gamepadObject The gamepad object correlating to this controller
  51561. * @param handedness handedness (left/right/none) of this controller
  51562. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51563. */
  51564. constructor(scene: Scene, layout: IMotionControllerLayout,
  51565. /**
  51566. * The gamepad object correlating to this controller
  51567. */
  51568. gamepadObject: IMinimalMotionControllerObject,
  51569. /**
  51570. * handedness (left/right/none) of this controller
  51571. */
  51572. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51573. /**
  51574. * Dispose this controller, the model mesh and all its components
  51575. */
  51576. dispose(): void;
  51577. /**
  51578. * Returns all components of specific type
  51579. * @param type the type to search for
  51580. * @return an array of components with this type
  51581. */
  51582. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51583. /**
  51584. * get a component based an its component id as defined in layout.components
  51585. * @param id the id of the component
  51586. * @returns the component correlates to the id or undefined if not found
  51587. */
  51588. getComponent(id: string): WebXRControllerComponent;
  51589. /**
  51590. * Get the list of components available in this motion controller
  51591. * @returns an array of strings correlating to available components
  51592. */
  51593. getComponentIds(): string[];
  51594. /**
  51595. * Get the first component of specific type
  51596. * @param type type of component to find
  51597. * @return a controller component or null if not found
  51598. */
  51599. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51600. /**
  51601. * Get the main (Select) component of this controller as defined in the layout
  51602. * @returns the main component of this controller
  51603. */
  51604. getMainComponent(): WebXRControllerComponent;
  51605. /**
  51606. * Loads the model correlating to this controller
  51607. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51608. * @returns A promise fulfilled with the result of the model loading
  51609. */
  51610. loadModel(): Promise<boolean>;
  51611. /**
  51612. * Update this model using the current XRFrame
  51613. * @param xrFrame the current xr frame to use and update the model
  51614. */
  51615. updateFromXRFrame(xrFrame: XRFrame): void;
  51616. /**
  51617. * Backwards compatibility due to a deeply-integrated typo
  51618. */
  51619. get handness(): XREye;
  51620. /**
  51621. * Pulse (vibrate) this controller
  51622. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51623. * Consecutive calls to this function will cancel the last pulse call
  51624. *
  51625. * @param value the strength of the pulse in 0.0...1.0 range
  51626. * @param duration Duration of the pulse in milliseconds
  51627. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51628. * @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
  51629. */
  51630. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51631. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51632. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51633. /**
  51634. * Moves the axis on the controller mesh based on its current state
  51635. * @param axis the index of the axis
  51636. * @param axisValue the value of the axis which determines the meshes new position
  51637. * @hidden
  51638. */
  51639. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  51640. /**
  51641. * Update the model itself with the current frame data
  51642. * @param xrFrame the frame to use for updating the model mesh
  51643. */
  51644. protected updateModel(xrFrame: XRFrame): void;
  51645. /**
  51646. * Get the filename and path for this controller's model
  51647. * @returns a map of filename and path
  51648. */
  51649. protected abstract _getFilenameAndPath(): {
  51650. filename: string;
  51651. path: string;
  51652. };
  51653. /**
  51654. * This function is called before the mesh is loaded. It checks for loading constraints.
  51655. * For example, this function can check if the GLB loader is available
  51656. * If this function returns false, the generic controller will be loaded instead
  51657. * @returns Is the client ready to load the mesh
  51658. */
  51659. protected abstract _getModelLoadingConstraints(): boolean;
  51660. /**
  51661. * This function will be called after the model was successfully loaded and can be used
  51662. * for mesh transformations before it is available for the user
  51663. * @param meshes the loaded meshes
  51664. */
  51665. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  51666. /**
  51667. * Set the root mesh for this controller. Important for the WebXR controller class
  51668. * @param meshes the loaded meshes
  51669. */
  51670. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  51671. /**
  51672. * A function executed each frame that updates the mesh (if needed)
  51673. * @param xrFrame the current xrFrame
  51674. */
  51675. protected abstract _updateModel(xrFrame: XRFrame): void;
  51676. private _getGenericFilenameAndPath;
  51677. private _getGenericParentMesh;
  51678. }
  51679. }
  51680. declare module BABYLON {
  51681. /**
  51682. * A generic trigger-only motion controller for WebXR
  51683. */
  51684. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  51685. /**
  51686. * Static version of the profile id of this controller
  51687. */
  51688. static ProfileId: string;
  51689. profileId: string;
  51690. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  51691. protected _getFilenameAndPath(): {
  51692. filename: string;
  51693. path: string;
  51694. };
  51695. protected _getModelLoadingConstraints(): boolean;
  51696. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  51697. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51698. protected _updateModel(): void;
  51699. }
  51700. }
  51701. declare module BABYLON {
  51702. /**
  51703. * Class containing static functions to help procedurally build meshes
  51704. */
  51705. export class SphereBuilder {
  51706. /**
  51707. * Creates a sphere mesh
  51708. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51709. * * 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`)
  51710. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51711. * * 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
  51712. * * 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)
  51713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51714. * * 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
  51715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51716. * @param name defines the name of the mesh
  51717. * @param options defines the options used to create the mesh
  51718. * @param scene defines the hosting scene
  51719. * @returns the sphere mesh
  51720. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51721. */
  51722. static CreateSphere(name: string, options: {
  51723. segments?: number;
  51724. diameter?: number;
  51725. diameterX?: number;
  51726. diameterY?: number;
  51727. diameterZ?: number;
  51728. arc?: number;
  51729. slice?: number;
  51730. sideOrientation?: number;
  51731. frontUVs?: Vector4;
  51732. backUVs?: Vector4;
  51733. updatable?: boolean;
  51734. }, scene?: Nullable<Scene>): Mesh;
  51735. }
  51736. }
  51737. declare module BABYLON {
  51738. /**
  51739. * A profiled motion controller has its profile loaded from an online repository.
  51740. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  51741. */
  51742. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  51743. private _repositoryUrl;
  51744. private _buttonMeshMapping;
  51745. private _touchDots;
  51746. /**
  51747. * The profile ID of this controller. Will be populated when the controller initializes.
  51748. */
  51749. profileId: string;
  51750. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  51751. dispose(): void;
  51752. protected _getFilenameAndPath(): {
  51753. filename: string;
  51754. path: string;
  51755. };
  51756. protected _getModelLoadingConstraints(): boolean;
  51757. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  51758. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51759. protected _updateModel(_xrFrame: XRFrame): void;
  51760. }
  51761. }
  51762. declare module BABYLON {
  51763. /**
  51764. * A construction function type to create a new controller based on an xrInput object
  51765. */
  51766. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  51767. /**
  51768. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  51769. *
  51770. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  51771. * it should be replaced with auto-loaded controllers.
  51772. *
  51773. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  51774. */
  51775. export class WebXRMotionControllerManager {
  51776. private static _AvailableControllers;
  51777. private static _Fallbacks;
  51778. private static _ProfileLoadingPromises;
  51779. private static _ProfilesList;
  51780. /**
  51781. * The base URL of the online controller repository. Can be changed at any time.
  51782. */
  51783. static BaseRepositoryUrl: string;
  51784. /**
  51785. * Which repository gets priority - local or online
  51786. */
  51787. static PrioritizeOnlineRepository: boolean;
  51788. /**
  51789. * Use the online repository, or use only locally-defined controllers
  51790. */
  51791. static UseOnlineRepository: boolean;
  51792. /**
  51793. * Clear the cache used for profile loading and reload when requested again
  51794. */
  51795. static ClearProfilesCache(): void;
  51796. /**
  51797. * Register the default fallbacks.
  51798. * This function is called automatically when this file is imported.
  51799. */
  51800. static DefaultFallbacks(): void;
  51801. /**
  51802. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  51803. * @param profileId the profile to which a fallback needs to be found
  51804. * @return an array with corresponding fallback profiles
  51805. */
  51806. static FindFallbackWithProfileId(profileId: string): string[];
  51807. /**
  51808. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  51809. * The order of search:
  51810. *
  51811. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  51812. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  51813. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  51814. * 4) return the generic trigger controller if none were found
  51815. *
  51816. * @param xrInput the xrInput to which a new controller is initialized
  51817. * @param scene the scene to which the model will be added
  51818. * @param forceProfile force a certain profile for this controller
  51819. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  51820. */
  51821. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  51822. /**
  51823. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  51824. *
  51825. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  51826. *
  51827. * @param type the profile type to register
  51828. * @param constructFunction the function to be called when loading this profile
  51829. */
  51830. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  51831. /**
  51832. * Register a fallback to a specific profile.
  51833. * @param profileId the profileId that will receive the fallbacks
  51834. * @param fallbacks A list of fallback profiles
  51835. */
  51836. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  51837. /**
  51838. * Will update the list of profiles available in the repository
  51839. * @return a promise that resolves to a map of profiles available online
  51840. */
  51841. static UpdateProfilesList(): Promise<{
  51842. [profile: string]: string;
  51843. }>;
  51844. private static _LoadProfileFromRepository;
  51845. private static _LoadProfilesFromAvailableControllers;
  51846. }
  51847. }
  51848. declare module BABYLON {
  51849. /**
  51850. * Configuration options for the WebXR controller creation
  51851. */
  51852. export interface IWebXRControllerOptions {
  51853. /**
  51854. * Should the controller mesh be animated when a user interacts with it
  51855. * The pressed buttons / thumbstick and touchpad animations will be disabled
  51856. */
  51857. disableMotionControllerAnimation?: boolean;
  51858. /**
  51859. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  51860. */
  51861. doNotLoadControllerMesh?: boolean;
  51862. /**
  51863. * Force a specific controller type for this controller.
  51864. * This can be used when creating your own profile or when testing different controllers
  51865. */
  51866. forceControllerProfile?: string;
  51867. /**
  51868. * Defines a rendering group ID for meshes that will be loaded.
  51869. * This is for the default controllers only.
  51870. */
  51871. renderingGroupId?: number;
  51872. }
  51873. /**
  51874. * Represents an XR controller
  51875. */
  51876. export class WebXRInputSource {
  51877. private _scene;
  51878. /** The underlying input source for the controller */
  51879. inputSource: XRInputSource;
  51880. private _options;
  51881. private _tmpVector;
  51882. private _uniqueId;
  51883. private _disposed;
  51884. /**
  51885. * 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
  51886. */
  51887. grip?: AbstractMesh;
  51888. /**
  51889. * If available, this is the gamepad object related to this controller.
  51890. * Using this object it is possible to get click events and trackpad changes of the
  51891. * webxr controller that is currently being used.
  51892. */
  51893. motionController?: WebXRAbstractMotionController;
  51894. /**
  51895. * Event that fires when the controller is removed/disposed.
  51896. * The object provided as event data is this controller, after associated assets were disposed.
  51897. * uniqueId is still available.
  51898. */
  51899. onDisposeObservable: Observable<WebXRInputSource>;
  51900. /**
  51901. * Will be triggered when the mesh associated with the motion controller is done loading.
  51902. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  51903. * A shortened version of controller -> motion controller -> on mesh loaded.
  51904. */
  51905. onMeshLoadedObservable: Observable<AbstractMesh>;
  51906. /**
  51907. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  51908. */
  51909. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  51910. /**
  51911. * Pointer which can be used to select objects or attach a visible laser to
  51912. */
  51913. pointer: AbstractMesh;
  51914. /**
  51915. * Creates the input source object
  51916. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  51917. * @param _scene the scene which the controller should be associated to
  51918. * @param inputSource the underlying input source for the controller
  51919. * @param _options options for this controller creation
  51920. */
  51921. constructor(_scene: Scene,
  51922. /** The underlying input source for the controller */
  51923. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  51924. /**
  51925. * Get this controllers unique id
  51926. */
  51927. get uniqueId(): string;
  51928. /**
  51929. * Disposes of the object
  51930. */
  51931. dispose(): void;
  51932. /**
  51933. * Gets a world space ray coming from the pointer or grip
  51934. * @param result the resulting ray
  51935. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  51936. */
  51937. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  51938. /**
  51939. * Updates the controller pose based on the given XRFrame
  51940. * @param xrFrame xr frame to update the pose with
  51941. * @param referenceSpace reference space to use
  51942. */
  51943. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  51944. }
  51945. }
  51946. declare module BABYLON {
  51947. /**
  51948. * The schema for initialization options of the XR Input class
  51949. */
  51950. export interface IWebXRInputOptions {
  51951. /**
  51952. * If set to true no model will be automatically loaded
  51953. */
  51954. doNotLoadControllerMeshes?: boolean;
  51955. /**
  51956. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  51957. * If not found, the xr input profile data will be used.
  51958. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  51959. */
  51960. forceInputProfile?: string;
  51961. /**
  51962. * Do not send a request to the controller repository to load the profile.
  51963. *
  51964. * Instead, use the controllers available in babylon itself.
  51965. */
  51966. disableOnlineControllerRepository?: boolean;
  51967. /**
  51968. * A custom URL for the controllers repository
  51969. */
  51970. customControllersRepositoryURL?: string;
  51971. /**
  51972. * Should the controller model's components not move according to the user input
  51973. */
  51974. disableControllerAnimation?: boolean;
  51975. /**
  51976. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  51977. */
  51978. controllerOptions?: IWebXRControllerOptions;
  51979. }
  51980. /**
  51981. * XR input used to track XR inputs such as controllers/rays
  51982. */
  51983. export class WebXRInput implements IDisposable {
  51984. /**
  51985. * the xr session manager for this session
  51986. */
  51987. xrSessionManager: WebXRSessionManager;
  51988. /**
  51989. * the WebXR camera for this session. Mainly used for teleportation
  51990. */
  51991. xrCamera: WebXRCamera;
  51992. private readonly options;
  51993. /**
  51994. * XR controllers being tracked
  51995. */
  51996. controllers: Array<WebXRInputSource>;
  51997. private _frameObserver;
  51998. private _sessionEndedObserver;
  51999. private _sessionInitObserver;
  52000. /**
  52001. * Event when a controller has been connected/added
  52002. */
  52003. onControllerAddedObservable: Observable<WebXRInputSource>;
  52004. /**
  52005. * Event when a controller has been removed/disconnected
  52006. */
  52007. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52008. /**
  52009. * Initializes the WebXRInput
  52010. * @param xrSessionManager the xr session manager for this session
  52011. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52012. * @param options = initialization options for this xr input
  52013. */
  52014. constructor(
  52015. /**
  52016. * the xr session manager for this session
  52017. */
  52018. xrSessionManager: WebXRSessionManager,
  52019. /**
  52020. * the WebXR camera for this session. Mainly used for teleportation
  52021. */
  52022. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  52023. private _onInputSourcesChange;
  52024. private _addAndRemoveControllers;
  52025. /**
  52026. * Disposes of the object
  52027. */
  52028. dispose(): void;
  52029. }
  52030. }
  52031. declare module BABYLON {
  52032. /**
  52033. * This is the base class for all WebXR features.
  52034. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52035. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52036. */
  52037. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52038. protected _xrSessionManager: WebXRSessionManager;
  52039. private _attached;
  52040. private _removeOnDetach;
  52041. /**
  52042. * Is this feature disposed?
  52043. */
  52044. isDisposed: boolean;
  52045. /**
  52046. * Should auto-attach be disabled?
  52047. */
  52048. disableAutoAttach: boolean;
  52049. /**
  52050. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52051. */
  52052. xrNativeFeatureName: string;
  52053. /**
  52054. * Construct a new (abstract) WebXR feature
  52055. * @param _xrSessionManager the xr session manager for this feature
  52056. */
  52057. constructor(_xrSessionManager: WebXRSessionManager);
  52058. /**
  52059. * Is this feature attached
  52060. */
  52061. get attached(): boolean;
  52062. /**
  52063. * attach this feature
  52064. *
  52065. * @param force should attachment be forced (even when already attached)
  52066. * @returns true if successful, false is failed or already attached
  52067. */
  52068. attach(force?: boolean): boolean;
  52069. /**
  52070. * detach this feature.
  52071. *
  52072. * @returns true if successful, false if failed or already detached
  52073. */
  52074. detach(): boolean;
  52075. /**
  52076. * Dispose this feature and all of the resources attached
  52077. */
  52078. dispose(): void;
  52079. /**
  52080. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52081. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52082. *
  52083. * @returns whether or not the feature is compatible in this environment
  52084. */
  52085. isCompatible(): boolean;
  52086. /**
  52087. * This is used to register callbacks that will automatically be removed when detach is called.
  52088. * @param observable the observable to which the observer will be attached
  52089. * @param callback the callback to register
  52090. */
  52091. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52092. /**
  52093. * Code in this function will be executed on each xrFrame received from the browser.
  52094. * This function will not execute after the feature is detached.
  52095. * @param _xrFrame the current frame
  52096. */
  52097. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52098. }
  52099. }
  52100. declare module BABYLON {
  52101. /**
  52102. * Renders a layer on top of an existing scene
  52103. */
  52104. export class UtilityLayerRenderer implements IDisposable {
  52105. /** the original scene that will be rendered on top of */
  52106. originalScene: Scene;
  52107. private _pointerCaptures;
  52108. private _lastPointerEvents;
  52109. private static _DefaultUtilityLayer;
  52110. private static _DefaultKeepDepthUtilityLayer;
  52111. private _sharedGizmoLight;
  52112. private _renderCamera;
  52113. /**
  52114. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52115. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52116. * @returns the camera that is used when rendering the utility layer
  52117. */
  52118. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52119. /**
  52120. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52121. * @param cam the camera that should be used when rendering the utility layer
  52122. */
  52123. setRenderCamera(cam: Nullable<Camera>): void;
  52124. /**
  52125. * @hidden
  52126. * Light which used by gizmos to get light shading
  52127. */
  52128. _getSharedGizmoLight(): HemisphericLight;
  52129. /**
  52130. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52131. */
  52132. pickUtilitySceneFirst: boolean;
  52133. /**
  52134. * 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)
  52135. */
  52136. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52137. /**
  52138. * 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)
  52139. */
  52140. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52141. /**
  52142. * The scene that is rendered on top of the original scene
  52143. */
  52144. utilityLayerScene: Scene;
  52145. /**
  52146. * If the utility layer should automatically be rendered on top of existing scene
  52147. */
  52148. shouldRender: boolean;
  52149. /**
  52150. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52151. */
  52152. onlyCheckPointerDownEvents: boolean;
  52153. /**
  52154. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52155. */
  52156. processAllEvents: boolean;
  52157. /**
  52158. * Observable raised when the pointer move from the utility layer scene to the main scene
  52159. */
  52160. onPointerOutObservable: Observable<number>;
  52161. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52162. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52163. private _afterRenderObserver;
  52164. private _sceneDisposeObserver;
  52165. private _originalPointerObserver;
  52166. /**
  52167. * Instantiates a UtilityLayerRenderer
  52168. * @param originalScene the original scene that will be rendered on top of
  52169. * @param handleEvents boolean indicating if the utility layer should handle events
  52170. */
  52171. constructor(
  52172. /** the original scene that will be rendered on top of */
  52173. originalScene: Scene, handleEvents?: boolean);
  52174. private _notifyObservers;
  52175. /**
  52176. * Renders the utility layers scene on top of the original scene
  52177. */
  52178. render(): void;
  52179. /**
  52180. * Disposes of the renderer
  52181. */
  52182. dispose(): void;
  52183. private _updateCamera;
  52184. }
  52185. }
  52186. declare module BABYLON {
  52187. /**
  52188. * Options interface for the pointer selection module
  52189. */
  52190. export interface IWebXRControllerPointerSelectionOptions {
  52191. /**
  52192. * if provided, this scene will be used to render meshes.
  52193. */
  52194. customUtilityLayerScene?: Scene;
  52195. /**
  52196. * 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)
  52197. * If not disabled, the last picked point will be used to execute a pointer up event
  52198. * If disabled, pointer up event will be triggered right after the pointer down event.
  52199. * Used in screen and gaze target ray mode only
  52200. */
  52201. disablePointerUpOnTouchOut: boolean;
  52202. /**
  52203. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52204. */
  52205. forceGazeMode: boolean;
  52206. /**
  52207. * 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
  52208. * to start a new countdown to the pointer down event.
  52209. * Defaults to 1.
  52210. */
  52211. gazeModePointerMovedFactor?: number;
  52212. /**
  52213. * Different button type to use instead of the main component
  52214. */
  52215. overrideButtonId?: string;
  52216. /**
  52217. * use this rendering group id for the meshes (optional)
  52218. */
  52219. renderingGroupId?: number;
  52220. /**
  52221. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52222. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52223. * 3000 means 3 seconds between pointing at something and selecting it
  52224. */
  52225. timeToSelect?: number;
  52226. /**
  52227. * Should meshes created here be added to a utility layer or the main scene
  52228. */
  52229. useUtilityLayer?: boolean;
  52230. /**
  52231. * Optional WebXR camera to be used for gaze selection
  52232. */
  52233. gazeCamera?: WebXRCamera;
  52234. /**
  52235. * the xr input to use with this pointer selection
  52236. */
  52237. xrInput: WebXRInput;
  52238. /**
  52239. * Should the scene pointerX and pointerY update be disabled
  52240. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52241. * Disable in VR, if not needed.
  52242. * The first rig camera (left eye) will be used to calculate the projection
  52243. */
  52244. disableScenePointerVectorUpdate: boolean;
  52245. /**
  52246. * Enable pointer selection on all controllers instead of switching between them
  52247. */
  52248. enablePointerSelectionOnAllControllers?: boolean;
  52249. /**
  52250. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52251. * If switch is enabled, it will still allow the user to switch between the different controllers
  52252. */
  52253. preferredHandedness?: XRHandedness;
  52254. /**
  52255. * Disable switching the pointer selection from one controller to the other.
  52256. * 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
  52257. */
  52258. disableSwitchOnClick?: boolean;
  52259. /**
  52260. * The maximum distance of the pointer selection feature. Defaults to 100.
  52261. */
  52262. maxPointerDistance?: number;
  52263. }
  52264. /**
  52265. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52266. */
  52267. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52268. private readonly _options;
  52269. private static _idCounter;
  52270. private _attachController;
  52271. private _controllers;
  52272. private _scene;
  52273. private _tmpVectorForPickCompare;
  52274. private _attachedController;
  52275. /**
  52276. * The module's name
  52277. */
  52278. static readonly Name: string;
  52279. /**
  52280. * The (Babylon) version of this module.
  52281. * This is an integer representing the implementation version.
  52282. * This number does not correspond to the WebXR specs version
  52283. */
  52284. static readonly Version: number;
  52285. /**
  52286. * Disable lighting on the laser pointer (so it will always be visible)
  52287. */
  52288. disablePointerLighting: boolean;
  52289. /**
  52290. * Disable lighting on the selection mesh (so it will always be visible)
  52291. */
  52292. disableSelectionMeshLighting: boolean;
  52293. /**
  52294. * Should the laser pointer be displayed
  52295. */
  52296. displayLaserPointer: boolean;
  52297. /**
  52298. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52299. */
  52300. displaySelectionMesh: boolean;
  52301. /**
  52302. * This color will be set to the laser pointer when selection is triggered
  52303. */
  52304. laserPointerPickedColor: Color3;
  52305. /**
  52306. * Default color of the laser pointer
  52307. */
  52308. laserPointerDefaultColor: Color3;
  52309. /**
  52310. * default color of the selection ring
  52311. */
  52312. selectionMeshDefaultColor: Color3;
  52313. /**
  52314. * This color will be applied to the selection ring when selection is triggered
  52315. */
  52316. selectionMeshPickedColor: Color3;
  52317. /**
  52318. * Optional filter to be used for ray selection. This predicate shares behavior with
  52319. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52320. */
  52321. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52322. /**
  52323. * constructs a new background remover module
  52324. * @param _xrSessionManager the session manager for this module
  52325. * @param _options read-only options to be used in this module
  52326. */
  52327. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52328. /**
  52329. * attach this feature
  52330. * Will usually be called by the features manager
  52331. *
  52332. * @returns true if successful.
  52333. */
  52334. attach(): boolean;
  52335. /**
  52336. * detach this feature.
  52337. * Will usually be called by the features manager
  52338. *
  52339. * @returns true if successful.
  52340. */
  52341. detach(): boolean;
  52342. /**
  52343. * Will get the mesh under a specific pointer.
  52344. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52345. * @param controllerId the controllerId to check
  52346. * @returns The mesh under pointer or null if no mesh is under the pointer
  52347. */
  52348. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52349. /**
  52350. * Get the xr controller that correlates to the pointer id in the pointer event
  52351. *
  52352. * @param id the pointer id to search for
  52353. * @returns the controller that correlates to this id or null if not found
  52354. */
  52355. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52356. private _identityMatrix;
  52357. private _screenCoordinatesRef;
  52358. private _viewportRef;
  52359. protected _onXRFrame(_xrFrame: XRFrame): void;
  52360. private _attachGazeMode;
  52361. private _attachScreenRayMode;
  52362. private _attachTrackedPointerRayMode;
  52363. private _convertNormalToDirectionOfRay;
  52364. private _detachController;
  52365. private _generateNewMeshPair;
  52366. private _pickingMoved;
  52367. private _updatePointerDistance;
  52368. /** @hidden */
  52369. get lasterPointerDefaultColor(): Color3;
  52370. }
  52371. }
  52372. declare module BABYLON {
  52373. /**
  52374. * Button which can be used to enter a different mode of XR
  52375. */
  52376. export class WebXREnterExitUIButton {
  52377. /** button element */
  52378. element: HTMLElement;
  52379. /** XR initialization options for the button */
  52380. sessionMode: XRSessionMode;
  52381. /** Reference space type */
  52382. referenceSpaceType: XRReferenceSpaceType;
  52383. /**
  52384. * Creates a WebXREnterExitUIButton
  52385. * @param element button element
  52386. * @param sessionMode XR initialization session mode
  52387. * @param referenceSpaceType the type of reference space to be used
  52388. */
  52389. constructor(
  52390. /** button element */
  52391. element: HTMLElement,
  52392. /** XR initialization options for the button */
  52393. sessionMode: XRSessionMode,
  52394. /** Reference space type */
  52395. referenceSpaceType: XRReferenceSpaceType);
  52396. /**
  52397. * Extendable function which can be used to update the button's visuals when the state changes
  52398. * @param activeButton the current active button in the UI
  52399. */
  52400. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52401. }
  52402. /**
  52403. * Options to create the webXR UI
  52404. */
  52405. export class WebXREnterExitUIOptions {
  52406. /**
  52407. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52408. */
  52409. customButtons?: Array<WebXREnterExitUIButton>;
  52410. /**
  52411. * A reference space type to use when creating the default button.
  52412. * Default is local-floor
  52413. */
  52414. referenceSpaceType?: XRReferenceSpaceType;
  52415. /**
  52416. * Context to enter xr with
  52417. */
  52418. renderTarget?: Nullable<WebXRRenderTarget>;
  52419. /**
  52420. * A session mode to use when creating the default button.
  52421. * Default is immersive-vr
  52422. */
  52423. sessionMode?: XRSessionMode;
  52424. /**
  52425. * A list of optional features to init the session with
  52426. */
  52427. optionalFeatures?: string[];
  52428. /**
  52429. * A list of optional features to init the session with
  52430. */
  52431. requiredFeatures?: string[];
  52432. /**
  52433. * If defined, this function will be executed if the UI encounters an error when entering XR
  52434. */
  52435. onError?: (error: any) => void;
  52436. }
  52437. /**
  52438. * UI to allow the user to enter/exit XR mode
  52439. */
  52440. export class WebXREnterExitUI implements IDisposable {
  52441. private scene;
  52442. /** version of the options passed to this UI */
  52443. options: WebXREnterExitUIOptions;
  52444. private _activeButton;
  52445. private _buttons;
  52446. /**
  52447. * The HTML Div Element to which buttons are added.
  52448. */
  52449. readonly overlay: HTMLDivElement;
  52450. /**
  52451. * Fired every time the active button is changed.
  52452. *
  52453. * When xr is entered via a button that launches xr that button will be the callback parameter
  52454. *
  52455. * When exiting xr the callback parameter will be null)
  52456. */
  52457. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52458. /**
  52459. *
  52460. * @param scene babylon scene object to use
  52461. * @param options (read-only) version of the options passed to this UI
  52462. */
  52463. private constructor();
  52464. /**
  52465. * Creates UI to allow the user to enter/exit XR mode
  52466. * @param scene the scene to add the ui to
  52467. * @param helper the xr experience helper to enter/exit xr with
  52468. * @param options options to configure the UI
  52469. * @returns the created ui
  52470. */
  52471. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52472. /**
  52473. * Disposes of the XR UI component
  52474. */
  52475. dispose(): void;
  52476. private _updateButtons;
  52477. }
  52478. }
  52479. declare module BABYLON {
  52480. /**
  52481. * Class containing static functions to help procedurally build meshes
  52482. */
  52483. export class LinesBuilder {
  52484. /**
  52485. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52486. * * 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
  52487. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52488. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52489. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52490. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52491. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52492. * * 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
  52493. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52496. * @param name defines the name of the new line system
  52497. * @param options defines the options used to create the line system
  52498. * @param scene defines the hosting scene
  52499. * @returns a new line system mesh
  52500. */
  52501. static CreateLineSystem(name: string, options: {
  52502. lines: Vector3[][];
  52503. updatable?: boolean;
  52504. instance?: Nullable<LinesMesh>;
  52505. colors?: Nullable<Color4[][]>;
  52506. useVertexAlpha?: boolean;
  52507. }, scene: Nullable<Scene>): LinesMesh;
  52508. /**
  52509. * Creates a line mesh
  52510. * 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
  52511. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52512. * * The parameter `points` is an array successive Vector3
  52513. * * 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
  52514. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52515. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52516. * * When updating an instance, remember that only point positions can change, not the number of points
  52517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52519. * @param name defines the name of the new line system
  52520. * @param options defines the options used to create the line system
  52521. * @param scene defines the hosting scene
  52522. * @returns a new line mesh
  52523. */
  52524. static CreateLines(name: string, options: {
  52525. points: Vector3[];
  52526. updatable?: boolean;
  52527. instance?: Nullable<LinesMesh>;
  52528. colors?: Color4[];
  52529. useVertexAlpha?: boolean;
  52530. }, scene?: Nullable<Scene>): LinesMesh;
  52531. /**
  52532. * Creates a dashed line mesh
  52533. * * 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
  52534. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52535. * * The parameter `points` is an array successive Vector3
  52536. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52537. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52538. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52539. * * 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
  52540. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52541. * * When updating an instance, remember that only point positions can change, not the number of points
  52542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52543. * @param name defines the name of the mesh
  52544. * @param options defines the options used to create the mesh
  52545. * @param scene defines the hosting scene
  52546. * @returns the dashed line mesh
  52547. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52548. */
  52549. static CreateDashedLines(name: string, options: {
  52550. points: Vector3[];
  52551. dashSize?: number;
  52552. gapSize?: number;
  52553. dashNb?: number;
  52554. updatable?: boolean;
  52555. instance?: LinesMesh;
  52556. useVertexAlpha?: boolean;
  52557. }, scene?: Nullable<Scene>): LinesMesh;
  52558. }
  52559. }
  52560. declare module BABYLON {
  52561. /**
  52562. * Construction options for a timer
  52563. */
  52564. export interface ITimerOptions<T> {
  52565. /**
  52566. * Time-to-end
  52567. */
  52568. timeout: number;
  52569. /**
  52570. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52571. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52572. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52573. */
  52574. contextObservable: Observable<T>;
  52575. /**
  52576. * Optional parameters when adding an observer to the observable
  52577. */
  52578. observableParameters?: {
  52579. mask?: number;
  52580. insertFirst?: boolean;
  52581. scope?: any;
  52582. };
  52583. /**
  52584. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52585. */
  52586. breakCondition?: (data?: ITimerData<T>) => boolean;
  52587. /**
  52588. * Will be triggered when the time condition has met
  52589. */
  52590. onEnded?: (data: ITimerData<any>) => void;
  52591. /**
  52592. * Will be triggered when the break condition has met (prematurely ended)
  52593. */
  52594. onAborted?: (data: ITimerData<any>) => void;
  52595. /**
  52596. * Optional function to execute on each tick (or count)
  52597. */
  52598. onTick?: (data: ITimerData<any>) => void;
  52599. }
  52600. /**
  52601. * An interface defining the data sent by the timer
  52602. */
  52603. export interface ITimerData<T> {
  52604. /**
  52605. * When did it start
  52606. */
  52607. startTime: number;
  52608. /**
  52609. * Time now
  52610. */
  52611. currentTime: number;
  52612. /**
  52613. * Time passed since started
  52614. */
  52615. deltaTime: number;
  52616. /**
  52617. * How much is completed, in [0.0...1.0].
  52618. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52619. */
  52620. completeRate: number;
  52621. /**
  52622. * What the registered observable sent in the last count
  52623. */
  52624. payload: T;
  52625. }
  52626. /**
  52627. * The current state of the timer
  52628. */
  52629. export enum TimerState {
  52630. /**
  52631. * Timer initialized, not yet started
  52632. */
  52633. INIT = 0,
  52634. /**
  52635. * Timer started and counting
  52636. */
  52637. STARTED = 1,
  52638. /**
  52639. * Timer ended (whether aborted or time reached)
  52640. */
  52641. ENDED = 2
  52642. }
  52643. /**
  52644. * A simple version of the timer. Will take options and start the timer immediately after calling it
  52645. *
  52646. * @param options options with which to initialize this timer
  52647. */
  52648. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  52649. /**
  52650. * An advanced implementation of a timer class
  52651. */
  52652. export class AdvancedTimer<T = any> implements IDisposable {
  52653. /**
  52654. * Will notify each time the timer calculates the remaining time
  52655. */
  52656. onEachCountObservable: Observable<ITimerData<T>>;
  52657. /**
  52658. * Will trigger when the timer was aborted due to the break condition
  52659. */
  52660. onTimerAbortedObservable: Observable<ITimerData<T>>;
  52661. /**
  52662. * Will trigger when the timer ended successfully
  52663. */
  52664. onTimerEndedObservable: Observable<ITimerData<T>>;
  52665. /**
  52666. * Will trigger when the timer state has changed
  52667. */
  52668. onStateChangedObservable: Observable<TimerState>;
  52669. private _observer;
  52670. private _contextObservable;
  52671. private _observableParameters;
  52672. private _startTime;
  52673. private _timer;
  52674. private _state;
  52675. private _breakCondition;
  52676. private _timeToEnd;
  52677. private _breakOnNextTick;
  52678. /**
  52679. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  52680. * @param options construction options for this advanced timer
  52681. */
  52682. constructor(options: ITimerOptions<T>);
  52683. /**
  52684. * set a breaking condition for this timer. Default is to never break during count
  52685. * @param predicate the new break condition. Returns true to break, false otherwise
  52686. */
  52687. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  52688. /**
  52689. * Reset ALL associated observables in this advanced timer
  52690. */
  52691. clearObservables(): void;
  52692. /**
  52693. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  52694. *
  52695. * @param timeToEnd how much time to measure until timer ended
  52696. */
  52697. start(timeToEnd?: number): void;
  52698. /**
  52699. * Will force a stop on the next tick.
  52700. */
  52701. stop(): void;
  52702. /**
  52703. * Dispose this timer, clearing all resources
  52704. */
  52705. dispose(): void;
  52706. private _setState;
  52707. private _tick;
  52708. private _stop;
  52709. }
  52710. }
  52711. declare module BABYLON {
  52712. /**
  52713. * The options container for the teleportation module
  52714. */
  52715. export interface IWebXRTeleportationOptions {
  52716. /**
  52717. * if provided, this scene will be used to render meshes.
  52718. */
  52719. customUtilityLayerScene?: Scene;
  52720. /**
  52721. * Values to configure the default target mesh
  52722. */
  52723. defaultTargetMeshOptions?: {
  52724. /**
  52725. * Fill color of the teleportation area
  52726. */
  52727. teleportationFillColor?: string;
  52728. /**
  52729. * Border color for the teleportation area
  52730. */
  52731. teleportationBorderColor?: string;
  52732. /**
  52733. * Disable the mesh's animation sequence
  52734. */
  52735. disableAnimation?: boolean;
  52736. /**
  52737. * Disable lighting on the material or the ring and arrow
  52738. */
  52739. disableLighting?: boolean;
  52740. /**
  52741. * Override the default material of the torus and arrow
  52742. */
  52743. torusArrowMaterial?: Material;
  52744. };
  52745. /**
  52746. * A list of meshes to use as floor meshes.
  52747. * Meshes can be added and removed after initializing the feature using the
  52748. * addFloorMesh and removeFloorMesh functions
  52749. * If empty, rotation will still work
  52750. */
  52751. floorMeshes?: AbstractMesh[];
  52752. /**
  52753. * use this rendering group id for the meshes (optional)
  52754. */
  52755. renderingGroupId?: number;
  52756. /**
  52757. * Should teleportation move only to snap points
  52758. */
  52759. snapPointsOnly?: boolean;
  52760. /**
  52761. * An array of points to which the teleportation will snap to.
  52762. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  52763. */
  52764. snapPositions?: Vector3[];
  52765. /**
  52766. * How close should the teleportation ray be in order to snap to position.
  52767. * Default to 0.8 units (meters)
  52768. */
  52769. snapToPositionRadius?: number;
  52770. /**
  52771. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  52772. * If you want to support rotation, make sure your mesh has a direction indicator.
  52773. *
  52774. * When left untouched, the default mesh will be initialized.
  52775. */
  52776. teleportationTargetMesh?: AbstractMesh;
  52777. /**
  52778. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  52779. */
  52780. timeToTeleport?: number;
  52781. /**
  52782. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  52783. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  52784. */
  52785. useMainComponentOnly?: boolean;
  52786. /**
  52787. * Should meshes created here be added to a utility layer or the main scene
  52788. */
  52789. useUtilityLayer?: boolean;
  52790. /**
  52791. * Babylon XR Input class for controller
  52792. */
  52793. xrInput: WebXRInput;
  52794. /**
  52795. * Meshes that the teleportation ray cannot go through
  52796. */
  52797. pickBlockerMeshes?: AbstractMesh[];
  52798. }
  52799. /**
  52800. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  52801. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  52802. * the input of the attached controllers.
  52803. */
  52804. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  52805. private _options;
  52806. private _controllers;
  52807. private _currentTeleportationControllerId;
  52808. private _floorMeshes;
  52809. private _quadraticBezierCurve;
  52810. private _selectionFeature;
  52811. private _snapToPositions;
  52812. private _snappedToPoint;
  52813. private _teleportationRingMaterial?;
  52814. private _tmpRay;
  52815. private _tmpVector;
  52816. private _tmpQuaternion;
  52817. /**
  52818. * The module's name
  52819. */
  52820. static readonly Name: string;
  52821. /**
  52822. * The (Babylon) version of this module.
  52823. * This is an integer representing the implementation version.
  52824. * This number does not correspond to the webxr specs version
  52825. */
  52826. static readonly Version: number;
  52827. /**
  52828. * Is movement backwards enabled
  52829. */
  52830. backwardsMovementEnabled: boolean;
  52831. /**
  52832. * Distance to travel when moving backwards
  52833. */
  52834. backwardsTeleportationDistance: number;
  52835. /**
  52836. * The distance from the user to the inspection point in the direction of the controller
  52837. * A higher number will allow the user to move further
  52838. * defaults to 5 (meters, in xr units)
  52839. */
  52840. parabolicCheckRadius: number;
  52841. /**
  52842. * Should the module support parabolic ray on top of direct ray
  52843. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  52844. * Very helpful when moving between floors / different heights
  52845. */
  52846. parabolicRayEnabled: boolean;
  52847. /**
  52848. * How much rotation should be applied when rotating right and left
  52849. */
  52850. rotationAngle: number;
  52851. /**
  52852. * Is rotation enabled when moving forward?
  52853. * Disabling this feature will prevent the user from deciding the direction when teleporting
  52854. */
  52855. rotationEnabled: boolean;
  52856. /**
  52857. * constructs a new anchor system
  52858. * @param _xrSessionManager an instance of WebXRSessionManager
  52859. * @param _options configuration object for this feature
  52860. */
  52861. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  52862. /**
  52863. * Get the snapPointsOnly flag
  52864. */
  52865. get snapPointsOnly(): boolean;
  52866. /**
  52867. * Sets the snapPointsOnly flag
  52868. * @param snapToPoints should teleportation be exclusively to snap points
  52869. */
  52870. set snapPointsOnly(snapToPoints: boolean);
  52871. /**
  52872. * Add a new mesh to the floor meshes array
  52873. * @param mesh the mesh to use as floor mesh
  52874. */
  52875. addFloorMesh(mesh: AbstractMesh): void;
  52876. /**
  52877. * Add a new snap-to point to fix teleportation to this position
  52878. * @param newSnapPoint The new Snap-To point
  52879. */
  52880. addSnapPoint(newSnapPoint: Vector3): void;
  52881. attach(): boolean;
  52882. detach(): boolean;
  52883. dispose(): void;
  52884. /**
  52885. * Remove a mesh from the floor meshes array
  52886. * @param mesh the mesh to remove
  52887. */
  52888. removeFloorMesh(mesh: AbstractMesh): void;
  52889. /**
  52890. * Remove a mesh from the floor meshes array using its name
  52891. * @param name the mesh name to remove
  52892. */
  52893. removeFloorMeshByName(name: string): void;
  52894. /**
  52895. * 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
  52896. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  52897. * @returns was the point found and removed or not
  52898. */
  52899. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  52900. /**
  52901. * This function sets a selection feature that will be disabled when
  52902. * the forward ray is shown and will be reattached when hidden.
  52903. * This is used to remove the selection rays when moving.
  52904. * @param selectionFeature the feature to disable when forward movement is enabled
  52905. */
  52906. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  52907. protected _onXRFrame(_xrFrame: XRFrame): void;
  52908. private _attachController;
  52909. private _createDefaultTargetMesh;
  52910. private _detachController;
  52911. private _findClosestSnapPointWithRadius;
  52912. private _setTargetMeshPosition;
  52913. private _setTargetMeshVisibility;
  52914. private _showParabolicPath;
  52915. private _teleportForward;
  52916. }
  52917. }
  52918. declare module BABYLON {
  52919. /**
  52920. * Options for the default xr helper
  52921. */
  52922. export class WebXRDefaultExperienceOptions {
  52923. /**
  52924. * Enable or disable default UI to enter XR
  52925. */
  52926. disableDefaultUI?: boolean;
  52927. /**
  52928. * Should teleportation not initialize. defaults to false.
  52929. */
  52930. disableTeleportation?: boolean;
  52931. /**
  52932. * Floor meshes that will be used for teleport
  52933. */
  52934. floorMeshes?: Array<AbstractMesh>;
  52935. /**
  52936. * If set to true, the first frame will not be used to reset position
  52937. * The first frame is mainly used when copying transformation from the old camera
  52938. * Mainly used in AR
  52939. */
  52940. ignoreNativeCameraTransformation?: boolean;
  52941. /**
  52942. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  52943. */
  52944. inputOptions?: IWebXRInputOptions;
  52945. /**
  52946. * optional configuration for the output canvas
  52947. */
  52948. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  52949. /**
  52950. * optional UI options. This can be used among other to change session mode and reference space type
  52951. */
  52952. uiOptions?: WebXREnterExitUIOptions;
  52953. /**
  52954. * When loading teleportation and pointer select, use stable versions instead of latest.
  52955. */
  52956. useStablePlugins?: boolean;
  52957. /**
  52958. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  52959. */
  52960. renderingGroupId?: number;
  52961. /**
  52962. * A list of optional features to init the session with
  52963. * If set to true, all features we support will be added
  52964. */
  52965. optionalFeatures?: boolean | string[];
  52966. }
  52967. /**
  52968. * Default experience which provides a similar setup to the previous webVRExperience
  52969. */
  52970. export class WebXRDefaultExperience {
  52971. /**
  52972. * Base experience
  52973. */
  52974. baseExperience: WebXRExperienceHelper;
  52975. /**
  52976. * Enables ui for entering/exiting xr
  52977. */
  52978. enterExitUI: WebXREnterExitUI;
  52979. /**
  52980. * Input experience extension
  52981. */
  52982. input: WebXRInput;
  52983. /**
  52984. * Enables laser pointer and selection
  52985. */
  52986. pointerSelection: WebXRControllerPointerSelection;
  52987. /**
  52988. * Default target xr should render to
  52989. */
  52990. renderTarget: WebXRRenderTarget;
  52991. /**
  52992. * Enables teleportation
  52993. */
  52994. teleportation: WebXRMotionControllerTeleportation;
  52995. private constructor();
  52996. /**
  52997. * Creates the default xr experience
  52998. * @param scene scene
  52999. * @param options options for basic configuration
  53000. * @returns resulting WebXRDefaultExperience
  53001. */
  53002. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53003. /**
  53004. * DIsposes of the experience helper
  53005. */
  53006. dispose(): void;
  53007. }
  53008. }
  53009. declare module BABYLON {
  53010. /**
  53011. * Options to modify the vr teleportation behavior.
  53012. */
  53013. export interface VRTeleportationOptions {
  53014. /**
  53015. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53016. */
  53017. floorMeshName?: string;
  53018. /**
  53019. * A list of meshes to be used as the teleportation floor. (default: empty)
  53020. */
  53021. floorMeshes?: Mesh[];
  53022. /**
  53023. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53024. */
  53025. teleportationMode?: number;
  53026. /**
  53027. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53028. */
  53029. teleportationTime?: number;
  53030. /**
  53031. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53032. */
  53033. teleportationSpeed?: number;
  53034. /**
  53035. * The easing function used in the animation or null for Linear. (default CircleEase)
  53036. */
  53037. easingFunction?: EasingFunction;
  53038. }
  53039. /**
  53040. * Options to modify the vr experience helper's behavior.
  53041. */
  53042. export interface VRExperienceHelperOptions extends WebVROptions {
  53043. /**
  53044. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53045. */
  53046. createDeviceOrientationCamera?: boolean;
  53047. /**
  53048. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53049. */
  53050. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53051. /**
  53052. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53053. */
  53054. laserToggle?: boolean;
  53055. /**
  53056. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53057. */
  53058. floorMeshes?: Mesh[];
  53059. /**
  53060. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53061. */
  53062. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53063. /**
  53064. * Defines if WebXR should be used instead of WebVR (if available)
  53065. */
  53066. useXR?: boolean;
  53067. }
  53068. /**
  53069. * Event containing information after VR has been entered
  53070. */
  53071. export class OnAfterEnteringVRObservableEvent {
  53072. /**
  53073. * If entering vr was successful
  53074. */
  53075. success: boolean;
  53076. }
  53077. /**
  53078. * Helps to quickly add VR support to an existing scene.
  53079. * See https://doc.babylonjs.com/how_to/webvr_helper
  53080. */
  53081. export class VRExperienceHelper {
  53082. /** Options to modify the vr experience helper's behavior. */
  53083. webVROptions: VRExperienceHelperOptions;
  53084. private _scene;
  53085. private _position;
  53086. private _btnVR;
  53087. private _btnVRDisplayed;
  53088. private _webVRsupported;
  53089. private _webVRready;
  53090. private _webVRrequesting;
  53091. private _webVRpresenting;
  53092. private _hasEnteredVR;
  53093. private _fullscreenVRpresenting;
  53094. private _inputElement;
  53095. private _webVRCamera;
  53096. private _vrDeviceOrientationCamera;
  53097. private _deviceOrientationCamera;
  53098. private _existingCamera;
  53099. private _onKeyDown;
  53100. private _onVrDisplayPresentChange;
  53101. private _onVRDisplayChanged;
  53102. private _onVRRequestPresentStart;
  53103. private _onVRRequestPresentComplete;
  53104. /**
  53105. * 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)
  53106. */
  53107. enableGazeEvenWhenNoPointerLock: boolean;
  53108. /**
  53109. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53110. */
  53111. exitVROnDoubleTap: boolean;
  53112. /**
  53113. * Observable raised right before entering VR.
  53114. */
  53115. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53116. /**
  53117. * Observable raised when entering VR has completed.
  53118. */
  53119. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53120. /**
  53121. * Observable raised when exiting VR.
  53122. */
  53123. onExitingVRObservable: Observable<VRExperienceHelper>;
  53124. /**
  53125. * Observable raised when controller mesh is loaded.
  53126. */
  53127. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53128. /** Return this.onEnteringVRObservable
  53129. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53130. */
  53131. get onEnteringVR(): Observable<VRExperienceHelper>;
  53132. /** Return this.onExitingVRObservable
  53133. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53134. */
  53135. get onExitingVR(): Observable<VRExperienceHelper>;
  53136. /** Return this.onControllerMeshLoadedObservable
  53137. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53138. */
  53139. get onControllerMeshLoaded(): Observable<WebVRController>;
  53140. private _rayLength;
  53141. private _useCustomVRButton;
  53142. private _teleportationRequested;
  53143. private _teleportActive;
  53144. private _floorMeshName;
  53145. private _floorMeshesCollection;
  53146. private _teleportationMode;
  53147. private _teleportationTime;
  53148. private _teleportationSpeed;
  53149. private _teleportationEasing;
  53150. private _rotationAllowed;
  53151. private _teleportBackwardsVector;
  53152. private _teleportationTarget;
  53153. private _isDefaultTeleportationTarget;
  53154. private _postProcessMove;
  53155. private _teleportationFillColor;
  53156. private _teleportationBorderColor;
  53157. private _rotationAngle;
  53158. private _haloCenter;
  53159. private _cameraGazer;
  53160. private _padSensibilityUp;
  53161. private _padSensibilityDown;
  53162. private _leftController;
  53163. private _rightController;
  53164. private _gazeColor;
  53165. private _laserColor;
  53166. private _pickedLaserColor;
  53167. private _pickedGazeColor;
  53168. /**
  53169. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53170. */
  53171. onNewMeshSelected: Observable<AbstractMesh>;
  53172. /**
  53173. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53174. * This observable will provide the mesh and the controller used to select the mesh
  53175. */
  53176. onMeshSelectedWithController: Observable<{
  53177. mesh: AbstractMesh;
  53178. controller: WebVRController;
  53179. }>;
  53180. /**
  53181. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53182. */
  53183. onNewMeshPicked: Observable<PickingInfo>;
  53184. private _circleEase;
  53185. /**
  53186. * Observable raised before camera teleportation
  53187. */
  53188. onBeforeCameraTeleport: Observable<Vector3>;
  53189. /**
  53190. * Observable raised after camera teleportation
  53191. */
  53192. onAfterCameraTeleport: Observable<Vector3>;
  53193. /**
  53194. * Observable raised when current selected mesh gets unselected
  53195. */
  53196. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53197. private _raySelectionPredicate;
  53198. /**
  53199. * To be optionaly changed by user to define custom ray selection
  53200. */
  53201. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53202. /**
  53203. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53204. */
  53205. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53206. /**
  53207. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53208. */
  53209. teleportationEnabled: boolean;
  53210. private _defaultHeight;
  53211. private _teleportationInitialized;
  53212. private _interactionsEnabled;
  53213. private _interactionsRequested;
  53214. private _displayGaze;
  53215. private _displayLaserPointer;
  53216. /**
  53217. * The mesh used to display where the user is going to teleport.
  53218. */
  53219. get teleportationTarget(): Mesh;
  53220. /**
  53221. * Sets the mesh to be used to display where the user is going to teleport.
  53222. */
  53223. set teleportationTarget(value: Mesh);
  53224. /**
  53225. * 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
  53226. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53227. * See https://doc.babylonjs.com/resources/baking_transformations
  53228. */
  53229. get gazeTrackerMesh(): Mesh;
  53230. set gazeTrackerMesh(value: Mesh);
  53231. /**
  53232. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53233. */
  53234. updateGazeTrackerScale: boolean;
  53235. /**
  53236. * If the gaze trackers color should be updated when selecting meshes
  53237. */
  53238. updateGazeTrackerColor: boolean;
  53239. /**
  53240. * If the controller laser color should be updated when selecting meshes
  53241. */
  53242. updateControllerLaserColor: boolean;
  53243. /**
  53244. * The gaze tracking mesh corresponding to the left controller
  53245. */
  53246. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53247. /**
  53248. * The gaze tracking mesh corresponding to the right controller
  53249. */
  53250. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53251. /**
  53252. * If the ray of the gaze should be displayed.
  53253. */
  53254. get displayGaze(): boolean;
  53255. /**
  53256. * Sets if the ray of the gaze should be displayed.
  53257. */
  53258. set displayGaze(value: boolean);
  53259. /**
  53260. * If the ray of the LaserPointer should be displayed.
  53261. */
  53262. get displayLaserPointer(): boolean;
  53263. /**
  53264. * Sets if the ray of the LaserPointer should be displayed.
  53265. */
  53266. set displayLaserPointer(value: boolean);
  53267. /**
  53268. * The deviceOrientationCamera used as the camera when not in VR.
  53269. */
  53270. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53271. /**
  53272. * Based on the current WebVR support, returns the current VR camera used.
  53273. */
  53274. get currentVRCamera(): Nullable<Camera>;
  53275. /**
  53276. * The webVRCamera which is used when in VR.
  53277. */
  53278. get webVRCamera(): WebVRFreeCamera;
  53279. /**
  53280. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53281. */
  53282. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53283. /**
  53284. * The html button that is used to trigger entering into VR.
  53285. */
  53286. get vrButton(): Nullable<HTMLButtonElement>;
  53287. private get _teleportationRequestInitiated();
  53288. /**
  53289. * Defines whether or not Pointer lock should be requested when switching to
  53290. * full screen.
  53291. */
  53292. requestPointerLockOnFullScreen: boolean;
  53293. /**
  53294. * If asking to force XR, this will be populated with the default xr experience
  53295. */
  53296. xr: WebXRDefaultExperience;
  53297. /**
  53298. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53299. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53300. */
  53301. xrTestDone: boolean;
  53302. /**
  53303. * Instantiates a VRExperienceHelper.
  53304. * Helps to quickly add VR support to an existing scene.
  53305. * @param scene The scene the VRExperienceHelper belongs to.
  53306. * @param webVROptions Options to modify the vr experience helper's behavior.
  53307. */
  53308. constructor(scene: Scene,
  53309. /** Options to modify the vr experience helper's behavior. */
  53310. webVROptions?: VRExperienceHelperOptions);
  53311. private completeVRInit;
  53312. private _onDefaultMeshLoaded;
  53313. private _onResize;
  53314. private _onFullscreenChange;
  53315. /**
  53316. * Gets a value indicating if we are currently in VR mode.
  53317. */
  53318. get isInVRMode(): boolean;
  53319. private onVrDisplayPresentChange;
  53320. private onVRDisplayChanged;
  53321. private moveButtonToBottomRight;
  53322. private displayVRButton;
  53323. private updateButtonVisibility;
  53324. private _cachedAngularSensibility;
  53325. /**
  53326. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53327. * Otherwise, will use the fullscreen API.
  53328. */
  53329. enterVR(): void;
  53330. /**
  53331. * Attempt to exit VR, or fullscreen.
  53332. */
  53333. exitVR(): void;
  53334. /**
  53335. * The position of the vr experience helper.
  53336. */
  53337. get position(): Vector3;
  53338. /**
  53339. * Sets the position of the vr experience helper.
  53340. */
  53341. set position(value: Vector3);
  53342. /**
  53343. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53344. */
  53345. enableInteractions(): void;
  53346. private get _noControllerIsActive();
  53347. private beforeRender;
  53348. private _isTeleportationFloor;
  53349. /**
  53350. * Adds a floor mesh to be used for teleportation.
  53351. * @param floorMesh the mesh to be used for teleportation.
  53352. */
  53353. addFloorMesh(floorMesh: Mesh): void;
  53354. /**
  53355. * Removes a floor mesh from being used for teleportation.
  53356. * @param floorMesh the mesh to be removed.
  53357. */
  53358. removeFloorMesh(floorMesh: Mesh): void;
  53359. /**
  53360. * Enables interactions and teleportation using the VR controllers and gaze.
  53361. * @param vrTeleportationOptions options to modify teleportation behavior.
  53362. */
  53363. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53364. private _onNewGamepadConnected;
  53365. private _tryEnableInteractionOnController;
  53366. private _onNewGamepadDisconnected;
  53367. private _enableInteractionOnController;
  53368. private _checkTeleportWithRay;
  53369. private _checkRotate;
  53370. private _checkTeleportBackwards;
  53371. private _enableTeleportationOnController;
  53372. private _createTeleportationCircles;
  53373. private _displayTeleportationTarget;
  53374. private _hideTeleportationTarget;
  53375. private _rotateCamera;
  53376. private _moveTeleportationSelectorTo;
  53377. private _workingVector;
  53378. private _workingQuaternion;
  53379. private _workingMatrix;
  53380. /**
  53381. * Time Constant Teleportation Mode
  53382. */
  53383. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53384. /**
  53385. * Speed Constant Teleportation Mode
  53386. */
  53387. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53388. /**
  53389. * Teleports the users feet to the desired location
  53390. * @param location The location where the user's feet should be placed
  53391. */
  53392. teleportCamera(location: Vector3): void;
  53393. private _convertNormalToDirectionOfRay;
  53394. private _castRayAndSelectObject;
  53395. private _notifySelectedMeshUnselected;
  53396. /**
  53397. * Permanently set new colors for the laser pointer
  53398. * @param color the new laser color
  53399. * @param pickedColor the new laser color when picked mesh detected
  53400. */
  53401. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53402. /**
  53403. * Set lighting enabled / disabled on the laser pointer of both controllers
  53404. * @param enabled should the lighting be enabled on the laser pointer
  53405. */
  53406. setLaserLightingState(enabled?: boolean): void;
  53407. /**
  53408. * Permanently set new colors for the gaze pointer
  53409. * @param color the new gaze color
  53410. * @param pickedColor the new gaze color when picked mesh detected
  53411. */
  53412. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53413. /**
  53414. * Sets the color of the laser ray from the vr controllers.
  53415. * @param color new color for the ray.
  53416. */
  53417. changeLaserColor(color: Color3): void;
  53418. /**
  53419. * Sets the color of the ray from the vr headsets gaze.
  53420. * @param color new color for the ray.
  53421. */
  53422. changeGazeColor(color: Color3): void;
  53423. /**
  53424. * Exits VR and disposes of the vr experience helper
  53425. */
  53426. dispose(): void;
  53427. /**
  53428. * Gets the name of the VRExperienceHelper class
  53429. * @returns "VRExperienceHelper"
  53430. */
  53431. getClassName(): string;
  53432. }
  53433. }
  53434. declare module BABYLON {
  53435. /**
  53436. * Contains an array of blocks representing the octree
  53437. */
  53438. export interface IOctreeContainer<T> {
  53439. /**
  53440. * Blocks within the octree
  53441. */
  53442. blocks: Array<OctreeBlock<T>>;
  53443. }
  53444. /**
  53445. * Class used to store a cell in an octree
  53446. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53447. */
  53448. export class OctreeBlock<T> {
  53449. /**
  53450. * Gets the content of the current block
  53451. */
  53452. entries: T[];
  53453. /**
  53454. * Gets the list of block children
  53455. */
  53456. blocks: Array<OctreeBlock<T>>;
  53457. private _depth;
  53458. private _maxDepth;
  53459. private _capacity;
  53460. private _minPoint;
  53461. private _maxPoint;
  53462. private _boundingVectors;
  53463. private _creationFunc;
  53464. /**
  53465. * Creates a new block
  53466. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53467. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53468. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53469. * @param depth defines the current depth of this block in the octree
  53470. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53471. * @param creationFunc defines a callback to call when an element is added to the block
  53472. */
  53473. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53474. /**
  53475. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53476. */
  53477. get capacity(): number;
  53478. /**
  53479. * Gets the minimum vector (in world space) of the block's bounding box
  53480. */
  53481. get minPoint(): Vector3;
  53482. /**
  53483. * Gets the maximum vector (in world space) of the block's bounding box
  53484. */
  53485. get maxPoint(): Vector3;
  53486. /**
  53487. * Add a new element to this block
  53488. * @param entry defines the element to add
  53489. */
  53490. addEntry(entry: T): void;
  53491. /**
  53492. * Remove an element from this block
  53493. * @param entry defines the element to remove
  53494. */
  53495. removeEntry(entry: T): void;
  53496. /**
  53497. * Add an array of elements to this block
  53498. * @param entries defines the array of elements to add
  53499. */
  53500. addEntries(entries: T[]): void;
  53501. /**
  53502. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53503. * @param frustumPlanes defines the frustum planes to test
  53504. * @param selection defines the array to store current content if selection is positive
  53505. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53506. */
  53507. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53508. /**
  53509. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53510. * @param sphereCenter defines the bounding sphere center
  53511. * @param sphereRadius defines the bounding sphere radius
  53512. * @param selection defines the array to store current content if selection is positive
  53513. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53514. */
  53515. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53516. /**
  53517. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53518. * @param ray defines the ray to test with
  53519. * @param selection defines the array to store current content if selection is positive
  53520. */
  53521. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53522. /**
  53523. * Subdivide the content into child blocks (this block will then be empty)
  53524. */
  53525. createInnerBlocks(): void;
  53526. /**
  53527. * @hidden
  53528. */
  53529. 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;
  53530. }
  53531. }
  53532. declare module BABYLON {
  53533. /**
  53534. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53535. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53536. */
  53537. export class Octree<T> {
  53538. /** 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.) */
  53539. maxDepth: number;
  53540. /**
  53541. * Blocks within the octree containing objects
  53542. */
  53543. blocks: Array<OctreeBlock<T>>;
  53544. /**
  53545. * Content stored in the octree
  53546. */
  53547. dynamicContent: T[];
  53548. private _maxBlockCapacity;
  53549. private _selectionContent;
  53550. private _creationFunc;
  53551. /**
  53552. * Creates a octree
  53553. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53554. * @param creationFunc function to be used to instatiate the octree
  53555. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53556. * @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.)
  53557. */
  53558. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53559. /** 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.) */
  53560. maxDepth?: number);
  53561. /**
  53562. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53563. * @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);
  53564. * @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);
  53565. * @param entries meshes to be added to the octree blocks
  53566. */
  53567. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53568. /**
  53569. * Adds a mesh to the octree
  53570. * @param entry Mesh to add to the octree
  53571. */
  53572. addMesh(entry: T): void;
  53573. /**
  53574. * Remove an element from the octree
  53575. * @param entry defines the element to remove
  53576. */
  53577. removeMesh(entry: T): void;
  53578. /**
  53579. * Selects an array of meshes within the frustum
  53580. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53581. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53582. * @returns array of meshes within the frustum
  53583. */
  53584. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53585. /**
  53586. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53587. * @param sphereCenter defines the bounding sphere center
  53588. * @param sphereRadius defines the bounding sphere radius
  53589. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53590. * @returns an array of objects that intersect the sphere
  53591. */
  53592. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53593. /**
  53594. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53595. * @param ray defines the ray to test with
  53596. * @returns array of intersected objects
  53597. */
  53598. intersectsRay(ray: Ray): SmartArray<T>;
  53599. /**
  53600. * Adds a mesh into the octree block if it intersects the block
  53601. */
  53602. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53603. /**
  53604. * Adds a submesh into the octree block if it intersects the block
  53605. */
  53606. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53607. }
  53608. }
  53609. declare module BABYLON {
  53610. interface Scene {
  53611. /**
  53612. * @hidden
  53613. * Backing Filed
  53614. */
  53615. _selectionOctree: Octree<AbstractMesh>;
  53616. /**
  53617. * Gets the octree used to boost mesh selection (picking)
  53618. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53619. */
  53620. selectionOctree: Octree<AbstractMesh>;
  53621. /**
  53622. * Creates or updates the octree used to boost selection (picking)
  53623. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53624. * @param maxCapacity defines the maximum capacity per leaf
  53625. * @param maxDepth defines the maximum depth of the octree
  53626. * @returns an octree of AbstractMesh
  53627. */
  53628. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  53629. }
  53630. interface AbstractMesh {
  53631. /**
  53632. * @hidden
  53633. * Backing Field
  53634. */
  53635. _submeshesOctree: Octree<SubMesh>;
  53636. /**
  53637. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  53638. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  53639. * @param maxCapacity defines the maximum size of each block (64 by default)
  53640. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  53641. * @returns the new octree
  53642. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  53643. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53644. */
  53645. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  53646. }
  53647. /**
  53648. * Defines the octree scene component responsible to manage any octrees
  53649. * in a given scene.
  53650. */
  53651. export class OctreeSceneComponent {
  53652. /**
  53653. * The component name help to identify the component in the list of scene components.
  53654. */
  53655. readonly name: string;
  53656. /**
  53657. * The scene the component belongs to.
  53658. */
  53659. scene: Scene;
  53660. /**
  53661. * Indicates if the meshes have been checked to make sure they are isEnabled()
  53662. */
  53663. readonly checksIsEnabled: boolean;
  53664. /**
  53665. * Creates a new instance of the component for the given scene
  53666. * @param scene Defines the scene to register the component in
  53667. */
  53668. constructor(scene: Scene);
  53669. /**
  53670. * Registers the component in a given scene
  53671. */
  53672. register(): void;
  53673. /**
  53674. * Return the list of active meshes
  53675. * @returns the list of active meshes
  53676. */
  53677. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  53678. /**
  53679. * Return the list of active sub meshes
  53680. * @param mesh The mesh to get the candidates sub meshes from
  53681. * @returns the list of active sub meshes
  53682. */
  53683. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  53684. private _tempRay;
  53685. /**
  53686. * Return the list of sub meshes intersecting with a given local ray
  53687. * @param mesh defines the mesh to find the submesh for
  53688. * @param localRay defines the ray in local space
  53689. * @returns the list of intersecting sub meshes
  53690. */
  53691. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  53692. /**
  53693. * Return the list of sub meshes colliding with a collider
  53694. * @param mesh defines the mesh to find the submesh for
  53695. * @param collider defines the collider to evaluate the collision against
  53696. * @returns the list of colliding sub meshes
  53697. */
  53698. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  53699. /**
  53700. * Rebuilds the elements related to this component in case of
  53701. * context lost for instance.
  53702. */
  53703. rebuild(): void;
  53704. /**
  53705. * Disposes the component and the associated ressources.
  53706. */
  53707. dispose(): void;
  53708. }
  53709. }
  53710. declare module BABYLON {
  53711. /**
  53712. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  53713. */
  53714. export class Gizmo implements IDisposable {
  53715. /** The utility layer the gizmo will be added to */
  53716. gizmoLayer: UtilityLayerRenderer;
  53717. /**
  53718. * The root mesh of the gizmo
  53719. */
  53720. _rootMesh: Mesh;
  53721. private _attachedMesh;
  53722. private _attachedNode;
  53723. /**
  53724. * Ratio for the scale of the gizmo (Default: 1)
  53725. */
  53726. protected _scaleRatio: number;
  53727. /**
  53728. * boolean updated by pointermove when a gizmo mesh is hovered
  53729. */
  53730. protected _isHovered: boolean;
  53731. /**
  53732. * Ratio for the scale of the gizmo (Default: 1)
  53733. */
  53734. set scaleRatio(value: number);
  53735. get scaleRatio(): number;
  53736. /**
  53737. * True when the mouse pointer is hovered a gizmo mesh
  53738. */
  53739. get isHovered(): boolean;
  53740. /**
  53741. * If a custom mesh has been set (Default: false)
  53742. */
  53743. protected _customMeshSet: boolean;
  53744. /**
  53745. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  53746. * * When set, interactions will be enabled
  53747. */
  53748. get attachedMesh(): Nullable<AbstractMesh>;
  53749. set attachedMesh(value: Nullable<AbstractMesh>);
  53750. /**
  53751. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  53752. * * When set, interactions will be enabled
  53753. */
  53754. get attachedNode(): Nullable<Node>;
  53755. set attachedNode(value: Nullable<Node>);
  53756. /**
  53757. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53758. * @param mesh The mesh to replace the default mesh of the gizmo
  53759. */
  53760. setCustomMesh(mesh: Mesh): void;
  53761. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  53762. /**
  53763. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  53764. */
  53765. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53766. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53767. /**
  53768. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  53769. */
  53770. updateGizmoPositionToMatchAttachedMesh: boolean;
  53771. /**
  53772. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  53773. */
  53774. updateScale: boolean;
  53775. protected _interactionsEnabled: boolean;
  53776. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53777. private _beforeRenderObserver;
  53778. private _tempQuaternion;
  53779. private _tempVector;
  53780. private _tempVector2;
  53781. private _tempMatrix1;
  53782. private _tempMatrix2;
  53783. private _rightHandtoLeftHandMatrix;
  53784. /**
  53785. * Creates a gizmo
  53786. * @param gizmoLayer The utility layer the gizmo will be added to
  53787. */
  53788. constructor(
  53789. /** The utility layer the gizmo will be added to */
  53790. gizmoLayer?: UtilityLayerRenderer);
  53791. /**
  53792. * Updates the gizmo to match the attached mesh's position/rotation
  53793. */
  53794. protected _update(): void;
  53795. /**
  53796. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  53797. * @param value Node, TransformNode or mesh
  53798. */
  53799. protected _matrixChanged(): void;
  53800. /**
  53801. * Disposes of the gizmo
  53802. */
  53803. dispose(): void;
  53804. }
  53805. }
  53806. declare module BABYLON {
  53807. /**
  53808. * Single plane drag gizmo
  53809. */
  53810. export class PlaneDragGizmo extends Gizmo {
  53811. /**
  53812. * Drag behavior responsible for the gizmos dragging interactions
  53813. */
  53814. dragBehavior: PointerDragBehavior;
  53815. private _pointerObserver;
  53816. /**
  53817. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53818. */
  53819. snapDistance: number;
  53820. /**
  53821. * Event that fires each time the gizmo snaps to a new location.
  53822. * * snapDistance is the the change in distance
  53823. */
  53824. onSnapObservable: Observable<{
  53825. snapDistance: number;
  53826. }>;
  53827. private _plane;
  53828. private _coloredMaterial;
  53829. private _hoverMaterial;
  53830. private _isEnabled;
  53831. private _parent;
  53832. /** @hidden */
  53833. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  53834. /** @hidden */
  53835. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53836. /**
  53837. * Creates a PlaneDragGizmo
  53838. * @param gizmoLayer The utility layer the gizmo will be added to
  53839. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  53840. * @param color The color of the gizmo
  53841. */
  53842. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  53843. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53844. /**
  53845. * If the gizmo is enabled
  53846. */
  53847. set isEnabled(value: boolean);
  53848. get isEnabled(): boolean;
  53849. /**
  53850. * Disposes of the gizmo
  53851. */
  53852. dispose(): void;
  53853. }
  53854. }
  53855. declare module BABYLON {
  53856. /**
  53857. * Gizmo that enables dragging a mesh along 3 axis
  53858. */
  53859. export class PositionGizmo extends Gizmo {
  53860. /**
  53861. * Internal gizmo used for interactions on the x axis
  53862. */
  53863. xGizmo: AxisDragGizmo;
  53864. /**
  53865. * Internal gizmo used for interactions on the y axis
  53866. */
  53867. yGizmo: AxisDragGizmo;
  53868. /**
  53869. * Internal gizmo used for interactions on the z axis
  53870. */
  53871. zGizmo: AxisDragGizmo;
  53872. /**
  53873. * Internal gizmo used for interactions on the yz plane
  53874. */
  53875. xPlaneGizmo: PlaneDragGizmo;
  53876. /**
  53877. * Internal gizmo used for interactions on the xz plane
  53878. */
  53879. yPlaneGizmo: PlaneDragGizmo;
  53880. /**
  53881. * Internal gizmo used for interactions on the xy plane
  53882. */
  53883. zPlaneGizmo: PlaneDragGizmo;
  53884. /**
  53885. * private variables
  53886. */
  53887. private _meshAttached;
  53888. private _nodeAttached;
  53889. private _snapDistance;
  53890. /** Fires an event when any of it's sub gizmos are dragged */
  53891. onDragStartObservable: Observable<unknown>;
  53892. /** Fires an event when any of it's sub gizmos are released from dragging */
  53893. onDragEndObservable: Observable<unknown>;
  53894. /**
  53895. * If set to true, planar drag is enabled
  53896. */
  53897. private _planarGizmoEnabled;
  53898. get attachedMesh(): Nullable<AbstractMesh>;
  53899. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53900. get attachedNode(): Nullable<Node>;
  53901. set attachedNode(node: Nullable<Node>);
  53902. /**
  53903. * True when the mouse pointer is hovering a gizmo mesh
  53904. */
  53905. get isHovered(): boolean;
  53906. /**
  53907. * Creates a PositionGizmo
  53908. * @param gizmoLayer The utility layer the gizmo will be added to
  53909. @param thickness display gizmo axis thickness
  53910. */
  53911. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53912. /**
  53913. * If the planar drag gizmo is enabled
  53914. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  53915. */
  53916. set planarGizmoEnabled(value: boolean);
  53917. get planarGizmoEnabled(): boolean;
  53918. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53919. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53920. /**
  53921. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53922. */
  53923. set snapDistance(value: number);
  53924. get snapDistance(): number;
  53925. /**
  53926. * Ratio for the scale of the gizmo (Default: 1)
  53927. */
  53928. set scaleRatio(value: number);
  53929. get scaleRatio(): number;
  53930. /**
  53931. * Disposes of the gizmo
  53932. */
  53933. dispose(): void;
  53934. /**
  53935. * CustomMeshes are not supported by this gizmo
  53936. * @param mesh The mesh to replace the default mesh of the gizmo
  53937. */
  53938. setCustomMesh(mesh: Mesh): void;
  53939. }
  53940. }
  53941. declare module BABYLON {
  53942. /**
  53943. * Single axis drag gizmo
  53944. */
  53945. export class AxisDragGizmo extends Gizmo {
  53946. /**
  53947. * Drag behavior responsible for the gizmos dragging interactions
  53948. */
  53949. dragBehavior: PointerDragBehavior;
  53950. private _pointerObserver;
  53951. /**
  53952. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53953. */
  53954. snapDistance: number;
  53955. /**
  53956. * Event that fires each time the gizmo snaps to a new location.
  53957. * * snapDistance is the the change in distance
  53958. */
  53959. onSnapObservable: Observable<{
  53960. snapDistance: number;
  53961. }>;
  53962. private _isEnabled;
  53963. private _parent;
  53964. private _arrow;
  53965. private _coloredMaterial;
  53966. private _hoverMaterial;
  53967. /** @hidden */
  53968. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  53969. /** @hidden */
  53970. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53971. /**
  53972. * Creates an AxisDragGizmo
  53973. * @param gizmoLayer The utility layer the gizmo will be added to
  53974. * @param dragAxis The axis which the gizmo will be able to drag on
  53975. * @param color The color of the gizmo
  53976. * @param thickness display gizmo axis thickness
  53977. */
  53978. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  53979. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53980. /**
  53981. * If the gizmo is enabled
  53982. */
  53983. set isEnabled(value: boolean);
  53984. get isEnabled(): boolean;
  53985. /**
  53986. * Disposes of the gizmo
  53987. */
  53988. dispose(): void;
  53989. }
  53990. }
  53991. declare module BABYLON.Debug {
  53992. /**
  53993. * The Axes viewer will show 3 axes in a specific point in space
  53994. */
  53995. export class AxesViewer {
  53996. private _xAxis;
  53997. private _yAxis;
  53998. private _zAxis;
  53999. private _scaleLinesFactor;
  54000. private _instanced;
  54001. /**
  54002. * Gets the hosting scene
  54003. */
  54004. scene: Nullable<Scene>;
  54005. /**
  54006. * Gets or sets a number used to scale line length
  54007. */
  54008. scaleLines: number;
  54009. /** Gets the node hierarchy used to render x-axis */
  54010. get xAxis(): TransformNode;
  54011. /** Gets the node hierarchy used to render y-axis */
  54012. get yAxis(): TransformNode;
  54013. /** Gets the node hierarchy used to render z-axis */
  54014. get zAxis(): TransformNode;
  54015. /**
  54016. * Creates a new AxesViewer
  54017. * @param scene defines the hosting scene
  54018. * @param scaleLines defines a number used to scale line length (1 by default)
  54019. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  54020. * @param xAxis defines the node hierarchy used to render the x-axis
  54021. * @param yAxis defines the node hierarchy used to render the y-axis
  54022. * @param zAxis defines the node hierarchy used to render the z-axis
  54023. */
  54024. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  54025. /**
  54026. * Force the viewer to update
  54027. * @param position defines the position of the viewer
  54028. * @param xaxis defines the x axis of the viewer
  54029. * @param yaxis defines the y axis of the viewer
  54030. * @param zaxis defines the z axis of the viewer
  54031. */
  54032. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  54033. /**
  54034. * Creates an instance of this axes viewer.
  54035. * @returns a new axes viewer with instanced meshes
  54036. */
  54037. createInstance(): AxesViewer;
  54038. /** Releases resources */
  54039. dispose(): void;
  54040. private static _SetRenderingGroupId;
  54041. }
  54042. }
  54043. declare module BABYLON.Debug {
  54044. /**
  54045. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  54046. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  54047. */
  54048. export class BoneAxesViewer extends AxesViewer {
  54049. /**
  54050. * Gets or sets the target mesh where to display the axes viewer
  54051. */
  54052. mesh: Nullable<Mesh>;
  54053. /**
  54054. * Gets or sets the target bone where to display the axes viewer
  54055. */
  54056. bone: Nullable<Bone>;
  54057. /** Gets current position */
  54058. pos: Vector3;
  54059. /** Gets direction of X axis */
  54060. xaxis: Vector3;
  54061. /** Gets direction of Y axis */
  54062. yaxis: Vector3;
  54063. /** Gets direction of Z axis */
  54064. zaxis: Vector3;
  54065. /**
  54066. * Creates a new BoneAxesViewer
  54067. * @param scene defines the hosting scene
  54068. * @param bone defines the target bone
  54069. * @param mesh defines the target mesh
  54070. * @param scaleLines defines a scaling factor for line length (1 by default)
  54071. */
  54072. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  54073. /**
  54074. * Force the viewer to update
  54075. */
  54076. update(): void;
  54077. /** Releases resources */
  54078. dispose(): void;
  54079. }
  54080. }
  54081. declare module BABYLON {
  54082. /**
  54083. * Interface used to define scene explorer extensibility option
  54084. */
  54085. export interface IExplorerExtensibilityOption {
  54086. /**
  54087. * Define the option label
  54088. */
  54089. label: string;
  54090. /**
  54091. * Defines the action to execute on click
  54092. */
  54093. action: (entity: any) => void;
  54094. }
  54095. /**
  54096. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  54097. */
  54098. export interface IExplorerExtensibilityGroup {
  54099. /**
  54100. * Defines a predicate to test if a given type mut be extended
  54101. */
  54102. predicate: (entity: any) => boolean;
  54103. /**
  54104. * Gets the list of options added to a type
  54105. */
  54106. entries: IExplorerExtensibilityOption[];
  54107. }
  54108. /**
  54109. * Interface used to define the options to use to create the Inspector
  54110. */
  54111. export interface IInspectorOptions {
  54112. /**
  54113. * Display in overlay mode (default: false)
  54114. */
  54115. overlay?: boolean;
  54116. /**
  54117. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  54118. */
  54119. globalRoot?: HTMLElement;
  54120. /**
  54121. * Display the Scene explorer
  54122. */
  54123. showExplorer?: boolean;
  54124. /**
  54125. * Display the property inspector
  54126. */
  54127. showInspector?: boolean;
  54128. /**
  54129. * Display in embed mode (both panes on the right)
  54130. */
  54131. embedMode?: boolean;
  54132. /**
  54133. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  54134. */
  54135. handleResize?: boolean;
  54136. /**
  54137. * Allow the panes to popup (default: true)
  54138. */
  54139. enablePopup?: boolean;
  54140. /**
  54141. * Allow the panes to be closed by users (default: true)
  54142. */
  54143. enableClose?: boolean;
  54144. /**
  54145. * Optional list of extensibility entries
  54146. */
  54147. explorerExtensibility?: IExplorerExtensibilityGroup[];
  54148. /**
  54149. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  54150. */
  54151. inspectorURL?: string;
  54152. /**
  54153. * Optional initial tab (default to DebugLayerTab.Properties)
  54154. */
  54155. initialTab?: DebugLayerTab;
  54156. }
  54157. interface Scene {
  54158. /**
  54159. * @hidden
  54160. * Backing field
  54161. */
  54162. _debugLayer: DebugLayer;
  54163. /**
  54164. * Gets the debug layer (aka Inspector) associated with the scene
  54165. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54166. */
  54167. debugLayer: DebugLayer;
  54168. }
  54169. /**
  54170. * Enum of inspector action tab
  54171. */
  54172. export enum DebugLayerTab {
  54173. /**
  54174. * Properties tag (default)
  54175. */
  54176. Properties = 0,
  54177. /**
  54178. * Debug tab
  54179. */
  54180. Debug = 1,
  54181. /**
  54182. * Statistics tab
  54183. */
  54184. Statistics = 2,
  54185. /**
  54186. * Tools tab
  54187. */
  54188. Tools = 3,
  54189. /**
  54190. * Settings tab
  54191. */
  54192. Settings = 4
  54193. }
  54194. /**
  54195. * The debug layer (aka Inspector) is the go to tool in order to better understand
  54196. * what is happening in your scene
  54197. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54198. */
  54199. export class DebugLayer {
  54200. /**
  54201. * Define the url to get the inspector script from.
  54202. * By default it uses the babylonjs CDN.
  54203. * @ignoreNaming
  54204. */
  54205. static InspectorURL: string;
  54206. private _scene;
  54207. private BJSINSPECTOR;
  54208. private _onPropertyChangedObservable?;
  54209. /**
  54210. * Observable triggered when a property is changed through the inspector.
  54211. */
  54212. get onPropertyChangedObservable(): any;
  54213. /**
  54214. * Instantiates a new debug layer.
  54215. * The debug layer (aka Inspector) is the go to tool in order to better understand
  54216. * what is happening in your scene
  54217. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54218. * @param scene Defines the scene to inspect
  54219. */
  54220. constructor(scene: Scene);
  54221. /** Creates the inspector window. */
  54222. private _createInspector;
  54223. /**
  54224. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  54225. * @param entity defines the entity to select
  54226. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  54227. */
  54228. select(entity: any, lineContainerTitles?: string | string[]): void;
  54229. /** Get the inspector from bundle or global */
  54230. private _getGlobalInspector;
  54231. /**
  54232. * Get if the inspector is visible or not.
  54233. * @returns true if visible otherwise, false
  54234. */
  54235. isVisible(): boolean;
  54236. /**
  54237. * Hide the inspector and close its window.
  54238. */
  54239. hide(): void;
  54240. /**
  54241. * Update the scene in the inspector
  54242. */
  54243. setAsActiveScene(): void;
  54244. /**
  54245. * Launch the debugLayer.
  54246. * @param config Define the configuration of the inspector
  54247. * @return a promise fulfilled when the debug layer is visible
  54248. */
  54249. show(config?: IInspectorOptions): Promise<DebugLayer>;
  54250. }
  54251. }
  54252. declare module BABYLON {
  54253. /**
  54254. * Class containing static functions to help procedurally build meshes
  54255. */
  54256. export class BoxBuilder {
  54257. /**
  54258. * Creates a box mesh
  54259. * * The parameter `size` sets the size (float) of each box side (default 1)
  54260. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54261. * * 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)
  54262. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54264. * * 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
  54265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54266. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54267. * @param name defines the name of the mesh
  54268. * @param options defines the options used to create the mesh
  54269. * @param scene defines the hosting scene
  54270. * @returns the box mesh
  54271. */
  54272. static CreateBox(name: string, options: {
  54273. size?: number;
  54274. width?: number;
  54275. height?: number;
  54276. depth?: number;
  54277. faceUV?: Vector4[];
  54278. faceColors?: Color4[];
  54279. sideOrientation?: number;
  54280. frontUVs?: Vector4;
  54281. backUVs?: Vector4;
  54282. wrap?: boolean;
  54283. topBaseAt?: number;
  54284. bottomBaseAt?: number;
  54285. updatable?: boolean;
  54286. }, scene?: Nullable<Scene>): Mesh;
  54287. }
  54288. }
  54289. declare module BABYLON.Debug {
  54290. /**
  54291. * Used to show the physics impostor around the specific mesh
  54292. */
  54293. export class PhysicsViewer {
  54294. /** @hidden */
  54295. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  54296. /** @hidden */
  54297. protected _meshes: Array<Nullable<AbstractMesh>>;
  54298. /** @hidden */
  54299. protected _scene: Nullable<Scene>;
  54300. /** @hidden */
  54301. protected _numMeshes: number;
  54302. /** @hidden */
  54303. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  54304. private _renderFunction;
  54305. private _utilityLayer;
  54306. private _debugBoxMesh;
  54307. private _debugSphereMesh;
  54308. private _debugCylinderMesh;
  54309. private _debugMaterial;
  54310. private _debugMeshMeshes;
  54311. /**
  54312. * Creates a new PhysicsViewer
  54313. * @param scene defines the hosting scene
  54314. */
  54315. constructor(scene: Scene);
  54316. /** @hidden */
  54317. protected _updateDebugMeshes(): void;
  54318. /**
  54319. * Renders a specified physic impostor
  54320. * @param impostor defines the impostor to render
  54321. * @param targetMesh defines the mesh represented by the impostor
  54322. * @returns the new debug mesh used to render the impostor
  54323. */
  54324. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  54325. /**
  54326. * Hides a specified physic impostor
  54327. * @param impostor defines the impostor to hide
  54328. */
  54329. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  54330. private _getDebugMaterial;
  54331. private _getDebugBoxMesh;
  54332. private _getDebugSphereMesh;
  54333. private _getDebugCylinderMesh;
  54334. private _getDebugMeshMesh;
  54335. private _getDebugMesh;
  54336. /** Releases all resources */
  54337. dispose(): void;
  54338. }
  54339. }
  54340. declare module BABYLON {
  54341. /**
  54342. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54343. * in order to better appreciate the issue one might have.
  54344. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54345. */
  54346. export class RayHelper {
  54347. /**
  54348. * Defines the ray we are currently tryin to visualize.
  54349. */
  54350. ray: Nullable<Ray>;
  54351. private _renderPoints;
  54352. private _renderLine;
  54353. private _renderFunction;
  54354. private _scene;
  54355. private _onAfterRenderObserver;
  54356. private _onAfterStepObserver;
  54357. private _attachedToMesh;
  54358. private _meshSpaceDirection;
  54359. private _meshSpaceOrigin;
  54360. /**
  54361. * Helper function to create a colored helper in a scene in one line.
  54362. * @param ray Defines the ray we are currently tryin to visualize
  54363. * @param scene Defines the scene the ray is used in
  54364. * @param color Defines the color we want to see the ray in
  54365. * @returns The newly created ray helper.
  54366. */
  54367. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  54368. /**
  54369. * Instantiate a new ray helper.
  54370. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54371. * in order to better appreciate the issue one might have.
  54372. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54373. * @param ray Defines the ray we are currently tryin to visualize
  54374. */
  54375. constructor(ray: Ray);
  54376. /**
  54377. * Shows the ray we are willing to debug.
  54378. * @param scene Defines the scene the ray needs to be rendered in
  54379. * @param color Defines the color the ray needs to be rendered in
  54380. */
  54381. show(scene: Scene, color?: Color3): void;
  54382. /**
  54383. * Hides the ray we are debugging.
  54384. */
  54385. hide(): void;
  54386. private _render;
  54387. /**
  54388. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  54389. * @param mesh Defines the mesh we want the helper attached to
  54390. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  54391. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  54392. * @param length Defines the length of the ray
  54393. */
  54394. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  54395. /**
  54396. * Detach the ray helper from the mesh it has previously been attached to.
  54397. */
  54398. detachFromMesh(): void;
  54399. private _updateToMesh;
  54400. /**
  54401. * Dispose the helper and release its associated resources.
  54402. */
  54403. dispose(): void;
  54404. }
  54405. }
  54406. declare module BABYLON {
  54407. /**
  54408. * Defines the options associated with the creation of a SkeletonViewer.
  54409. */
  54410. export interface ISkeletonViewerOptions {
  54411. /** Should the system pause animations before building the Viewer? */
  54412. pauseAnimations: boolean;
  54413. /** Should the system return the skeleton to rest before building? */
  54414. returnToRest: boolean;
  54415. /** public Display Mode of the Viewer */
  54416. displayMode: number;
  54417. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54418. displayOptions: ISkeletonViewerDisplayOptions;
  54419. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54420. computeBonesUsingShaders: boolean;
  54421. /** Flag ignore non weighted bones */
  54422. useAllBones: boolean;
  54423. }
  54424. /**
  54425. * Defines how to display the various bone meshes for the viewer.
  54426. */
  54427. export interface ISkeletonViewerDisplayOptions {
  54428. /** How far down to start tapering the bone spurs */
  54429. midStep?: number;
  54430. /** How big is the midStep? */
  54431. midStepFactor?: number;
  54432. /** Base for the Sphere Size */
  54433. sphereBaseSize?: number;
  54434. /** The ratio of the sphere to the longest bone in units */
  54435. sphereScaleUnit?: number;
  54436. /** Ratio for the Sphere Size */
  54437. sphereFactor?: number;
  54438. /** Whether a spur should attach its far end to the child bone position */
  54439. spurFollowsChild?: boolean;
  54440. /** Whether to show local axes or not */
  54441. showLocalAxes?: boolean;
  54442. /** Length of each local axis */
  54443. localAxesSize?: number;
  54444. }
  54445. /**
  54446. * Defines the constructor options for the BoneWeight Shader.
  54447. */
  54448. export interface IBoneWeightShaderOptions {
  54449. /** Skeleton to Map */
  54450. skeleton: Skeleton;
  54451. /** Colors for Uninfluenced bones */
  54452. colorBase?: Color3;
  54453. /** Colors for 0.0-0.25 Weight bones */
  54454. colorZero?: Color3;
  54455. /** Color for 0.25-0.5 Weight Influence */
  54456. colorQuarter?: Color3;
  54457. /** Color for 0.5-0.75 Weight Influence */
  54458. colorHalf?: Color3;
  54459. /** Color for 0.75-1 Weight Influence */
  54460. colorFull?: Color3;
  54461. /** Color for Zero Weight Influence */
  54462. targetBoneIndex?: number;
  54463. }
  54464. /**
  54465. * Simple structure of the gradient steps for the Color Map.
  54466. */
  54467. export interface ISkeletonMapShaderColorMapKnot {
  54468. /** Color of the Knot */
  54469. color: Color3;
  54470. /** Location of the Knot */
  54471. location: number;
  54472. }
  54473. /**
  54474. * Defines the constructor options for the SkeletonMap Shader.
  54475. */
  54476. export interface ISkeletonMapShaderOptions {
  54477. /** Skeleton to Map */
  54478. skeleton: Skeleton;
  54479. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  54480. colorMap?: ISkeletonMapShaderColorMapKnot[];
  54481. }
  54482. }
  54483. declare module BABYLON {
  54484. /**
  54485. * Class containing static functions to help procedurally build meshes
  54486. */
  54487. export class RibbonBuilder {
  54488. /**
  54489. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54490. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54491. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54492. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54493. * * 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
  54494. * * 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
  54495. * * 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
  54496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54497. * * 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
  54498. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54499. * * 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
  54500. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54501. * * 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
  54502. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54504. * @param name defines the name of the mesh
  54505. * @param options defines the options used to create the mesh
  54506. * @param scene defines the hosting scene
  54507. * @returns the ribbon mesh
  54508. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54509. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54510. */
  54511. static CreateRibbon(name: string, options: {
  54512. pathArray: Vector3[][];
  54513. closeArray?: boolean;
  54514. closePath?: boolean;
  54515. offset?: number;
  54516. updatable?: boolean;
  54517. sideOrientation?: number;
  54518. frontUVs?: Vector4;
  54519. backUVs?: Vector4;
  54520. instance?: Mesh;
  54521. invertUV?: boolean;
  54522. uvs?: Vector2[];
  54523. colors?: Color4[];
  54524. }, scene?: Nullable<Scene>): Mesh;
  54525. }
  54526. }
  54527. declare module BABYLON {
  54528. /**
  54529. * Class containing static functions to help procedurally build meshes
  54530. */
  54531. export class ShapeBuilder {
  54532. /**
  54533. * 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.
  54534. * * 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.
  54535. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54536. * * 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.
  54537. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54538. * * 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
  54539. * * 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
  54540. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54542. * * 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
  54543. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54545. * @param name defines the name of the mesh
  54546. * @param options defines the options used to create the mesh
  54547. * @param scene defines the hosting scene
  54548. * @returns the extruded shape mesh
  54549. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54550. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54551. */
  54552. static ExtrudeShape(name: string, options: {
  54553. shape: Vector3[];
  54554. path: Vector3[];
  54555. scale?: number;
  54556. rotation?: number;
  54557. cap?: number;
  54558. updatable?: boolean;
  54559. sideOrientation?: number;
  54560. frontUVs?: Vector4;
  54561. backUVs?: Vector4;
  54562. instance?: Mesh;
  54563. invertUV?: boolean;
  54564. }, scene?: Nullable<Scene>): Mesh;
  54565. /**
  54566. * Creates an custom extruded shape mesh.
  54567. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54568. * * 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.
  54569. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54570. * * 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
  54571. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54572. * * 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
  54573. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54574. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54575. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54576. * * 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
  54577. * * 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
  54578. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54580. * * 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
  54581. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54583. * @param name defines the name of the mesh
  54584. * @param options defines the options used to create the mesh
  54585. * @param scene defines the hosting scene
  54586. * @returns the custom extruded shape mesh
  54587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54588. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54589. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54590. */
  54591. static ExtrudeShapeCustom(name: string, options: {
  54592. shape: Vector3[];
  54593. path: Vector3[];
  54594. scaleFunction?: any;
  54595. rotationFunction?: any;
  54596. ribbonCloseArray?: boolean;
  54597. ribbonClosePath?: boolean;
  54598. cap?: number;
  54599. updatable?: boolean;
  54600. sideOrientation?: number;
  54601. frontUVs?: Vector4;
  54602. backUVs?: Vector4;
  54603. instance?: Mesh;
  54604. invertUV?: boolean;
  54605. }, scene?: Nullable<Scene>): Mesh;
  54606. private static _ExtrudeShapeGeneric;
  54607. }
  54608. }
  54609. declare module BABYLON.Debug {
  54610. /**
  54611. * Class used to render a debug view of a given skeleton
  54612. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  54613. */
  54614. export class SkeletonViewer {
  54615. /** defines the skeleton to render */
  54616. skeleton: Skeleton;
  54617. /** defines the mesh attached to the skeleton */
  54618. mesh: AbstractMesh;
  54619. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54620. autoUpdateBonesMatrices: boolean;
  54621. /** defines the rendering group id to use with the viewer */
  54622. renderingGroupId: number;
  54623. /** is the options for the viewer */
  54624. options: Partial<ISkeletonViewerOptions>;
  54625. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  54626. static readonly DISPLAY_LINES: number;
  54627. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  54628. static readonly DISPLAY_SPHERES: number;
  54629. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  54630. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  54631. /** public static method to create a BoneWeight Shader
  54632. * @param options The constructor options
  54633. * @param scene The scene that the shader is scoped to
  54634. * @returns The created ShaderMaterial
  54635. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  54636. */
  54637. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  54638. /** public static method to create a BoneWeight Shader
  54639. * @param options The constructor options
  54640. * @param scene The scene that the shader is scoped to
  54641. * @returns The created ShaderMaterial
  54642. */
  54643. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  54644. /** private static method to create a BoneWeight Shader
  54645. * @param size The size of the buffer to create (usually the bone count)
  54646. * @param colorMap The gradient data to generate
  54647. * @param scene The scene that the shader is scoped to
  54648. * @returns an Array of floats from the color gradient values
  54649. */
  54650. private static _CreateBoneMapColorBuffer;
  54651. /** If SkeletonViewer scene scope. */
  54652. private _scene;
  54653. /** Gets or sets the color used to render the skeleton */
  54654. color: Color3;
  54655. /** Array of the points of the skeleton fo the line view. */
  54656. private _debugLines;
  54657. /** The SkeletonViewers Mesh. */
  54658. private _debugMesh;
  54659. /** The local axes Meshes. */
  54660. private _localAxes;
  54661. /** If SkeletonViewer is enabled. */
  54662. private _isEnabled;
  54663. /** If SkeletonViewer is ready. */
  54664. private _ready;
  54665. /** SkeletonViewer render observable. */
  54666. private _obs;
  54667. /** The Utility Layer to render the gizmos in. */
  54668. private _utilityLayer;
  54669. private _boneIndices;
  54670. /** Gets the Scene. */
  54671. get scene(): Scene;
  54672. /** Gets the utilityLayer. */
  54673. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  54674. /** Checks Ready Status. */
  54675. get isReady(): Boolean;
  54676. /** Sets Ready Status. */
  54677. set ready(value: boolean);
  54678. /** Gets the debugMesh */
  54679. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  54680. /** Sets the debugMesh */
  54681. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  54682. /** Gets the displayMode */
  54683. get displayMode(): number;
  54684. /** Sets the displayMode */
  54685. set displayMode(value: number);
  54686. /**
  54687. * Creates a new SkeletonViewer
  54688. * @param skeleton defines the skeleton to render
  54689. * @param mesh defines the mesh attached to the skeleton
  54690. * @param scene defines the hosting scene
  54691. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  54692. * @param renderingGroupId defines the rendering group id to use with the viewer
  54693. * @param options All of the extra constructor options for the SkeletonViewer
  54694. */
  54695. constructor(
  54696. /** defines the skeleton to render */
  54697. skeleton: Skeleton,
  54698. /** defines the mesh attached to the skeleton */
  54699. mesh: AbstractMesh,
  54700. /** The Scene scope*/
  54701. scene: Scene,
  54702. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54703. autoUpdateBonesMatrices?: boolean,
  54704. /** defines the rendering group id to use with the viewer */
  54705. renderingGroupId?: number,
  54706. /** is the options for the viewer */
  54707. options?: Partial<ISkeletonViewerOptions>);
  54708. /** The Dynamic bindings for the update functions */
  54709. private _bindObs;
  54710. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  54711. update(): void;
  54712. /** Gets or sets a boolean indicating if the viewer is enabled */
  54713. set isEnabled(value: boolean);
  54714. get isEnabled(): boolean;
  54715. private _getBonePosition;
  54716. private _getLinesForBonesWithLength;
  54717. private _getLinesForBonesNoLength;
  54718. /** function to revert the mesh and scene back to the initial state. */
  54719. private _revert;
  54720. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  54721. private _getAbsoluteBindPoseToRef;
  54722. /** function to build and bind sphere joint points and spur bone representations. */
  54723. private _buildSpheresAndSpurs;
  54724. private _buildLocalAxes;
  54725. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  54726. private _displayLinesUpdate;
  54727. /** Changes the displayMode of the skeleton viewer
  54728. * @param mode The displayMode numerical value
  54729. */
  54730. changeDisplayMode(mode: number): void;
  54731. /** Sets a display option of the skeleton viewer
  54732. *
  54733. * | Option | Type | Default | Description |
  54734. * | ---------------- | ------- | ------- | ----------- |
  54735. * | 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`. |
  54736. * | 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`. |
  54737. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54738. * | 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`. |
  54739. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  54740. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  54741. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  54742. *
  54743. * @param option String of the option name
  54744. * @param value The numerical option value
  54745. */
  54746. changeDisplayOptions(option: string, value: number): void;
  54747. /** Release associated resources */
  54748. dispose(): void;
  54749. }
  54750. }
  54751. declare module BABYLON {
  54752. /**
  54753. * Enum for Device Types
  54754. */
  54755. export enum DeviceType {
  54756. /** Generic */
  54757. Generic = 0,
  54758. /** Keyboard */
  54759. Keyboard = 1,
  54760. /** Mouse */
  54761. Mouse = 2,
  54762. /** Touch Pointers */
  54763. Touch = 3,
  54764. /** PS4 Dual Shock */
  54765. DualShock = 4,
  54766. /** Xbox */
  54767. Xbox = 5,
  54768. /** Switch Controller */
  54769. Switch = 6
  54770. }
  54771. /**
  54772. * Enum for All Pointers (Touch/Mouse)
  54773. */
  54774. export enum PointerInput {
  54775. /** Horizontal Axis */
  54776. Horizontal = 0,
  54777. /** Vertical Axis */
  54778. Vertical = 1,
  54779. /** Left Click or Touch */
  54780. LeftClick = 2,
  54781. /** Middle Click */
  54782. MiddleClick = 3,
  54783. /** Right Click */
  54784. RightClick = 4,
  54785. /** Browser Back */
  54786. BrowserBack = 5,
  54787. /** Browser Forward */
  54788. BrowserForward = 6
  54789. }
  54790. /**
  54791. * Enum for Dual Shock Gamepad
  54792. */
  54793. export enum DualShockInput {
  54794. /** Cross */
  54795. Cross = 0,
  54796. /** Circle */
  54797. Circle = 1,
  54798. /** Square */
  54799. Square = 2,
  54800. /** Triangle */
  54801. Triangle = 3,
  54802. /** L1 */
  54803. L1 = 4,
  54804. /** R1 */
  54805. R1 = 5,
  54806. /** L2 */
  54807. L2 = 6,
  54808. /** R2 */
  54809. R2 = 7,
  54810. /** Share */
  54811. Share = 8,
  54812. /** Options */
  54813. Options = 9,
  54814. /** L3 */
  54815. L3 = 10,
  54816. /** R3 */
  54817. R3 = 11,
  54818. /** DPadUp */
  54819. DPadUp = 12,
  54820. /** DPadDown */
  54821. DPadDown = 13,
  54822. /** DPadLeft */
  54823. DPadLeft = 14,
  54824. /** DRight */
  54825. DPadRight = 15,
  54826. /** Home */
  54827. Home = 16,
  54828. /** TouchPad */
  54829. TouchPad = 17,
  54830. /** LStickXAxis */
  54831. LStickXAxis = 18,
  54832. /** LStickYAxis */
  54833. LStickYAxis = 19,
  54834. /** RStickXAxis */
  54835. RStickXAxis = 20,
  54836. /** RStickYAxis */
  54837. RStickYAxis = 21
  54838. }
  54839. /**
  54840. * Enum for Xbox Gamepad
  54841. */
  54842. export enum XboxInput {
  54843. /** A */
  54844. A = 0,
  54845. /** B */
  54846. B = 1,
  54847. /** X */
  54848. X = 2,
  54849. /** Y */
  54850. Y = 3,
  54851. /** LB */
  54852. LB = 4,
  54853. /** RB */
  54854. RB = 5,
  54855. /** LT */
  54856. LT = 6,
  54857. /** RT */
  54858. RT = 7,
  54859. /** Back */
  54860. Back = 8,
  54861. /** Start */
  54862. Start = 9,
  54863. /** LS */
  54864. LS = 10,
  54865. /** RS */
  54866. RS = 11,
  54867. /** DPadUp */
  54868. DPadUp = 12,
  54869. /** DPadDown */
  54870. DPadDown = 13,
  54871. /** DPadLeft */
  54872. DPadLeft = 14,
  54873. /** DRight */
  54874. DPadRight = 15,
  54875. /** Home */
  54876. Home = 16,
  54877. /** LStickXAxis */
  54878. LStickXAxis = 17,
  54879. /** LStickYAxis */
  54880. LStickYAxis = 18,
  54881. /** RStickXAxis */
  54882. RStickXAxis = 19,
  54883. /** RStickYAxis */
  54884. RStickYAxis = 20
  54885. }
  54886. /**
  54887. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  54888. */
  54889. export enum SwitchInput {
  54890. /** B */
  54891. B = 0,
  54892. /** A */
  54893. A = 1,
  54894. /** Y */
  54895. Y = 2,
  54896. /** X */
  54897. X = 3,
  54898. /** L */
  54899. L = 4,
  54900. /** R */
  54901. R = 5,
  54902. /** ZL */
  54903. ZL = 6,
  54904. /** ZR */
  54905. ZR = 7,
  54906. /** Minus */
  54907. Minus = 8,
  54908. /** Plus */
  54909. Plus = 9,
  54910. /** LS */
  54911. LS = 10,
  54912. /** RS */
  54913. RS = 11,
  54914. /** DPadUp */
  54915. DPadUp = 12,
  54916. /** DPadDown */
  54917. DPadDown = 13,
  54918. /** DPadLeft */
  54919. DPadLeft = 14,
  54920. /** DRight */
  54921. DPadRight = 15,
  54922. /** Home */
  54923. Home = 16,
  54924. /** Capture */
  54925. Capture = 17,
  54926. /** LStickXAxis */
  54927. LStickXAxis = 18,
  54928. /** LStickYAxis */
  54929. LStickYAxis = 19,
  54930. /** RStickXAxis */
  54931. RStickXAxis = 20,
  54932. /** RStickYAxis */
  54933. RStickYAxis = 21
  54934. }
  54935. }
  54936. declare module BABYLON {
  54937. /**
  54938. * This class will take all inputs from Keyboard, Pointer, and
  54939. * any Gamepads and provide a polling system that all devices
  54940. * will use. This class assumes that there will only be one
  54941. * pointer device and one keyboard.
  54942. */
  54943. export class DeviceInputSystem implements IDisposable {
  54944. /**
  54945. * Returns onDeviceConnected callback property
  54946. * @returns Callback with function to execute when a device is connected
  54947. */
  54948. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  54949. /**
  54950. * Sets callback function when a device is connected and executes against all connected devices
  54951. * @param callback Function to execute when a device is connected
  54952. */
  54953. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  54954. /**
  54955. * Callback to be triggered when a device is disconnected
  54956. */
  54957. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54958. /**
  54959. * Callback to be triggered when event driven input is updated
  54960. */
  54961. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  54962. private _inputs;
  54963. private _gamepads;
  54964. private _keyboardActive;
  54965. private _pointerActive;
  54966. private _elementToAttachTo;
  54967. private _keyboardDownEvent;
  54968. private _keyboardUpEvent;
  54969. private _pointerMoveEvent;
  54970. private _pointerDownEvent;
  54971. private _pointerUpEvent;
  54972. private _gamepadConnectedEvent;
  54973. private _gamepadDisconnectedEvent;
  54974. private _onDeviceConnected;
  54975. private static _MAX_KEYCODES;
  54976. private static _MAX_POINTER_INPUTS;
  54977. private constructor();
  54978. /**
  54979. * Creates a new DeviceInputSystem instance
  54980. * @param engine Engine to pull input element from
  54981. * @returns The new instance
  54982. */
  54983. static Create(engine: Engine): DeviceInputSystem;
  54984. /**
  54985. * Checks for current device input value, given an id and input index
  54986. * @param deviceName Id of connected device
  54987. * @param inputIndex Index of device input
  54988. * @returns Current value of input
  54989. */
  54990. /**
  54991. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  54992. * @param deviceType Enum specifiying device type
  54993. * @param deviceSlot "Slot" or index that device is referenced in
  54994. * @param inputIndex Id of input to be checked
  54995. * @returns Current value of input
  54996. */
  54997. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  54998. /**
  54999. * Dispose of all the eventlisteners
  55000. */
  55001. dispose(): void;
  55002. /**
  55003. * Checks for existing connections to devices and register them, if necessary
  55004. * Currently handles gamepads and mouse
  55005. */
  55006. private _checkForConnectedDevices;
  55007. /**
  55008. * Add a gamepad to the DeviceInputSystem
  55009. * @param gamepad A single DOM Gamepad object
  55010. */
  55011. private _addGamePad;
  55012. /**
  55013. * Add pointer device to DeviceInputSystem
  55014. * @param deviceType Type of Pointer to add
  55015. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  55016. * @param currentX Current X at point of adding
  55017. * @param currentY Current Y at point of adding
  55018. */
  55019. private _addPointerDevice;
  55020. /**
  55021. * Add device and inputs to device array
  55022. * @param deviceType Enum specifiying device type
  55023. * @param deviceSlot "Slot" or index that device is referenced in
  55024. * @param numberOfInputs Number of input entries to create for given device
  55025. */
  55026. private _registerDevice;
  55027. /**
  55028. * Given a specific device name, remove that device from the device map
  55029. * @param deviceType Enum specifiying device type
  55030. * @param deviceSlot "Slot" or index that device is referenced in
  55031. */
  55032. private _unregisterDevice;
  55033. /**
  55034. * Handle all actions that come from keyboard interaction
  55035. */
  55036. private _handleKeyActions;
  55037. /**
  55038. * Handle all actions that come from pointer interaction
  55039. */
  55040. private _handlePointerActions;
  55041. /**
  55042. * Handle all actions that come from gamepad interaction
  55043. */
  55044. private _handleGamepadActions;
  55045. /**
  55046. * Update all non-event based devices with each frame
  55047. * @param deviceType Enum specifiying device type
  55048. * @param deviceSlot "Slot" or index that device is referenced in
  55049. * @param inputIndex Id of input to be checked
  55050. */
  55051. private _updateDevice;
  55052. /**
  55053. * Gets DeviceType from the device name
  55054. * @param deviceName Name of Device from DeviceInputSystem
  55055. * @returns DeviceType enum value
  55056. */
  55057. private _getGamepadDeviceType;
  55058. }
  55059. }
  55060. declare module BABYLON {
  55061. /**
  55062. * Type to handle enforcement of inputs
  55063. */
  55064. 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;
  55065. }
  55066. declare module BABYLON {
  55067. /**
  55068. * Class that handles all input for a specific device
  55069. */
  55070. export class DeviceSource<T extends DeviceType> {
  55071. /** Type of device */
  55072. readonly deviceType: DeviceType;
  55073. /** "Slot" or index that device is referenced in */
  55074. readonly deviceSlot: number;
  55075. /**
  55076. * Observable to handle device input changes per device
  55077. */
  55078. readonly onInputChangedObservable: Observable<{
  55079. inputIndex: DeviceInput<T>;
  55080. previousState: Nullable<number>;
  55081. currentState: Nullable<number>;
  55082. }>;
  55083. private readonly _deviceInputSystem;
  55084. /**
  55085. * Default Constructor
  55086. * @param deviceInputSystem Reference to DeviceInputSystem
  55087. * @param deviceType Type of device
  55088. * @param deviceSlot "Slot" or index that device is referenced in
  55089. */
  55090. constructor(deviceInputSystem: DeviceInputSystem,
  55091. /** Type of device */
  55092. deviceType: DeviceType,
  55093. /** "Slot" or index that device is referenced in */
  55094. deviceSlot?: number);
  55095. /**
  55096. * Get input for specific input
  55097. * @param inputIndex index of specific input on device
  55098. * @returns Input value from DeviceInputSystem
  55099. */
  55100. getInput(inputIndex: DeviceInput<T>): number;
  55101. }
  55102. /**
  55103. * Class to keep track of devices
  55104. */
  55105. export class DeviceSourceManager implements IDisposable {
  55106. /**
  55107. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  55108. */
  55109. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  55110. /**
  55111. * Observable to be triggered when after a device is disconnected
  55112. */
  55113. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  55114. private readonly _devices;
  55115. private readonly _firstDevice;
  55116. private readonly _deviceInputSystem;
  55117. /**
  55118. * Default Constructor
  55119. * @param engine engine to pull input element from
  55120. */
  55121. constructor(engine: Engine);
  55122. /**
  55123. * Gets a DeviceSource, given a type and slot
  55124. * @param deviceType Enum specifying device type
  55125. * @param deviceSlot "Slot" or index that device is referenced in
  55126. * @returns DeviceSource object
  55127. */
  55128. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  55129. /**
  55130. * Gets an array of DeviceSource objects for a given device type
  55131. * @param deviceType Enum specifying device type
  55132. * @returns Array of DeviceSource objects
  55133. */
  55134. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  55135. /**
  55136. * Returns a read-only list of all available devices
  55137. * @returns Read-only array with active devices
  55138. */
  55139. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  55140. /**
  55141. * Dispose of DeviceInputSystem and other parts
  55142. */
  55143. dispose(): void;
  55144. /**
  55145. * Function to add device name to device list
  55146. * @param deviceType Enum specifying device type
  55147. * @param deviceSlot "Slot" or index that device is referenced in
  55148. */
  55149. private _addDevice;
  55150. /**
  55151. * Function to remove device name to device list
  55152. * @param deviceType Enum specifying device type
  55153. * @param deviceSlot "Slot" or index that device is referenced in
  55154. */
  55155. private _removeDevice;
  55156. /**
  55157. * Updates array storing first connected device of each type
  55158. * @param type Type of Device
  55159. */
  55160. private _updateFirstDevices;
  55161. }
  55162. }
  55163. declare module BABYLON {
  55164. /**
  55165. * Options to create the null engine
  55166. */
  55167. export class NullEngineOptions {
  55168. /**
  55169. * Render width (Default: 512)
  55170. */
  55171. renderWidth: number;
  55172. /**
  55173. * Render height (Default: 256)
  55174. */
  55175. renderHeight: number;
  55176. /**
  55177. * Texture size (Default: 512)
  55178. */
  55179. textureSize: number;
  55180. /**
  55181. * If delta time between frames should be constant
  55182. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55183. */
  55184. deterministicLockstep: boolean;
  55185. /**
  55186. * Maximum about of steps between frames (Default: 4)
  55187. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55188. */
  55189. lockstepMaxSteps: number;
  55190. /**
  55191. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  55192. */
  55193. useHighPrecisionMatrix?: boolean;
  55194. }
  55195. /**
  55196. * The null engine class provides support for headless version of babylon.js.
  55197. * This can be used in server side scenario or for testing purposes
  55198. */
  55199. export class NullEngine extends Engine {
  55200. private _options;
  55201. /**
  55202. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  55203. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55204. * @returns true if engine is in deterministic lock step mode
  55205. */
  55206. isDeterministicLockStep(): boolean;
  55207. /**
  55208. * Gets the max steps when engine is running in deterministic lock step
  55209. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55210. * @returns the max steps
  55211. */
  55212. getLockstepMaxSteps(): number;
  55213. /**
  55214. * Gets the current hardware scaling level.
  55215. * By default the hardware scaling level is computed from the window device ratio.
  55216. * 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.
  55217. * @returns a number indicating the current hardware scaling level
  55218. */
  55219. getHardwareScalingLevel(): number;
  55220. constructor(options?: NullEngineOptions);
  55221. /**
  55222. * Creates a vertex buffer
  55223. * @param vertices the data for the vertex buffer
  55224. * @returns the new WebGL static buffer
  55225. */
  55226. createVertexBuffer(vertices: FloatArray): DataBuffer;
  55227. /**
  55228. * Creates a new index buffer
  55229. * @param indices defines the content of the index buffer
  55230. * @param updatable defines if the index buffer must be updatable
  55231. * @returns a new webGL buffer
  55232. */
  55233. createIndexBuffer(indices: IndicesArray): DataBuffer;
  55234. /**
  55235. * Clear the current render buffer or the current render target (if any is set up)
  55236. * @param color defines the color to use
  55237. * @param backBuffer defines if the back buffer must be cleared
  55238. * @param depth defines if the depth buffer must be cleared
  55239. * @param stencil defines if the stencil buffer must be cleared
  55240. */
  55241. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55242. /**
  55243. * Gets the current render width
  55244. * @param useScreen defines if screen size must be used (or the current render target if any)
  55245. * @returns a number defining the current render width
  55246. */
  55247. getRenderWidth(useScreen?: boolean): number;
  55248. /**
  55249. * Gets the current render height
  55250. * @param useScreen defines if screen size must be used (or the current render target if any)
  55251. * @returns a number defining the current render height
  55252. */
  55253. getRenderHeight(useScreen?: boolean): number;
  55254. /**
  55255. * Set the WebGL's viewport
  55256. * @param viewport defines the viewport element to be used
  55257. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  55258. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  55259. */
  55260. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  55261. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  55262. /**
  55263. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  55264. * @param pipelineContext defines the pipeline context to use
  55265. * @param uniformsNames defines the list of uniform names
  55266. * @returns an array of webGL uniform locations
  55267. */
  55268. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  55269. /**
  55270. * Gets the lsit of active attributes for a given webGL program
  55271. * @param pipelineContext defines the pipeline context to use
  55272. * @param attributesNames defines the list of attribute names to get
  55273. * @returns an array of indices indicating the offset of each attribute
  55274. */
  55275. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55276. /**
  55277. * Binds an effect to the webGL context
  55278. * @param effect defines the effect to bind
  55279. */
  55280. bindSamplers(effect: Effect): void;
  55281. /**
  55282. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  55283. * @param effect defines the effect to activate
  55284. */
  55285. enableEffect(effect: Effect): void;
  55286. /**
  55287. * Set various states to the webGL context
  55288. * @param culling defines backface culling state
  55289. * @param zOffset defines the value to apply to zOffset (0 by default)
  55290. * @param force defines if states must be applied even if cache is up to date
  55291. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  55292. */
  55293. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55294. /**
  55295. * Set the value of an uniform to an array of int32
  55296. * @param uniform defines the webGL uniform location where to store the value
  55297. * @param array defines the array of int32 to store
  55298. * @returns true if value was set
  55299. */
  55300. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55301. /**
  55302. * Set the value of an uniform to an array of int32 (stored as vec2)
  55303. * @param uniform defines the webGL uniform location where to store the value
  55304. * @param array defines the array of int32 to store
  55305. * @returns true if value was set
  55306. */
  55307. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55308. /**
  55309. * Set the value of an uniform to an array of int32 (stored as vec3)
  55310. * @param uniform defines the webGL uniform location where to store the value
  55311. * @param array defines the array of int32 to store
  55312. * @returns true if value was set
  55313. */
  55314. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55315. /**
  55316. * Set the value of an uniform to an array of int32 (stored as vec4)
  55317. * @param uniform defines the webGL uniform location where to store the value
  55318. * @param array defines the array of int32 to store
  55319. * @returns true if value was set
  55320. */
  55321. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55322. /**
  55323. * Set the value of an uniform to an array of float32
  55324. * @param uniform defines the webGL uniform location where to store the value
  55325. * @param array defines the array of float32 to store
  55326. * @returns true if value was set
  55327. */
  55328. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55329. /**
  55330. * Set the value of an uniform to an array of float32 (stored as vec2)
  55331. * @param uniform defines the webGL uniform location where to store the value
  55332. * @param array defines the array of float32 to store
  55333. * @returns true if value was set
  55334. */
  55335. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55336. /**
  55337. * Set the value of an uniform to an array of float32 (stored as vec3)
  55338. * @param uniform defines the webGL uniform location where to store the value
  55339. * @param array defines the array of float32 to store
  55340. * @returns true if value was set
  55341. */
  55342. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55343. /**
  55344. * Set the value of an uniform to an array of float32 (stored as vec4)
  55345. * @param uniform defines the webGL uniform location where to store the value
  55346. * @param array defines the array of float32 to store
  55347. * @returns true if value was set
  55348. */
  55349. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55350. /**
  55351. * Set the value of an uniform to an array of number
  55352. * @param uniform defines the webGL uniform location where to store the value
  55353. * @param array defines the array of number to store
  55354. * @returns true if value was set
  55355. */
  55356. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55357. /**
  55358. * Set the value of an uniform to an array of number (stored as vec2)
  55359. * @param uniform defines the webGL uniform location where to store the value
  55360. * @param array defines the array of number to store
  55361. * @returns true if value was set
  55362. */
  55363. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55364. /**
  55365. * Set the value of an uniform to an array of number (stored as vec3)
  55366. * @param uniform defines the webGL uniform location where to store the value
  55367. * @param array defines the array of number to store
  55368. * @returns true if value was set
  55369. */
  55370. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55371. /**
  55372. * Set the value of an uniform to an array of number (stored as vec4)
  55373. * @param uniform defines the webGL uniform location where to store the value
  55374. * @param array defines the array of number to store
  55375. * @returns true if value was set
  55376. */
  55377. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55378. /**
  55379. * Set the value of an uniform to an array of float32 (stored as matrices)
  55380. * @param uniform defines the webGL uniform location where to store the value
  55381. * @param matrices defines the array of float32 to store
  55382. * @returns true if value was set
  55383. */
  55384. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55385. /**
  55386. * Set the value of an uniform to a matrix (3x3)
  55387. * @param uniform defines the webGL uniform location where to store the value
  55388. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  55389. * @returns true if value was set
  55390. */
  55391. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55392. /**
  55393. * Set the value of an uniform to a matrix (2x2)
  55394. * @param uniform defines the webGL uniform location where to store the value
  55395. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  55396. * @returns true if value was set
  55397. */
  55398. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55399. /**
  55400. * Set the value of an uniform to a number (float)
  55401. * @param uniform defines the webGL uniform location where to store the value
  55402. * @param value defines the float number to store
  55403. * @returns true if value was set
  55404. */
  55405. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55406. /**
  55407. * Set the value of an uniform to a vec2
  55408. * @param uniform defines the webGL uniform location where to store the value
  55409. * @param x defines the 1st component of the value
  55410. * @param y defines the 2nd component of the value
  55411. * @returns true if value was set
  55412. */
  55413. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55414. /**
  55415. * Set the value of an uniform to a vec3
  55416. * @param uniform defines the webGL uniform location where to store the value
  55417. * @param x defines the 1st component of the value
  55418. * @param y defines the 2nd component of the value
  55419. * @param z defines the 3rd component of the value
  55420. * @returns true if value was set
  55421. */
  55422. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55423. /**
  55424. * Set the value of an uniform to a boolean
  55425. * @param uniform defines the webGL uniform location where to store the value
  55426. * @param bool defines the boolean to store
  55427. * @returns true if value was set
  55428. */
  55429. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  55430. /**
  55431. * Set the value of an uniform to a vec4
  55432. * @param uniform defines the webGL uniform location where to store the value
  55433. * @param x defines the 1st component of the value
  55434. * @param y defines the 2nd component of the value
  55435. * @param z defines the 3rd component of the value
  55436. * @param w defines the 4th component of the value
  55437. * @returns true if value was set
  55438. */
  55439. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55440. /**
  55441. * Sets the current alpha mode
  55442. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  55443. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55444. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55445. */
  55446. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55447. /**
  55448. * Bind webGl buffers directly to the webGL context
  55449. * @param vertexBuffers defines the vertex buffer to bind
  55450. * @param indexBuffer defines the index buffer to bind
  55451. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  55452. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  55453. * @param effect defines the effect associated with the vertex buffer
  55454. */
  55455. bindBuffers(vertexBuffers: {
  55456. [key: string]: VertexBuffer;
  55457. }, indexBuffer: DataBuffer, effect: Effect): void;
  55458. /**
  55459. * Force the entire cache to be cleared
  55460. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  55461. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  55462. */
  55463. wipeCaches(bruteForce?: boolean): void;
  55464. /**
  55465. * Send a draw order
  55466. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  55467. * @param indexStart defines the starting index
  55468. * @param indexCount defines the number of index to draw
  55469. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55470. */
  55471. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  55472. /**
  55473. * Draw a list of indexed primitives
  55474. * @param fillMode defines the primitive to use
  55475. * @param indexStart defines the starting index
  55476. * @param indexCount defines the number of index to draw
  55477. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55478. */
  55479. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55480. /**
  55481. * Draw a list of unindexed primitives
  55482. * @param fillMode defines the primitive to use
  55483. * @param verticesStart defines the index of first vertex to draw
  55484. * @param verticesCount defines the count of vertices to draw
  55485. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55486. */
  55487. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55488. /** @hidden */
  55489. _createTexture(): WebGLTexture;
  55490. /** @hidden */
  55491. _releaseTexture(texture: InternalTexture): void;
  55492. /**
  55493. * Usually called from Texture.ts.
  55494. * Passed information to create a WebGLTexture
  55495. * @param urlArg defines a value which contains one of the following:
  55496. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55497. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55498. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55499. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55500. * @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)
  55501. * @param scene needed for loading to the correct scene
  55502. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55503. * @param onLoad optional callback to be called upon successful completion
  55504. * @param onError optional callback to be called upon failure
  55505. * @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
  55506. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55507. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55508. * @param forcedExtension defines the extension to use to pick the right loader
  55509. * @param mimeType defines an optional mime type
  55510. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55511. */
  55512. 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;
  55513. /**
  55514. * Creates a new render target texture
  55515. * @param size defines the size of the texture
  55516. * @param options defines the options used to create the texture
  55517. * @returns a new render target texture stored in an InternalTexture
  55518. */
  55519. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  55520. /**
  55521. * Update the sampling mode of a given texture
  55522. * @param samplingMode defines the required sampling mode
  55523. * @param texture defines the texture to update
  55524. */
  55525. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55526. /**
  55527. * Binds the frame buffer to the specified texture.
  55528. * @param texture The texture to render to or null for the default canvas
  55529. * @param faceIndex The face of the texture to render to in case of cube texture
  55530. * @param requiredWidth The width of the target to render to
  55531. * @param requiredHeight The height of the target to render to
  55532. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  55533. * @param lodLevel defines le lod level to bind to the frame buffer
  55534. */
  55535. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55536. /**
  55537. * Unbind the current render target texture from the webGL context
  55538. * @param texture defines the render target texture to unbind
  55539. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  55540. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  55541. */
  55542. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55543. /**
  55544. * Creates a dynamic vertex buffer
  55545. * @param vertices the data for the dynamic vertex buffer
  55546. * @returns the new WebGL dynamic buffer
  55547. */
  55548. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  55549. /**
  55550. * Update the content of a dynamic texture
  55551. * @param texture defines the texture to update
  55552. * @param canvas defines the canvas containing the source
  55553. * @param invertY defines if data must be stored with Y axis inverted
  55554. * @param premulAlpha defines if alpha is stored as premultiplied
  55555. * @param format defines the format of the data
  55556. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55557. */
  55558. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55559. /**
  55560. * Gets a boolean indicating if all created effects are ready
  55561. * @returns true if all effects are ready
  55562. */
  55563. areAllEffectsReady(): boolean;
  55564. /**
  55565. * @hidden
  55566. * Get the current error code of the webGL context
  55567. * @returns the error code
  55568. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  55569. */
  55570. getError(): number;
  55571. /** @hidden */
  55572. _getUnpackAlignement(): number;
  55573. /** @hidden */
  55574. _unpackFlipY(value: boolean): void;
  55575. /**
  55576. * Update a dynamic index buffer
  55577. * @param indexBuffer defines the target index buffer
  55578. * @param indices defines the data to update
  55579. * @param offset defines the offset in the target index buffer where update should start
  55580. */
  55581. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  55582. /**
  55583. * Updates a dynamic vertex buffer.
  55584. * @param vertexBuffer the vertex buffer to update
  55585. * @param vertices the data used to update the vertex buffer
  55586. * @param byteOffset the byte offset of the data (optional)
  55587. * @param byteLength the byte length of the data (optional)
  55588. */
  55589. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  55590. /** @hidden */
  55591. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  55592. /** @hidden */
  55593. _bindTexture(channel: number, texture: InternalTexture): void;
  55594. protected _deleteBuffer(buffer: WebGLBuffer): void;
  55595. /**
  55596. * 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
  55597. */
  55598. releaseEffects(): void;
  55599. displayLoadingUI(): void;
  55600. hideLoadingUI(): void;
  55601. /** @hidden */
  55602. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55603. /** @hidden */
  55604. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55605. /** @hidden */
  55606. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55607. /** @hidden */
  55608. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55609. }
  55610. }
  55611. declare module BABYLON {
  55612. /**
  55613. * @hidden
  55614. **/
  55615. export class _TimeToken {
  55616. _startTimeQuery: Nullable<WebGLQuery>;
  55617. _endTimeQuery: Nullable<WebGLQuery>;
  55618. _timeElapsedQuery: Nullable<WebGLQuery>;
  55619. _timeElapsedQueryEnded: boolean;
  55620. }
  55621. }
  55622. declare module BABYLON {
  55623. /** @hidden */
  55624. export class _OcclusionDataStorage {
  55625. /** @hidden */
  55626. occlusionInternalRetryCounter: number;
  55627. /** @hidden */
  55628. isOcclusionQueryInProgress: boolean;
  55629. /** @hidden */
  55630. isOccluded: boolean;
  55631. /** @hidden */
  55632. occlusionRetryCount: number;
  55633. /** @hidden */
  55634. occlusionType: number;
  55635. /** @hidden */
  55636. occlusionQueryAlgorithmType: number;
  55637. }
  55638. interface Engine {
  55639. /**
  55640. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  55641. * @return the new query
  55642. */
  55643. createQuery(): WebGLQuery;
  55644. /**
  55645. * Delete and release a webGL query
  55646. * @param query defines the query to delete
  55647. * @return the current engine
  55648. */
  55649. deleteQuery(query: WebGLQuery): Engine;
  55650. /**
  55651. * Check if a given query has resolved and got its value
  55652. * @param query defines the query to check
  55653. * @returns true if the query got its value
  55654. */
  55655. isQueryResultAvailable(query: WebGLQuery): boolean;
  55656. /**
  55657. * Gets the value of a given query
  55658. * @param query defines the query to check
  55659. * @returns the value of the query
  55660. */
  55661. getQueryResult(query: WebGLQuery): number;
  55662. /**
  55663. * Initiates an occlusion query
  55664. * @param algorithmType defines the algorithm to use
  55665. * @param query defines the query to use
  55666. * @returns the current engine
  55667. * @see https://doc.babylonjs.com/features/occlusionquery
  55668. */
  55669. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  55670. /**
  55671. * Ends an occlusion query
  55672. * @see https://doc.babylonjs.com/features/occlusionquery
  55673. * @param algorithmType defines the algorithm to use
  55674. * @returns the current engine
  55675. */
  55676. endOcclusionQuery(algorithmType: number): Engine;
  55677. /**
  55678. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  55679. * Please note that only one query can be issued at a time
  55680. * @returns a time token used to track the time span
  55681. */
  55682. startTimeQuery(): Nullable<_TimeToken>;
  55683. /**
  55684. * Ends a time query
  55685. * @param token defines the token used to measure the time span
  55686. * @returns the time spent (in ns)
  55687. */
  55688. endTimeQuery(token: _TimeToken): int;
  55689. /** @hidden */
  55690. _currentNonTimestampToken: Nullable<_TimeToken>;
  55691. /** @hidden */
  55692. _createTimeQuery(): WebGLQuery;
  55693. /** @hidden */
  55694. _deleteTimeQuery(query: WebGLQuery): void;
  55695. /** @hidden */
  55696. _getGlAlgorithmType(algorithmType: number): number;
  55697. /** @hidden */
  55698. _getTimeQueryResult(query: WebGLQuery): any;
  55699. /** @hidden */
  55700. _getTimeQueryAvailability(query: WebGLQuery): any;
  55701. }
  55702. interface AbstractMesh {
  55703. /**
  55704. * Backing filed
  55705. * @hidden
  55706. */
  55707. __occlusionDataStorage: _OcclusionDataStorage;
  55708. /**
  55709. * Access property
  55710. * @hidden
  55711. */
  55712. _occlusionDataStorage: _OcclusionDataStorage;
  55713. /**
  55714. * 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.
  55715. * The default value is -1 which means don't break the query and wait till the result
  55716. * @see https://doc.babylonjs.com/features/occlusionquery
  55717. */
  55718. occlusionRetryCount: number;
  55719. /**
  55720. * 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:
  55721. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  55722. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  55723. * * 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.
  55724. * @see https://doc.babylonjs.com/features/occlusionquery
  55725. */
  55726. occlusionType: number;
  55727. /**
  55728. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  55729. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  55730. * * 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.
  55731. * @see https://doc.babylonjs.com/features/occlusionquery
  55732. */
  55733. occlusionQueryAlgorithmType: number;
  55734. /**
  55735. * 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
  55736. * @see https://doc.babylonjs.com/features/occlusionquery
  55737. */
  55738. isOccluded: boolean;
  55739. /**
  55740. * Flag to check the progress status of the query
  55741. * @see https://doc.babylonjs.com/features/occlusionquery
  55742. */
  55743. isOcclusionQueryInProgress: boolean;
  55744. }
  55745. }
  55746. declare module BABYLON {
  55747. /** @hidden */
  55748. export var _forceTransformFeedbackToBundle: boolean;
  55749. interface Engine {
  55750. /**
  55751. * Creates a webGL transform feedback object
  55752. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  55753. * @returns the webGL transform feedback object
  55754. */
  55755. createTransformFeedback(): WebGLTransformFeedback;
  55756. /**
  55757. * Delete a webGL transform feedback object
  55758. * @param value defines the webGL transform feedback object to delete
  55759. */
  55760. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  55761. /**
  55762. * Bind a webGL transform feedback object to the webgl context
  55763. * @param value defines the webGL transform feedback object to bind
  55764. */
  55765. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  55766. /**
  55767. * Begins a transform feedback operation
  55768. * @param usePoints defines if points or triangles must be used
  55769. */
  55770. beginTransformFeedback(usePoints: boolean): void;
  55771. /**
  55772. * Ends a transform feedback operation
  55773. */
  55774. endTransformFeedback(): void;
  55775. /**
  55776. * Specify the varyings to use with transform feedback
  55777. * @param program defines the associated webGL program
  55778. * @param value defines the list of strings representing the varying names
  55779. */
  55780. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  55781. /**
  55782. * Bind a webGL buffer for a transform feedback operation
  55783. * @param value defines the webGL buffer to bind
  55784. */
  55785. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  55786. }
  55787. }
  55788. declare module BABYLON {
  55789. /**
  55790. * Class used to define an additional view for the engine
  55791. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55792. */
  55793. export class EngineView {
  55794. /** Defines the canvas where to render the view */
  55795. target: HTMLCanvasElement;
  55796. /** Defines an optional camera used to render the view (will use active camera else) */
  55797. camera?: Camera;
  55798. }
  55799. interface Engine {
  55800. /**
  55801. * Gets or sets the HTML element to use for attaching events
  55802. */
  55803. inputElement: Nullable<HTMLElement>;
  55804. /**
  55805. * Gets the current engine view
  55806. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55807. */
  55808. activeView: Nullable<EngineView>;
  55809. /** Gets or sets the list of views */
  55810. views: EngineView[];
  55811. /**
  55812. * Register a new child canvas
  55813. * @param canvas defines the canvas to register
  55814. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  55815. * @returns the associated view
  55816. */
  55817. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  55818. /**
  55819. * Remove a registered child canvas
  55820. * @param canvas defines the canvas to remove
  55821. * @returns the current engine
  55822. */
  55823. unRegisterView(canvas: HTMLCanvasElement): Engine;
  55824. }
  55825. }
  55826. declare module BABYLON {
  55827. interface Engine {
  55828. /** @hidden */
  55829. _excludedCompressedTextures: string[];
  55830. /** @hidden */
  55831. _textureFormatInUse: string;
  55832. /**
  55833. * Gets the list of texture formats supported
  55834. */
  55835. readonly texturesSupported: Array<string>;
  55836. /**
  55837. * Gets the texture format in use
  55838. */
  55839. readonly textureFormatInUse: Nullable<string>;
  55840. /**
  55841. * Set the compressed texture extensions or file names to skip.
  55842. *
  55843. * @param skippedFiles defines the list of those texture files you want to skip
  55844. * Example: [".dds", ".env", "myfile.png"]
  55845. */
  55846. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  55847. /**
  55848. * Set the compressed texture format to use, based on the formats you have, and the formats
  55849. * supported by the hardware / browser.
  55850. *
  55851. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  55852. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  55853. * to API arguments needed to compressed textures. This puts the burden on the container
  55854. * generator to house the arcane code for determining these for current & future formats.
  55855. *
  55856. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55857. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55858. *
  55859. * Note: The result of this call is not taken into account when a texture is base64.
  55860. *
  55861. * @param formatsAvailable defines the list of those format families you have created
  55862. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  55863. *
  55864. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  55865. * @returns The extension selected.
  55866. */
  55867. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  55868. }
  55869. }
  55870. declare module BABYLON {
  55871. /** @hidden */
  55872. export var rgbdEncodePixelShader: {
  55873. name: string;
  55874. shader: string;
  55875. };
  55876. }
  55877. declare module BABYLON {
  55878. /**
  55879. * Raw texture data and descriptor sufficient for WebGL texture upload
  55880. */
  55881. export interface EnvironmentTextureInfo {
  55882. /**
  55883. * Version of the environment map
  55884. */
  55885. version: number;
  55886. /**
  55887. * Width of image
  55888. */
  55889. width: number;
  55890. /**
  55891. * Irradiance information stored in the file.
  55892. */
  55893. irradiance: any;
  55894. /**
  55895. * Specular information stored in the file.
  55896. */
  55897. specular: any;
  55898. }
  55899. /**
  55900. * Defines One Image in the file. It requires only the position in the file
  55901. * as well as the length.
  55902. */
  55903. interface BufferImageData {
  55904. /**
  55905. * Length of the image data.
  55906. */
  55907. length: number;
  55908. /**
  55909. * Position of the data from the null terminator delimiting the end of the JSON.
  55910. */
  55911. position: number;
  55912. }
  55913. /**
  55914. * Defines the specular data enclosed in the file.
  55915. * This corresponds to the version 1 of the data.
  55916. */
  55917. export interface EnvironmentTextureSpecularInfoV1 {
  55918. /**
  55919. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  55920. */
  55921. specularDataPosition?: number;
  55922. /**
  55923. * This contains all the images data needed to reconstruct the cubemap.
  55924. */
  55925. mipmaps: Array<BufferImageData>;
  55926. /**
  55927. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  55928. */
  55929. lodGenerationScale: number;
  55930. }
  55931. /**
  55932. * Sets of helpers addressing the serialization and deserialization of environment texture
  55933. * stored in a BabylonJS env file.
  55934. * Those files are usually stored as .env files.
  55935. */
  55936. export class EnvironmentTextureTools {
  55937. /**
  55938. * Magic number identifying the env file.
  55939. */
  55940. private static _MagicBytes;
  55941. /**
  55942. * Gets the environment info from an env file.
  55943. * @param data The array buffer containing the .env bytes.
  55944. * @returns the environment file info (the json header) if successfully parsed.
  55945. */
  55946. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  55947. /**
  55948. * Creates an environment texture from a loaded cube texture.
  55949. * @param texture defines the cube texture to convert in env file
  55950. * @return a promise containing the environment data if succesfull.
  55951. */
  55952. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  55953. /**
  55954. * Creates a JSON representation of the spherical data.
  55955. * @param texture defines the texture containing the polynomials
  55956. * @return the JSON representation of the spherical info
  55957. */
  55958. private static _CreateEnvTextureIrradiance;
  55959. /**
  55960. * Creates the ArrayBufferViews used for initializing environment texture image data.
  55961. * @param data the image data
  55962. * @param info parameters that determine what views will be created for accessing the underlying buffer
  55963. * @return the views described by info providing access to the underlying buffer
  55964. */
  55965. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  55966. /**
  55967. * Uploads the texture info contained in the env file to the GPU.
  55968. * @param texture defines the internal texture to upload to
  55969. * @param data defines the data to load
  55970. * @param info defines the texture info retrieved through the GetEnvInfo method
  55971. * @returns a promise
  55972. */
  55973. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  55974. private static _OnImageReadyAsync;
  55975. /**
  55976. * Uploads the levels of image data to the GPU.
  55977. * @param texture defines the internal texture to upload to
  55978. * @param imageData defines the array buffer views of image data [mipmap][face]
  55979. * @returns a promise
  55980. */
  55981. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  55982. /**
  55983. * Uploads spherical polynomials information to the texture.
  55984. * @param texture defines the texture we are trying to upload the information to
  55985. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  55986. */
  55987. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  55988. /** @hidden */
  55989. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55990. }
  55991. }
  55992. declare module BABYLON {
  55993. /**
  55994. * Class used to inline functions in shader code
  55995. */
  55996. export class ShaderCodeInliner {
  55997. private static readonly _RegexpFindFunctionNameAndType;
  55998. private _sourceCode;
  55999. private _functionDescr;
  56000. private _numMaxIterations;
  56001. /** Gets or sets the token used to mark the functions to inline */
  56002. inlineToken: string;
  56003. /** Gets or sets the debug mode */
  56004. debug: boolean;
  56005. /** Gets the code after the inlining process */
  56006. get code(): string;
  56007. /**
  56008. * Initializes the inliner
  56009. * @param sourceCode shader code source to inline
  56010. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  56011. */
  56012. constructor(sourceCode: string, numMaxIterations?: number);
  56013. /**
  56014. * Start the processing of the shader code
  56015. */
  56016. processCode(): void;
  56017. private _collectFunctions;
  56018. private _processInlining;
  56019. private _extractBetweenMarkers;
  56020. private _skipWhitespaces;
  56021. private _removeComments;
  56022. private _replaceFunctionCallsByCode;
  56023. private _findBackward;
  56024. private _escapeRegExp;
  56025. private _replaceNames;
  56026. }
  56027. }
  56028. declare module BABYLON {
  56029. /**
  56030. * Container for accessors for natively-stored mesh data buffers.
  56031. */
  56032. class NativeDataBuffer extends DataBuffer {
  56033. /**
  56034. * Accessor value used to identify/retrieve a natively-stored index buffer.
  56035. */
  56036. nativeIndexBuffer?: any;
  56037. /**
  56038. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  56039. */
  56040. nativeVertexBuffer?: any;
  56041. }
  56042. /** @hidden */
  56043. class NativeTexture extends InternalTexture {
  56044. getInternalTexture(): InternalTexture;
  56045. getViewCount(): number;
  56046. }
  56047. /** @hidden */
  56048. export class NativeEngine extends Engine {
  56049. private readonly _native;
  56050. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  56051. private readonly INVALID_HANDLE;
  56052. private _boundBuffersVertexArray;
  56053. private _currentDepthTest;
  56054. getHardwareScalingLevel(): number;
  56055. constructor();
  56056. dispose(): void;
  56057. /**
  56058. * Can be used to override the current requestAnimationFrame requester.
  56059. * @hidden
  56060. */
  56061. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  56062. /**
  56063. * Override default engine behavior.
  56064. * @param color
  56065. * @param backBuffer
  56066. * @param depth
  56067. * @param stencil
  56068. */
  56069. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  56070. /**
  56071. * Gets host document
  56072. * @returns the host document object
  56073. */
  56074. getHostDocument(): Nullable<Document>;
  56075. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56076. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  56077. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  56078. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  56079. [key: string]: VertexBuffer;
  56080. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56081. bindBuffers(vertexBuffers: {
  56082. [key: string]: VertexBuffer;
  56083. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56084. recordVertexArrayObject(vertexBuffers: {
  56085. [key: string]: VertexBuffer;
  56086. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  56087. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56088. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56089. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56090. /**
  56091. * Draw a list of indexed primitives
  56092. * @param fillMode defines the primitive to use
  56093. * @param indexStart defines the starting index
  56094. * @param indexCount defines the number of index to draw
  56095. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56096. */
  56097. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56098. /**
  56099. * Draw a list of unindexed primitives
  56100. * @param fillMode defines the primitive to use
  56101. * @param verticesStart defines the index of first vertex to draw
  56102. * @param verticesCount defines the count of vertices to draw
  56103. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56104. */
  56105. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56106. createPipelineContext(): IPipelineContext;
  56107. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  56108. /** @hidden */
  56109. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  56110. /** @hidden */
  56111. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  56112. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56113. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56114. protected _setProgram(program: WebGLProgram): void;
  56115. _releaseEffect(effect: Effect): void;
  56116. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  56117. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  56118. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  56119. bindSamplers(effect: Effect): void;
  56120. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  56121. getRenderWidth(useScreen?: boolean): number;
  56122. getRenderHeight(useScreen?: boolean): number;
  56123. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  56124. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56125. /**
  56126. * Set the z offset to apply to current rendering
  56127. * @param value defines the offset to apply
  56128. */
  56129. setZOffset(value: number): void;
  56130. /**
  56131. * Gets the current value of the zOffset
  56132. * @returns the current zOffset state
  56133. */
  56134. getZOffset(): number;
  56135. /**
  56136. * Enable or disable depth buffering
  56137. * @param enable defines the state to set
  56138. */
  56139. setDepthBuffer(enable: boolean): void;
  56140. /**
  56141. * Gets a boolean indicating if depth writing is enabled
  56142. * @returns the current depth writing state
  56143. */
  56144. getDepthWrite(): boolean;
  56145. setDepthFunctionToGreater(): void;
  56146. setDepthFunctionToGreaterOrEqual(): void;
  56147. setDepthFunctionToLess(): void;
  56148. setDepthFunctionToLessOrEqual(): void;
  56149. /**
  56150. * Enable or disable depth writing
  56151. * @param enable defines the state to set
  56152. */
  56153. setDepthWrite(enable: boolean): void;
  56154. /**
  56155. * Enable or disable color writing
  56156. * @param enable defines the state to set
  56157. */
  56158. setColorWrite(enable: boolean): void;
  56159. /**
  56160. * Gets a boolean indicating if color writing is enabled
  56161. * @returns the current color writing state
  56162. */
  56163. getColorWrite(): boolean;
  56164. /**
  56165. * Sets alpha constants used by some alpha blending modes
  56166. * @param r defines the red component
  56167. * @param g defines the green component
  56168. * @param b defines the blue component
  56169. * @param a defines the alpha component
  56170. */
  56171. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  56172. /**
  56173. * Sets the current alpha mode
  56174. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  56175. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56176. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56177. */
  56178. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56179. /**
  56180. * Gets the current alpha mode
  56181. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56182. * @returns the current alpha mode
  56183. */
  56184. getAlphaMode(): number;
  56185. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  56186. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56187. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56188. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56189. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56190. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56191. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56192. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56193. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56194. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56195. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56196. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56197. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56198. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56199. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56200. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56201. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56202. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56203. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56204. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56205. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  56206. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  56207. wipeCaches(bruteForce?: boolean): void;
  56208. _createTexture(): WebGLTexture;
  56209. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  56210. /**
  56211. * Update the content of a dynamic texture
  56212. * @param texture defines the texture to update
  56213. * @param canvas defines the canvas containing the source
  56214. * @param invertY defines if data must be stored with Y axis inverted
  56215. * @param premulAlpha defines if alpha is stored as premultiplied
  56216. * @param format defines the format of the data
  56217. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56218. */
  56219. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56220. /**
  56221. * Usually called from Texture.ts.
  56222. * Passed information to create a WebGLTexture
  56223. * @param url defines a value which contains one of the following:
  56224. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56225. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56226. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56227. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56228. * @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)
  56229. * @param scene needed for loading to the correct scene
  56230. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56231. * @param onLoad optional callback to be called upon successful completion
  56232. * @param onError optional callback to be called upon failure
  56233. * @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
  56234. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56235. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56236. * @param forcedExtension defines the extension to use to pick the right loader
  56237. * @param mimeType defines an optional mime type
  56238. * @param loaderOptions options to be passed to the loader
  56239. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56240. */
  56241. 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;
  56242. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  56243. _releaseFramebufferObjects(texture: InternalTexture): void;
  56244. /**
  56245. * Creates a cube texture
  56246. * @param rootUrl defines the url where the files to load is located
  56247. * @param scene defines the current scene
  56248. * @param files defines the list of files to load (1 per face)
  56249. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  56250. * @param onLoad defines an optional callback raised when the texture is loaded
  56251. * @param onError defines an optional callback raised if there is an issue to load the texture
  56252. * @param format defines the format of the data
  56253. * @param forcedExtension defines the extension to use to pick the right loader
  56254. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  56255. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56256. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56257. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  56258. * @returns the cube texture as an InternalTexture
  56259. */
  56260. 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;
  56261. createRenderTargetTexture(size: number | {
  56262. width: number;
  56263. height: number;
  56264. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  56265. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56266. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56267. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56268. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  56269. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  56270. /**
  56271. * Updates a dynamic vertex buffer.
  56272. * @param vertexBuffer the vertex buffer to update
  56273. * @param data the data used to update the vertex buffer
  56274. * @param byteOffset the byte offset of the data (optional)
  56275. * @param byteLength the byte length of the data (optional)
  56276. */
  56277. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  56278. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  56279. private _updateAnisotropicLevel;
  56280. private _getAddressMode;
  56281. /** @hidden */
  56282. _bindTexture(channel: number, texture: InternalTexture): void;
  56283. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  56284. releaseEffects(): void;
  56285. /** @hidden */
  56286. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56287. /** @hidden */
  56288. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56289. /** @hidden */
  56290. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56291. /** @hidden */
  56292. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56293. private _getNativeSamplingMode;
  56294. private _getNativeTextureFormat;
  56295. private _getNativeAlphaMode;
  56296. private _getNativeAttribType;
  56297. }
  56298. }
  56299. declare module BABYLON {
  56300. /**
  56301. * Gather the list of clipboard event types as constants.
  56302. */
  56303. export class ClipboardEventTypes {
  56304. /**
  56305. * The clipboard event is fired when a copy command is active (pressed).
  56306. */
  56307. static readonly COPY: number;
  56308. /**
  56309. * The clipboard event is fired when a cut command is active (pressed).
  56310. */
  56311. static readonly CUT: number;
  56312. /**
  56313. * The clipboard event is fired when a paste command is active (pressed).
  56314. */
  56315. static readonly PASTE: number;
  56316. }
  56317. /**
  56318. * This class is used to store clipboard related info for the onClipboardObservable event.
  56319. */
  56320. export class ClipboardInfo {
  56321. /**
  56322. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56323. */
  56324. type: number;
  56325. /**
  56326. * Defines the related dom event
  56327. */
  56328. event: ClipboardEvent;
  56329. /**
  56330. *Creates an instance of ClipboardInfo.
  56331. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  56332. * @param event Defines the related dom event
  56333. */
  56334. constructor(
  56335. /**
  56336. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56337. */
  56338. type: number,
  56339. /**
  56340. * Defines the related dom event
  56341. */
  56342. event: ClipboardEvent);
  56343. /**
  56344. * Get the clipboard event's type from the keycode.
  56345. * @param keyCode Defines the keyCode for the current keyboard event.
  56346. * @return {number}
  56347. */
  56348. static GetTypeFromCharacter(keyCode: number): number;
  56349. }
  56350. }
  56351. declare module BABYLON {
  56352. /**
  56353. * Google Daydream controller
  56354. */
  56355. export class DaydreamController extends WebVRController {
  56356. /**
  56357. * Base Url for the controller model.
  56358. */
  56359. static MODEL_BASE_URL: string;
  56360. /**
  56361. * File name for the controller model.
  56362. */
  56363. static MODEL_FILENAME: string;
  56364. /**
  56365. * Gamepad Id prefix used to identify Daydream Controller.
  56366. */
  56367. static readonly GAMEPAD_ID_PREFIX: string;
  56368. /**
  56369. * Creates a new DaydreamController from a gamepad
  56370. * @param vrGamepad the gamepad that the controller should be created from
  56371. */
  56372. constructor(vrGamepad: any);
  56373. /**
  56374. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56375. * @param scene scene in which to add meshes
  56376. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56377. */
  56378. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56379. /**
  56380. * Called once for each button that changed state since the last frame
  56381. * @param buttonIdx Which button index changed
  56382. * @param state New state of the button
  56383. * @param changes Which properties on the state changed since last frame
  56384. */
  56385. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56386. }
  56387. }
  56388. declare module BABYLON {
  56389. /**
  56390. * Gear VR Controller
  56391. */
  56392. export class GearVRController extends WebVRController {
  56393. /**
  56394. * Base Url for the controller model.
  56395. */
  56396. static MODEL_BASE_URL: string;
  56397. /**
  56398. * File name for the controller model.
  56399. */
  56400. static MODEL_FILENAME: string;
  56401. /**
  56402. * Gamepad Id prefix used to identify this controller.
  56403. */
  56404. static readonly GAMEPAD_ID_PREFIX: string;
  56405. private readonly _buttonIndexToObservableNameMap;
  56406. /**
  56407. * Creates a new GearVRController from a gamepad
  56408. * @param vrGamepad the gamepad that the controller should be created from
  56409. */
  56410. constructor(vrGamepad: any);
  56411. /**
  56412. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56413. * @param scene scene in which to add meshes
  56414. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56415. */
  56416. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56417. /**
  56418. * Called once for each button that changed state since the last frame
  56419. * @param buttonIdx Which button index changed
  56420. * @param state New state of the button
  56421. * @param changes Which properties on the state changed since last frame
  56422. */
  56423. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56424. }
  56425. }
  56426. declare module BABYLON {
  56427. /**
  56428. * Generic Controller
  56429. */
  56430. export class GenericController extends WebVRController {
  56431. /**
  56432. * Base Url for the controller model.
  56433. */
  56434. static readonly MODEL_BASE_URL: string;
  56435. /**
  56436. * File name for the controller model.
  56437. */
  56438. static readonly MODEL_FILENAME: string;
  56439. /**
  56440. * Creates a new GenericController from a gamepad
  56441. * @param vrGamepad the gamepad that the controller should be created from
  56442. */
  56443. constructor(vrGamepad: any);
  56444. /**
  56445. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56446. * @param scene scene in which to add meshes
  56447. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56448. */
  56449. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56450. /**
  56451. * Called once for each button that changed state since the last frame
  56452. * @param buttonIdx Which button index changed
  56453. * @param state New state of the button
  56454. * @param changes Which properties on the state changed since last frame
  56455. */
  56456. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56457. }
  56458. }
  56459. declare module BABYLON {
  56460. /**
  56461. * Oculus Touch Controller
  56462. */
  56463. export class OculusTouchController extends WebVRController {
  56464. /**
  56465. * Base Url for the controller model.
  56466. */
  56467. static MODEL_BASE_URL: string;
  56468. /**
  56469. * File name for the left controller model.
  56470. */
  56471. static MODEL_LEFT_FILENAME: string;
  56472. /**
  56473. * File name for the right controller model.
  56474. */
  56475. static MODEL_RIGHT_FILENAME: string;
  56476. /**
  56477. * Base Url for the Quest controller model.
  56478. */
  56479. static QUEST_MODEL_BASE_URL: string;
  56480. /**
  56481. * @hidden
  56482. * If the controllers are running on a device that needs the updated Quest controller models
  56483. */
  56484. static _IsQuest: boolean;
  56485. /**
  56486. * Fired when the secondary trigger on this controller is modified
  56487. */
  56488. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  56489. /**
  56490. * Fired when the thumb rest on this controller is modified
  56491. */
  56492. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  56493. /**
  56494. * Creates a new OculusTouchController 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. * Fired when the A button on this controller is modified
  56506. */
  56507. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56508. /**
  56509. * Fired when the B button on this controller is modified
  56510. */
  56511. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56512. /**
  56513. * Fired when the X button on this controller is modified
  56514. */
  56515. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56516. /**
  56517. * Fired when the Y button on this controller is modified
  56518. */
  56519. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56520. /**
  56521. * Called once for each button that changed state since the last frame
  56522. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  56523. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  56524. * 2) secondary trigger (same)
  56525. * 3) A (right) X (left), touch, pressed = value
  56526. * 4) B / Y
  56527. * 5) thumb rest
  56528. * @param buttonIdx Which button index changed
  56529. * @param state New state of the button
  56530. * @param changes Which properties on the state changed since last frame
  56531. */
  56532. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56533. }
  56534. }
  56535. declare module BABYLON {
  56536. /**
  56537. * Vive Controller
  56538. */
  56539. export class ViveController extends WebVRController {
  56540. /**
  56541. * Base Url for the controller model.
  56542. */
  56543. static MODEL_BASE_URL: string;
  56544. /**
  56545. * File name for the controller model.
  56546. */
  56547. static MODEL_FILENAME: string;
  56548. /**
  56549. * Creates a new ViveController from a gamepad
  56550. * @param vrGamepad the gamepad that the controller should be created from
  56551. */
  56552. constructor(vrGamepad: any);
  56553. /**
  56554. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56555. * @param scene scene in which to add meshes
  56556. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56557. */
  56558. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56559. /**
  56560. * Fired when the left button on this controller is modified
  56561. */
  56562. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56563. /**
  56564. * Fired when the right button on this controller is modified
  56565. */
  56566. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56567. /**
  56568. * Fired when the menu button on this controller is modified
  56569. */
  56570. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56571. /**
  56572. * Called once for each button that changed state since the last frame
  56573. * Vive mapping:
  56574. * 0: touchpad
  56575. * 1: trigger
  56576. * 2: left AND right buttons
  56577. * 3: menu button
  56578. * @param buttonIdx Which button index changed
  56579. * @param state New state of the button
  56580. * @param changes Which properties on the state changed since last frame
  56581. */
  56582. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56583. }
  56584. }
  56585. declare module BABYLON {
  56586. /**
  56587. * Defines the WindowsMotionController object that the state of the windows motion controller
  56588. */
  56589. export class WindowsMotionController extends WebVRController {
  56590. /**
  56591. * The base url used to load the left and right controller models
  56592. */
  56593. static MODEL_BASE_URL: string;
  56594. /**
  56595. * The name of the left controller model file
  56596. */
  56597. static MODEL_LEFT_FILENAME: string;
  56598. /**
  56599. * The name of the right controller model file
  56600. */
  56601. static MODEL_RIGHT_FILENAME: string;
  56602. /**
  56603. * The controller name prefix for this controller type
  56604. */
  56605. static readonly GAMEPAD_ID_PREFIX: string;
  56606. /**
  56607. * The controller id pattern for this controller type
  56608. */
  56609. private static readonly GAMEPAD_ID_PATTERN;
  56610. private _loadedMeshInfo;
  56611. protected readonly _mapping: {
  56612. buttons: string[];
  56613. buttonMeshNames: {
  56614. trigger: string;
  56615. menu: string;
  56616. grip: string;
  56617. thumbstick: string;
  56618. trackpad: string;
  56619. };
  56620. buttonObservableNames: {
  56621. trigger: string;
  56622. menu: string;
  56623. grip: string;
  56624. thumbstick: string;
  56625. trackpad: string;
  56626. };
  56627. axisMeshNames: string[];
  56628. pointingPoseMeshName: string;
  56629. };
  56630. /**
  56631. * Fired when the trackpad on this controller is clicked
  56632. */
  56633. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56634. /**
  56635. * Fired when the trackpad on this controller is modified
  56636. */
  56637. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56638. /**
  56639. * The current x and y values of this controller's trackpad
  56640. */
  56641. trackpad: StickValues;
  56642. /**
  56643. * Creates a new WindowsMotionController from a gamepad
  56644. * @param vrGamepad the gamepad that the controller should be created from
  56645. */
  56646. constructor(vrGamepad: any);
  56647. /**
  56648. * Fired when the trigger on this controller is modified
  56649. */
  56650. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56651. /**
  56652. * Fired when the menu button on this controller is modified
  56653. */
  56654. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56655. /**
  56656. * Fired when the grip button on this controller is modified
  56657. */
  56658. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56659. /**
  56660. * Fired when the thumbstick button on this controller is modified
  56661. */
  56662. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56663. /**
  56664. * Fired when the touchpad button on this controller is modified
  56665. */
  56666. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56667. /**
  56668. * Fired when the touchpad values on this controller are modified
  56669. */
  56670. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  56671. protected _updateTrackpad(): void;
  56672. /**
  56673. * Called once per frame by the engine.
  56674. */
  56675. update(): void;
  56676. /**
  56677. * Called once for each button that changed state since the last frame
  56678. * @param buttonIdx Which button index changed
  56679. * @param state New state of the button
  56680. * @param changes Which properties on the state changed since last frame
  56681. */
  56682. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56683. /**
  56684. * Moves the buttons on the controller mesh based on their current state
  56685. * @param buttonName the name of the button to move
  56686. * @param buttonValue the value of the button which determines the buttons new position
  56687. */
  56688. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  56689. /**
  56690. * Moves the axis on the controller mesh based on its current state
  56691. * @param axis the index of the axis
  56692. * @param axisValue the value of the axis which determines the meshes new position
  56693. * @hidden
  56694. */
  56695. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  56696. /**
  56697. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56698. * @param scene scene in which to add meshes
  56699. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56700. */
  56701. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  56702. /**
  56703. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  56704. * can be transformed by button presses and axes values, based on this._mapping.
  56705. *
  56706. * @param scene scene in which the meshes exist
  56707. * @param meshes list of meshes that make up the controller model to process
  56708. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  56709. */
  56710. private processModel;
  56711. private createMeshInfo;
  56712. /**
  56713. * Gets the ray of the controller in the direction the controller is pointing
  56714. * @param length the length the resulting ray should be
  56715. * @returns a ray in the direction the controller is pointing
  56716. */
  56717. getForwardRay(length?: number): Ray;
  56718. /**
  56719. * Disposes of the controller
  56720. */
  56721. dispose(): void;
  56722. }
  56723. /**
  56724. * This class represents a new windows motion controller in XR.
  56725. */
  56726. export class XRWindowsMotionController extends WindowsMotionController {
  56727. /**
  56728. * Changing the original WIndowsMotionController mapping to fir the new mapping
  56729. */
  56730. protected readonly _mapping: {
  56731. buttons: string[];
  56732. buttonMeshNames: {
  56733. trigger: string;
  56734. menu: string;
  56735. grip: string;
  56736. thumbstick: string;
  56737. trackpad: string;
  56738. };
  56739. buttonObservableNames: {
  56740. trigger: string;
  56741. menu: string;
  56742. grip: string;
  56743. thumbstick: string;
  56744. trackpad: string;
  56745. };
  56746. axisMeshNames: string[];
  56747. pointingPoseMeshName: string;
  56748. };
  56749. /**
  56750. * Construct a new XR-Based windows motion controller
  56751. *
  56752. * @param gamepadInfo the gamepad object from the browser
  56753. */
  56754. constructor(gamepadInfo: any);
  56755. /**
  56756. * holds the thumbstick values (X,Y)
  56757. */
  56758. thumbstickValues: StickValues;
  56759. /**
  56760. * Fired when the thumbstick on this controller is clicked
  56761. */
  56762. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  56763. /**
  56764. * Fired when the thumbstick on this controller is modified
  56765. */
  56766. onThumbstickValuesChangedObservable: Observable<StickValues>;
  56767. /**
  56768. * Fired when the touchpad button on this controller is modified
  56769. */
  56770. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56771. /**
  56772. * Fired when the touchpad values on this controller are modified
  56773. */
  56774. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56775. /**
  56776. * Fired when the thumbstick button on this controller is modified
  56777. * here to prevent breaking changes
  56778. */
  56779. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56780. /**
  56781. * updating the thumbstick(!) and not the trackpad.
  56782. * This is named this way due to the difference between WebVR and XR and to avoid
  56783. * changing the parent class.
  56784. */
  56785. protected _updateTrackpad(): void;
  56786. /**
  56787. * Disposes the class with joy
  56788. */
  56789. dispose(): void;
  56790. }
  56791. }
  56792. declare module BABYLON {
  56793. /**
  56794. * Class containing static functions to help procedurally build meshes
  56795. */
  56796. export class PolyhedronBuilder {
  56797. /**
  56798. * Creates a polyhedron mesh
  56799. * * 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
  56800. * * The parameter `size` (positive float, default 1) sets the polygon size
  56801. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56802. * * 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`
  56803. * * 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
  56804. * * 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)`)
  56805. * * 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
  56806. * * 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
  56807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56808. * * 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
  56809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56810. * @param name defines the name of the mesh
  56811. * @param options defines the options used to create the mesh
  56812. * @param scene defines the hosting scene
  56813. * @returns the polyhedron mesh
  56814. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56815. */
  56816. static CreatePolyhedron(name: string, options: {
  56817. type?: number;
  56818. size?: number;
  56819. sizeX?: number;
  56820. sizeY?: number;
  56821. sizeZ?: number;
  56822. custom?: any;
  56823. faceUV?: Vector4[];
  56824. faceColors?: Color4[];
  56825. flat?: boolean;
  56826. updatable?: boolean;
  56827. sideOrientation?: number;
  56828. frontUVs?: Vector4;
  56829. backUVs?: Vector4;
  56830. }, scene?: Nullable<Scene>): Mesh;
  56831. }
  56832. }
  56833. declare module BABYLON {
  56834. /**
  56835. * Gizmo that enables scaling a mesh along 3 axis
  56836. */
  56837. export class ScaleGizmo extends Gizmo {
  56838. /**
  56839. * Internal gizmo used for interactions on the x axis
  56840. */
  56841. xGizmo: AxisScaleGizmo;
  56842. /**
  56843. * Internal gizmo used for interactions on the y axis
  56844. */
  56845. yGizmo: AxisScaleGizmo;
  56846. /**
  56847. * Internal gizmo used for interactions on the z axis
  56848. */
  56849. zGizmo: AxisScaleGizmo;
  56850. /**
  56851. * Internal gizmo used to scale all axis equally
  56852. */
  56853. uniformScaleGizmo: AxisScaleGizmo;
  56854. private _meshAttached;
  56855. private _nodeAttached;
  56856. private _snapDistance;
  56857. private _uniformScalingMesh;
  56858. private _octahedron;
  56859. private _sensitivity;
  56860. /** Fires an event when any of it's sub gizmos are dragged */
  56861. onDragStartObservable: Observable<unknown>;
  56862. /** Fires an event when any of it's sub gizmos are released from dragging */
  56863. onDragEndObservable: Observable<unknown>;
  56864. get attachedMesh(): Nullable<AbstractMesh>;
  56865. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56866. get attachedNode(): Nullable<Node>;
  56867. set attachedNode(node: Nullable<Node>);
  56868. /**
  56869. * True when the mouse pointer is hovering a gizmo mesh
  56870. */
  56871. get isHovered(): boolean;
  56872. /**
  56873. * Creates a ScaleGizmo
  56874. * @param gizmoLayer The utility layer the gizmo will be added to
  56875. * @param thickness display gizmo axis thickness
  56876. */
  56877. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56878. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56879. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56880. /**
  56881. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56882. */
  56883. set snapDistance(value: number);
  56884. get snapDistance(): number;
  56885. /**
  56886. * Ratio for the scale of the gizmo (Default: 1)
  56887. */
  56888. set scaleRatio(value: number);
  56889. get scaleRatio(): number;
  56890. /**
  56891. * Sensitivity factor for dragging (Default: 1)
  56892. */
  56893. set sensitivity(value: number);
  56894. get sensitivity(): number;
  56895. /**
  56896. * Disposes of the gizmo
  56897. */
  56898. dispose(): void;
  56899. }
  56900. }
  56901. declare module BABYLON {
  56902. /**
  56903. * Single axis scale gizmo
  56904. */
  56905. export class AxisScaleGizmo extends Gizmo {
  56906. /**
  56907. * Drag behavior responsible for the gizmos dragging interactions
  56908. */
  56909. dragBehavior: PointerDragBehavior;
  56910. private _pointerObserver;
  56911. /**
  56912. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56913. */
  56914. snapDistance: number;
  56915. /**
  56916. * Event that fires each time the gizmo snaps to a new location.
  56917. * * snapDistance is the the change in distance
  56918. */
  56919. onSnapObservable: Observable<{
  56920. snapDistance: number;
  56921. }>;
  56922. /**
  56923. * If the scaling operation should be done on all axis (default: false)
  56924. */
  56925. uniformScaling: boolean;
  56926. /**
  56927. * Custom sensitivity value for the drag strength
  56928. */
  56929. sensitivity: number;
  56930. private _isEnabled;
  56931. private _parent;
  56932. private _arrow;
  56933. private _coloredMaterial;
  56934. private _hoverMaterial;
  56935. /**
  56936. * Creates an AxisScaleGizmo
  56937. * @param gizmoLayer The utility layer the gizmo will be added to
  56938. * @param dragAxis The axis which the gizmo will be able to scale on
  56939. * @param color The color of the gizmo
  56940. * @param thickness display gizmo axis thickness
  56941. */
  56942. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56943. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56944. /**
  56945. * If the gizmo is enabled
  56946. */
  56947. set isEnabled(value: boolean);
  56948. get isEnabled(): boolean;
  56949. /**
  56950. * Disposes of the gizmo
  56951. */
  56952. dispose(): void;
  56953. /**
  56954. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56955. * @param mesh The mesh to replace the default mesh of the gizmo
  56956. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56957. */
  56958. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56959. }
  56960. }
  56961. declare module BABYLON {
  56962. /**
  56963. * Bounding box gizmo
  56964. */
  56965. export class BoundingBoxGizmo extends Gizmo {
  56966. private _lineBoundingBox;
  56967. private _rotateSpheresParent;
  56968. private _scaleBoxesParent;
  56969. private _boundingDimensions;
  56970. private _renderObserver;
  56971. private _pointerObserver;
  56972. private _scaleDragSpeed;
  56973. private _tmpQuaternion;
  56974. private _tmpVector;
  56975. private _tmpRotationMatrix;
  56976. /**
  56977. * 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)
  56978. */
  56979. ignoreChildren: boolean;
  56980. /**
  56981. * 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)
  56982. */
  56983. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56984. /**
  56985. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56986. */
  56987. rotationSphereSize: number;
  56988. /**
  56989. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56990. */
  56991. scaleBoxSize: number;
  56992. /**
  56993. * 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)
  56994. */
  56995. fixedDragMeshScreenSize: boolean;
  56996. /**
  56997. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56998. */
  56999. fixedDragMeshScreenSizeDistanceFactor: number;
  57000. /**
  57001. * Fired when a rotation sphere or scale box is dragged
  57002. */
  57003. onDragStartObservable: Observable<{}>;
  57004. /**
  57005. * Fired when a scale box is dragged
  57006. */
  57007. onScaleBoxDragObservable: Observable<{}>;
  57008. /**
  57009. * Fired when a scale box drag is ended
  57010. */
  57011. onScaleBoxDragEndObservable: Observable<{}>;
  57012. /**
  57013. * Fired when a rotation sphere is dragged
  57014. */
  57015. onRotationSphereDragObservable: Observable<{}>;
  57016. /**
  57017. * Fired when a rotation sphere drag is ended
  57018. */
  57019. onRotationSphereDragEndObservable: Observable<{}>;
  57020. /**
  57021. * 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)
  57022. */
  57023. scalePivot: Nullable<Vector3>;
  57024. /**
  57025. * Mesh used as a pivot to rotate the attached node
  57026. */
  57027. private _anchorMesh;
  57028. private _existingMeshScale;
  57029. private _dragMesh;
  57030. private pointerDragBehavior;
  57031. private coloredMaterial;
  57032. private hoverColoredMaterial;
  57033. /**
  57034. * Sets the color of the bounding box gizmo
  57035. * @param color the color to set
  57036. */
  57037. setColor(color: Color3): void;
  57038. /**
  57039. * Creates an BoundingBoxGizmo
  57040. * @param gizmoLayer The utility layer the gizmo will be added to
  57041. * @param color The color of the gizmo
  57042. */
  57043. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57044. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57045. private _selectNode;
  57046. /**
  57047. * Updates the bounding box information for the Gizmo
  57048. */
  57049. updateBoundingBox(): void;
  57050. private _updateRotationSpheres;
  57051. private _updateScaleBoxes;
  57052. /**
  57053. * Enables rotation on the specified axis and disables rotation on the others
  57054. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57055. */
  57056. setEnabledRotationAxis(axis: string): void;
  57057. /**
  57058. * Enables/disables scaling
  57059. * @param enable if scaling should be enabled
  57060. * @param homogeneousScaling defines if scaling should only be homogeneous
  57061. */
  57062. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57063. private _updateDummy;
  57064. /**
  57065. * Enables a pointer drag behavior on the bounding box of the gizmo
  57066. */
  57067. enableDragBehavior(): void;
  57068. /**
  57069. * Disposes of the gizmo
  57070. */
  57071. dispose(): void;
  57072. /**
  57073. * 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)
  57074. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57075. * @returns the bounding box mesh with the passed in mesh as a child
  57076. */
  57077. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57078. /**
  57079. * CustomMeshes are not supported by this gizmo
  57080. * @param mesh The mesh to replace the default mesh of the gizmo
  57081. */
  57082. setCustomMesh(mesh: Mesh): void;
  57083. }
  57084. }
  57085. declare module BABYLON {
  57086. /**
  57087. * Single plane rotation gizmo
  57088. */
  57089. export class PlaneRotationGizmo extends Gizmo {
  57090. /**
  57091. * Drag behavior responsible for the gizmos dragging interactions
  57092. */
  57093. dragBehavior: PointerDragBehavior;
  57094. private _pointerObserver;
  57095. /**
  57096. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57097. */
  57098. snapDistance: number;
  57099. /**
  57100. * Event that fires each time the gizmo snaps to a new location.
  57101. * * snapDistance is the the change in distance
  57102. */
  57103. onSnapObservable: Observable<{
  57104. snapDistance: number;
  57105. }>;
  57106. private _isEnabled;
  57107. private _parent;
  57108. /**
  57109. * Creates a PlaneRotationGizmo
  57110. * @param gizmoLayer The utility layer the gizmo will be added to
  57111. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57112. * @param color The color of the gizmo
  57113. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57114. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57115. * @param thickness display gizmo axis thickness
  57116. */
  57117. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57118. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57119. /**
  57120. * If the gizmo is enabled
  57121. */
  57122. set isEnabled(value: boolean);
  57123. get isEnabled(): boolean;
  57124. /**
  57125. * Disposes of the gizmo
  57126. */
  57127. dispose(): void;
  57128. }
  57129. }
  57130. declare module BABYLON {
  57131. /**
  57132. * Gizmo that enables rotating a mesh along 3 axis
  57133. */
  57134. export class RotationGizmo extends Gizmo {
  57135. /**
  57136. * Internal gizmo used for interactions on the x axis
  57137. */
  57138. xGizmo: PlaneRotationGizmo;
  57139. /**
  57140. * Internal gizmo used for interactions on the y axis
  57141. */
  57142. yGizmo: PlaneRotationGizmo;
  57143. /**
  57144. * Internal gizmo used for interactions on the z axis
  57145. */
  57146. zGizmo: PlaneRotationGizmo;
  57147. /** Fires an event when any of it's sub gizmos are dragged */
  57148. onDragStartObservable: Observable<unknown>;
  57149. /** Fires an event when any of it's sub gizmos are released from dragging */
  57150. onDragEndObservable: Observable<unknown>;
  57151. private _meshAttached;
  57152. private _nodeAttached;
  57153. get attachedMesh(): Nullable<AbstractMesh>;
  57154. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57155. get attachedNode(): Nullable<Node>;
  57156. set attachedNode(node: Nullable<Node>);
  57157. protected _checkBillboardTransform(): void;
  57158. /**
  57159. * True when the mouse pointer is hovering a gizmo mesh
  57160. */
  57161. get isHovered(): boolean;
  57162. /**
  57163. * Creates a RotationGizmo
  57164. * @param gizmoLayer The utility layer the gizmo will be added to
  57165. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57166. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57167. * @param thickness display gizmo axis thickness
  57168. */
  57169. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  57170. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57171. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57172. /**
  57173. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57174. */
  57175. set snapDistance(value: number);
  57176. get snapDistance(): number;
  57177. /**
  57178. * Ratio for the scale of the gizmo (Default: 1)
  57179. */
  57180. set scaleRatio(value: number);
  57181. get scaleRatio(): number;
  57182. /**
  57183. * Disposes of the gizmo
  57184. */
  57185. dispose(): void;
  57186. /**
  57187. * CustomMeshes are not supported by this gizmo
  57188. * @param mesh The mesh to replace the default mesh of the gizmo
  57189. */
  57190. setCustomMesh(mesh: Mesh): void;
  57191. }
  57192. }
  57193. declare module BABYLON {
  57194. /**
  57195. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57196. */
  57197. export class GizmoManager implements IDisposable {
  57198. private scene;
  57199. /**
  57200. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57201. */
  57202. gizmos: {
  57203. positionGizmo: Nullable<PositionGizmo>;
  57204. rotationGizmo: Nullable<RotationGizmo>;
  57205. scaleGizmo: Nullable<ScaleGizmo>;
  57206. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57207. };
  57208. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57209. clearGizmoOnEmptyPointerEvent: boolean;
  57210. /** Fires an event when the manager is attached to a mesh */
  57211. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57212. /** Fires an event when the manager is attached to a node */
  57213. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57214. private _gizmosEnabled;
  57215. private _pointerObserver;
  57216. private _attachedMesh;
  57217. private _attachedNode;
  57218. private _boundingBoxColor;
  57219. private _defaultUtilityLayer;
  57220. private _defaultKeepDepthUtilityLayer;
  57221. private _thickness;
  57222. /**
  57223. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57224. */
  57225. boundingBoxDragBehavior: SixDofDragBehavior;
  57226. /**
  57227. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57228. */
  57229. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57230. /**
  57231. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57232. */
  57233. attachableNodes: Nullable<Array<Node>>;
  57234. /**
  57235. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57236. */
  57237. usePointerToAttachGizmos: boolean;
  57238. /**
  57239. * Utility layer that the bounding box gizmo belongs to
  57240. */
  57241. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57242. /**
  57243. * Utility layer that all gizmos besides bounding box belong to
  57244. */
  57245. get utilityLayer(): UtilityLayerRenderer;
  57246. /**
  57247. * True when the mouse pointer is hovering a gizmo mesh
  57248. */
  57249. get isHovered(): boolean;
  57250. /**
  57251. * Instatiates a gizmo manager
  57252. * @param scene the scene to overlay the gizmos on top of
  57253. * @param thickness display gizmo axis thickness
  57254. */
  57255. constructor(scene: Scene, thickness?: number);
  57256. /**
  57257. * Attaches a set of gizmos to the specified mesh
  57258. * @param mesh The mesh the gizmo's should be attached to
  57259. */
  57260. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57261. /**
  57262. * Attaches a set of gizmos to the specified node
  57263. * @param node The node the gizmo's should be attached to
  57264. */
  57265. attachToNode(node: Nullable<Node>): void;
  57266. /**
  57267. * If the position gizmo is enabled
  57268. */
  57269. set positionGizmoEnabled(value: boolean);
  57270. get positionGizmoEnabled(): boolean;
  57271. /**
  57272. * If the rotation gizmo is enabled
  57273. */
  57274. set rotationGizmoEnabled(value: boolean);
  57275. get rotationGizmoEnabled(): boolean;
  57276. /**
  57277. * If the scale gizmo is enabled
  57278. */
  57279. set scaleGizmoEnabled(value: boolean);
  57280. get scaleGizmoEnabled(): boolean;
  57281. /**
  57282. * If the boundingBox gizmo is enabled
  57283. */
  57284. set boundingBoxGizmoEnabled(value: boolean);
  57285. get boundingBoxGizmoEnabled(): boolean;
  57286. /**
  57287. * Disposes of the gizmo manager
  57288. */
  57289. dispose(): void;
  57290. }
  57291. }
  57292. declare module BABYLON {
  57293. /**
  57294. * A directional light is defined by a direction (what a surprise!).
  57295. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57296. * 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.
  57297. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57298. */
  57299. export class DirectionalLight extends ShadowLight {
  57300. private _shadowFrustumSize;
  57301. /**
  57302. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57303. */
  57304. get shadowFrustumSize(): number;
  57305. /**
  57306. * Specifies a fix frustum size for the shadow generation.
  57307. */
  57308. set shadowFrustumSize(value: number);
  57309. private _shadowOrthoScale;
  57310. /**
  57311. * Gets the shadow projection scale against the optimal computed one.
  57312. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57313. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57314. */
  57315. get shadowOrthoScale(): number;
  57316. /**
  57317. * Sets the shadow projection scale against the optimal computed one.
  57318. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57319. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57320. */
  57321. set shadowOrthoScale(value: number);
  57322. /**
  57323. * Automatically compute the projection matrix to best fit (including all the casters)
  57324. * on each frame.
  57325. */
  57326. autoUpdateExtends: boolean;
  57327. /**
  57328. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57329. * on each frame. autoUpdateExtends must be set to true for this to work
  57330. */
  57331. autoCalcShadowZBounds: boolean;
  57332. private _orthoLeft;
  57333. private _orthoRight;
  57334. private _orthoTop;
  57335. private _orthoBottom;
  57336. /**
  57337. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57338. * The directional light is emitted from everywhere in the given direction.
  57339. * It can cast shadows.
  57340. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57341. * @param name The friendly name of the light
  57342. * @param direction The direction of the light
  57343. * @param scene The scene the light belongs to
  57344. */
  57345. constructor(name: string, direction: Vector3, scene: Scene);
  57346. /**
  57347. * Returns the string "DirectionalLight".
  57348. * @return The class name
  57349. */
  57350. getClassName(): string;
  57351. /**
  57352. * Returns the integer 1.
  57353. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57354. */
  57355. getTypeID(): number;
  57356. /**
  57357. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57358. * Returns the DirectionalLight Shadow projection matrix.
  57359. */
  57360. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57361. /**
  57362. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57363. * Returns the DirectionalLight Shadow projection matrix.
  57364. */
  57365. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57366. /**
  57367. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57368. * Returns the DirectionalLight Shadow projection matrix.
  57369. */
  57370. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57371. protected _buildUniformLayout(): void;
  57372. /**
  57373. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57374. * @param effect The effect to update
  57375. * @param lightIndex The index of the light in the effect to update
  57376. * @returns The directional light
  57377. */
  57378. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57379. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57380. /**
  57381. * Gets the minZ used for shadow according to both the scene and the light.
  57382. *
  57383. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57384. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57385. * @param activeCamera The camera we are returning the min for
  57386. * @returns the depth min z
  57387. */
  57388. getDepthMinZ(activeCamera: Camera): number;
  57389. /**
  57390. * Gets the maxZ used for shadow according to both the scene and the light.
  57391. *
  57392. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57393. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57394. * @param activeCamera The camera we are returning the max for
  57395. * @returns the depth max z
  57396. */
  57397. getDepthMaxZ(activeCamera: Camera): number;
  57398. /**
  57399. * Prepares the list of defines specific to the light type.
  57400. * @param defines the list of defines
  57401. * @param lightIndex defines the index of the light for the effect
  57402. */
  57403. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57404. }
  57405. }
  57406. declare module BABYLON {
  57407. /**
  57408. * Class containing static functions to help procedurally build meshes
  57409. */
  57410. export class HemisphereBuilder {
  57411. /**
  57412. * Creates a hemisphere mesh
  57413. * @param name defines the name of the mesh
  57414. * @param options defines the options used to create the mesh
  57415. * @param scene defines the hosting scene
  57416. * @returns the hemisphere mesh
  57417. */
  57418. static CreateHemisphere(name: string, options: {
  57419. segments?: number;
  57420. diameter?: number;
  57421. sideOrientation?: number;
  57422. }, scene: any): Mesh;
  57423. }
  57424. }
  57425. declare module BABYLON {
  57426. /**
  57427. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57428. * These values define a cone of light starting from the position, emitting toward the direction.
  57429. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57430. * and the exponent defines the speed of the decay of the light with distance (reach).
  57431. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57432. */
  57433. export class SpotLight extends ShadowLight {
  57434. private _angle;
  57435. private _innerAngle;
  57436. private _cosHalfAngle;
  57437. private _lightAngleScale;
  57438. private _lightAngleOffset;
  57439. /**
  57440. * Gets the cone angle of the spot light in Radians.
  57441. */
  57442. get angle(): number;
  57443. /**
  57444. * Sets the cone angle of the spot light in Radians.
  57445. */
  57446. set angle(value: number);
  57447. /**
  57448. * Only used in gltf falloff mode, this defines the angle where
  57449. * the directional falloff will start before cutting at angle which could be seen
  57450. * as outer angle.
  57451. */
  57452. get innerAngle(): number;
  57453. /**
  57454. * Only used in gltf falloff mode, this defines the angle where
  57455. * the directional falloff will start before cutting at angle which could be seen
  57456. * as outer angle.
  57457. */
  57458. set innerAngle(value: number);
  57459. private _shadowAngleScale;
  57460. /**
  57461. * Allows scaling the angle of the light for shadow generation only.
  57462. */
  57463. get shadowAngleScale(): number;
  57464. /**
  57465. * Allows scaling the angle of the light for shadow generation only.
  57466. */
  57467. set shadowAngleScale(value: number);
  57468. /**
  57469. * The light decay speed with the distance from the emission spot.
  57470. */
  57471. exponent: number;
  57472. private _projectionTextureMatrix;
  57473. /**
  57474. * Allows reading the projecton texture
  57475. */
  57476. get projectionTextureMatrix(): Matrix;
  57477. protected _projectionTextureLightNear: number;
  57478. /**
  57479. * Gets the near clip of the Spotlight for texture projection.
  57480. */
  57481. get projectionTextureLightNear(): number;
  57482. /**
  57483. * Sets the near clip of the Spotlight for texture projection.
  57484. */
  57485. set projectionTextureLightNear(value: number);
  57486. protected _projectionTextureLightFar: number;
  57487. /**
  57488. * Gets the far clip of the Spotlight for texture projection.
  57489. */
  57490. get projectionTextureLightFar(): number;
  57491. /**
  57492. * Sets the far clip of the Spotlight for texture projection.
  57493. */
  57494. set projectionTextureLightFar(value: number);
  57495. protected _projectionTextureUpDirection: Vector3;
  57496. /**
  57497. * Gets the Up vector of the Spotlight for texture projection.
  57498. */
  57499. get projectionTextureUpDirection(): Vector3;
  57500. /**
  57501. * Sets the Up vector of the Spotlight for texture projection.
  57502. */
  57503. set projectionTextureUpDirection(value: Vector3);
  57504. private _projectionTexture;
  57505. /**
  57506. * Gets the projection texture of the light.
  57507. */
  57508. get projectionTexture(): Nullable<BaseTexture>;
  57509. /**
  57510. * Sets the projection texture of the light.
  57511. */
  57512. set projectionTexture(value: Nullable<BaseTexture>);
  57513. private _projectionTextureViewLightDirty;
  57514. private _projectionTextureProjectionLightDirty;
  57515. private _projectionTextureDirty;
  57516. private _projectionTextureViewTargetVector;
  57517. private _projectionTextureViewLightMatrix;
  57518. private _projectionTextureProjectionLightMatrix;
  57519. private _projectionTextureScalingMatrix;
  57520. /**
  57521. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57522. * It can cast shadows.
  57523. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57524. * @param name The light friendly name
  57525. * @param position The position of the spot light in the scene
  57526. * @param direction The direction of the light in the scene
  57527. * @param angle The cone angle of the light in Radians
  57528. * @param exponent The light decay speed with the distance from the emission spot
  57529. * @param scene The scene the lights belongs to
  57530. */
  57531. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  57532. /**
  57533. * Returns the string "SpotLight".
  57534. * @returns the class name
  57535. */
  57536. getClassName(): string;
  57537. /**
  57538. * Returns the integer 2.
  57539. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57540. */
  57541. getTypeID(): number;
  57542. /**
  57543. * Overrides the direction setter to recompute the projection texture view light Matrix.
  57544. */
  57545. protected _setDirection(value: Vector3): void;
  57546. /**
  57547. * Overrides the position setter to recompute the projection texture view light Matrix.
  57548. */
  57549. protected _setPosition(value: Vector3): void;
  57550. /**
  57551. * 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.
  57552. * Returns the SpotLight.
  57553. */
  57554. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57555. protected _computeProjectionTextureViewLightMatrix(): void;
  57556. protected _computeProjectionTextureProjectionLightMatrix(): void;
  57557. /**
  57558. * Main function for light texture projection matrix computing.
  57559. */
  57560. protected _computeProjectionTextureMatrix(): void;
  57561. protected _buildUniformLayout(): void;
  57562. private _computeAngleValues;
  57563. /**
  57564. * Sets the passed Effect "effect" with the Light textures.
  57565. * @param effect The effect to update
  57566. * @param lightIndex The index of the light in the effect to update
  57567. * @returns The light
  57568. */
  57569. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  57570. /**
  57571. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  57572. * @param effect The effect to update
  57573. * @param lightIndex The index of the light in the effect to update
  57574. * @returns The spot light
  57575. */
  57576. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  57577. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57578. /**
  57579. * Disposes the light and the associated resources.
  57580. */
  57581. dispose(): void;
  57582. /**
  57583. * Prepares the list of defines specific to the light type.
  57584. * @param defines the list of defines
  57585. * @param lightIndex defines the index of the light for the effect
  57586. */
  57587. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57588. }
  57589. }
  57590. declare module BABYLON {
  57591. /**
  57592. * Gizmo that enables viewing a light
  57593. */
  57594. export class LightGizmo extends Gizmo {
  57595. private _lightMesh;
  57596. private _material;
  57597. private _cachedPosition;
  57598. private _cachedForward;
  57599. private _attachedMeshParent;
  57600. private _pointerObserver;
  57601. /**
  57602. * Event that fires each time the gizmo is clicked
  57603. */
  57604. onClickedObservable: Observable<Light>;
  57605. /**
  57606. * Creates a LightGizmo
  57607. * @param gizmoLayer The utility layer the gizmo will be added to
  57608. */
  57609. constructor(gizmoLayer?: UtilityLayerRenderer);
  57610. private _light;
  57611. /**
  57612. * The light that the gizmo is attached to
  57613. */
  57614. set light(light: Nullable<Light>);
  57615. get light(): Nullable<Light>;
  57616. /**
  57617. * Gets the material used to render the light gizmo
  57618. */
  57619. get material(): StandardMaterial;
  57620. /**
  57621. * @hidden
  57622. * Updates the gizmo to match the attached mesh's position/rotation
  57623. */
  57624. protected _update(): void;
  57625. private static _Scale;
  57626. /**
  57627. * Creates the lines for a light mesh
  57628. */
  57629. private static _CreateLightLines;
  57630. /**
  57631. * Disposes of the light gizmo
  57632. */
  57633. dispose(): void;
  57634. private static _CreateHemisphericLightMesh;
  57635. private static _CreatePointLightMesh;
  57636. private static _CreateSpotLightMesh;
  57637. private static _CreateDirectionalLightMesh;
  57638. }
  57639. }
  57640. declare module BABYLON {
  57641. /**
  57642. * Gizmo that enables viewing a camera
  57643. */
  57644. export class CameraGizmo extends Gizmo {
  57645. private _cameraMesh;
  57646. private _cameraLinesMesh;
  57647. private _material;
  57648. private _pointerObserver;
  57649. /**
  57650. * Event that fires each time the gizmo is clicked
  57651. */
  57652. onClickedObservable: Observable<Camera>;
  57653. /**
  57654. * Creates a CameraGizmo
  57655. * @param gizmoLayer The utility layer the gizmo will be added to
  57656. */
  57657. constructor(gizmoLayer?: UtilityLayerRenderer);
  57658. private _camera;
  57659. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  57660. get displayFrustum(): boolean;
  57661. set displayFrustum(value: boolean);
  57662. /**
  57663. * The camera that the gizmo is attached to
  57664. */
  57665. set camera(camera: Nullable<Camera>);
  57666. get camera(): Nullable<Camera>;
  57667. /**
  57668. * Gets the material used to render the camera gizmo
  57669. */
  57670. get material(): StandardMaterial;
  57671. /**
  57672. * @hidden
  57673. * Updates the gizmo to match the attached mesh's position/rotation
  57674. */
  57675. protected _update(): void;
  57676. private static _Scale;
  57677. private _invProjection;
  57678. /**
  57679. * Disposes of the camera gizmo
  57680. */
  57681. dispose(): void;
  57682. private static _CreateCameraMesh;
  57683. private static _CreateCameraFrustum;
  57684. }
  57685. }
  57686. declare module BABYLON {
  57687. /** @hidden */
  57688. export var backgroundFragmentDeclaration: {
  57689. name: string;
  57690. shader: string;
  57691. };
  57692. }
  57693. declare module BABYLON {
  57694. /** @hidden */
  57695. export var backgroundUboDeclaration: {
  57696. name: string;
  57697. shader: string;
  57698. };
  57699. }
  57700. declare module BABYLON {
  57701. /** @hidden */
  57702. export var backgroundPixelShader: {
  57703. name: string;
  57704. shader: string;
  57705. };
  57706. }
  57707. declare module BABYLON {
  57708. /** @hidden */
  57709. export var backgroundVertexDeclaration: {
  57710. name: string;
  57711. shader: string;
  57712. };
  57713. }
  57714. declare module BABYLON {
  57715. /** @hidden */
  57716. export var backgroundVertexShader: {
  57717. name: string;
  57718. shader: string;
  57719. };
  57720. }
  57721. declare module BABYLON {
  57722. /**
  57723. * Background material used to create an efficient environement around your scene.
  57724. */
  57725. export class BackgroundMaterial extends PushMaterial {
  57726. /**
  57727. * Standard reflectance value at parallel view angle.
  57728. */
  57729. static StandardReflectance0: number;
  57730. /**
  57731. * Standard reflectance value at grazing angle.
  57732. */
  57733. static StandardReflectance90: number;
  57734. protected _primaryColor: Color3;
  57735. /**
  57736. * Key light Color (multiply against the environement texture)
  57737. */
  57738. primaryColor: Color3;
  57739. protected __perceptualColor: Nullable<Color3>;
  57740. /**
  57741. * Experimental Internal Use Only.
  57742. *
  57743. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  57744. * This acts as a helper to set the primary color to a more "human friendly" value.
  57745. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  57746. * output color as close as possible from the chosen value.
  57747. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  57748. * part of lighting setup.)
  57749. */
  57750. get _perceptualColor(): Nullable<Color3>;
  57751. set _perceptualColor(value: Nullable<Color3>);
  57752. protected _primaryColorShadowLevel: float;
  57753. /**
  57754. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  57755. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  57756. */
  57757. get primaryColorShadowLevel(): float;
  57758. set primaryColorShadowLevel(value: float);
  57759. protected _primaryColorHighlightLevel: float;
  57760. /**
  57761. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  57762. * The primary color is used at the level chosen to define what the white area would look.
  57763. */
  57764. get primaryColorHighlightLevel(): float;
  57765. set primaryColorHighlightLevel(value: float);
  57766. protected _reflectionTexture: Nullable<BaseTexture>;
  57767. /**
  57768. * Reflection Texture used in the material.
  57769. * Should be author in a specific way for the best result (refer to the documentation).
  57770. */
  57771. reflectionTexture: Nullable<BaseTexture>;
  57772. protected _reflectionBlur: float;
  57773. /**
  57774. * Reflection Texture level of blur.
  57775. *
  57776. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57777. * texture twice.
  57778. */
  57779. reflectionBlur: float;
  57780. protected _diffuseTexture: Nullable<BaseTexture>;
  57781. /**
  57782. * Diffuse Texture used in the material.
  57783. * Should be author in a specific way for the best result (refer to the documentation).
  57784. */
  57785. diffuseTexture: Nullable<BaseTexture>;
  57786. protected _shadowLights: Nullable<IShadowLight[]>;
  57787. /**
  57788. * Specify the list of lights casting shadow on the material.
  57789. * All scene shadow lights will be included if null.
  57790. */
  57791. shadowLights: Nullable<IShadowLight[]>;
  57792. protected _shadowLevel: float;
  57793. /**
  57794. * Helps adjusting the shadow to a softer level if required.
  57795. * 0 means black shadows and 1 means no shadows.
  57796. */
  57797. shadowLevel: float;
  57798. protected _sceneCenter: Vector3;
  57799. /**
  57800. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57801. * It is usually zero but might be interesting to modify according to your setup.
  57802. */
  57803. sceneCenter: Vector3;
  57804. protected _opacityFresnel: boolean;
  57805. /**
  57806. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57807. * This helps ensuring a nice transition when the camera goes under the ground.
  57808. */
  57809. opacityFresnel: boolean;
  57810. protected _reflectionFresnel: boolean;
  57811. /**
  57812. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57813. * This helps adding a mirror texture on the ground.
  57814. */
  57815. reflectionFresnel: boolean;
  57816. protected _reflectionFalloffDistance: number;
  57817. /**
  57818. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57819. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57820. */
  57821. reflectionFalloffDistance: number;
  57822. protected _reflectionAmount: number;
  57823. /**
  57824. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57825. */
  57826. reflectionAmount: number;
  57827. protected _reflectionReflectance0: number;
  57828. /**
  57829. * This specifies the weight of the reflection at grazing angle.
  57830. */
  57831. reflectionReflectance0: number;
  57832. protected _reflectionReflectance90: number;
  57833. /**
  57834. * This specifies the weight of the reflection at a perpendicular point of view.
  57835. */
  57836. reflectionReflectance90: number;
  57837. /**
  57838. * Sets the reflection reflectance fresnel values according to the default standard
  57839. * empirically know to work well :-)
  57840. */
  57841. set reflectionStandardFresnelWeight(value: number);
  57842. protected _useRGBColor: boolean;
  57843. /**
  57844. * Helps to directly use the maps channels instead of their level.
  57845. */
  57846. useRGBColor: boolean;
  57847. protected _enableNoise: boolean;
  57848. /**
  57849. * This helps reducing the banding effect that could occur on the background.
  57850. */
  57851. enableNoise: boolean;
  57852. /**
  57853. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57854. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57855. * Recommended to be keep at 1.0 except for special cases.
  57856. */
  57857. get fovMultiplier(): number;
  57858. set fovMultiplier(value: number);
  57859. private _fovMultiplier;
  57860. /**
  57861. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57862. */
  57863. useEquirectangularFOV: boolean;
  57864. private _maxSimultaneousLights;
  57865. /**
  57866. * Number of Simultaneous lights allowed on the material.
  57867. */
  57868. maxSimultaneousLights: int;
  57869. private _shadowOnly;
  57870. /**
  57871. * Make the material only render shadows
  57872. */
  57873. shadowOnly: boolean;
  57874. /**
  57875. * Default configuration related to image processing available in the Background Material.
  57876. */
  57877. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57878. /**
  57879. * Keep track of the image processing observer to allow dispose and replace.
  57880. */
  57881. private _imageProcessingObserver;
  57882. /**
  57883. * Attaches a new image processing configuration to the PBR Material.
  57884. * @param configuration (if null the scene configuration will be use)
  57885. */
  57886. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57887. /**
  57888. * Gets the image processing configuration used either in this material.
  57889. */
  57890. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57891. /**
  57892. * Sets the Default image processing configuration used either in the this material.
  57893. *
  57894. * If sets to null, the scene one is in use.
  57895. */
  57896. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57897. /**
  57898. * Gets wether the color curves effect is enabled.
  57899. */
  57900. get cameraColorCurvesEnabled(): boolean;
  57901. /**
  57902. * Sets wether the color curves effect is enabled.
  57903. */
  57904. set cameraColorCurvesEnabled(value: boolean);
  57905. /**
  57906. * Gets wether the color grading effect is enabled.
  57907. */
  57908. get cameraColorGradingEnabled(): boolean;
  57909. /**
  57910. * Gets wether the color grading effect is enabled.
  57911. */
  57912. set cameraColorGradingEnabled(value: boolean);
  57913. /**
  57914. * Gets wether tonemapping is enabled or not.
  57915. */
  57916. get cameraToneMappingEnabled(): boolean;
  57917. /**
  57918. * Sets wether tonemapping is enabled or not
  57919. */
  57920. set cameraToneMappingEnabled(value: boolean);
  57921. /**
  57922. * The camera exposure used on this material.
  57923. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57924. * This corresponds to a photographic exposure.
  57925. */
  57926. get cameraExposure(): float;
  57927. /**
  57928. * The camera exposure used on this material.
  57929. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57930. * This corresponds to a photographic exposure.
  57931. */
  57932. set cameraExposure(value: float);
  57933. /**
  57934. * Gets The camera contrast used on this material.
  57935. */
  57936. get cameraContrast(): float;
  57937. /**
  57938. * Sets The camera contrast used on this material.
  57939. */
  57940. set cameraContrast(value: float);
  57941. /**
  57942. * Gets the Color Grading 2D Lookup Texture.
  57943. */
  57944. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57945. /**
  57946. * Sets the Color Grading 2D Lookup Texture.
  57947. */
  57948. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57949. /**
  57950. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57951. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57952. * 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;
  57953. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57954. */
  57955. get cameraColorCurves(): Nullable<ColorCurves>;
  57956. /**
  57957. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57958. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57959. * 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;
  57960. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57961. */
  57962. set cameraColorCurves(value: Nullable<ColorCurves>);
  57963. /**
  57964. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57965. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57966. */
  57967. switchToBGR: boolean;
  57968. private _renderTargets;
  57969. private _reflectionControls;
  57970. private _white;
  57971. private _primaryShadowColor;
  57972. private _primaryHighlightColor;
  57973. /**
  57974. * Instantiates a Background Material in the given scene
  57975. * @param name The friendly name of the material
  57976. * @param scene The scene to add the material to
  57977. */
  57978. constructor(name: string, scene: Scene);
  57979. /**
  57980. * Gets a boolean indicating that current material needs to register RTT
  57981. */
  57982. get hasRenderTargetTextures(): boolean;
  57983. /**
  57984. * The entire material has been created in order to prevent overdraw.
  57985. * @returns false
  57986. */
  57987. needAlphaTesting(): boolean;
  57988. /**
  57989. * The entire material has been created in order to prevent overdraw.
  57990. * @returns true if blending is enable
  57991. */
  57992. needAlphaBlending(): boolean;
  57993. /**
  57994. * Checks wether the material is ready to be rendered for a given mesh.
  57995. * @param mesh The mesh to render
  57996. * @param subMesh The submesh to check against
  57997. * @param useInstances Specify wether or not the material is used with instances
  57998. * @returns true if all the dependencies are ready (Textures, Effects...)
  57999. */
  58000. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58001. /**
  58002. * Compute the primary color according to the chosen perceptual color.
  58003. */
  58004. private _computePrimaryColorFromPerceptualColor;
  58005. /**
  58006. * Compute the highlights and shadow colors according to their chosen levels.
  58007. */
  58008. private _computePrimaryColors;
  58009. /**
  58010. * Build the uniform buffer used in the material.
  58011. */
  58012. buildUniformLayout(): void;
  58013. /**
  58014. * Unbind the material.
  58015. */
  58016. unbind(): void;
  58017. /**
  58018. * Bind only the world matrix to the material.
  58019. * @param world The world matrix to bind.
  58020. */
  58021. bindOnlyWorldMatrix(world: Matrix): void;
  58022. /**
  58023. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58024. * @param world The world matrix to bind.
  58025. * @param subMesh The submesh to bind for.
  58026. */
  58027. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58028. /**
  58029. * Checks to see if a texture is used in the material.
  58030. * @param texture - Base texture to use.
  58031. * @returns - Boolean specifying if a texture is used in the material.
  58032. */
  58033. hasTexture(texture: BaseTexture): boolean;
  58034. /**
  58035. * Dispose the material.
  58036. * @param forceDisposeEffect Force disposal of the associated effect.
  58037. * @param forceDisposeTextures Force disposal of the associated textures.
  58038. */
  58039. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58040. /**
  58041. * Clones the material.
  58042. * @param name The cloned name.
  58043. * @returns The cloned material.
  58044. */
  58045. clone(name: string): BackgroundMaterial;
  58046. /**
  58047. * Serializes the current material to its JSON representation.
  58048. * @returns The JSON representation.
  58049. */
  58050. serialize(): any;
  58051. /**
  58052. * Gets the class name of the material
  58053. * @returns "BackgroundMaterial"
  58054. */
  58055. getClassName(): string;
  58056. /**
  58057. * Parse a JSON input to create back a background material.
  58058. * @param source The JSON data to parse
  58059. * @param scene The scene to create the parsed material in
  58060. * @param rootUrl The root url of the assets the material depends upon
  58061. * @returns the instantiated BackgroundMaterial.
  58062. */
  58063. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58064. }
  58065. }
  58066. declare module BABYLON {
  58067. /**
  58068. * Represents the different options available during the creation of
  58069. * a Environment helper.
  58070. *
  58071. * This can control the default ground, skybox and image processing setup of your scene.
  58072. */
  58073. export interface IEnvironmentHelperOptions {
  58074. /**
  58075. * Specifies whether or not to create a ground.
  58076. * True by default.
  58077. */
  58078. createGround: boolean;
  58079. /**
  58080. * Specifies the ground size.
  58081. * 15 by default.
  58082. */
  58083. groundSize: number;
  58084. /**
  58085. * The texture used on the ground for the main color.
  58086. * Comes from the BabylonJS CDN by default.
  58087. *
  58088. * Remarks: Can be either a texture or a url.
  58089. */
  58090. groundTexture: string | BaseTexture;
  58091. /**
  58092. * The color mixed in the ground texture by default.
  58093. * BabylonJS clearColor by default.
  58094. */
  58095. groundColor: Color3;
  58096. /**
  58097. * Specifies the ground opacity.
  58098. * 1 by default.
  58099. */
  58100. groundOpacity: number;
  58101. /**
  58102. * Enables the ground to receive shadows.
  58103. * True by default.
  58104. */
  58105. enableGroundShadow: boolean;
  58106. /**
  58107. * Helps preventing the shadow to be fully black on the ground.
  58108. * 0.5 by default.
  58109. */
  58110. groundShadowLevel: number;
  58111. /**
  58112. * Creates a mirror texture attach to the ground.
  58113. * false by default.
  58114. */
  58115. enableGroundMirror: boolean;
  58116. /**
  58117. * Specifies the ground mirror size ratio.
  58118. * 0.3 by default as the default kernel is 64.
  58119. */
  58120. groundMirrorSizeRatio: number;
  58121. /**
  58122. * Specifies the ground mirror blur kernel size.
  58123. * 64 by default.
  58124. */
  58125. groundMirrorBlurKernel: number;
  58126. /**
  58127. * Specifies the ground mirror visibility amount.
  58128. * 1 by default
  58129. */
  58130. groundMirrorAmount: number;
  58131. /**
  58132. * Specifies the ground mirror reflectance weight.
  58133. * This uses the standard weight of the background material to setup the fresnel effect
  58134. * of the mirror.
  58135. * 1 by default.
  58136. */
  58137. groundMirrorFresnelWeight: number;
  58138. /**
  58139. * Specifies the ground mirror Falloff distance.
  58140. * This can helps reducing the size of the reflection.
  58141. * 0 by Default.
  58142. */
  58143. groundMirrorFallOffDistance: number;
  58144. /**
  58145. * Specifies the ground mirror texture type.
  58146. * Unsigned Int by Default.
  58147. */
  58148. groundMirrorTextureType: number;
  58149. /**
  58150. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58151. * the shown objects.
  58152. */
  58153. groundYBias: number;
  58154. /**
  58155. * Specifies whether or not to create a skybox.
  58156. * True by default.
  58157. */
  58158. createSkybox: boolean;
  58159. /**
  58160. * Specifies the skybox size.
  58161. * 20 by default.
  58162. */
  58163. skyboxSize: number;
  58164. /**
  58165. * The texture used on the skybox for the main color.
  58166. * Comes from the BabylonJS CDN by default.
  58167. *
  58168. * Remarks: Can be either a texture or a url.
  58169. */
  58170. skyboxTexture: string | BaseTexture;
  58171. /**
  58172. * The color mixed in the skybox texture by default.
  58173. * BabylonJS clearColor by default.
  58174. */
  58175. skyboxColor: Color3;
  58176. /**
  58177. * The background rotation around the Y axis of the scene.
  58178. * This helps aligning the key lights of your scene with the background.
  58179. * 0 by default.
  58180. */
  58181. backgroundYRotation: number;
  58182. /**
  58183. * Compute automatically the size of the elements to best fit with the scene.
  58184. */
  58185. sizeAuto: boolean;
  58186. /**
  58187. * Default position of the rootMesh if autoSize is not true.
  58188. */
  58189. rootPosition: Vector3;
  58190. /**
  58191. * Sets up the image processing in the scene.
  58192. * true by default.
  58193. */
  58194. setupImageProcessing: boolean;
  58195. /**
  58196. * The texture used as your environment texture in the scene.
  58197. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58198. *
  58199. * Remarks: Can be either a texture or a url.
  58200. */
  58201. environmentTexture: string | BaseTexture;
  58202. /**
  58203. * The value of the exposure to apply to the scene.
  58204. * 0.6 by default if setupImageProcessing is true.
  58205. */
  58206. cameraExposure: number;
  58207. /**
  58208. * The value of the contrast to apply to the scene.
  58209. * 1.6 by default if setupImageProcessing is true.
  58210. */
  58211. cameraContrast: number;
  58212. /**
  58213. * Specifies whether or not tonemapping should be enabled in the scene.
  58214. * true by default if setupImageProcessing is true.
  58215. */
  58216. toneMappingEnabled: boolean;
  58217. }
  58218. /**
  58219. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58220. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58221. * It also helps with the default setup of your imageProcessing configuration.
  58222. */
  58223. export class EnvironmentHelper {
  58224. /**
  58225. * Default ground texture URL.
  58226. */
  58227. private static _groundTextureCDNUrl;
  58228. /**
  58229. * Default skybox texture URL.
  58230. */
  58231. private static _skyboxTextureCDNUrl;
  58232. /**
  58233. * Default environment texture URL.
  58234. */
  58235. private static _environmentTextureCDNUrl;
  58236. /**
  58237. * Creates the default options for the helper.
  58238. */
  58239. private static _getDefaultOptions;
  58240. private _rootMesh;
  58241. /**
  58242. * Gets the root mesh created by the helper.
  58243. */
  58244. get rootMesh(): Mesh;
  58245. private _skybox;
  58246. /**
  58247. * Gets the skybox created by the helper.
  58248. */
  58249. get skybox(): Nullable<Mesh>;
  58250. private _skyboxTexture;
  58251. /**
  58252. * Gets the skybox texture created by the helper.
  58253. */
  58254. get skyboxTexture(): Nullable<BaseTexture>;
  58255. private _skyboxMaterial;
  58256. /**
  58257. * Gets the skybox material created by the helper.
  58258. */
  58259. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58260. private _ground;
  58261. /**
  58262. * Gets the ground mesh created by the helper.
  58263. */
  58264. get ground(): Nullable<Mesh>;
  58265. private _groundTexture;
  58266. /**
  58267. * Gets the ground texture created by the helper.
  58268. */
  58269. get groundTexture(): Nullable<BaseTexture>;
  58270. private _groundMirror;
  58271. /**
  58272. * Gets the ground mirror created by the helper.
  58273. */
  58274. get groundMirror(): Nullable<MirrorTexture>;
  58275. /**
  58276. * Gets the ground mirror render list to helps pushing the meshes
  58277. * you wish in the ground reflection.
  58278. */
  58279. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58280. private _groundMaterial;
  58281. /**
  58282. * Gets the ground material created by the helper.
  58283. */
  58284. get groundMaterial(): Nullable<BackgroundMaterial>;
  58285. /**
  58286. * Stores the creation options.
  58287. */
  58288. private readonly _scene;
  58289. private _options;
  58290. /**
  58291. * This observable will be notified with any error during the creation of the environment,
  58292. * mainly texture creation errors.
  58293. */
  58294. onErrorObservable: Observable<{
  58295. message?: string;
  58296. exception?: any;
  58297. }>;
  58298. /**
  58299. * constructor
  58300. * @param options Defines the options we want to customize the helper
  58301. * @param scene The scene to add the material to
  58302. */
  58303. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58304. /**
  58305. * Updates the background according to the new options
  58306. * @param options
  58307. */
  58308. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58309. /**
  58310. * Sets the primary color of all the available elements.
  58311. * @param color the main color to affect to the ground and the background
  58312. */
  58313. setMainColor(color: Color3): void;
  58314. /**
  58315. * Setup the image processing according to the specified options.
  58316. */
  58317. private _setupImageProcessing;
  58318. /**
  58319. * Setup the environment texture according to the specified options.
  58320. */
  58321. private _setupEnvironmentTexture;
  58322. /**
  58323. * Setup the background according to the specified options.
  58324. */
  58325. private _setupBackground;
  58326. /**
  58327. * Get the scene sizes according to the setup.
  58328. */
  58329. private _getSceneSize;
  58330. /**
  58331. * Setup the ground according to the specified options.
  58332. */
  58333. private _setupGround;
  58334. /**
  58335. * Setup the ground material according to the specified options.
  58336. */
  58337. private _setupGroundMaterial;
  58338. /**
  58339. * Setup the ground diffuse texture according to the specified options.
  58340. */
  58341. private _setupGroundDiffuseTexture;
  58342. /**
  58343. * Setup the ground mirror texture according to the specified options.
  58344. */
  58345. private _setupGroundMirrorTexture;
  58346. /**
  58347. * Setup the ground to receive the mirror texture.
  58348. */
  58349. private _setupMirrorInGroundMaterial;
  58350. /**
  58351. * Setup the skybox according to the specified options.
  58352. */
  58353. private _setupSkybox;
  58354. /**
  58355. * Setup the skybox material according to the specified options.
  58356. */
  58357. private _setupSkyboxMaterial;
  58358. /**
  58359. * Setup the skybox reflection texture according to the specified options.
  58360. */
  58361. private _setupSkyboxReflectionTexture;
  58362. private _errorHandler;
  58363. /**
  58364. * Dispose all the elements created by the Helper.
  58365. */
  58366. dispose(): void;
  58367. }
  58368. }
  58369. declare module BABYLON {
  58370. /**
  58371. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58372. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58373. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58374. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58375. */
  58376. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58377. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58378. /**
  58379. * Define the source as a Monoscopic panoramic 360/180.
  58380. */
  58381. static readonly MODE_MONOSCOPIC: number;
  58382. /**
  58383. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58384. */
  58385. static readonly MODE_TOPBOTTOM: number;
  58386. /**
  58387. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58388. */
  58389. static readonly MODE_SIDEBYSIDE: number;
  58390. private _halfDome;
  58391. private _crossEye;
  58392. protected _useDirectMapping: boolean;
  58393. /**
  58394. * The texture being displayed on the sphere
  58395. */
  58396. protected _texture: T;
  58397. /**
  58398. * Gets the texture being displayed on the sphere
  58399. */
  58400. get texture(): T;
  58401. /**
  58402. * Sets the texture being displayed on the sphere
  58403. */
  58404. set texture(newTexture: T);
  58405. /**
  58406. * The skybox material
  58407. */
  58408. protected _material: BackgroundMaterial;
  58409. /**
  58410. * The surface used for the dome
  58411. */
  58412. protected _mesh: Mesh;
  58413. /**
  58414. * Gets the mesh used for the dome.
  58415. */
  58416. get mesh(): Mesh;
  58417. /**
  58418. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58419. */
  58420. private _halfDomeMask;
  58421. /**
  58422. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58423. * Also see the options.resolution property.
  58424. */
  58425. get fovMultiplier(): number;
  58426. set fovMultiplier(value: number);
  58427. protected _textureMode: number;
  58428. /**
  58429. * Gets or set the current texture mode for the texture. It can be:
  58430. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58431. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58432. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58433. */
  58434. get textureMode(): number;
  58435. /**
  58436. * Sets the current texture mode for the texture. It can be:
  58437. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58438. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58439. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58440. */
  58441. set textureMode(value: number);
  58442. /**
  58443. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58444. */
  58445. get halfDome(): boolean;
  58446. /**
  58447. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58448. */
  58449. set halfDome(enabled: boolean);
  58450. /**
  58451. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58452. */
  58453. set crossEye(enabled: boolean);
  58454. /**
  58455. * Is it a cross-eye texture?
  58456. */
  58457. get crossEye(): boolean;
  58458. /**
  58459. * The background material of this dome.
  58460. */
  58461. get material(): BackgroundMaterial;
  58462. /**
  58463. * Oberserver used in Stereoscopic VR Mode.
  58464. */
  58465. private _onBeforeCameraRenderObserver;
  58466. /**
  58467. * Observable raised when an error occured while loading the 360 image
  58468. */
  58469. onLoadErrorObservable: Observable<string>;
  58470. /**
  58471. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58472. * @param name Element's name, child elements will append suffixes for their own names.
  58473. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58474. * @param options An object containing optional or exposed sub element properties
  58475. */
  58476. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58477. resolution?: number;
  58478. clickToPlay?: boolean;
  58479. autoPlay?: boolean;
  58480. loop?: boolean;
  58481. size?: number;
  58482. poster?: string;
  58483. faceForward?: boolean;
  58484. useDirectMapping?: boolean;
  58485. halfDomeMode?: boolean;
  58486. crossEyeMode?: boolean;
  58487. generateMipMaps?: boolean;
  58488. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58489. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58490. protected _changeTextureMode(value: number): void;
  58491. /**
  58492. * Releases resources associated with this node.
  58493. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58494. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58495. */
  58496. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58497. }
  58498. }
  58499. declare module BABYLON {
  58500. /**
  58501. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58502. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58503. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58504. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58505. */
  58506. export class PhotoDome extends TextureDome<Texture> {
  58507. /**
  58508. * Define the image as a Monoscopic panoramic 360 image.
  58509. */
  58510. static readonly MODE_MONOSCOPIC: number;
  58511. /**
  58512. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58513. */
  58514. static readonly MODE_TOPBOTTOM: number;
  58515. /**
  58516. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58517. */
  58518. static readonly MODE_SIDEBYSIDE: number;
  58519. /**
  58520. * Gets or sets the texture being displayed on the sphere
  58521. */
  58522. get photoTexture(): Texture;
  58523. /**
  58524. * sets the texture being displayed on the sphere
  58525. */
  58526. set photoTexture(value: Texture);
  58527. /**
  58528. * Gets the current video mode for the video. It can be:
  58529. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58530. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58531. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58532. */
  58533. get imageMode(): number;
  58534. /**
  58535. * Sets the current video mode for the video. It can be:
  58536. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58537. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58538. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58539. */
  58540. set imageMode(value: number);
  58541. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  58542. }
  58543. }
  58544. declare module BABYLON {
  58545. /**
  58546. * Direct draw surface info
  58547. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58548. */
  58549. export interface DDSInfo {
  58550. /**
  58551. * Width of the texture
  58552. */
  58553. width: number;
  58554. /**
  58555. * Width of the texture
  58556. */
  58557. height: number;
  58558. /**
  58559. * Number of Mipmaps for the texture
  58560. * @see https://en.wikipedia.org/wiki/Mipmap
  58561. */
  58562. mipmapCount: number;
  58563. /**
  58564. * If the textures format is a known fourCC format
  58565. * @see https://www.fourcc.org/
  58566. */
  58567. isFourCC: boolean;
  58568. /**
  58569. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58570. */
  58571. isRGB: boolean;
  58572. /**
  58573. * If the texture is a lumincance format
  58574. */
  58575. isLuminance: boolean;
  58576. /**
  58577. * If this is a cube texture
  58578. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58579. */
  58580. isCube: boolean;
  58581. /**
  58582. * If the texture is a compressed format eg. FOURCC_DXT1
  58583. */
  58584. isCompressed: boolean;
  58585. /**
  58586. * The dxgiFormat of the texture
  58587. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58588. */
  58589. dxgiFormat: number;
  58590. /**
  58591. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58592. */
  58593. textureType: number;
  58594. /**
  58595. * Sphericle polynomial created for the dds texture
  58596. */
  58597. sphericalPolynomial?: SphericalPolynomial;
  58598. }
  58599. /**
  58600. * Class used to provide DDS decompression tools
  58601. */
  58602. export class DDSTools {
  58603. /**
  58604. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58605. */
  58606. static StoreLODInAlphaChannel: boolean;
  58607. /**
  58608. * Gets DDS information from an array buffer
  58609. * @param data defines the array buffer view to read data from
  58610. * @returns the DDS information
  58611. */
  58612. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58613. private static _FloatView;
  58614. private static _Int32View;
  58615. private static _ToHalfFloat;
  58616. private static _FromHalfFloat;
  58617. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58618. private static _GetHalfFloatRGBAArrayBuffer;
  58619. private static _GetFloatRGBAArrayBuffer;
  58620. private static _GetFloatAsUIntRGBAArrayBuffer;
  58621. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58622. private static _GetRGBAArrayBuffer;
  58623. private static _ExtractLongWordOrder;
  58624. private static _GetRGBArrayBuffer;
  58625. private static _GetLuminanceArrayBuffer;
  58626. /**
  58627. * Uploads DDS Levels to a Babylon Texture
  58628. * @hidden
  58629. */
  58630. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58631. }
  58632. interface ThinEngine {
  58633. /**
  58634. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58635. * @param rootUrl defines the url where the file to load is located
  58636. * @param scene defines the current scene
  58637. * @param lodScale defines scale to apply to the mip map selection
  58638. * @param lodOffset defines offset to apply to the mip map selection
  58639. * @param onLoad defines an optional callback raised when the texture is loaded
  58640. * @param onError defines an optional callback raised if there is an issue to load the texture
  58641. * @param format defines the format of the data
  58642. * @param forcedExtension defines the extension to use to pick the right loader
  58643. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58644. * @returns the cube texture as an InternalTexture
  58645. */
  58646. 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;
  58647. }
  58648. }
  58649. declare module BABYLON {
  58650. /**
  58651. * Implementation of the DDS Texture Loader.
  58652. * @hidden
  58653. */
  58654. export class _DDSTextureLoader implements IInternalTextureLoader {
  58655. /**
  58656. * Defines wether the loader supports cascade loading the different faces.
  58657. */
  58658. readonly supportCascades: boolean;
  58659. /**
  58660. * This returns if the loader support the current file information.
  58661. * @param extension defines the file extension of the file being loaded
  58662. * @returns true if the loader can load the specified file
  58663. */
  58664. canLoad(extension: string): boolean;
  58665. /**
  58666. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58667. * @param data contains the texture data
  58668. * @param texture defines the BabylonJS internal texture
  58669. * @param createPolynomials will be true if polynomials have been requested
  58670. * @param onLoad defines the callback to trigger once the texture is ready
  58671. * @param onError defines the callback to trigger in case of error
  58672. */
  58673. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58674. /**
  58675. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58676. * @param data contains the texture data
  58677. * @param texture defines the BabylonJS internal texture
  58678. * @param callback defines the method to call once ready to upload
  58679. */
  58680. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58681. }
  58682. }
  58683. declare module BABYLON {
  58684. /**
  58685. * Implementation of the ENV Texture Loader.
  58686. * @hidden
  58687. */
  58688. export class _ENVTextureLoader implements IInternalTextureLoader {
  58689. /**
  58690. * Defines wether the loader supports cascade loading the different faces.
  58691. */
  58692. readonly supportCascades: boolean;
  58693. /**
  58694. * This returns if the loader support the current file information.
  58695. * @param extension defines the file extension of the file being loaded
  58696. * @returns true if the loader can load the specified file
  58697. */
  58698. canLoad(extension: string): boolean;
  58699. /**
  58700. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58701. * @param data contains the texture data
  58702. * @param texture defines the BabylonJS internal texture
  58703. * @param createPolynomials will be true if polynomials have been requested
  58704. * @param onLoad defines the callback to trigger once the texture is ready
  58705. * @param onError defines the callback to trigger in case of error
  58706. */
  58707. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58708. /**
  58709. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58710. * @param data contains the texture data
  58711. * @param texture defines the BabylonJS internal texture
  58712. * @param callback defines the method to call once ready to upload
  58713. */
  58714. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58715. }
  58716. }
  58717. declare module BABYLON {
  58718. /**
  58719. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58720. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58721. */
  58722. export class KhronosTextureContainer {
  58723. /** contents of the KTX container file */
  58724. data: ArrayBufferView;
  58725. private static HEADER_LEN;
  58726. private static COMPRESSED_2D;
  58727. private static COMPRESSED_3D;
  58728. private static TEX_2D;
  58729. private static TEX_3D;
  58730. /**
  58731. * Gets the openGL type
  58732. */
  58733. glType: number;
  58734. /**
  58735. * Gets the openGL type size
  58736. */
  58737. glTypeSize: number;
  58738. /**
  58739. * Gets the openGL format
  58740. */
  58741. glFormat: number;
  58742. /**
  58743. * Gets the openGL internal format
  58744. */
  58745. glInternalFormat: number;
  58746. /**
  58747. * Gets the base internal format
  58748. */
  58749. glBaseInternalFormat: number;
  58750. /**
  58751. * Gets image width in pixel
  58752. */
  58753. pixelWidth: number;
  58754. /**
  58755. * Gets image height in pixel
  58756. */
  58757. pixelHeight: number;
  58758. /**
  58759. * Gets image depth in pixels
  58760. */
  58761. pixelDepth: number;
  58762. /**
  58763. * Gets the number of array elements
  58764. */
  58765. numberOfArrayElements: number;
  58766. /**
  58767. * Gets the number of faces
  58768. */
  58769. numberOfFaces: number;
  58770. /**
  58771. * Gets the number of mipmap levels
  58772. */
  58773. numberOfMipmapLevels: number;
  58774. /**
  58775. * Gets the bytes of key value data
  58776. */
  58777. bytesOfKeyValueData: number;
  58778. /**
  58779. * Gets the load type
  58780. */
  58781. loadType: number;
  58782. /**
  58783. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58784. */
  58785. isInvalid: boolean;
  58786. /**
  58787. * Creates a new KhronosTextureContainer
  58788. * @param data contents of the KTX container file
  58789. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58790. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58791. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58792. */
  58793. constructor(
  58794. /** contents of the KTX container file */
  58795. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58796. /**
  58797. * Uploads KTX content to a Babylon Texture.
  58798. * It is assumed that the texture has already been created & is currently bound
  58799. * @hidden
  58800. */
  58801. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58802. private _upload2DCompressedLevels;
  58803. /**
  58804. * Checks if the given data starts with a KTX file identifier.
  58805. * @param data the data to check
  58806. * @returns true if the data is a KTX file or false otherwise
  58807. */
  58808. static IsValid(data: ArrayBufferView): boolean;
  58809. }
  58810. }
  58811. declare module BABYLON {
  58812. /**
  58813. * Helper class to push actions to a pool of workers.
  58814. */
  58815. export class WorkerPool implements IDisposable {
  58816. private _workerInfos;
  58817. private _pendingActions;
  58818. /**
  58819. * Constructor
  58820. * @param workers Array of workers to use for actions
  58821. */
  58822. constructor(workers: Array<Worker>);
  58823. /**
  58824. * Terminates all workers and clears any pending actions.
  58825. */
  58826. dispose(): void;
  58827. /**
  58828. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58829. * pended until a worker has completed its action.
  58830. * @param action The action to perform. Call onComplete when the action is complete.
  58831. */
  58832. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58833. private _execute;
  58834. }
  58835. }
  58836. declare module BABYLON {
  58837. /**
  58838. * Class for loading KTX2 files
  58839. */
  58840. export class KhronosTextureContainer2 {
  58841. private static _WorkerPoolPromise?;
  58842. private static _Initialized;
  58843. private static _Ktx2Decoder;
  58844. /**
  58845. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  58846. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  58847. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  58848. * Urls you can change:
  58849. * URLConfig.jsDecoderModule
  58850. * URLConfig.wasmUASTCToASTC
  58851. * URLConfig.wasmUASTCToBC7
  58852. * URLConfig.wasmUASTCToRGBA_UNORM
  58853. * URLConfig.wasmUASTCToRGBA_SRGB
  58854. * URLConfig.jsMSCTranscoder
  58855. * URLConfig.wasmMSCTranscoder
  58856. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  58857. */
  58858. static URLConfig: {
  58859. jsDecoderModule: string;
  58860. wasmUASTCToASTC: null;
  58861. wasmUASTCToBC7: null;
  58862. wasmUASTCToRGBA_UNORM: null;
  58863. wasmUASTCToRGBA_SRGB: null;
  58864. jsMSCTranscoder: null;
  58865. wasmMSCTranscoder: null;
  58866. };
  58867. /**
  58868. * Default number of workers used to handle data decoding
  58869. */
  58870. static DefaultNumWorkers: number;
  58871. private static GetDefaultNumWorkers;
  58872. private _engine;
  58873. private static _CreateWorkerPool;
  58874. /**
  58875. * Constructor
  58876. * @param engine The engine to use
  58877. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58878. */
  58879. constructor(engine: ThinEngine, numWorkers?: number);
  58880. /** @hidden */
  58881. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  58882. /**
  58883. * Stop all async operations and release resources.
  58884. */
  58885. dispose(): void;
  58886. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  58887. /**
  58888. * Checks if the given data starts with a KTX2 file identifier.
  58889. * @param data the data to check
  58890. * @returns true if the data is a KTX2 file or false otherwise
  58891. */
  58892. static IsValid(data: ArrayBufferView): boolean;
  58893. }
  58894. }
  58895. declare module BABYLON {
  58896. /**
  58897. * Implementation of the KTX Texture Loader.
  58898. * @hidden
  58899. */
  58900. export class _KTXTextureLoader implements IInternalTextureLoader {
  58901. /**
  58902. * Defines wether the loader supports cascade loading the different faces.
  58903. */
  58904. readonly supportCascades: boolean;
  58905. /**
  58906. * This returns if the loader support the current file information.
  58907. * @param extension defines the file extension of the file being loaded
  58908. * @param mimeType defines the optional mime type of the file being loaded
  58909. * @returns true if the loader can load the specified file
  58910. */
  58911. canLoad(extension: string, mimeType?: string): boolean;
  58912. /**
  58913. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58914. * @param data contains the texture data
  58915. * @param texture defines the BabylonJS internal texture
  58916. * @param createPolynomials will be true if polynomials have been requested
  58917. * @param onLoad defines the callback to trigger once the texture is ready
  58918. * @param onError defines the callback to trigger in case of error
  58919. */
  58920. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58921. /**
  58922. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58923. * @param data contains the texture data
  58924. * @param texture defines the BabylonJS internal texture
  58925. * @param callback defines the method to call once ready to upload
  58926. */
  58927. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  58928. }
  58929. }
  58930. declare module BABYLON {
  58931. /** @hidden */
  58932. export var _forceSceneHelpersToBundle: boolean;
  58933. interface Scene {
  58934. /**
  58935. * Creates a default light for the scene.
  58936. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58937. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58938. */
  58939. createDefaultLight(replace?: boolean): void;
  58940. /**
  58941. * Creates a default camera for the scene.
  58942. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58943. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58944. * @param replace has default false, when true replaces the active camera in the scene
  58945. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58946. */
  58947. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58948. /**
  58949. * Creates a default camera and a default light.
  58950. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58951. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58952. * @param replace has the default false, when true replaces the active camera/light in the scene
  58953. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58954. */
  58955. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58956. /**
  58957. * Creates a new sky box
  58958. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58959. * @param environmentTexture defines the texture to use as environment texture
  58960. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58961. * @param scale defines the overall scale of the skybox
  58962. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58963. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58964. * @returns a new mesh holding the sky box
  58965. */
  58966. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58967. /**
  58968. * Creates a new environment
  58969. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58970. * @param options defines the options you can use to configure the environment
  58971. * @returns the new EnvironmentHelper
  58972. */
  58973. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58974. /**
  58975. * Creates a new VREXperienceHelper
  58976. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58977. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58978. * @returns a new VREXperienceHelper
  58979. */
  58980. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58981. /**
  58982. * Creates a new WebXRDefaultExperience
  58983. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58984. * @param options experience options
  58985. * @returns a promise for a new WebXRDefaultExperience
  58986. */
  58987. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58988. }
  58989. }
  58990. declare module BABYLON {
  58991. /**
  58992. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58993. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58994. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58995. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58996. */
  58997. export class VideoDome extends TextureDome<VideoTexture> {
  58998. /**
  58999. * Define the video source as a Monoscopic panoramic 360 video.
  59000. */
  59001. static readonly MODE_MONOSCOPIC: number;
  59002. /**
  59003. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59004. */
  59005. static readonly MODE_TOPBOTTOM: number;
  59006. /**
  59007. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59008. */
  59009. static readonly MODE_SIDEBYSIDE: number;
  59010. /**
  59011. * Get the video texture associated with this video dome
  59012. */
  59013. get videoTexture(): VideoTexture;
  59014. /**
  59015. * Get the video mode of this dome
  59016. */
  59017. get videoMode(): number;
  59018. /**
  59019. * Set the video mode of this dome.
  59020. * @see textureMode
  59021. */
  59022. set videoMode(value: number);
  59023. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59024. }
  59025. }
  59026. declare module BABYLON {
  59027. /**
  59028. * This class can be used to get instrumentation data from a Babylon engine
  59029. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59030. */
  59031. export class EngineInstrumentation implements IDisposable {
  59032. /**
  59033. * Define the instrumented engine.
  59034. */
  59035. engine: Engine;
  59036. private _captureGPUFrameTime;
  59037. private _gpuFrameTimeToken;
  59038. private _gpuFrameTime;
  59039. private _captureShaderCompilationTime;
  59040. private _shaderCompilationTime;
  59041. private _onBeginFrameObserver;
  59042. private _onEndFrameObserver;
  59043. private _onBeforeShaderCompilationObserver;
  59044. private _onAfterShaderCompilationObserver;
  59045. /**
  59046. * Gets the perf counter used for GPU frame time
  59047. */
  59048. get gpuFrameTimeCounter(): PerfCounter;
  59049. /**
  59050. * Gets the GPU frame time capture status
  59051. */
  59052. get captureGPUFrameTime(): boolean;
  59053. /**
  59054. * Enable or disable the GPU frame time capture
  59055. */
  59056. set captureGPUFrameTime(value: boolean);
  59057. /**
  59058. * Gets the perf counter used for shader compilation time
  59059. */
  59060. get shaderCompilationTimeCounter(): PerfCounter;
  59061. /**
  59062. * Gets the shader compilation time capture status
  59063. */
  59064. get captureShaderCompilationTime(): boolean;
  59065. /**
  59066. * Enable or disable the shader compilation time capture
  59067. */
  59068. set captureShaderCompilationTime(value: boolean);
  59069. /**
  59070. * Instantiates a new engine instrumentation.
  59071. * This class can be used to get instrumentation data from a Babylon engine
  59072. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59073. * @param engine Defines the engine to instrument
  59074. */
  59075. constructor(
  59076. /**
  59077. * Define the instrumented engine.
  59078. */
  59079. engine: Engine);
  59080. /**
  59081. * Dispose and release associated resources.
  59082. */
  59083. dispose(): void;
  59084. }
  59085. }
  59086. declare module BABYLON {
  59087. /**
  59088. * This class can be used to get instrumentation data from a Babylon engine
  59089. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59090. */
  59091. export class SceneInstrumentation implements IDisposable {
  59092. /**
  59093. * Defines the scene to instrument
  59094. */
  59095. scene: Scene;
  59096. private _captureActiveMeshesEvaluationTime;
  59097. private _activeMeshesEvaluationTime;
  59098. private _captureRenderTargetsRenderTime;
  59099. private _renderTargetsRenderTime;
  59100. private _captureFrameTime;
  59101. private _frameTime;
  59102. private _captureRenderTime;
  59103. private _renderTime;
  59104. private _captureInterFrameTime;
  59105. private _interFrameTime;
  59106. private _captureParticlesRenderTime;
  59107. private _particlesRenderTime;
  59108. private _captureSpritesRenderTime;
  59109. private _spritesRenderTime;
  59110. private _capturePhysicsTime;
  59111. private _physicsTime;
  59112. private _captureAnimationsTime;
  59113. private _animationsTime;
  59114. private _captureCameraRenderTime;
  59115. private _cameraRenderTime;
  59116. private _onBeforeActiveMeshesEvaluationObserver;
  59117. private _onAfterActiveMeshesEvaluationObserver;
  59118. private _onBeforeRenderTargetsRenderObserver;
  59119. private _onAfterRenderTargetsRenderObserver;
  59120. private _onAfterRenderObserver;
  59121. private _onBeforeDrawPhaseObserver;
  59122. private _onAfterDrawPhaseObserver;
  59123. private _onBeforeAnimationsObserver;
  59124. private _onBeforeParticlesRenderingObserver;
  59125. private _onAfterParticlesRenderingObserver;
  59126. private _onBeforeSpritesRenderingObserver;
  59127. private _onAfterSpritesRenderingObserver;
  59128. private _onBeforePhysicsObserver;
  59129. private _onAfterPhysicsObserver;
  59130. private _onAfterAnimationsObserver;
  59131. private _onBeforeCameraRenderObserver;
  59132. private _onAfterCameraRenderObserver;
  59133. /**
  59134. * Gets the perf counter used for active meshes evaluation time
  59135. */
  59136. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59137. /**
  59138. * Gets the active meshes evaluation time capture status
  59139. */
  59140. get captureActiveMeshesEvaluationTime(): boolean;
  59141. /**
  59142. * Enable or disable the active meshes evaluation time capture
  59143. */
  59144. set captureActiveMeshesEvaluationTime(value: boolean);
  59145. /**
  59146. * Gets the perf counter used for render targets render time
  59147. */
  59148. get renderTargetsRenderTimeCounter(): PerfCounter;
  59149. /**
  59150. * Gets the render targets render time capture status
  59151. */
  59152. get captureRenderTargetsRenderTime(): boolean;
  59153. /**
  59154. * Enable or disable the render targets render time capture
  59155. */
  59156. set captureRenderTargetsRenderTime(value: boolean);
  59157. /**
  59158. * Gets the perf counter used for particles render time
  59159. */
  59160. get particlesRenderTimeCounter(): PerfCounter;
  59161. /**
  59162. * Gets the particles render time capture status
  59163. */
  59164. get captureParticlesRenderTime(): boolean;
  59165. /**
  59166. * Enable or disable the particles render time capture
  59167. */
  59168. set captureParticlesRenderTime(value: boolean);
  59169. /**
  59170. * Gets the perf counter used for sprites render time
  59171. */
  59172. get spritesRenderTimeCounter(): PerfCounter;
  59173. /**
  59174. * Gets the sprites render time capture status
  59175. */
  59176. get captureSpritesRenderTime(): boolean;
  59177. /**
  59178. * Enable or disable the sprites render time capture
  59179. */
  59180. set captureSpritesRenderTime(value: boolean);
  59181. /**
  59182. * Gets the perf counter used for physics time
  59183. */
  59184. get physicsTimeCounter(): PerfCounter;
  59185. /**
  59186. * Gets the physics time capture status
  59187. */
  59188. get capturePhysicsTime(): boolean;
  59189. /**
  59190. * Enable or disable the physics time capture
  59191. */
  59192. set capturePhysicsTime(value: boolean);
  59193. /**
  59194. * Gets the perf counter used for animations time
  59195. */
  59196. get animationsTimeCounter(): PerfCounter;
  59197. /**
  59198. * Gets the animations time capture status
  59199. */
  59200. get captureAnimationsTime(): boolean;
  59201. /**
  59202. * Enable or disable the animations time capture
  59203. */
  59204. set captureAnimationsTime(value: boolean);
  59205. /**
  59206. * Gets the perf counter used for frame time capture
  59207. */
  59208. get frameTimeCounter(): PerfCounter;
  59209. /**
  59210. * Gets the frame time capture status
  59211. */
  59212. get captureFrameTime(): boolean;
  59213. /**
  59214. * Enable or disable the frame time capture
  59215. */
  59216. set captureFrameTime(value: boolean);
  59217. /**
  59218. * Gets the perf counter used for inter-frames time capture
  59219. */
  59220. get interFrameTimeCounter(): PerfCounter;
  59221. /**
  59222. * Gets the inter-frames time capture status
  59223. */
  59224. get captureInterFrameTime(): boolean;
  59225. /**
  59226. * Enable or disable the inter-frames time capture
  59227. */
  59228. set captureInterFrameTime(value: boolean);
  59229. /**
  59230. * Gets the perf counter used for render time capture
  59231. */
  59232. get renderTimeCounter(): PerfCounter;
  59233. /**
  59234. * Gets the render time capture status
  59235. */
  59236. get captureRenderTime(): boolean;
  59237. /**
  59238. * Enable or disable the render time capture
  59239. */
  59240. set captureRenderTime(value: boolean);
  59241. /**
  59242. * Gets the perf counter used for camera render time capture
  59243. */
  59244. get cameraRenderTimeCounter(): PerfCounter;
  59245. /**
  59246. * Gets the camera render time capture status
  59247. */
  59248. get captureCameraRenderTime(): boolean;
  59249. /**
  59250. * Enable or disable the camera render time capture
  59251. */
  59252. set captureCameraRenderTime(value: boolean);
  59253. /**
  59254. * Gets the perf counter used for draw calls
  59255. */
  59256. get drawCallsCounter(): PerfCounter;
  59257. /**
  59258. * Instantiates a new scene instrumentation.
  59259. * This class can be used to get instrumentation data from a Babylon engine
  59260. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59261. * @param scene Defines the scene to instrument
  59262. */
  59263. constructor(
  59264. /**
  59265. * Defines the scene to instrument
  59266. */
  59267. scene: Scene);
  59268. /**
  59269. * Dispose and release associated resources.
  59270. */
  59271. dispose(): void;
  59272. }
  59273. }
  59274. declare module BABYLON {
  59275. /** @hidden */
  59276. export var glowMapGenerationPixelShader: {
  59277. name: string;
  59278. shader: string;
  59279. };
  59280. }
  59281. declare module BABYLON {
  59282. /** @hidden */
  59283. export var glowMapGenerationVertexShader: {
  59284. name: string;
  59285. shader: string;
  59286. };
  59287. }
  59288. declare module BABYLON {
  59289. /**
  59290. * Effect layer options. This helps customizing the behaviour
  59291. * of the effect layer.
  59292. */
  59293. export interface IEffectLayerOptions {
  59294. /**
  59295. * Multiplication factor apply to the canvas size to compute the render target size
  59296. * used to generated the objects (the smaller the faster).
  59297. */
  59298. mainTextureRatio: number;
  59299. /**
  59300. * Enforces a fixed size texture to ensure effect stability across devices.
  59301. */
  59302. mainTextureFixedSize?: number;
  59303. /**
  59304. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59305. */
  59306. alphaBlendingMode: number;
  59307. /**
  59308. * The camera attached to the layer.
  59309. */
  59310. camera: Nullable<Camera>;
  59311. /**
  59312. * The rendering group to draw the layer in.
  59313. */
  59314. renderingGroupId: number;
  59315. }
  59316. /**
  59317. * The effect layer Helps adding post process effect blended with the main pass.
  59318. *
  59319. * This can be for instance use to generate glow or higlight effects on the scene.
  59320. *
  59321. * The effect layer class can not be used directly and is intented to inherited from to be
  59322. * customized per effects.
  59323. */
  59324. export abstract class EffectLayer {
  59325. private _vertexBuffers;
  59326. private _indexBuffer;
  59327. private _cachedDefines;
  59328. private _effectLayerMapGenerationEffect;
  59329. private _effectLayerOptions;
  59330. private _mergeEffect;
  59331. protected _scene: Scene;
  59332. protected _engine: Engine;
  59333. protected _maxSize: number;
  59334. protected _mainTextureDesiredSize: ISize;
  59335. protected _mainTexture: RenderTargetTexture;
  59336. protected _shouldRender: boolean;
  59337. protected _postProcesses: PostProcess[];
  59338. protected _textures: BaseTexture[];
  59339. protected _emissiveTextureAndColor: {
  59340. texture: Nullable<BaseTexture>;
  59341. color: Color4;
  59342. };
  59343. /**
  59344. * The name of the layer
  59345. */
  59346. name: string;
  59347. /**
  59348. * The clear color of the texture used to generate the glow map.
  59349. */
  59350. neutralColor: Color4;
  59351. /**
  59352. * Specifies whether the highlight layer is enabled or not.
  59353. */
  59354. isEnabled: boolean;
  59355. /**
  59356. * Gets the camera attached to the layer.
  59357. */
  59358. get camera(): Nullable<Camera>;
  59359. /**
  59360. * Gets the rendering group id the layer should render in.
  59361. */
  59362. get renderingGroupId(): number;
  59363. set renderingGroupId(renderingGroupId: number);
  59364. /**
  59365. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59366. */
  59367. disableBoundingBoxesFromEffectLayer: boolean;
  59368. /**
  59369. * An event triggered when the effect layer has been disposed.
  59370. */
  59371. onDisposeObservable: Observable<EffectLayer>;
  59372. /**
  59373. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59374. */
  59375. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59376. /**
  59377. * An event triggered when the generated texture is being merged in the scene.
  59378. */
  59379. onBeforeComposeObservable: Observable<EffectLayer>;
  59380. /**
  59381. * An event triggered when the mesh is rendered into the effect render target.
  59382. */
  59383. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59384. /**
  59385. * An event triggered after the mesh has been rendered into the effect render target.
  59386. */
  59387. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59388. /**
  59389. * An event triggered when the generated texture has been merged in the scene.
  59390. */
  59391. onAfterComposeObservable: Observable<EffectLayer>;
  59392. /**
  59393. * An event triggered when the efffect layer changes its size.
  59394. */
  59395. onSizeChangedObservable: Observable<EffectLayer>;
  59396. /** @hidden */
  59397. static _SceneComponentInitialization: (scene: Scene) => void;
  59398. /**
  59399. * Instantiates a new effect Layer and references it in the scene.
  59400. * @param name The name of the layer
  59401. * @param scene The scene to use the layer in
  59402. */
  59403. constructor(
  59404. /** The Friendly of the effect in the scene */
  59405. name: string, scene: Scene);
  59406. /**
  59407. * Get the effect name of the layer.
  59408. * @return The effect name
  59409. */
  59410. abstract getEffectName(): string;
  59411. /**
  59412. * Checks for the readiness of the element composing the layer.
  59413. * @param subMesh the mesh to check for
  59414. * @param useInstances specify whether or not to use instances to render the mesh
  59415. * @return true if ready otherwise, false
  59416. */
  59417. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59418. /**
  59419. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59420. * @returns true if the effect requires stencil during the main canvas render pass.
  59421. */
  59422. abstract needStencil(): boolean;
  59423. /**
  59424. * Create the merge effect. This is the shader use to blit the information back
  59425. * to the main canvas at the end of the scene rendering.
  59426. * @returns The effect containing the shader used to merge the effect on the main canvas
  59427. */
  59428. protected abstract _createMergeEffect(): Effect;
  59429. /**
  59430. * Creates the render target textures and post processes used in the effect layer.
  59431. */
  59432. protected abstract _createTextureAndPostProcesses(): void;
  59433. /**
  59434. * Implementation specific of rendering the generating effect on the main canvas.
  59435. * @param effect The effect used to render through
  59436. */
  59437. protected abstract _internalRender(effect: Effect): void;
  59438. /**
  59439. * Sets the required values for both the emissive texture and and the main color.
  59440. */
  59441. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59442. /**
  59443. * Free any resources and references associated to a mesh.
  59444. * Internal use
  59445. * @param mesh The mesh to free.
  59446. */
  59447. abstract _disposeMesh(mesh: Mesh): void;
  59448. /**
  59449. * Serializes this layer (Glow or Highlight for example)
  59450. * @returns a serialized layer object
  59451. */
  59452. abstract serialize?(): any;
  59453. /**
  59454. * Initializes the effect layer with the required options.
  59455. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59456. */
  59457. protected _init(options: Partial<IEffectLayerOptions>): void;
  59458. /**
  59459. * Generates the index buffer of the full screen quad blending to the main canvas.
  59460. */
  59461. private _generateIndexBuffer;
  59462. /**
  59463. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59464. */
  59465. private _generateVertexBuffer;
  59466. /**
  59467. * Sets the main texture desired size which is the closest power of two
  59468. * of the engine canvas size.
  59469. */
  59470. private _setMainTextureSize;
  59471. /**
  59472. * Creates the main texture for the effect layer.
  59473. */
  59474. protected _createMainTexture(): void;
  59475. /**
  59476. * Adds specific effects defines.
  59477. * @param defines The defines to add specifics to.
  59478. */
  59479. protected _addCustomEffectDefines(defines: string[]): void;
  59480. /**
  59481. * Checks for the readiness of the element composing the layer.
  59482. * @param subMesh the mesh to check for
  59483. * @param useInstances specify whether or not to use instances to render the mesh
  59484. * @param emissiveTexture the associated emissive texture used to generate the glow
  59485. * @return true if ready otherwise, false
  59486. */
  59487. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59488. /**
  59489. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59490. */
  59491. render(): void;
  59492. /**
  59493. * Determine if a given mesh will be used in the current effect.
  59494. * @param mesh mesh to test
  59495. * @returns true if the mesh will be used
  59496. */
  59497. hasMesh(mesh: AbstractMesh): boolean;
  59498. /**
  59499. * Returns true if the layer contains information to display, otherwise false.
  59500. * @returns true if the glow layer should be rendered
  59501. */
  59502. shouldRender(): boolean;
  59503. /**
  59504. * Returns true if the mesh should render, otherwise false.
  59505. * @param mesh The mesh to render
  59506. * @returns true if it should render otherwise false
  59507. */
  59508. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59509. /**
  59510. * Returns true if the mesh can be rendered, otherwise false.
  59511. * @param mesh The mesh to render
  59512. * @param material The material used on the mesh
  59513. * @returns true if it can be rendered otherwise false
  59514. */
  59515. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59516. /**
  59517. * Returns true if the mesh should render, otherwise false.
  59518. * @param mesh The mesh to render
  59519. * @returns true if it should render otherwise false
  59520. */
  59521. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59522. /**
  59523. * Renders the submesh passed in parameter to the generation map.
  59524. */
  59525. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59526. /**
  59527. * Defines whether the current material of the mesh should be use to render the effect.
  59528. * @param mesh defines the current mesh to render
  59529. */
  59530. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59531. /**
  59532. * Rebuild the required buffers.
  59533. * @hidden Internal use only.
  59534. */
  59535. _rebuild(): void;
  59536. /**
  59537. * Dispose only the render target textures and post process.
  59538. */
  59539. private _disposeTextureAndPostProcesses;
  59540. /**
  59541. * Dispose the highlight layer and free resources.
  59542. */
  59543. dispose(): void;
  59544. /**
  59545. * Gets the class name of the effect layer
  59546. * @returns the string with the class name of the effect layer
  59547. */
  59548. getClassName(): string;
  59549. /**
  59550. * Creates an effect layer from parsed effect layer data
  59551. * @param parsedEffectLayer defines effect layer data
  59552. * @param scene defines the current scene
  59553. * @param rootUrl defines the root URL containing the effect layer information
  59554. * @returns a parsed effect Layer
  59555. */
  59556. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59557. }
  59558. }
  59559. declare module BABYLON {
  59560. interface AbstractScene {
  59561. /**
  59562. * The list of effect layers (highlights/glow) added to the scene
  59563. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59564. * @see https://doc.babylonjs.com/how_to/glow_layer
  59565. */
  59566. effectLayers: Array<EffectLayer>;
  59567. /**
  59568. * Removes the given effect layer from this scene.
  59569. * @param toRemove defines the effect layer to remove
  59570. * @returns the index of the removed effect layer
  59571. */
  59572. removeEffectLayer(toRemove: EffectLayer): number;
  59573. /**
  59574. * Adds the given effect layer to this scene
  59575. * @param newEffectLayer defines the effect layer to add
  59576. */
  59577. addEffectLayer(newEffectLayer: EffectLayer): void;
  59578. }
  59579. /**
  59580. * Defines the layer scene component responsible to manage any effect layers
  59581. * in a given scene.
  59582. */
  59583. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59584. /**
  59585. * The component name helpfull to identify the component in the list of scene components.
  59586. */
  59587. readonly name: string;
  59588. /**
  59589. * The scene the component belongs to.
  59590. */
  59591. scene: Scene;
  59592. private _engine;
  59593. private _renderEffects;
  59594. private _needStencil;
  59595. private _previousStencilState;
  59596. /**
  59597. * Creates a new instance of the component for the given scene
  59598. * @param scene Defines the scene to register the component in
  59599. */
  59600. constructor(scene: Scene);
  59601. /**
  59602. * Registers the component in a given scene
  59603. */
  59604. register(): void;
  59605. /**
  59606. * Rebuilds the elements related to this component in case of
  59607. * context lost for instance.
  59608. */
  59609. rebuild(): void;
  59610. /**
  59611. * Serializes the component data to the specified json object
  59612. * @param serializationObject The object to serialize to
  59613. */
  59614. serialize(serializationObject: any): void;
  59615. /**
  59616. * Adds all the elements from the container to the scene
  59617. * @param container the container holding the elements
  59618. */
  59619. addFromContainer(container: AbstractScene): void;
  59620. /**
  59621. * Removes all the elements in the container from the scene
  59622. * @param container contains the elements to remove
  59623. * @param dispose if the removed element should be disposed (default: false)
  59624. */
  59625. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59626. /**
  59627. * Disposes the component and the associated ressources.
  59628. */
  59629. dispose(): void;
  59630. private _isReadyForMesh;
  59631. private _renderMainTexture;
  59632. private _setStencil;
  59633. private _setStencilBack;
  59634. private _draw;
  59635. private _drawCamera;
  59636. private _drawRenderingGroup;
  59637. }
  59638. }
  59639. declare module BABYLON {
  59640. /** @hidden */
  59641. export var glowMapMergePixelShader: {
  59642. name: string;
  59643. shader: string;
  59644. };
  59645. }
  59646. declare module BABYLON {
  59647. /** @hidden */
  59648. export var glowMapMergeVertexShader: {
  59649. name: string;
  59650. shader: string;
  59651. };
  59652. }
  59653. declare module BABYLON {
  59654. interface AbstractScene {
  59655. /**
  59656. * Return a the first highlight layer of the scene with a given name.
  59657. * @param name The name of the highlight layer to look for.
  59658. * @return The highlight layer if found otherwise null.
  59659. */
  59660. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59661. }
  59662. /**
  59663. * Glow layer options. This helps customizing the behaviour
  59664. * of the glow layer.
  59665. */
  59666. export interface IGlowLayerOptions {
  59667. /**
  59668. * Multiplication factor apply to the canvas size to compute the render target size
  59669. * used to generated the glowing objects (the smaller the faster).
  59670. */
  59671. mainTextureRatio: number;
  59672. /**
  59673. * Enforces a fixed size texture to ensure resize independant blur.
  59674. */
  59675. mainTextureFixedSize?: number;
  59676. /**
  59677. * How big is the kernel of the blur texture.
  59678. */
  59679. blurKernelSize: number;
  59680. /**
  59681. * The camera attached to the layer.
  59682. */
  59683. camera: Nullable<Camera>;
  59684. /**
  59685. * Enable MSAA by chosing the number of samples.
  59686. */
  59687. mainTextureSamples?: number;
  59688. /**
  59689. * The rendering group to draw the layer in.
  59690. */
  59691. renderingGroupId: number;
  59692. }
  59693. /**
  59694. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59695. *
  59696. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59697. *
  59698. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59699. */
  59700. export class GlowLayer extends EffectLayer {
  59701. /**
  59702. * Effect Name of the layer.
  59703. */
  59704. static readonly EffectName: string;
  59705. /**
  59706. * The default blur kernel size used for the glow.
  59707. */
  59708. static DefaultBlurKernelSize: number;
  59709. /**
  59710. * The default texture size ratio used for the glow.
  59711. */
  59712. static DefaultTextureRatio: number;
  59713. /**
  59714. * Sets the kernel size of the blur.
  59715. */
  59716. set blurKernelSize(value: number);
  59717. /**
  59718. * Gets the kernel size of the blur.
  59719. */
  59720. get blurKernelSize(): number;
  59721. /**
  59722. * Sets the glow intensity.
  59723. */
  59724. set intensity(value: number);
  59725. /**
  59726. * Gets the glow intensity.
  59727. */
  59728. get intensity(): number;
  59729. private _options;
  59730. private _intensity;
  59731. private _horizontalBlurPostprocess1;
  59732. private _verticalBlurPostprocess1;
  59733. private _horizontalBlurPostprocess2;
  59734. private _verticalBlurPostprocess2;
  59735. private _blurTexture1;
  59736. private _blurTexture2;
  59737. private _postProcesses1;
  59738. private _postProcesses2;
  59739. private _includedOnlyMeshes;
  59740. private _excludedMeshes;
  59741. private _meshesUsingTheirOwnMaterials;
  59742. /**
  59743. * Callback used to let the user override the color selection on a per mesh basis
  59744. */
  59745. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59746. /**
  59747. * Callback used to let the user override the texture selection on a per mesh basis
  59748. */
  59749. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59750. /**
  59751. * Instantiates a new glow Layer and references it to the scene.
  59752. * @param name The name of the layer
  59753. * @param scene The scene to use the layer in
  59754. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59755. */
  59756. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59757. /**
  59758. * Get the effect name of the layer.
  59759. * @return The effect name
  59760. */
  59761. getEffectName(): string;
  59762. /**
  59763. * Create the merge effect. This is the shader use to blit the information back
  59764. * to the main canvas at the end of the scene rendering.
  59765. */
  59766. protected _createMergeEffect(): Effect;
  59767. /**
  59768. * Creates the render target textures and post processes used in the glow layer.
  59769. */
  59770. protected _createTextureAndPostProcesses(): void;
  59771. /**
  59772. * Checks for the readiness of the element composing the layer.
  59773. * @param subMesh the mesh to check for
  59774. * @param useInstances specify wether or not to use instances to render the mesh
  59775. * @param emissiveTexture the associated emissive texture used to generate the glow
  59776. * @return true if ready otherwise, false
  59777. */
  59778. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59779. /**
  59780. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59781. */
  59782. needStencil(): boolean;
  59783. /**
  59784. * Returns true if the mesh can be rendered, otherwise false.
  59785. * @param mesh The mesh to render
  59786. * @param material The material used on the mesh
  59787. * @returns true if it can be rendered otherwise false
  59788. */
  59789. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59790. /**
  59791. * Implementation specific of rendering the generating effect on the main canvas.
  59792. * @param effect The effect used to render through
  59793. */
  59794. protected _internalRender(effect: Effect): void;
  59795. /**
  59796. * Sets the required values for both the emissive texture and and the main color.
  59797. */
  59798. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59799. /**
  59800. * Returns true if the mesh should render, otherwise false.
  59801. * @param mesh The mesh to render
  59802. * @returns true if it should render otherwise false
  59803. */
  59804. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59805. /**
  59806. * Adds specific effects defines.
  59807. * @param defines The defines to add specifics to.
  59808. */
  59809. protected _addCustomEffectDefines(defines: string[]): void;
  59810. /**
  59811. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59812. * @param mesh The mesh to exclude from the glow layer
  59813. */
  59814. addExcludedMesh(mesh: Mesh): void;
  59815. /**
  59816. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59817. * @param mesh The mesh to remove
  59818. */
  59819. removeExcludedMesh(mesh: Mesh): void;
  59820. /**
  59821. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59822. * @param mesh The mesh to include in the glow layer
  59823. */
  59824. addIncludedOnlyMesh(mesh: Mesh): void;
  59825. /**
  59826. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59827. * @param mesh The mesh to remove
  59828. */
  59829. removeIncludedOnlyMesh(mesh: Mesh): void;
  59830. /**
  59831. * Determine if a given mesh will be used in the glow layer
  59832. * @param mesh The mesh to test
  59833. * @returns true if the mesh will be highlighted by the current glow layer
  59834. */
  59835. hasMesh(mesh: AbstractMesh): boolean;
  59836. /**
  59837. * Defines whether the current material of the mesh should be use to render the effect.
  59838. * @param mesh defines the current mesh to render
  59839. */
  59840. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59841. /**
  59842. * Add a mesh to be rendered through its own material and not with emissive only.
  59843. * @param mesh The mesh for which we need to use its material
  59844. */
  59845. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59846. /**
  59847. * Remove a mesh from being rendered through its own material and not with emissive only.
  59848. * @param mesh The mesh for which we need to not use its material
  59849. */
  59850. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59851. /**
  59852. * Free any resources and references associated to a mesh.
  59853. * Internal use
  59854. * @param mesh The mesh to free.
  59855. * @hidden
  59856. */
  59857. _disposeMesh(mesh: Mesh): void;
  59858. /**
  59859. * Gets the class name of the effect layer
  59860. * @returns the string with the class name of the effect layer
  59861. */
  59862. getClassName(): string;
  59863. /**
  59864. * Serializes this glow layer
  59865. * @returns a serialized glow layer object
  59866. */
  59867. serialize(): any;
  59868. /**
  59869. * Creates a Glow Layer from parsed glow layer data
  59870. * @param parsedGlowLayer defines glow layer data
  59871. * @param scene defines the current scene
  59872. * @param rootUrl defines the root URL containing the glow layer information
  59873. * @returns a parsed Glow Layer
  59874. */
  59875. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59876. }
  59877. }
  59878. declare module BABYLON {
  59879. /** @hidden */
  59880. export var glowBlurPostProcessPixelShader: {
  59881. name: string;
  59882. shader: string;
  59883. };
  59884. }
  59885. declare module BABYLON {
  59886. interface AbstractScene {
  59887. /**
  59888. * Return a the first highlight layer of the scene with a given name.
  59889. * @param name The name of the highlight layer to look for.
  59890. * @return The highlight layer if found otherwise null.
  59891. */
  59892. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59893. }
  59894. /**
  59895. * Highlight layer options. This helps customizing the behaviour
  59896. * of the highlight layer.
  59897. */
  59898. export interface IHighlightLayerOptions {
  59899. /**
  59900. * Multiplication factor apply to the canvas size to compute the render target size
  59901. * used to generated the glowing objects (the smaller the faster).
  59902. */
  59903. mainTextureRatio: number;
  59904. /**
  59905. * Enforces a fixed size texture to ensure resize independant blur.
  59906. */
  59907. mainTextureFixedSize?: number;
  59908. /**
  59909. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59910. * of the picture to blur (the smaller the faster).
  59911. */
  59912. blurTextureSizeRatio: number;
  59913. /**
  59914. * How big in texel of the blur texture is the vertical blur.
  59915. */
  59916. blurVerticalSize: number;
  59917. /**
  59918. * How big in texel of the blur texture is the horizontal blur.
  59919. */
  59920. blurHorizontalSize: number;
  59921. /**
  59922. * Alpha blending mode used to apply the blur. Default is combine.
  59923. */
  59924. alphaBlendingMode: number;
  59925. /**
  59926. * The camera attached to the layer.
  59927. */
  59928. camera: Nullable<Camera>;
  59929. /**
  59930. * Should we display highlight as a solid stroke?
  59931. */
  59932. isStroke?: boolean;
  59933. /**
  59934. * The rendering group to draw the layer in.
  59935. */
  59936. renderingGroupId: number;
  59937. }
  59938. /**
  59939. * The highlight layer Helps adding a glow effect around a mesh.
  59940. *
  59941. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59942. * glowy meshes to your scene.
  59943. *
  59944. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59945. */
  59946. export class HighlightLayer extends EffectLayer {
  59947. name: string;
  59948. /**
  59949. * Effect Name of the highlight layer.
  59950. */
  59951. static readonly EffectName: string;
  59952. /**
  59953. * The neutral color used during the preparation of the glow effect.
  59954. * This is black by default as the blend operation is a blend operation.
  59955. */
  59956. static NeutralColor: Color4;
  59957. /**
  59958. * Stencil value used for glowing meshes.
  59959. */
  59960. static GlowingMeshStencilReference: number;
  59961. /**
  59962. * Stencil value used for the other meshes in the scene.
  59963. */
  59964. static NormalMeshStencilReference: number;
  59965. /**
  59966. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59967. */
  59968. innerGlow: boolean;
  59969. /**
  59970. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59971. */
  59972. outerGlow: boolean;
  59973. /**
  59974. * Specifies the horizontal size of the blur.
  59975. */
  59976. set blurHorizontalSize(value: number);
  59977. /**
  59978. * Specifies the vertical size of the blur.
  59979. */
  59980. set blurVerticalSize(value: number);
  59981. /**
  59982. * Gets the horizontal size of the blur.
  59983. */
  59984. get blurHorizontalSize(): number;
  59985. /**
  59986. * Gets the vertical size of the blur.
  59987. */
  59988. get blurVerticalSize(): number;
  59989. /**
  59990. * An event triggered when the highlight layer is being blurred.
  59991. */
  59992. onBeforeBlurObservable: Observable<HighlightLayer>;
  59993. /**
  59994. * An event triggered when the highlight layer has been blurred.
  59995. */
  59996. onAfterBlurObservable: Observable<HighlightLayer>;
  59997. private _instanceGlowingMeshStencilReference;
  59998. private _options;
  59999. private _downSamplePostprocess;
  60000. private _horizontalBlurPostprocess;
  60001. private _verticalBlurPostprocess;
  60002. private _blurTexture;
  60003. private _meshes;
  60004. private _excludedMeshes;
  60005. /**
  60006. * Instantiates a new highlight Layer and references it to the scene..
  60007. * @param name The name of the layer
  60008. * @param scene The scene to use the layer in
  60009. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60010. */
  60011. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60012. /**
  60013. * Get the effect name of the layer.
  60014. * @return The effect name
  60015. */
  60016. getEffectName(): string;
  60017. /**
  60018. * Create the merge effect. This is the shader use to blit the information back
  60019. * to the main canvas at the end of the scene rendering.
  60020. */
  60021. protected _createMergeEffect(): Effect;
  60022. /**
  60023. * Creates the render target textures and post processes used in the highlight layer.
  60024. */
  60025. protected _createTextureAndPostProcesses(): void;
  60026. /**
  60027. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60028. */
  60029. needStencil(): boolean;
  60030. /**
  60031. * Checks for the readiness of the element composing the layer.
  60032. * @param subMesh the mesh to check for
  60033. * @param useInstances specify wether or not to use instances to render the mesh
  60034. * @param emissiveTexture the associated emissive texture used to generate the glow
  60035. * @return true if ready otherwise, false
  60036. */
  60037. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60038. /**
  60039. * Implementation specific of rendering the generating effect on the main canvas.
  60040. * @param effect The effect used to render through
  60041. */
  60042. protected _internalRender(effect: Effect): void;
  60043. /**
  60044. * Returns true if the layer contains information to display, otherwise false.
  60045. */
  60046. shouldRender(): boolean;
  60047. /**
  60048. * Returns true if the mesh should render, otherwise false.
  60049. * @param mesh The mesh to render
  60050. * @returns true if it should render otherwise false
  60051. */
  60052. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60053. /**
  60054. * Returns true if the mesh can be rendered, otherwise false.
  60055. * @param mesh The mesh to render
  60056. * @param material The material used on the mesh
  60057. * @returns true if it can be rendered otherwise false
  60058. */
  60059. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60060. /**
  60061. * Adds specific effects defines.
  60062. * @param defines The defines to add specifics to.
  60063. */
  60064. protected _addCustomEffectDefines(defines: string[]): void;
  60065. /**
  60066. * Sets the required values for both the emissive texture and and the main color.
  60067. */
  60068. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60069. /**
  60070. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60071. * @param mesh The mesh to exclude from the highlight layer
  60072. */
  60073. addExcludedMesh(mesh: Mesh): void;
  60074. /**
  60075. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60076. * @param mesh The mesh to highlight
  60077. */
  60078. removeExcludedMesh(mesh: Mesh): void;
  60079. /**
  60080. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60081. * @param mesh mesh to test
  60082. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60083. */
  60084. hasMesh(mesh: AbstractMesh): boolean;
  60085. /**
  60086. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60087. * @param mesh The mesh to highlight
  60088. * @param color The color of the highlight
  60089. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60090. */
  60091. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60092. /**
  60093. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60094. * @param mesh The mesh to highlight
  60095. */
  60096. removeMesh(mesh: Mesh): void;
  60097. /**
  60098. * Remove all the meshes currently referenced in the highlight layer
  60099. */
  60100. removeAllMeshes(): void;
  60101. /**
  60102. * Force the stencil to the normal expected value for none glowing parts
  60103. */
  60104. private _defaultStencilReference;
  60105. /**
  60106. * Free any resources and references associated to a mesh.
  60107. * Internal use
  60108. * @param mesh The mesh to free.
  60109. * @hidden
  60110. */
  60111. _disposeMesh(mesh: Mesh): void;
  60112. /**
  60113. * Dispose the highlight layer and free resources.
  60114. */
  60115. dispose(): void;
  60116. /**
  60117. * Gets the class name of the effect layer
  60118. * @returns the string with the class name of the effect layer
  60119. */
  60120. getClassName(): string;
  60121. /**
  60122. * Serializes this Highlight layer
  60123. * @returns a serialized Highlight layer object
  60124. */
  60125. serialize(): any;
  60126. /**
  60127. * Creates a Highlight layer from parsed Highlight layer data
  60128. * @param parsedHightlightLayer defines the Highlight layer data
  60129. * @param scene defines the current scene
  60130. * @param rootUrl defines the root URL containing the Highlight layer information
  60131. * @returns a parsed Highlight layer
  60132. */
  60133. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60134. }
  60135. }
  60136. declare module BABYLON {
  60137. interface AbstractScene {
  60138. /**
  60139. * The list of layers (background and foreground) of the scene
  60140. */
  60141. layers: Array<Layer>;
  60142. }
  60143. /**
  60144. * Defines the layer scene component responsible to manage any layers
  60145. * in a given scene.
  60146. */
  60147. export class LayerSceneComponent implements ISceneComponent {
  60148. /**
  60149. * The component name helpfull to identify the component in the list of scene components.
  60150. */
  60151. readonly name: string;
  60152. /**
  60153. * The scene the component belongs to.
  60154. */
  60155. scene: Scene;
  60156. private _engine;
  60157. /**
  60158. * Creates a new instance of the component for the given scene
  60159. * @param scene Defines the scene to register the component in
  60160. */
  60161. constructor(scene: Scene);
  60162. /**
  60163. * Registers the component in a given scene
  60164. */
  60165. register(): void;
  60166. /**
  60167. * Rebuilds the elements related to this component in case of
  60168. * context lost for instance.
  60169. */
  60170. rebuild(): void;
  60171. /**
  60172. * Disposes the component and the associated ressources.
  60173. */
  60174. dispose(): void;
  60175. private _draw;
  60176. private _drawCameraPredicate;
  60177. private _drawCameraBackground;
  60178. private _drawCameraForeground;
  60179. private _drawRenderTargetPredicate;
  60180. private _drawRenderTargetBackground;
  60181. private _drawRenderTargetForeground;
  60182. /**
  60183. * Adds all the elements from the container to the scene
  60184. * @param container the container holding the elements
  60185. */
  60186. addFromContainer(container: AbstractScene): void;
  60187. /**
  60188. * Removes all the elements in the container from the scene
  60189. * @param container contains the elements to remove
  60190. * @param dispose if the removed element should be disposed (default: false)
  60191. */
  60192. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60193. }
  60194. }
  60195. declare module BABYLON {
  60196. /** @hidden */
  60197. export var layerPixelShader: {
  60198. name: string;
  60199. shader: string;
  60200. };
  60201. }
  60202. declare module BABYLON {
  60203. /** @hidden */
  60204. export var layerVertexShader: {
  60205. name: string;
  60206. shader: string;
  60207. };
  60208. }
  60209. declare module BABYLON {
  60210. /**
  60211. * This represents a full screen 2d layer.
  60212. * This can be useful to display a picture in the background of your scene for instance.
  60213. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60214. */
  60215. export class Layer {
  60216. /**
  60217. * Define the name of the layer.
  60218. */
  60219. name: string;
  60220. /**
  60221. * Define the texture the layer should display.
  60222. */
  60223. texture: Nullable<Texture>;
  60224. /**
  60225. * Is the layer in background or foreground.
  60226. */
  60227. isBackground: boolean;
  60228. /**
  60229. * Define the color of the layer (instead of texture).
  60230. */
  60231. color: Color4;
  60232. /**
  60233. * Define the scale of the layer in order to zoom in out of the texture.
  60234. */
  60235. scale: Vector2;
  60236. /**
  60237. * Define an offset for the layer in order to shift the texture.
  60238. */
  60239. offset: Vector2;
  60240. /**
  60241. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60242. */
  60243. alphaBlendingMode: number;
  60244. /**
  60245. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60246. * Alpha test will not mix with the background color in case of transparency.
  60247. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60248. */
  60249. alphaTest: boolean;
  60250. /**
  60251. * Define a mask to restrict the layer to only some of the scene cameras.
  60252. */
  60253. layerMask: number;
  60254. /**
  60255. * Define the list of render target the layer is visible into.
  60256. */
  60257. renderTargetTextures: RenderTargetTexture[];
  60258. /**
  60259. * Define if the layer is only used in renderTarget or if it also
  60260. * renders in the main frame buffer of the canvas.
  60261. */
  60262. renderOnlyInRenderTargetTextures: boolean;
  60263. private _scene;
  60264. private _vertexBuffers;
  60265. private _indexBuffer;
  60266. private _effect;
  60267. private _previousDefines;
  60268. /**
  60269. * An event triggered when the layer is disposed.
  60270. */
  60271. onDisposeObservable: Observable<Layer>;
  60272. private _onDisposeObserver;
  60273. /**
  60274. * Back compatibility with callback before the onDisposeObservable existed.
  60275. * The set callback will be triggered when the layer has been disposed.
  60276. */
  60277. set onDispose(callback: () => void);
  60278. /**
  60279. * An event triggered before rendering the scene
  60280. */
  60281. onBeforeRenderObservable: Observable<Layer>;
  60282. private _onBeforeRenderObserver;
  60283. /**
  60284. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60285. * The set callback will be triggered just before rendering the layer.
  60286. */
  60287. set onBeforeRender(callback: () => void);
  60288. /**
  60289. * An event triggered after rendering the scene
  60290. */
  60291. onAfterRenderObservable: Observable<Layer>;
  60292. private _onAfterRenderObserver;
  60293. /**
  60294. * Back compatibility with callback before the onAfterRenderObservable existed.
  60295. * The set callback will be triggered just after rendering the layer.
  60296. */
  60297. set onAfterRender(callback: () => void);
  60298. /**
  60299. * Instantiates a new layer.
  60300. * This represents a full screen 2d layer.
  60301. * This can be useful to display a picture in the background of your scene for instance.
  60302. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60303. * @param name Define the name of the layer in the scene
  60304. * @param imgUrl Define the url of the texture to display in the layer
  60305. * @param scene Define the scene the layer belongs to
  60306. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60307. * @param color Defines a color for the layer
  60308. */
  60309. constructor(
  60310. /**
  60311. * Define the name of the layer.
  60312. */
  60313. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60314. private _createIndexBuffer;
  60315. /** @hidden */
  60316. _rebuild(): void;
  60317. /**
  60318. * Renders the layer in the scene.
  60319. */
  60320. render(): void;
  60321. /**
  60322. * Disposes and releases the associated ressources.
  60323. */
  60324. dispose(): void;
  60325. }
  60326. }
  60327. declare module BABYLON {
  60328. /** @hidden */
  60329. export var lensFlarePixelShader: {
  60330. name: string;
  60331. shader: string;
  60332. };
  60333. }
  60334. declare module BABYLON {
  60335. /** @hidden */
  60336. export var lensFlareVertexShader: {
  60337. name: string;
  60338. shader: string;
  60339. };
  60340. }
  60341. declare module BABYLON {
  60342. /**
  60343. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60344. * It is usually composed of several `lensFlare`.
  60345. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60346. */
  60347. export class LensFlareSystem {
  60348. /**
  60349. * Define the name of the lens flare system
  60350. */
  60351. name: string;
  60352. /**
  60353. * List of lens flares used in this system.
  60354. */
  60355. lensFlares: LensFlare[];
  60356. /**
  60357. * Define a limit from the border the lens flare can be visible.
  60358. */
  60359. borderLimit: number;
  60360. /**
  60361. * Define a viewport border we do not want to see the lens flare in.
  60362. */
  60363. viewportBorder: number;
  60364. /**
  60365. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60366. */
  60367. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60368. /**
  60369. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60370. */
  60371. layerMask: number;
  60372. /**
  60373. * Define the id of the lens flare system in the scene.
  60374. * (equal to name by default)
  60375. */
  60376. id: string;
  60377. private _scene;
  60378. private _emitter;
  60379. private _vertexBuffers;
  60380. private _indexBuffer;
  60381. private _effect;
  60382. private _positionX;
  60383. private _positionY;
  60384. private _isEnabled;
  60385. /** @hidden */
  60386. static _SceneComponentInitialization: (scene: Scene) => void;
  60387. /**
  60388. * Instantiates a lens flare system.
  60389. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60390. * It is usually composed of several `lensFlare`.
  60391. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60392. * @param name Define the name of the lens flare system in the scene
  60393. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60394. * @param scene Define the scene the lens flare system belongs to
  60395. */
  60396. constructor(
  60397. /**
  60398. * Define the name of the lens flare system
  60399. */
  60400. name: string, emitter: any, scene: Scene);
  60401. /**
  60402. * Define if the lens flare system is enabled.
  60403. */
  60404. get isEnabled(): boolean;
  60405. set isEnabled(value: boolean);
  60406. /**
  60407. * Get the scene the effects belongs to.
  60408. * @returns the scene holding the lens flare system
  60409. */
  60410. getScene(): Scene;
  60411. /**
  60412. * Get the emitter of the lens flare system.
  60413. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60414. * @returns the emitter of the lens flare system
  60415. */
  60416. getEmitter(): any;
  60417. /**
  60418. * Set the emitter of the lens flare system.
  60419. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60420. * @param newEmitter Define the new emitter of the system
  60421. */
  60422. setEmitter(newEmitter: any): void;
  60423. /**
  60424. * Get the lens flare system emitter position.
  60425. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60426. * @returns the position
  60427. */
  60428. getEmitterPosition(): Vector3;
  60429. /**
  60430. * @hidden
  60431. */
  60432. computeEffectivePosition(globalViewport: Viewport): boolean;
  60433. /** @hidden */
  60434. _isVisible(): boolean;
  60435. /**
  60436. * @hidden
  60437. */
  60438. render(): boolean;
  60439. /**
  60440. * Dispose and release the lens flare with its associated resources.
  60441. */
  60442. dispose(): void;
  60443. /**
  60444. * Parse a lens flare system from a JSON repressentation
  60445. * @param parsedLensFlareSystem Define the JSON to parse
  60446. * @param scene Define the scene the parsed system should be instantiated in
  60447. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60448. * @returns the parsed system
  60449. */
  60450. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60451. /**
  60452. * Serialize the current Lens Flare System into a JSON representation.
  60453. * @returns the serialized JSON
  60454. */
  60455. serialize(): any;
  60456. }
  60457. }
  60458. declare module BABYLON {
  60459. /**
  60460. * This represents one of the lens effect in a `lensFlareSystem`.
  60461. * It controls one of the indiviual texture used in the effect.
  60462. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60463. */
  60464. export class LensFlare {
  60465. /**
  60466. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60467. */
  60468. size: number;
  60469. /**
  60470. * 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.
  60471. */
  60472. position: number;
  60473. /**
  60474. * Define the lens color.
  60475. */
  60476. color: Color3;
  60477. /**
  60478. * Define the lens texture.
  60479. */
  60480. texture: Nullable<Texture>;
  60481. /**
  60482. * Define the alpha mode to render this particular lens.
  60483. */
  60484. alphaMode: number;
  60485. private _system;
  60486. /**
  60487. * Creates a new Lens Flare.
  60488. * This represents one of the lens effect in a `lensFlareSystem`.
  60489. * It controls one of the indiviual texture used in the effect.
  60490. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60491. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60492. * @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.
  60493. * @param color Define the lens color
  60494. * @param imgUrl Define the lens texture url
  60495. * @param system Define the `lensFlareSystem` this flare is part of
  60496. * @returns The newly created Lens Flare
  60497. */
  60498. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60499. /**
  60500. * Instantiates a new Lens Flare.
  60501. * This represents one of the lens effect in a `lensFlareSystem`.
  60502. * It controls one of the indiviual texture used in the effect.
  60503. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60504. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60505. * @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.
  60506. * @param color Define the lens color
  60507. * @param imgUrl Define the lens texture url
  60508. * @param system Define the `lensFlareSystem` this flare is part of
  60509. */
  60510. constructor(
  60511. /**
  60512. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60513. */
  60514. size: number,
  60515. /**
  60516. * 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.
  60517. */
  60518. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60519. /**
  60520. * Dispose and release the lens flare with its associated resources.
  60521. */
  60522. dispose(): void;
  60523. }
  60524. }
  60525. declare module BABYLON {
  60526. interface AbstractScene {
  60527. /**
  60528. * The list of lens flare system added to the scene
  60529. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60530. */
  60531. lensFlareSystems: Array<LensFlareSystem>;
  60532. /**
  60533. * Removes the given lens flare system from this scene.
  60534. * @param toRemove The lens flare system to remove
  60535. * @returns The index of the removed lens flare system
  60536. */
  60537. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60538. /**
  60539. * Adds the given lens flare system to this scene
  60540. * @param newLensFlareSystem The lens flare system to add
  60541. */
  60542. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60543. /**
  60544. * Gets a lens flare system using its name
  60545. * @param name defines the name to look for
  60546. * @returns the lens flare system or null if not found
  60547. */
  60548. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60549. /**
  60550. * Gets a lens flare system using its id
  60551. * @param id defines the id to look for
  60552. * @returns the lens flare system or null if not found
  60553. */
  60554. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60555. }
  60556. /**
  60557. * Defines the lens flare scene component responsible to manage any lens flares
  60558. * in a given scene.
  60559. */
  60560. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60561. /**
  60562. * The component name helpfull to identify the component in the list of scene components.
  60563. */
  60564. readonly name: string;
  60565. /**
  60566. * The scene the component belongs to.
  60567. */
  60568. scene: Scene;
  60569. /**
  60570. * Creates a new instance of the component for the given scene
  60571. * @param scene Defines the scene to register the component in
  60572. */
  60573. constructor(scene: Scene);
  60574. /**
  60575. * Registers the component in a given scene
  60576. */
  60577. register(): void;
  60578. /**
  60579. * Rebuilds the elements related to this component in case of
  60580. * context lost for instance.
  60581. */
  60582. rebuild(): void;
  60583. /**
  60584. * Adds all the elements from the container to the scene
  60585. * @param container the container holding the elements
  60586. */
  60587. addFromContainer(container: AbstractScene): void;
  60588. /**
  60589. * Removes all the elements in the container from the scene
  60590. * @param container contains the elements to remove
  60591. * @param dispose if the removed element should be disposed (default: false)
  60592. */
  60593. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60594. /**
  60595. * Serializes the component data to the specified json object
  60596. * @param serializationObject The object to serialize to
  60597. */
  60598. serialize(serializationObject: any): void;
  60599. /**
  60600. * Disposes the component and the associated ressources.
  60601. */
  60602. dispose(): void;
  60603. private _draw;
  60604. }
  60605. }
  60606. declare module BABYLON {
  60607. /** @hidden */
  60608. export var depthPixelShader: {
  60609. name: string;
  60610. shader: string;
  60611. };
  60612. }
  60613. declare module BABYLON {
  60614. /** @hidden */
  60615. export var depthVertexShader: {
  60616. name: string;
  60617. shader: string;
  60618. };
  60619. }
  60620. declare module BABYLON {
  60621. /**
  60622. * This represents a depth renderer in Babylon.
  60623. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60624. */
  60625. export class DepthRenderer {
  60626. private _scene;
  60627. private _depthMap;
  60628. private _effect;
  60629. private readonly _storeNonLinearDepth;
  60630. private readonly _clearColor;
  60631. /** Get if the depth renderer is using packed depth or not */
  60632. readonly isPacked: boolean;
  60633. private _cachedDefines;
  60634. private _camera;
  60635. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60636. enabled: boolean;
  60637. /**
  60638. * Specifiess that the depth renderer will only be used within
  60639. * the camera it is created for.
  60640. * This can help forcing its rendering during the camera processing.
  60641. */
  60642. useOnlyInActiveCamera: boolean;
  60643. /** @hidden */
  60644. static _SceneComponentInitialization: (scene: Scene) => void;
  60645. /**
  60646. * Instantiates a depth renderer
  60647. * @param scene The scene the renderer belongs to
  60648. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60649. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60650. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60651. */
  60652. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60653. /**
  60654. * Creates the depth rendering effect and checks if the effect is ready.
  60655. * @param subMesh The submesh to be used to render the depth map of
  60656. * @param useInstances If multiple world instances should be used
  60657. * @returns if the depth renderer is ready to render the depth map
  60658. */
  60659. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60660. /**
  60661. * Gets the texture which the depth map will be written to.
  60662. * @returns The depth map texture
  60663. */
  60664. getDepthMap(): RenderTargetTexture;
  60665. /**
  60666. * Disposes of the depth renderer.
  60667. */
  60668. dispose(): void;
  60669. }
  60670. }
  60671. declare module BABYLON {
  60672. /** @hidden */
  60673. export var minmaxReduxPixelShader: {
  60674. name: string;
  60675. shader: string;
  60676. };
  60677. }
  60678. declare module BABYLON {
  60679. /**
  60680. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60681. * and maximum values from all values of the texture.
  60682. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60683. * The source values are read from the red channel of the texture.
  60684. */
  60685. export class MinMaxReducer {
  60686. /**
  60687. * Observable triggered when the computation has been performed
  60688. */
  60689. onAfterReductionPerformed: Observable<{
  60690. min: number;
  60691. max: number;
  60692. }>;
  60693. protected _camera: Camera;
  60694. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60695. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60696. protected _postProcessManager: PostProcessManager;
  60697. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60698. protected _forceFullscreenViewport: boolean;
  60699. /**
  60700. * Creates a min/max reducer
  60701. * @param camera The camera to use for the post processes
  60702. */
  60703. constructor(camera: Camera);
  60704. /**
  60705. * Gets the texture used to read the values from.
  60706. */
  60707. get sourceTexture(): Nullable<RenderTargetTexture>;
  60708. /**
  60709. * Sets the source texture to read the values from.
  60710. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60711. * because in such textures '1' value must not be taken into account to compute the maximum
  60712. * as this value is used to clear the texture.
  60713. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60714. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60715. * @param depthRedux Indicates if the texture is a depth texture or not
  60716. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60717. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60718. */
  60719. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60720. /**
  60721. * Defines the refresh rate of the computation.
  60722. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60723. */
  60724. get refreshRate(): number;
  60725. set refreshRate(value: number);
  60726. protected _activated: boolean;
  60727. /**
  60728. * Gets the activation status of the reducer
  60729. */
  60730. get activated(): boolean;
  60731. /**
  60732. * Activates the reduction computation.
  60733. * When activated, the observers registered in onAfterReductionPerformed are
  60734. * called after the compuation is performed
  60735. */
  60736. activate(): void;
  60737. /**
  60738. * Deactivates the reduction computation.
  60739. */
  60740. deactivate(): void;
  60741. /**
  60742. * Disposes the min/max reducer
  60743. * @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.
  60744. */
  60745. dispose(disposeAll?: boolean): void;
  60746. }
  60747. }
  60748. declare module BABYLON {
  60749. /**
  60750. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60751. */
  60752. export class DepthReducer extends MinMaxReducer {
  60753. private _depthRenderer;
  60754. private _depthRendererId;
  60755. /**
  60756. * Gets the depth renderer used for the computation.
  60757. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60758. */
  60759. get depthRenderer(): Nullable<DepthRenderer>;
  60760. /**
  60761. * Creates a depth reducer
  60762. * @param camera The camera used to render the depth texture
  60763. */
  60764. constructor(camera: Camera);
  60765. /**
  60766. * Sets the depth renderer to use to generate the depth map
  60767. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60768. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60769. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60770. */
  60771. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60772. /** @hidden */
  60773. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60774. /**
  60775. * Activates the reduction computation.
  60776. * When activated, the observers registered in onAfterReductionPerformed are
  60777. * called after the compuation is performed
  60778. */
  60779. activate(): void;
  60780. /**
  60781. * Deactivates the reduction computation.
  60782. */
  60783. deactivate(): void;
  60784. /**
  60785. * Disposes the depth reducer
  60786. * @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.
  60787. */
  60788. dispose(disposeAll?: boolean): void;
  60789. }
  60790. }
  60791. declare module BABYLON {
  60792. /**
  60793. * A CSM implementation allowing casting shadows on large scenes.
  60794. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60795. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60796. */
  60797. export class CascadedShadowGenerator extends ShadowGenerator {
  60798. private static readonly frustumCornersNDCSpace;
  60799. /**
  60800. * Name of the CSM class
  60801. */
  60802. static CLASSNAME: string;
  60803. /**
  60804. * Defines the default number of cascades used by the CSM.
  60805. */
  60806. static readonly DEFAULT_CASCADES_COUNT: number;
  60807. /**
  60808. * Defines the minimum number of cascades used by the CSM.
  60809. */
  60810. static readonly MIN_CASCADES_COUNT: number;
  60811. /**
  60812. * Defines the maximum number of cascades used by the CSM.
  60813. */
  60814. static readonly MAX_CASCADES_COUNT: number;
  60815. protected _validateFilter(filter: number): number;
  60816. /**
  60817. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60818. */
  60819. penumbraDarkness: number;
  60820. private _numCascades;
  60821. /**
  60822. * Gets or set the number of cascades used by the CSM.
  60823. */
  60824. get numCascades(): number;
  60825. set numCascades(value: number);
  60826. /**
  60827. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60828. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60829. */
  60830. stabilizeCascades: boolean;
  60831. private _freezeShadowCastersBoundingInfo;
  60832. private _freezeShadowCastersBoundingInfoObservable;
  60833. /**
  60834. * Enables or disables the shadow casters bounding info computation.
  60835. * If your shadow casters don't move, you can disable this feature.
  60836. * If it is enabled, the bounding box computation is done every frame.
  60837. */
  60838. get freezeShadowCastersBoundingInfo(): boolean;
  60839. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60840. private _scbiMin;
  60841. private _scbiMax;
  60842. protected _computeShadowCastersBoundingInfo(): void;
  60843. protected _shadowCastersBoundingInfo: BoundingInfo;
  60844. /**
  60845. * Gets or sets the shadow casters bounding info.
  60846. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60847. * so that the system won't overwrite the bounds you provide
  60848. */
  60849. get shadowCastersBoundingInfo(): BoundingInfo;
  60850. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60851. protected _breaksAreDirty: boolean;
  60852. protected _minDistance: number;
  60853. protected _maxDistance: number;
  60854. /**
  60855. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60856. *
  60857. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60858. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60859. * @param min minimal distance for the breaks (default to 0.)
  60860. * @param max maximal distance for the breaks (default to 1.)
  60861. */
  60862. setMinMaxDistance(min: number, max: number): void;
  60863. /** Gets the minimal distance used in the cascade break computation */
  60864. get minDistance(): number;
  60865. /** Gets the maximal distance used in the cascade break computation */
  60866. get maxDistance(): number;
  60867. /**
  60868. * Gets the class name of that object
  60869. * @returns "CascadedShadowGenerator"
  60870. */
  60871. getClassName(): string;
  60872. private _cascadeMinExtents;
  60873. private _cascadeMaxExtents;
  60874. /**
  60875. * Gets a cascade minimum extents
  60876. * @param cascadeIndex index of the cascade
  60877. * @returns the minimum cascade extents
  60878. */
  60879. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60880. /**
  60881. * Gets a cascade maximum extents
  60882. * @param cascadeIndex index of the cascade
  60883. * @returns the maximum cascade extents
  60884. */
  60885. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60886. private _cascades;
  60887. private _currentLayer;
  60888. private _viewSpaceFrustumsZ;
  60889. private _viewMatrices;
  60890. private _projectionMatrices;
  60891. private _transformMatrices;
  60892. private _transformMatricesAsArray;
  60893. private _frustumLengths;
  60894. private _lightSizeUVCorrection;
  60895. private _depthCorrection;
  60896. private _frustumCornersWorldSpace;
  60897. private _frustumCenter;
  60898. private _shadowCameraPos;
  60899. private _shadowMaxZ;
  60900. /**
  60901. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60902. * It defaults to camera.maxZ
  60903. */
  60904. get shadowMaxZ(): number;
  60905. /**
  60906. * Sets the shadow max z distance.
  60907. */
  60908. set shadowMaxZ(value: number);
  60909. protected _debug: boolean;
  60910. /**
  60911. * Gets or sets the debug flag.
  60912. * When enabled, the cascades are materialized by different colors on the screen.
  60913. */
  60914. get debug(): boolean;
  60915. set debug(dbg: boolean);
  60916. private _depthClamp;
  60917. /**
  60918. * Gets or sets the depth clamping value.
  60919. *
  60920. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60921. * to account for the shadow casters far away.
  60922. *
  60923. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60924. */
  60925. get depthClamp(): boolean;
  60926. set depthClamp(value: boolean);
  60927. private _cascadeBlendPercentage;
  60928. /**
  60929. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60930. * It defaults to 0.1 (10% blending).
  60931. */
  60932. get cascadeBlendPercentage(): number;
  60933. set cascadeBlendPercentage(value: number);
  60934. private _lambda;
  60935. /**
  60936. * Gets or set the lambda parameter.
  60937. * This parameter is used to split the camera frustum and create the cascades.
  60938. * 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.
  60939. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60940. */
  60941. get lambda(): number;
  60942. set lambda(value: number);
  60943. /**
  60944. * Gets the view matrix corresponding to a given cascade
  60945. * @param cascadeNum cascade to retrieve the view matrix from
  60946. * @returns the cascade view matrix
  60947. */
  60948. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60949. /**
  60950. * Gets the projection matrix corresponding to a given cascade
  60951. * @param cascadeNum cascade to retrieve the projection matrix from
  60952. * @returns the cascade projection matrix
  60953. */
  60954. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60955. /**
  60956. * Gets the transformation matrix corresponding to a given cascade
  60957. * @param cascadeNum cascade to retrieve the transformation matrix from
  60958. * @returns the cascade transformation matrix
  60959. */
  60960. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60961. private _depthRenderer;
  60962. /**
  60963. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60964. *
  60965. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60966. *
  60967. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60968. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60969. * @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
  60970. */
  60971. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60972. private _depthReducer;
  60973. private _autoCalcDepthBounds;
  60974. /**
  60975. * Gets or sets the autoCalcDepthBounds property.
  60976. *
  60977. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60978. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60979. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60980. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60981. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60982. */
  60983. get autoCalcDepthBounds(): boolean;
  60984. set autoCalcDepthBounds(value: boolean);
  60985. /**
  60986. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60987. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60988. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60989. * for setting the refresh rate on the renderer yourself!
  60990. */
  60991. get autoCalcDepthBoundsRefreshRate(): number;
  60992. set autoCalcDepthBoundsRefreshRate(value: number);
  60993. /**
  60994. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60995. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60996. * you change the camera near/far planes!
  60997. */
  60998. splitFrustum(): void;
  60999. private _splitFrustum;
  61000. private _computeMatrices;
  61001. private _computeFrustumInWorldSpace;
  61002. private _computeCascadeFrustum;
  61003. /**
  61004. * Support test.
  61005. */
  61006. static get IsSupported(): boolean;
  61007. /** @hidden */
  61008. static _SceneComponentInitialization: (scene: Scene) => void;
  61009. /**
  61010. * Creates a Cascaded Shadow Generator object.
  61011. * A ShadowGenerator is the required tool to use the shadows.
  61012. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61013. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61014. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61015. * @param light The directional light object generating the shadows.
  61016. * @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.
  61017. */
  61018. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61019. protected _initializeGenerator(): void;
  61020. protected _createTargetRenderTexture(): void;
  61021. protected _initializeShadowMap(): void;
  61022. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61023. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61024. /**
  61025. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61026. * @param defines Defines of the material we want to update
  61027. * @param lightIndex Index of the light in the enabled light list of the material
  61028. */
  61029. prepareDefines(defines: any, lightIndex: number): void;
  61030. /**
  61031. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61032. * defined in the generator but impacting the effect).
  61033. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61034. * @param effect The effect we are binfing the information for
  61035. */
  61036. bindShadowLight(lightIndex: string, effect: Effect): void;
  61037. /**
  61038. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61039. * (eq to view projection * shadow projection matrices)
  61040. * @returns The transform matrix used to create the shadow map
  61041. */
  61042. getTransformMatrix(): Matrix;
  61043. /**
  61044. * Disposes the ShadowGenerator.
  61045. * Returns nothing.
  61046. */
  61047. dispose(): void;
  61048. /**
  61049. * Serializes the shadow generator setup to a json object.
  61050. * @returns The serialized JSON object
  61051. */
  61052. serialize(): any;
  61053. /**
  61054. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61055. * @param parsedShadowGenerator The JSON object to parse
  61056. * @param scene The scene to create the shadow map for
  61057. * @returns The parsed shadow generator
  61058. */
  61059. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61060. }
  61061. }
  61062. declare module BABYLON {
  61063. /**
  61064. * Defines the shadow generator component responsible to manage any shadow generators
  61065. * in a given scene.
  61066. */
  61067. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61068. /**
  61069. * The component name helpfull to identify the component in the list of scene components.
  61070. */
  61071. readonly name: string;
  61072. /**
  61073. * The scene the component belongs to.
  61074. */
  61075. scene: Scene;
  61076. /**
  61077. * Creates a new instance of the component for the given scene
  61078. * @param scene Defines the scene to register the component in
  61079. */
  61080. constructor(scene: Scene);
  61081. /**
  61082. * Registers the component in a given scene
  61083. */
  61084. register(): void;
  61085. /**
  61086. * Rebuilds the elements related to this component in case of
  61087. * context lost for instance.
  61088. */
  61089. rebuild(): void;
  61090. /**
  61091. * Serializes the component data to the specified json object
  61092. * @param serializationObject The object to serialize to
  61093. */
  61094. serialize(serializationObject: any): void;
  61095. /**
  61096. * Adds all the elements from the container to the scene
  61097. * @param container the container holding the elements
  61098. */
  61099. addFromContainer(container: AbstractScene): void;
  61100. /**
  61101. * Removes all the elements in the container from the scene
  61102. * @param container contains the elements to remove
  61103. * @param dispose if the removed element should be disposed (default: false)
  61104. */
  61105. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61106. /**
  61107. * Rebuilds the elements related to this component in case of
  61108. * context lost for instance.
  61109. */
  61110. dispose(): void;
  61111. private _gatherRenderTargets;
  61112. }
  61113. }
  61114. declare module BABYLON {
  61115. /**
  61116. * A point light is a light defined by an unique point in world space.
  61117. * The light is emitted in every direction from this point.
  61118. * A good example of a point light is a standard light bulb.
  61119. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61120. */
  61121. export class PointLight extends ShadowLight {
  61122. private _shadowAngle;
  61123. /**
  61124. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61125. * This specifies what angle the shadow will use to be created.
  61126. *
  61127. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61128. */
  61129. get shadowAngle(): number;
  61130. /**
  61131. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61132. * This specifies what angle the shadow will use to be created.
  61133. *
  61134. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61135. */
  61136. set shadowAngle(value: number);
  61137. /**
  61138. * Gets the direction if it has been set.
  61139. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61140. */
  61141. get direction(): Vector3;
  61142. /**
  61143. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61144. */
  61145. set direction(value: Vector3);
  61146. /**
  61147. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61148. * A PointLight emits the light in every direction.
  61149. * It can cast shadows.
  61150. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61151. * ```javascript
  61152. * var pointLight = new PointLight("pl", camera.position, scene);
  61153. * ```
  61154. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61155. * @param name The light friendly name
  61156. * @param position The position of the point light in the scene
  61157. * @param scene The scene the lights belongs to
  61158. */
  61159. constructor(name: string, position: Vector3, scene: Scene);
  61160. /**
  61161. * Returns the string "PointLight"
  61162. * @returns the class name
  61163. */
  61164. getClassName(): string;
  61165. /**
  61166. * Returns the integer 0.
  61167. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61168. */
  61169. getTypeID(): number;
  61170. /**
  61171. * Specifies wether or not the shadowmap should be a cube texture.
  61172. * @returns true if the shadowmap needs to be a cube texture.
  61173. */
  61174. needCube(): boolean;
  61175. /**
  61176. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61177. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61178. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61179. */
  61180. getShadowDirection(faceIndex?: number): Vector3;
  61181. /**
  61182. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61183. * - fov = PI / 2
  61184. * - aspect ratio : 1.0
  61185. * - z-near and far equal to the active camera minZ and maxZ.
  61186. * Returns the PointLight.
  61187. */
  61188. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61189. protected _buildUniformLayout(): void;
  61190. /**
  61191. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61192. * @param effect The effect to update
  61193. * @param lightIndex The index of the light in the effect to update
  61194. * @returns The point light
  61195. */
  61196. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61197. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61198. /**
  61199. * Prepares the list of defines specific to the light type.
  61200. * @param defines the list of defines
  61201. * @param lightIndex defines the index of the light for the effect
  61202. */
  61203. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61204. }
  61205. }
  61206. declare module BABYLON {
  61207. /**
  61208. * Header information of HDR texture files.
  61209. */
  61210. export interface HDRInfo {
  61211. /**
  61212. * The height of the texture in pixels.
  61213. */
  61214. height: number;
  61215. /**
  61216. * The width of the texture in pixels.
  61217. */
  61218. width: number;
  61219. /**
  61220. * The index of the beginning of the data in the binary file.
  61221. */
  61222. dataPosition: number;
  61223. }
  61224. /**
  61225. * This groups tools to convert HDR texture to native colors array.
  61226. */
  61227. export class HDRTools {
  61228. private static Ldexp;
  61229. private static Rgbe2float;
  61230. private static readStringLine;
  61231. /**
  61232. * Reads header information from an RGBE texture stored in a native array.
  61233. * More information on this format are available here:
  61234. * https://en.wikipedia.org/wiki/RGBE_image_format
  61235. *
  61236. * @param uint8array The binary file stored in native array.
  61237. * @return The header information.
  61238. */
  61239. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61240. /**
  61241. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61242. * This RGBE texture needs to store the information as a panorama.
  61243. *
  61244. * More information on this format are available here:
  61245. * https://en.wikipedia.org/wiki/RGBE_image_format
  61246. *
  61247. * @param buffer The binary file stored in an array buffer.
  61248. * @param size The expected size of the extracted cubemap.
  61249. * @return The Cube Map information.
  61250. */
  61251. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61252. /**
  61253. * Returns the pixels data extracted from an RGBE texture.
  61254. * This pixels will be stored left to right up to down in the R G B order in one array.
  61255. *
  61256. * More information on this format are available here:
  61257. * https://en.wikipedia.org/wiki/RGBE_image_format
  61258. *
  61259. * @param uint8array The binary file stored in an array buffer.
  61260. * @param hdrInfo The header information of the file.
  61261. * @return The pixels data in RGB right to left up to down order.
  61262. */
  61263. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61264. private static RGBE_ReadPixels_RLE;
  61265. private static RGBE_ReadPixels_NOT_RLE;
  61266. }
  61267. }
  61268. declare module BABYLON {
  61269. /**
  61270. * Effect Render Options
  61271. */
  61272. export interface IEffectRendererOptions {
  61273. /**
  61274. * Defines the vertices positions.
  61275. */
  61276. positions?: number[];
  61277. /**
  61278. * Defines the indices.
  61279. */
  61280. indices?: number[];
  61281. }
  61282. /**
  61283. * Helper class to render one or more effects.
  61284. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61285. */
  61286. export class EffectRenderer {
  61287. private engine;
  61288. private static _DefaultOptions;
  61289. private _vertexBuffers;
  61290. private _indexBuffer;
  61291. private _fullscreenViewport;
  61292. /**
  61293. * Creates an effect renderer
  61294. * @param engine the engine to use for rendering
  61295. * @param options defines the options of the effect renderer
  61296. */
  61297. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61298. /**
  61299. * Sets the current viewport in normalized coordinates 0-1
  61300. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61301. */
  61302. setViewport(viewport?: Viewport): void;
  61303. /**
  61304. * Binds the embedded attributes buffer to the effect.
  61305. * @param effect Defines the effect to bind the attributes for
  61306. */
  61307. bindBuffers(effect: Effect): void;
  61308. /**
  61309. * Sets the current effect wrapper to use during draw.
  61310. * The effect needs to be ready before calling this api.
  61311. * This also sets the default full screen position attribute.
  61312. * @param effectWrapper Defines the effect to draw with
  61313. */
  61314. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61315. /**
  61316. * Restores engine states
  61317. */
  61318. restoreStates(): void;
  61319. /**
  61320. * Draws a full screen quad.
  61321. */
  61322. draw(): void;
  61323. private isRenderTargetTexture;
  61324. /**
  61325. * renders one or more effects to a specified texture
  61326. * @param effectWrapper the effect to renderer
  61327. * @param outputTexture texture to draw to, if null it will render to the screen.
  61328. */
  61329. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61330. /**
  61331. * Disposes of the effect renderer
  61332. */
  61333. dispose(): void;
  61334. }
  61335. /**
  61336. * Options to create an EffectWrapper
  61337. */
  61338. interface EffectWrapperCreationOptions {
  61339. /**
  61340. * Engine to use to create the effect
  61341. */
  61342. engine: ThinEngine;
  61343. /**
  61344. * Fragment shader for the effect
  61345. */
  61346. fragmentShader: string;
  61347. /**
  61348. * Use the shader store instead of direct source code
  61349. */
  61350. useShaderStore?: boolean;
  61351. /**
  61352. * Vertex shader for the effect
  61353. */
  61354. vertexShader?: string;
  61355. /**
  61356. * Attributes to use in the shader
  61357. */
  61358. attributeNames?: Array<string>;
  61359. /**
  61360. * Uniforms to use in the shader
  61361. */
  61362. uniformNames?: Array<string>;
  61363. /**
  61364. * Texture sampler names to use in the shader
  61365. */
  61366. samplerNames?: Array<string>;
  61367. /**
  61368. * Defines to use in the shader
  61369. */
  61370. defines?: Array<string>;
  61371. /**
  61372. * Callback when effect is compiled
  61373. */
  61374. onCompiled?: Nullable<(effect: Effect) => void>;
  61375. /**
  61376. * The friendly name of the effect displayed in Spector.
  61377. */
  61378. name?: string;
  61379. }
  61380. /**
  61381. * Wraps an effect to be used for rendering
  61382. */
  61383. export class EffectWrapper {
  61384. /**
  61385. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61386. */
  61387. onApplyObservable: Observable<{}>;
  61388. /**
  61389. * The underlying effect
  61390. */
  61391. effect: Effect;
  61392. /**
  61393. * Creates an effect to be renderer
  61394. * @param creationOptions options to create the effect
  61395. */
  61396. constructor(creationOptions: EffectWrapperCreationOptions);
  61397. /**
  61398. * Disposes of the effect wrapper
  61399. */
  61400. dispose(): void;
  61401. }
  61402. }
  61403. declare module BABYLON {
  61404. /** @hidden */
  61405. export var hdrFilteringVertexShader: {
  61406. name: string;
  61407. shader: string;
  61408. };
  61409. }
  61410. declare module BABYLON {
  61411. /** @hidden */
  61412. export var hdrFilteringPixelShader: {
  61413. name: string;
  61414. shader: string;
  61415. };
  61416. }
  61417. declare module BABYLON {
  61418. /**
  61419. * Options for texture filtering
  61420. */
  61421. interface IHDRFilteringOptions {
  61422. /**
  61423. * Scales pixel intensity for the input HDR map.
  61424. */
  61425. hdrScale?: number;
  61426. /**
  61427. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61428. */
  61429. quality?: number;
  61430. }
  61431. /**
  61432. * Filters HDR maps to get correct renderings of PBR reflections
  61433. */
  61434. export class HDRFiltering {
  61435. private _engine;
  61436. private _effectRenderer;
  61437. private _effectWrapper;
  61438. private _lodGenerationOffset;
  61439. private _lodGenerationScale;
  61440. /**
  61441. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61442. * you care about baking speed.
  61443. */
  61444. quality: number;
  61445. /**
  61446. * Scales pixel intensity for the input HDR map.
  61447. */
  61448. hdrScale: number;
  61449. /**
  61450. * Instantiates HDR filter for reflection maps
  61451. *
  61452. * @param engine Thin engine
  61453. * @param options Options
  61454. */
  61455. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61456. private _createRenderTarget;
  61457. private _prefilterInternal;
  61458. private _createEffect;
  61459. /**
  61460. * Get a value indicating if the filter is ready to be used
  61461. * @param texture Texture to filter
  61462. * @returns true if the filter is ready
  61463. */
  61464. isReady(texture: BaseTexture): boolean;
  61465. /**
  61466. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61467. * Prefiltering will be invoked at the end of next rendering pass.
  61468. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61469. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61470. * @param texture Texture to filter
  61471. * @param onFinished Callback when filtering is done
  61472. * @return Promise called when prefiltering is done
  61473. */
  61474. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61475. }
  61476. }
  61477. declare module BABYLON {
  61478. /**
  61479. * This represents a texture coming from an HDR input.
  61480. *
  61481. * The only supported format is currently panorama picture stored in RGBE format.
  61482. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61483. */
  61484. export class HDRCubeTexture extends BaseTexture {
  61485. private static _facesMapping;
  61486. private _generateHarmonics;
  61487. private _noMipmap;
  61488. private _prefilterOnLoad;
  61489. private _textureMatrix;
  61490. private _size;
  61491. private _onLoad;
  61492. private _onError;
  61493. /**
  61494. * The texture URL.
  61495. */
  61496. url: string;
  61497. protected _isBlocking: boolean;
  61498. /**
  61499. * Sets wether or not the texture is blocking during loading.
  61500. */
  61501. set isBlocking(value: boolean);
  61502. /**
  61503. * Gets wether or not the texture is blocking during loading.
  61504. */
  61505. get isBlocking(): boolean;
  61506. protected _rotationY: number;
  61507. /**
  61508. * Sets texture matrix rotation angle around Y axis in radians.
  61509. */
  61510. set rotationY(value: number);
  61511. /**
  61512. * Gets texture matrix rotation angle around Y axis radians.
  61513. */
  61514. get rotationY(): number;
  61515. /**
  61516. * Gets or sets the center of the bounding box associated with the cube texture
  61517. * It must define where the camera used to render the texture was set
  61518. */
  61519. boundingBoxPosition: Vector3;
  61520. private _boundingBoxSize;
  61521. /**
  61522. * Gets or sets the size of the bounding box associated with the cube texture
  61523. * When defined, the cubemap will switch to local mode
  61524. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61525. * @example https://www.babylonjs-playground.com/#RNASML
  61526. */
  61527. set boundingBoxSize(value: Vector3);
  61528. get boundingBoxSize(): Vector3;
  61529. /**
  61530. * Instantiates an HDRTexture from the following parameters.
  61531. *
  61532. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61533. * @param sceneOrEngine The scene or engine the texture will be used in
  61534. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61535. * @param noMipmap Forces to not generate the mipmap if true
  61536. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61537. * @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)
  61538. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61539. */
  61540. 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>);
  61541. /**
  61542. * Get the current class name of the texture useful for serialization or dynamic coding.
  61543. * @returns "HDRCubeTexture"
  61544. */
  61545. getClassName(): string;
  61546. /**
  61547. * Occurs when the file is raw .hdr file.
  61548. */
  61549. private loadTexture;
  61550. clone(): HDRCubeTexture;
  61551. delayLoad(): void;
  61552. /**
  61553. * Get the texture reflection matrix used to rotate/transform the reflection.
  61554. * @returns the reflection matrix
  61555. */
  61556. getReflectionTextureMatrix(): Matrix;
  61557. /**
  61558. * Set the texture reflection matrix used to rotate/transform the reflection.
  61559. * @param value Define the reflection matrix to set
  61560. */
  61561. setReflectionTextureMatrix(value: Matrix): void;
  61562. /**
  61563. * Parses a JSON representation of an HDR Texture in order to create the texture
  61564. * @param parsedTexture Define the JSON representation
  61565. * @param scene Define the scene the texture should be created in
  61566. * @param rootUrl Define the root url in case we need to load relative dependencies
  61567. * @returns the newly created texture after parsing
  61568. */
  61569. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61570. serialize(): any;
  61571. }
  61572. }
  61573. declare module BABYLON {
  61574. /**
  61575. * Class used to control physics engine
  61576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61577. */
  61578. export class PhysicsEngine implements IPhysicsEngine {
  61579. private _physicsPlugin;
  61580. /**
  61581. * Global value used to control the smallest number supported by the simulation
  61582. */
  61583. static Epsilon: number;
  61584. private _impostors;
  61585. private _joints;
  61586. private _subTimeStep;
  61587. /**
  61588. * Gets the gravity vector used by the simulation
  61589. */
  61590. gravity: Vector3;
  61591. /**
  61592. * Factory used to create the default physics plugin.
  61593. * @returns The default physics plugin
  61594. */
  61595. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61596. /**
  61597. * Creates a new Physics Engine
  61598. * @param gravity defines the gravity vector used by the simulation
  61599. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61600. */
  61601. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61602. /**
  61603. * Sets the gravity vector used by the simulation
  61604. * @param gravity defines the gravity vector to use
  61605. */
  61606. setGravity(gravity: Vector3): void;
  61607. /**
  61608. * Set the time step of the physics engine.
  61609. * Default is 1/60.
  61610. * To slow it down, enter 1/600 for example.
  61611. * To speed it up, 1/30
  61612. * @param newTimeStep defines the new timestep to apply to this world.
  61613. */
  61614. setTimeStep(newTimeStep?: number): void;
  61615. /**
  61616. * Get the time step of the physics engine.
  61617. * @returns the current time step
  61618. */
  61619. getTimeStep(): number;
  61620. /**
  61621. * Set the sub time step of the physics engine.
  61622. * Default is 0 meaning there is no sub steps
  61623. * To increase physics resolution precision, set a small value (like 1 ms)
  61624. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61625. */
  61626. setSubTimeStep(subTimeStep?: number): void;
  61627. /**
  61628. * Get the sub time step of the physics engine.
  61629. * @returns the current sub time step
  61630. */
  61631. getSubTimeStep(): number;
  61632. /**
  61633. * Release all resources
  61634. */
  61635. dispose(): void;
  61636. /**
  61637. * Gets the name of the current physics plugin
  61638. * @returns the name of the plugin
  61639. */
  61640. getPhysicsPluginName(): string;
  61641. /**
  61642. * Adding a new impostor for the impostor tracking.
  61643. * This will be done by the impostor itself.
  61644. * @param impostor the impostor to add
  61645. */
  61646. addImpostor(impostor: PhysicsImpostor): void;
  61647. /**
  61648. * Remove an impostor from the engine.
  61649. * This impostor and its mesh will not longer be updated by the physics engine.
  61650. * @param impostor the impostor to remove
  61651. */
  61652. removeImpostor(impostor: PhysicsImpostor): void;
  61653. /**
  61654. * Add a joint to the physics engine
  61655. * @param mainImpostor defines the main impostor to which the joint is added.
  61656. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61657. * @param joint defines the joint that will connect both impostors.
  61658. */
  61659. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61660. /**
  61661. * Removes a joint from the simulation
  61662. * @param mainImpostor defines the impostor used with the joint
  61663. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61664. * @param joint defines the joint to remove
  61665. */
  61666. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61667. /**
  61668. * Called by the scene. No need to call it.
  61669. * @param delta defines the timespam between frames
  61670. */
  61671. _step(delta: number): void;
  61672. /**
  61673. * Gets the current plugin used to run the simulation
  61674. * @returns current plugin
  61675. */
  61676. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61677. /**
  61678. * Gets the list of physic impostors
  61679. * @returns an array of PhysicsImpostor
  61680. */
  61681. getImpostors(): Array<PhysicsImpostor>;
  61682. /**
  61683. * Gets the impostor for a physics enabled object
  61684. * @param object defines the object impersonated by the impostor
  61685. * @returns the PhysicsImpostor or null if not found
  61686. */
  61687. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61688. /**
  61689. * Gets the impostor for a physics body object
  61690. * @param body defines physics body used by the impostor
  61691. * @returns the PhysicsImpostor or null if not found
  61692. */
  61693. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61694. /**
  61695. * Does a raycast in the physics world
  61696. * @param from when should the ray start?
  61697. * @param to when should the ray end?
  61698. * @returns PhysicsRaycastResult
  61699. */
  61700. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61701. }
  61702. }
  61703. declare module BABYLON {
  61704. /** @hidden */
  61705. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61706. private _useDeltaForWorldStep;
  61707. world: any;
  61708. name: string;
  61709. private _physicsMaterials;
  61710. private _fixedTimeStep;
  61711. private _cannonRaycastResult;
  61712. private _raycastResult;
  61713. private _physicsBodysToRemoveAfterStep;
  61714. private _firstFrame;
  61715. BJSCANNON: any;
  61716. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61717. setGravity(gravity: Vector3): void;
  61718. setTimeStep(timeStep: number): void;
  61719. getTimeStep(): number;
  61720. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61721. private _removeMarkedPhysicsBodiesFromWorld;
  61722. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61723. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61724. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61725. private _processChildMeshes;
  61726. removePhysicsBody(impostor: PhysicsImpostor): void;
  61727. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61728. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61729. private _addMaterial;
  61730. private _checkWithEpsilon;
  61731. private _createShape;
  61732. private _createHeightmap;
  61733. private _minus90X;
  61734. private _plus90X;
  61735. private _tmpPosition;
  61736. private _tmpDeltaPosition;
  61737. private _tmpUnityRotation;
  61738. private _updatePhysicsBodyTransformation;
  61739. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61740. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61741. isSupported(): boolean;
  61742. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61743. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61744. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61745. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61746. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61747. getBodyMass(impostor: PhysicsImpostor): number;
  61748. getBodyFriction(impostor: PhysicsImpostor): number;
  61749. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61750. getBodyRestitution(impostor: PhysicsImpostor): number;
  61751. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61752. sleepBody(impostor: PhysicsImpostor): void;
  61753. wakeUpBody(impostor: PhysicsImpostor): void;
  61754. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61755. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61756. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61757. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61758. getRadius(impostor: PhysicsImpostor): number;
  61759. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61760. dispose(): void;
  61761. private _extendNamespace;
  61762. /**
  61763. * Does a raycast in the physics world
  61764. * @param from when should the ray start?
  61765. * @param to when should the ray end?
  61766. * @returns PhysicsRaycastResult
  61767. */
  61768. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61769. }
  61770. }
  61771. declare module BABYLON {
  61772. /** @hidden */
  61773. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61774. private _useDeltaForWorldStep;
  61775. world: any;
  61776. name: string;
  61777. BJSOIMO: any;
  61778. private _raycastResult;
  61779. private _fixedTimeStep;
  61780. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61781. setGravity(gravity: Vector3): void;
  61782. setTimeStep(timeStep: number): void;
  61783. getTimeStep(): number;
  61784. private _tmpImpostorsArray;
  61785. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61786. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61787. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61788. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61789. private _tmpPositionVector;
  61790. removePhysicsBody(impostor: PhysicsImpostor): void;
  61791. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61792. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61793. isSupported(): boolean;
  61794. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61795. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61796. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61797. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61798. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61799. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61800. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61801. getBodyMass(impostor: PhysicsImpostor): number;
  61802. getBodyFriction(impostor: PhysicsImpostor): number;
  61803. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61804. getBodyRestitution(impostor: PhysicsImpostor): number;
  61805. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61806. sleepBody(impostor: PhysicsImpostor): void;
  61807. wakeUpBody(impostor: PhysicsImpostor): void;
  61808. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61809. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61810. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61811. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61812. getRadius(impostor: PhysicsImpostor): number;
  61813. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61814. dispose(): void;
  61815. /**
  61816. * Does a raycast in the physics world
  61817. * @param from when should the ray start?
  61818. * @param to when should the ray end?
  61819. * @returns PhysicsRaycastResult
  61820. */
  61821. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61822. }
  61823. }
  61824. declare module BABYLON {
  61825. /**
  61826. * AmmoJS Physics plugin
  61827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61828. * @see https://github.com/kripken/ammo.js/
  61829. */
  61830. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61831. private _useDeltaForWorldStep;
  61832. /**
  61833. * Reference to the Ammo library
  61834. */
  61835. bjsAMMO: any;
  61836. /**
  61837. * Created ammoJS world which physics bodies are added to
  61838. */
  61839. world: any;
  61840. /**
  61841. * Name of the plugin
  61842. */
  61843. name: string;
  61844. private _timeStep;
  61845. private _fixedTimeStep;
  61846. private _maxSteps;
  61847. private _tmpQuaternion;
  61848. private _tmpAmmoTransform;
  61849. private _tmpAmmoQuaternion;
  61850. private _tmpAmmoConcreteContactResultCallback;
  61851. private _collisionConfiguration;
  61852. private _dispatcher;
  61853. private _overlappingPairCache;
  61854. private _solver;
  61855. private _softBodySolver;
  61856. private _tmpAmmoVectorA;
  61857. private _tmpAmmoVectorB;
  61858. private _tmpAmmoVectorC;
  61859. private _tmpAmmoVectorD;
  61860. private _tmpContactCallbackResult;
  61861. private _tmpAmmoVectorRCA;
  61862. private _tmpAmmoVectorRCB;
  61863. private _raycastResult;
  61864. private _tmpContactPoint;
  61865. private static readonly DISABLE_COLLISION_FLAG;
  61866. private static readonly KINEMATIC_FLAG;
  61867. private static readonly DISABLE_DEACTIVATION_FLAG;
  61868. /**
  61869. * Initializes the ammoJS plugin
  61870. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61871. * @param ammoInjection can be used to inject your own ammo reference
  61872. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61873. */
  61874. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61875. /**
  61876. * Sets the gravity of the physics world (m/(s^2))
  61877. * @param gravity Gravity to set
  61878. */
  61879. setGravity(gravity: Vector3): void;
  61880. /**
  61881. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61882. * @param timeStep timestep to use in seconds
  61883. */
  61884. setTimeStep(timeStep: number): void;
  61885. /**
  61886. * 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)
  61887. * @param fixedTimeStep fixedTimeStep to use in seconds
  61888. */
  61889. setFixedTimeStep(fixedTimeStep: number): void;
  61890. /**
  61891. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61892. * @param maxSteps the maximum number of steps by the physics engine per frame
  61893. */
  61894. setMaxSteps(maxSteps: number): void;
  61895. /**
  61896. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61897. * @returns the current timestep in seconds
  61898. */
  61899. getTimeStep(): number;
  61900. /**
  61901. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61902. */
  61903. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61904. private _isImpostorInContact;
  61905. private _isImpostorPairInContact;
  61906. private _stepSimulation;
  61907. /**
  61908. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61909. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61910. * After the step the babylon meshes are set to the position of the physics imposters
  61911. * @param delta amount of time to step forward
  61912. * @param impostors array of imposters to update before/after the step
  61913. */
  61914. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61915. /**
  61916. * Update babylon mesh to match physics world object
  61917. * @param impostor imposter to match
  61918. */
  61919. private _afterSoftStep;
  61920. /**
  61921. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61922. * @param impostor imposter to match
  61923. */
  61924. private _ropeStep;
  61925. /**
  61926. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61927. * @param impostor imposter to match
  61928. */
  61929. private _softbodyOrClothStep;
  61930. private _tmpMatrix;
  61931. /**
  61932. * Applies an impulse on the imposter
  61933. * @param impostor imposter to apply impulse to
  61934. * @param force amount of force to be applied to the imposter
  61935. * @param contactPoint the location to apply the impulse on the imposter
  61936. */
  61937. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61938. /**
  61939. * Applies a force on the imposter
  61940. * @param impostor imposter to apply force
  61941. * @param force amount of force to be applied to the imposter
  61942. * @param contactPoint the location to apply the force on the imposter
  61943. */
  61944. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61945. /**
  61946. * Creates a physics body using the plugin
  61947. * @param impostor the imposter to create the physics body on
  61948. */
  61949. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61950. /**
  61951. * Removes the physics body from the imposter and disposes of the body's memory
  61952. * @param impostor imposter to remove the physics body from
  61953. */
  61954. removePhysicsBody(impostor: PhysicsImpostor): void;
  61955. /**
  61956. * Generates a joint
  61957. * @param impostorJoint the imposter joint to create the joint with
  61958. */
  61959. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61960. /**
  61961. * Removes a joint
  61962. * @param impostorJoint the imposter joint to remove the joint from
  61963. */
  61964. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61965. private _addMeshVerts;
  61966. /**
  61967. * Initialise the soft body vertices to match its object's (mesh) vertices
  61968. * Softbody vertices (nodes) are in world space and to match this
  61969. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61970. * @param impostor to create the softbody for
  61971. */
  61972. private _softVertexData;
  61973. /**
  61974. * Create an impostor's soft body
  61975. * @param impostor to create the softbody for
  61976. */
  61977. private _createSoftbody;
  61978. /**
  61979. * Create cloth for an impostor
  61980. * @param impostor to create the softbody for
  61981. */
  61982. private _createCloth;
  61983. /**
  61984. * Create rope for an impostor
  61985. * @param impostor to create the softbody for
  61986. */
  61987. private _createRope;
  61988. /**
  61989. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61990. * @param impostor to create the custom physics shape for
  61991. */
  61992. private _createCustom;
  61993. private _addHullVerts;
  61994. private _createShape;
  61995. /**
  61996. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61997. * @param impostor imposter containing the physics body and babylon object
  61998. */
  61999. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62000. /**
  62001. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62002. * @param impostor imposter containing the physics body and babylon object
  62003. * @param newPosition new position
  62004. * @param newRotation new rotation
  62005. */
  62006. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62007. /**
  62008. * If this plugin is supported
  62009. * @returns true if its supported
  62010. */
  62011. isSupported(): boolean;
  62012. /**
  62013. * Sets the linear velocity of the physics body
  62014. * @param impostor imposter to set the velocity on
  62015. * @param velocity velocity to set
  62016. */
  62017. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62018. /**
  62019. * Sets the angular velocity of the physics body
  62020. * @param impostor imposter to set the velocity on
  62021. * @param velocity velocity to set
  62022. */
  62023. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62024. /**
  62025. * gets the linear velocity
  62026. * @param impostor imposter to get linear velocity from
  62027. * @returns linear velocity
  62028. */
  62029. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62030. /**
  62031. * gets the angular velocity
  62032. * @param impostor imposter to get angular velocity from
  62033. * @returns angular velocity
  62034. */
  62035. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62036. /**
  62037. * Sets the mass of physics body
  62038. * @param impostor imposter to set the mass on
  62039. * @param mass mass to set
  62040. */
  62041. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62042. /**
  62043. * Gets the mass of the physics body
  62044. * @param impostor imposter to get the mass from
  62045. * @returns mass
  62046. */
  62047. getBodyMass(impostor: PhysicsImpostor): number;
  62048. /**
  62049. * Gets friction of the impostor
  62050. * @param impostor impostor to get friction from
  62051. * @returns friction value
  62052. */
  62053. getBodyFriction(impostor: PhysicsImpostor): number;
  62054. /**
  62055. * Sets friction of the impostor
  62056. * @param impostor impostor to set friction on
  62057. * @param friction friction value
  62058. */
  62059. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62060. /**
  62061. * Gets restitution of the impostor
  62062. * @param impostor impostor to get restitution from
  62063. * @returns restitution value
  62064. */
  62065. getBodyRestitution(impostor: PhysicsImpostor): number;
  62066. /**
  62067. * Sets resitution of the impostor
  62068. * @param impostor impostor to set resitution on
  62069. * @param restitution resitution value
  62070. */
  62071. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62072. /**
  62073. * Gets pressure inside the impostor
  62074. * @param impostor impostor to get pressure from
  62075. * @returns pressure value
  62076. */
  62077. getBodyPressure(impostor: PhysicsImpostor): number;
  62078. /**
  62079. * Sets pressure inside a soft body impostor
  62080. * Cloth and rope must remain 0 pressure
  62081. * @param impostor impostor to set pressure on
  62082. * @param pressure pressure value
  62083. */
  62084. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62085. /**
  62086. * Gets stiffness of the impostor
  62087. * @param impostor impostor to get stiffness from
  62088. * @returns pressure value
  62089. */
  62090. getBodyStiffness(impostor: PhysicsImpostor): number;
  62091. /**
  62092. * Sets stiffness of the impostor
  62093. * @param impostor impostor to set stiffness on
  62094. * @param stiffness stiffness value from 0 to 1
  62095. */
  62096. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62097. /**
  62098. * Gets velocityIterations of the impostor
  62099. * @param impostor impostor to get velocity iterations from
  62100. * @returns velocityIterations value
  62101. */
  62102. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62103. /**
  62104. * Sets velocityIterations of the impostor
  62105. * @param impostor impostor to set velocity iterations on
  62106. * @param velocityIterations velocityIterations value
  62107. */
  62108. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62109. /**
  62110. * Gets positionIterations of the impostor
  62111. * @param impostor impostor to get position iterations from
  62112. * @returns positionIterations value
  62113. */
  62114. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62115. /**
  62116. * Sets positionIterations of the impostor
  62117. * @param impostor impostor to set position on
  62118. * @param positionIterations positionIterations value
  62119. */
  62120. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62121. /**
  62122. * Append an anchor to a cloth object
  62123. * @param impostor is the cloth impostor to add anchor to
  62124. * @param otherImpostor is the rigid impostor to anchor to
  62125. * @param width ratio across width from 0 to 1
  62126. * @param height ratio up height from 0 to 1
  62127. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62128. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62129. */
  62130. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62131. /**
  62132. * Append an hook to a rope object
  62133. * @param impostor is the rope impostor to add hook to
  62134. * @param otherImpostor is the rigid impostor to hook to
  62135. * @param length ratio along the rope from 0 to 1
  62136. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62137. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62138. */
  62139. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62140. /**
  62141. * Sleeps the physics body and stops it from being active
  62142. * @param impostor impostor to sleep
  62143. */
  62144. sleepBody(impostor: PhysicsImpostor): void;
  62145. /**
  62146. * Activates the physics body
  62147. * @param impostor impostor to activate
  62148. */
  62149. wakeUpBody(impostor: PhysicsImpostor): void;
  62150. /**
  62151. * Updates the distance parameters of the joint
  62152. * @param joint joint to update
  62153. * @param maxDistance maximum distance of the joint
  62154. * @param minDistance minimum distance of the joint
  62155. */
  62156. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62157. /**
  62158. * Sets a motor on the joint
  62159. * @param joint joint to set motor on
  62160. * @param speed speed of the motor
  62161. * @param maxForce maximum force of the motor
  62162. * @param motorIndex index of the motor
  62163. */
  62164. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62165. /**
  62166. * Sets the motors limit
  62167. * @param joint joint to set limit on
  62168. * @param upperLimit upper limit
  62169. * @param lowerLimit lower limit
  62170. */
  62171. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62172. /**
  62173. * Syncs the position and rotation of a mesh with the impostor
  62174. * @param mesh mesh to sync
  62175. * @param impostor impostor to update the mesh with
  62176. */
  62177. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62178. /**
  62179. * Gets the radius of the impostor
  62180. * @param impostor impostor to get radius from
  62181. * @returns the radius
  62182. */
  62183. getRadius(impostor: PhysicsImpostor): number;
  62184. /**
  62185. * Gets the box size of the impostor
  62186. * @param impostor impostor to get box size from
  62187. * @param result the resulting box size
  62188. */
  62189. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62190. /**
  62191. * Disposes of the impostor
  62192. */
  62193. dispose(): void;
  62194. /**
  62195. * Does a raycast in the physics world
  62196. * @param from when should the ray start?
  62197. * @param to when should the ray end?
  62198. * @returns PhysicsRaycastResult
  62199. */
  62200. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62201. }
  62202. }
  62203. declare module BABYLON {
  62204. interface AbstractScene {
  62205. /**
  62206. * The list of reflection probes added to the scene
  62207. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62208. */
  62209. reflectionProbes: Array<ReflectionProbe>;
  62210. /**
  62211. * Removes the given reflection probe from this scene.
  62212. * @param toRemove The reflection probe to remove
  62213. * @returns The index of the removed reflection probe
  62214. */
  62215. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62216. /**
  62217. * Adds the given reflection probe to this scene.
  62218. * @param newReflectionProbe The reflection probe to add
  62219. */
  62220. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62221. }
  62222. /**
  62223. * Class used to generate realtime reflection / refraction cube textures
  62224. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62225. */
  62226. export class ReflectionProbe {
  62227. /** defines the name of the probe */
  62228. name: string;
  62229. private _scene;
  62230. private _renderTargetTexture;
  62231. private _projectionMatrix;
  62232. private _viewMatrix;
  62233. private _target;
  62234. private _add;
  62235. private _attachedMesh;
  62236. private _invertYAxis;
  62237. /** Gets or sets probe position (center of the cube map) */
  62238. position: Vector3;
  62239. /**
  62240. * Creates a new reflection probe
  62241. * @param name defines the name of the probe
  62242. * @param size defines the texture resolution (for each face)
  62243. * @param scene defines the hosting scene
  62244. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62245. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62246. */
  62247. constructor(
  62248. /** defines the name of the probe */
  62249. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62250. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62251. get samples(): number;
  62252. set samples(value: number);
  62253. /** Gets or sets the refresh rate to use (on every frame by default) */
  62254. get refreshRate(): number;
  62255. set refreshRate(value: number);
  62256. /**
  62257. * Gets the hosting scene
  62258. * @returns a Scene
  62259. */
  62260. getScene(): Scene;
  62261. /** Gets the internal CubeTexture used to render to */
  62262. get cubeTexture(): RenderTargetTexture;
  62263. /** Gets the list of meshes to render */
  62264. get renderList(): Nullable<AbstractMesh[]>;
  62265. /**
  62266. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62267. * @param mesh defines the mesh to attach to
  62268. */
  62269. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62270. /**
  62271. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62272. * @param renderingGroupId The rendering group id corresponding to its index
  62273. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62274. */
  62275. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62276. /**
  62277. * Clean all associated resources
  62278. */
  62279. dispose(): void;
  62280. /**
  62281. * Converts the reflection probe information to a readable string for debug purpose.
  62282. * @param fullDetails Supports for multiple levels of logging within scene loading
  62283. * @returns the human readable reflection probe info
  62284. */
  62285. toString(fullDetails?: boolean): string;
  62286. /**
  62287. * Get the class name of the relfection probe.
  62288. * @returns "ReflectionProbe"
  62289. */
  62290. getClassName(): string;
  62291. /**
  62292. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62293. * @returns The JSON representation of the texture
  62294. */
  62295. serialize(): any;
  62296. /**
  62297. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62298. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62299. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62300. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62301. * @returns The parsed reflection probe if successful
  62302. */
  62303. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62304. }
  62305. }
  62306. declare module BABYLON {
  62307. /** @hidden */
  62308. export var _BabylonLoaderRegistered: boolean;
  62309. /**
  62310. * Helps setting up some configuration for the babylon file loader.
  62311. */
  62312. export class BabylonFileLoaderConfiguration {
  62313. /**
  62314. * The loader does not allow injecting custom physix engine into the plugins.
  62315. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62316. * So you could set this variable to your engine import to make it work.
  62317. */
  62318. static LoaderInjectedPhysicsEngine: any;
  62319. }
  62320. }
  62321. declare module BABYLON {
  62322. /**
  62323. * The Physically based simple base material of BJS.
  62324. *
  62325. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62326. * It is used as the base class for both the specGloss and metalRough conventions.
  62327. */
  62328. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62329. /**
  62330. * Number of Simultaneous lights allowed on the material.
  62331. */
  62332. maxSimultaneousLights: number;
  62333. /**
  62334. * If sets to true, disables all the lights affecting the material.
  62335. */
  62336. disableLighting: boolean;
  62337. /**
  62338. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62339. */
  62340. environmentTexture: BaseTexture;
  62341. /**
  62342. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62343. */
  62344. invertNormalMapX: boolean;
  62345. /**
  62346. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62347. */
  62348. invertNormalMapY: boolean;
  62349. /**
  62350. * Normal map used in the model.
  62351. */
  62352. normalTexture: BaseTexture;
  62353. /**
  62354. * Emissivie color used to self-illuminate the model.
  62355. */
  62356. emissiveColor: Color3;
  62357. /**
  62358. * Emissivie texture used to self-illuminate the model.
  62359. */
  62360. emissiveTexture: BaseTexture;
  62361. /**
  62362. * Occlusion Channel Strenght.
  62363. */
  62364. occlusionStrength: number;
  62365. /**
  62366. * Occlusion Texture of the material (adding extra occlusion effects).
  62367. */
  62368. occlusionTexture: BaseTexture;
  62369. /**
  62370. * Defines the alpha limits in alpha test mode.
  62371. */
  62372. alphaCutOff: number;
  62373. /**
  62374. * Gets the current double sided mode.
  62375. */
  62376. get doubleSided(): boolean;
  62377. /**
  62378. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62379. */
  62380. set doubleSided(value: boolean);
  62381. /**
  62382. * Stores the pre-calculated light information of a mesh in a texture.
  62383. */
  62384. lightmapTexture: BaseTexture;
  62385. /**
  62386. * If true, the light map contains occlusion information instead of lighting info.
  62387. */
  62388. useLightmapAsShadowmap: boolean;
  62389. /**
  62390. * Instantiates a new PBRMaterial instance.
  62391. *
  62392. * @param name The material name
  62393. * @param scene The scene the material will be use in.
  62394. */
  62395. constructor(name: string, scene: Scene);
  62396. getClassName(): string;
  62397. }
  62398. }
  62399. declare module BABYLON {
  62400. /**
  62401. * The PBR material of BJS following the metal roughness convention.
  62402. *
  62403. * This fits to the PBR convention in the GLTF definition:
  62404. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62405. */
  62406. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62407. /**
  62408. * The base color has two different interpretations depending on the value of metalness.
  62409. * When the material is a metal, the base color is the specific measured reflectance value
  62410. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62411. * of the material.
  62412. */
  62413. baseColor: Color3;
  62414. /**
  62415. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62416. * well as opacity information in the alpha channel.
  62417. */
  62418. baseTexture: BaseTexture;
  62419. /**
  62420. * Specifies the metallic scalar value of the material.
  62421. * Can also be used to scale the metalness values of the metallic texture.
  62422. */
  62423. metallic: number;
  62424. /**
  62425. * Specifies the roughness scalar value of the material.
  62426. * Can also be used to scale the roughness values of the metallic texture.
  62427. */
  62428. roughness: number;
  62429. /**
  62430. * Texture containing both the metallic value in the B channel and the
  62431. * roughness value in the G channel to keep better precision.
  62432. */
  62433. metallicRoughnessTexture: BaseTexture;
  62434. /**
  62435. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62436. *
  62437. * @param name The material name
  62438. * @param scene The scene the material will be use in.
  62439. */
  62440. constructor(name: string, scene: Scene);
  62441. /**
  62442. * Return the currrent class name of the material.
  62443. */
  62444. getClassName(): string;
  62445. /**
  62446. * Makes a duplicate of the current material.
  62447. * @param name - name to use for the new material.
  62448. */
  62449. clone(name: string): PBRMetallicRoughnessMaterial;
  62450. /**
  62451. * Serialize the material to a parsable JSON object.
  62452. */
  62453. serialize(): any;
  62454. /**
  62455. * Parses a JSON object correponding to the serialize function.
  62456. */
  62457. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62458. }
  62459. }
  62460. declare module BABYLON {
  62461. /**
  62462. * The PBR material of BJS following the specular glossiness convention.
  62463. *
  62464. * This fits to the PBR convention in the GLTF definition:
  62465. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62466. */
  62467. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62468. /**
  62469. * Specifies the diffuse color of the material.
  62470. */
  62471. diffuseColor: Color3;
  62472. /**
  62473. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62474. * channel.
  62475. */
  62476. diffuseTexture: BaseTexture;
  62477. /**
  62478. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62479. */
  62480. specularColor: Color3;
  62481. /**
  62482. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62483. */
  62484. glossiness: number;
  62485. /**
  62486. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62487. */
  62488. specularGlossinessTexture: BaseTexture;
  62489. /**
  62490. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62491. *
  62492. * @param name The material name
  62493. * @param scene The scene the material will be use in.
  62494. */
  62495. constructor(name: string, scene: Scene);
  62496. /**
  62497. * Return the currrent class name of the material.
  62498. */
  62499. getClassName(): string;
  62500. /**
  62501. * Makes a duplicate of the current material.
  62502. * @param name - name to use for the new material.
  62503. */
  62504. clone(name: string): PBRSpecularGlossinessMaterial;
  62505. /**
  62506. * Serialize the material to a parsable JSON object.
  62507. */
  62508. serialize(): any;
  62509. /**
  62510. * Parses a JSON object correponding to the serialize function.
  62511. */
  62512. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62513. }
  62514. }
  62515. declare module BABYLON {
  62516. /**
  62517. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62518. * It can help converting any input color in a desired output one. This can then be used to create effects
  62519. * from sepia, black and white to sixties or futuristic rendering...
  62520. *
  62521. * The only supported format is currently 3dl.
  62522. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62523. */
  62524. export class ColorGradingTexture extends BaseTexture {
  62525. /**
  62526. * The texture URL.
  62527. */
  62528. url: string;
  62529. /**
  62530. * Empty line regex stored for GC.
  62531. */
  62532. private static _noneEmptyLineRegex;
  62533. private _textureMatrix;
  62534. private _onLoad;
  62535. /**
  62536. * Instantiates a ColorGradingTexture from the following parameters.
  62537. *
  62538. * @param url The location of the color gradind data (currently only supporting 3dl)
  62539. * @param sceneOrEngine The scene or engine the texture will be used in
  62540. * @param onLoad defines a callback triggered when the texture has been loaded
  62541. */
  62542. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62543. /**
  62544. * Fires the onload event from the constructor if requested.
  62545. */
  62546. private _triggerOnLoad;
  62547. /**
  62548. * Returns the texture matrix used in most of the material.
  62549. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62550. */
  62551. getTextureMatrix(): Matrix;
  62552. /**
  62553. * Occurs when the file being loaded is a .3dl LUT file.
  62554. */
  62555. private load3dlTexture;
  62556. /**
  62557. * Starts the loading process of the texture.
  62558. */
  62559. private loadTexture;
  62560. /**
  62561. * Clones the color gradind texture.
  62562. */
  62563. clone(): ColorGradingTexture;
  62564. /**
  62565. * Called during delayed load for textures.
  62566. */
  62567. delayLoad(): void;
  62568. /**
  62569. * Parses a color grading texture serialized by Babylon.
  62570. * @param parsedTexture The texture information being parsedTexture
  62571. * @param scene The scene to load the texture in
  62572. * @param rootUrl The root url of the data assets to load
  62573. * @return A color gradind texture
  62574. */
  62575. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62576. /**
  62577. * Serializes the LUT texture to json format.
  62578. */
  62579. serialize(): any;
  62580. }
  62581. }
  62582. declare module BABYLON {
  62583. /**
  62584. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62585. */
  62586. export class EquiRectangularCubeTexture extends BaseTexture {
  62587. /** The six faces of the cube. */
  62588. private static _FacesMapping;
  62589. private _noMipmap;
  62590. private _onLoad;
  62591. private _onError;
  62592. /** The size of the cubemap. */
  62593. private _size;
  62594. /** The buffer of the image. */
  62595. private _buffer;
  62596. /** The width of the input image. */
  62597. private _width;
  62598. /** The height of the input image. */
  62599. private _height;
  62600. /** The URL to the image. */
  62601. url: string;
  62602. /**
  62603. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62604. * @param url The location of the image
  62605. * @param scene The scene the texture will be used in
  62606. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62607. * @param noMipmap Forces to not generate the mipmap if true
  62608. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62609. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62610. * @param onLoad — defines a callback called when texture is loaded
  62611. * @param onError — defines a callback called if there is an error
  62612. */
  62613. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62614. /**
  62615. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62616. */
  62617. private loadImage;
  62618. /**
  62619. * Convert the image buffer into a cubemap and create a CubeTexture.
  62620. */
  62621. private loadTexture;
  62622. /**
  62623. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62624. * @param buffer The ArrayBuffer that should be converted.
  62625. * @returns The buffer as Float32Array.
  62626. */
  62627. private getFloat32ArrayFromArrayBuffer;
  62628. /**
  62629. * Get the current class name of the texture useful for serialization or dynamic coding.
  62630. * @returns "EquiRectangularCubeTexture"
  62631. */
  62632. getClassName(): string;
  62633. /**
  62634. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62635. * @returns A clone of the current EquiRectangularCubeTexture.
  62636. */
  62637. clone(): EquiRectangularCubeTexture;
  62638. }
  62639. }
  62640. declare module BABYLON {
  62641. /**
  62642. * Defines the options related to the creation of an HtmlElementTexture
  62643. */
  62644. export interface IHtmlElementTextureOptions {
  62645. /**
  62646. * Defines wether mip maps should be created or not.
  62647. */
  62648. generateMipMaps?: boolean;
  62649. /**
  62650. * Defines the sampling mode of the texture.
  62651. */
  62652. samplingMode?: number;
  62653. /**
  62654. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62655. */
  62656. engine: Nullable<ThinEngine>;
  62657. /**
  62658. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62659. */
  62660. scene: Nullable<Scene>;
  62661. }
  62662. /**
  62663. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62664. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62665. * is automatically managed.
  62666. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62667. * in your application.
  62668. *
  62669. * As the update is not automatic, you need to call them manually.
  62670. */
  62671. export class HtmlElementTexture extends BaseTexture {
  62672. /**
  62673. * The texture URL.
  62674. */
  62675. element: HTMLVideoElement | HTMLCanvasElement;
  62676. private static readonly DefaultOptions;
  62677. private _textureMatrix;
  62678. private _isVideo;
  62679. private _generateMipMaps;
  62680. private _samplingMode;
  62681. /**
  62682. * Instantiates a HtmlElementTexture from the following parameters.
  62683. *
  62684. * @param name Defines the name of the texture
  62685. * @param element Defines the video or canvas the texture is filled with
  62686. * @param options Defines the other none mandatory texture creation options
  62687. */
  62688. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62689. private _createInternalTexture;
  62690. /**
  62691. * Returns the texture matrix used in most of the material.
  62692. */
  62693. getTextureMatrix(): Matrix;
  62694. /**
  62695. * Updates the content of the texture.
  62696. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62697. */
  62698. update(invertY?: Nullable<boolean>): void;
  62699. }
  62700. }
  62701. declare module BABYLON {
  62702. /**
  62703. * Based on jsTGALoader - Javascript loader for TGA file
  62704. * By Vincent Thibault
  62705. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62706. */
  62707. export class TGATools {
  62708. private static _TYPE_INDEXED;
  62709. private static _TYPE_RGB;
  62710. private static _TYPE_GREY;
  62711. private static _TYPE_RLE_INDEXED;
  62712. private static _TYPE_RLE_RGB;
  62713. private static _TYPE_RLE_GREY;
  62714. private static _ORIGIN_MASK;
  62715. private static _ORIGIN_SHIFT;
  62716. private static _ORIGIN_BL;
  62717. private static _ORIGIN_BR;
  62718. private static _ORIGIN_UL;
  62719. private static _ORIGIN_UR;
  62720. /**
  62721. * Gets the header of a TGA file
  62722. * @param data defines the TGA data
  62723. * @returns the header
  62724. */
  62725. static GetTGAHeader(data: Uint8Array): any;
  62726. /**
  62727. * Uploads TGA content to a Babylon Texture
  62728. * @hidden
  62729. */
  62730. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62731. /** @hidden */
  62732. 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;
  62733. /** @hidden */
  62734. 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;
  62735. /** @hidden */
  62736. 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;
  62737. /** @hidden */
  62738. 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;
  62739. /** @hidden */
  62740. 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;
  62741. /** @hidden */
  62742. 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;
  62743. }
  62744. }
  62745. declare module BABYLON {
  62746. /**
  62747. * Implementation of the TGA Texture Loader.
  62748. * @hidden
  62749. */
  62750. export class _TGATextureLoader implements IInternalTextureLoader {
  62751. /**
  62752. * Defines wether the loader supports cascade loading the different faces.
  62753. */
  62754. readonly supportCascades: boolean;
  62755. /**
  62756. * This returns if the loader support the current file information.
  62757. * @param extension defines the file extension of the file being loaded
  62758. * @returns true if the loader can load the specified file
  62759. */
  62760. canLoad(extension: string): boolean;
  62761. /**
  62762. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62763. * @param data contains the texture data
  62764. * @param texture defines the BabylonJS internal texture
  62765. * @param createPolynomials will be true if polynomials have been requested
  62766. * @param onLoad defines the callback to trigger once the texture is ready
  62767. * @param onError defines the callback to trigger in case of error
  62768. */
  62769. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62770. /**
  62771. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62772. * @param data contains the texture data
  62773. * @param texture defines the BabylonJS internal texture
  62774. * @param callback defines the method to call once ready to upload
  62775. */
  62776. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62777. }
  62778. }
  62779. declare module BABYLON {
  62780. /**
  62781. * Info about the .basis files
  62782. */
  62783. class BasisFileInfo {
  62784. /**
  62785. * If the file has alpha
  62786. */
  62787. hasAlpha: boolean;
  62788. /**
  62789. * Info about each image of the basis file
  62790. */
  62791. images: Array<{
  62792. levels: Array<{
  62793. width: number;
  62794. height: number;
  62795. transcodedPixels: ArrayBufferView;
  62796. }>;
  62797. }>;
  62798. }
  62799. /**
  62800. * Result of transcoding a basis file
  62801. */
  62802. class TranscodeResult {
  62803. /**
  62804. * Info about the .basis file
  62805. */
  62806. fileInfo: BasisFileInfo;
  62807. /**
  62808. * Format to use when loading the file
  62809. */
  62810. format: number;
  62811. }
  62812. /**
  62813. * Configuration options for the Basis transcoder
  62814. */
  62815. export class BasisTranscodeConfiguration {
  62816. /**
  62817. * Supported compression formats used to determine the supported output format of the transcoder
  62818. */
  62819. supportedCompressionFormats?: {
  62820. /**
  62821. * etc1 compression format
  62822. */
  62823. etc1?: boolean;
  62824. /**
  62825. * s3tc compression format
  62826. */
  62827. s3tc?: boolean;
  62828. /**
  62829. * pvrtc compression format
  62830. */
  62831. pvrtc?: boolean;
  62832. /**
  62833. * etc2 compression format
  62834. */
  62835. etc2?: boolean;
  62836. };
  62837. /**
  62838. * If mipmap levels should be loaded for transcoded images (Default: true)
  62839. */
  62840. loadMipmapLevels?: boolean;
  62841. /**
  62842. * Index of a single image to load (Default: all images)
  62843. */
  62844. loadSingleImage?: number;
  62845. }
  62846. /**
  62847. * Used to load .Basis files
  62848. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62849. */
  62850. export class BasisTools {
  62851. private static _IgnoreSupportedFormats;
  62852. /**
  62853. * URL to use when loading the basis transcoder
  62854. */
  62855. static JSModuleURL: string;
  62856. /**
  62857. * URL to use when loading the wasm module for the transcoder
  62858. */
  62859. static WasmModuleURL: string;
  62860. /**
  62861. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62862. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62863. * @returns internal format corresponding to the Basis format
  62864. */
  62865. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62866. private static _WorkerPromise;
  62867. private static _Worker;
  62868. private static _actionId;
  62869. private static _CreateWorkerAsync;
  62870. /**
  62871. * Transcodes a loaded image file to compressed pixel data
  62872. * @param data image data to transcode
  62873. * @param config configuration options for the transcoding
  62874. * @returns a promise resulting in the transcoded image
  62875. */
  62876. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62877. /**
  62878. * Loads a texture from the transcode result
  62879. * @param texture texture load to
  62880. * @param transcodeResult the result of transcoding the basis file to load from
  62881. */
  62882. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62883. }
  62884. }
  62885. declare module BABYLON {
  62886. /**
  62887. * Loader for .basis file format
  62888. */
  62889. export class _BasisTextureLoader implements IInternalTextureLoader {
  62890. /**
  62891. * Defines whether the loader supports cascade loading the different faces.
  62892. */
  62893. readonly supportCascades: boolean;
  62894. /**
  62895. * This returns if the loader support the current file information.
  62896. * @param extension defines the file extension of the file being loaded
  62897. * @returns true if the loader can load the specified file
  62898. */
  62899. canLoad(extension: string): boolean;
  62900. /**
  62901. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62902. * @param data contains the texture data
  62903. * @param texture defines the BabylonJS internal texture
  62904. * @param createPolynomials will be true if polynomials have been requested
  62905. * @param onLoad defines the callback to trigger once the texture is ready
  62906. * @param onError defines the callback to trigger in case of error
  62907. */
  62908. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62909. /**
  62910. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62911. * @param data contains the texture data
  62912. * @param texture defines the BabylonJS internal texture
  62913. * @param callback defines the method to call once ready to upload
  62914. */
  62915. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62916. }
  62917. }
  62918. declare module BABYLON {
  62919. /**
  62920. * Defines the basic options interface of a TexturePacker Frame
  62921. */
  62922. export interface ITexturePackerFrame {
  62923. /**
  62924. * The frame ID
  62925. */
  62926. id: number;
  62927. /**
  62928. * The frames Scale
  62929. */
  62930. scale: Vector2;
  62931. /**
  62932. * The Frames offset
  62933. */
  62934. offset: Vector2;
  62935. }
  62936. /**
  62937. * This is a support class for frame Data on texture packer sets.
  62938. */
  62939. export class TexturePackerFrame implements ITexturePackerFrame {
  62940. /**
  62941. * The frame ID
  62942. */
  62943. id: number;
  62944. /**
  62945. * The frames Scale
  62946. */
  62947. scale: Vector2;
  62948. /**
  62949. * The Frames offset
  62950. */
  62951. offset: Vector2;
  62952. /**
  62953. * Initializes a texture package frame.
  62954. * @param id The numerical frame identifier
  62955. * @param scale Scalar Vector2 for UV frame
  62956. * @param offset Vector2 for the frame position in UV units.
  62957. * @returns TexturePackerFrame
  62958. */
  62959. constructor(id: number, scale: Vector2, offset: Vector2);
  62960. }
  62961. }
  62962. declare module BABYLON {
  62963. /**
  62964. * Defines the basic options interface of a TexturePacker
  62965. */
  62966. export interface ITexturePackerOptions {
  62967. /**
  62968. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62969. */
  62970. map?: string[];
  62971. /**
  62972. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62973. */
  62974. uvsIn?: string;
  62975. /**
  62976. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62977. */
  62978. uvsOut?: string;
  62979. /**
  62980. * number representing the layout style. Defaults to LAYOUT_STRIP
  62981. */
  62982. layout?: number;
  62983. /**
  62984. * number of columns if using custom column count layout(2). This defaults to 4.
  62985. */
  62986. colnum?: number;
  62987. /**
  62988. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62989. */
  62990. updateInputMeshes?: boolean;
  62991. /**
  62992. * boolean flag to dispose all the source textures. Defaults to true.
  62993. */
  62994. disposeSources?: boolean;
  62995. /**
  62996. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62997. */
  62998. fillBlanks?: boolean;
  62999. /**
  63000. * string value representing the context fill style color. Defaults to 'black'.
  63001. */
  63002. customFillColor?: string;
  63003. /**
  63004. * Width and Height Value of each Frame in the TexturePacker Sets
  63005. */
  63006. frameSize?: number;
  63007. /**
  63008. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63009. */
  63010. paddingRatio?: number;
  63011. /**
  63012. * Number that declares the fill method for the padding gutter.
  63013. */
  63014. paddingMode?: number;
  63015. /**
  63016. * If in SUBUV_COLOR padding mode what color to use.
  63017. */
  63018. paddingColor?: Color3 | Color4;
  63019. }
  63020. /**
  63021. * Defines the basic interface of a TexturePacker JSON File
  63022. */
  63023. export interface ITexturePackerJSON {
  63024. /**
  63025. * The frame ID
  63026. */
  63027. name: string;
  63028. /**
  63029. * The base64 channel data
  63030. */
  63031. sets: any;
  63032. /**
  63033. * The options of the Packer
  63034. */
  63035. options: ITexturePackerOptions;
  63036. /**
  63037. * The frame data of the Packer
  63038. */
  63039. frames: Array<number>;
  63040. }
  63041. /**
  63042. * This is a support class that generates a series of packed texture sets.
  63043. * @see https://doc.babylonjs.com/babylon101/materials
  63044. */
  63045. export class TexturePacker {
  63046. /** Packer Layout Constant 0 */
  63047. static readonly LAYOUT_STRIP: number;
  63048. /** Packer Layout Constant 1 */
  63049. static readonly LAYOUT_POWER2: number;
  63050. /** Packer Layout Constant 2 */
  63051. static readonly LAYOUT_COLNUM: number;
  63052. /** Packer Layout Constant 0 */
  63053. static readonly SUBUV_WRAP: number;
  63054. /** Packer Layout Constant 1 */
  63055. static readonly SUBUV_EXTEND: number;
  63056. /** Packer Layout Constant 2 */
  63057. static readonly SUBUV_COLOR: number;
  63058. /** The Name of the Texture Package */
  63059. name: string;
  63060. /** The scene scope of the TexturePacker */
  63061. scene: Scene;
  63062. /** The Meshes to target */
  63063. meshes: AbstractMesh[];
  63064. /** Arguments passed with the Constructor */
  63065. options: ITexturePackerOptions;
  63066. /** The promise that is started upon initialization */
  63067. promise: Nullable<Promise<TexturePacker | string>>;
  63068. /** The Container object for the channel sets that are generated */
  63069. sets: object;
  63070. /** The Container array for the frames that are generated */
  63071. frames: TexturePackerFrame[];
  63072. /** The expected number of textures the system is parsing. */
  63073. private _expecting;
  63074. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63075. private _paddingValue;
  63076. /**
  63077. * Initializes a texture package series from an array of meshes or a single mesh.
  63078. * @param name The name of the package
  63079. * @param meshes The target meshes to compose the package from
  63080. * @param options The arguments that texture packer should follow while building.
  63081. * @param scene The scene which the textures are scoped to.
  63082. * @returns TexturePacker
  63083. */
  63084. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63085. /**
  63086. * Starts the package process
  63087. * @param resolve The promises resolution function
  63088. * @returns TexturePacker
  63089. */
  63090. private _createFrames;
  63091. /**
  63092. * Calculates the Size of the Channel Sets
  63093. * @returns Vector2
  63094. */
  63095. private _calculateSize;
  63096. /**
  63097. * Calculates the UV data for the frames.
  63098. * @param baseSize the base frameSize
  63099. * @param padding the base frame padding
  63100. * @param dtSize size of the Dynamic Texture for that channel
  63101. * @param dtUnits is 1/dtSize
  63102. * @param update flag to update the input meshes
  63103. */
  63104. private _calculateMeshUVFrames;
  63105. /**
  63106. * Calculates the frames Offset.
  63107. * @param index of the frame
  63108. * @returns Vector2
  63109. */
  63110. private _getFrameOffset;
  63111. /**
  63112. * Updates a Mesh to the frame data
  63113. * @param mesh that is the target
  63114. * @param frameID or the frame index
  63115. */
  63116. private _updateMeshUV;
  63117. /**
  63118. * Updates a Meshes materials to use the texture packer channels
  63119. * @param m is the mesh to target
  63120. * @param force all channels on the packer to be set.
  63121. */
  63122. private _updateTextureReferences;
  63123. /**
  63124. * Public method to set a Mesh to a frame
  63125. * @param m that is the target
  63126. * @param frameID or the frame index
  63127. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63128. */
  63129. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63130. /**
  63131. * Starts the async promise to compile the texture packer.
  63132. * @returns Promise<void>
  63133. */
  63134. processAsync(): Promise<void>;
  63135. /**
  63136. * Disposes all textures associated with this packer
  63137. */
  63138. dispose(): void;
  63139. /**
  63140. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63141. * @param imageType is the image type to use.
  63142. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63143. */
  63144. download(imageType?: string, quality?: number): void;
  63145. /**
  63146. * Public method to load a texturePacker JSON file.
  63147. * @param data of the JSON file in string format.
  63148. */
  63149. updateFromJSON(data: string): void;
  63150. }
  63151. }
  63152. declare module BABYLON {
  63153. /**
  63154. * 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.
  63155. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63156. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63157. */
  63158. export class CustomProceduralTexture extends ProceduralTexture {
  63159. private _animate;
  63160. private _time;
  63161. private _config;
  63162. private _texturePath;
  63163. /**
  63164. * Instantiates a new Custom Procedural Texture.
  63165. * 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.
  63166. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63167. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63168. * @param name Define the name of the texture
  63169. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63170. * @param size Define the size of the texture to create
  63171. * @param scene Define the scene the texture belongs to
  63172. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63173. * @param generateMipMaps Define if the texture should creates mip maps or not
  63174. */
  63175. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63176. private _loadJson;
  63177. /**
  63178. * Is the texture ready to be used ? (rendered at least once)
  63179. * @returns true if ready, otherwise, false.
  63180. */
  63181. isReady(): boolean;
  63182. /**
  63183. * Render the texture to its associated render target.
  63184. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63185. */
  63186. render(useCameraPostProcess?: boolean): void;
  63187. /**
  63188. * Update the list of dependant textures samplers in the shader.
  63189. */
  63190. updateTextures(): void;
  63191. /**
  63192. * Update the uniform values of the procedural texture in the shader.
  63193. */
  63194. updateShaderUniforms(): void;
  63195. /**
  63196. * Define if the texture animates or not.
  63197. */
  63198. get animate(): boolean;
  63199. set animate(value: boolean);
  63200. }
  63201. }
  63202. declare module BABYLON {
  63203. /** @hidden */
  63204. export var noisePixelShader: {
  63205. name: string;
  63206. shader: string;
  63207. };
  63208. }
  63209. declare module BABYLON {
  63210. /**
  63211. * Class used to generate noise procedural textures
  63212. */
  63213. export class NoiseProceduralTexture extends ProceduralTexture {
  63214. /** Gets or sets the start time (default is 0) */
  63215. time: number;
  63216. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63217. brightness: number;
  63218. /** Defines the number of octaves to process */
  63219. octaves: number;
  63220. /** Defines the level of persistence (0.8 by default) */
  63221. persistence: number;
  63222. /** Gets or sets animation speed factor (default is 1) */
  63223. animationSpeedFactor: number;
  63224. /**
  63225. * Creates a new NoiseProceduralTexture
  63226. * @param name defines the name fo the texture
  63227. * @param size defines the size of the texture (default is 256)
  63228. * @param scene defines the hosting scene
  63229. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63230. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63231. */
  63232. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63233. private _updateShaderUniforms;
  63234. protected _getDefines(): string;
  63235. /** Generate the current state of the procedural texture */
  63236. render(useCameraPostProcess?: boolean): void;
  63237. /**
  63238. * Serializes this noise procedural texture
  63239. * @returns a serialized noise procedural texture object
  63240. */
  63241. serialize(): any;
  63242. /**
  63243. * Clone the texture.
  63244. * @returns the cloned texture
  63245. */
  63246. clone(): NoiseProceduralTexture;
  63247. /**
  63248. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63249. * @param parsedTexture defines parsed texture data
  63250. * @param scene defines the current scene
  63251. * @param rootUrl defines the root URL containing noise procedural texture information
  63252. * @returns a parsed NoiseProceduralTexture
  63253. */
  63254. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63255. }
  63256. }
  63257. declare module BABYLON {
  63258. /**
  63259. * Raw cube texture where the raw buffers are passed in
  63260. */
  63261. export class RawCubeTexture extends CubeTexture {
  63262. /**
  63263. * Creates a cube texture where the raw buffers are passed in.
  63264. * @param scene defines the scene the texture is attached to
  63265. * @param data defines the array of data to use to create each face
  63266. * @param size defines the size of the textures
  63267. * @param format defines the format of the data
  63268. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63269. * @param generateMipMaps defines if the engine should generate the mip levels
  63270. * @param invertY defines if data must be stored with Y axis inverted
  63271. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63272. * @param compression defines the compression used (null by default)
  63273. */
  63274. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63275. /**
  63276. * Updates the raw cube texture.
  63277. * @param data defines the data to store
  63278. * @param format defines the data format
  63279. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63280. * @param invertY defines if data must be stored with Y axis inverted
  63281. * @param compression defines the compression used (null by default)
  63282. * @param level defines which level of the texture to update
  63283. */
  63284. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63285. /**
  63286. * Updates a raw cube texture with RGBD encoded data.
  63287. * @param data defines the array of data [mipmap][face] to use to create each face
  63288. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63289. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63290. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63291. * @returns a promsie that resolves when the operation is complete
  63292. */
  63293. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63294. /**
  63295. * Clones the raw cube texture.
  63296. * @return a new cube texture
  63297. */
  63298. clone(): CubeTexture;
  63299. /** @hidden */
  63300. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63301. }
  63302. }
  63303. declare module BABYLON {
  63304. /**
  63305. * Class used to store 2D array textures containing user data
  63306. */
  63307. export class RawTexture2DArray extends Texture {
  63308. /** Gets or sets the texture format to use */
  63309. format: number;
  63310. /**
  63311. * Create a new RawTexture2DArray
  63312. * @param data defines the data of the texture
  63313. * @param width defines the width of the texture
  63314. * @param height defines the height of the texture
  63315. * @param depth defines the number of layers of the texture
  63316. * @param format defines the texture format to use
  63317. * @param scene defines the hosting scene
  63318. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63319. * @param invertY defines if texture must be stored with Y axis inverted
  63320. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63321. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63322. */
  63323. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63324. /** Gets or sets the texture format to use */
  63325. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63326. /**
  63327. * Update the texture with new data
  63328. * @param data defines the data to store in the texture
  63329. */
  63330. update(data: ArrayBufferView): void;
  63331. }
  63332. }
  63333. declare module BABYLON {
  63334. /**
  63335. * Class used to store 3D textures containing user data
  63336. */
  63337. export class RawTexture3D extends Texture {
  63338. /** Gets or sets the texture format to use */
  63339. format: number;
  63340. /**
  63341. * Create a new RawTexture3D
  63342. * @param data defines the data of the texture
  63343. * @param width defines the width of the texture
  63344. * @param height defines the height of the texture
  63345. * @param depth defines the depth of the texture
  63346. * @param format defines the texture format to use
  63347. * @param scene defines the hosting scene
  63348. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63349. * @param invertY defines if texture must be stored with Y axis inverted
  63350. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63351. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63352. */
  63353. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63354. /** Gets or sets the texture format to use */
  63355. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63356. /**
  63357. * Update the texture with new data
  63358. * @param data defines the data to store in the texture
  63359. */
  63360. update(data: ArrayBufferView): void;
  63361. }
  63362. }
  63363. declare module BABYLON {
  63364. /**
  63365. * Creates a refraction texture used by refraction channel of the standard material.
  63366. * It is like a mirror but to see through a material.
  63367. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63368. */
  63369. export class RefractionTexture extends RenderTargetTexture {
  63370. /**
  63371. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63372. * 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.
  63373. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63374. */
  63375. refractionPlane: Plane;
  63376. /**
  63377. * Define how deep under the surface we should see.
  63378. */
  63379. depth: number;
  63380. /**
  63381. * Creates a refraction texture used by refraction channel of the standard material.
  63382. * It is like a mirror but to see through a material.
  63383. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63384. * @param name Define the texture name
  63385. * @param size Define the size of the underlying texture
  63386. * @param scene Define the scene the refraction belongs to
  63387. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63388. */
  63389. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63390. /**
  63391. * Clone the refraction texture.
  63392. * @returns the cloned texture
  63393. */
  63394. clone(): RefractionTexture;
  63395. /**
  63396. * Serialize the texture to a JSON representation you could use in Parse later on
  63397. * @returns the serialized JSON representation
  63398. */
  63399. serialize(): any;
  63400. }
  63401. }
  63402. declare module BABYLON {
  63403. /**
  63404. * Block used to add support for vertex skinning (bones)
  63405. */
  63406. export class BonesBlock extends NodeMaterialBlock {
  63407. /**
  63408. * Creates a new BonesBlock
  63409. * @param name defines the block name
  63410. */
  63411. constructor(name: string);
  63412. /**
  63413. * Initialize the block and prepare the context for build
  63414. * @param state defines the state that will be used for the build
  63415. */
  63416. initialize(state: NodeMaterialBuildState): void;
  63417. /**
  63418. * Gets the current class name
  63419. * @returns the class name
  63420. */
  63421. getClassName(): string;
  63422. /**
  63423. * Gets the matrix indices input component
  63424. */
  63425. get matricesIndices(): NodeMaterialConnectionPoint;
  63426. /**
  63427. * Gets the matrix weights input component
  63428. */
  63429. get matricesWeights(): NodeMaterialConnectionPoint;
  63430. /**
  63431. * Gets the extra matrix indices input component
  63432. */
  63433. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63434. /**
  63435. * Gets the extra matrix weights input component
  63436. */
  63437. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63438. /**
  63439. * Gets the world input component
  63440. */
  63441. get world(): NodeMaterialConnectionPoint;
  63442. /**
  63443. * Gets the output component
  63444. */
  63445. get output(): NodeMaterialConnectionPoint;
  63446. autoConfigure(material: NodeMaterial): void;
  63447. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63448. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63449. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63450. protected _buildBlock(state: NodeMaterialBuildState): this;
  63451. }
  63452. }
  63453. declare module BABYLON {
  63454. /**
  63455. * Block used to add support for instances
  63456. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63457. */
  63458. export class InstancesBlock extends NodeMaterialBlock {
  63459. /**
  63460. * Creates a new InstancesBlock
  63461. * @param name defines the block name
  63462. */
  63463. constructor(name: string);
  63464. /**
  63465. * Gets the current class name
  63466. * @returns the class name
  63467. */
  63468. getClassName(): string;
  63469. /**
  63470. * Gets the first world row input component
  63471. */
  63472. get world0(): NodeMaterialConnectionPoint;
  63473. /**
  63474. * Gets the second world row input component
  63475. */
  63476. get world1(): NodeMaterialConnectionPoint;
  63477. /**
  63478. * Gets the third world row input component
  63479. */
  63480. get world2(): NodeMaterialConnectionPoint;
  63481. /**
  63482. * Gets the forth world row input component
  63483. */
  63484. get world3(): NodeMaterialConnectionPoint;
  63485. /**
  63486. * Gets the world input component
  63487. */
  63488. get world(): NodeMaterialConnectionPoint;
  63489. /**
  63490. * Gets the output component
  63491. */
  63492. get output(): NodeMaterialConnectionPoint;
  63493. /**
  63494. * Gets the isntanceID component
  63495. */
  63496. get instanceID(): NodeMaterialConnectionPoint;
  63497. autoConfigure(material: NodeMaterial): void;
  63498. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63499. protected _buildBlock(state: NodeMaterialBuildState): this;
  63500. }
  63501. }
  63502. declare module BABYLON {
  63503. /**
  63504. * Block used to add morph targets support to vertex shader
  63505. */
  63506. export class MorphTargetsBlock extends NodeMaterialBlock {
  63507. private _repeatableContentAnchor;
  63508. /**
  63509. * Create a new MorphTargetsBlock
  63510. * @param name defines the block name
  63511. */
  63512. constructor(name: string);
  63513. /**
  63514. * Gets the current class name
  63515. * @returns the class name
  63516. */
  63517. getClassName(): string;
  63518. /**
  63519. * Gets the position input component
  63520. */
  63521. get position(): NodeMaterialConnectionPoint;
  63522. /**
  63523. * Gets the normal input component
  63524. */
  63525. get normal(): NodeMaterialConnectionPoint;
  63526. /**
  63527. * Gets the tangent input component
  63528. */
  63529. get tangent(): NodeMaterialConnectionPoint;
  63530. /**
  63531. * Gets the tangent input component
  63532. */
  63533. get uv(): NodeMaterialConnectionPoint;
  63534. /**
  63535. * Gets the position output component
  63536. */
  63537. get positionOutput(): NodeMaterialConnectionPoint;
  63538. /**
  63539. * Gets the normal output component
  63540. */
  63541. get normalOutput(): NodeMaterialConnectionPoint;
  63542. /**
  63543. * Gets the tangent output component
  63544. */
  63545. get tangentOutput(): NodeMaterialConnectionPoint;
  63546. /**
  63547. * Gets the tangent output component
  63548. */
  63549. get uvOutput(): NodeMaterialConnectionPoint;
  63550. initialize(state: NodeMaterialBuildState): void;
  63551. autoConfigure(material: NodeMaterial): void;
  63552. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63553. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63554. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63555. protected _buildBlock(state: NodeMaterialBuildState): this;
  63556. }
  63557. }
  63558. declare module BABYLON {
  63559. /**
  63560. * Block used to get data information from a light
  63561. */
  63562. export class LightInformationBlock extends NodeMaterialBlock {
  63563. private _lightDataUniformName;
  63564. private _lightColorUniformName;
  63565. private _lightTypeDefineName;
  63566. /**
  63567. * Gets or sets the light associated with this block
  63568. */
  63569. light: Nullable<Light>;
  63570. /**
  63571. * Creates a new LightInformationBlock
  63572. * @param name defines the block name
  63573. */
  63574. constructor(name: string);
  63575. /**
  63576. * Gets the current class name
  63577. * @returns the class name
  63578. */
  63579. getClassName(): string;
  63580. /**
  63581. * Gets the world position input component
  63582. */
  63583. get worldPosition(): NodeMaterialConnectionPoint;
  63584. /**
  63585. * Gets the direction output component
  63586. */
  63587. get direction(): NodeMaterialConnectionPoint;
  63588. /**
  63589. * Gets the direction output component
  63590. */
  63591. get color(): NodeMaterialConnectionPoint;
  63592. /**
  63593. * Gets the direction output component
  63594. */
  63595. get intensity(): NodeMaterialConnectionPoint;
  63596. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63597. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63598. protected _buildBlock(state: NodeMaterialBuildState): this;
  63599. serialize(): any;
  63600. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63601. }
  63602. }
  63603. declare module BABYLON {
  63604. /**
  63605. * Block used to add image processing support to fragment shader
  63606. */
  63607. export class ImageProcessingBlock extends NodeMaterialBlock {
  63608. /**
  63609. * Create a new ImageProcessingBlock
  63610. * @param name defines the block name
  63611. */
  63612. constructor(name: string);
  63613. /**
  63614. * Gets the current class name
  63615. * @returns the class name
  63616. */
  63617. getClassName(): string;
  63618. /**
  63619. * Gets the color input component
  63620. */
  63621. get color(): NodeMaterialConnectionPoint;
  63622. /**
  63623. * Gets the output component
  63624. */
  63625. get output(): NodeMaterialConnectionPoint;
  63626. /**
  63627. * Initialize the block and prepare the context for build
  63628. * @param state defines the state that will be used for the build
  63629. */
  63630. initialize(state: NodeMaterialBuildState): void;
  63631. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63632. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63633. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63634. protected _buildBlock(state: NodeMaterialBuildState): this;
  63635. }
  63636. }
  63637. declare module BABYLON {
  63638. /**
  63639. * Block used to pertub normals based on a normal map
  63640. */
  63641. export class PerturbNormalBlock extends NodeMaterialBlock {
  63642. private _tangentSpaceParameterName;
  63643. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63644. invertX: boolean;
  63645. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63646. invertY: boolean;
  63647. /**
  63648. * Create a new PerturbNormalBlock
  63649. * @param name defines the block name
  63650. */
  63651. constructor(name: string);
  63652. /**
  63653. * Gets the current class name
  63654. * @returns the class name
  63655. */
  63656. getClassName(): string;
  63657. /**
  63658. * Gets the world position input component
  63659. */
  63660. get worldPosition(): NodeMaterialConnectionPoint;
  63661. /**
  63662. * Gets the world normal input component
  63663. */
  63664. get worldNormal(): NodeMaterialConnectionPoint;
  63665. /**
  63666. * Gets the world tangent input component
  63667. */
  63668. get worldTangent(): NodeMaterialConnectionPoint;
  63669. /**
  63670. * Gets the uv input component
  63671. */
  63672. get uv(): NodeMaterialConnectionPoint;
  63673. /**
  63674. * Gets the normal map color input component
  63675. */
  63676. get normalMapColor(): NodeMaterialConnectionPoint;
  63677. /**
  63678. * Gets the strength input component
  63679. */
  63680. get strength(): NodeMaterialConnectionPoint;
  63681. /**
  63682. * Gets the output component
  63683. */
  63684. get output(): NodeMaterialConnectionPoint;
  63685. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63686. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63687. autoConfigure(material: NodeMaterial): void;
  63688. protected _buildBlock(state: NodeMaterialBuildState): this;
  63689. protected _dumpPropertiesCode(): string;
  63690. serialize(): any;
  63691. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63692. }
  63693. }
  63694. declare module BABYLON {
  63695. /**
  63696. * Block used to discard a pixel if a value is smaller than a cutoff
  63697. */
  63698. export class DiscardBlock extends NodeMaterialBlock {
  63699. /**
  63700. * Create a new DiscardBlock
  63701. * @param name defines the block name
  63702. */
  63703. constructor(name: string);
  63704. /**
  63705. * Gets the current class name
  63706. * @returns the class name
  63707. */
  63708. getClassName(): string;
  63709. /**
  63710. * Gets the color input component
  63711. */
  63712. get value(): NodeMaterialConnectionPoint;
  63713. /**
  63714. * Gets the cutoff input component
  63715. */
  63716. get cutoff(): NodeMaterialConnectionPoint;
  63717. protected _buildBlock(state: NodeMaterialBuildState): this;
  63718. }
  63719. }
  63720. declare module BABYLON {
  63721. /**
  63722. * Block used to test if the fragment shader is front facing
  63723. */
  63724. export class FrontFacingBlock extends NodeMaterialBlock {
  63725. /**
  63726. * Creates a new FrontFacingBlock
  63727. * @param name defines the block name
  63728. */
  63729. constructor(name: string);
  63730. /**
  63731. * Gets the current class name
  63732. * @returns the class name
  63733. */
  63734. getClassName(): string;
  63735. /**
  63736. * Gets the output component
  63737. */
  63738. get output(): NodeMaterialConnectionPoint;
  63739. protected _buildBlock(state: NodeMaterialBuildState): this;
  63740. }
  63741. }
  63742. declare module BABYLON {
  63743. /**
  63744. * Block used to get the derivative value on x and y of a given input
  63745. */
  63746. export class DerivativeBlock extends NodeMaterialBlock {
  63747. /**
  63748. * Create a new DerivativeBlock
  63749. * @param name defines the block name
  63750. */
  63751. constructor(name: string);
  63752. /**
  63753. * Gets the current class name
  63754. * @returns the class name
  63755. */
  63756. getClassName(): string;
  63757. /**
  63758. * Gets the input component
  63759. */
  63760. get input(): NodeMaterialConnectionPoint;
  63761. /**
  63762. * Gets the derivative output on x
  63763. */
  63764. get dx(): NodeMaterialConnectionPoint;
  63765. /**
  63766. * Gets the derivative output on y
  63767. */
  63768. get dy(): NodeMaterialConnectionPoint;
  63769. protected _buildBlock(state: NodeMaterialBuildState): this;
  63770. }
  63771. }
  63772. declare module BABYLON {
  63773. /**
  63774. * Block used to make gl_FragCoord available
  63775. */
  63776. export class FragCoordBlock extends NodeMaterialBlock {
  63777. /**
  63778. * Creates a new FragCoordBlock
  63779. * @param name defines the block name
  63780. */
  63781. constructor(name: string);
  63782. /**
  63783. * Gets the current class name
  63784. * @returns the class name
  63785. */
  63786. getClassName(): string;
  63787. /**
  63788. * Gets the xy component
  63789. */
  63790. get xy(): NodeMaterialConnectionPoint;
  63791. /**
  63792. * Gets the xyz component
  63793. */
  63794. get xyz(): NodeMaterialConnectionPoint;
  63795. /**
  63796. * Gets the xyzw component
  63797. */
  63798. get xyzw(): NodeMaterialConnectionPoint;
  63799. /**
  63800. * Gets the x component
  63801. */
  63802. get x(): NodeMaterialConnectionPoint;
  63803. /**
  63804. * Gets the y component
  63805. */
  63806. get y(): NodeMaterialConnectionPoint;
  63807. /**
  63808. * Gets the z component
  63809. */
  63810. get z(): NodeMaterialConnectionPoint;
  63811. /**
  63812. * Gets the w component
  63813. */
  63814. get output(): NodeMaterialConnectionPoint;
  63815. protected writeOutputs(state: NodeMaterialBuildState): string;
  63816. protected _buildBlock(state: NodeMaterialBuildState): this;
  63817. }
  63818. }
  63819. declare module BABYLON {
  63820. /**
  63821. * Block used to get the screen sizes
  63822. */
  63823. export class ScreenSizeBlock extends NodeMaterialBlock {
  63824. private _varName;
  63825. private _scene;
  63826. /**
  63827. * Creates a new ScreenSizeBlock
  63828. * @param name defines the block name
  63829. */
  63830. constructor(name: string);
  63831. /**
  63832. * Gets the current class name
  63833. * @returns the class name
  63834. */
  63835. getClassName(): string;
  63836. /**
  63837. * Gets the xy component
  63838. */
  63839. get xy(): NodeMaterialConnectionPoint;
  63840. /**
  63841. * Gets the x component
  63842. */
  63843. get x(): NodeMaterialConnectionPoint;
  63844. /**
  63845. * Gets the y component
  63846. */
  63847. get y(): NodeMaterialConnectionPoint;
  63848. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63849. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  63850. protected _buildBlock(state: NodeMaterialBuildState): this;
  63851. }
  63852. }
  63853. declare module BABYLON {
  63854. /**
  63855. * Block used to add support for scene fog
  63856. */
  63857. export class FogBlock extends NodeMaterialBlock {
  63858. private _fogDistanceName;
  63859. private _fogParameters;
  63860. /**
  63861. * Create a new FogBlock
  63862. * @param name defines the block name
  63863. */
  63864. constructor(name: string);
  63865. /**
  63866. * Gets the current class name
  63867. * @returns the class name
  63868. */
  63869. getClassName(): string;
  63870. /**
  63871. * Gets the world position input component
  63872. */
  63873. get worldPosition(): NodeMaterialConnectionPoint;
  63874. /**
  63875. * Gets the view input component
  63876. */
  63877. get view(): NodeMaterialConnectionPoint;
  63878. /**
  63879. * Gets the color input component
  63880. */
  63881. get input(): NodeMaterialConnectionPoint;
  63882. /**
  63883. * Gets the fog color input component
  63884. */
  63885. get fogColor(): NodeMaterialConnectionPoint;
  63886. /**
  63887. * Gets the output component
  63888. */
  63889. get output(): NodeMaterialConnectionPoint;
  63890. autoConfigure(material: NodeMaterial): void;
  63891. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63892. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63893. protected _buildBlock(state: NodeMaterialBuildState): this;
  63894. }
  63895. }
  63896. declare module BABYLON {
  63897. /**
  63898. * Block used to add light in the fragment shader
  63899. */
  63900. export class LightBlock extends NodeMaterialBlock {
  63901. private _lightId;
  63902. /**
  63903. * Gets or sets the light associated with this block
  63904. */
  63905. light: Nullable<Light>;
  63906. /**
  63907. * Create a new LightBlock
  63908. * @param name defines the block name
  63909. */
  63910. constructor(name: string);
  63911. /**
  63912. * Gets the current class name
  63913. * @returns the class name
  63914. */
  63915. getClassName(): string;
  63916. /**
  63917. * Gets the world position input component
  63918. */
  63919. get worldPosition(): NodeMaterialConnectionPoint;
  63920. /**
  63921. * Gets the world normal input component
  63922. */
  63923. get worldNormal(): NodeMaterialConnectionPoint;
  63924. /**
  63925. * Gets the camera (or eye) position component
  63926. */
  63927. get cameraPosition(): NodeMaterialConnectionPoint;
  63928. /**
  63929. * Gets the glossiness component
  63930. */
  63931. get glossiness(): NodeMaterialConnectionPoint;
  63932. /**
  63933. * Gets the glossinness power component
  63934. */
  63935. get glossPower(): NodeMaterialConnectionPoint;
  63936. /**
  63937. * Gets the diffuse color component
  63938. */
  63939. get diffuseColor(): NodeMaterialConnectionPoint;
  63940. /**
  63941. * Gets the specular color component
  63942. */
  63943. get specularColor(): NodeMaterialConnectionPoint;
  63944. /**
  63945. * Gets the view matrix component
  63946. */
  63947. get view(): NodeMaterialConnectionPoint;
  63948. /**
  63949. * Gets the diffuse output component
  63950. */
  63951. get diffuseOutput(): NodeMaterialConnectionPoint;
  63952. /**
  63953. * Gets the specular output component
  63954. */
  63955. get specularOutput(): NodeMaterialConnectionPoint;
  63956. /**
  63957. * Gets the shadow output component
  63958. */
  63959. get shadow(): NodeMaterialConnectionPoint;
  63960. autoConfigure(material: NodeMaterial): void;
  63961. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63962. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63963. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63964. private _injectVertexCode;
  63965. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63966. serialize(): any;
  63967. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63968. }
  63969. }
  63970. declare module BABYLON {
  63971. /**
  63972. * Block used to read a reflection texture from a sampler
  63973. */
  63974. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63975. /**
  63976. * Create a new ReflectionTextureBlock
  63977. * @param name defines the block name
  63978. */
  63979. constructor(name: string);
  63980. /**
  63981. * Gets the current class name
  63982. * @returns the class name
  63983. */
  63984. getClassName(): string;
  63985. /**
  63986. * Gets the world position input component
  63987. */
  63988. get position(): NodeMaterialConnectionPoint;
  63989. /**
  63990. * Gets the world position input component
  63991. */
  63992. get worldPosition(): NodeMaterialConnectionPoint;
  63993. /**
  63994. * Gets the world normal input component
  63995. */
  63996. get worldNormal(): NodeMaterialConnectionPoint;
  63997. /**
  63998. * Gets the world input component
  63999. */
  64000. get world(): NodeMaterialConnectionPoint;
  64001. /**
  64002. * Gets the camera (or eye) position component
  64003. */
  64004. get cameraPosition(): NodeMaterialConnectionPoint;
  64005. /**
  64006. * Gets the view input component
  64007. */
  64008. get view(): NodeMaterialConnectionPoint;
  64009. /**
  64010. * Gets the rgb output component
  64011. */
  64012. get rgb(): NodeMaterialConnectionPoint;
  64013. /**
  64014. * Gets the rgba output component
  64015. */
  64016. get rgba(): NodeMaterialConnectionPoint;
  64017. /**
  64018. * Gets the r output component
  64019. */
  64020. get r(): NodeMaterialConnectionPoint;
  64021. /**
  64022. * Gets the g output component
  64023. */
  64024. get g(): NodeMaterialConnectionPoint;
  64025. /**
  64026. * Gets the b output component
  64027. */
  64028. get b(): NodeMaterialConnectionPoint;
  64029. /**
  64030. * Gets the a output component
  64031. */
  64032. get a(): NodeMaterialConnectionPoint;
  64033. autoConfigure(material: NodeMaterial): void;
  64034. protected _buildBlock(state: NodeMaterialBuildState): this;
  64035. }
  64036. }
  64037. declare module BABYLON {
  64038. /**
  64039. * Block used to add 2 vectors
  64040. */
  64041. export class AddBlock extends NodeMaterialBlock {
  64042. /**
  64043. * Creates a new AddBlock
  64044. * @param name defines the block name
  64045. */
  64046. constructor(name: string);
  64047. /**
  64048. * Gets the current class name
  64049. * @returns the class name
  64050. */
  64051. getClassName(): string;
  64052. /**
  64053. * Gets the left operand input component
  64054. */
  64055. get left(): NodeMaterialConnectionPoint;
  64056. /**
  64057. * Gets the right operand input component
  64058. */
  64059. get right(): NodeMaterialConnectionPoint;
  64060. /**
  64061. * Gets the output component
  64062. */
  64063. get output(): NodeMaterialConnectionPoint;
  64064. protected _buildBlock(state: NodeMaterialBuildState): this;
  64065. }
  64066. }
  64067. declare module BABYLON {
  64068. /**
  64069. * Block used to scale a vector by a float
  64070. */
  64071. export class ScaleBlock extends NodeMaterialBlock {
  64072. /**
  64073. * Creates a new ScaleBlock
  64074. * @param name defines the block name
  64075. */
  64076. constructor(name: string);
  64077. /**
  64078. * Gets the current class name
  64079. * @returns the class name
  64080. */
  64081. getClassName(): string;
  64082. /**
  64083. * Gets the input component
  64084. */
  64085. get input(): NodeMaterialConnectionPoint;
  64086. /**
  64087. * Gets the factor input component
  64088. */
  64089. get factor(): NodeMaterialConnectionPoint;
  64090. /**
  64091. * Gets the output component
  64092. */
  64093. get output(): NodeMaterialConnectionPoint;
  64094. protected _buildBlock(state: NodeMaterialBuildState): this;
  64095. }
  64096. }
  64097. declare module BABYLON {
  64098. /**
  64099. * Block used to clamp a float
  64100. */
  64101. export class ClampBlock extends NodeMaterialBlock {
  64102. /** Gets or sets the minimum range */
  64103. minimum: number;
  64104. /** Gets or sets the maximum range */
  64105. maximum: number;
  64106. /**
  64107. * Creates a new ClampBlock
  64108. * @param name defines the block name
  64109. */
  64110. constructor(name: string);
  64111. /**
  64112. * Gets the current class name
  64113. * @returns the class name
  64114. */
  64115. getClassName(): string;
  64116. /**
  64117. * Gets the value input component
  64118. */
  64119. get value(): NodeMaterialConnectionPoint;
  64120. /**
  64121. * Gets the output component
  64122. */
  64123. get output(): NodeMaterialConnectionPoint;
  64124. protected _buildBlock(state: NodeMaterialBuildState): this;
  64125. protected _dumpPropertiesCode(): string;
  64126. serialize(): any;
  64127. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64128. }
  64129. }
  64130. declare module BABYLON {
  64131. /**
  64132. * Block used to apply a cross product between 2 vectors
  64133. */
  64134. export class CrossBlock extends NodeMaterialBlock {
  64135. /**
  64136. * Creates a new CrossBlock
  64137. * @param name defines the block name
  64138. */
  64139. constructor(name: string);
  64140. /**
  64141. * Gets the current class name
  64142. * @returns the class name
  64143. */
  64144. getClassName(): string;
  64145. /**
  64146. * Gets the left operand input component
  64147. */
  64148. get left(): NodeMaterialConnectionPoint;
  64149. /**
  64150. * Gets the right operand input component
  64151. */
  64152. get right(): NodeMaterialConnectionPoint;
  64153. /**
  64154. * Gets the output component
  64155. */
  64156. get output(): NodeMaterialConnectionPoint;
  64157. protected _buildBlock(state: NodeMaterialBuildState): this;
  64158. }
  64159. }
  64160. declare module BABYLON {
  64161. /**
  64162. * Block used to apply a dot product between 2 vectors
  64163. */
  64164. export class DotBlock extends NodeMaterialBlock {
  64165. /**
  64166. * Creates a new DotBlock
  64167. * @param name defines the block name
  64168. */
  64169. constructor(name: string);
  64170. /**
  64171. * Gets the current class name
  64172. * @returns the class name
  64173. */
  64174. getClassName(): string;
  64175. /**
  64176. * Gets the left operand input component
  64177. */
  64178. get left(): NodeMaterialConnectionPoint;
  64179. /**
  64180. * Gets the right operand input component
  64181. */
  64182. get right(): NodeMaterialConnectionPoint;
  64183. /**
  64184. * Gets the output component
  64185. */
  64186. get output(): NodeMaterialConnectionPoint;
  64187. protected _buildBlock(state: NodeMaterialBuildState): this;
  64188. }
  64189. }
  64190. declare module BABYLON {
  64191. /**
  64192. * Block used to normalize a vector
  64193. */
  64194. export class NormalizeBlock extends NodeMaterialBlock {
  64195. /**
  64196. * Creates a new NormalizeBlock
  64197. * @param name defines the block name
  64198. */
  64199. constructor(name: string);
  64200. /**
  64201. * Gets the current class name
  64202. * @returns the class name
  64203. */
  64204. getClassName(): string;
  64205. /**
  64206. * Gets the input component
  64207. */
  64208. get input(): 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 create a Color3/4 out of individual inputs (one for each component)
  64219. */
  64220. export class ColorMergerBlock extends NodeMaterialBlock {
  64221. /**
  64222. * Create a new ColorMergerBlock
  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 rgb component (input)
  64233. */
  64234. get rgbIn(): NodeMaterialConnectionPoint;
  64235. /**
  64236. * Gets the r component (input)
  64237. */
  64238. get r(): NodeMaterialConnectionPoint;
  64239. /**
  64240. * Gets the g component (input)
  64241. */
  64242. get g(): NodeMaterialConnectionPoint;
  64243. /**
  64244. * Gets the b component (input)
  64245. */
  64246. get b(): NodeMaterialConnectionPoint;
  64247. /**
  64248. * Gets the a component (input)
  64249. */
  64250. get a(): NodeMaterialConnectionPoint;
  64251. /**
  64252. * Gets the rgba component (output)
  64253. */
  64254. get rgba(): NodeMaterialConnectionPoint;
  64255. /**
  64256. * Gets the rgb component (output)
  64257. */
  64258. get rgbOut(): NodeMaterialConnectionPoint;
  64259. /**
  64260. * Gets the rgb component (output)
  64261. * @deprecated Please use rgbOut instead.
  64262. */
  64263. get rgb(): NodeMaterialConnectionPoint;
  64264. protected _buildBlock(state: NodeMaterialBuildState): this;
  64265. }
  64266. }
  64267. declare module BABYLON {
  64268. /**
  64269. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64270. */
  64271. export class VectorSplitterBlock extends NodeMaterialBlock {
  64272. /**
  64273. * Create a new VectorSplitterBlock
  64274. * @param name defines the block name
  64275. */
  64276. constructor(name: string);
  64277. /**
  64278. * Gets the current class name
  64279. * @returns the class name
  64280. */
  64281. getClassName(): string;
  64282. /**
  64283. * Gets the xyzw component (input)
  64284. */
  64285. get xyzw(): NodeMaterialConnectionPoint;
  64286. /**
  64287. * Gets the xyz component (input)
  64288. */
  64289. get xyzIn(): NodeMaterialConnectionPoint;
  64290. /**
  64291. * Gets the xy component (input)
  64292. */
  64293. get xyIn(): NodeMaterialConnectionPoint;
  64294. /**
  64295. * Gets the xyz component (output)
  64296. */
  64297. get xyzOut(): NodeMaterialConnectionPoint;
  64298. /**
  64299. * Gets the xy component (output)
  64300. */
  64301. get xyOut(): NodeMaterialConnectionPoint;
  64302. /**
  64303. * Gets the x component (output)
  64304. */
  64305. get x(): NodeMaterialConnectionPoint;
  64306. /**
  64307. * Gets the y component (output)
  64308. */
  64309. get y(): NodeMaterialConnectionPoint;
  64310. /**
  64311. * Gets the z component (output)
  64312. */
  64313. get z(): NodeMaterialConnectionPoint;
  64314. /**
  64315. * Gets the w component (output)
  64316. */
  64317. get w(): NodeMaterialConnectionPoint;
  64318. protected _inputRename(name: string): string;
  64319. protected _outputRename(name: string): string;
  64320. protected _buildBlock(state: NodeMaterialBuildState): this;
  64321. }
  64322. }
  64323. declare module BABYLON {
  64324. /**
  64325. * Block used to lerp between 2 values
  64326. */
  64327. export class LerpBlock extends NodeMaterialBlock {
  64328. /**
  64329. * Creates a new LerpBlock
  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 left operand input component
  64340. */
  64341. get left(): NodeMaterialConnectionPoint;
  64342. /**
  64343. * Gets the right operand input component
  64344. */
  64345. get right(): NodeMaterialConnectionPoint;
  64346. /**
  64347. * Gets the gradient operand input component
  64348. */
  64349. get gradient(): NodeMaterialConnectionPoint;
  64350. /**
  64351. * Gets the output component
  64352. */
  64353. get output(): NodeMaterialConnectionPoint;
  64354. protected _buildBlock(state: NodeMaterialBuildState): this;
  64355. }
  64356. }
  64357. declare module BABYLON {
  64358. /**
  64359. * Block used to divide 2 vectors
  64360. */
  64361. export class DivideBlock extends NodeMaterialBlock {
  64362. /**
  64363. * Creates a new DivideBlock
  64364. * @param name defines the block name
  64365. */
  64366. constructor(name: string);
  64367. /**
  64368. * Gets the current class name
  64369. * @returns the class name
  64370. */
  64371. getClassName(): string;
  64372. /**
  64373. * Gets the left operand input component
  64374. */
  64375. get left(): NodeMaterialConnectionPoint;
  64376. /**
  64377. * Gets the right operand input component
  64378. */
  64379. get right(): NodeMaterialConnectionPoint;
  64380. /**
  64381. * Gets the output component
  64382. */
  64383. get output(): NodeMaterialConnectionPoint;
  64384. protected _buildBlock(state: NodeMaterialBuildState): this;
  64385. }
  64386. }
  64387. declare module BABYLON {
  64388. /**
  64389. * Block used to subtract 2 vectors
  64390. */
  64391. export class SubtractBlock extends NodeMaterialBlock {
  64392. /**
  64393. * Creates a new SubtractBlock
  64394. * @param name defines the block name
  64395. */
  64396. constructor(name: string);
  64397. /**
  64398. * Gets the current class name
  64399. * @returns the class name
  64400. */
  64401. getClassName(): string;
  64402. /**
  64403. * Gets the left operand input component
  64404. */
  64405. get left(): NodeMaterialConnectionPoint;
  64406. /**
  64407. * Gets the right operand input component
  64408. */
  64409. get right(): NodeMaterialConnectionPoint;
  64410. /**
  64411. * Gets the output component
  64412. */
  64413. get output(): NodeMaterialConnectionPoint;
  64414. protected _buildBlock(state: NodeMaterialBuildState): this;
  64415. }
  64416. }
  64417. declare module BABYLON {
  64418. /**
  64419. * Block used to step a value
  64420. */
  64421. export class StepBlock extends NodeMaterialBlock {
  64422. /**
  64423. * Creates a new StepBlock
  64424. * @param name defines the block name
  64425. */
  64426. constructor(name: string);
  64427. /**
  64428. * Gets the current class name
  64429. * @returns the class name
  64430. */
  64431. getClassName(): string;
  64432. /**
  64433. * Gets the value operand input component
  64434. */
  64435. get value(): NodeMaterialConnectionPoint;
  64436. /**
  64437. * Gets the edge operand input component
  64438. */
  64439. get edge(): NodeMaterialConnectionPoint;
  64440. /**
  64441. * Gets the output component
  64442. */
  64443. get output(): NodeMaterialConnectionPoint;
  64444. protected _buildBlock(state: NodeMaterialBuildState): this;
  64445. }
  64446. }
  64447. declare module BABYLON {
  64448. /**
  64449. * Block used to get the opposite (1 - x) of a value
  64450. */
  64451. export class OneMinusBlock extends NodeMaterialBlock {
  64452. /**
  64453. * Creates a new OneMinusBlock
  64454. * @param name defines the block name
  64455. */
  64456. constructor(name: string);
  64457. /**
  64458. * Gets the current class name
  64459. * @returns the class name
  64460. */
  64461. getClassName(): string;
  64462. /**
  64463. * Gets the input component
  64464. */
  64465. get input(): 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 get the view direction
  64476. */
  64477. export class ViewDirectionBlock extends NodeMaterialBlock {
  64478. /**
  64479. * Creates a new ViewDirectionBlock
  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 world position component
  64490. */
  64491. get worldPosition(): NodeMaterialConnectionPoint;
  64492. /**
  64493. * Gets the camera position component
  64494. */
  64495. get cameraPosition(): NodeMaterialConnectionPoint;
  64496. /**
  64497. * Gets the output component
  64498. */
  64499. get output(): NodeMaterialConnectionPoint;
  64500. autoConfigure(material: NodeMaterial): void;
  64501. protected _buildBlock(state: NodeMaterialBuildState): this;
  64502. }
  64503. }
  64504. declare module BABYLON {
  64505. /**
  64506. * Block used to compute fresnel value
  64507. */
  64508. export class FresnelBlock extends NodeMaterialBlock {
  64509. /**
  64510. * Create a new FresnelBlock
  64511. * @param name defines the block name
  64512. */
  64513. constructor(name: string);
  64514. /**
  64515. * Gets the current class name
  64516. * @returns the class name
  64517. */
  64518. getClassName(): string;
  64519. /**
  64520. * Gets the world normal input component
  64521. */
  64522. get worldNormal(): NodeMaterialConnectionPoint;
  64523. /**
  64524. * Gets the view direction input component
  64525. */
  64526. get viewDirection(): NodeMaterialConnectionPoint;
  64527. /**
  64528. * Gets the bias input component
  64529. */
  64530. get bias(): NodeMaterialConnectionPoint;
  64531. /**
  64532. * Gets the camera (or eye) position component
  64533. */
  64534. get power(): NodeMaterialConnectionPoint;
  64535. /**
  64536. * Gets the fresnel output component
  64537. */
  64538. get fresnel(): NodeMaterialConnectionPoint;
  64539. autoConfigure(material: NodeMaterial): void;
  64540. protected _buildBlock(state: NodeMaterialBuildState): this;
  64541. }
  64542. }
  64543. declare module BABYLON {
  64544. /**
  64545. * Block used to get the max of 2 values
  64546. */
  64547. export class MaxBlock extends NodeMaterialBlock {
  64548. /**
  64549. * Creates a new MaxBlock
  64550. * @param name defines the block name
  64551. */
  64552. constructor(name: string);
  64553. /**
  64554. * Gets the current class name
  64555. * @returns the class name
  64556. */
  64557. getClassName(): string;
  64558. /**
  64559. * Gets the left operand input component
  64560. */
  64561. get left(): NodeMaterialConnectionPoint;
  64562. /**
  64563. * Gets the right operand input component
  64564. */
  64565. get right(): NodeMaterialConnectionPoint;
  64566. /**
  64567. * Gets the output component
  64568. */
  64569. get output(): NodeMaterialConnectionPoint;
  64570. protected _buildBlock(state: NodeMaterialBuildState): this;
  64571. }
  64572. }
  64573. declare module BABYLON {
  64574. /**
  64575. * Block used to get the min of 2 values
  64576. */
  64577. export class MinBlock extends NodeMaterialBlock {
  64578. /**
  64579. * Creates a new MinBlock
  64580. * @param name defines the block name
  64581. */
  64582. constructor(name: string);
  64583. /**
  64584. * Gets the current class name
  64585. * @returns the class name
  64586. */
  64587. getClassName(): string;
  64588. /**
  64589. * Gets the left operand input component
  64590. */
  64591. get left(): NodeMaterialConnectionPoint;
  64592. /**
  64593. * Gets the right operand input component
  64594. */
  64595. get right(): NodeMaterialConnectionPoint;
  64596. /**
  64597. * Gets the output component
  64598. */
  64599. get output(): NodeMaterialConnectionPoint;
  64600. protected _buildBlock(state: NodeMaterialBuildState): this;
  64601. }
  64602. }
  64603. declare module BABYLON {
  64604. /**
  64605. * Block used to get the distance between 2 values
  64606. */
  64607. export class DistanceBlock extends NodeMaterialBlock {
  64608. /**
  64609. * Creates a new DistanceBlock
  64610. * @param name defines the block name
  64611. */
  64612. constructor(name: string);
  64613. /**
  64614. * Gets the current class name
  64615. * @returns the class name
  64616. */
  64617. getClassName(): string;
  64618. /**
  64619. * Gets the left operand input component
  64620. */
  64621. get left(): NodeMaterialConnectionPoint;
  64622. /**
  64623. * Gets the right operand input component
  64624. */
  64625. get right(): NodeMaterialConnectionPoint;
  64626. /**
  64627. * Gets the output component
  64628. */
  64629. get output(): NodeMaterialConnectionPoint;
  64630. protected _buildBlock(state: NodeMaterialBuildState): this;
  64631. }
  64632. }
  64633. declare module BABYLON {
  64634. /**
  64635. * Block used to get the length of a vector
  64636. */
  64637. export class LengthBlock extends NodeMaterialBlock {
  64638. /**
  64639. * Creates a new LengthBlock
  64640. * @param name defines the block name
  64641. */
  64642. constructor(name: string);
  64643. /**
  64644. * Gets the current class name
  64645. * @returns the class name
  64646. */
  64647. getClassName(): string;
  64648. /**
  64649. * Gets the value input component
  64650. */
  64651. get value(): 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 negative version of a value (i.e. x * -1)
  64662. */
  64663. export class NegateBlock extends NodeMaterialBlock {
  64664. /**
  64665. * Creates a new NegateBlock
  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 value input component
  64676. */
  64677. get value(): NodeMaterialConnectionPoint;
  64678. /**
  64679. * Gets the output component
  64680. */
  64681. get output(): NodeMaterialConnectionPoint;
  64682. protected _buildBlock(state: NodeMaterialBuildState): this;
  64683. }
  64684. }
  64685. declare module BABYLON {
  64686. /**
  64687. * Block used to get the value of the first parameter raised to the power of the second
  64688. */
  64689. export class PowBlock extends NodeMaterialBlock {
  64690. /**
  64691. * Creates a new PowBlock
  64692. * @param name defines the block name
  64693. */
  64694. constructor(name: string);
  64695. /**
  64696. * Gets the current class name
  64697. * @returns the class name
  64698. */
  64699. getClassName(): string;
  64700. /**
  64701. * Gets the value operand input component
  64702. */
  64703. get value(): NodeMaterialConnectionPoint;
  64704. /**
  64705. * Gets the power operand input component
  64706. */
  64707. get power(): 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 a random number
  64718. */
  64719. export class RandomNumberBlock extends NodeMaterialBlock {
  64720. /**
  64721. * Creates a new RandomNumberBlock
  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 seed input component
  64732. */
  64733. get seed(): 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 compute arc tangent of 2 values
  64744. */
  64745. export class ArcTan2Block extends NodeMaterialBlock {
  64746. /**
  64747. * Creates a new ArcTan2Block
  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 x operand input component
  64758. */
  64759. get x(): NodeMaterialConnectionPoint;
  64760. /**
  64761. * Gets the y operand input component
  64762. */
  64763. get y(): 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 smooth step a value
  64774. */
  64775. export class SmoothStepBlock extends NodeMaterialBlock {
  64776. /**
  64777. * Creates a new SmoothStepBlock
  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 value operand input component
  64788. */
  64789. get value(): NodeMaterialConnectionPoint;
  64790. /**
  64791. * Gets the first edge operand input component
  64792. */
  64793. get edge0(): NodeMaterialConnectionPoint;
  64794. /**
  64795. * Gets the second edge operand input component
  64796. */
  64797. get edge1(): NodeMaterialConnectionPoint;
  64798. /**
  64799. * Gets the output component
  64800. */
  64801. get output(): NodeMaterialConnectionPoint;
  64802. protected _buildBlock(state: NodeMaterialBuildState): this;
  64803. }
  64804. }
  64805. declare module BABYLON {
  64806. /**
  64807. * Block used to get the reciprocal (1 / x) of a value
  64808. */
  64809. export class ReciprocalBlock extends NodeMaterialBlock {
  64810. /**
  64811. * Creates a new ReciprocalBlock
  64812. * @param name defines the block name
  64813. */
  64814. constructor(name: string);
  64815. /**
  64816. * Gets the current class name
  64817. * @returns the class name
  64818. */
  64819. getClassName(): string;
  64820. /**
  64821. * Gets the input component
  64822. */
  64823. get input(): NodeMaterialConnectionPoint;
  64824. /**
  64825. * Gets the output component
  64826. */
  64827. get output(): NodeMaterialConnectionPoint;
  64828. protected _buildBlock(state: NodeMaterialBuildState): this;
  64829. }
  64830. }
  64831. declare module BABYLON {
  64832. /**
  64833. * Block used to replace a color by another one
  64834. */
  64835. export class ReplaceColorBlock extends NodeMaterialBlock {
  64836. /**
  64837. * Creates a new ReplaceColorBlock
  64838. * @param name defines the block name
  64839. */
  64840. constructor(name: string);
  64841. /**
  64842. * Gets the current class name
  64843. * @returns the class name
  64844. */
  64845. getClassName(): string;
  64846. /**
  64847. * Gets the value input component
  64848. */
  64849. get value(): NodeMaterialConnectionPoint;
  64850. /**
  64851. * Gets the reference input component
  64852. */
  64853. get reference(): NodeMaterialConnectionPoint;
  64854. /**
  64855. * Gets the distance input component
  64856. */
  64857. get distance(): NodeMaterialConnectionPoint;
  64858. /**
  64859. * Gets the replacement input component
  64860. */
  64861. get replacement(): NodeMaterialConnectionPoint;
  64862. /**
  64863. * Gets the output component
  64864. */
  64865. get output(): NodeMaterialConnectionPoint;
  64866. protected _buildBlock(state: NodeMaterialBuildState): this;
  64867. }
  64868. }
  64869. declare module BABYLON {
  64870. /**
  64871. * Block used to posterize a value
  64872. * @see https://en.wikipedia.org/wiki/Posterization
  64873. */
  64874. export class PosterizeBlock extends NodeMaterialBlock {
  64875. /**
  64876. * Creates a new PosterizeBlock
  64877. * @param name defines the block name
  64878. */
  64879. constructor(name: string);
  64880. /**
  64881. * Gets the current class name
  64882. * @returns the class name
  64883. */
  64884. getClassName(): string;
  64885. /**
  64886. * Gets the value input component
  64887. */
  64888. get value(): NodeMaterialConnectionPoint;
  64889. /**
  64890. * Gets the steps input component
  64891. */
  64892. get steps(): NodeMaterialConnectionPoint;
  64893. /**
  64894. * Gets the output component
  64895. */
  64896. get output(): NodeMaterialConnectionPoint;
  64897. protected _buildBlock(state: NodeMaterialBuildState): this;
  64898. }
  64899. }
  64900. declare module BABYLON {
  64901. /**
  64902. * Operations supported by the Wave block
  64903. */
  64904. export enum WaveBlockKind {
  64905. /** SawTooth */
  64906. SawTooth = 0,
  64907. /** Square */
  64908. Square = 1,
  64909. /** Triangle */
  64910. Triangle = 2
  64911. }
  64912. /**
  64913. * Block used to apply wave operation to floats
  64914. */
  64915. export class WaveBlock extends NodeMaterialBlock {
  64916. /**
  64917. * Gets or sets the kibnd of wave to be applied by the block
  64918. */
  64919. kind: WaveBlockKind;
  64920. /**
  64921. * Creates a new WaveBlock
  64922. * @param name defines the block name
  64923. */
  64924. constructor(name: string);
  64925. /**
  64926. * Gets the current class name
  64927. * @returns the class name
  64928. */
  64929. getClassName(): string;
  64930. /**
  64931. * Gets the input component
  64932. */
  64933. get input(): NodeMaterialConnectionPoint;
  64934. /**
  64935. * Gets the output component
  64936. */
  64937. get output(): NodeMaterialConnectionPoint;
  64938. protected _buildBlock(state: NodeMaterialBuildState): this;
  64939. serialize(): any;
  64940. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64941. }
  64942. }
  64943. declare module BABYLON {
  64944. /**
  64945. * Class used to store a color step for the GradientBlock
  64946. */
  64947. export class GradientBlockColorStep {
  64948. private _step;
  64949. /**
  64950. * Gets value indicating which step this color is associated with (between 0 and 1)
  64951. */
  64952. get step(): number;
  64953. /**
  64954. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64955. */
  64956. set step(val: number);
  64957. private _color;
  64958. /**
  64959. * Gets the color associated with this step
  64960. */
  64961. get color(): Color3;
  64962. /**
  64963. * Sets the color associated with this step
  64964. */
  64965. set color(val: Color3);
  64966. /**
  64967. * Creates a new GradientBlockColorStep
  64968. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64969. * @param color defines the color associated with this step
  64970. */
  64971. constructor(step: number, color: Color3);
  64972. }
  64973. /**
  64974. * Block used to return a color from a gradient based on an input value between 0 and 1
  64975. */
  64976. export class GradientBlock extends NodeMaterialBlock {
  64977. /**
  64978. * Gets or sets the list of color steps
  64979. */
  64980. colorSteps: GradientBlockColorStep[];
  64981. /** Gets an observable raised when the value is changed */
  64982. onValueChangedObservable: Observable<GradientBlock>;
  64983. /** calls observable when the value is changed*/
  64984. colorStepsUpdated(): void;
  64985. /**
  64986. * Creates a new GradientBlock
  64987. * @param name defines the block name
  64988. */
  64989. constructor(name: string);
  64990. /**
  64991. * Gets the current class name
  64992. * @returns the class name
  64993. */
  64994. getClassName(): string;
  64995. /**
  64996. * Gets the gradient input component
  64997. */
  64998. get gradient(): NodeMaterialConnectionPoint;
  64999. /**
  65000. * Gets the output component
  65001. */
  65002. get output(): NodeMaterialConnectionPoint;
  65003. private _writeColorConstant;
  65004. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65005. serialize(): any;
  65006. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65007. protected _dumpPropertiesCode(): string;
  65008. }
  65009. }
  65010. declare module BABYLON {
  65011. /**
  65012. * Block used to normalize lerp between 2 values
  65013. */
  65014. export class NLerpBlock extends NodeMaterialBlock {
  65015. /**
  65016. * Creates a new NLerpBlock
  65017. * @param name defines the block name
  65018. */
  65019. constructor(name: string);
  65020. /**
  65021. * Gets the current class name
  65022. * @returns the class name
  65023. */
  65024. getClassName(): string;
  65025. /**
  65026. * Gets the left operand input component
  65027. */
  65028. get left(): NodeMaterialConnectionPoint;
  65029. /**
  65030. * Gets the right operand input component
  65031. */
  65032. get right(): NodeMaterialConnectionPoint;
  65033. /**
  65034. * Gets the gradient operand input component
  65035. */
  65036. get gradient(): NodeMaterialConnectionPoint;
  65037. /**
  65038. * Gets the output component
  65039. */
  65040. get output(): NodeMaterialConnectionPoint;
  65041. protected _buildBlock(state: NodeMaterialBuildState): this;
  65042. }
  65043. }
  65044. declare module BABYLON {
  65045. /**
  65046. * block used to Generate a Worley Noise 3D Noise Pattern
  65047. */
  65048. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65049. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65050. manhattanDistance: boolean;
  65051. /**
  65052. * Creates a new WorleyNoise3DBlock
  65053. * @param name defines the block name
  65054. */
  65055. constructor(name: string);
  65056. /**
  65057. * Gets the current class name
  65058. * @returns the class name
  65059. */
  65060. getClassName(): string;
  65061. /**
  65062. * Gets the seed input component
  65063. */
  65064. get seed(): NodeMaterialConnectionPoint;
  65065. /**
  65066. * Gets the jitter input component
  65067. */
  65068. get jitter(): NodeMaterialConnectionPoint;
  65069. /**
  65070. * Gets the output component
  65071. */
  65072. get output(): NodeMaterialConnectionPoint;
  65073. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65074. /**
  65075. * Exposes the properties to the UI?
  65076. */
  65077. protected _dumpPropertiesCode(): string;
  65078. /**
  65079. * Exposes the properties to the Seralize?
  65080. */
  65081. serialize(): any;
  65082. /**
  65083. * Exposes the properties to the deseralize?
  65084. */
  65085. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65086. }
  65087. }
  65088. declare module BABYLON {
  65089. /**
  65090. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65091. */
  65092. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65093. /**
  65094. * Creates a new SimplexPerlin3DBlock
  65095. * @param name defines the block name
  65096. */
  65097. constructor(name: string);
  65098. /**
  65099. * Gets the current class name
  65100. * @returns the class name
  65101. */
  65102. getClassName(): string;
  65103. /**
  65104. * Gets the seed operand input component
  65105. */
  65106. get seed(): NodeMaterialConnectionPoint;
  65107. /**
  65108. * Gets the output component
  65109. */
  65110. get output(): NodeMaterialConnectionPoint;
  65111. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65112. }
  65113. }
  65114. declare module BABYLON {
  65115. /**
  65116. * Block used to blend normals
  65117. */
  65118. export class NormalBlendBlock extends NodeMaterialBlock {
  65119. /**
  65120. * Creates a new NormalBlendBlock
  65121. * @param name defines the block name
  65122. */
  65123. constructor(name: string);
  65124. /**
  65125. * Gets the current class name
  65126. * @returns the class name
  65127. */
  65128. getClassName(): string;
  65129. /**
  65130. * Gets the first input component
  65131. */
  65132. get normalMap0(): NodeMaterialConnectionPoint;
  65133. /**
  65134. * Gets the second input component
  65135. */
  65136. get normalMap1(): NodeMaterialConnectionPoint;
  65137. /**
  65138. * Gets the output component
  65139. */
  65140. get output(): NodeMaterialConnectionPoint;
  65141. protected _buildBlock(state: NodeMaterialBuildState): this;
  65142. }
  65143. }
  65144. declare module BABYLON {
  65145. /**
  65146. * Block used to rotate a 2d vector by a given angle
  65147. */
  65148. export class Rotate2dBlock extends NodeMaterialBlock {
  65149. /**
  65150. * Creates a new Rotate2dBlock
  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 input vector
  65161. */
  65162. get input(): NodeMaterialConnectionPoint;
  65163. /**
  65164. * Gets the input angle
  65165. */
  65166. get angle(): NodeMaterialConnectionPoint;
  65167. /**
  65168. * Gets the output component
  65169. */
  65170. get output(): NodeMaterialConnectionPoint;
  65171. autoConfigure(material: NodeMaterial): void;
  65172. protected _buildBlock(state: NodeMaterialBuildState): this;
  65173. }
  65174. }
  65175. declare module BABYLON {
  65176. /**
  65177. * Block used to get the reflected vector from a direction and a normal
  65178. */
  65179. export class ReflectBlock extends NodeMaterialBlock {
  65180. /**
  65181. * Creates a new ReflectBlock
  65182. * @param name defines the block name
  65183. */
  65184. constructor(name: string);
  65185. /**
  65186. * Gets the current class name
  65187. * @returns the class name
  65188. */
  65189. getClassName(): string;
  65190. /**
  65191. * Gets the incident component
  65192. */
  65193. get incident(): NodeMaterialConnectionPoint;
  65194. /**
  65195. * Gets the normal component
  65196. */
  65197. get normal(): NodeMaterialConnectionPoint;
  65198. /**
  65199. * Gets the output component
  65200. */
  65201. get output(): NodeMaterialConnectionPoint;
  65202. protected _buildBlock(state: NodeMaterialBuildState): this;
  65203. }
  65204. }
  65205. declare module BABYLON {
  65206. /**
  65207. * Block used to get the refracted vector from a direction and a normal
  65208. */
  65209. export class RefractBlock extends NodeMaterialBlock {
  65210. /**
  65211. * Creates a new RefractBlock
  65212. * @param name defines the block name
  65213. */
  65214. constructor(name: string);
  65215. /**
  65216. * Gets the current class name
  65217. * @returns the class name
  65218. */
  65219. getClassName(): string;
  65220. /**
  65221. * Gets the incident component
  65222. */
  65223. get incident(): NodeMaterialConnectionPoint;
  65224. /**
  65225. * Gets the normal component
  65226. */
  65227. get normal(): NodeMaterialConnectionPoint;
  65228. /**
  65229. * Gets the index of refraction component
  65230. */
  65231. get ior(): NodeMaterialConnectionPoint;
  65232. /**
  65233. * Gets the output component
  65234. */
  65235. get output(): NodeMaterialConnectionPoint;
  65236. protected _buildBlock(state: NodeMaterialBuildState): this;
  65237. }
  65238. }
  65239. declare module BABYLON {
  65240. /**
  65241. * Block used to desaturate a color
  65242. */
  65243. export class DesaturateBlock extends NodeMaterialBlock {
  65244. /**
  65245. * Creates a new DesaturateBlock
  65246. * @param name defines the block name
  65247. */
  65248. constructor(name: string);
  65249. /**
  65250. * Gets the current class name
  65251. * @returns the class name
  65252. */
  65253. getClassName(): string;
  65254. /**
  65255. * Gets the color operand input component
  65256. */
  65257. get color(): NodeMaterialConnectionPoint;
  65258. /**
  65259. * Gets the level operand input component
  65260. */
  65261. get level(): NodeMaterialConnectionPoint;
  65262. /**
  65263. * Gets the output component
  65264. */
  65265. get output(): NodeMaterialConnectionPoint;
  65266. protected _buildBlock(state: NodeMaterialBuildState): this;
  65267. }
  65268. }
  65269. declare module BABYLON {
  65270. /**
  65271. * Block used to implement the ambient occlusion module of the PBR material
  65272. */
  65273. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  65274. /**
  65275. * Create a new AmbientOcclusionBlock
  65276. * @param name defines the block name
  65277. */
  65278. constructor(name: string);
  65279. /**
  65280. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  65281. */
  65282. useAmbientInGrayScale: boolean;
  65283. /**
  65284. * Initialize the block and prepare the context for build
  65285. * @param state defines the state that will be used for the build
  65286. */
  65287. initialize(state: NodeMaterialBuildState): void;
  65288. /**
  65289. * Gets the current class name
  65290. * @returns the class name
  65291. */
  65292. getClassName(): string;
  65293. /**
  65294. * Gets the texture input component
  65295. */
  65296. get texture(): NodeMaterialConnectionPoint;
  65297. /**
  65298. * Gets the texture intensity component
  65299. */
  65300. get intensity(): NodeMaterialConnectionPoint;
  65301. /**
  65302. * Gets the direct light intensity input component
  65303. */
  65304. get directLightIntensity(): NodeMaterialConnectionPoint;
  65305. /**
  65306. * Gets the ambient occlusion object output component
  65307. */
  65308. get ambientOcc(): NodeMaterialConnectionPoint;
  65309. /**
  65310. * Gets the main code of the block (fragment side)
  65311. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65312. * @returns the shader code
  65313. */
  65314. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65315. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65316. protected _buildBlock(state: NodeMaterialBuildState): this;
  65317. protected _dumpPropertiesCode(): string;
  65318. serialize(): any;
  65319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65320. }
  65321. }
  65322. declare module BABYLON {
  65323. /**
  65324. * Block used to implement the reflection module of the PBR material
  65325. */
  65326. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65327. /** @hidden */
  65328. _defineLODReflectionAlpha: string;
  65329. /** @hidden */
  65330. _defineLinearSpecularReflection: string;
  65331. private _vEnvironmentIrradianceName;
  65332. /** @hidden */
  65333. _vReflectionMicrosurfaceInfosName: string;
  65334. /** @hidden */
  65335. _vReflectionInfosName: string;
  65336. /** @hidden */
  65337. _vReflectionFilteringInfoName: string;
  65338. private _scene;
  65339. /**
  65340. * The three properties below are set by the main PBR block prior to calling methods of this class.
  65341. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65342. * It's less burden on the user side in the editor part.
  65343. */
  65344. /** @hidden */
  65345. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65346. /** @hidden */
  65347. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65348. /** @hidden */
  65349. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65350. /**
  65351. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65352. * diffuse part of the IBL.
  65353. */
  65354. useSphericalHarmonics: boolean;
  65355. /**
  65356. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65357. */
  65358. forceIrradianceInFragment: boolean;
  65359. /**
  65360. * Create a new ReflectionBlock
  65361. * @param name defines the block name
  65362. */
  65363. constructor(name: string);
  65364. /**
  65365. * Gets the current class name
  65366. * @returns the class name
  65367. */
  65368. getClassName(): string;
  65369. /**
  65370. * Gets the position input component
  65371. */
  65372. get position(): NodeMaterialConnectionPoint;
  65373. /**
  65374. * Gets the world position input component
  65375. */
  65376. get worldPosition(): NodeMaterialConnectionPoint;
  65377. /**
  65378. * Gets the world normal input component
  65379. */
  65380. get worldNormal(): NodeMaterialConnectionPoint;
  65381. /**
  65382. * Gets the world input component
  65383. */
  65384. get world(): NodeMaterialConnectionPoint;
  65385. /**
  65386. * Gets the camera (or eye) position component
  65387. */
  65388. get cameraPosition(): NodeMaterialConnectionPoint;
  65389. /**
  65390. * Gets the view input component
  65391. */
  65392. get view(): NodeMaterialConnectionPoint;
  65393. /**
  65394. * Gets the color input component
  65395. */
  65396. get color(): NodeMaterialConnectionPoint;
  65397. /**
  65398. * Gets the reflection object output component
  65399. */
  65400. get reflection(): NodeMaterialConnectionPoint;
  65401. /**
  65402. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65403. */
  65404. get hasTexture(): boolean;
  65405. /**
  65406. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65407. */
  65408. get reflectionColor(): string;
  65409. protected _getTexture(): Nullable<BaseTexture>;
  65410. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65411. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65412. /**
  65413. * Gets the code to inject in the vertex shader
  65414. * @param state current state of the node material building
  65415. * @returns the shader code
  65416. */
  65417. handleVertexSide(state: NodeMaterialBuildState): string;
  65418. /**
  65419. * Gets the main code of the block (fragment side)
  65420. * @param state current state of the node material building
  65421. * @param normalVarName name of the existing variable corresponding to the normal
  65422. * @returns the shader code
  65423. */
  65424. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65425. protected _buildBlock(state: NodeMaterialBuildState): this;
  65426. protected _dumpPropertiesCode(): string;
  65427. serialize(): any;
  65428. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65429. }
  65430. }
  65431. declare module BABYLON {
  65432. /**
  65433. * Block used to implement the sheen module of the PBR material
  65434. */
  65435. export class SheenBlock extends NodeMaterialBlock {
  65436. /**
  65437. * Create a new SheenBlock
  65438. * @param name defines the block name
  65439. */
  65440. constructor(name: string);
  65441. /**
  65442. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65443. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65444. * making it easier to setup and tweak the effect
  65445. */
  65446. albedoScaling: boolean;
  65447. /**
  65448. * Defines if the sheen is linked to the sheen color.
  65449. */
  65450. linkSheenWithAlbedo: boolean;
  65451. /**
  65452. * Initialize the block and prepare the context for build
  65453. * @param state defines the state that will be used for the build
  65454. */
  65455. initialize(state: NodeMaterialBuildState): void;
  65456. /**
  65457. * Gets the current class name
  65458. * @returns the class name
  65459. */
  65460. getClassName(): string;
  65461. /**
  65462. * Gets the intensity input component
  65463. */
  65464. get intensity(): NodeMaterialConnectionPoint;
  65465. /**
  65466. * Gets the color input component
  65467. */
  65468. get color(): NodeMaterialConnectionPoint;
  65469. /**
  65470. * Gets the roughness input component
  65471. */
  65472. get roughness(): NodeMaterialConnectionPoint;
  65473. /**
  65474. * Gets the sheen object output component
  65475. */
  65476. get sheen(): NodeMaterialConnectionPoint;
  65477. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65478. /**
  65479. * Gets the main code of the block (fragment side)
  65480. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65481. * @returns the shader code
  65482. */
  65483. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65484. protected _buildBlock(state: NodeMaterialBuildState): this;
  65485. protected _dumpPropertiesCode(): string;
  65486. serialize(): any;
  65487. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65488. }
  65489. }
  65490. declare module BABYLON {
  65491. /**
  65492. * Block used to implement the reflectivity module of the PBR material
  65493. */
  65494. export class ReflectivityBlock extends NodeMaterialBlock {
  65495. private _metallicReflectanceColor;
  65496. private _metallicF0Factor;
  65497. /** @hidden */
  65498. _vMetallicReflectanceFactorsName: string;
  65499. /**
  65500. * The property below is set by the main PBR block prior to calling methods of this class.
  65501. */
  65502. /** @hidden */
  65503. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  65504. /**
  65505. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65506. */
  65507. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65508. /**
  65509. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65510. */
  65511. useMetallnessFromMetallicTextureBlue: boolean;
  65512. /**
  65513. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65514. */
  65515. useRoughnessFromMetallicTextureAlpha: boolean;
  65516. /**
  65517. * Specifies if the metallic texture contains the roughness information in its green channel.
  65518. */
  65519. useRoughnessFromMetallicTextureGreen: boolean;
  65520. /**
  65521. * Create a new ReflectivityBlock
  65522. * @param name defines the block name
  65523. */
  65524. constructor(name: string);
  65525. /**
  65526. * Initialize the block and prepare the context for build
  65527. * @param state defines the state that will be used for the build
  65528. */
  65529. initialize(state: NodeMaterialBuildState): void;
  65530. /**
  65531. * Gets the current class name
  65532. * @returns the class name
  65533. */
  65534. getClassName(): string;
  65535. /**
  65536. * Gets the metallic input component
  65537. */
  65538. get metallic(): NodeMaterialConnectionPoint;
  65539. /**
  65540. * Gets the roughness input component
  65541. */
  65542. get roughness(): NodeMaterialConnectionPoint;
  65543. /**
  65544. * Gets the texture input component
  65545. */
  65546. get texture(): NodeMaterialConnectionPoint;
  65547. /**
  65548. * Gets the reflectivity object output component
  65549. */
  65550. get reflectivity(): NodeMaterialConnectionPoint;
  65551. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65552. /**
  65553. * Gets the main code of the block (fragment side)
  65554. * @param state current state of the node material building
  65555. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65556. * @returns the shader code
  65557. */
  65558. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  65559. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65560. protected _buildBlock(state: NodeMaterialBuildState): this;
  65561. protected _dumpPropertiesCode(): string;
  65562. serialize(): any;
  65563. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65564. }
  65565. }
  65566. declare module BABYLON {
  65567. /**
  65568. * Block used to implement the anisotropy module of the PBR material
  65569. */
  65570. export class AnisotropyBlock extends NodeMaterialBlock {
  65571. /**
  65572. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65573. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65574. * It's less burden on the user side in the editor part.
  65575. */
  65576. /** @hidden */
  65577. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65578. /** @hidden */
  65579. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65580. /**
  65581. * Create a new AnisotropyBlock
  65582. * @param name defines the block name
  65583. */
  65584. constructor(name: string);
  65585. /**
  65586. * Initialize the block and prepare the context for build
  65587. * @param state defines the state that will be used for the build
  65588. */
  65589. initialize(state: NodeMaterialBuildState): void;
  65590. /**
  65591. * Gets the current class name
  65592. * @returns the class name
  65593. */
  65594. getClassName(): string;
  65595. /**
  65596. * Gets the intensity input component
  65597. */
  65598. get intensity(): NodeMaterialConnectionPoint;
  65599. /**
  65600. * Gets the direction input component
  65601. */
  65602. get direction(): NodeMaterialConnectionPoint;
  65603. /**
  65604. * Gets the texture input component
  65605. */
  65606. get texture(): NodeMaterialConnectionPoint;
  65607. /**
  65608. * Gets the uv input component
  65609. */
  65610. get uv(): NodeMaterialConnectionPoint;
  65611. /**
  65612. * Gets the worldTangent input component
  65613. */
  65614. get worldTangent(): NodeMaterialConnectionPoint;
  65615. /**
  65616. * Gets the anisotropy object output component
  65617. */
  65618. get anisotropy(): NodeMaterialConnectionPoint;
  65619. private _generateTBNSpace;
  65620. /**
  65621. * Gets the main code of the block (fragment side)
  65622. * @param state current state of the node material building
  65623. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65624. * @returns the shader code
  65625. */
  65626. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65628. protected _buildBlock(state: NodeMaterialBuildState): this;
  65629. }
  65630. }
  65631. declare module BABYLON {
  65632. /**
  65633. * Block used to implement the clear coat module of the PBR material
  65634. */
  65635. export class ClearCoatBlock extends NodeMaterialBlock {
  65636. private _scene;
  65637. /**
  65638. * Create a new ClearCoatBlock
  65639. * @param name defines the block name
  65640. */
  65641. constructor(name: string);
  65642. /**
  65643. * Initialize the block and prepare the context for build
  65644. * @param state defines the state that will be used for the build
  65645. */
  65646. initialize(state: NodeMaterialBuildState): void;
  65647. /**
  65648. * Gets the current class name
  65649. * @returns the class name
  65650. */
  65651. getClassName(): string;
  65652. /**
  65653. * Gets the intensity input component
  65654. */
  65655. get intensity(): NodeMaterialConnectionPoint;
  65656. /**
  65657. * Gets the roughness input component
  65658. */
  65659. get roughness(): NodeMaterialConnectionPoint;
  65660. /**
  65661. * Gets the ior input component
  65662. */
  65663. get ior(): NodeMaterialConnectionPoint;
  65664. /**
  65665. * Gets the texture input component
  65666. */
  65667. get texture(): NodeMaterialConnectionPoint;
  65668. /**
  65669. * Gets the bump texture input component
  65670. */
  65671. get bumpTexture(): NodeMaterialConnectionPoint;
  65672. /**
  65673. * Gets the uv input component
  65674. */
  65675. get uv(): NodeMaterialConnectionPoint;
  65676. /**
  65677. * Gets the tint color input component
  65678. */
  65679. get tintColor(): NodeMaterialConnectionPoint;
  65680. /**
  65681. * Gets the tint "at distance" input component
  65682. */
  65683. get tintAtDistance(): NodeMaterialConnectionPoint;
  65684. /**
  65685. * Gets the tint thickness input component
  65686. */
  65687. get tintThickness(): NodeMaterialConnectionPoint;
  65688. /**
  65689. * Gets the world tangent input component
  65690. */
  65691. get worldTangent(): NodeMaterialConnectionPoint;
  65692. /**
  65693. * Gets the clear coat object output component
  65694. */
  65695. get clearcoat(): NodeMaterialConnectionPoint;
  65696. autoConfigure(material: NodeMaterial): void;
  65697. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65698. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65699. private _generateTBNSpace;
  65700. /**
  65701. * Gets the main code of the block (fragment side)
  65702. * @param state current state of the node material building
  65703. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65704. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65705. * @param worldPosVarName name of the variable holding the world position
  65706. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65707. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65708. * @param worldNormalVarName name of the variable holding the world normal
  65709. * @returns the shader code
  65710. */
  65711. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65712. protected _buildBlock(state: NodeMaterialBuildState): this;
  65713. }
  65714. }
  65715. declare module BABYLON {
  65716. /**
  65717. * Block used to implement the sub surface module of the PBR material
  65718. */
  65719. export class SubSurfaceBlock extends NodeMaterialBlock {
  65720. /**
  65721. * Create a new SubSurfaceBlock
  65722. * @param name defines the block name
  65723. */
  65724. constructor(name: string);
  65725. /**
  65726. * Stores the intensity of the different subsurface effects in the thickness texture.
  65727. * * the green channel is the translucency intensity.
  65728. * * the blue channel is the scattering intensity.
  65729. * * the alpha channel is the refraction intensity.
  65730. */
  65731. useMaskFromThicknessTexture: boolean;
  65732. /**
  65733. * Initialize the block and prepare the context for build
  65734. * @param state defines the state that will be used for the build
  65735. */
  65736. initialize(state: NodeMaterialBuildState): void;
  65737. /**
  65738. * Gets the current class name
  65739. * @returns the class name
  65740. */
  65741. getClassName(): string;
  65742. /**
  65743. * Gets the min thickness input component
  65744. */
  65745. get minThickness(): NodeMaterialConnectionPoint;
  65746. /**
  65747. * Gets the max thickness input component
  65748. */
  65749. get maxThickness(): NodeMaterialConnectionPoint;
  65750. /**
  65751. * Gets the thickness texture component
  65752. */
  65753. get thicknessTexture(): NodeMaterialConnectionPoint;
  65754. /**
  65755. * Gets the tint color input component
  65756. */
  65757. get tintColor(): NodeMaterialConnectionPoint;
  65758. /**
  65759. * Gets the translucency intensity input component
  65760. */
  65761. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65762. /**
  65763. * Gets the translucency diffusion distance input component
  65764. */
  65765. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65766. /**
  65767. * Gets the refraction object parameters
  65768. */
  65769. get refraction(): NodeMaterialConnectionPoint;
  65770. /**
  65771. * Gets the sub surface object output component
  65772. */
  65773. get subsurface(): NodeMaterialConnectionPoint;
  65774. autoConfigure(material: NodeMaterial): void;
  65775. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65776. /**
  65777. * Gets the main code of the block (fragment side)
  65778. * @param state current state of the node material building
  65779. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65780. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65781. * @param worldPosVarName name of the variable holding the world position
  65782. * @returns the shader code
  65783. */
  65784. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65785. protected _buildBlock(state: NodeMaterialBuildState): this;
  65786. }
  65787. }
  65788. declare module BABYLON {
  65789. /**
  65790. * Block used to implement the PBR metallic/roughness model
  65791. */
  65792. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65793. /**
  65794. * Gets or sets the light associated with this block
  65795. */
  65796. light: Nullable<Light>;
  65797. private _lightId;
  65798. private _scene;
  65799. private _environmentBRDFTexture;
  65800. private _environmentBrdfSamplerName;
  65801. private _vNormalWName;
  65802. private _invertNormalName;
  65803. /**
  65804. * Create a new ReflectionBlock
  65805. * @param name defines the block name
  65806. */
  65807. constructor(name: string);
  65808. /**
  65809. * Intensity of the direct lights e.g. the four lights available in your scene.
  65810. * This impacts both the direct diffuse and specular highlights.
  65811. */
  65812. directIntensity: number;
  65813. /**
  65814. * Intensity of the environment e.g. how much the environment will light the object
  65815. * either through harmonics for rough material or through the refelction for shiny ones.
  65816. */
  65817. environmentIntensity: number;
  65818. /**
  65819. * This is a special control allowing the reduction of the specular highlights coming from the
  65820. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65821. */
  65822. specularIntensity: number;
  65823. /**
  65824. * Defines the falloff type used in this material.
  65825. * It by default is Physical.
  65826. */
  65827. lightFalloff: number;
  65828. /**
  65829. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65830. */
  65831. useAlphaFromAlbedoTexture: boolean;
  65832. /**
  65833. * Specifies that alpha test should be used
  65834. */
  65835. useAlphaTest: boolean;
  65836. /**
  65837. * Defines the alpha limits in alpha test mode.
  65838. */
  65839. alphaTestCutoff: number;
  65840. /**
  65841. * Specifies that alpha blending should be used
  65842. */
  65843. useAlphaBlending: boolean;
  65844. /**
  65845. * Defines if the alpha value should be determined via the rgb values.
  65846. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65847. */
  65848. opacityRGB: boolean;
  65849. /**
  65850. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65851. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65852. */
  65853. useRadianceOverAlpha: boolean;
  65854. /**
  65855. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65856. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65857. */
  65858. useSpecularOverAlpha: boolean;
  65859. /**
  65860. * Enables specular anti aliasing in the PBR shader.
  65861. * It will both interacts on the Geometry for analytical and IBL lighting.
  65862. * It also prefilter the roughness map based on the bump values.
  65863. */
  65864. enableSpecularAntiAliasing: boolean;
  65865. /**
  65866. * Enables realtime filtering on the texture.
  65867. */
  65868. realTimeFiltering: boolean;
  65869. /**
  65870. * Quality switch for realtime filtering
  65871. */
  65872. realTimeFilteringQuality: number;
  65873. /**
  65874. * Defines if the material uses energy conservation.
  65875. */
  65876. useEnergyConservation: boolean;
  65877. /**
  65878. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65879. * too much the area relying on ambient texture to define their ambient occlusion.
  65880. */
  65881. useRadianceOcclusion: boolean;
  65882. /**
  65883. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65884. * makes the reflect vector face the model (under horizon).
  65885. */
  65886. useHorizonOcclusion: boolean;
  65887. /**
  65888. * If set to true, no lighting calculations will be applied.
  65889. */
  65890. unlit: boolean;
  65891. /**
  65892. * Force normal to face away from face.
  65893. */
  65894. forceNormalForward: boolean;
  65895. /**
  65896. * Defines the material debug mode.
  65897. * It helps seeing only some components of the material while troubleshooting.
  65898. */
  65899. debugMode: number;
  65900. /**
  65901. * Specify from where on screen the debug mode should start.
  65902. * The value goes from -1 (full screen) to 1 (not visible)
  65903. * It helps with side by side comparison against the final render
  65904. * This defaults to 0
  65905. */
  65906. debugLimit: number;
  65907. /**
  65908. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65909. * You can use the factor to better multiply the final value.
  65910. */
  65911. debugFactor: number;
  65912. /**
  65913. * Initialize the block and prepare the context for build
  65914. * @param state defines the state that will be used for the build
  65915. */
  65916. initialize(state: NodeMaterialBuildState): void;
  65917. /**
  65918. * Gets the current class name
  65919. * @returns the class name
  65920. */
  65921. getClassName(): string;
  65922. /**
  65923. * Gets the world position input component
  65924. */
  65925. get worldPosition(): NodeMaterialConnectionPoint;
  65926. /**
  65927. * Gets the world normal input component
  65928. */
  65929. get worldNormal(): NodeMaterialConnectionPoint;
  65930. /**
  65931. * Gets the perturbed normal input component
  65932. */
  65933. get perturbedNormal(): NodeMaterialConnectionPoint;
  65934. /**
  65935. * Gets the camera position input component
  65936. */
  65937. get cameraPosition(): NodeMaterialConnectionPoint;
  65938. /**
  65939. * Gets the base color input component
  65940. */
  65941. get baseColor(): NodeMaterialConnectionPoint;
  65942. /**
  65943. * Gets the opacity texture input component
  65944. */
  65945. get opacityTexture(): NodeMaterialConnectionPoint;
  65946. /**
  65947. * Gets the ambient color input component
  65948. */
  65949. get ambientColor(): NodeMaterialConnectionPoint;
  65950. /**
  65951. * Gets the reflectivity object parameters
  65952. */
  65953. get reflectivity(): NodeMaterialConnectionPoint;
  65954. /**
  65955. * Gets the ambient occlusion object parameters
  65956. */
  65957. get ambientOcc(): NodeMaterialConnectionPoint;
  65958. /**
  65959. * Gets the reflection object parameters
  65960. */
  65961. get reflection(): NodeMaterialConnectionPoint;
  65962. /**
  65963. * Gets the sheen object parameters
  65964. */
  65965. get sheen(): NodeMaterialConnectionPoint;
  65966. /**
  65967. * Gets the clear coat object parameters
  65968. */
  65969. get clearcoat(): NodeMaterialConnectionPoint;
  65970. /**
  65971. * Gets the sub surface object parameters
  65972. */
  65973. get subsurface(): NodeMaterialConnectionPoint;
  65974. /**
  65975. * Gets the anisotropy object parameters
  65976. */
  65977. get anisotropy(): NodeMaterialConnectionPoint;
  65978. /**
  65979. * Gets the view matrix parameter
  65980. */
  65981. get view(): NodeMaterialConnectionPoint;
  65982. /**
  65983. * Gets the ambient output component
  65984. */
  65985. get ambient(): NodeMaterialConnectionPoint;
  65986. /**
  65987. * Gets the diffuse output component
  65988. */
  65989. get diffuse(): NodeMaterialConnectionPoint;
  65990. /**
  65991. * Gets the specular output component
  65992. */
  65993. get specular(): NodeMaterialConnectionPoint;
  65994. /**
  65995. * Gets the sheen output component
  65996. */
  65997. get sheenDir(): NodeMaterialConnectionPoint;
  65998. /**
  65999. * Gets the clear coat output component
  66000. */
  66001. get clearcoatDir(): NodeMaterialConnectionPoint;
  66002. /**
  66003. * Gets the indirect diffuse output component
  66004. */
  66005. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66006. /**
  66007. * Gets the indirect specular output component
  66008. */
  66009. get specularIndirect(): NodeMaterialConnectionPoint;
  66010. /**
  66011. * Gets the indirect sheen output component
  66012. */
  66013. get sheenIndirect(): NodeMaterialConnectionPoint;
  66014. /**
  66015. * Gets the indirect clear coat output component
  66016. */
  66017. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66018. /**
  66019. * Gets the refraction output component
  66020. */
  66021. get refraction(): NodeMaterialConnectionPoint;
  66022. /**
  66023. * Gets the global lighting output component
  66024. */
  66025. get lighting(): NodeMaterialConnectionPoint;
  66026. /**
  66027. * Gets the shadow output component
  66028. */
  66029. get shadow(): NodeMaterialConnectionPoint;
  66030. /**
  66031. * Gets the alpha output component
  66032. */
  66033. get alpha(): NodeMaterialConnectionPoint;
  66034. autoConfigure(material: NodeMaterial): void;
  66035. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66036. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66037. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66038. private _injectVertexCode;
  66039. /**
  66040. * Gets the code corresponding to the albedo/opacity module
  66041. * @returns the shader code
  66042. */
  66043. getAlbedoOpacityCode(): string;
  66044. protected _buildBlock(state: NodeMaterialBuildState): this;
  66045. protected _dumpPropertiesCode(): string;
  66046. serialize(): any;
  66047. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66048. }
  66049. }
  66050. declare module BABYLON {
  66051. /**
  66052. * Block used to compute value of one parameter modulo another
  66053. */
  66054. export class ModBlock extends NodeMaterialBlock {
  66055. /**
  66056. * Creates a new ModBlock
  66057. * @param name defines the block name
  66058. */
  66059. constructor(name: string);
  66060. /**
  66061. * Gets the current class name
  66062. * @returns the class name
  66063. */
  66064. getClassName(): string;
  66065. /**
  66066. * Gets the left operand input component
  66067. */
  66068. get left(): NodeMaterialConnectionPoint;
  66069. /**
  66070. * Gets the right operand input component
  66071. */
  66072. get right(): NodeMaterialConnectionPoint;
  66073. /**
  66074. * Gets the output component
  66075. */
  66076. get output(): NodeMaterialConnectionPoint;
  66077. protected _buildBlock(state: NodeMaterialBuildState): this;
  66078. }
  66079. }
  66080. declare module BABYLON {
  66081. /**
  66082. * Configuration for Draco compression
  66083. */
  66084. export interface IDracoCompressionConfiguration {
  66085. /**
  66086. * Configuration for the decoder.
  66087. */
  66088. decoder: {
  66089. /**
  66090. * The url to the WebAssembly module.
  66091. */
  66092. wasmUrl?: string;
  66093. /**
  66094. * The url to the WebAssembly binary.
  66095. */
  66096. wasmBinaryUrl?: string;
  66097. /**
  66098. * The url to the fallback JavaScript module.
  66099. */
  66100. fallbackUrl?: string;
  66101. };
  66102. }
  66103. /**
  66104. * Draco compression (https://google.github.io/draco/)
  66105. *
  66106. * This class wraps the Draco module.
  66107. *
  66108. * **Encoder**
  66109. *
  66110. * The encoder is not currently implemented.
  66111. *
  66112. * **Decoder**
  66113. *
  66114. * 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.
  66115. *
  66116. * To update the configuration, use the following code:
  66117. * ```javascript
  66118. * DracoCompression.Configuration = {
  66119. * decoder: {
  66120. * wasmUrl: "<url to the WebAssembly library>",
  66121. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66122. * fallbackUrl: "<url to the fallback JavaScript library>",
  66123. * }
  66124. * };
  66125. * ```
  66126. *
  66127. * 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.
  66128. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66129. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66130. *
  66131. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66132. * ```javascript
  66133. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66134. * ```
  66135. *
  66136. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66137. */
  66138. export class DracoCompression implements IDisposable {
  66139. private _workerPoolPromise?;
  66140. private _decoderModulePromise?;
  66141. /**
  66142. * The configuration. Defaults to the following urls:
  66143. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66144. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66145. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66146. */
  66147. static Configuration: IDracoCompressionConfiguration;
  66148. /**
  66149. * Returns true if the decoder configuration is available.
  66150. */
  66151. static get DecoderAvailable(): boolean;
  66152. /**
  66153. * Default number of workers to create when creating the draco compression object.
  66154. */
  66155. static DefaultNumWorkers: number;
  66156. private static GetDefaultNumWorkers;
  66157. private static _Default;
  66158. /**
  66159. * Default instance for the draco compression object.
  66160. */
  66161. static get Default(): DracoCompression;
  66162. /**
  66163. * Constructor
  66164. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66165. */
  66166. constructor(numWorkers?: number);
  66167. /**
  66168. * Stop all async operations and release resources.
  66169. */
  66170. dispose(): void;
  66171. /**
  66172. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66173. * @returns a promise that resolves when ready
  66174. */
  66175. whenReadyAsync(): Promise<void>;
  66176. /**
  66177. * Decode Draco compressed mesh data to vertex data.
  66178. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66179. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66180. * @returns A promise that resolves with the decoded vertex data
  66181. */
  66182. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66183. [kind: string]: number;
  66184. }): Promise<VertexData>;
  66185. }
  66186. }
  66187. declare module BABYLON {
  66188. /**
  66189. * Class for building Constructive Solid Geometry
  66190. */
  66191. export class CSG {
  66192. private polygons;
  66193. /**
  66194. * The world matrix
  66195. */
  66196. matrix: Matrix;
  66197. /**
  66198. * Stores the position
  66199. */
  66200. position: Vector3;
  66201. /**
  66202. * Stores the rotation
  66203. */
  66204. rotation: Vector3;
  66205. /**
  66206. * Stores the rotation quaternion
  66207. */
  66208. rotationQuaternion: Nullable<Quaternion>;
  66209. /**
  66210. * Stores the scaling vector
  66211. */
  66212. scaling: Vector3;
  66213. /**
  66214. * Convert the Mesh to CSG
  66215. * @param mesh The Mesh to convert to CSG
  66216. * @returns A new CSG from the Mesh
  66217. */
  66218. static FromMesh(mesh: Mesh): CSG;
  66219. /**
  66220. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66221. * @param polygons Polygons used to construct a CSG solid
  66222. */
  66223. private static FromPolygons;
  66224. /**
  66225. * Clones, or makes a deep copy, of the CSG
  66226. * @returns A new CSG
  66227. */
  66228. clone(): CSG;
  66229. /**
  66230. * Unions this CSG with another CSG
  66231. * @param csg The CSG to union against this CSG
  66232. * @returns The unioned CSG
  66233. */
  66234. union(csg: CSG): CSG;
  66235. /**
  66236. * Unions this CSG with another CSG in place
  66237. * @param csg The CSG to union against this CSG
  66238. */
  66239. unionInPlace(csg: CSG): void;
  66240. /**
  66241. * Subtracts this CSG with another CSG
  66242. * @param csg The CSG to subtract against this CSG
  66243. * @returns A new CSG
  66244. */
  66245. subtract(csg: CSG): CSG;
  66246. /**
  66247. * Subtracts this CSG with another CSG in place
  66248. * @param csg The CSG to subtact against this CSG
  66249. */
  66250. subtractInPlace(csg: CSG): void;
  66251. /**
  66252. * Intersect this CSG with another CSG
  66253. * @param csg The CSG to intersect against this CSG
  66254. * @returns A new CSG
  66255. */
  66256. intersect(csg: CSG): CSG;
  66257. /**
  66258. * Intersects this CSG with another CSG in place
  66259. * @param csg The CSG to intersect against this CSG
  66260. */
  66261. intersectInPlace(csg: CSG): void;
  66262. /**
  66263. * Return a new CSG solid with solid and empty space switched. This solid is
  66264. * not modified.
  66265. * @returns A new CSG solid with solid and empty space switched
  66266. */
  66267. inverse(): CSG;
  66268. /**
  66269. * Inverses the CSG in place
  66270. */
  66271. inverseInPlace(): void;
  66272. /**
  66273. * This is used to keep meshes transformations so they can be restored
  66274. * when we build back a Babylon Mesh
  66275. * NB : All CSG operations are performed in world coordinates
  66276. * @param csg The CSG to copy the transform attributes from
  66277. * @returns This CSG
  66278. */
  66279. copyTransformAttributes(csg: CSG): CSG;
  66280. /**
  66281. * Build Raw mesh from CSG
  66282. * Coordinates here are in world space
  66283. * @param name The name of the mesh geometry
  66284. * @param scene The Scene
  66285. * @param keepSubMeshes Specifies if the submeshes should be kept
  66286. * @returns A new Mesh
  66287. */
  66288. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66289. /**
  66290. * Build Mesh from CSG taking material and transforms into account
  66291. * @param name The name of the Mesh
  66292. * @param material The material of the Mesh
  66293. * @param scene The Scene
  66294. * @param keepSubMeshes Specifies if submeshes should be kept
  66295. * @returns The new Mesh
  66296. */
  66297. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66298. }
  66299. }
  66300. declare module BABYLON {
  66301. /**
  66302. * Class used to create a trail following a mesh
  66303. */
  66304. export class TrailMesh extends Mesh {
  66305. private _generator;
  66306. private _autoStart;
  66307. private _running;
  66308. private _diameter;
  66309. private _length;
  66310. private _sectionPolygonPointsCount;
  66311. private _sectionVectors;
  66312. private _sectionNormalVectors;
  66313. private _beforeRenderObserver;
  66314. /**
  66315. * @constructor
  66316. * @param name The value used by scene.getMeshByName() to do a lookup.
  66317. * @param generator The mesh or transform node to generate a trail.
  66318. * @param scene The scene to add this mesh to.
  66319. * @param diameter Diameter of trailing mesh. Default is 1.
  66320. * @param length Length of trailing mesh. Default is 60.
  66321. * @param autoStart Automatically start trailing mesh. Default true.
  66322. */
  66323. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66324. /**
  66325. * "TrailMesh"
  66326. * @returns "TrailMesh"
  66327. */
  66328. getClassName(): string;
  66329. private _createMesh;
  66330. /**
  66331. * Start trailing mesh.
  66332. */
  66333. start(): void;
  66334. /**
  66335. * Stop trailing mesh.
  66336. */
  66337. stop(): void;
  66338. /**
  66339. * Update trailing mesh geometry.
  66340. */
  66341. update(): void;
  66342. /**
  66343. * Returns a new TrailMesh object.
  66344. * @param name is a string, the name given to the new mesh
  66345. * @param newGenerator use new generator object for cloned trail mesh
  66346. * @returns a new mesh
  66347. */
  66348. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66349. /**
  66350. * Serializes this trail mesh
  66351. * @param serializationObject object to write serialization to
  66352. */
  66353. serialize(serializationObject: any): void;
  66354. /**
  66355. * Parses a serialized trail mesh
  66356. * @param parsedMesh the serialized mesh
  66357. * @param scene the scene to create the trail mesh in
  66358. * @returns the created trail mesh
  66359. */
  66360. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66361. }
  66362. }
  66363. declare module BABYLON {
  66364. /**
  66365. * Class containing static functions to help procedurally build meshes
  66366. */
  66367. export class TiledBoxBuilder {
  66368. /**
  66369. * Creates a box mesh
  66370. * 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)
  66371. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66373. * * 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
  66374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66375. * @param name defines the name of the mesh
  66376. * @param options defines the options used to create the mesh
  66377. * @param scene defines the hosting scene
  66378. * @returns the box mesh
  66379. */
  66380. static CreateTiledBox(name: string, options: {
  66381. pattern?: number;
  66382. width?: number;
  66383. height?: number;
  66384. depth?: number;
  66385. tileSize?: number;
  66386. tileWidth?: number;
  66387. tileHeight?: number;
  66388. alignHorizontal?: number;
  66389. alignVertical?: number;
  66390. faceUV?: Vector4[];
  66391. faceColors?: Color4[];
  66392. sideOrientation?: number;
  66393. updatable?: boolean;
  66394. }, scene?: Nullable<Scene>): Mesh;
  66395. }
  66396. }
  66397. declare module BABYLON {
  66398. /**
  66399. * Class containing static functions to help procedurally build meshes
  66400. */
  66401. export class TorusKnotBuilder {
  66402. /**
  66403. * Creates a torus knot mesh
  66404. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66405. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66406. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66407. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66409. * * 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
  66410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66411. * @param name defines the name of the mesh
  66412. * @param options defines the options used to create the mesh
  66413. * @param scene defines the hosting scene
  66414. * @returns the torus knot mesh
  66415. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66416. */
  66417. static CreateTorusKnot(name: string, options: {
  66418. radius?: number;
  66419. tube?: number;
  66420. radialSegments?: number;
  66421. tubularSegments?: number;
  66422. p?: number;
  66423. q?: number;
  66424. updatable?: boolean;
  66425. sideOrientation?: number;
  66426. frontUVs?: Vector4;
  66427. backUVs?: Vector4;
  66428. }, scene: any): Mesh;
  66429. }
  66430. }
  66431. declare module BABYLON {
  66432. /**
  66433. * Polygon
  66434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66435. */
  66436. export class Polygon {
  66437. /**
  66438. * Creates a rectangle
  66439. * @param xmin bottom X coord
  66440. * @param ymin bottom Y coord
  66441. * @param xmax top X coord
  66442. * @param ymax top Y coord
  66443. * @returns points that make the resulting rectation
  66444. */
  66445. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66446. /**
  66447. * Creates a circle
  66448. * @param radius radius of circle
  66449. * @param cx scale in x
  66450. * @param cy scale in y
  66451. * @param numberOfSides number of sides that make up the circle
  66452. * @returns points that make the resulting circle
  66453. */
  66454. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66455. /**
  66456. * Creates a polygon from input string
  66457. * @param input Input polygon data
  66458. * @returns the parsed points
  66459. */
  66460. static Parse(input: string): Vector2[];
  66461. /**
  66462. * Starts building a polygon from x and y coordinates
  66463. * @param x x coordinate
  66464. * @param y y coordinate
  66465. * @returns the started path2
  66466. */
  66467. static StartingAt(x: number, y: number): Path2;
  66468. }
  66469. /**
  66470. * Builds a polygon
  66471. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66472. */
  66473. export class PolygonMeshBuilder {
  66474. private _points;
  66475. private _outlinepoints;
  66476. private _holes;
  66477. private _name;
  66478. private _scene;
  66479. private _epoints;
  66480. private _eholes;
  66481. private _addToepoint;
  66482. /**
  66483. * Babylon reference to the earcut plugin.
  66484. */
  66485. bjsEarcut: any;
  66486. /**
  66487. * Creates a PolygonMeshBuilder
  66488. * @param name name of the builder
  66489. * @param contours Path of the polygon
  66490. * @param scene scene to add to when creating the mesh
  66491. * @param earcutInjection can be used to inject your own earcut reference
  66492. */
  66493. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66494. /**
  66495. * Adds a whole within the polygon
  66496. * @param hole Array of points defining the hole
  66497. * @returns this
  66498. */
  66499. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66500. /**
  66501. * Creates the polygon
  66502. * @param updatable If the mesh should be updatable
  66503. * @param depth The depth of the mesh created
  66504. * @returns the created mesh
  66505. */
  66506. build(updatable?: boolean, depth?: number): Mesh;
  66507. /**
  66508. * Creates the polygon
  66509. * @param depth The depth of the mesh created
  66510. * @returns the created VertexData
  66511. */
  66512. buildVertexData(depth?: number): VertexData;
  66513. /**
  66514. * Adds a side to the polygon
  66515. * @param positions points that make the polygon
  66516. * @param normals normals of the polygon
  66517. * @param uvs uvs of the polygon
  66518. * @param indices indices of the polygon
  66519. * @param bounds bounds of the polygon
  66520. * @param points points of the polygon
  66521. * @param depth depth of the polygon
  66522. * @param flip flip of the polygon
  66523. */
  66524. private addSide;
  66525. }
  66526. }
  66527. declare module BABYLON {
  66528. /**
  66529. * Class containing static functions to help procedurally build meshes
  66530. */
  66531. export class PolygonBuilder {
  66532. /**
  66533. * Creates a polygon mesh
  66534. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66535. * * 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
  66536. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66538. * * 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)
  66539. * * Remember you can only change the shape positions, not their number when updating a polygon
  66540. * @param name defines the name of the mesh
  66541. * @param options defines the options used to create the mesh
  66542. * @param scene defines the hosting scene
  66543. * @param earcutInjection can be used to inject your own earcut reference
  66544. * @returns the polygon mesh
  66545. */
  66546. static CreatePolygon(name: string, options: {
  66547. shape: Vector3[];
  66548. holes?: Vector3[][];
  66549. depth?: number;
  66550. faceUV?: Vector4[];
  66551. faceColors?: Color4[];
  66552. updatable?: boolean;
  66553. sideOrientation?: number;
  66554. frontUVs?: Vector4;
  66555. backUVs?: Vector4;
  66556. wrap?: boolean;
  66557. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66558. /**
  66559. * Creates an extruded polygon mesh, with depth in the Y direction.
  66560. * * 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)
  66561. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66562. * @param name defines the name of the mesh
  66563. * @param options defines the options used to create the mesh
  66564. * @param scene defines the hosting scene
  66565. * @param earcutInjection can be used to inject your own earcut reference
  66566. * @returns the polygon mesh
  66567. */
  66568. static ExtrudePolygon(name: string, options: {
  66569. shape: Vector3[];
  66570. holes?: Vector3[][];
  66571. depth?: number;
  66572. faceUV?: Vector4[];
  66573. faceColors?: Color4[];
  66574. updatable?: boolean;
  66575. sideOrientation?: number;
  66576. frontUVs?: Vector4;
  66577. backUVs?: Vector4;
  66578. wrap?: boolean;
  66579. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66580. }
  66581. }
  66582. declare module BABYLON {
  66583. /**
  66584. * Class containing static functions to help procedurally build meshes
  66585. */
  66586. export class LatheBuilder {
  66587. /**
  66588. * Creates lathe mesh.
  66589. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66590. * * 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
  66591. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66592. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66593. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66594. * * 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
  66595. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66596. * * 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
  66597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66599. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66601. * @param name defines the name of the mesh
  66602. * @param options defines the options used to create the mesh
  66603. * @param scene defines the hosting scene
  66604. * @returns the lathe mesh
  66605. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66606. */
  66607. static CreateLathe(name: string, options: {
  66608. shape: Vector3[];
  66609. radius?: number;
  66610. tessellation?: number;
  66611. clip?: number;
  66612. arc?: number;
  66613. closed?: boolean;
  66614. updatable?: boolean;
  66615. sideOrientation?: number;
  66616. frontUVs?: Vector4;
  66617. backUVs?: Vector4;
  66618. cap?: number;
  66619. invertUV?: boolean;
  66620. }, scene?: Nullable<Scene>): Mesh;
  66621. }
  66622. }
  66623. declare module BABYLON {
  66624. /**
  66625. * Class containing static functions to help procedurally build meshes
  66626. */
  66627. export class TiledPlaneBuilder {
  66628. /**
  66629. * Creates a tiled plane mesh
  66630. * * The parameter `pattern` will, depending on value, do nothing or
  66631. * * * flip (reflect about central vertical) alternate tiles across and up
  66632. * * * flip every tile on alternate rows
  66633. * * * rotate (180 degs) alternate tiles across and up
  66634. * * * rotate every tile on alternate rows
  66635. * * * flip and rotate alternate tiles across and up
  66636. * * * flip and rotate every tile on alternate rows
  66637. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66638. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66639. * * 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
  66640. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66641. * * 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)
  66642. * * 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)
  66643. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66644. * @param name defines the name of the mesh
  66645. * @param options defines the options used to create the mesh
  66646. * @param scene defines the hosting scene
  66647. * @returns the box mesh
  66648. */
  66649. static CreateTiledPlane(name: string, options: {
  66650. pattern?: number;
  66651. tileSize?: number;
  66652. tileWidth?: number;
  66653. tileHeight?: number;
  66654. size?: number;
  66655. width?: number;
  66656. height?: number;
  66657. alignHorizontal?: number;
  66658. alignVertical?: number;
  66659. sideOrientation?: number;
  66660. frontUVs?: Vector4;
  66661. backUVs?: Vector4;
  66662. updatable?: boolean;
  66663. }, scene?: Nullable<Scene>): Mesh;
  66664. }
  66665. }
  66666. declare module BABYLON {
  66667. /**
  66668. * Class containing static functions to help procedurally build meshes
  66669. */
  66670. export class TubeBuilder {
  66671. /**
  66672. * Creates a tube mesh.
  66673. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66674. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66675. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66676. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66677. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66678. * * 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)
  66679. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66680. * * 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
  66681. * * 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
  66682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66683. * * 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
  66684. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66686. * @param name defines the name of the mesh
  66687. * @param options defines the options used to create the mesh
  66688. * @param scene defines the hosting scene
  66689. * @returns the tube mesh
  66690. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66691. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66692. */
  66693. static CreateTube(name: string, options: {
  66694. path: Vector3[];
  66695. radius?: number;
  66696. tessellation?: number;
  66697. radiusFunction?: {
  66698. (i: number, distance: number): number;
  66699. };
  66700. cap?: number;
  66701. arc?: number;
  66702. updatable?: boolean;
  66703. sideOrientation?: number;
  66704. frontUVs?: Vector4;
  66705. backUVs?: Vector4;
  66706. instance?: Mesh;
  66707. invertUV?: boolean;
  66708. }, scene?: Nullable<Scene>): Mesh;
  66709. }
  66710. }
  66711. declare module BABYLON {
  66712. /**
  66713. * Class containing static functions to help procedurally build meshes
  66714. */
  66715. export class IcoSphereBuilder {
  66716. /**
  66717. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66718. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66719. * * 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`)
  66720. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66721. * * 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
  66722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66723. * * 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
  66724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66725. * @param name defines the name of the mesh
  66726. * @param options defines the options used to create the mesh
  66727. * @param scene defines the hosting scene
  66728. * @returns the icosahedron mesh
  66729. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66730. */
  66731. static CreateIcoSphere(name: string, options: {
  66732. radius?: number;
  66733. radiusX?: number;
  66734. radiusY?: number;
  66735. radiusZ?: number;
  66736. flat?: boolean;
  66737. subdivisions?: number;
  66738. sideOrientation?: number;
  66739. frontUVs?: Vector4;
  66740. backUVs?: Vector4;
  66741. updatable?: boolean;
  66742. }, scene?: Nullable<Scene>): Mesh;
  66743. }
  66744. }
  66745. declare module BABYLON {
  66746. /**
  66747. * Class containing static functions to help procedurally build meshes
  66748. */
  66749. export class DecalBuilder {
  66750. /**
  66751. * Creates a decal mesh.
  66752. * 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
  66753. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66754. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66755. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66756. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66757. * @param name defines the name of the mesh
  66758. * @param sourceMesh defines the mesh where the decal must be applied
  66759. * @param options defines the options used to create the mesh
  66760. * @param scene defines the hosting scene
  66761. * @returns the decal mesh
  66762. * @see https://doc.babylonjs.com/how_to/decals
  66763. */
  66764. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66765. position?: Vector3;
  66766. normal?: Vector3;
  66767. size?: Vector3;
  66768. angle?: number;
  66769. }): Mesh;
  66770. }
  66771. }
  66772. declare module BABYLON {
  66773. /**
  66774. * Class containing static functions to help procedurally build meshes
  66775. */
  66776. export class MeshBuilder {
  66777. /**
  66778. * Creates a box mesh
  66779. * * The parameter `size` sets the size (float) of each box side (default 1)
  66780. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66781. * * 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)
  66782. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66784. * * 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
  66785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66786. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66787. * @param name defines the name of the mesh
  66788. * @param options defines the options used to create the mesh
  66789. * @param scene defines the hosting scene
  66790. * @returns the box mesh
  66791. */
  66792. static CreateBox(name: string, options: {
  66793. size?: number;
  66794. width?: number;
  66795. height?: number;
  66796. depth?: number;
  66797. faceUV?: Vector4[];
  66798. faceColors?: Color4[];
  66799. sideOrientation?: number;
  66800. frontUVs?: Vector4;
  66801. backUVs?: Vector4;
  66802. wrap?: boolean;
  66803. topBaseAt?: number;
  66804. bottomBaseAt?: number;
  66805. updatable?: boolean;
  66806. }, scene?: Nullable<Scene>): Mesh;
  66807. /**
  66808. * Creates a tiled box mesh
  66809. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66811. * @param name defines the name of the mesh
  66812. * @param options defines the options used to create the mesh
  66813. * @param scene defines the hosting scene
  66814. * @returns the tiled box mesh
  66815. */
  66816. static CreateTiledBox(name: string, options: {
  66817. pattern?: number;
  66818. size?: number;
  66819. width?: number;
  66820. height?: number;
  66821. depth: number;
  66822. tileSize?: number;
  66823. tileWidth?: number;
  66824. tileHeight?: number;
  66825. faceUV?: Vector4[];
  66826. faceColors?: Color4[];
  66827. alignHorizontal?: number;
  66828. alignVertical?: number;
  66829. sideOrientation?: number;
  66830. updatable?: boolean;
  66831. }, scene?: Nullable<Scene>): Mesh;
  66832. /**
  66833. * Creates a sphere mesh
  66834. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66835. * * 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`)
  66836. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66837. * * 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
  66838. * * 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)
  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. * @param name defines the name of the mesh
  66843. * @param options defines the options used to create the mesh
  66844. * @param scene defines the hosting scene
  66845. * @returns the sphere mesh
  66846. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66847. */
  66848. static CreateSphere(name: string, options: {
  66849. segments?: number;
  66850. diameter?: number;
  66851. diameterX?: number;
  66852. diameterY?: number;
  66853. diameterZ?: number;
  66854. arc?: number;
  66855. slice?: number;
  66856. sideOrientation?: number;
  66857. frontUVs?: Vector4;
  66858. backUVs?: Vector4;
  66859. updatable?: boolean;
  66860. }, scene?: Nullable<Scene>): Mesh;
  66861. /**
  66862. * Creates a plane polygonal mesh. By default, this is a disc
  66863. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66864. * * 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
  66865. * * 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
  66866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66867. * * 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
  66868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66869. * @param name defines the name of the mesh
  66870. * @param options defines the options used to create the mesh
  66871. * @param scene defines the hosting scene
  66872. * @returns the plane polygonal mesh
  66873. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66874. */
  66875. static CreateDisc(name: string, options: {
  66876. radius?: number;
  66877. tessellation?: number;
  66878. arc?: number;
  66879. updatable?: boolean;
  66880. sideOrientation?: number;
  66881. frontUVs?: Vector4;
  66882. backUVs?: Vector4;
  66883. }, scene?: Nullable<Scene>): Mesh;
  66884. /**
  66885. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66886. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66887. * * 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`)
  66888. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66889. * * 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
  66890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66891. * * 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
  66892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66893. * @param name defines the name of the mesh
  66894. * @param options defines the options used to create the mesh
  66895. * @param scene defines the hosting scene
  66896. * @returns the icosahedron mesh
  66897. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66898. */
  66899. static CreateIcoSphere(name: string, options: {
  66900. radius?: number;
  66901. radiusX?: number;
  66902. radiusY?: number;
  66903. radiusZ?: number;
  66904. flat?: boolean;
  66905. subdivisions?: number;
  66906. sideOrientation?: number;
  66907. frontUVs?: Vector4;
  66908. backUVs?: Vector4;
  66909. updatable?: boolean;
  66910. }, scene?: Nullable<Scene>): Mesh;
  66911. /**
  66912. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66913. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66914. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66915. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66916. * * 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
  66917. * * 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
  66918. * * 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
  66919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66920. * * 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
  66921. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66922. * * 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
  66923. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66924. * * 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
  66925. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66927. * @param name defines the name of the mesh
  66928. * @param options defines the options used to create the mesh
  66929. * @param scene defines the hosting scene
  66930. * @returns the ribbon mesh
  66931. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66932. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66933. */
  66934. static CreateRibbon(name: string, options: {
  66935. pathArray: Vector3[][];
  66936. closeArray?: boolean;
  66937. closePath?: boolean;
  66938. offset?: number;
  66939. updatable?: boolean;
  66940. sideOrientation?: number;
  66941. frontUVs?: Vector4;
  66942. backUVs?: Vector4;
  66943. instance?: Mesh;
  66944. invertUV?: boolean;
  66945. uvs?: Vector2[];
  66946. colors?: Color4[];
  66947. }, scene?: Nullable<Scene>): Mesh;
  66948. /**
  66949. * Creates a cylinder or a cone mesh
  66950. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66951. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66952. * * 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.
  66953. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66954. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66955. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66956. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66957. * * 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).
  66958. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66959. * * 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).
  66960. * * 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
  66961. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66962. * * 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
  66963. * * 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.
  66964. * * If `enclose` is false, a ring surface is one element.
  66965. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66966. * * 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
  66967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66968. * * 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
  66969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66970. * @param name defines the name of the mesh
  66971. * @param options defines the options used to create the mesh
  66972. * @param scene defines the hosting scene
  66973. * @returns the cylinder mesh
  66974. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66975. */
  66976. static CreateCylinder(name: string, options: {
  66977. height?: number;
  66978. diameterTop?: number;
  66979. diameterBottom?: number;
  66980. diameter?: number;
  66981. tessellation?: number;
  66982. subdivisions?: number;
  66983. arc?: number;
  66984. faceColors?: Color4[];
  66985. faceUV?: Vector4[];
  66986. updatable?: boolean;
  66987. hasRings?: boolean;
  66988. enclose?: boolean;
  66989. cap?: number;
  66990. sideOrientation?: number;
  66991. frontUVs?: Vector4;
  66992. backUVs?: Vector4;
  66993. }, scene?: Nullable<Scene>): Mesh;
  66994. /**
  66995. * Creates a torus mesh
  66996. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66997. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66998. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67000. * * 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
  67001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67002. * @param name defines the name of the mesh
  67003. * @param options defines the options used to create the mesh
  67004. * @param scene defines the hosting scene
  67005. * @returns the torus mesh
  67006. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67007. */
  67008. static CreateTorus(name: string, options: {
  67009. diameter?: number;
  67010. thickness?: number;
  67011. tessellation?: number;
  67012. updatable?: boolean;
  67013. sideOrientation?: number;
  67014. frontUVs?: Vector4;
  67015. backUVs?: Vector4;
  67016. }, scene?: Nullable<Scene>): Mesh;
  67017. /**
  67018. * Creates a torus knot mesh
  67019. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67020. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67021. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67022. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  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 torus knot mesh
  67030. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67031. */
  67032. static CreateTorusKnot(name: string, options: {
  67033. radius?: number;
  67034. tube?: number;
  67035. radialSegments?: number;
  67036. tubularSegments?: number;
  67037. p?: number;
  67038. q?: number;
  67039. updatable?: boolean;
  67040. sideOrientation?: number;
  67041. frontUVs?: Vector4;
  67042. backUVs?: Vector4;
  67043. }, scene?: Nullable<Scene>): Mesh;
  67044. /**
  67045. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67046. * * 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
  67047. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67048. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67049. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67050. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67051. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67052. * * 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
  67053. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67055. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67056. * @param name defines the name of the new line system
  67057. * @param options defines the options used to create the line system
  67058. * @param scene defines the hosting scene
  67059. * @returns a new line system mesh
  67060. */
  67061. static CreateLineSystem(name: string, options: {
  67062. lines: Vector3[][];
  67063. updatable?: boolean;
  67064. instance?: Nullable<LinesMesh>;
  67065. colors?: Nullable<Color4[][]>;
  67066. useVertexAlpha?: boolean;
  67067. }, scene: Nullable<Scene>): LinesMesh;
  67068. /**
  67069. * Creates a line mesh
  67070. * 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
  67071. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67072. * * The parameter `points` is an array successive Vector3
  67073. * * 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
  67074. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67075. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67076. * * When updating an instance, remember that only point positions can change, not the number of points
  67077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67078. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67079. * @param name defines the name of the new line system
  67080. * @param options defines the options used to create the line system
  67081. * @param scene defines the hosting scene
  67082. * @returns a new line mesh
  67083. */
  67084. static CreateLines(name: string, options: {
  67085. points: Vector3[];
  67086. updatable?: boolean;
  67087. instance?: Nullable<LinesMesh>;
  67088. colors?: Color4[];
  67089. useVertexAlpha?: boolean;
  67090. }, scene?: Nullable<Scene>): LinesMesh;
  67091. /**
  67092. * Creates a dashed line mesh
  67093. * * 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
  67094. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67095. * * The parameter `points` is an array successive Vector3
  67096. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67097. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67098. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67099. * * 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
  67100. * * When updating an instance, remember that only point positions can change, not the number of points
  67101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67102. * @param name defines the name of the mesh
  67103. * @param options defines the options used to create the mesh
  67104. * @param scene defines the hosting scene
  67105. * @returns the dashed line mesh
  67106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67107. */
  67108. static CreateDashedLines(name: string, options: {
  67109. points: Vector3[];
  67110. dashSize?: number;
  67111. gapSize?: number;
  67112. dashNb?: number;
  67113. updatable?: boolean;
  67114. instance?: LinesMesh;
  67115. }, scene?: Nullable<Scene>): LinesMesh;
  67116. /**
  67117. * 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.
  67118. * * 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.
  67119. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67120. * * 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.
  67121. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67122. * * 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
  67123. * * 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
  67124. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67126. * * 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
  67127. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67129. * @param name defines the name of the mesh
  67130. * @param options defines the options used to create the mesh
  67131. * @param scene defines the hosting scene
  67132. * @returns the extruded shape mesh
  67133. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67134. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67135. */
  67136. static ExtrudeShape(name: string, options: {
  67137. shape: Vector3[];
  67138. path: Vector3[];
  67139. scale?: number;
  67140. rotation?: number;
  67141. cap?: number;
  67142. updatable?: boolean;
  67143. sideOrientation?: number;
  67144. frontUVs?: Vector4;
  67145. backUVs?: Vector4;
  67146. instance?: Mesh;
  67147. invertUV?: boolean;
  67148. }, scene?: Nullable<Scene>): Mesh;
  67149. /**
  67150. * Creates an custom extruded shape mesh.
  67151. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67152. * * 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.
  67153. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67154. * * 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
  67155. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67156. * * 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
  67157. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67158. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67159. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67160. * * 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
  67161. * * 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
  67162. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67164. * * 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
  67165. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67167. * @param name defines the name of the mesh
  67168. * @param options defines the options used to create the mesh
  67169. * @param scene defines the hosting scene
  67170. * @returns the custom extruded shape mesh
  67171. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67172. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67173. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67174. */
  67175. static ExtrudeShapeCustom(name: string, options: {
  67176. shape: Vector3[];
  67177. path: Vector3[];
  67178. scaleFunction?: any;
  67179. rotationFunction?: any;
  67180. ribbonCloseArray?: boolean;
  67181. ribbonClosePath?: boolean;
  67182. cap?: number;
  67183. updatable?: boolean;
  67184. sideOrientation?: number;
  67185. frontUVs?: Vector4;
  67186. backUVs?: Vector4;
  67187. instance?: Mesh;
  67188. invertUV?: boolean;
  67189. }, scene?: Nullable<Scene>): Mesh;
  67190. /**
  67191. * Creates lathe mesh.
  67192. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67193. * * 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
  67194. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67195. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67196. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67197. * * 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
  67198. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67199. * * 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
  67200. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67201. * * 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
  67202. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67204. * @param name defines the name of the mesh
  67205. * @param options defines the options used to create the mesh
  67206. * @param scene defines the hosting scene
  67207. * @returns the lathe mesh
  67208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67209. */
  67210. static CreateLathe(name: string, options: {
  67211. shape: Vector3[];
  67212. radius?: number;
  67213. tessellation?: number;
  67214. clip?: number;
  67215. arc?: number;
  67216. closed?: boolean;
  67217. updatable?: boolean;
  67218. sideOrientation?: number;
  67219. frontUVs?: Vector4;
  67220. backUVs?: Vector4;
  67221. cap?: number;
  67222. invertUV?: boolean;
  67223. }, scene?: Nullable<Scene>): Mesh;
  67224. /**
  67225. * Creates a tiled plane mesh
  67226. * * You can set a limited pattern arrangement with the tiles
  67227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67228. * * 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
  67229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67230. * @param name defines the name of the mesh
  67231. * @param options defines the options used to create the mesh
  67232. * @param scene defines the hosting scene
  67233. * @returns the plane mesh
  67234. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67235. */
  67236. static CreateTiledPlane(name: string, options: {
  67237. pattern?: number;
  67238. tileSize?: number;
  67239. tileWidth?: number;
  67240. tileHeight?: number;
  67241. size?: number;
  67242. width?: number;
  67243. height?: number;
  67244. alignHorizontal?: number;
  67245. alignVertical?: number;
  67246. sideOrientation?: number;
  67247. frontUVs?: Vector4;
  67248. backUVs?: Vector4;
  67249. updatable?: boolean;
  67250. }, scene?: Nullable<Scene>): Mesh;
  67251. /**
  67252. * Creates a plane mesh
  67253. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67254. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67255. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67259. * @param name defines the name of the mesh
  67260. * @param options defines the options used to create the mesh
  67261. * @param scene defines the hosting scene
  67262. * @returns the plane mesh
  67263. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67264. */
  67265. static CreatePlane(name: string, options: {
  67266. size?: number;
  67267. width?: number;
  67268. height?: number;
  67269. sideOrientation?: number;
  67270. frontUVs?: Vector4;
  67271. backUVs?: Vector4;
  67272. updatable?: boolean;
  67273. sourcePlane?: Plane;
  67274. }, scene?: Nullable<Scene>): Mesh;
  67275. /**
  67276. * Creates a ground mesh
  67277. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67278. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67280. * @param name defines the name of the mesh
  67281. * @param options defines the options used to create the mesh
  67282. * @param scene defines the hosting scene
  67283. * @returns the ground mesh
  67284. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67285. */
  67286. static CreateGround(name: string, options: {
  67287. width?: number;
  67288. height?: number;
  67289. subdivisions?: number;
  67290. subdivisionsX?: number;
  67291. subdivisionsY?: number;
  67292. updatable?: boolean;
  67293. }, scene?: Nullable<Scene>): Mesh;
  67294. /**
  67295. * Creates a tiled ground mesh
  67296. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67297. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67298. * * 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
  67299. * * 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
  67300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67301. * @param name defines the name of the mesh
  67302. * @param options defines the options used to create the mesh
  67303. * @param scene defines the hosting scene
  67304. * @returns the tiled ground mesh
  67305. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67306. */
  67307. static CreateTiledGround(name: string, options: {
  67308. xmin: number;
  67309. zmin: number;
  67310. xmax: number;
  67311. zmax: number;
  67312. subdivisions?: {
  67313. w: number;
  67314. h: number;
  67315. };
  67316. precision?: {
  67317. w: number;
  67318. h: number;
  67319. };
  67320. updatable?: boolean;
  67321. }, scene?: Nullable<Scene>): Mesh;
  67322. /**
  67323. * Creates a ground mesh from a height map
  67324. * * The parameter `url` sets the URL of the height map image resource.
  67325. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67326. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67327. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67328. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67329. * * 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.
  67330. * * 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).
  67331. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67333. * @param name defines the name of the mesh
  67334. * @param url defines the url to the height map
  67335. * @param options defines the options used to create the mesh
  67336. * @param scene defines the hosting scene
  67337. * @returns the ground mesh
  67338. * @see https://doc.babylonjs.com/babylon101/height_map
  67339. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67340. */
  67341. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67342. width?: number;
  67343. height?: number;
  67344. subdivisions?: number;
  67345. minHeight?: number;
  67346. maxHeight?: number;
  67347. colorFilter?: Color3;
  67348. alphaFilter?: number;
  67349. updatable?: boolean;
  67350. onReady?: (mesh: GroundMesh) => void;
  67351. }, scene?: Nullable<Scene>): GroundMesh;
  67352. /**
  67353. * Creates a polygon mesh
  67354. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67355. * * 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
  67356. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67358. * * 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)
  67359. * * Remember you can only change the shape positions, not their number when updating a polygon
  67360. * @param name defines the name of the mesh
  67361. * @param options defines the options used to create the mesh
  67362. * @param scene defines the hosting scene
  67363. * @param earcutInjection can be used to inject your own earcut reference
  67364. * @returns the polygon mesh
  67365. */
  67366. static CreatePolygon(name: string, options: {
  67367. shape: Vector3[];
  67368. holes?: Vector3[][];
  67369. depth?: number;
  67370. faceUV?: Vector4[];
  67371. faceColors?: Color4[];
  67372. updatable?: boolean;
  67373. sideOrientation?: number;
  67374. frontUVs?: Vector4;
  67375. backUVs?: Vector4;
  67376. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67377. /**
  67378. * Creates an extruded polygon mesh, with depth in the Y direction.
  67379. * * 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)
  67380. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67381. * @param name defines the name of the mesh
  67382. * @param options defines the options used to create the mesh
  67383. * @param scene defines the hosting scene
  67384. * @param earcutInjection can be used to inject your own earcut reference
  67385. * @returns the polygon mesh
  67386. */
  67387. static ExtrudePolygon(name: string, options: {
  67388. shape: Vector3[];
  67389. holes?: Vector3[][];
  67390. depth?: number;
  67391. faceUV?: Vector4[];
  67392. faceColors?: Color4[];
  67393. updatable?: boolean;
  67394. sideOrientation?: number;
  67395. frontUVs?: Vector4;
  67396. backUVs?: Vector4;
  67397. wrap?: boolean;
  67398. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67399. /**
  67400. * Creates a tube mesh.
  67401. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67402. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67403. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67404. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67405. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67406. * * 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)
  67407. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67408. * * 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
  67409. * * 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
  67410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67411. * * 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
  67412. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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. * @param name defines the name of the mesh
  67415. * @param options defines the options used to create the mesh
  67416. * @param scene defines the hosting scene
  67417. * @returns the tube mesh
  67418. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67419. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67420. */
  67421. static CreateTube(name: string, options: {
  67422. path: Vector3[];
  67423. radius?: number;
  67424. tessellation?: number;
  67425. radiusFunction?: {
  67426. (i: number, distance: number): number;
  67427. };
  67428. cap?: number;
  67429. arc?: number;
  67430. updatable?: boolean;
  67431. sideOrientation?: number;
  67432. frontUVs?: Vector4;
  67433. backUVs?: Vector4;
  67434. instance?: Mesh;
  67435. invertUV?: boolean;
  67436. }, scene?: Nullable<Scene>): Mesh;
  67437. /**
  67438. * Creates a polyhedron mesh
  67439. * * 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
  67440. * * The parameter `size` (positive float, default 1) sets the polygon size
  67441. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67442. * * 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`
  67443. * * 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
  67444. * * 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)`)
  67445. * * 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
  67446. * * 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
  67447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67448. * * 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
  67449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67450. * @param name defines the name of the mesh
  67451. * @param options defines the options used to create the mesh
  67452. * @param scene defines the hosting scene
  67453. * @returns the polyhedron mesh
  67454. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67455. */
  67456. static CreatePolyhedron(name: string, options: {
  67457. type?: number;
  67458. size?: number;
  67459. sizeX?: number;
  67460. sizeY?: number;
  67461. sizeZ?: number;
  67462. custom?: any;
  67463. faceUV?: Vector4[];
  67464. faceColors?: Color4[];
  67465. flat?: boolean;
  67466. updatable?: boolean;
  67467. sideOrientation?: number;
  67468. frontUVs?: Vector4;
  67469. backUVs?: Vector4;
  67470. }, scene?: Nullable<Scene>): Mesh;
  67471. /**
  67472. * Creates a decal mesh.
  67473. * 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
  67474. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67475. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67476. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67477. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67478. * @param name defines the name of the mesh
  67479. * @param sourceMesh defines the mesh where the decal must be applied
  67480. * @param options defines the options used to create the mesh
  67481. * @param scene defines the hosting scene
  67482. * @returns the decal mesh
  67483. * @see https://doc.babylonjs.com/how_to/decals
  67484. */
  67485. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67486. position?: Vector3;
  67487. normal?: Vector3;
  67488. size?: Vector3;
  67489. angle?: number;
  67490. }): Mesh;
  67491. /**
  67492. * Creates a Capsule Mesh
  67493. * @param name defines the name of the mesh.
  67494. * @param options the constructors options used to shape the mesh.
  67495. * @param scene defines the scene the mesh is scoped to.
  67496. * @returns the capsule mesh
  67497. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67498. */
  67499. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67500. }
  67501. }
  67502. declare module BABYLON {
  67503. /**
  67504. * A simplifier interface for future simplification implementations
  67505. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67506. */
  67507. export interface ISimplifier {
  67508. /**
  67509. * Simplification of a given mesh according to the given settings.
  67510. * Since this requires computation, it is assumed that the function runs async.
  67511. * @param settings The settings of the simplification, including quality and distance
  67512. * @param successCallback A callback that will be called after the mesh was simplified.
  67513. * @param errorCallback in case of an error, this callback will be called. optional.
  67514. */
  67515. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67516. }
  67517. /**
  67518. * Expected simplification settings.
  67519. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67520. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67521. */
  67522. export interface ISimplificationSettings {
  67523. /**
  67524. * Gets or sets the expected quality
  67525. */
  67526. quality: number;
  67527. /**
  67528. * Gets or sets the distance when this optimized version should be used
  67529. */
  67530. distance: number;
  67531. /**
  67532. * Gets an already optimized mesh
  67533. */
  67534. optimizeMesh?: boolean;
  67535. }
  67536. /**
  67537. * Class used to specify simplification options
  67538. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67539. */
  67540. export class SimplificationSettings implements ISimplificationSettings {
  67541. /** expected quality */
  67542. quality: number;
  67543. /** distance when this optimized version should be used */
  67544. distance: number;
  67545. /** already optimized mesh */
  67546. optimizeMesh?: boolean | undefined;
  67547. /**
  67548. * Creates a SimplificationSettings
  67549. * @param quality expected quality
  67550. * @param distance distance when this optimized version should be used
  67551. * @param optimizeMesh already optimized mesh
  67552. */
  67553. constructor(
  67554. /** expected quality */
  67555. quality: number,
  67556. /** distance when this optimized version should be used */
  67557. distance: number,
  67558. /** already optimized mesh */
  67559. optimizeMesh?: boolean | undefined);
  67560. }
  67561. /**
  67562. * Interface used to define a simplification task
  67563. */
  67564. export interface ISimplificationTask {
  67565. /**
  67566. * Array of settings
  67567. */
  67568. settings: Array<ISimplificationSettings>;
  67569. /**
  67570. * Simplification type
  67571. */
  67572. simplificationType: SimplificationType;
  67573. /**
  67574. * Mesh to simplify
  67575. */
  67576. mesh: Mesh;
  67577. /**
  67578. * Callback called on success
  67579. */
  67580. successCallback?: () => void;
  67581. /**
  67582. * Defines if parallel processing can be used
  67583. */
  67584. parallelProcessing: boolean;
  67585. }
  67586. /**
  67587. * Queue used to order the simplification tasks
  67588. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67589. */
  67590. export class SimplificationQueue {
  67591. private _simplificationArray;
  67592. /**
  67593. * Gets a boolean indicating that the process is still running
  67594. */
  67595. running: boolean;
  67596. /**
  67597. * Creates a new queue
  67598. */
  67599. constructor();
  67600. /**
  67601. * Adds a new simplification task
  67602. * @param task defines a task to add
  67603. */
  67604. addTask(task: ISimplificationTask): void;
  67605. /**
  67606. * Execute next task
  67607. */
  67608. executeNext(): void;
  67609. /**
  67610. * Execute a simplification task
  67611. * @param task defines the task to run
  67612. */
  67613. runSimplification(task: ISimplificationTask): void;
  67614. private getSimplifier;
  67615. }
  67616. /**
  67617. * The implemented types of simplification
  67618. * At the moment only Quadratic Error Decimation is implemented
  67619. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67620. */
  67621. export enum SimplificationType {
  67622. /** Quadratic error decimation */
  67623. QUADRATIC = 0
  67624. }
  67625. /**
  67626. * An implementation of the Quadratic Error simplification algorithm.
  67627. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67628. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67629. * @author RaananW
  67630. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67631. */
  67632. export class QuadraticErrorSimplification implements ISimplifier {
  67633. private _mesh;
  67634. private triangles;
  67635. private vertices;
  67636. private references;
  67637. private _reconstructedMesh;
  67638. /** Gets or sets the number pf sync interations */
  67639. syncIterations: number;
  67640. /** Gets or sets the aggressiveness of the simplifier */
  67641. aggressiveness: number;
  67642. /** Gets or sets the number of allowed iterations for decimation */
  67643. decimationIterations: number;
  67644. /** Gets or sets the espilon to use for bounding box computation */
  67645. boundingBoxEpsilon: number;
  67646. /**
  67647. * Creates a new QuadraticErrorSimplification
  67648. * @param _mesh defines the target mesh
  67649. */
  67650. constructor(_mesh: Mesh);
  67651. /**
  67652. * Simplification of a given mesh according to the given settings.
  67653. * Since this requires computation, it is assumed that the function runs async.
  67654. * @param settings The settings of the simplification, including quality and distance
  67655. * @param successCallback A callback that will be called after the mesh was simplified.
  67656. */
  67657. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67658. private runDecimation;
  67659. private initWithMesh;
  67660. private init;
  67661. private reconstructMesh;
  67662. private initDecimatedMesh;
  67663. private isFlipped;
  67664. private updateTriangles;
  67665. private identifyBorder;
  67666. private updateMesh;
  67667. private vertexError;
  67668. private calculateError;
  67669. }
  67670. }
  67671. declare module BABYLON {
  67672. interface Scene {
  67673. /** @hidden (Backing field) */
  67674. _simplificationQueue: SimplificationQueue;
  67675. /**
  67676. * Gets or sets the simplification queue attached to the scene
  67677. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67678. */
  67679. simplificationQueue: SimplificationQueue;
  67680. }
  67681. interface Mesh {
  67682. /**
  67683. * Simplify the mesh according to the given array of settings.
  67684. * Function will return immediately and will simplify async
  67685. * @param settings a collection of simplification settings
  67686. * @param parallelProcessing should all levels calculate parallel or one after the other
  67687. * @param simplificationType the type of simplification to run
  67688. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67689. * @returns the current mesh
  67690. */
  67691. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67692. }
  67693. /**
  67694. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67695. * created in a scene
  67696. */
  67697. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67698. /**
  67699. * The component name helpfull to identify the component in the list of scene components.
  67700. */
  67701. readonly name: string;
  67702. /**
  67703. * The scene the component belongs to.
  67704. */
  67705. scene: Scene;
  67706. /**
  67707. * Creates a new instance of the component for the given scene
  67708. * @param scene Defines the scene to register the component in
  67709. */
  67710. constructor(scene: Scene);
  67711. /**
  67712. * Registers the component in a given scene
  67713. */
  67714. register(): void;
  67715. /**
  67716. * Rebuilds the elements related to this component in case of
  67717. * context lost for instance.
  67718. */
  67719. rebuild(): void;
  67720. /**
  67721. * Disposes the component and the associated ressources
  67722. */
  67723. dispose(): void;
  67724. private _beforeCameraUpdate;
  67725. }
  67726. }
  67727. declare module BABYLON {
  67728. interface Mesh {
  67729. /**
  67730. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67731. */
  67732. thinInstanceEnablePicking: boolean;
  67733. /**
  67734. * Creates a new thin instance
  67735. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67736. * @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
  67737. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67738. */
  67739. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67740. /**
  67741. * Adds the transformation (matrix) of the current mesh as a thin instance
  67742. * @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
  67743. * @returns the thin instance index number
  67744. */
  67745. thinInstanceAddSelf(refresh: boolean): number;
  67746. /**
  67747. * Registers a custom attribute to be used with thin instances
  67748. * @param kind name of the attribute
  67749. * @param stride size in floats of the attribute
  67750. */
  67751. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67752. /**
  67753. * Sets the matrix of a thin instance
  67754. * @param index index of the thin instance
  67755. * @param matrix matrix to set
  67756. * @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
  67757. */
  67758. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67759. /**
  67760. * Sets the value of a custom attribute for a thin instance
  67761. * @param kind name of the attribute
  67762. * @param index index of the thin instance
  67763. * @param value value to set
  67764. * @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
  67765. */
  67766. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67767. /**
  67768. * 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.
  67769. */
  67770. thinInstanceCount: number;
  67771. /**
  67772. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67773. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67774. * @param buffer buffer to set
  67775. * @param stride size in floats of each value of the buffer
  67776. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67777. */
  67778. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67779. /**
  67780. * Gets the list of world matrices
  67781. * @return an array containing all the world matrices from the thin instances
  67782. */
  67783. thinInstanceGetWorldMatrices(): Matrix[];
  67784. /**
  67785. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67786. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67787. */
  67788. thinInstanceBufferUpdated(kind: string): void;
  67789. /**
  67790. * Applies a partial update to a buffer directly on the GPU
  67791. * 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
  67792. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67793. * @param data the data to set in the GPU buffer
  67794. * @param offset the offset in the GPU buffer where to update the data
  67795. */
  67796. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67797. /**
  67798. * Refreshes the bounding info, taking into account all the thin instances defined
  67799. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  67800. */
  67801. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  67802. /** @hidden */
  67803. _thinInstanceInitializeUserStorage(): void;
  67804. /** @hidden */
  67805. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  67806. /** @hidden */
  67807. _userThinInstanceBuffersStorage: {
  67808. data: {
  67809. [key: string]: Float32Array;
  67810. };
  67811. sizes: {
  67812. [key: string]: number;
  67813. };
  67814. vertexBuffers: {
  67815. [key: string]: Nullable<VertexBuffer>;
  67816. };
  67817. strides: {
  67818. [key: string]: number;
  67819. };
  67820. };
  67821. }
  67822. }
  67823. declare module BABYLON {
  67824. /**
  67825. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67826. */
  67827. export interface INavigationEnginePlugin {
  67828. /**
  67829. * plugin name
  67830. */
  67831. name: string;
  67832. /**
  67833. * Creates a navigation mesh
  67834. * @param meshes array of all the geometry used to compute the navigatio mesh
  67835. * @param parameters bunch of parameters used to filter geometry
  67836. */
  67837. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67838. /**
  67839. * Create a navigation mesh debug mesh
  67840. * @param scene is where the mesh will be added
  67841. * @returns debug display mesh
  67842. */
  67843. createDebugNavMesh(scene: Scene): Mesh;
  67844. /**
  67845. * Get a navigation mesh constrained position, closest to the parameter position
  67846. * @param position world position
  67847. * @returns the closest point to position constrained by the navigation mesh
  67848. */
  67849. getClosestPoint(position: Vector3): Vector3;
  67850. /**
  67851. * Get a navigation mesh constrained position, closest to the parameter position
  67852. * @param position world position
  67853. * @param result output the closest point to position constrained by the navigation mesh
  67854. */
  67855. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67856. /**
  67857. * Get a navigation mesh constrained position, within a particular radius
  67858. * @param position world position
  67859. * @param maxRadius the maximum distance to the constrained world position
  67860. * @returns the closest point to position constrained by the navigation mesh
  67861. */
  67862. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67863. /**
  67864. * Get a navigation mesh constrained position, within a particular radius
  67865. * @param position world position
  67866. * @param maxRadius the maximum distance to the constrained world position
  67867. * @param result output the closest point to position constrained by the navigation mesh
  67868. */
  67869. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67870. /**
  67871. * Compute the final position from a segment made of destination-position
  67872. * @param position world position
  67873. * @param destination world position
  67874. * @returns the resulting point along the navmesh
  67875. */
  67876. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67877. /**
  67878. * Compute the final position from a segment made of destination-position
  67879. * @param position world position
  67880. * @param destination world position
  67881. * @param result output the resulting point along the navmesh
  67882. */
  67883. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67884. /**
  67885. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67886. * @param start world position
  67887. * @param end world position
  67888. * @returns array containing world position composing the path
  67889. */
  67890. computePath(start: Vector3, end: Vector3): Vector3[];
  67891. /**
  67892. * If this plugin is supported
  67893. * @returns true if plugin is supported
  67894. */
  67895. isSupported(): boolean;
  67896. /**
  67897. * Create a new Crowd so you can add agents
  67898. * @param maxAgents the maximum agent count in the crowd
  67899. * @param maxAgentRadius the maximum radius an agent can have
  67900. * @param scene to attach the crowd to
  67901. * @returns the crowd you can add agents to
  67902. */
  67903. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67904. /**
  67905. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67906. * The queries will try to find a solution within those bounds
  67907. * default is (1,1,1)
  67908. * @param extent x,y,z value that define the extent around the queries point of reference
  67909. */
  67910. setDefaultQueryExtent(extent: Vector3): void;
  67911. /**
  67912. * Get the Bounding box extent specified by setDefaultQueryExtent
  67913. * @returns the box extent values
  67914. */
  67915. getDefaultQueryExtent(): Vector3;
  67916. /**
  67917. * build the navmesh from a previously saved state using getNavmeshData
  67918. * @param data the Uint8Array returned by getNavmeshData
  67919. */
  67920. buildFromNavmeshData(data: Uint8Array): void;
  67921. /**
  67922. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67923. * @returns data the Uint8Array that can be saved and reused
  67924. */
  67925. getNavmeshData(): Uint8Array;
  67926. /**
  67927. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67928. * @param result output the box extent values
  67929. */
  67930. getDefaultQueryExtentToRef(result: Vector3): void;
  67931. /**
  67932. * Release all resources
  67933. */
  67934. dispose(): void;
  67935. }
  67936. /**
  67937. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67938. */
  67939. export interface ICrowd {
  67940. /**
  67941. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67942. * You can attach anything to that node. The node position is updated in the scene update tick.
  67943. * @param pos world position that will be constrained by the navigation mesh
  67944. * @param parameters agent parameters
  67945. * @param transform hooked to the agent that will be update by the scene
  67946. * @returns agent index
  67947. */
  67948. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67949. /**
  67950. * Returns the agent position in world space
  67951. * @param index agent index returned by addAgent
  67952. * @returns world space position
  67953. */
  67954. getAgentPosition(index: number): Vector3;
  67955. /**
  67956. * Gets the agent position result in world space
  67957. * @param index agent index returned by addAgent
  67958. * @param result output world space position
  67959. */
  67960. getAgentPositionToRef(index: number, result: Vector3): void;
  67961. /**
  67962. * Gets the agent velocity in world space
  67963. * @param index agent index returned by addAgent
  67964. * @returns world space velocity
  67965. */
  67966. getAgentVelocity(index: number): Vector3;
  67967. /**
  67968. * Gets the agent velocity result in world space
  67969. * @param index agent index returned by addAgent
  67970. * @param result output world space velocity
  67971. */
  67972. getAgentVelocityToRef(index: number, result: Vector3): void;
  67973. /**
  67974. * Gets the agent next target point on the path
  67975. * @param index agent index returned by addAgent
  67976. * @returns world space position
  67977. */
  67978. getAgentNextTargetPath(index: number): Vector3;
  67979. /**
  67980. * Gets the agent state
  67981. * @param index agent index returned by addAgent
  67982. * @returns agent state
  67983. */
  67984. getAgentState(index: number): number;
  67985. /**
  67986. * returns true if the agent in over an off mesh link connection
  67987. * @param index agent index returned by addAgent
  67988. * @returns true if over an off mesh link connection
  67989. */
  67990. overOffmeshConnection(index: number): boolean;
  67991. /**
  67992. * Gets the agent next target point on the path
  67993. * @param index agent index returned by addAgent
  67994. * @param result output world space position
  67995. */
  67996. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  67997. /**
  67998. * remove a particular agent previously created
  67999. * @param index agent index returned by addAgent
  68000. */
  68001. removeAgent(index: number): void;
  68002. /**
  68003. * get the list of all agents attached to this crowd
  68004. * @returns list of agent indices
  68005. */
  68006. getAgents(): number[];
  68007. /**
  68008. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68009. * @param deltaTime in seconds
  68010. */
  68011. update(deltaTime: number): void;
  68012. /**
  68013. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68014. * @param index agent index returned by addAgent
  68015. * @param destination targeted world position
  68016. */
  68017. agentGoto(index: number, destination: Vector3): void;
  68018. /**
  68019. * Teleport the agent to a new position
  68020. * @param index agent index returned by addAgent
  68021. * @param destination targeted world position
  68022. */
  68023. agentTeleport(index: number, destination: Vector3): void;
  68024. /**
  68025. * Update agent parameters
  68026. * @param index agent index returned by addAgent
  68027. * @param parameters agent parameters
  68028. */
  68029. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68030. /**
  68031. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68032. * The queries will try to find a solution within those bounds
  68033. * default is (1,1,1)
  68034. * @param extent x,y,z value that define the extent around the queries point of reference
  68035. */
  68036. setDefaultQueryExtent(extent: Vector3): void;
  68037. /**
  68038. * Get the Bounding box extent specified by setDefaultQueryExtent
  68039. * @returns the box extent values
  68040. */
  68041. getDefaultQueryExtent(): Vector3;
  68042. /**
  68043. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68044. * @param result output the box extent values
  68045. */
  68046. getDefaultQueryExtentToRef(result: Vector3): void;
  68047. /**
  68048. * Release all resources
  68049. */
  68050. dispose(): void;
  68051. }
  68052. /**
  68053. * Configures an agent
  68054. */
  68055. export interface IAgentParameters {
  68056. /**
  68057. * Agent radius. [Limit: >= 0]
  68058. */
  68059. radius: number;
  68060. /**
  68061. * Agent height. [Limit: > 0]
  68062. */
  68063. height: number;
  68064. /**
  68065. * Maximum allowed acceleration. [Limit: >= 0]
  68066. */
  68067. maxAcceleration: number;
  68068. /**
  68069. * Maximum allowed speed. [Limit: >= 0]
  68070. */
  68071. maxSpeed: number;
  68072. /**
  68073. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68074. */
  68075. collisionQueryRange: number;
  68076. /**
  68077. * The path visibility optimization range. [Limit: > 0]
  68078. */
  68079. pathOptimizationRange: number;
  68080. /**
  68081. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68082. */
  68083. separationWeight: number;
  68084. }
  68085. /**
  68086. * Configures the navigation mesh creation
  68087. */
  68088. export interface INavMeshParameters {
  68089. /**
  68090. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68091. */
  68092. cs: number;
  68093. /**
  68094. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68095. */
  68096. ch: number;
  68097. /**
  68098. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68099. */
  68100. walkableSlopeAngle: number;
  68101. /**
  68102. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68103. * be considered walkable. [Limit: >= 3] [Units: vx]
  68104. */
  68105. walkableHeight: number;
  68106. /**
  68107. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68108. */
  68109. walkableClimb: number;
  68110. /**
  68111. * The distance to erode/shrink the walkable area of the heightfield away from
  68112. * obstructions. [Limit: >=0] [Units: vx]
  68113. */
  68114. walkableRadius: number;
  68115. /**
  68116. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68117. */
  68118. maxEdgeLen: number;
  68119. /**
  68120. * The maximum distance a simplfied contour's border edges should deviate
  68121. * the original raw contour. [Limit: >=0] [Units: vx]
  68122. */
  68123. maxSimplificationError: number;
  68124. /**
  68125. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68126. */
  68127. minRegionArea: number;
  68128. /**
  68129. * Any regions with a span count smaller than this value will, if possible,
  68130. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68131. */
  68132. mergeRegionArea: number;
  68133. /**
  68134. * The maximum number of vertices allowed for polygons generated during the
  68135. * contour to polygon conversion process. [Limit: >= 3]
  68136. */
  68137. maxVertsPerPoly: number;
  68138. /**
  68139. * Sets the sampling distance to use when generating the detail mesh.
  68140. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68141. */
  68142. detailSampleDist: number;
  68143. /**
  68144. * The maximum distance the detail mesh surface should deviate from heightfield
  68145. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68146. */
  68147. detailSampleMaxError: number;
  68148. }
  68149. }
  68150. declare module BABYLON {
  68151. /**
  68152. * RecastJS navigation plugin
  68153. */
  68154. export class RecastJSPlugin implements INavigationEnginePlugin {
  68155. /**
  68156. * Reference to the Recast library
  68157. */
  68158. bjsRECAST: any;
  68159. /**
  68160. * plugin name
  68161. */
  68162. name: string;
  68163. /**
  68164. * the first navmesh created. We might extend this to support multiple navmeshes
  68165. */
  68166. navMesh: any;
  68167. /**
  68168. * Initializes the recastJS plugin
  68169. * @param recastInjection can be used to inject your own recast reference
  68170. */
  68171. constructor(recastInjection?: any);
  68172. /**
  68173. * Creates a navigation mesh
  68174. * @param meshes array of all the geometry used to compute the navigatio mesh
  68175. * @param parameters bunch of parameters used to filter geometry
  68176. */
  68177. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68178. /**
  68179. * Create a navigation mesh debug mesh
  68180. * @param scene is where the mesh will be added
  68181. * @returns debug display mesh
  68182. */
  68183. createDebugNavMesh(scene: Scene): Mesh;
  68184. /**
  68185. * Get a navigation mesh constrained position, closest to the parameter position
  68186. * @param position world position
  68187. * @returns the closest point to position constrained by the navigation mesh
  68188. */
  68189. getClosestPoint(position: Vector3): Vector3;
  68190. /**
  68191. * Get a navigation mesh constrained position, closest to the parameter position
  68192. * @param position world position
  68193. * @param result output the closest point to position constrained by the navigation mesh
  68194. */
  68195. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68196. /**
  68197. * Get a navigation mesh constrained position, within a particular radius
  68198. * @param position world position
  68199. * @param maxRadius the maximum distance to the constrained world position
  68200. * @returns the closest point to position constrained by the navigation mesh
  68201. */
  68202. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68203. /**
  68204. * Get a navigation mesh constrained position, within a particular radius
  68205. * @param position world position
  68206. * @param maxRadius the maximum distance to the constrained world position
  68207. * @param result output the closest point to position constrained by the navigation mesh
  68208. */
  68209. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68210. /**
  68211. * Compute the final position from a segment made of destination-position
  68212. * @param position world position
  68213. * @param destination world position
  68214. * @returns the resulting point along the navmesh
  68215. */
  68216. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68217. /**
  68218. * Compute the final position from a segment made of destination-position
  68219. * @param position world position
  68220. * @param destination world position
  68221. * @param result output the resulting point along the navmesh
  68222. */
  68223. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68224. /**
  68225. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68226. * @param start world position
  68227. * @param end world position
  68228. * @returns array containing world position composing the path
  68229. */
  68230. computePath(start: Vector3, end: Vector3): Vector3[];
  68231. /**
  68232. * Create a new Crowd so you can add agents
  68233. * @param maxAgents the maximum agent count in the crowd
  68234. * @param maxAgentRadius the maximum radius an agent can have
  68235. * @param scene to attach the crowd to
  68236. * @returns the crowd you can add agents to
  68237. */
  68238. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68239. /**
  68240. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68241. * The queries will try to find a solution within those bounds
  68242. * default is (1,1,1)
  68243. * @param extent x,y,z value that define the extent around the queries point of reference
  68244. */
  68245. setDefaultQueryExtent(extent: Vector3): void;
  68246. /**
  68247. * Get the Bounding box extent specified by setDefaultQueryExtent
  68248. * @returns the box extent values
  68249. */
  68250. getDefaultQueryExtent(): Vector3;
  68251. /**
  68252. * build the navmesh from a previously saved state using getNavmeshData
  68253. * @param data the Uint8Array returned by getNavmeshData
  68254. */
  68255. buildFromNavmeshData(data: Uint8Array): void;
  68256. /**
  68257. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68258. * @returns data the Uint8Array that can be saved and reused
  68259. */
  68260. getNavmeshData(): Uint8Array;
  68261. /**
  68262. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68263. * @param result output the box extent values
  68264. */
  68265. getDefaultQueryExtentToRef(result: Vector3): void;
  68266. /**
  68267. * Disposes
  68268. */
  68269. dispose(): void;
  68270. /**
  68271. * If this plugin is supported
  68272. * @returns true if plugin is supported
  68273. */
  68274. isSupported(): boolean;
  68275. }
  68276. /**
  68277. * Recast detour crowd implementation
  68278. */
  68279. export class RecastJSCrowd implements ICrowd {
  68280. /**
  68281. * Recast/detour plugin
  68282. */
  68283. bjsRECASTPlugin: RecastJSPlugin;
  68284. /**
  68285. * Link to the detour crowd
  68286. */
  68287. recastCrowd: any;
  68288. /**
  68289. * One transform per agent
  68290. */
  68291. transforms: TransformNode[];
  68292. /**
  68293. * All agents created
  68294. */
  68295. agents: number[];
  68296. /**
  68297. * Link to the scene is kept to unregister the crowd from the scene
  68298. */
  68299. private _scene;
  68300. /**
  68301. * Observer for crowd updates
  68302. */
  68303. private _onBeforeAnimationsObserver;
  68304. /**
  68305. * Constructor
  68306. * @param plugin recastJS plugin
  68307. * @param maxAgents the maximum agent count in the crowd
  68308. * @param maxAgentRadius the maximum radius an agent can have
  68309. * @param scene to attach the crowd to
  68310. * @returns the crowd you can add agents to
  68311. */
  68312. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68313. /**
  68314. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68315. * You can attach anything to that node. The node position is updated in the scene update tick.
  68316. * @param pos world position that will be constrained by the navigation mesh
  68317. * @param parameters agent parameters
  68318. * @param transform hooked to the agent that will be update by the scene
  68319. * @returns agent index
  68320. */
  68321. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68322. /**
  68323. * Returns the agent position in world space
  68324. * @param index agent index returned by addAgent
  68325. * @returns world space position
  68326. */
  68327. getAgentPosition(index: number): Vector3;
  68328. /**
  68329. * Returns the agent position result in world space
  68330. * @param index agent index returned by addAgent
  68331. * @param result output world space position
  68332. */
  68333. getAgentPositionToRef(index: number, result: Vector3): void;
  68334. /**
  68335. * Returns the agent velocity in world space
  68336. * @param index agent index returned by addAgent
  68337. * @returns world space velocity
  68338. */
  68339. getAgentVelocity(index: number): Vector3;
  68340. /**
  68341. * Returns the agent velocity result in world space
  68342. * @param index agent index returned by addAgent
  68343. * @param result output world space velocity
  68344. */
  68345. getAgentVelocityToRef(index: number, result: Vector3): void;
  68346. /**
  68347. * Returns the agent next target point on the path
  68348. * @param index agent index returned by addAgent
  68349. * @returns world space position
  68350. */
  68351. getAgentNextTargetPath(index: number): Vector3;
  68352. /**
  68353. * Returns the agent next target point on the path
  68354. * @param index agent index returned by addAgent
  68355. * @param result output world space position
  68356. */
  68357. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68358. /**
  68359. * Gets the agent state
  68360. * @param index agent index returned by addAgent
  68361. * @returns agent state
  68362. */
  68363. getAgentState(index: number): number;
  68364. /**
  68365. * returns true if the agent in over an off mesh link connection
  68366. * @param index agent index returned by addAgent
  68367. * @returns true if over an off mesh link connection
  68368. */
  68369. overOffmeshConnection(index: number): boolean;
  68370. /**
  68371. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68372. * @param index agent index returned by addAgent
  68373. * @param destination targeted world position
  68374. */
  68375. agentGoto(index: number, destination: Vector3): void;
  68376. /**
  68377. * Teleport the agent to a new position
  68378. * @param index agent index returned by addAgent
  68379. * @param destination targeted world position
  68380. */
  68381. agentTeleport(index: number, destination: Vector3): void;
  68382. /**
  68383. * Update agent parameters
  68384. * @param index agent index returned by addAgent
  68385. * @param parameters agent parameters
  68386. */
  68387. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68388. /**
  68389. * remove a particular agent previously created
  68390. * @param index agent index returned by addAgent
  68391. */
  68392. removeAgent(index: number): void;
  68393. /**
  68394. * get the list of all agents attached to this crowd
  68395. * @returns list of agent indices
  68396. */
  68397. getAgents(): number[];
  68398. /**
  68399. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68400. * @param deltaTime in seconds
  68401. */
  68402. update(deltaTime: number): void;
  68403. /**
  68404. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68405. * The queries will try to find a solution within those bounds
  68406. * default is (1,1,1)
  68407. * @param extent x,y,z value that define the extent around the queries point of reference
  68408. */
  68409. setDefaultQueryExtent(extent: Vector3): void;
  68410. /**
  68411. * Get the Bounding box extent specified by setDefaultQueryExtent
  68412. * @returns the box extent values
  68413. */
  68414. getDefaultQueryExtent(): Vector3;
  68415. /**
  68416. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68417. * @param result output the box extent values
  68418. */
  68419. getDefaultQueryExtentToRef(result: Vector3): void;
  68420. /**
  68421. * Release all resources
  68422. */
  68423. dispose(): void;
  68424. }
  68425. }
  68426. declare module BABYLON {
  68427. /**
  68428. * Class used to enable access to IndexedDB
  68429. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68430. */
  68431. export class Database implements IOfflineProvider {
  68432. private _callbackManifestChecked;
  68433. private _currentSceneUrl;
  68434. private _db;
  68435. private _enableSceneOffline;
  68436. private _enableTexturesOffline;
  68437. private _manifestVersionFound;
  68438. private _mustUpdateRessources;
  68439. private _hasReachedQuota;
  68440. private _isSupported;
  68441. private _idbFactory;
  68442. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68443. private static IsUASupportingBlobStorage;
  68444. /**
  68445. * Gets a boolean indicating if Database storate is enabled (off by default)
  68446. */
  68447. static IDBStorageEnabled: boolean;
  68448. /**
  68449. * Gets a boolean indicating if scene must be saved in the database
  68450. */
  68451. get enableSceneOffline(): boolean;
  68452. /**
  68453. * Gets a boolean indicating if textures must be saved in the database
  68454. */
  68455. get enableTexturesOffline(): boolean;
  68456. /**
  68457. * Creates a new Database
  68458. * @param urlToScene defines the url to load the scene
  68459. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68460. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68461. */
  68462. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68463. private static _ParseURL;
  68464. private static _ReturnFullUrlLocation;
  68465. private _checkManifestFile;
  68466. /**
  68467. * Open the database and make it available
  68468. * @param successCallback defines the callback to call on success
  68469. * @param errorCallback defines the callback to call on error
  68470. */
  68471. open(successCallback: () => void, errorCallback: () => void): void;
  68472. /**
  68473. * Loads an image from the database
  68474. * @param url defines the url to load from
  68475. * @param image defines the target DOM image
  68476. */
  68477. loadImage(url: string, image: HTMLImageElement): void;
  68478. private _loadImageFromDBAsync;
  68479. private _saveImageIntoDBAsync;
  68480. private _checkVersionFromDB;
  68481. private _loadVersionFromDBAsync;
  68482. private _saveVersionIntoDBAsync;
  68483. /**
  68484. * Loads a file from database
  68485. * @param url defines the URL to load from
  68486. * @param sceneLoaded defines a callback to call on success
  68487. * @param progressCallBack defines a callback to call when progress changed
  68488. * @param errorCallback defines a callback to call on error
  68489. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68490. */
  68491. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68492. private _loadFileAsync;
  68493. private _saveFileAsync;
  68494. /**
  68495. * Validates if xhr data is correct
  68496. * @param xhr defines the request to validate
  68497. * @param dataType defines the expected data type
  68498. * @returns true if data is correct
  68499. */
  68500. private static _ValidateXHRData;
  68501. }
  68502. }
  68503. declare module BABYLON {
  68504. /** @hidden */
  68505. export var gpuUpdateParticlesPixelShader: {
  68506. name: string;
  68507. shader: string;
  68508. };
  68509. }
  68510. declare module BABYLON {
  68511. /** @hidden */
  68512. export var gpuUpdateParticlesVertexShader: {
  68513. name: string;
  68514. shader: string;
  68515. };
  68516. }
  68517. declare module BABYLON {
  68518. /** @hidden */
  68519. export var clipPlaneFragmentDeclaration2: {
  68520. name: string;
  68521. shader: string;
  68522. };
  68523. }
  68524. declare module BABYLON {
  68525. /** @hidden */
  68526. export var gpuRenderParticlesPixelShader: {
  68527. name: string;
  68528. shader: string;
  68529. };
  68530. }
  68531. declare module BABYLON {
  68532. /** @hidden */
  68533. export var clipPlaneVertexDeclaration2: {
  68534. name: string;
  68535. shader: string;
  68536. };
  68537. }
  68538. declare module BABYLON {
  68539. /** @hidden */
  68540. export var gpuRenderParticlesVertexShader: {
  68541. name: string;
  68542. shader: string;
  68543. };
  68544. }
  68545. declare module BABYLON {
  68546. /**
  68547. * This represents a GPU particle system in Babylon
  68548. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68549. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68550. */
  68551. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68552. /**
  68553. * The layer mask we are rendering the particles through.
  68554. */
  68555. layerMask: number;
  68556. private _capacity;
  68557. private _activeCount;
  68558. private _currentActiveCount;
  68559. private _accumulatedCount;
  68560. private _renderEffect;
  68561. private _updateEffect;
  68562. private _buffer0;
  68563. private _buffer1;
  68564. private _spriteBuffer;
  68565. private _updateVAO;
  68566. private _renderVAO;
  68567. private _targetIndex;
  68568. private _sourceBuffer;
  68569. private _targetBuffer;
  68570. private _currentRenderId;
  68571. private _started;
  68572. private _stopped;
  68573. private _timeDelta;
  68574. private _randomTexture;
  68575. private _randomTexture2;
  68576. private _attributesStrideSize;
  68577. private _updateEffectOptions;
  68578. private _randomTextureSize;
  68579. private _actualFrame;
  68580. private _customEffect;
  68581. private readonly _rawTextureWidth;
  68582. /**
  68583. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68584. */
  68585. static get IsSupported(): boolean;
  68586. /**
  68587. * An event triggered when the system is disposed.
  68588. */
  68589. onDisposeObservable: Observable<IParticleSystem>;
  68590. /**
  68591. * An event triggered when the system is stopped
  68592. */
  68593. onStoppedObservable: Observable<IParticleSystem>;
  68594. /**
  68595. * Gets the maximum number of particles active at the same time.
  68596. * @returns The max number of active particles.
  68597. */
  68598. getCapacity(): number;
  68599. /**
  68600. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68601. * to override the particles.
  68602. */
  68603. forceDepthWrite: boolean;
  68604. /**
  68605. * Gets or set the number of active particles
  68606. */
  68607. get activeParticleCount(): number;
  68608. set activeParticleCount(value: number);
  68609. private _preWarmDone;
  68610. /**
  68611. * Specifies if the particles are updated in emitter local space or world space.
  68612. */
  68613. isLocal: boolean;
  68614. /** Gets or sets a matrix to use to compute projection */
  68615. defaultProjectionMatrix: Matrix;
  68616. /**
  68617. * Is this system ready to be used/rendered
  68618. * @return true if the system is ready
  68619. */
  68620. isReady(): boolean;
  68621. /**
  68622. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68623. * @returns True if it has been started, otherwise false.
  68624. */
  68625. isStarted(): boolean;
  68626. /**
  68627. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68628. * @returns True if it has been stopped, otherwise false.
  68629. */
  68630. isStopped(): boolean;
  68631. /**
  68632. * Gets a boolean indicating that the system is stopping
  68633. * @returns true if the system is currently stopping
  68634. */
  68635. isStopping(): boolean;
  68636. /**
  68637. * Gets the number of particles active at the same time.
  68638. * @returns The number of active particles.
  68639. */
  68640. getActiveCount(): number;
  68641. /**
  68642. * Starts the particle system and begins to emit
  68643. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68644. */
  68645. start(delay?: number): void;
  68646. /**
  68647. * Stops the particle system.
  68648. */
  68649. stop(): void;
  68650. /**
  68651. * Remove all active particles
  68652. */
  68653. reset(): void;
  68654. /**
  68655. * Returns the string "GPUParticleSystem"
  68656. * @returns a string containing the class name
  68657. */
  68658. getClassName(): string;
  68659. /**
  68660. * Gets the custom effect used to render the particles
  68661. * @param blendMode Blend mode for which the effect should be retrieved
  68662. * @returns The effect
  68663. */
  68664. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68665. /**
  68666. * Sets the custom effect used to render the particles
  68667. * @param effect The effect to set
  68668. * @param blendMode Blend mode for which the effect should be set
  68669. */
  68670. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  68671. /** @hidden */
  68672. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  68673. /**
  68674. * Observable that will be called just before the particles are drawn
  68675. */
  68676. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  68677. /**
  68678. * Gets the name of the particle vertex shader
  68679. */
  68680. get vertexShaderName(): string;
  68681. private _colorGradientsTexture;
  68682. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68683. /**
  68684. * Adds a new color gradient
  68685. * @param gradient defines the gradient to use (between 0 and 1)
  68686. * @param color1 defines the color to affect to the specified gradient
  68687. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68688. * @returns the current particle system
  68689. */
  68690. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68691. private _refreshColorGradient;
  68692. /** Force the system to rebuild all gradients that need to be resync */
  68693. forceRefreshGradients(): void;
  68694. /**
  68695. * Remove a specific color gradient
  68696. * @param gradient defines the gradient to remove
  68697. * @returns the current particle system
  68698. */
  68699. removeColorGradient(gradient: number): GPUParticleSystem;
  68700. private _angularSpeedGradientsTexture;
  68701. private _sizeGradientsTexture;
  68702. private _velocityGradientsTexture;
  68703. private _limitVelocityGradientsTexture;
  68704. private _dragGradientsTexture;
  68705. private _addFactorGradient;
  68706. /**
  68707. * Adds a new size gradient
  68708. * @param gradient defines the gradient to use (between 0 and 1)
  68709. * @param factor defines the size factor to affect to the specified gradient
  68710. * @returns the current particle system
  68711. */
  68712. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68713. /**
  68714. * Remove a specific size gradient
  68715. * @param gradient defines the gradient to remove
  68716. * @returns the current particle system
  68717. */
  68718. removeSizeGradient(gradient: number): GPUParticleSystem;
  68719. private _refreshFactorGradient;
  68720. /**
  68721. * Adds a new angular speed gradient
  68722. * @param gradient defines the gradient to use (between 0 and 1)
  68723. * @param factor defines the angular speed to affect to the specified gradient
  68724. * @returns the current particle system
  68725. */
  68726. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68727. /**
  68728. * Remove a specific angular speed gradient
  68729. * @param gradient defines the gradient to remove
  68730. * @returns the current particle system
  68731. */
  68732. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68733. /**
  68734. * Adds a new velocity gradient
  68735. * @param gradient defines the gradient to use (between 0 and 1)
  68736. * @param factor defines the velocity to affect to the specified gradient
  68737. * @returns the current particle system
  68738. */
  68739. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68740. /**
  68741. * Remove a specific velocity gradient
  68742. * @param gradient defines the gradient to remove
  68743. * @returns the current particle system
  68744. */
  68745. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68746. /**
  68747. * Adds a new limit velocity gradient
  68748. * @param gradient defines the gradient to use (between 0 and 1)
  68749. * @param factor defines the limit velocity value to affect to the specified gradient
  68750. * @returns the current particle system
  68751. */
  68752. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68753. /**
  68754. * Remove a specific limit velocity gradient
  68755. * @param gradient defines the gradient to remove
  68756. * @returns the current particle system
  68757. */
  68758. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68759. /**
  68760. * Adds a new drag gradient
  68761. * @param gradient defines the gradient to use (between 0 and 1)
  68762. * @param factor defines the drag value to affect to the specified gradient
  68763. * @returns the current particle system
  68764. */
  68765. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68766. /**
  68767. * Remove a specific drag gradient
  68768. * @param gradient defines the gradient to remove
  68769. * @returns the current particle system
  68770. */
  68771. removeDragGradient(gradient: number): GPUParticleSystem;
  68772. /**
  68773. * Not supported by GPUParticleSystem
  68774. * @param gradient defines the gradient to use (between 0 and 1)
  68775. * @param factor defines the emit rate value to affect to the specified gradient
  68776. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68777. * @returns the current particle system
  68778. */
  68779. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68780. /**
  68781. * Not supported by GPUParticleSystem
  68782. * @param gradient defines the gradient to remove
  68783. * @returns the current particle system
  68784. */
  68785. removeEmitRateGradient(gradient: number): IParticleSystem;
  68786. /**
  68787. * Not supported by GPUParticleSystem
  68788. * @param gradient defines the gradient to use (between 0 and 1)
  68789. * @param factor defines the start size value to affect to the specified gradient
  68790. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68791. * @returns the current particle system
  68792. */
  68793. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68794. /**
  68795. * Not supported by GPUParticleSystem
  68796. * @param gradient defines the gradient to remove
  68797. * @returns the current particle system
  68798. */
  68799. removeStartSizeGradient(gradient: number): IParticleSystem;
  68800. /**
  68801. * Not supported by GPUParticleSystem
  68802. * @param gradient defines the gradient to use (between 0 and 1)
  68803. * @param min defines the color remap minimal range
  68804. * @param max defines the color remap maximal range
  68805. * @returns the current particle system
  68806. */
  68807. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68808. /**
  68809. * Not supported by GPUParticleSystem
  68810. * @param gradient defines the gradient to remove
  68811. * @returns the current particle system
  68812. */
  68813. removeColorRemapGradient(): IParticleSystem;
  68814. /**
  68815. * Not supported by GPUParticleSystem
  68816. * @param gradient defines the gradient to use (between 0 and 1)
  68817. * @param min defines the alpha remap minimal range
  68818. * @param max defines the alpha remap maximal range
  68819. * @returns the current particle system
  68820. */
  68821. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68822. /**
  68823. * Not supported by GPUParticleSystem
  68824. * @param gradient defines the gradient to remove
  68825. * @returns the current particle system
  68826. */
  68827. removeAlphaRemapGradient(): IParticleSystem;
  68828. /**
  68829. * Not supported by GPUParticleSystem
  68830. * @param gradient defines the gradient to use (between 0 and 1)
  68831. * @param color defines the color to affect to the specified gradient
  68832. * @returns the current particle system
  68833. */
  68834. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68835. /**
  68836. * Not supported by GPUParticleSystem
  68837. * @param gradient defines the gradient to remove
  68838. * @returns the current particle system
  68839. */
  68840. removeRampGradient(): IParticleSystem;
  68841. /**
  68842. * Not supported by GPUParticleSystem
  68843. * @returns the list of ramp gradients
  68844. */
  68845. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68846. /**
  68847. * Not supported by GPUParticleSystem
  68848. * Gets or sets a boolean indicating that ramp gradients must be used
  68849. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68850. */
  68851. get useRampGradients(): boolean;
  68852. set useRampGradients(value: boolean);
  68853. /**
  68854. * Not supported by GPUParticleSystem
  68855. * @param gradient defines the gradient to use (between 0 and 1)
  68856. * @param factor defines the life time factor to affect to the specified gradient
  68857. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68858. * @returns the current particle system
  68859. */
  68860. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68861. /**
  68862. * Not supported by GPUParticleSystem
  68863. * @param gradient defines the gradient to remove
  68864. * @returns the current particle system
  68865. */
  68866. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68867. /**
  68868. * Instantiates a GPU particle system.
  68869. * 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.
  68870. * @param name The name of the particle system
  68871. * @param options The options used to create the system
  68872. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  68873. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68874. * @param customEffect a custom effect used to change the way particles are rendered by default
  68875. */
  68876. constructor(name: string, options: Partial<{
  68877. capacity: number;
  68878. randomTextureSize: number;
  68879. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  68880. protected _reset(): void;
  68881. private _createUpdateVAO;
  68882. private _createRenderVAO;
  68883. private _initialize;
  68884. /** @hidden */
  68885. _recreateUpdateEffect(): void;
  68886. private _getEffect;
  68887. /**
  68888. * Fill the defines array according to the current settings of the particle system
  68889. * @param defines Array to be updated
  68890. * @param blendMode blend mode to take into account when updating the array
  68891. */
  68892. fillDefines(defines: Array<string>, blendMode?: number): void;
  68893. /**
  68894. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  68895. * @param uniforms Uniforms array to fill
  68896. * @param attributes Attributes array to fill
  68897. * @param samplers Samplers array to fill
  68898. */
  68899. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  68900. /** @hidden */
  68901. _recreateRenderEffect(): Effect;
  68902. /**
  68903. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68904. * @param preWarm defines if we are in the pre-warmimg phase
  68905. */
  68906. animate(preWarm?: boolean): void;
  68907. private _createFactorGradientTexture;
  68908. private _createSizeGradientTexture;
  68909. private _createAngularSpeedGradientTexture;
  68910. private _createVelocityGradientTexture;
  68911. private _createLimitVelocityGradientTexture;
  68912. private _createDragGradientTexture;
  68913. private _createColorGradientTexture;
  68914. /**
  68915. * Renders the particle system in its current state
  68916. * @param preWarm defines if the system should only update the particles but not render them
  68917. * @returns the current number of particles
  68918. */
  68919. render(preWarm?: boolean): number;
  68920. /**
  68921. * Rebuilds the particle system
  68922. */
  68923. rebuild(): void;
  68924. private _releaseBuffers;
  68925. private _releaseVAOs;
  68926. /**
  68927. * Disposes the particle system and free the associated resources
  68928. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68929. */
  68930. dispose(disposeTexture?: boolean): void;
  68931. /**
  68932. * Clones the particle system.
  68933. * @param name The name of the cloned object
  68934. * @param newEmitter The new emitter to use
  68935. * @returns the cloned particle system
  68936. */
  68937. clone(name: string, newEmitter: any): GPUParticleSystem;
  68938. /**
  68939. * Serializes the particle system to a JSON object
  68940. * @param serializeTexture defines if the texture must be serialized as well
  68941. * @returns the JSON object
  68942. */
  68943. serialize(serializeTexture?: boolean): any;
  68944. /**
  68945. * Parses a JSON object to create a GPU particle system.
  68946. * @param parsedParticleSystem The JSON object to parse
  68947. * @param sceneOrEngine The scene or the engine to create the particle system in
  68948. * @param rootUrl The root url to use to load external dependencies like texture
  68949. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68950. * @returns the parsed GPU particle system
  68951. */
  68952. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68953. }
  68954. }
  68955. declare module BABYLON {
  68956. /**
  68957. * Represents a set of particle systems working together to create a specific effect
  68958. */
  68959. export class ParticleSystemSet implements IDisposable {
  68960. /**
  68961. * Gets or sets base Assets URL
  68962. */
  68963. static BaseAssetsUrl: string;
  68964. private _emitterCreationOptions;
  68965. private _emitterNode;
  68966. /**
  68967. * Gets the particle system list
  68968. */
  68969. systems: IParticleSystem[];
  68970. /**
  68971. * Gets the emitter node used with this set
  68972. */
  68973. get emitterNode(): Nullable<TransformNode>;
  68974. /**
  68975. * Creates a new emitter mesh as a sphere
  68976. * @param options defines the options used to create the sphere
  68977. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68978. * @param scene defines the hosting scene
  68979. */
  68980. setEmitterAsSphere(options: {
  68981. diameter: number;
  68982. segments: number;
  68983. color: Color3;
  68984. }, renderingGroupId: number, scene: Scene): void;
  68985. /**
  68986. * Starts all particle systems of the set
  68987. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68988. */
  68989. start(emitter?: AbstractMesh): void;
  68990. /**
  68991. * Release all associated resources
  68992. */
  68993. dispose(): void;
  68994. /**
  68995. * Serialize the set into a JSON compatible object
  68996. * @param serializeTexture defines if the texture must be serialized as well
  68997. * @returns a JSON compatible representation of the set
  68998. */
  68999. serialize(serializeTexture?: boolean): any;
  69000. /**
  69001. * Parse a new ParticleSystemSet from a serialized source
  69002. * @param data defines a JSON compatible representation of the set
  69003. * @param scene defines the hosting scene
  69004. * @param gpu defines if we want GPU particles or CPU particles
  69005. * @returns a new ParticleSystemSet
  69006. */
  69007. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69008. }
  69009. }
  69010. declare module BABYLON {
  69011. /**
  69012. * This class is made for on one-liner static method to help creating particle system set.
  69013. */
  69014. export class ParticleHelper {
  69015. /**
  69016. * Gets or sets base Assets URL
  69017. */
  69018. static BaseAssetsUrl: string;
  69019. /** Define the Url to load snippets */
  69020. static SnippetUrl: string;
  69021. /**
  69022. * Create a default particle system that you can tweak
  69023. * @param emitter defines the emitter to use
  69024. * @param capacity defines the system capacity (default is 500 particles)
  69025. * @param scene defines the hosting scene
  69026. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69027. * @returns the new Particle system
  69028. */
  69029. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69030. /**
  69031. * This is the main static method (one-liner) of this helper to create different particle systems
  69032. * @param type This string represents the type to the particle system to create
  69033. * @param scene The scene where the particle system should live
  69034. * @param gpu If the system will use gpu
  69035. * @returns the ParticleSystemSet created
  69036. */
  69037. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69038. /**
  69039. * Static function used to export a particle system to a ParticleSystemSet variable.
  69040. * Please note that the emitter shape is not exported
  69041. * @param systems defines the particle systems to export
  69042. * @returns the created particle system set
  69043. */
  69044. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69045. /**
  69046. * Creates a particle system from a snippet saved in a remote file
  69047. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69048. * @param url defines the url to load from
  69049. * @param scene defines the hosting scene
  69050. * @param gpu If the system will use gpu
  69051. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69052. * @returns a promise that will resolve to the new particle system
  69053. */
  69054. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69055. /**
  69056. * Creates a particle system from a snippet saved by the particle system editor
  69057. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69058. * @param scene defines the hosting scene
  69059. * @param gpu If the system will use gpu
  69060. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69061. * @returns a promise that will resolve to the new particle system
  69062. */
  69063. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69064. }
  69065. }
  69066. declare module BABYLON {
  69067. interface Engine {
  69068. /**
  69069. * Create an effect to use with particle systems.
  69070. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69071. * the particle system for which you want to create a custom effect in the last parameter
  69072. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69073. * @param uniformsNames defines a list of attribute names
  69074. * @param samplers defines an array of string used to represent textures
  69075. * @param defines defines the string containing the defines to use to compile the shaders
  69076. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69077. * @param onCompiled defines a function to call when the effect creation is successful
  69078. * @param onError defines a function to call when the effect creation has failed
  69079. * @param particleSystem the particle system you want to create the effect for
  69080. * @returns the new Effect
  69081. */
  69082. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69083. }
  69084. interface Mesh {
  69085. /**
  69086. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69087. * @returns an array of IParticleSystem
  69088. */
  69089. getEmittedParticleSystems(): IParticleSystem[];
  69090. /**
  69091. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69092. * @returns an array of IParticleSystem
  69093. */
  69094. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69095. }
  69096. }
  69097. declare module BABYLON {
  69098. /** Defines the 4 color options */
  69099. export enum PointColor {
  69100. /** color value */
  69101. Color = 2,
  69102. /** uv value */
  69103. UV = 1,
  69104. /** random value */
  69105. Random = 0,
  69106. /** stated value */
  69107. Stated = 3
  69108. }
  69109. /**
  69110. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69111. * 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.
  69112. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69113. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69114. *
  69115. * Full documentation here : TO BE ENTERED
  69116. */
  69117. export class PointsCloudSystem implements IDisposable {
  69118. /**
  69119. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69120. * Example : var p = SPS.particles[i];
  69121. */
  69122. particles: CloudPoint[];
  69123. /**
  69124. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69125. */
  69126. nbParticles: number;
  69127. /**
  69128. * This a counter for your own usage. It's not set by any SPS functions.
  69129. */
  69130. counter: number;
  69131. /**
  69132. * The PCS name. This name is also given to the underlying mesh.
  69133. */
  69134. name: string;
  69135. /**
  69136. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69137. */
  69138. mesh: Mesh;
  69139. /**
  69140. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69141. * Please read :
  69142. */
  69143. vars: any;
  69144. /**
  69145. * @hidden
  69146. */
  69147. _size: number;
  69148. private _scene;
  69149. private _promises;
  69150. private _positions;
  69151. private _indices;
  69152. private _normals;
  69153. private _colors;
  69154. private _uvs;
  69155. private _indices32;
  69156. private _positions32;
  69157. private _colors32;
  69158. private _uvs32;
  69159. private _updatable;
  69160. private _isVisibilityBoxLocked;
  69161. private _alwaysVisible;
  69162. private _groups;
  69163. private _groupCounter;
  69164. private _computeParticleColor;
  69165. private _computeParticleTexture;
  69166. private _computeParticleRotation;
  69167. private _computeBoundingBox;
  69168. private _isReady;
  69169. /**
  69170. * Creates a PCS (Points Cloud System) object
  69171. * @param name (String) is the PCS name, this will be the underlying mesh name
  69172. * @param pointSize (number) is the size for each point
  69173. * @param scene (Scene) is the scene in which the PCS is added
  69174. * @param options defines the options of the PCS e.g.
  69175. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69176. */
  69177. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69178. updatable?: boolean;
  69179. });
  69180. /**
  69181. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69182. * If no points were added to the PCS, the returned mesh is just a single point.
  69183. * @returns a promise for the created mesh
  69184. */
  69185. buildMeshAsync(): Promise<Mesh>;
  69186. /**
  69187. * @hidden
  69188. */
  69189. private _buildMesh;
  69190. private _addParticle;
  69191. private _randomUnitVector;
  69192. private _getColorIndicesForCoord;
  69193. private _setPointsColorOrUV;
  69194. private _colorFromTexture;
  69195. private _calculateDensity;
  69196. /**
  69197. * Adds points to the PCS in random positions within a unit sphere
  69198. * @param nb (positive integer) the number of particles to be created from this model
  69199. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69200. * @returns the number of groups in the system
  69201. */
  69202. addPoints(nb: number, pointFunction?: any): number;
  69203. /**
  69204. * Adds points to the PCS from the surface of the model shape
  69205. * @param mesh is any Mesh object that will be used as a surface model for the points
  69206. * @param nb (positive integer) the number of particles to be created from this model
  69207. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69208. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69209. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69210. * @returns the number of groups in the system
  69211. */
  69212. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69213. /**
  69214. * Adds points to the PCS inside the model shape
  69215. * @param mesh is any Mesh object that will be used as a surface model for the points
  69216. * @param nb (positive integer) the number of particles to be created from this model
  69217. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69218. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69219. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69220. * @returns the number of groups in the system
  69221. */
  69222. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69223. /**
  69224. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69225. * This method calls `updateParticle()` for each particle of the SPS.
  69226. * For an animated SPS, it is usually called within the render loop.
  69227. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69228. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69229. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69230. * @returns the PCS.
  69231. */
  69232. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69233. /**
  69234. * Disposes the PCS.
  69235. */
  69236. dispose(): void;
  69237. /**
  69238. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69239. * doc :
  69240. * @returns the PCS.
  69241. */
  69242. refreshVisibleSize(): PointsCloudSystem;
  69243. /**
  69244. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69245. * @param size the size (float) of the visibility box
  69246. * note : this doesn't lock the PCS mesh bounding box.
  69247. * doc :
  69248. */
  69249. setVisibilityBox(size: number): void;
  69250. /**
  69251. * Gets whether the PCS is always visible or not
  69252. * doc :
  69253. */
  69254. get isAlwaysVisible(): boolean;
  69255. /**
  69256. * Sets the PCS as always visible or not
  69257. * doc :
  69258. */
  69259. set isAlwaysVisible(val: boolean);
  69260. /**
  69261. * Tells to `setParticles()` to compute the particle rotations or not
  69262. * Default value : false. The PCS is faster when it's set to false
  69263. * Note : particle rotations are only applied to parent particles
  69264. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69265. */
  69266. set computeParticleRotation(val: boolean);
  69267. /**
  69268. * Tells to `setParticles()` to compute the particle colors or not.
  69269. * Default value : true. The PCS is faster when it's set to false.
  69270. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69271. */
  69272. set computeParticleColor(val: boolean);
  69273. set computeParticleTexture(val: boolean);
  69274. /**
  69275. * Gets if `setParticles()` computes the particle colors or not.
  69276. * Default value : false. The PCS is faster when it's set to false.
  69277. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69278. */
  69279. get computeParticleColor(): boolean;
  69280. /**
  69281. * Gets if `setParticles()` computes the particle textures or not.
  69282. * Default value : false. The PCS is faster when it's set to false.
  69283. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69284. */
  69285. get computeParticleTexture(): boolean;
  69286. /**
  69287. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69288. */
  69289. set computeBoundingBox(val: boolean);
  69290. /**
  69291. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69292. */
  69293. get computeBoundingBox(): boolean;
  69294. /**
  69295. * This function does nothing. It may be overwritten to set all the particle first values.
  69296. * The PCS doesn't call this function, you may have to call it by your own.
  69297. * doc :
  69298. */
  69299. initParticles(): void;
  69300. /**
  69301. * This function does nothing. It may be overwritten to recycle a particle
  69302. * The PCS doesn't call this function, you can to call it
  69303. * doc :
  69304. * @param particle The particle to recycle
  69305. * @returns the recycled particle
  69306. */
  69307. recycleParticle(particle: CloudPoint): CloudPoint;
  69308. /**
  69309. * Updates a particle : this function should be overwritten by the user.
  69310. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69311. * doc :
  69312. * @example : just set a particle position or velocity and recycle conditions
  69313. * @param particle The particle to update
  69314. * @returns the updated particle
  69315. */
  69316. updateParticle(particle: CloudPoint): CloudPoint;
  69317. /**
  69318. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69319. * This does nothing and may be overwritten by the user.
  69320. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69321. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69322. * @param update the boolean update value actually passed to setParticles()
  69323. */
  69324. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69325. /**
  69326. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69327. * This will be passed three parameters.
  69328. * This does nothing and may be overwritten by the user.
  69329. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69330. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69331. * @param update the boolean update value actually passed to setParticles()
  69332. */
  69333. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69334. }
  69335. }
  69336. declare module BABYLON {
  69337. /**
  69338. * Represents one particle of a points cloud system.
  69339. */
  69340. export class CloudPoint {
  69341. /**
  69342. * particle global index
  69343. */
  69344. idx: number;
  69345. /**
  69346. * The color of the particle
  69347. */
  69348. color: Nullable<Color4>;
  69349. /**
  69350. * The world space position of the particle.
  69351. */
  69352. position: Vector3;
  69353. /**
  69354. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69355. */
  69356. rotation: Vector3;
  69357. /**
  69358. * The world space rotation quaternion of the particle.
  69359. */
  69360. rotationQuaternion: Nullable<Quaternion>;
  69361. /**
  69362. * The uv of the particle.
  69363. */
  69364. uv: Nullable<Vector2>;
  69365. /**
  69366. * The current speed of the particle.
  69367. */
  69368. velocity: Vector3;
  69369. /**
  69370. * The pivot point in the particle local space.
  69371. */
  69372. pivot: Vector3;
  69373. /**
  69374. * Must the particle be translated from its pivot point in its local space ?
  69375. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69376. * Default : false
  69377. */
  69378. translateFromPivot: boolean;
  69379. /**
  69380. * Index of this particle in the global "positions" array (Internal use)
  69381. * @hidden
  69382. */
  69383. _pos: number;
  69384. /**
  69385. * @hidden Index of this particle in the global "indices" array (Internal use)
  69386. */
  69387. _ind: number;
  69388. /**
  69389. * Group this particle belongs to
  69390. */
  69391. _group: PointsGroup;
  69392. /**
  69393. * Group id of this particle
  69394. */
  69395. groupId: number;
  69396. /**
  69397. * Index of the particle in its group id (Internal use)
  69398. */
  69399. idxInGroup: number;
  69400. /**
  69401. * @hidden Particle BoundingInfo object (Internal use)
  69402. */
  69403. _boundingInfo: BoundingInfo;
  69404. /**
  69405. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69406. */
  69407. _pcs: PointsCloudSystem;
  69408. /**
  69409. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69410. */
  69411. _stillInvisible: boolean;
  69412. /**
  69413. * @hidden Last computed particle rotation matrix
  69414. */
  69415. _rotationMatrix: number[];
  69416. /**
  69417. * Parent particle Id, if any.
  69418. * Default null.
  69419. */
  69420. parentId: Nullable<number>;
  69421. /**
  69422. * @hidden Internal global position in the PCS.
  69423. */
  69424. _globalPosition: Vector3;
  69425. /**
  69426. * Creates a Point Cloud object.
  69427. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69428. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69429. * @param group (PointsGroup) is the group the particle belongs to
  69430. * @param groupId (integer) is the group identifier in the PCS.
  69431. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69432. * @param pcs defines the PCS it is associated to
  69433. */
  69434. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69435. /**
  69436. * get point size
  69437. */
  69438. get size(): Vector3;
  69439. /**
  69440. * Set point size
  69441. */
  69442. set size(scale: Vector3);
  69443. /**
  69444. * Legacy support, changed quaternion to rotationQuaternion
  69445. */
  69446. get quaternion(): Nullable<Quaternion>;
  69447. /**
  69448. * Legacy support, changed quaternion to rotationQuaternion
  69449. */
  69450. set quaternion(q: Nullable<Quaternion>);
  69451. /**
  69452. * Returns a boolean. True if the particle intersects a mesh, else false
  69453. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69454. * @param target is the object (point or mesh) what the intersection is computed against
  69455. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69456. * @returns true if it intersects
  69457. */
  69458. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69459. /**
  69460. * get the rotation matrix of the particle
  69461. * @hidden
  69462. */
  69463. getRotationMatrix(m: Matrix): void;
  69464. }
  69465. /**
  69466. * Represents a group of points in a points cloud system
  69467. * * PCS internal tool, don't use it manually.
  69468. */
  69469. export class PointsGroup {
  69470. /**
  69471. * The group id
  69472. * @hidden
  69473. */
  69474. groupID: number;
  69475. /**
  69476. * image data for group (internal use)
  69477. * @hidden
  69478. */
  69479. _groupImageData: Nullable<ArrayBufferView>;
  69480. /**
  69481. * Image Width (internal use)
  69482. * @hidden
  69483. */
  69484. _groupImgWidth: number;
  69485. /**
  69486. * Image Height (internal use)
  69487. * @hidden
  69488. */
  69489. _groupImgHeight: number;
  69490. /**
  69491. * Custom position function (internal use)
  69492. * @hidden
  69493. */
  69494. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69495. /**
  69496. * density per facet for surface points
  69497. * @hidden
  69498. */
  69499. _groupDensity: number[];
  69500. /**
  69501. * Only when points are colored by texture carries pointer to texture list array
  69502. * @hidden
  69503. */
  69504. _textureNb: number;
  69505. /**
  69506. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69507. * PCS internal tool, don't use it manually.
  69508. * @hidden
  69509. */
  69510. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69511. }
  69512. }
  69513. declare module BABYLON {
  69514. interface Scene {
  69515. /** @hidden (Backing field) */
  69516. _physicsEngine: Nullable<IPhysicsEngine>;
  69517. /** @hidden */
  69518. _physicsTimeAccumulator: number;
  69519. /**
  69520. * Gets the current physics engine
  69521. * @returns a IPhysicsEngine or null if none attached
  69522. */
  69523. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69524. /**
  69525. * Enables physics to the current scene
  69526. * @param gravity defines the scene's gravity for the physics engine
  69527. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69528. * @return a boolean indicating if the physics engine was initialized
  69529. */
  69530. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69531. /**
  69532. * Disables and disposes the physics engine associated with the scene
  69533. */
  69534. disablePhysicsEngine(): void;
  69535. /**
  69536. * Gets a boolean indicating if there is an active physics engine
  69537. * @returns a boolean indicating if there is an active physics engine
  69538. */
  69539. isPhysicsEnabled(): boolean;
  69540. /**
  69541. * Deletes a physics compound impostor
  69542. * @param compound defines the compound to delete
  69543. */
  69544. deleteCompoundImpostor(compound: any): void;
  69545. /**
  69546. * An event triggered when physic simulation is about to be run
  69547. */
  69548. onBeforePhysicsObservable: Observable<Scene>;
  69549. /**
  69550. * An event triggered when physic simulation has been done
  69551. */
  69552. onAfterPhysicsObservable: Observable<Scene>;
  69553. }
  69554. interface AbstractMesh {
  69555. /** @hidden */
  69556. _physicsImpostor: Nullable<PhysicsImpostor>;
  69557. /**
  69558. * Gets or sets impostor used for physic simulation
  69559. * @see https://doc.babylonjs.com/features/physics_engine
  69560. */
  69561. physicsImpostor: Nullable<PhysicsImpostor>;
  69562. /**
  69563. * Gets the current physics impostor
  69564. * @see https://doc.babylonjs.com/features/physics_engine
  69565. * @returns a physics impostor or null
  69566. */
  69567. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69568. /** Apply a physic impulse to the mesh
  69569. * @param force defines the force to apply
  69570. * @param contactPoint defines where to apply the force
  69571. * @returns the current mesh
  69572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69573. */
  69574. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69575. /**
  69576. * Creates a physic joint between two meshes
  69577. * @param otherMesh defines the other mesh to use
  69578. * @param pivot1 defines the pivot to use on this mesh
  69579. * @param pivot2 defines the pivot to use on the other mesh
  69580. * @param options defines additional options (can be plugin dependent)
  69581. * @returns the current mesh
  69582. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69583. */
  69584. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69585. /** @hidden */
  69586. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69587. }
  69588. /**
  69589. * Defines the physics engine scene component responsible to manage a physics engine
  69590. */
  69591. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69592. /**
  69593. * The component name helpful to identify the component in the list of scene components.
  69594. */
  69595. readonly name: string;
  69596. /**
  69597. * The scene the component belongs to.
  69598. */
  69599. scene: Scene;
  69600. /**
  69601. * Creates a new instance of the component for the given scene
  69602. * @param scene Defines the scene to register the component in
  69603. */
  69604. constructor(scene: Scene);
  69605. /**
  69606. * Registers the component in a given scene
  69607. */
  69608. register(): void;
  69609. /**
  69610. * Rebuilds the elements related to this component in case of
  69611. * context lost for instance.
  69612. */
  69613. rebuild(): void;
  69614. /**
  69615. * Disposes the component and the associated ressources
  69616. */
  69617. dispose(): void;
  69618. }
  69619. }
  69620. declare module BABYLON {
  69621. /**
  69622. * A helper for physics simulations
  69623. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69624. */
  69625. export class PhysicsHelper {
  69626. private _scene;
  69627. private _physicsEngine;
  69628. /**
  69629. * Initializes the Physics helper
  69630. * @param scene Babylon.js scene
  69631. */
  69632. constructor(scene: Scene);
  69633. /**
  69634. * Applies a radial explosion impulse
  69635. * @param origin the origin of the explosion
  69636. * @param radiusOrEventOptions the radius or the options of radial explosion
  69637. * @param strength the explosion strength
  69638. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69639. * @returns A physics radial explosion event, or null
  69640. */
  69641. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69642. /**
  69643. * Applies a radial explosion force
  69644. * @param origin the origin of the explosion
  69645. * @param radiusOrEventOptions the radius or the options of radial explosion
  69646. * @param strength the explosion strength
  69647. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69648. * @returns A physics radial explosion event, or null
  69649. */
  69650. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69651. /**
  69652. * Creates a gravitational field
  69653. * @param origin the origin of the explosion
  69654. * @param radiusOrEventOptions the radius or the options of radial explosion
  69655. * @param strength the explosion strength
  69656. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69657. * @returns A physics gravitational field event, or null
  69658. */
  69659. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69660. /**
  69661. * Creates a physics updraft event
  69662. * @param origin the origin of the updraft
  69663. * @param radiusOrEventOptions the radius or the options of the updraft
  69664. * @param strength the strength of the updraft
  69665. * @param height the height of the updraft
  69666. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69667. * @returns A physics updraft event, or null
  69668. */
  69669. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69670. /**
  69671. * Creates a physics vortex event
  69672. * @param origin the of the vortex
  69673. * @param radiusOrEventOptions the radius or the options of the vortex
  69674. * @param strength the strength of the vortex
  69675. * @param height the height of the vortex
  69676. * @returns a Physics vortex event, or null
  69677. * A physics vortex event or null
  69678. */
  69679. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69680. }
  69681. /**
  69682. * Represents a physics radial explosion event
  69683. */
  69684. class PhysicsRadialExplosionEvent {
  69685. private _scene;
  69686. private _options;
  69687. private _sphere;
  69688. private _dataFetched;
  69689. /**
  69690. * Initializes a radial explosioin event
  69691. * @param _scene BabylonJS scene
  69692. * @param _options The options for the vortex event
  69693. */
  69694. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69695. /**
  69696. * Returns the data related to the radial explosion event (sphere).
  69697. * @returns The radial explosion event data
  69698. */
  69699. getData(): PhysicsRadialExplosionEventData;
  69700. /**
  69701. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69702. * @param impostor A physics imposter
  69703. * @param origin the origin of the explosion
  69704. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69705. */
  69706. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69707. /**
  69708. * Triggers affecterd impostors callbacks
  69709. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69710. */
  69711. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69712. /**
  69713. * Disposes the sphere.
  69714. * @param force Specifies if the sphere should be disposed by force
  69715. */
  69716. dispose(force?: boolean): void;
  69717. /*** Helpers ***/
  69718. private _prepareSphere;
  69719. private _intersectsWithSphere;
  69720. }
  69721. /**
  69722. * Represents a gravitational field event
  69723. */
  69724. class PhysicsGravitationalFieldEvent {
  69725. private _physicsHelper;
  69726. private _scene;
  69727. private _origin;
  69728. private _options;
  69729. private _tickCallback;
  69730. private _sphere;
  69731. private _dataFetched;
  69732. /**
  69733. * Initializes the physics gravitational field event
  69734. * @param _physicsHelper A physics helper
  69735. * @param _scene BabylonJS scene
  69736. * @param _origin The origin position of the gravitational field event
  69737. * @param _options The options for the vortex event
  69738. */
  69739. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69740. /**
  69741. * Returns the data related to the gravitational field event (sphere).
  69742. * @returns A gravitational field event
  69743. */
  69744. getData(): PhysicsGravitationalFieldEventData;
  69745. /**
  69746. * Enables the gravitational field.
  69747. */
  69748. enable(): void;
  69749. /**
  69750. * Disables the gravitational field.
  69751. */
  69752. disable(): void;
  69753. /**
  69754. * Disposes the sphere.
  69755. * @param force The force to dispose from the gravitational field event
  69756. */
  69757. dispose(force?: boolean): void;
  69758. private _tick;
  69759. }
  69760. /**
  69761. * Represents a physics updraft event
  69762. */
  69763. class PhysicsUpdraftEvent {
  69764. private _scene;
  69765. private _origin;
  69766. private _options;
  69767. private _physicsEngine;
  69768. private _originTop;
  69769. private _originDirection;
  69770. private _tickCallback;
  69771. private _cylinder;
  69772. private _cylinderPosition;
  69773. private _dataFetched;
  69774. /**
  69775. * Initializes the physics updraft event
  69776. * @param _scene BabylonJS scene
  69777. * @param _origin The origin position of the updraft
  69778. * @param _options The options for the updraft event
  69779. */
  69780. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69781. /**
  69782. * Returns the data related to the updraft event (cylinder).
  69783. * @returns A physics updraft event
  69784. */
  69785. getData(): PhysicsUpdraftEventData;
  69786. /**
  69787. * Enables the updraft.
  69788. */
  69789. enable(): void;
  69790. /**
  69791. * Disables the updraft.
  69792. */
  69793. disable(): void;
  69794. /**
  69795. * Disposes the cylinder.
  69796. * @param force Specifies if the updraft should be disposed by force
  69797. */
  69798. dispose(force?: boolean): void;
  69799. private getImpostorHitData;
  69800. private _tick;
  69801. /*** Helpers ***/
  69802. private _prepareCylinder;
  69803. private _intersectsWithCylinder;
  69804. }
  69805. /**
  69806. * Represents a physics vortex event
  69807. */
  69808. class PhysicsVortexEvent {
  69809. private _scene;
  69810. private _origin;
  69811. private _options;
  69812. private _physicsEngine;
  69813. private _originTop;
  69814. private _tickCallback;
  69815. private _cylinder;
  69816. private _cylinderPosition;
  69817. private _dataFetched;
  69818. /**
  69819. * Initializes the physics vortex event
  69820. * @param _scene The BabylonJS scene
  69821. * @param _origin The origin position of the vortex
  69822. * @param _options The options for the vortex event
  69823. */
  69824. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69825. /**
  69826. * Returns the data related to the vortex event (cylinder).
  69827. * @returns The physics vortex event data
  69828. */
  69829. getData(): PhysicsVortexEventData;
  69830. /**
  69831. * Enables the vortex.
  69832. */
  69833. enable(): void;
  69834. /**
  69835. * Disables the cortex.
  69836. */
  69837. disable(): void;
  69838. /**
  69839. * Disposes the sphere.
  69840. * @param force
  69841. */
  69842. dispose(force?: boolean): void;
  69843. private getImpostorHitData;
  69844. private _tick;
  69845. /*** Helpers ***/
  69846. private _prepareCylinder;
  69847. private _intersectsWithCylinder;
  69848. }
  69849. /**
  69850. * Options fot the radial explosion event
  69851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69852. */
  69853. export class PhysicsRadialExplosionEventOptions {
  69854. /**
  69855. * The radius of the sphere for the radial explosion.
  69856. */
  69857. radius: number;
  69858. /**
  69859. * The strenth of the explosion.
  69860. */
  69861. strength: number;
  69862. /**
  69863. * The strenght of the force in correspondence to the distance of the affected object
  69864. */
  69865. falloff: PhysicsRadialImpulseFalloff;
  69866. /**
  69867. * Sphere options for the radial explosion.
  69868. */
  69869. sphere: {
  69870. segments: number;
  69871. diameter: number;
  69872. };
  69873. /**
  69874. * Sphere options for the radial explosion.
  69875. */
  69876. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69877. }
  69878. /**
  69879. * Options fot the updraft event
  69880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69881. */
  69882. export class PhysicsUpdraftEventOptions {
  69883. /**
  69884. * The radius of the cylinder for the vortex
  69885. */
  69886. radius: number;
  69887. /**
  69888. * The strenth of the updraft.
  69889. */
  69890. strength: number;
  69891. /**
  69892. * The height of the cylinder for the updraft.
  69893. */
  69894. height: number;
  69895. /**
  69896. * The mode for the the updraft.
  69897. */
  69898. updraftMode: PhysicsUpdraftMode;
  69899. }
  69900. /**
  69901. * Options fot the vortex event
  69902. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69903. */
  69904. export class PhysicsVortexEventOptions {
  69905. /**
  69906. * The radius of the cylinder for the vortex
  69907. */
  69908. radius: number;
  69909. /**
  69910. * The strenth of the vortex.
  69911. */
  69912. strength: number;
  69913. /**
  69914. * The height of the cylinder for the vortex.
  69915. */
  69916. height: number;
  69917. /**
  69918. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69919. */
  69920. centripetalForceThreshold: number;
  69921. /**
  69922. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69923. */
  69924. centripetalForceMultiplier: number;
  69925. /**
  69926. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69927. */
  69928. centrifugalForceMultiplier: number;
  69929. /**
  69930. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69931. */
  69932. updraftForceMultiplier: number;
  69933. }
  69934. /**
  69935. * The strenght of the force in correspondence to the distance of the affected object
  69936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69937. */
  69938. export enum PhysicsRadialImpulseFalloff {
  69939. /** Defines that impulse is constant in strength across it's whole radius */
  69940. Constant = 0,
  69941. /** Defines that impulse gets weaker if it's further from the origin */
  69942. Linear = 1
  69943. }
  69944. /**
  69945. * The strength of the force in correspondence to the distance of the affected object
  69946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69947. */
  69948. export enum PhysicsUpdraftMode {
  69949. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69950. Center = 0,
  69951. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69952. Perpendicular = 1
  69953. }
  69954. /**
  69955. * Interface for a physics hit data
  69956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69957. */
  69958. export interface PhysicsHitData {
  69959. /**
  69960. * The force applied at the contact point
  69961. */
  69962. force: Vector3;
  69963. /**
  69964. * The contact point
  69965. */
  69966. contactPoint: Vector3;
  69967. /**
  69968. * The distance from the origin to the contact point
  69969. */
  69970. distanceFromOrigin: number;
  69971. }
  69972. /**
  69973. * Interface for radial explosion event data
  69974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69975. */
  69976. export interface PhysicsRadialExplosionEventData {
  69977. /**
  69978. * A sphere used for the radial explosion event
  69979. */
  69980. sphere: Mesh;
  69981. }
  69982. /**
  69983. * Interface for gravitational field event data
  69984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69985. */
  69986. export interface PhysicsGravitationalFieldEventData {
  69987. /**
  69988. * A sphere mesh used for the gravitational field event
  69989. */
  69990. sphere: Mesh;
  69991. }
  69992. /**
  69993. * Interface for updraft event data
  69994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69995. */
  69996. export interface PhysicsUpdraftEventData {
  69997. /**
  69998. * A cylinder used for the updraft event
  69999. */
  70000. cylinder: Mesh;
  70001. }
  70002. /**
  70003. * Interface for vortex event data
  70004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70005. */
  70006. export interface PhysicsVortexEventData {
  70007. /**
  70008. * A cylinder used for the vortex event
  70009. */
  70010. cylinder: Mesh;
  70011. }
  70012. /**
  70013. * Interface for an affected physics impostor
  70014. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70015. */
  70016. export interface PhysicsAffectedImpostorWithData {
  70017. /**
  70018. * The impostor affected by the effect
  70019. */
  70020. impostor: PhysicsImpostor;
  70021. /**
  70022. * The data about the hit/horce from the explosion
  70023. */
  70024. hitData: PhysicsHitData;
  70025. }
  70026. }
  70027. declare module BABYLON {
  70028. /** @hidden */
  70029. export var blackAndWhitePixelShader: {
  70030. name: string;
  70031. shader: string;
  70032. };
  70033. }
  70034. declare module BABYLON {
  70035. /**
  70036. * Post process used to render in black and white
  70037. */
  70038. export class BlackAndWhitePostProcess extends PostProcess {
  70039. /**
  70040. * Linear about to convert he result to black and white (default: 1)
  70041. */
  70042. degree: number;
  70043. /**
  70044. * Gets a string identifying the name of the class
  70045. * @returns "BlackAndWhitePostProcess" string
  70046. */
  70047. getClassName(): string;
  70048. /**
  70049. * Creates a black and white post process
  70050. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70051. * @param name The name of the effect.
  70052. * @param options The required width/height ratio to downsize to before computing the render pass.
  70053. * @param camera The camera to apply the render pass to.
  70054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70055. * @param engine The engine which the post process will be applied. (default: current engine)
  70056. * @param reusable If the post process can be reused on the same frame. (default: false)
  70057. */
  70058. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70059. /** @hidden */
  70060. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70061. }
  70062. }
  70063. declare module BABYLON {
  70064. /**
  70065. * This represents a set of one or more post processes in Babylon.
  70066. * A post process can be used to apply a shader to a texture after it is rendered.
  70067. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70068. */
  70069. export class PostProcessRenderEffect {
  70070. private _postProcesses;
  70071. private _getPostProcesses;
  70072. private _singleInstance;
  70073. private _cameras;
  70074. private _indicesForCamera;
  70075. /**
  70076. * Name of the effect
  70077. * @hidden
  70078. */
  70079. _name: string;
  70080. /**
  70081. * Instantiates a post process render effect.
  70082. * A post process can be used to apply a shader to a texture after it is rendered.
  70083. * @param engine The engine the effect is tied to
  70084. * @param name The name of the effect
  70085. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70086. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70087. */
  70088. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70089. /**
  70090. * Checks if all the post processes in the effect are supported.
  70091. */
  70092. get isSupported(): boolean;
  70093. /**
  70094. * Updates the current state of the effect
  70095. * @hidden
  70096. */
  70097. _update(): void;
  70098. /**
  70099. * Attaches the effect on cameras
  70100. * @param cameras The camera to attach to.
  70101. * @hidden
  70102. */
  70103. _attachCameras(cameras: Camera): void;
  70104. /**
  70105. * Attaches the effect on cameras
  70106. * @param cameras The camera to attach to.
  70107. * @hidden
  70108. */
  70109. _attachCameras(cameras: Camera[]): void;
  70110. /**
  70111. * Detaches the effect on cameras
  70112. * @param cameras The camera to detatch from.
  70113. * @hidden
  70114. */
  70115. _detachCameras(cameras: Camera): void;
  70116. /**
  70117. * Detatches the effect on cameras
  70118. * @param cameras The camera to detatch from.
  70119. * @hidden
  70120. */
  70121. _detachCameras(cameras: Camera[]): void;
  70122. /**
  70123. * Enables the effect on given cameras
  70124. * @param cameras The camera to enable.
  70125. * @hidden
  70126. */
  70127. _enable(cameras: Camera): void;
  70128. /**
  70129. * Enables the effect on given cameras
  70130. * @param cameras The camera to enable.
  70131. * @hidden
  70132. */
  70133. _enable(cameras: Nullable<Camera[]>): void;
  70134. /**
  70135. * Disables the effect on the given cameras
  70136. * @param cameras The camera to disable.
  70137. * @hidden
  70138. */
  70139. _disable(cameras: Camera): void;
  70140. /**
  70141. * Disables the effect on the given cameras
  70142. * @param cameras The camera to disable.
  70143. * @hidden
  70144. */
  70145. _disable(cameras: Nullable<Camera[]>): void;
  70146. /**
  70147. * Gets a list of the post processes contained in the effect.
  70148. * @param camera The camera to get the post processes on.
  70149. * @returns The list of the post processes in the effect.
  70150. */
  70151. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70152. }
  70153. }
  70154. declare module BABYLON {
  70155. /** @hidden */
  70156. export var extractHighlightsPixelShader: {
  70157. name: string;
  70158. shader: string;
  70159. };
  70160. }
  70161. declare module BABYLON {
  70162. /**
  70163. * 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.
  70164. */
  70165. export class ExtractHighlightsPostProcess extends PostProcess {
  70166. /**
  70167. * The luminance threshold, pixels below this value will be set to black.
  70168. */
  70169. threshold: number;
  70170. /** @hidden */
  70171. _exposure: number;
  70172. /**
  70173. * Post process which has the input texture to be used when performing highlight extraction
  70174. * @hidden
  70175. */
  70176. _inputPostProcess: Nullable<PostProcess>;
  70177. /**
  70178. * Gets a string identifying the name of the class
  70179. * @returns "ExtractHighlightsPostProcess" string
  70180. */
  70181. getClassName(): string;
  70182. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70183. }
  70184. }
  70185. declare module BABYLON {
  70186. /** @hidden */
  70187. export var bloomMergePixelShader: {
  70188. name: string;
  70189. shader: string;
  70190. };
  70191. }
  70192. declare module BABYLON {
  70193. /**
  70194. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70195. */
  70196. export class BloomMergePostProcess extends PostProcess {
  70197. /** Weight of the bloom to be added to the original input. */
  70198. weight: number;
  70199. /**
  70200. * Gets a string identifying the name of the class
  70201. * @returns "BloomMergePostProcess" string
  70202. */
  70203. getClassName(): string;
  70204. /**
  70205. * Creates a new instance of @see BloomMergePostProcess
  70206. * @param name The name of the effect.
  70207. * @param originalFromInput Post process which's input will be used for the merge.
  70208. * @param blurred Blurred highlights post process which's output will be used.
  70209. * @param weight Weight of the bloom to be added to the original input.
  70210. * @param options The required width/height ratio to downsize to before computing the render pass.
  70211. * @param camera The camera to apply the render pass to.
  70212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70213. * @param engine The engine which the post process will be applied. (default: current engine)
  70214. * @param reusable If the post process can be reused on the same frame. (default: false)
  70215. * @param textureType Type of textures used when performing the post process. (default: 0)
  70216. * @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)
  70217. */
  70218. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70219. /** Weight of the bloom to be added to the original input. */
  70220. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70221. }
  70222. }
  70223. declare module BABYLON {
  70224. /**
  70225. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70226. */
  70227. export class BloomEffect extends PostProcessRenderEffect {
  70228. private bloomScale;
  70229. /**
  70230. * @hidden Internal
  70231. */
  70232. _effects: Array<PostProcess>;
  70233. /**
  70234. * @hidden Internal
  70235. */
  70236. _downscale: ExtractHighlightsPostProcess;
  70237. private _blurX;
  70238. private _blurY;
  70239. private _merge;
  70240. /**
  70241. * The luminance threshold to find bright areas of the image to bloom.
  70242. */
  70243. get threshold(): number;
  70244. set threshold(value: number);
  70245. /**
  70246. * The strength of the bloom.
  70247. */
  70248. get weight(): number;
  70249. set weight(value: number);
  70250. /**
  70251. * Specifies the size of the bloom blur kernel, relative to the final output size
  70252. */
  70253. get kernel(): number;
  70254. set kernel(value: number);
  70255. /**
  70256. * Creates a new instance of @see BloomEffect
  70257. * @param scene The scene the effect belongs to.
  70258. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70259. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70260. * @param bloomWeight The the strength of bloom.
  70261. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70262. * @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)
  70263. */
  70264. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70265. /**
  70266. * Disposes each of the internal effects for a given camera.
  70267. * @param camera The camera to dispose the effect on.
  70268. */
  70269. disposeEffects(camera: Camera): void;
  70270. /**
  70271. * @hidden Internal
  70272. */
  70273. _updateEffects(): void;
  70274. /**
  70275. * Internal
  70276. * @returns if all the contained post processes are ready.
  70277. * @hidden
  70278. */
  70279. _isReady(): boolean;
  70280. }
  70281. }
  70282. declare module BABYLON {
  70283. /** @hidden */
  70284. export var chromaticAberrationPixelShader: {
  70285. name: string;
  70286. shader: string;
  70287. };
  70288. }
  70289. declare module BABYLON {
  70290. /**
  70291. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70292. */
  70293. export class ChromaticAberrationPostProcess extends PostProcess {
  70294. /**
  70295. * The amount of seperation of rgb channels (default: 30)
  70296. */
  70297. aberrationAmount: number;
  70298. /**
  70299. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70300. */
  70301. radialIntensity: number;
  70302. /**
  70303. * 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))
  70304. */
  70305. direction: Vector2;
  70306. /**
  70307. * 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))
  70308. */
  70309. centerPosition: Vector2;
  70310. /** The width of the screen to apply the effect on */
  70311. screenWidth: number;
  70312. /** The height of the screen to apply the effect on */
  70313. screenHeight: number;
  70314. /**
  70315. * Gets a string identifying the name of the class
  70316. * @returns "ChromaticAberrationPostProcess" string
  70317. */
  70318. getClassName(): string;
  70319. /**
  70320. * Creates a new instance ChromaticAberrationPostProcess
  70321. * @param name The name of the effect.
  70322. * @param screenWidth The width of the screen to apply the effect on.
  70323. * @param screenHeight The height of the screen to apply the effect on.
  70324. * @param options The required width/height ratio to downsize to before computing the render pass.
  70325. * @param camera The camera to apply the render pass to.
  70326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70327. * @param engine The engine which the post process will be applied. (default: current engine)
  70328. * @param reusable If the post process can be reused on the same frame. (default: false)
  70329. * @param textureType Type of textures used when performing the post process. (default: 0)
  70330. * @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)
  70331. */
  70332. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70333. /** @hidden */
  70334. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70335. }
  70336. }
  70337. declare module BABYLON {
  70338. /** @hidden */
  70339. export var circleOfConfusionPixelShader: {
  70340. name: string;
  70341. shader: string;
  70342. };
  70343. }
  70344. declare module BABYLON {
  70345. /**
  70346. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70347. */
  70348. export class CircleOfConfusionPostProcess extends PostProcess {
  70349. /**
  70350. * 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.
  70351. */
  70352. lensSize: number;
  70353. /**
  70354. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70355. */
  70356. fStop: number;
  70357. /**
  70358. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70359. */
  70360. focusDistance: number;
  70361. /**
  70362. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70363. */
  70364. focalLength: number;
  70365. /**
  70366. * Gets a string identifying the name of the class
  70367. * @returns "CircleOfConfusionPostProcess" string
  70368. */
  70369. getClassName(): string;
  70370. private _depthTexture;
  70371. /**
  70372. * Creates a new instance CircleOfConfusionPostProcess
  70373. * @param name The name of the effect.
  70374. * @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.
  70375. * @param options The required width/height ratio to downsize to before computing the render pass.
  70376. * @param camera The camera to apply the render pass to.
  70377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70378. * @param engine The engine which the post process will be applied. (default: current engine)
  70379. * @param reusable If the post process can be reused on the same frame. (default: false)
  70380. * @param textureType Type of textures used when performing the post process. (default: 0)
  70381. * @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)
  70382. */
  70383. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70384. /**
  70385. * 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.
  70386. */
  70387. set depthTexture(value: RenderTargetTexture);
  70388. }
  70389. }
  70390. declare module BABYLON {
  70391. /** @hidden */
  70392. export var colorCorrectionPixelShader: {
  70393. name: string;
  70394. shader: string;
  70395. };
  70396. }
  70397. declare module BABYLON {
  70398. /**
  70399. *
  70400. * This post-process allows the modification of rendered colors by using
  70401. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70402. *
  70403. * The object needs to be provided an url to a texture containing the color
  70404. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70405. * Use an image editing software to tweak the LUT to match your needs.
  70406. *
  70407. * For an example of a color LUT, see here:
  70408. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70409. * For explanations on color grading, see here:
  70410. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70411. *
  70412. */
  70413. export class ColorCorrectionPostProcess extends PostProcess {
  70414. private _colorTableTexture;
  70415. /**
  70416. * Gets the color table url used to create the LUT texture
  70417. */
  70418. colorTableUrl: string;
  70419. /**
  70420. * Gets a string identifying the name of the class
  70421. * @returns "ColorCorrectionPostProcess" string
  70422. */
  70423. getClassName(): string;
  70424. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70425. /** @hidden */
  70426. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70427. }
  70428. }
  70429. declare module BABYLON {
  70430. /** @hidden */
  70431. export var convolutionPixelShader: {
  70432. name: string;
  70433. shader: string;
  70434. };
  70435. }
  70436. declare module BABYLON {
  70437. /**
  70438. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70439. * input texture to perform effects such as edge detection or sharpening
  70440. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70441. */
  70442. export class ConvolutionPostProcess extends PostProcess {
  70443. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70444. kernel: number[];
  70445. /**
  70446. * Gets a string identifying the name of the class
  70447. * @returns "ConvolutionPostProcess" string
  70448. */
  70449. getClassName(): string;
  70450. /**
  70451. * Creates a new instance ConvolutionPostProcess
  70452. * @param name The name of the effect.
  70453. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70454. * @param options The required width/height ratio to downsize to before computing the render pass.
  70455. * @param camera The camera to apply the render pass to.
  70456. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70457. * @param engine The engine which the post process will be applied. (default: current engine)
  70458. * @param reusable If the post process can be reused on the same frame. (default: false)
  70459. * @param textureType Type of textures used when performing the post process. (default: 0)
  70460. */
  70461. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70462. /** @hidden */
  70463. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70464. /**
  70465. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70466. */
  70467. static EdgeDetect0Kernel: number[];
  70468. /**
  70469. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70470. */
  70471. static EdgeDetect1Kernel: number[];
  70472. /**
  70473. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70474. */
  70475. static EdgeDetect2Kernel: number[];
  70476. /**
  70477. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70478. */
  70479. static SharpenKernel: number[];
  70480. /**
  70481. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70482. */
  70483. static EmbossKernel: number[];
  70484. /**
  70485. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70486. */
  70487. static GaussianKernel: number[];
  70488. }
  70489. }
  70490. declare module BABYLON {
  70491. /**
  70492. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70493. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70494. * based on samples that have a large difference in distance than the center pixel.
  70495. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70496. */
  70497. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70498. /**
  70499. * The direction the blur should be applied
  70500. */
  70501. direction: Vector2;
  70502. /**
  70503. * Gets a string identifying the name of the class
  70504. * @returns "DepthOfFieldBlurPostProcess" string
  70505. */
  70506. getClassName(): string;
  70507. /**
  70508. * Creates a new instance CircleOfConfusionPostProcess
  70509. * @param name The name of the effect.
  70510. * @param scene The scene the effect belongs to.
  70511. * @param direction The direction the blur should be applied.
  70512. * @param kernel The size of the kernel used to blur.
  70513. * @param options The required width/height ratio to downsize to before computing the render pass.
  70514. * @param camera The camera to apply the render pass to.
  70515. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70516. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70518. * @param engine The engine which the post process will be applied. (default: current engine)
  70519. * @param reusable If the post process can be reused on the same frame. (default: false)
  70520. * @param textureType Type of textures used when performing the post process. (default: 0)
  70521. * @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)
  70522. */
  70523. 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);
  70524. }
  70525. }
  70526. declare module BABYLON {
  70527. /** @hidden */
  70528. export var depthOfFieldMergePixelShader: {
  70529. name: string;
  70530. shader: string;
  70531. };
  70532. }
  70533. declare module BABYLON {
  70534. /**
  70535. * Options to be set when merging outputs from the default pipeline.
  70536. */
  70537. export class DepthOfFieldMergePostProcessOptions {
  70538. /**
  70539. * The original image to merge on top of
  70540. */
  70541. originalFromInput: PostProcess;
  70542. /**
  70543. * Parameters to perform the merge of the depth of field effect
  70544. */
  70545. depthOfField?: {
  70546. circleOfConfusion: PostProcess;
  70547. blurSteps: Array<PostProcess>;
  70548. };
  70549. /**
  70550. * Parameters to perform the merge of bloom effect
  70551. */
  70552. bloom?: {
  70553. blurred: PostProcess;
  70554. weight: number;
  70555. };
  70556. }
  70557. /**
  70558. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70559. */
  70560. export class DepthOfFieldMergePostProcess extends PostProcess {
  70561. private blurSteps;
  70562. /**
  70563. * Gets a string identifying the name of the class
  70564. * @returns "DepthOfFieldMergePostProcess" string
  70565. */
  70566. getClassName(): string;
  70567. /**
  70568. * Creates a new instance of DepthOfFieldMergePostProcess
  70569. * @param name The name of the effect.
  70570. * @param originalFromInput Post process which's input will be used for the merge.
  70571. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70572. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70573. * @param options The required width/height ratio to downsize to before computing the render pass.
  70574. * @param camera The camera to apply the render pass to.
  70575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70576. * @param engine The engine which the post process will be applied. (default: current engine)
  70577. * @param reusable If the post process can be reused on the same frame. (default: false)
  70578. * @param textureType Type of textures used when performing the post process. (default: 0)
  70579. * @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)
  70580. */
  70581. 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);
  70582. /**
  70583. * Updates the effect with the current post process compile time values and recompiles the shader.
  70584. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70585. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70586. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70587. * @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
  70588. * @param onCompiled Called when the shader has been compiled.
  70589. * @param onError Called if there is an error when compiling a shader.
  70590. */
  70591. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70592. }
  70593. }
  70594. declare module BABYLON {
  70595. /**
  70596. * Specifies the level of max blur that should be applied when using the depth of field effect
  70597. */
  70598. export enum DepthOfFieldEffectBlurLevel {
  70599. /**
  70600. * Subtle blur
  70601. */
  70602. Low = 0,
  70603. /**
  70604. * Medium blur
  70605. */
  70606. Medium = 1,
  70607. /**
  70608. * Large blur
  70609. */
  70610. High = 2
  70611. }
  70612. /**
  70613. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70614. */
  70615. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70616. private _circleOfConfusion;
  70617. /**
  70618. * @hidden Internal, blurs from high to low
  70619. */
  70620. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70621. private _depthOfFieldBlurY;
  70622. private _dofMerge;
  70623. /**
  70624. * @hidden Internal post processes in depth of field effect
  70625. */
  70626. _effects: Array<PostProcess>;
  70627. /**
  70628. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70629. */
  70630. set focalLength(value: number);
  70631. get focalLength(): number;
  70632. /**
  70633. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70634. */
  70635. set fStop(value: number);
  70636. get fStop(): number;
  70637. /**
  70638. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70639. */
  70640. set focusDistance(value: number);
  70641. get focusDistance(): number;
  70642. /**
  70643. * 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.
  70644. */
  70645. set lensSize(value: number);
  70646. get lensSize(): number;
  70647. /**
  70648. * Creates a new instance DepthOfFieldEffect
  70649. * @param scene The scene the effect belongs to.
  70650. * @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.
  70651. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70652. * @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)
  70653. */
  70654. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70655. /**
  70656. * Get the current class name of the current effet
  70657. * @returns "DepthOfFieldEffect"
  70658. */
  70659. getClassName(): string;
  70660. /**
  70661. * 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.
  70662. */
  70663. set depthTexture(value: RenderTargetTexture);
  70664. /**
  70665. * Disposes each of the internal effects for a given camera.
  70666. * @param camera The camera to dispose the effect on.
  70667. */
  70668. disposeEffects(camera: Camera): void;
  70669. /**
  70670. * @hidden Internal
  70671. */
  70672. _updateEffects(): void;
  70673. /**
  70674. * Internal
  70675. * @returns if all the contained post processes are ready.
  70676. * @hidden
  70677. */
  70678. _isReady(): boolean;
  70679. }
  70680. }
  70681. declare module BABYLON {
  70682. /** @hidden */
  70683. export var displayPassPixelShader: {
  70684. name: string;
  70685. shader: string;
  70686. };
  70687. }
  70688. declare module BABYLON {
  70689. /**
  70690. * DisplayPassPostProcess which produces an output the same as it's input
  70691. */
  70692. export class DisplayPassPostProcess extends PostProcess {
  70693. /**
  70694. * Gets a string identifying the name of the class
  70695. * @returns "DisplayPassPostProcess" string
  70696. */
  70697. getClassName(): string;
  70698. /**
  70699. * Creates the DisplayPassPostProcess
  70700. * @param name The name of the effect.
  70701. * @param options The required width/height ratio to downsize to before computing the render pass.
  70702. * @param camera The camera to apply the render pass to.
  70703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70704. * @param engine The engine which the post process will be applied. (default: current engine)
  70705. * @param reusable If the post process can be reused on the same frame. (default: false)
  70706. */
  70707. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70708. /** @hidden */
  70709. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  70710. }
  70711. }
  70712. declare module BABYLON {
  70713. /** @hidden */
  70714. export var filterPixelShader: {
  70715. name: string;
  70716. shader: string;
  70717. };
  70718. }
  70719. declare module BABYLON {
  70720. /**
  70721. * Applies a kernel filter to the image
  70722. */
  70723. export class FilterPostProcess extends PostProcess {
  70724. /** The matrix to be applied to the image */
  70725. kernelMatrix: Matrix;
  70726. /**
  70727. * Gets a string identifying the name of the class
  70728. * @returns "FilterPostProcess" string
  70729. */
  70730. getClassName(): string;
  70731. /**
  70732. *
  70733. * @param name The name of the effect.
  70734. * @param kernelMatrix The matrix to be applied to the image
  70735. * @param options The required width/height ratio to downsize to before computing the render pass.
  70736. * @param camera The camera to apply the render pass to.
  70737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70738. * @param engine The engine which the post process will be applied. (default: current engine)
  70739. * @param reusable If the post process can be reused on the same frame. (default: false)
  70740. */
  70741. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70742. /** @hidden */
  70743. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  70744. }
  70745. }
  70746. declare module BABYLON {
  70747. /** @hidden */
  70748. export var fxaaPixelShader: {
  70749. name: string;
  70750. shader: string;
  70751. };
  70752. }
  70753. declare module BABYLON {
  70754. /** @hidden */
  70755. export var fxaaVertexShader: {
  70756. name: string;
  70757. shader: string;
  70758. };
  70759. }
  70760. declare module BABYLON {
  70761. /**
  70762. * Fxaa post process
  70763. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70764. */
  70765. export class FxaaPostProcess extends PostProcess {
  70766. /**
  70767. * Gets a string identifying the name of the class
  70768. * @returns "FxaaPostProcess" string
  70769. */
  70770. getClassName(): string;
  70771. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70772. private _getDefines;
  70773. /** @hidden */
  70774. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  70775. }
  70776. }
  70777. declare module BABYLON {
  70778. /** @hidden */
  70779. export var grainPixelShader: {
  70780. name: string;
  70781. shader: string;
  70782. };
  70783. }
  70784. declare module BABYLON {
  70785. /**
  70786. * The GrainPostProcess adds noise to the image at mid luminance levels
  70787. */
  70788. export class GrainPostProcess extends PostProcess {
  70789. /**
  70790. * The intensity of the grain added (default: 30)
  70791. */
  70792. intensity: number;
  70793. /**
  70794. * If the grain should be randomized on every frame
  70795. */
  70796. animated: boolean;
  70797. /**
  70798. * Gets a string identifying the name of the class
  70799. * @returns "GrainPostProcess" string
  70800. */
  70801. getClassName(): string;
  70802. /**
  70803. * Creates a new instance of @see GrainPostProcess
  70804. * @param name The name of the effect.
  70805. * @param options The required width/height ratio to downsize to before computing the render pass.
  70806. * @param camera The camera to apply the render pass to.
  70807. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70808. * @param engine The engine which the post process will be applied. (default: current engine)
  70809. * @param reusable If the post process can be reused on the same frame. (default: false)
  70810. * @param textureType Type of textures used when performing the post process. (default: 0)
  70811. * @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)
  70812. */
  70813. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70814. /** @hidden */
  70815. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  70816. }
  70817. }
  70818. declare module BABYLON {
  70819. /** @hidden */
  70820. export var highlightsPixelShader: {
  70821. name: string;
  70822. shader: string;
  70823. };
  70824. }
  70825. declare module BABYLON {
  70826. /**
  70827. * Extracts highlights from the image
  70828. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70829. */
  70830. export class HighlightsPostProcess extends PostProcess {
  70831. /**
  70832. * Gets a string identifying the name of the class
  70833. * @returns "HighlightsPostProcess" string
  70834. */
  70835. getClassName(): string;
  70836. /**
  70837. * Extracts highlights from the image
  70838. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70839. * @param name The name of the effect.
  70840. * @param options The required width/height ratio to downsize to before computing the render pass.
  70841. * @param camera The camera to apply the render pass to.
  70842. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70843. * @param engine The engine which the post process will be applied. (default: current engine)
  70844. * @param reusable If the post process can be reused on the same frame. (default: false)
  70845. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70846. */
  70847. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70848. }
  70849. }
  70850. declare module BABYLON {
  70851. /**
  70852. * Contains all parameters needed for the prepass to perform
  70853. * motion blur
  70854. */
  70855. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  70856. /**
  70857. * Is motion blur enabled
  70858. */
  70859. enabled: boolean;
  70860. /**
  70861. * Name of the configuration
  70862. */
  70863. name: string;
  70864. /**
  70865. * Textures that should be present in the MRT for this effect to work
  70866. */
  70867. readonly texturesRequired: number[];
  70868. }
  70869. }
  70870. declare module BABYLON {
  70871. interface Scene {
  70872. /** @hidden (Backing field) */
  70873. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70874. /**
  70875. * Gets or Sets the current geometry buffer associated to the scene.
  70876. */
  70877. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70878. /**
  70879. * Enables a GeometryBufferRender and associates it with the scene
  70880. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70881. * @returns the GeometryBufferRenderer
  70882. */
  70883. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70884. /**
  70885. * Disables the GeometryBufferRender associated with the scene
  70886. */
  70887. disableGeometryBufferRenderer(): void;
  70888. }
  70889. /**
  70890. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70891. * in several rendering techniques.
  70892. */
  70893. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70894. /**
  70895. * The component name helpful to identify the component in the list of scene components.
  70896. */
  70897. readonly name: string;
  70898. /**
  70899. * The scene the component belongs to.
  70900. */
  70901. scene: Scene;
  70902. /**
  70903. * Creates a new instance of the component for the given scene
  70904. * @param scene Defines the scene to register the component in
  70905. */
  70906. constructor(scene: Scene);
  70907. /**
  70908. * Registers the component in a given scene
  70909. */
  70910. register(): void;
  70911. /**
  70912. * Rebuilds the elements related to this component in case of
  70913. * context lost for instance.
  70914. */
  70915. rebuild(): void;
  70916. /**
  70917. * Disposes the component and the associated ressources
  70918. */
  70919. dispose(): void;
  70920. private _gatherRenderTargets;
  70921. }
  70922. }
  70923. declare module BABYLON {
  70924. /** @hidden */
  70925. export var motionBlurPixelShader: {
  70926. name: string;
  70927. shader: string;
  70928. };
  70929. }
  70930. declare module BABYLON {
  70931. /**
  70932. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70933. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70934. * As an example, all you have to do is to create the post-process:
  70935. * var mb = new BABYLON.MotionBlurPostProcess(
  70936. * 'mb', // The name of the effect.
  70937. * scene, // The scene containing the objects to blur according to their velocity.
  70938. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70939. * camera // The camera to apply the render pass to.
  70940. * );
  70941. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70942. */
  70943. export class MotionBlurPostProcess extends PostProcess {
  70944. /**
  70945. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70946. */
  70947. motionStrength: number;
  70948. /**
  70949. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70950. */
  70951. get motionBlurSamples(): number;
  70952. /**
  70953. * Sets the number of iterations to be used for motion blur quality
  70954. */
  70955. set motionBlurSamples(samples: number);
  70956. private _motionBlurSamples;
  70957. private _forceGeometryBuffer;
  70958. private _geometryBufferRenderer;
  70959. private _prePassRenderer;
  70960. /**
  70961. * Gets a string identifying the name of the class
  70962. * @returns "MotionBlurPostProcess" string
  70963. */
  70964. getClassName(): string;
  70965. /**
  70966. * Creates a new instance MotionBlurPostProcess
  70967. * @param name The name of the effect.
  70968. * @param scene The scene containing the objects to blur according to their velocity.
  70969. * @param options The required width/height ratio to downsize to before computing the render pass.
  70970. * @param camera The camera to apply the render pass to.
  70971. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70972. * @param engine The engine which the post process will be applied. (default: current engine)
  70973. * @param reusable If the post process can be reused on the same frame. (default: false)
  70974. * @param textureType Type of textures used when performing the post process. (default: 0)
  70975. * @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)
  70976. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  70977. */
  70978. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  70979. /**
  70980. * Excludes the given skinned mesh from computing bones velocities.
  70981. * 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.
  70982. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70983. */
  70984. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70985. /**
  70986. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70987. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70988. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70989. */
  70990. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70991. /**
  70992. * Disposes the post process.
  70993. * @param camera The camera to dispose the post process on.
  70994. */
  70995. dispose(camera?: Camera): void;
  70996. /** @hidden */
  70997. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70998. }
  70999. }
  71000. declare module BABYLON {
  71001. /** @hidden */
  71002. export var refractionPixelShader: {
  71003. name: string;
  71004. shader: string;
  71005. };
  71006. }
  71007. declare module BABYLON {
  71008. /**
  71009. * Post process which applies a refractin texture
  71010. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71011. */
  71012. export class RefractionPostProcess extends PostProcess {
  71013. private _refTexture;
  71014. private _ownRefractionTexture;
  71015. /** the base color of the refraction (used to taint the rendering) */
  71016. color: Color3;
  71017. /** simulated refraction depth */
  71018. depth: number;
  71019. /** the coefficient of the base color (0 to remove base color tainting) */
  71020. colorLevel: number;
  71021. /** Gets the url used to load the refraction texture */
  71022. refractionTextureUrl: string;
  71023. /**
  71024. * Gets or sets the refraction texture
  71025. * Please note that you are responsible for disposing the texture if you set it manually
  71026. */
  71027. get refractionTexture(): Texture;
  71028. set refractionTexture(value: Texture);
  71029. /**
  71030. * Gets a string identifying the name of the class
  71031. * @returns "RefractionPostProcess" string
  71032. */
  71033. getClassName(): string;
  71034. /**
  71035. * Initializes the RefractionPostProcess
  71036. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71037. * @param name The name of the effect.
  71038. * @param refractionTextureUrl Url of the refraction texture to use
  71039. * @param color the base color of the refraction (used to taint the rendering)
  71040. * @param depth simulated refraction depth
  71041. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71042. * @param camera The camera to apply the render pass to.
  71043. * @param options The required width/height ratio to downsize to before computing the render pass.
  71044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71045. * @param engine The engine which the post process will be applied. (default: current engine)
  71046. * @param reusable If the post process can be reused on the same frame. (default: false)
  71047. */
  71048. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71049. /**
  71050. * Disposes of the post process
  71051. * @param camera Camera to dispose post process on
  71052. */
  71053. dispose(camera: Camera): void;
  71054. /** @hidden */
  71055. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71056. }
  71057. }
  71058. declare module BABYLON {
  71059. /** @hidden */
  71060. export var sharpenPixelShader: {
  71061. name: string;
  71062. shader: string;
  71063. };
  71064. }
  71065. declare module BABYLON {
  71066. /**
  71067. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71068. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71069. */
  71070. export class SharpenPostProcess extends PostProcess {
  71071. /**
  71072. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71073. */
  71074. colorAmount: number;
  71075. /**
  71076. * How much sharpness should be applied (default: 0.3)
  71077. */
  71078. edgeAmount: number;
  71079. /**
  71080. * Gets a string identifying the name of the class
  71081. * @returns "SharpenPostProcess" string
  71082. */
  71083. getClassName(): string;
  71084. /**
  71085. * Creates a new instance ConvolutionPostProcess
  71086. * @param name The name of the effect.
  71087. * @param options The required width/height ratio to downsize to before computing the render pass.
  71088. * @param camera The camera to apply the render pass to.
  71089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71090. * @param engine The engine which the post process will be applied. (default: current engine)
  71091. * @param reusable If the post process can be reused on the same frame. (default: false)
  71092. * @param textureType Type of textures used when performing the post process. (default: 0)
  71093. * @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)
  71094. */
  71095. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71096. /** @hidden */
  71097. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71098. }
  71099. }
  71100. declare module BABYLON {
  71101. /**
  71102. * PostProcessRenderPipeline
  71103. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71104. */
  71105. export class PostProcessRenderPipeline {
  71106. private engine;
  71107. private _renderEffects;
  71108. private _renderEffectsForIsolatedPass;
  71109. /**
  71110. * List of inspectable custom properties (used by the Inspector)
  71111. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71112. */
  71113. inspectableCustomProperties: IInspectable[];
  71114. /**
  71115. * @hidden
  71116. */
  71117. protected _cameras: Camera[];
  71118. /** @hidden */
  71119. _name: string;
  71120. /**
  71121. * Gets pipeline name
  71122. */
  71123. get name(): string;
  71124. /** Gets the list of attached cameras */
  71125. get cameras(): Camera[];
  71126. /**
  71127. * Initializes a PostProcessRenderPipeline
  71128. * @param engine engine to add the pipeline to
  71129. * @param name name of the pipeline
  71130. */
  71131. constructor(engine: Engine, name: string);
  71132. /**
  71133. * Gets the class name
  71134. * @returns "PostProcessRenderPipeline"
  71135. */
  71136. getClassName(): string;
  71137. /**
  71138. * If all the render effects in the pipeline are supported
  71139. */
  71140. get isSupported(): boolean;
  71141. /**
  71142. * Adds an effect to the pipeline
  71143. * @param renderEffect the effect to add
  71144. */
  71145. addEffect(renderEffect: PostProcessRenderEffect): void;
  71146. /** @hidden */
  71147. _rebuild(): void;
  71148. /** @hidden */
  71149. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71150. /** @hidden */
  71151. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71152. /** @hidden */
  71153. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71154. /** @hidden */
  71155. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71156. /** @hidden */
  71157. _attachCameras(cameras: Camera, unique: boolean): void;
  71158. /** @hidden */
  71159. _attachCameras(cameras: Camera[], unique: boolean): void;
  71160. /** @hidden */
  71161. _detachCameras(cameras: Camera): void;
  71162. /** @hidden */
  71163. _detachCameras(cameras: Nullable<Camera[]>): void;
  71164. /** @hidden */
  71165. _update(): void;
  71166. /** @hidden */
  71167. _reset(): void;
  71168. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71169. /**
  71170. * Sets the required values to the prepass renderer.
  71171. * @param prePassRenderer defines the prepass renderer to setup.
  71172. * @returns true if the pre pass is needed.
  71173. */
  71174. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71175. /**
  71176. * Disposes of the pipeline
  71177. */
  71178. dispose(): void;
  71179. }
  71180. }
  71181. declare module BABYLON {
  71182. /**
  71183. * PostProcessRenderPipelineManager class
  71184. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71185. */
  71186. export class PostProcessRenderPipelineManager {
  71187. private _renderPipelines;
  71188. /**
  71189. * Initializes a PostProcessRenderPipelineManager
  71190. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71191. */
  71192. constructor();
  71193. /**
  71194. * Gets the list of supported render pipelines
  71195. */
  71196. get supportedPipelines(): PostProcessRenderPipeline[];
  71197. /**
  71198. * Adds a pipeline to the manager
  71199. * @param renderPipeline The pipeline to add
  71200. */
  71201. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71202. /**
  71203. * Attaches a camera to the pipeline
  71204. * @param renderPipelineName The name of the pipeline to attach to
  71205. * @param cameras the camera to attach
  71206. * @param unique if the camera can be attached multiple times to the pipeline
  71207. */
  71208. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71209. /**
  71210. * Detaches a camera from the pipeline
  71211. * @param renderPipelineName The name of the pipeline to detach from
  71212. * @param cameras the camera to detach
  71213. */
  71214. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71215. /**
  71216. * Enables an effect by name on a pipeline
  71217. * @param renderPipelineName the name of the pipeline to enable the effect in
  71218. * @param renderEffectName the name of the effect to enable
  71219. * @param cameras the cameras that the effect should be enabled on
  71220. */
  71221. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71222. /**
  71223. * Disables an effect by name on a pipeline
  71224. * @param renderPipelineName the name of the pipeline to disable the effect in
  71225. * @param renderEffectName the name of the effect to disable
  71226. * @param cameras the cameras that the effect should be disabled on
  71227. */
  71228. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71229. /**
  71230. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71231. */
  71232. update(): void;
  71233. /** @hidden */
  71234. _rebuild(): void;
  71235. /**
  71236. * Disposes of the manager and pipelines
  71237. */
  71238. dispose(): void;
  71239. }
  71240. }
  71241. declare module BABYLON {
  71242. interface Scene {
  71243. /** @hidden (Backing field) */
  71244. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71245. /**
  71246. * Gets the postprocess render pipeline manager
  71247. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71248. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71249. */
  71250. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71251. }
  71252. /**
  71253. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71254. */
  71255. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71256. /**
  71257. * The component name helpfull to identify the component in the list of scene components.
  71258. */
  71259. readonly name: string;
  71260. /**
  71261. * The scene the component belongs to.
  71262. */
  71263. scene: Scene;
  71264. /**
  71265. * Creates a new instance of the component for the given scene
  71266. * @param scene Defines the scene to register the component in
  71267. */
  71268. constructor(scene: Scene);
  71269. /**
  71270. * Registers the component in a given scene
  71271. */
  71272. register(): void;
  71273. /**
  71274. * Rebuilds the elements related to this component in case of
  71275. * context lost for instance.
  71276. */
  71277. rebuild(): void;
  71278. /**
  71279. * Disposes the component and the associated ressources
  71280. */
  71281. dispose(): void;
  71282. private _gatherRenderTargets;
  71283. }
  71284. }
  71285. declare module BABYLON {
  71286. /**
  71287. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71288. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71289. */
  71290. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71291. private _scene;
  71292. private _camerasToBeAttached;
  71293. /**
  71294. * ID of the sharpen post process,
  71295. */
  71296. private readonly SharpenPostProcessId;
  71297. /**
  71298. * @ignore
  71299. * ID of the image processing post process;
  71300. */
  71301. readonly ImageProcessingPostProcessId: string;
  71302. /**
  71303. * @ignore
  71304. * ID of the Fast Approximate Anti-Aliasing post process;
  71305. */
  71306. readonly FxaaPostProcessId: string;
  71307. /**
  71308. * ID of the chromatic aberration post process,
  71309. */
  71310. private readonly ChromaticAberrationPostProcessId;
  71311. /**
  71312. * ID of the grain post process
  71313. */
  71314. private readonly GrainPostProcessId;
  71315. /**
  71316. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71317. */
  71318. sharpen: SharpenPostProcess;
  71319. private _sharpenEffect;
  71320. private bloom;
  71321. /**
  71322. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71323. */
  71324. depthOfField: DepthOfFieldEffect;
  71325. /**
  71326. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71327. */
  71328. fxaa: FxaaPostProcess;
  71329. /**
  71330. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71331. */
  71332. imageProcessing: ImageProcessingPostProcess;
  71333. /**
  71334. * Chromatic aberration post process which will shift rgb colors in the image
  71335. */
  71336. chromaticAberration: ChromaticAberrationPostProcess;
  71337. private _chromaticAberrationEffect;
  71338. /**
  71339. * Grain post process which add noise to the image
  71340. */
  71341. grain: GrainPostProcess;
  71342. private _grainEffect;
  71343. /**
  71344. * Glow post process which adds a glow to emissive areas of the image
  71345. */
  71346. private _glowLayer;
  71347. /**
  71348. * Animations which can be used to tweak settings over a period of time
  71349. */
  71350. animations: Animation[];
  71351. private _imageProcessingConfigurationObserver;
  71352. private _sharpenEnabled;
  71353. private _bloomEnabled;
  71354. private _depthOfFieldEnabled;
  71355. private _depthOfFieldBlurLevel;
  71356. private _fxaaEnabled;
  71357. private _imageProcessingEnabled;
  71358. private _defaultPipelineTextureType;
  71359. private _bloomScale;
  71360. private _chromaticAberrationEnabled;
  71361. private _grainEnabled;
  71362. private _buildAllowed;
  71363. /**
  71364. * Gets active scene
  71365. */
  71366. get scene(): Scene;
  71367. /**
  71368. * Enable or disable the sharpen process from the pipeline
  71369. */
  71370. set sharpenEnabled(enabled: boolean);
  71371. get sharpenEnabled(): boolean;
  71372. private _resizeObserver;
  71373. private _hardwareScaleLevel;
  71374. private _bloomKernel;
  71375. /**
  71376. * Specifies the size of the bloom blur kernel, relative to the final output size
  71377. */
  71378. get bloomKernel(): number;
  71379. set bloomKernel(value: number);
  71380. /**
  71381. * Specifies the weight of the bloom in the final rendering
  71382. */
  71383. private _bloomWeight;
  71384. /**
  71385. * Specifies the luma threshold for the area that will be blurred by the bloom
  71386. */
  71387. private _bloomThreshold;
  71388. private _hdr;
  71389. /**
  71390. * The strength of the bloom.
  71391. */
  71392. set bloomWeight(value: number);
  71393. get bloomWeight(): number;
  71394. /**
  71395. * The strength of the bloom.
  71396. */
  71397. set bloomThreshold(value: number);
  71398. get bloomThreshold(): number;
  71399. /**
  71400. * The scale of the bloom, lower value will provide better performance.
  71401. */
  71402. set bloomScale(value: number);
  71403. get bloomScale(): number;
  71404. /**
  71405. * Enable or disable the bloom from the pipeline
  71406. */
  71407. set bloomEnabled(enabled: boolean);
  71408. get bloomEnabled(): boolean;
  71409. private _rebuildBloom;
  71410. /**
  71411. * If the depth of field is enabled.
  71412. */
  71413. get depthOfFieldEnabled(): boolean;
  71414. set depthOfFieldEnabled(enabled: boolean);
  71415. /**
  71416. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71417. */
  71418. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71419. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71420. /**
  71421. * If the anti aliasing is enabled.
  71422. */
  71423. set fxaaEnabled(enabled: boolean);
  71424. get fxaaEnabled(): boolean;
  71425. private _samples;
  71426. /**
  71427. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71428. */
  71429. set samples(sampleCount: number);
  71430. get samples(): number;
  71431. /**
  71432. * If image processing is enabled.
  71433. */
  71434. set imageProcessingEnabled(enabled: boolean);
  71435. get imageProcessingEnabled(): boolean;
  71436. /**
  71437. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71438. */
  71439. set glowLayerEnabled(enabled: boolean);
  71440. get glowLayerEnabled(): boolean;
  71441. /**
  71442. * Gets the glow layer (or null if not defined)
  71443. */
  71444. get glowLayer(): Nullable<GlowLayer>;
  71445. /**
  71446. * Enable or disable the chromaticAberration process from the pipeline
  71447. */
  71448. set chromaticAberrationEnabled(enabled: boolean);
  71449. get chromaticAberrationEnabled(): boolean;
  71450. /**
  71451. * Enable or disable the grain process from the pipeline
  71452. */
  71453. set grainEnabled(enabled: boolean);
  71454. get grainEnabled(): boolean;
  71455. /**
  71456. * @constructor
  71457. * @param name - The rendering pipeline name (default: "")
  71458. * @param hdr - If high dynamic range textures should be used (default: true)
  71459. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71460. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71461. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71462. */
  71463. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71464. /**
  71465. * Get the class name
  71466. * @returns "DefaultRenderingPipeline"
  71467. */
  71468. getClassName(): string;
  71469. /**
  71470. * Force the compilation of the entire pipeline.
  71471. */
  71472. prepare(): void;
  71473. private _hasCleared;
  71474. private _prevPostProcess;
  71475. private _prevPrevPostProcess;
  71476. private _setAutoClearAndTextureSharing;
  71477. private _depthOfFieldSceneObserver;
  71478. private _buildPipeline;
  71479. private _disposePostProcesses;
  71480. /**
  71481. * Adds a camera to the pipeline
  71482. * @param camera the camera to be added
  71483. */
  71484. addCamera(camera: Camera): void;
  71485. /**
  71486. * Removes a camera from the pipeline
  71487. * @param camera the camera to remove
  71488. */
  71489. removeCamera(camera: Camera): void;
  71490. /**
  71491. * Dispose of the pipeline and stop all post processes
  71492. */
  71493. dispose(): void;
  71494. /**
  71495. * Serialize the rendering pipeline (Used when exporting)
  71496. * @returns the serialized object
  71497. */
  71498. serialize(): any;
  71499. /**
  71500. * Parse the serialized pipeline
  71501. * @param source Source pipeline.
  71502. * @param scene The scene to load the pipeline to.
  71503. * @param rootUrl The URL of the serialized pipeline.
  71504. * @returns An instantiated pipeline from the serialized object.
  71505. */
  71506. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71507. }
  71508. }
  71509. declare module BABYLON {
  71510. /** @hidden */
  71511. export var lensHighlightsPixelShader: {
  71512. name: string;
  71513. shader: string;
  71514. };
  71515. }
  71516. declare module BABYLON {
  71517. /** @hidden */
  71518. export var depthOfFieldPixelShader: {
  71519. name: string;
  71520. shader: string;
  71521. };
  71522. }
  71523. declare module BABYLON {
  71524. /**
  71525. * BABYLON.JS Chromatic Aberration GLSL Shader
  71526. * Author: Olivier Guyot
  71527. * Separates very slightly R, G and B colors on the edges of the screen
  71528. * Inspired by Francois Tarlier & Martins Upitis
  71529. */
  71530. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71531. /**
  71532. * @ignore
  71533. * The chromatic aberration PostProcess id in the pipeline
  71534. */
  71535. LensChromaticAberrationEffect: string;
  71536. /**
  71537. * @ignore
  71538. * The highlights enhancing PostProcess id in the pipeline
  71539. */
  71540. HighlightsEnhancingEffect: string;
  71541. /**
  71542. * @ignore
  71543. * The depth-of-field PostProcess id in the pipeline
  71544. */
  71545. LensDepthOfFieldEffect: string;
  71546. private _scene;
  71547. private _depthTexture;
  71548. private _grainTexture;
  71549. private _chromaticAberrationPostProcess;
  71550. private _highlightsPostProcess;
  71551. private _depthOfFieldPostProcess;
  71552. private _edgeBlur;
  71553. private _grainAmount;
  71554. private _chromaticAberration;
  71555. private _distortion;
  71556. private _highlightsGain;
  71557. private _highlightsThreshold;
  71558. private _dofDistance;
  71559. private _dofAperture;
  71560. private _dofDarken;
  71561. private _dofPentagon;
  71562. private _blurNoise;
  71563. /**
  71564. * @constructor
  71565. *
  71566. * Effect parameters are as follow:
  71567. * {
  71568. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71569. * edge_blur: number; // from 0 to x (1 for realism)
  71570. * distortion: number; // from 0 to x (1 for realism)
  71571. * grain_amount: number; // from 0 to 1
  71572. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71573. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71574. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71575. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71576. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71577. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71578. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71579. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71580. * }
  71581. * Note: if an effect parameter is unset, effect is disabled
  71582. *
  71583. * @param name The rendering pipeline name
  71584. * @param parameters - An object containing all parameters (see above)
  71585. * @param scene The scene linked to this pipeline
  71586. * @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)
  71587. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71588. */
  71589. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71590. /**
  71591. * Get the class name
  71592. * @returns "LensRenderingPipeline"
  71593. */
  71594. getClassName(): string;
  71595. /**
  71596. * Gets associated scene
  71597. */
  71598. get scene(): Scene;
  71599. /**
  71600. * Gets or sets the edge blur
  71601. */
  71602. get edgeBlur(): number;
  71603. set edgeBlur(value: number);
  71604. /**
  71605. * Gets or sets the grain amount
  71606. */
  71607. get grainAmount(): number;
  71608. set grainAmount(value: number);
  71609. /**
  71610. * Gets or sets the chromatic aberration amount
  71611. */
  71612. get chromaticAberration(): number;
  71613. set chromaticAberration(value: number);
  71614. /**
  71615. * Gets or sets the depth of field aperture
  71616. */
  71617. get dofAperture(): number;
  71618. set dofAperture(value: number);
  71619. /**
  71620. * Gets or sets the edge distortion
  71621. */
  71622. get edgeDistortion(): number;
  71623. set edgeDistortion(value: number);
  71624. /**
  71625. * Gets or sets the depth of field distortion
  71626. */
  71627. get dofDistortion(): number;
  71628. set dofDistortion(value: number);
  71629. /**
  71630. * Gets or sets the darken out of focus amount
  71631. */
  71632. get darkenOutOfFocus(): number;
  71633. set darkenOutOfFocus(value: number);
  71634. /**
  71635. * Gets or sets a boolean indicating if blur noise is enabled
  71636. */
  71637. get blurNoise(): boolean;
  71638. set blurNoise(value: boolean);
  71639. /**
  71640. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71641. */
  71642. get pentagonBokeh(): boolean;
  71643. set pentagonBokeh(value: boolean);
  71644. /**
  71645. * Gets or sets the highlight grain amount
  71646. */
  71647. get highlightsGain(): number;
  71648. set highlightsGain(value: number);
  71649. /**
  71650. * Gets or sets the highlight threshold
  71651. */
  71652. get highlightsThreshold(): number;
  71653. set highlightsThreshold(value: number);
  71654. /**
  71655. * Sets the amount of blur at the edges
  71656. * @param amount blur amount
  71657. */
  71658. setEdgeBlur(amount: number): void;
  71659. /**
  71660. * Sets edge blur to 0
  71661. */
  71662. disableEdgeBlur(): void;
  71663. /**
  71664. * Sets the amout of grain
  71665. * @param amount Amount of grain
  71666. */
  71667. setGrainAmount(amount: number): void;
  71668. /**
  71669. * Set grain amount to 0
  71670. */
  71671. disableGrain(): void;
  71672. /**
  71673. * Sets the chromatic aberration amount
  71674. * @param amount amount of chromatic aberration
  71675. */
  71676. setChromaticAberration(amount: number): void;
  71677. /**
  71678. * Sets chromatic aberration amount to 0
  71679. */
  71680. disableChromaticAberration(): void;
  71681. /**
  71682. * Sets the EdgeDistortion amount
  71683. * @param amount amount of EdgeDistortion
  71684. */
  71685. setEdgeDistortion(amount: number): void;
  71686. /**
  71687. * Sets edge distortion to 0
  71688. */
  71689. disableEdgeDistortion(): void;
  71690. /**
  71691. * Sets the FocusDistance amount
  71692. * @param amount amount of FocusDistance
  71693. */
  71694. setFocusDistance(amount: number): void;
  71695. /**
  71696. * Disables depth of field
  71697. */
  71698. disableDepthOfField(): void;
  71699. /**
  71700. * Sets the Aperture amount
  71701. * @param amount amount of Aperture
  71702. */
  71703. setAperture(amount: number): void;
  71704. /**
  71705. * Sets the DarkenOutOfFocus amount
  71706. * @param amount amount of DarkenOutOfFocus
  71707. */
  71708. setDarkenOutOfFocus(amount: number): void;
  71709. private _pentagonBokehIsEnabled;
  71710. /**
  71711. * Creates a pentagon bokeh effect
  71712. */
  71713. enablePentagonBokeh(): void;
  71714. /**
  71715. * Disables the pentagon bokeh effect
  71716. */
  71717. disablePentagonBokeh(): void;
  71718. /**
  71719. * Enables noise blur
  71720. */
  71721. enableNoiseBlur(): void;
  71722. /**
  71723. * Disables noise blur
  71724. */
  71725. disableNoiseBlur(): void;
  71726. /**
  71727. * Sets the HighlightsGain amount
  71728. * @param amount amount of HighlightsGain
  71729. */
  71730. setHighlightsGain(amount: number): void;
  71731. /**
  71732. * Sets the HighlightsThreshold amount
  71733. * @param amount amount of HighlightsThreshold
  71734. */
  71735. setHighlightsThreshold(amount: number): void;
  71736. /**
  71737. * Disables highlights
  71738. */
  71739. disableHighlights(): void;
  71740. /**
  71741. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71742. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71743. */
  71744. dispose(disableDepthRender?: boolean): void;
  71745. private _createChromaticAberrationPostProcess;
  71746. private _createHighlightsPostProcess;
  71747. private _createDepthOfFieldPostProcess;
  71748. private _createGrainTexture;
  71749. }
  71750. }
  71751. declare module BABYLON {
  71752. /**
  71753. * Contains all parameters needed for the prepass to perform
  71754. * screen space subsurface scattering
  71755. */
  71756. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71757. /**
  71758. * Is subsurface enabled
  71759. */
  71760. enabled: boolean;
  71761. /**
  71762. * Name of the configuration
  71763. */
  71764. name: string;
  71765. /**
  71766. * Textures that should be present in the MRT for this effect to work
  71767. */
  71768. readonly texturesRequired: number[];
  71769. }
  71770. }
  71771. declare module BABYLON {
  71772. /** @hidden */
  71773. export var ssao2PixelShader: {
  71774. name: string;
  71775. shader: string;
  71776. };
  71777. }
  71778. declare module BABYLON {
  71779. /** @hidden */
  71780. export var ssaoCombinePixelShader: {
  71781. name: string;
  71782. shader: string;
  71783. };
  71784. }
  71785. declare module BABYLON {
  71786. /**
  71787. * Render pipeline to produce ssao effect
  71788. */
  71789. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71790. /**
  71791. * @ignore
  71792. * The PassPostProcess id in the pipeline that contains the original scene color
  71793. */
  71794. SSAOOriginalSceneColorEffect: string;
  71795. /**
  71796. * @ignore
  71797. * The SSAO PostProcess id in the pipeline
  71798. */
  71799. SSAORenderEffect: string;
  71800. /**
  71801. * @ignore
  71802. * The horizontal blur PostProcess id in the pipeline
  71803. */
  71804. SSAOBlurHRenderEffect: string;
  71805. /**
  71806. * @ignore
  71807. * The vertical blur PostProcess id in the pipeline
  71808. */
  71809. SSAOBlurVRenderEffect: string;
  71810. /**
  71811. * @ignore
  71812. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71813. */
  71814. SSAOCombineRenderEffect: string;
  71815. /**
  71816. * The output strength of the SSAO post-process. Default value is 1.0.
  71817. */
  71818. totalStrength: number;
  71819. /**
  71820. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71821. */
  71822. maxZ: number;
  71823. /**
  71824. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71825. */
  71826. minZAspect: number;
  71827. private _samples;
  71828. /**
  71829. * Number of samples used for the SSAO calculations. Default value is 8
  71830. */
  71831. set samples(n: number);
  71832. get samples(): number;
  71833. private _textureSamples;
  71834. /**
  71835. * Number of samples to use for antialiasing
  71836. */
  71837. set textureSamples(n: number);
  71838. get textureSamples(): number;
  71839. /**
  71840. * Force rendering the geometry through geometry buffer
  71841. */
  71842. private _forceGeometryBuffer;
  71843. /**
  71844. * Ratio object used for SSAO ratio and blur ratio
  71845. */
  71846. private _ratio;
  71847. /**
  71848. * Dynamically generated sphere sampler.
  71849. */
  71850. private _sampleSphere;
  71851. /**
  71852. * Blur filter offsets
  71853. */
  71854. private _samplerOffsets;
  71855. private _expensiveBlur;
  71856. /**
  71857. * If bilateral blur should be used
  71858. */
  71859. set expensiveBlur(b: boolean);
  71860. get expensiveBlur(): boolean;
  71861. /**
  71862. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71863. */
  71864. radius: number;
  71865. /**
  71866. * The base color of the SSAO post-process
  71867. * The final result is "base + ssao" between [0, 1]
  71868. */
  71869. base: number;
  71870. /**
  71871. * Support test.
  71872. */
  71873. static get IsSupported(): boolean;
  71874. private _scene;
  71875. private _randomTexture;
  71876. private _originalColorPostProcess;
  71877. private _ssaoPostProcess;
  71878. private _blurHPostProcess;
  71879. private _blurVPostProcess;
  71880. private _ssaoCombinePostProcess;
  71881. private _prePassRenderer;
  71882. /**
  71883. * Gets active scene
  71884. */
  71885. get scene(): Scene;
  71886. /**
  71887. * @constructor
  71888. * @param name The rendering pipeline name
  71889. * @param scene The scene linked to this pipeline
  71890. * @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 }
  71891. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71892. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71893. */
  71894. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71895. /**
  71896. * Get the class name
  71897. * @returns "SSAO2RenderingPipeline"
  71898. */
  71899. getClassName(): string;
  71900. /**
  71901. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71902. */
  71903. dispose(disableGeometryBufferRenderer?: boolean): void;
  71904. private _createBlurPostProcess;
  71905. /** @hidden */
  71906. _rebuild(): void;
  71907. private _bits;
  71908. private _radicalInverse_VdC;
  71909. private _hammersley;
  71910. private _hemisphereSample_uniform;
  71911. private _generateHemisphere;
  71912. private _getDefinesForSSAO;
  71913. private _createSSAOPostProcess;
  71914. private _createSSAOCombinePostProcess;
  71915. private _createRandomTexture;
  71916. /**
  71917. * Serialize the rendering pipeline (Used when exporting)
  71918. * @returns the serialized object
  71919. */
  71920. serialize(): any;
  71921. /**
  71922. * Parse the serialized pipeline
  71923. * @param source Source pipeline.
  71924. * @param scene The scene to load the pipeline to.
  71925. * @param rootUrl The URL of the serialized pipeline.
  71926. * @returns An instantiated pipeline from the serialized object.
  71927. */
  71928. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71929. }
  71930. }
  71931. declare module BABYLON {
  71932. /** @hidden */
  71933. export var ssaoPixelShader: {
  71934. name: string;
  71935. shader: string;
  71936. };
  71937. }
  71938. declare module BABYLON {
  71939. /**
  71940. * Render pipeline to produce ssao effect
  71941. */
  71942. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71943. /**
  71944. * @ignore
  71945. * The PassPostProcess id in the pipeline that contains the original scene color
  71946. */
  71947. SSAOOriginalSceneColorEffect: string;
  71948. /**
  71949. * @ignore
  71950. * The SSAO PostProcess id in the pipeline
  71951. */
  71952. SSAORenderEffect: string;
  71953. /**
  71954. * @ignore
  71955. * The horizontal blur PostProcess id in the pipeline
  71956. */
  71957. SSAOBlurHRenderEffect: string;
  71958. /**
  71959. * @ignore
  71960. * The vertical blur PostProcess id in the pipeline
  71961. */
  71962. SSAOBlurVRenderEffect: string;
  71963. /**
  71964. * @ignore
  71965. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71966. */
  71967. SSAOCombineRenderEffect: string;
  71968. /**
  71969. * The output strength of the SSAO post-process. Default value is 1.0.
  71970. */
  71971. totalStrength: number;
  71972. /**
  71973. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71974. */
  71975. radius: number;
  71976. /**
  71977. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71978. * Must not be equal to fallOff and superior to fallOff.
  71979. * Default value is 0.0075
  71980. */
  71981. area: number;
  71982. /**
  71983. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71984. * Must not be equal to area and inferior to area.
  71985. * Default value is 0.000001
  71986. */
  71987. fallOff: number;
  71988. /**
  71989. * The base color of the SSAO post-process
  71990. * The final result is "base + ssao" between [0, 1]
  71991. */
  71992. base: number;
  71993. private _scene;
  71994. private _depthTexture;
  71995. private _randomTexture;
  71996. private _originalColorPostProcess;
  71997. private _ssaoPostProcess;
  71998. private _blurHPostProcess;
  71999. private _blurVPostProcess;
  72000. private _ssaoCombinePostProcess;
  72001. private _firstUpdate;
  72002. /**
  72003. * Gets active scene
  72004. */
  72005. get scene(): Scene;
  72006. /**
  72007. * @constructor
  72008. * @param name - The rendering pipeline name
  72009. * @param scene - The scene linked to this pipeline
  72010. * @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 }
  72011. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72012. */
  72013. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72014. /**
  72015. * Get the class name
  72016. * @returns "SSAORenderingPipeline"
  72017. */
  72018. getClassName(): string;
  72019. /**
  72020. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72021. */
  72022. dispose(disableDepthRender?: boolean): void;
  72023. private _createBlurPostProcess;
  72024. /** @hidden */
  72025. _rebuild(): void;
  72026. private _createSSAOPostProcess;
  72027. private _createSSAOCombinePostProcess;
  72028. private _createRandomTexture;
  72029. }
  72030. }
  72031. declare module BABYLON {
  72032. /**
  72033. * Contains all parameters needed for the prepass to perform
  72034. * screen space reflections
  72035. */
  72036. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72037. /**
  72038. * Is ssr enabled
  72039. */
  72040. enabled: boolean;
  72041. /**
  72042. * Name of the configuration
  72043. */
  72044. name: string;
  72045. /**
  72046. * Textures that should be present in the MRT for this effect to work
  72047. */
  72048. readonly texturesRequired: number[];
  72049. }
  72050. }
  72051. declare module BABYLON {
  72052. /** @hidden */
  72053. export var screenSpaceReflectionPixelShader: {
  72054. name: string;
  72055. shader: string;
  72056. };
  72057. }
  72058. declare module BABYLON {
  72059. /**
  72060. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72061. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72062. */
  72063. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72064. /**
  72065. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72066. */
  72067. threshold: number;
  72068. /**
  72069. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72070. */
  72071. strength: number;
  72072. /**
  72073. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72074. */
  72075. reflectionSpecularFalloffExponent: number;
  72076. /**
  72077. * 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]
  72078. */
  72079. step: number;
  72080. /**
  72081. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72082. */
  72083. roughnessFactor: number;
  72084. private _forceGeometryBuffer;
  72085. private _geometryBufferRenderer;
  72086. private _prePassRenderer;
  72087. private _enableSmoothReflections;
  72088. private _reflectionSamples;
  72089. private _smoothSteps;
  72090. /**
  72091. * Gets a string identifying the name of the class
  72092. * @returns "ScreenSpaceReflectionPostProcess" string
  72093. */
  72094. getClassName(): string;
  72095. /**
  72096. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72097. * @param name The name of the effect.
  72098. * @param scene The scene containing the objects to calculate reflections.
  72099. * @param options The required width/height ratio to downsize to before computing the render pass.
  72100. * @param camera The camera to apply the render pass to.
  72101. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72102. * @param engine The engine which the post process will be applied. (default: current engine)
  72103. * @param reusable If the post process can be reused on the same frame. (default: false)
  72104. * @param textureType Type of textures used when performing the post process. (default: 0)
  72105. * @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)
  72106. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72107. */
  72108. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72109. /**
  72110. * Gets wether or not smoothing reflections is enabled.
  72111. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72112. */
  72113. get enableSmoothReflections(): boolean;
  72114. /**
  72115. * Sets wether or not smoothing reflections is enabled.
  72116. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72117. */
  72118. set enableSmoothReflections(enabled: boolean);
  72119. /**
  72120. * Gets the number of samples taken while computing reflections. More samples count is high,
  72121. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72122. */
  72123. get reflectionSamples(): number;
  72124. /**
  72125. * Sets the number of samples taken while computing reflections. More samples count is high,
  72126. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72127. */
  72128. set reflectionSamples(samples: number);
  72129. /**
  72130. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72131. * more the post-process will require GPU power and can generate a drop in FPS.
  72132. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72133. */
  72134. get smoothSteps(): number;
  72135. set smoothSteps(steps: number);
  72136. private _updateEffectDefines;
  72137. /** @hidden */
  72138. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72139. }
  72140. }
  72141. declare module BABYLON {
  72142. /** @hidden */
  72143. export var standardPixelShader: {
  72144. name: string;
  72145. shader: string;
  72146. };
  72147. }
  72148. declare module BABYLON {
  72149. /**
  72150. * Standard rendering pipeline
  72151. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72152. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72153. */
  72154. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72155. /**
  72156. * Public members
  72157. */
  72158. /**
  72159. * Post-process which contains the original scene color before the pipeline applies all the effects
  72160. */
  72161. originalPostProcess: Nullable<PostProcess>;
  72162. /**
  72163. * Post-process used to down scale an image x4
  72164. */
  72165. downSampleX4PostProcess: Nullable<PostProcess>;
  72166. /**
  72167. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72168. */
  72169. brightPassPostProcess: Nullable<PostProcess>;
  72170. /**
  72171. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72172. */
  72173. blurHPostProcesses: PostProcess[];
  72174. /**
  72175. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72176. */
  72177. blurVPostProcesses: PostProcess[];
  72178. /**
  72179. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72180. */
  72181. textureAdderPostProcess: Nullable<PostProcess>;
  72182. /**
  72183. * Post-process used to create volumetric lighting effect
  72184. */
  72185. volumetricLightPostProcess: Nullable<PostProcess>;
  72186. /**
  72187. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72188. */
  72189. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72190. /**
  72191. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72192. */
  72193. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72194. /**
  72195. * Post-process used to merge the volumetric light effect and the real scene color
  72196. */
  72197. volumetricLightMergePostProces: Nullable<PostProcess>;
  72198. /**
  72199. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72200. */
  72201. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72202. /**
  72203. * Base post-process used to calculate the average luminance of the final image for HDR
  72204. */
  72205. luminancePostProcess: Nullable<PostProcess>;
  72206. /**
  72207. * Post-processes used to create down sample post-processes in order to get
  72208. * the average luminance of the final image for HDR
  72209. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72210. */
  72211. luminanceDownSamplePostProcesses: PostProcess[];
  72212. /**
  72213. * Post-process used to create a HDR effect (light adaptation)
  72214. */
  72215. hdrPostProcess: Nullable<PostProcess>;
  72216. /**
  72217. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72218. */
  72219. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72220. /**
  72221. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72222. */
  72223. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72224. /**
  72225. * Post-process used to merge the final HDR post-process and the real scene color
  72226. */
  72227. hdrFinalPostProcess: Nullable<PostProcess>;
  72228. /**
  72229. * Post-process used to create a lens flare effect
  72230. */
  72231. lensFlarePostProcess: Nullable<PostProcess>;
  72232. /**
  72233. * Post-process that merges the result of the lens flare post-process and the real scene color
  72234. */
  72235. lensFlareComposePostProcess: Nullable<PostProcess>;
  72236. /**
  72237. * Post-process used to create a motion blur effect
  72238. */
  72239. motionBlurPostProcess: Nullable<PostProcess>;
  72240. /**
  72241. * Post-process used to create a depth of field effect
  72242. */
  72243. depthOfFieldPostProcess: Nullable<PostProcess>;
  72244. /**
  72245. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72246. */
  72247. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72248. /**
  72249. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72250. */
  72251. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72252. /**
  72253. * Represents the brightness threshold in order to configure the illuminated surfaces
  72254. */
  72255. brightThreshold: number;
  72256. /**
  72257. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72258. */
  72259. blurWidth: number;
  72260. /**
  72261. * Sets if the blur for highlighted surfaces must be only horizontal
  72262. */
  72263. horizontalBlur: boolean;
  72264. /**
  72265. * Gets the overall exposure used by the pipeline
  72266. */
  72267. get exposure(): number;
  72268. /**
  72269. * Sets the overall exposure used by the pipeline
  72270. */
  72271. set exposure(value: number);
  72272. /**
  72273. * Texture used typically to simulate "dirty" on camera lens
  72274. */
  72275. lensTexture: Nullable<Texture>;
  72276. /**
  72277. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72278. */
  72279. volumetricLightCoefficient: number;
  72280. /**
  72281. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72282. */
  72283. volumetricLightPower: number;
  72284. /**
  72285. * Used the set the blur intensity to smooth the volumetric lights
  72286. */
  72287. volumetricLightBlurScale: number;
  72288. /**
  72289. * Light (spot or directional) used to generate the volumetric lights rays
  72290. * The source light must have a shadow generate so the pipeline can get its
  72291. * depth map
  72292. */
  72293. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72294. /**
  72295. * For eye adaptation, represents the minimum luminance the eye can see
  72296. */
  72297. hdrMinimumLuminance: number;
  72298. /**
  72299. * For eye adaptation, represents the decrease luminance speed
  72300. */
  72301. hdrDecreaseRate: number;
  72302. /**
  72303. * For eye adaptation, represents the increase luminance speed
  72304. */
  72305. hdrIncreaseRate: number;
  72306. /**
  72307. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72308. */
  72309. get hdrAutoExposure(): boolean;
  72310. /**
  72311. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72312. */
  72313. set hdrAutoExposure(value: boolean);
  72314. /**
  72315. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72316. */
  72317. lensColorTexture: Nullable<Texture>;
  72318. /**
  72319. * The overall strengh for the lens flare effect
  72320. */
  72321. lensFlareStrength: number;
  72322. /**
  72323. * Dispersion coefficient for lens flare ghosts
  72324. */
  72325. lensFlareGhostDispersal: number;
  72326. /**
  72327. * Main lens flare halo width
  72328. */
  72329. lensFlareHaloWidth: number;
  72330. /**
  72331. * Based on the lens distortion effect, defines how much the lens flare result
  72332. * is distorted
  72333. */
  72334. lensFlareDistortionStrength: number;
  72335. /**
  72336. * Configures the blur intensity used for for lens flare (halo)
  72337. */
  72338. lensFlareBlurWidth: number;
  72339. /**
  72340. * Lens star texture must be used to simulate rays on the flares and is available
  72341. * in the documentation
  72342. */
  72343. lensStarTexture: Nullable<Texture>;
  72344. /**
  72345. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72346. * flare effect by taking account of the dirt texture
  72347. */
  72348. lensFlareDirtTexture: Nullable<Texture>;
  72349. /**
  72350. * Represents the focal length for the depth of field effect
  72351. */
  72352. depthOfFieldDistance: number;
  72353. /**
  72354. * Represents the blur intensity for the blurred part of the depth of field effect
  72355. */
  72356. depthOfFieldBlurWidth: number;
  72357. /**
  72358. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72359. */
  72360. get motionStrength(): number;
  72361. /**
  72362. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72363. */
  72364. set motionStrength(strength: number);
  72365. /**
  72366. * Gets wether or not the motion blur post-process is object based or screen based.
  72367. */
  72368. get objectBasedMotionBlur(): boolean;
  72369. /**
  72370. * Sets wether or not the motion blur post-process should be object based or screen based
  72371. */
  72372. set objectBasedMotionBlur(value: boolean);
  72373. /**
  72374. * List of animations for the pipeline (IAnimatable implementation)
  72375. */
  72376. animations: Animation[];
  72377. /**
  72378. * Private members
  72379. */
  72380. private _scene;
  72381. private _currentDepthOfFieldSource;
  72382. private _basePostProcess;
  72383. private _fixedExposure;
  72384. private _currentExposure;
  72385. private _hdrAutoExposure;
  72386. private _hdrCurrentLuminance;
  72387. private _motionStrength;
  72388. private _isObjectBasedMotionBlur;
  72389. private _floatTextureType;
  72390. private _camerasToBeAttached;
  72391. private _ratio;
  72392. private _bloomEnabled;
  72393. private _depthOfFieldEnabled;
  72394. private _vlsEnabled;
  72395. private _lensFlareEnabled;
  72396. private _hdrEnabled;
  72397. private _motionBlurEnabled;
  72398. private _fxaaEnabled;
  72399. private _screenSpaceReflectionsEnabled;
  72400. private _motionBlurSamples;
  72401. private _volumetricLightStepsCount;
  72402. private _samples;
  72403. /**
  72404. * @ignore
  72405. * Specifies if the bloom pipeline is enabled
  72406. */
  72407. get BloomEnabled(): boolean;
  72408. set BloomEnabled(enabled: boolean);
  72409. /**
  72410. * @ignore
  72411. * Specifies if the depth of field pipeline is enabed
  72412. */
  72413. get DepthOfFieldEnabled(): boolean;
  72414. set DepthOfFieldEnabled(enabled: boolean);
  72415. /**
  72416. * @ignore
  72417. * Specifies if the lens flare pipeline is enabed
  72418. */
  72419. get LensFlareEnabled(): boolean;
  72420. set LensFlareEnabled(enabled: boolean);
  72421. /**
  72422. * @ignore
  72423. * Specifies if the HDR pipeline is enabled
  72424. */
  72425. get HDREnabled(): boolean;
  72426. set HDREnabled(enabled: boolean);
  72427. /**
  72428. * @ignore
  72429. * Specifies if the volumetric lights scattering effect is enabled
  72430. */
  72431. get VLSEnabled(): boolean;
  72432. set VLSEnabled(enabled: boolean);
  72433. /**
  72434. * @ignore
  72435. * Specifies if the motion blur effect is enabled
  72436. */
  72437. get MotionBlurEnabled(): boolean;
  72438. set MotionBlurEnabled(enabled: boolean);
  72439. /**
  72440. * Specifies if anti-aliasing is enabled
  72441. */
  72442. get fxaaEnabled(): boolean;
  72443. set fxaaEnabled(enabled: boolean);
  72444. /**
  72445. * Specifies if screen space reflections are enabled.
  72446. */
  72447. get screenSpaceReflectionsEnabled(): boolean;
  72448. set screenSpaceReflectionsEnabled(enabled: boolean);
  72449. /**
  72450. * Specifies the number of steps used to calculate the volumetric lights
  72451. * Typically in interval [50, 200]
  72452. */
  72453. get volumetricLightStepsCount(): number;
  72454. set volumetricLightStepsCount(count: number);
  72455. /**
  72456. * Specifies the number of samples used for the motion blur effect
  72457. * Typically in interval [16, 64]
  72458. */
  72459. get motionBlurSamples(): number;
  72460. set motionBlurSamples(samples: number);
  72461. /**
  72462. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72463. */
  72464. get samples(): number;
  72465. set samples(sampleCount: number);
  72466. /**
  72467. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72468. * @constructor
  72469. * @param name The rendering pipeline name
  72470. * @param scene The scene linked to this pipeline
  72471. * @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)
  72472. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72473. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72474. */
  72475. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72476. private _buildPipeline;
  72477. private _createDownSampleX4PostProcess;
  72478. private _createBrightPassPostProcess;
  72479. private _createBlurPostProcesses;
  72480. private _createTextureAdderPostProcess;
  72481. private _createVolumetricLightPostProcess;
  72482. private _createLuminancePostProcesses;
  72483. private _createHdrPostProcess;
  72484. private _createLensFlarePostProcess;
  72485. private _createDepthOfFieldPostProcess;
  72486. private _createMotionBlurPostProcess;
  72487. private _getDepthTexture;
  72488. private _disposePostProcesses;
  72489. /**
  72490. * Dispose of the pipeline and stop all post processes
  72491. */
  72492. dispose(): void;
  72493. /**
  72494. * Serialize the rendering pipeline (Used when exporting)
  72495. * @returns the serialized object
  72496. */
  72497. serialize(): any;
  72498. /**
  72499. * Parse the serialized pipeline
  72500. * @param source Source pipeline.
  72501. * @param scene The scene to load the pipeline to.
  72502. * @param rootUrl The URL of the serialized pipeline.
  72503. * @returns An instantiated pipeline from the serialized object.
  72504. */
  72505. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72506. /**
  72507. * Luminance steps
  72508. */
  72509. static LuminanceSteps: number;
  72510. }
  72511. }
  72512. declare module BABYLON {
  72513. /** @hidden */
  72514. export var stereoscopicInterlacePixelShader: {
  72515. name: string;
  72516. shader: string;
  72517. };
  72518. }
  72519. declare module BABYLON {
  72520. /**
  72521. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72522. */
  72523. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72524. private _stepSize;
  72525. private _passedProcess;
  72526. /**
  72527. * Gets a string identifying the name of the class
  72528. * @returns "StereoscopicInterlacePostProcessI" string
  72529. */
  72530. getClassName(): string;
  72531. /**
  72532. * Initializes a StereoscopicInterlacePostProcessI
  72533. * @param name The name of the effect.
  72534. * @param rigCameras The rig cameras to be appled to the post process
  72535. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72536. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72538. * @param engine The engine which the post process will be applied. (default: current engine)
  72539. * @param reusable If the post process can be reused on the same frame. (default: false)
  72540. */
  72541. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72542. }
  72543. /**
  72544. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72545. */
  72546. export class StereoscopicInterlacePostProcess extends PostProcess {
  72547. private _stepSize;
  72548. private _passedProcess;
  72549. /**
  72550. * Gets a string identifying the name of the class
  72551. * @returns "StereoscopicInterlacePostProcess" string
  72552. */
  72553. getClassName(): string;
  72554. /**
  72555. * Initializes a StereoscopicInterlacePostProcess
  72556. * @param name The name of the effect.
  72557. * @param rigCameras The rig cameras to be appled to the post process
  72558. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72560. * @param engine The engine which the post process will be applied. (default: current engine)
  72561. * @param reusable If the post process can be reused on the same frame. (default: false)
  72562. */
  72563. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72564. }
  72565. }
  72566. declare module BABYLON {
  72567. /** @hidden */
  72568. export var tonemapPixelShader: {
  72569. name: string;
  72570. shader: string;
  72571. };
  72572. }
  72573. declare module BABYLON {
  72574. /** Defines operator used for tonemapping */
  72575. export enum TonemappingOperator {
  72576. /** Hable */
  72577. Hable = 0,
  72578. /** Reinhard */
  72579. Reinhard = 1,
  72580. /** HejiDawson */
  72581. HejiDawson = 2,
  72582. /** Photographic */
  72583. Photographic = 3
  72584. }
  72585. /**
  72586. * Defines a post process to apply tone mapping
  72587. */
  72588. export class TonemapPostProcess extends PostProcess {
  72589. private _operator;
  72590. /** Defines the required exposure adjustement */
  72591. exposureAdjustment: number;
  72592. /**
  72593. * Gets a string identifying the name of the class
  72594. * @returns "TonemapPostProcess" string
  72595. */
  72596. getClassName(): string;
  72597. /**
  72598. * Creates a new TonemapPostProcess
  72599. * @param name defines the name of the postprocess
  72600. * @param _operator defines the operator to use
  72601. * @param exposureAdjustment defines the required exposure adjustement
  72602. * @param camera defines the camera to use (can be null)
  72603. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72604. * @param engine defines the hosting engine (can be ignore if camera is set)
  72605. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72606. */
  72607. constructor(name: string, _operator: TonemappingOperator,
  72608. /** Defines the required exposure adjustement */
  72609. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72610. }
  72611. }
  72612. declare module BABYLON {
  72613. /** @hidden */
  72614. export var volumetricLightScatteringPixelShader: {
  72615. name: string;
  72616. shader: string;
  72617. };
  72618. }
  72619. declare module BABYLON {
  72620. /** @hidden */
  72621. export var volumetricLightScatteringPassVertexShader: {
  72622. name: string;
  72623. shader: string;
  72624. };
  72625. }
  72626. declare module BABYLON {
  72627. /** @hidden */
  72628. export var volumetricLightScatteringPassPixelShader: {
  72629. name: string;
  72630. shader: string;
  72631. };
  72632. }
  72633. declare module BABYLON {
  72634. /**
  72635. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72636. */
  72637. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72638. private _volumetricLightScatteringPass;
  72639. private _volumetricLightScatteringRTT;
  72640. private _viewPort;
  72641. private _screenCoordinates;
  72642. private _cachedDefines;
  72643. /**
  72644. * If not undefined, the mesh position is computed from the attached node position
  72645. */
  72646. attachedNode: {
  72647. position: Vector3;
  72648. };
  72649. /**
  72650. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72651. */
  72652. customMeshPosition: Vector3;
  72653. /**
  72654. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72655. */
  72656. useCustomMeshPosition: boolean;
  72657. /**
  72658. * If the post-process should inverse the light scattering direction
  72659. */
  72660. invert: boolean;
  72661. /**
  72662. * The internal mesh used by the post-process
  72663. */
  72664. mesh: Mesh;
  72665. /**
  72666. * @hidden
  72667. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72668. */
  72669. get useDiffuseColor(): boolean;
  72670. set useDiffuseColor(useDiffuseColor: boolean);
  72671. /**
  72672. * Array containing the excluded meshes not rendered in the internal pass
  72673. */
  72674. excludedMeshes: AbstractMesh[];
  72675. /**
  72676. * Controls the overall intensity of the post-process
  72677. */
  72678. exposure: number;
  72679. /**
  72680. * Dissipates each sample's contribution in range [0, 1]
  72681. */
  72682. decay: number;
  72683. /**
  72684. * Controls the overall intensity of each sample
  72685. */
  72686. weight: number;
  72687. /**
  72688. * Controls the density of each sample
  72689. */
  72690. density: number;
  72691. /**
  72692. * @constructor
  72693. * @param name The post-process name
  72694. * @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)
  72695. * @param camera The camera that the post-process will be attached to
  72696. * @param mesh The mesh used to create the light scattering
  72697. * @param samples The post-process quality, default 100
  72698. * @param samplingModeThe post-process filtering mode
  72699. * @param engine The babylon engine
  72700. * @param reusable If the post-process is reusable
  72701. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72702. */
  72703. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72704. /**
  72705. * Returns the string "VolumetricLightScatteringPostProcess"
  72706. * @returns "VolumetricLightScatteringPostProcess"
  72707. */
  72708. getClassName(): string;
  72709. private _isReady;
  72710. /**
  72711. * Sets the new light position for light scattering effect
  72712. * @param position The new custom light position
  72713. */
  72714. setCustomMeshPosition(position: Vector3): void;
  72715. /**
  72716. * Returns the light position for light scattering effect
  72717. * @return Vector3 The custom light position
  72718. */
  72719. getCustomMeshPosition(): Vector3;
  72720. /**
  72721. * Disposes the internal assets and detaches the post-process from the camera
  72722. */
  72723. dispose(camera: Camera): void;
  72724. /**
  72725. * Returns the render target texture used by the post-process
  72726. * @return the render target texture used by the post-process
  72727. */
  72728. getPass(): RenderTargetTexture;
  72729. private _meshExcluded;
  72730. private _createPass;
  72731. private _updateMeshScreenCoordinates;
  72732. /**
  72733. * Creates a default mesh for the Volumeric Light Scattering post-process
  72734. * @param name The mesh name
  72735. * @param scene The scene where to create the mesh
  72736. * @return the default mesh
  72737. */
  72738. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72739. }
  72740. }
  72741. declare module BABYLON {
  72742. /** @hidden */
  72743. export var screenSpaceCurvaturePixelShader: {
  72744. name: string;
  72745. shader: string;
  72746. };
  72747. }
  72748. declare module BABYLON {
  72749. /**
  72750. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72751. */
  72752. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72753. /**
  72754. * Defines how much ridge the curvature effect displays.
  72755. */
  72756. ridge: number;
  72757. /**
  72758. * Defines how much valley the curvature effect displays.
  72759. */
  72760. valley: number;
  72761. private _geometryBufferRenderer;
  72762. /**
  72763. * Gets a string identifying the name of the class
  72764. * @returns "ScreenSpaceCurvaturePostProcess" string
  72765. */
  72766. getClassName(): string;
  72767. /**
  72768. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72769. * @param name The name of the effect.
  72770. * @param scene The scene containing the objects to blur according to their velocity.
  72771. * @param options The required width/height ratio to downsize to before computing the render pass.
  72772. * @param camera The camera to apply the render pass to.
  72773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72774. * @param engine The engine which the post process will be applied. (default: current engine)
  72775. * @param reusable If the post process can be reused on the same frame. (default: false)
  72776. * @param textureType Type of textures used when performing the post process. (default: 0)
  72777. * @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)
  72778. */
  72779. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72780. /**
  72781. * Support test.
  72782. */
  72783. static get IsSupported(): boolean;
  72784. /** @hidden */
  72785. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72786. }
  72787. }
  72788. declare module BABYLON {
  72789. interface Scene {
  72790. /** @hidden (Backing field) */
  72791. _boundingBoxRenderer: BoundingBoxRenderer;
  72792. /** @hidden (Backing field) */
  72793. _forceShowBoundingBoxes: boolean;
  72794. /**
  72795. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72796. */
  72797. forceShowBoundingBoxes: boolean;
  72798. /**
  72799. * Gets the bounding box renderer associated with the scene
  72800. * @returns a BoundingBoxRenderer
  72801. */
  72802. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72803. }
  72804. interface AbstractMesh {
  72805. /** @hidden (Backing field) */
  72806. _showBoundingBox: boolean;
  72807. /**
  72808. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72809. */
  72810. showBoundingBox: boolean;
  72811. }
  72812. /**
  72813. * Component responsible of rendering the bounding box of the meshes in a scene.
  72814. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72815. */
  72816. export class BoundingBoxRenderer implements ISceneComponent {
  72817. /**
  72818. * The component name helpfull to identify the component in the list of scene components.
  72819. */
  72820. readonly name: string;
  72821. /**
  72822. * The scene the component belongs to.
  72823. */
  72824. scene: Scene;
  72825. /**
  72826. * Color of the bounding box lines placed in front of an object
  72827. */
  72828. frontColor: Color3;
  72829. /**
  72830. * Color of the bounding box lines placed behind an object
  72831. */
  72832. backColor: Color3;
  72833. /**
  72834. * Defines if the renderer should show the back lines or not
  72835. */
  72836. showBackLines: boolean;
  72837. /**
  72838. * Observable raised before rendering a bounding box
  72839. */
  72840. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72841. /**
  72842. * Observable raised after rendering a bounding box
  72843. */
  72844. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72845. /**
  72846. * Observable raised after resources are created
  72847. */
  72848. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  72849. /**
  72850. * When false, no bounding boxes will be rendered
  72851. */
  72852. enabled: boolean;
  72853. /**
  72854. * @hidden
  72855. */
  72856. renderList: SmartArray<BoundingBox>;
  72857. private _colorShader;
  72858. private _vertexBuffers;
  72859. private _indexBuffer;
  72860. private _fillIndexBuffer;
  72861. private _fillIndexData;
  72862. /**
  72863. * Instantiates a new bounding box renderer in a scene.
  72864. * @param scene the scene the renderer renders in
  72865. */
  72866. constructor(scene: Scene);
  72867. /**
  72868. * Registers the component in a given scene
  72869. */
  72870. register(): void;
  72871. private _evaluateSubMesh;
  72872. private _preActiveMesh;
  72873. private _prepareResources;
  72874. private _createIndexBuffer;
  72875. /**
  72876. * Rebuilds the elements related to this component in case of
  72877. * context lost for instance.
  72878. */
  72879. rebuild(): void;
  72880. /**
  72881. * @hidden
  72882. */
  72883. reset(): void;
  72884. /**
  72885. * Render the bounding boxes of a specific rendering group
  72886. * @param renderingGroupId defines the rendering group to render
  72887. */
  72888. render(renderingGroupId: number): void;
  72889. /**
  72890. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72891. * @param mesh Define the mesh to render the occlusion bounding box for
  72892. */
  72893. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72894. /**
  72895. * Dispose and release the resources attached to this renderer.
  72896. */
  72897. dispose(): void;
  72898. }
  72899. }
  72900. declare module BABYLON {
  72901. interface Scene {
  72902. /** @hidden (Backing field) */
  72903. _depthRenderer: {
  72904. [id: string]: DepthRenderer;
  72905. };
  72906. /**
  72907. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72908. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72909. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72910. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72911. * @returns the created depth renderer
  72912. */
  72913. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72914. /**
  72915. * Disables a depth renderer for a given camera
  72916. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72917. */
  72918. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72919. }
  72920. /**
  72921. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72922. * in several rendering techniques.
  72923. */
  72924. export class DepthRendererSceneComponent implements ISceneComponent {
  72925. /**
  72926. * The component name helpfull to identify the component in the list of scene components.
  72927. */
  72928. readonly name: string;
  72929. /**
  72930. * The scene the component belongs to.
  72931. */
  72932. scene: Scene;
  72933. /**
  72934. * Creates a new instance of the component for the given scene
  72935. * @param scene Defines the scene to register the component in
  72936. */
  72937. constructor(scene: Scene);
  72938. /**
  72939. * Registers the component in a given scene
  72940. */
  72941. register(): void;
  72942. /**
  72943. * Rebuilds the elements related to this component in case of
  72944. * context lost for instance.
  72945. */
  72946. rebuild(): void;
  72947. /**
  72948. * Disposes the component and the associated ressources
  72949. */
  72950. dispose(): void;
  72951. private _gatherRenderTargets;
  72952. private _gatherActiveCameraRenderTargets;
  72953. }
  72954. }
  72955. declare module BABYLON {
  72956. interface AbstractScene {
  72957. /** @hidden (Backing field) */
  72958. _prePassRenderer: Nullable<PrePassRenderer>;
  72959. /**
  72960. * Gets or Sets the current prepass renderer associated to the scene.
  72961. */
  72962. prePassRenderer: Nullable<PrePassRenderer>;
  72963. /**
  72964. * Enables the prepass and associates it with the scene
  72965. * @returns the PrePassRenderer
  72966. */
  72967. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72968. /**
  72969. * Disables the prepass associated with the scene
  72970. */
  72971. disablePrePassRenderer(): void;
  72972. }
  72973. /**
  72974. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72975. * in several rendering techniques.
  72976. */
  72977. export class PrePassRendererSceneComponent implements ISceneComponent {
  72978. /**
  72979. * The component name helpful to identify the component in the list of scene components.
  72980. */
  72981. readonly name: string;
  72982. /**
  72983. * The scene the component belongs to.
  72984. */
  72985. scene: Scene;
  72986. /**
  72987. * Creates a new instance of the component for the given scene
  72988. * @param scene Defines the scene to register the component in
  72989. */
  72990. constructor(scene: Scene);
  72991. /**
  72992. * Registers the component in a given scene
  72993. */
  72994. register(): void;
  72995. private _beforeCameraDraw;
  72996. private _afterCameraDraw;
  72997. private _beforeClearStage;
  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. }
  73008. }
  73009. declare module BABYLON {
  73010. /** @hidden */
  73011. export var fibonacci: {
  73012. name: string;
  73013. shader: string;
  73014. };
  73015. }
  73016. declare module BABYLON {
  73017. /** @hidden */
  73018. export var diffusionProfile: {
  73019. name: string;
  73020. shader: string;
  73021. };
  73022. }
  73023. declare module BABYLON {
  73024. /** @hidden */
  73025. export var subSurfaceScatteringPixelShader: {
  73026. name: string;
  73027. shader: string;
  73028. };
  73029. }
  73030. declare module BABYLON {
  73031. /**
  73032. * Sub surface scattering post process
  73033. */
  73034. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73035. /**
  73036. * Gets a string identifying the name of the class
  73037. * @returns "SubSurfaceScatteringPostProcess" string
  73038. */
  73039. getClassName(): string;
  73040. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73041. }
  73042. }
  73043. declare module BABYLON {
  73044. /**
  73045. * Contains all parameters needed for the prepass to perform
  73046. * screen space subsurface scattering
  73047. */
  73048. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73049. /** @hidden */
  73050. static _SceneComponentInitialization: (scene: Scene) => void;
  73051. private _ssDiffusionS;
  73052. private _ssFilterRadii;
  73053. private _ssDiffusionD;
  73054. /**
  73055. * Post process to attach for screen space subsurface scattering
  73056. */
  73057. postProcess: SubSurfaceScatteringPostProcess;
  73058. /**
  73059. * Diffusion profile color for subsurface scattering
  73060. */
  73061. get ssDiffusionS(): number[];
  73062. /**
  73063. * Diffusion profile max color channel value for subsurface scattering
  73064. */
  73065. get ssDiffusionD(): number[];
  73066. /**
  73067. * Diffusion profile filter radius for subsurface scattering
  73068. */
  73069. get ssFilterRadii(): number[];
  73070. /**
  73071. * Is subsurface enabled
  73072. */
  73073. enabled: boolean;
  73074. /**
  73075. * Name of the configuration
  73076. */
  73077. name: string;
  73078. /**
  73079. * Diffusion profile colors for subsurface scattering
  73080. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73081. * See ...
  73082. * Note that you can only store up to 5 of them
  73083. */
  73084. ssDiffusionProfileColors: Color3[];
  73085. /**
  73086. * Defines the ratio real world => scene units.
  73087. * Used for subsurface scattering
  73088. */
  73089. metersPerUnit: number;
  73090. /**
  73091. * Textures that should be present in the MRT for this effect to work
  73092. */
  73093. readonly texturesRequired: number[];
  73094. private _scene;
  73095. /**
  73096. * Builds a subsurface configuration object
  73097. * @param scene The scene
  73098. */
  73099. constructor(scene: Scene);
  73100. /**
  73101. * Adds a new diffusion profile.
  73102. * Useful for more realistic subsurface scattering on diverse materials.
  73103. * @param color The color of the diffusion profile. Should be the average color of the material.
  73104. * @return The index of the diffusion profile for the material subsurface configuration
  73105. */
  73106. addDiffusionProfile(color: Color3): number;
  73107. /**
  73108. * Creates the sss post process
  73109. * @return The created post process
  73110. */
  73111. createPostProcess(): SubSurfaceScatteringPostProcess;
  73112. /**
  73113. * Deletes all diffusion profiles.
  73114. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73115. */
  73116. clearAllDiffusionProfiles(): void;
  73117. /**
  73118. * Disposes this object
  73119. */
  73120. dispose(): void;
  73121. /**
  73122. * @hidden
  73123. * https://zero-radiance.github.io/post/sampling-diffusion/
  73124. *
  73125. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73126. * ------------------------------------------------------------------------------------
  73127. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73128. * PDF[r, phi, s] = r * R[r, phi, s]
  73129. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73130. * ------------------------------------------------------------------------------------
  73131. * We importance sample the color channel with the widest scattering distance.
  73132. */
  73133. getDiffusionProfileParameters(color: Color3): number;
  73134. /**
  73135. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73136. * 'u' is the random number (the value of the CDF): [0, 1).
  73137. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73138. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73139. */
  73140. private _sampleBurleyDiffusionProfile;
  73141. }
  73142. }
  73143. declare module BABYLON {
  73144. interface AbstractScene {
  73145. /** @hidden (Backing field) */
  73146. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73147. /**
  73148. * Gets or Sets the current prepass renderer associated to the scene.
  73149. */
  73150. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73151. /**
  73152. * Enables the subsurface effect for prepass
  73153. * @returns the SubSurfaceConfiguration
  73154. */
  73155. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73156. /**
  73157. * Disables the subsurface effect for prepass
  73158. */
  73159. disableSubSurfaceForPrePass(): void;
  73160. }
  73161. /**
  73162. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73163. * in several rendering techniques.
  73164. */
  73165. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73166. /**
  73167. * The component name helpful to identify the component in the list of scene components.
  73168. */
  73169. readonly name: string;
  73170. /**
  73171. * The scene the component belongs to.
  73172. */
  73173. scene: Scene;
  73174. /**
  73175. * Creates a new instance of the component for the given scene
  73176. * @param scene Defines the scene to register the component in
  73177. */
  73178. constructor(scene: Scene);
  73179. /**
  73180. * Registers the component in a given scene
  73181. */
  73182. register(): void;
  73183. /**
  73184. * Serializes the component data to the specified json object
  73185. * @param serializationObject The object to serialize to
  73186. */
  73187. serialize(serializationObject: any): void;
  73188. /**
  73189. * Adds all the elements from the container to the scene
  73190. * @param container the container holding the elements
  73191. */
  73192. addFromContainer(container: AbstractScene): void;
  73193. /**
  73194. * Removes all the elements in the container from the scene
  73195. * @param container contains the elements to remove
  73196. * @param dispose if the removed element should be disposed (default: false)
  73197. */
  73198. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73199. /**
  73200. * Rebuilds the elements related to this component in case of
  73201. * context lost for instance.
  73202. */
  73203. rebuild(): void;
  73204. /**
  73205. * Disposes the component and the associated ressources
  73206. */
  73207. dispose(): void;
  73208. }
  73209. }
  73210. declare module BABYLON {
  73211. /** @hidden */
  73212. export var outlinePixelShader: {
  73213. name: string;
  73214. shader: string;
  73215. };
  73216. }
  73217. declare module BABYLON {
  73218. /** @hidden */
  73219. export var outlineVertexShader: {
  73220. name: string;
  73221. shader: string;
  73222. };
  73223. }
  73224. declare module BABYLON {
  73225. interface Scene {
  73226. /** @hidden */
  73227. _outlineRenderer: OutlineRenderer;
  73228. /**
  73229. * Gets the outline renderer associated with the scene
  73230. * @returns a OutlineRenderer
  73231. */
  73232. getOutlineRenderer(): OutlineRenderer;
  73233. }
  73234. interface AbstractMesh {
  73235. /** @hidden (Backing field) */
  73236. _renderOutline: boolean;
  73237. /**
  73238. * Gets or sets a boolean indicating if the outline must be rendered as well
  73239. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73240. */
  73241. renderOutline: boolean;
  73242. /** @hidden (Backing field) */
  73243. _renderOverlay: boolean;
  73244. /**
  73245. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73246. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73247. */
  73248. renderOverlay: boolean;
  73249. }
  73250. /**
  73251. * This class is responsible to draw bothe outline/overlay of meshes.
  73252. * It should not be used directly but through the available method on mesh.
  73253. */
  73254. export class OutlineRenderer implements ISceneComponent {
  73255. /**
  73256. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73257. */
  73258. private static _StencilReference;
  73259. /**
  73260. * The name of the component. Each component must have a unique name.
  73261. */
  73262. name: string;
  73263. /**
  73264. * The scene the component belongs to.
  73265. */
  73266. scene: Scene;
  73267. /**
  73268. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73269. */
  73270. zOffset: number;
  73271. private _engine;
  73272. private _effect;
  73273. private _cachedDefines;
  73274. private _savedDepthWrite;
  73275. /**
  73276. * Instantiates a new outline renderer. (There could be only one per scene).
  73277. * @param scene Defines the scene it belongs to
  73278. */
  73279. constructor(scene: Scene);
  73280. /**
  73281. * Register the component to one instance of a scene.
  73282. */
  73283. register(): void;
  73284. /**
  73285. * Rebuilds the elements related to this component in case of
  73286. * context lost for instance.
  73287. */
  73288. rebuild(): void;
  73289. /**
  73290. * Disposes the component and the associated ressources.
  73291. */
  73292. dispose(): void;
  73293. /**
  73294. * Renders the outline in the canvas.
  73295. * @param subMesh Defines the sumesh to render
  73296. * @param batch Defines the batch of meshes in case of instances
  73297. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73298. */
  73299. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73300. /**
  73301. * Returns whether or not the outline renderer is ready for a given submesh.
  73302. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73303. * @param subMesh Defines the submesh to check readyness for
  73304. * @param useInstances Defines wheter wee are trying to render instances or not
  73305. * @returns true if ready otherwise false
  73306. */
  73307. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73308. private _beforeRenderingMesh;
  73309. private _afterRenderingMesh;
  73310. }
  73311. }
  73312. declare module BABYLON {
  73313. /**
  73314. * Defines the basic options interface of a Sprite Frame Source Size.
  73315. */
  73316. export interface ISpriteJSONSpriteSourceSize {
  73317. /**
  73318. * number of the original width of the Frame
  73319. */
  73320. w: number;
  73321. /**
  73322. * number of the original height of the Frame
  73323. */
  73324. h: number;
  73325. }
  73326. /**
  73327. * Defines the basic options interface of a Sprite Frame Data.
  73328. */
  73329. export interface ISpriteJSONSpriteFrameData {
  73330. /**
  73331. * number of the x offset of the Frame
  73332. */
  73333. x: number;
  73334. /**
  73335. * number of the y offset of the Frame
  73336. */
  73337. y: number;
  73338. /**
  73339. * number of the width of the Frame
  73340. */
  73341. w: number;
  73342. /**
  73343. * number of the height of the Frame
  73344. */
  73345. h: number;
  73346. }
  73347. /**
  73348. * Defines the basic options interface of a JSON Sprite.
  73349. */
  73350. export interface ISpriteJSONSprite {
  73351. /**
  73352. * string name of the Frame
  73353. */
  73354. filename: string;
  73355. /**
  73356. * ISpriteJSONSpriteFrame basic object of the frame data
  73357. */
  73358. frame: ISpriteJSONSpriteFrameData;
  73359. /**
  73360. * boolean to flag is the frame was rotated.
  73361. */
  73362. rotated: boolean;
  73363. /**
  73364. * boolean to flag is the frame was trimmed.
  73365. */
  73366. trimmed: boolean;
  73367. /**
  73368. * ISpriteJSONSpriteFrame basic object of the source data
  73369. */
  73370. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73371. /**
  73372. * ISpriteJSONSpriteFrame basic object of the source data
  73373. */
  73374. sourceSize: ISpriteJSONSpriteSourceSize;
  73375. }
  73376. /**
  73377. * Defines the basic options interface of a JSON atlas.
  73378. */
  73379. export interface ISpriteJSONAtlas {
  73380. /**
  73381. * Array of objects that contain the frame data.
  73382. */
  73383. frames: Array<ISpriteJSONSprite>;
  73384. /**
  73385. * object basic object containing the sprite meta data.
  73386. */
  73387. meta?: object;
  73388. }
  73389. }
  73390. declare module BABYLON {
  73391. /** @hidden */
  73392. export var spriteMapPixelShader: {
  73393. name: string;
  73394. shader: string;
  73395. };
  73396. }
  73397. declare module BABYLON {
  73398. /** @hidden */
  73399. export var spriteMapVertexShader: {
  73400. name: string;
  73401. shader: string;
  73402. };
  73403. }
  73404. declare module BABYLON {
  73405. /**
  73406. * Defines the basic options interface of a SpriteMap
  73407. */
  73408. export interface ISpriteMapOptions {
  73409. /**
  73410. * Vector2 of the number of cells in the grid.
  73411. */
  73412. stageSize?: Vector2;
  73413. /**
  73414. * Vector2 of the size of the output plane in World Units.
  73415. */
  73416. outputSize?: Vector2;
  73417. /**
  73418. * Vector3 of the position of the output plane in World Units.
  73419. */
  73420. outputPosition?: Vector3;
  73421. /**
  73422. * Vector3 of the rotation of the output plane.
  73423. */
  73424. outputRotation?: Vector3;
  73425. /**
  73426. * number of layers that the system will reserve in resources.
  73427. */
  73428. layerCount?: number;
  73429. /**
  73430. * number of max animation frames a single cell will reserve in resources.
  73431. */
  73432. maxAnimationFrames?: number;
  73433. /**
  73434. * number cell index of the base tile when the system compiles.
  73435. */
  73436. baseTile?: number;
  73437. /**
  73438. * boolean flip the sprite after its been repositioned by the framing data.
  73439. */
  73440. flipU?: boolean;
  73441. /**
  73442. * Vector3 scalar of the global RGB values of the SpriteMap.
  73443. */
  73444. colorMultiply?: Vector3;
  73445. }
  73446. /**
  73447. * Defines the IDisposable interface in order to be cleanable from resources.
  73448. */
  73449. export interface ISpriteMap extends IDisposable {
  73450. /**
  73451. * String name of the SpriteMap.
  73452. */
  73453. name: string;
  73454. /**
  73455. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73456. */
  73457. atlasJSON: ISpriteJSONAtlas;
  73458. /**
  73459. * Texture of the SpriteMap.
  73460. */
  73461. spriteSheet: Texture;
  73462. /**
  73463. * The parameters to initialize the SpriteMap with.
  73464. */
  73465. options: ISpriteMapOptions;
  73466. }
  73467. /**
  73468. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73469. */
  73470. export class SpriteMap implements ISpriteMap {
  73471. /** The Name of the spriteMap */
  73472. name: string;
  73473. /** The JSON file with the frame and meta data */
  73474. atlasJSON: ISpriteJSONAtlas;
  73475. /** The systems Sprite Sheet Texture */
  73476. spriteSheet: Texture;
  73477. /** Arguments passed with the Constructor */
  73478. options: ISpriteMapOptions;
  73479. /** Public Sprite Storage array, parsed from atlasJSON */
  73480. sprites: Array<ISpriteJSONSprite>;
  73481. /** Returns the Number of Sprites in the System */
  73482. get spriteCount(): number;
  73483. /** Returns the Position of Output Plane*/
  73484. get position(): Vector3;
  73485. /** Returns the Position of Output Plane*/
  73486. set position(v: Vector3);
  73487. /** Returns the Rotation of Output Plane*/
  73488. get rotation(): Vector3;
  73489. /** Returns the Rotation of Output Plane*/
  73490. set rotation(v: Vector3);
  73491. /** Sets the AnimationMap*/
  73492. get animationMap(): RawTexture;
  73493. /** Sets the AnimationMap*/
  73494. set animationMap(v: RawTexture);
  73495. /** Scene that the SpriteMap was created in */
  73496. private _scene;
  73497. /** Texture Buffer of Float32 that holds tile frame data*/
  73498. private _frameMap;
  73499. /** Texture Buffers of Float32 that holds tileMap data*/
  73500. private _tileMaps;
  73501. /** Texture Buffer of Float32 that holds Animation Data*/
  73502. private _animationMap;
  73503. /** Custom ShaderMaterial Central to the System*/
  73504. private _material;
  73505. /** Custom ShaderMaterial Central to the System*/
  73506. private _output;
  73507. /** Systems Time Ticker*/
  73508. private _time;
  73509. /**
  73510. * Creates a new SpriteMap
  73511. * @param name defines the SpriteMaps Name
  73512. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73513. * @param spriteSheet is the Texture that the Sprites are on.
  73514. * @param options a basic deployment configuration
  73515. * @param scene The Scene that the map is deployed on
  73516. */
  73517. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73518. /**
  73519. * Returns tileID location
  73520. * @returns Vector2 the cell position ID
  73521. */
  73522. getTileID(): Vector2;
  73523. /**
  73524. * Gets the UV location of the mouse over the SpriteMap.
  73525. * @returns Vector2 the UV position of the mouse interaction
  73526. */
  73527. getMousePosition(): Vector2;
  73528. /**
  73529. * Creates the "frame" texture Buffer
  73530. * -------------------------------------
  73531. * Structure of frames
  73532. * "filename": "Falling-Water-2.png",
  73533. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73534. * "rotated": true,
  73535. * "trimmed": true,
  73536. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73537. * "sourceSize": {"w":32,"h":32}
  73538. * @returns RawTexture of the frameMap
  73539. */
  73540. private _createFrameBuffer;
  73541. /**
  73542. * Creates the tileMap texture Buffer
  73543. * @param buffer normally and array of numbers, or a false to generate from scratch
  73544. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73545. * @returns RawTexture of the tileMap
  73546. */
  73547. private _createTileBuffer;
  73548. /**
  73549. * Modifies the data of the tileMaps
  73550. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73551. * @param pos is the iVector2 Coordinates of the Tile
  73552. * @param tile The SpriteIndex of the new Tile
  73553. */
  73554. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73555. /**
  73556. * Creates the animationMap texture Buffer
  73557. * @param buffer normally and array of numbers, or a false to generate from scratch
  73558. * @returns RawTexture of the animationMap
  73559. */
  73560. private _createTileAnimationBuffer;
  73561. /**
  73562. * Modifies the data of the animationMap
  73563. * @param cellID is the Index of the Sprite
  73564. * @param _frame is the target Animation frame
  73565. * @param toCell is the Target Index of the next frame of the animation
  73566. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73567. * @param speed is a global scalar of the time variable on the map.
  73568. */
  73569. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73570. /**
  73571. * Exports the .tilemaps file
  73572. */
  73573. saveTileMaps(): void;
  73574. /**
  73575. * Imports the .tilemaps file
  73576. * @param url of the .tilemaps file
  73577. */
  73578. loadTileMaps(url: string): void;
  73579. /**
  73580. * Release associated resources
  73581. */
  73582. dispose(): void;
  73583. }
  73584. }
  73585. declare module BABYLON {
  73586. /**
  73587. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73588. * @see https://doc.babylonjs.com/babylon101/sprites
  73589. */
  73590. export class SpritePackedManager extends SpriteManager {
  73591. /** defines the packed manager's name */
  73592. name: string;
  73593. /**
  73594. * Creates a new sprite manager from a packed sprite sheet
  73595. * @param name defines the manager's name
  73596. * @param imgUrl defines the sprite sheet url
  73597. * @param capacity defines the maximum allowed number of sprites
  73598. * @param scene defines the hosting scene
  73599. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73600. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73601. * @param samplingMode defines the smapling mode to use with spritesheet
  73602. * @param fromPacked set to true; do not alter
  73603. */
  73604. constructor(
  73605. /** defines the packed manager's name */
  73606. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73607. }
  73608. }
  73609. declare module BABYLON {
  73610. /**
  73611. * Defines the list of states available for a task inside a AssetsManager
  73612. */
  73613. export enum AssetTaskState {
  73614. /**
  73615. * Initialization
  73616. */
  73617. INIT = 0,
  73618. /**
  73619. * Running
  73620. */
  73621. RUNNING = 1,
  73622. /**
  73623. * Done
  73624. */
  73625. DONE = 2,
  73626. /**
  73627. * Error
  73628. */
  73629. ERROR = 3
  73630. }
  73631. /**
  73632. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73633. */
  73634. export abstract class AbstractAssetTask {
  73635. /**
  73636. * Task name
  73637. */ name: string;
  73638. /**
  73639. * Callback called when the task is successful
  73640. */
  73641. onSuccess: (task: any) => void;
  73642. /**
  73643. * Callback called when the task is not successful
  73644. */
  73645. onError: (task: any, message?: string, exception?: any) => void;
  73646. /**
  73647. * Creates a new AssetsManager
  73648. * @param name defines the name of the task
  73649. */
  73650. constructor(
  73651. /**
  73652. * Task name
  73653. */ name: string);
  73654. private _isCompleted;
  73655. private _taskState;
  73656. private _errorObject;
  73657. /**
  73658. * Get if the task is completed
  73659. */
  73660. get isCompleted(): boolean;
  73661. /**
  73662. * Gets the current state of the task
  73663. */
  73664. get taskState(): AssetTaskState;
  73665. /**
  73666. * Gets the current error object (if task is in error)
  73667. */
  73668. get errorObject(): {
  73669. message?: string;
  73670. exception?: any;
  73671. };
  73672. /**
  73673. * Internal only
  73674. * @hidden
  73675. */
  73676. _setErrorObject(message?: string, exception?: any): void;
  73677. /**
  73678. * Execute the current task
  73679. * @param scene defines the scene where you want your assets to be loaded
  73680. * @param onSuccess is a callback called when the task is successfully executed
  73681. * @param onError is a callback called if an error occurs
  73682. */
  73683. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73684. /**
  73685. * Execute the current task
  73686. * @param scene defines the scene where you want your assets to be loaded
  73687. * @param onSuccess is a callback called when the task is successfully executed
  73688. * @param onError is a callback called if an error occurs
  73689. */
  73690. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73691. /**
  73692. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73693. * This can be used with failed tasks that have the reason for failure fixed.
  73694. */
  73695. reset(): void;
  73696. private onErrorCallback;
  73697. private onDoneCallback;
  73698. }
  73699. /**
  73700. * Define the interface used by progress events raised during assets loading
  73701. */
  73702. export interface IAssetsProgressEvent {
  73703. /**
  73704. * Defines the number of remaining tasks to process
  73705. */
  73706. remainingCount: number;
  73707. /**
  73708. * Defines the total number of tasks
  73709. */
  73710. totalCount: number;
  73711. /**
  73712. * Defines the task that was just processed
  73713. */
  73714. task: AbstractAssetTask;
  73715. }
  73716. /**
  73717. * Class used to share progress information about assets loading
  73718. */
  73719. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73720. /**
  73721. * Defines the number of remaining tasks to process
  73722. */
  73723. remainingCount: number;
  73724. /**
  73725. * Defines the total number of tasks
  73726. */
  73727. totalCount: number;
  73728. /**
  73729. * Defines the task that was just processed
  73730. */
  73731. task: AbstractAssetTask;
  73732. /**
  73733. * Creates a AssetsProgressEvent
  73734. * @param remainingCount defines the number of remaining tasks to process
  73735. * @param totalCount defines the total number of tasks
  73736. * @param task defines the task that was just processed
  73737. */
  73738. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73739. }
  73740. /**
  73741. * Define a task used by AssetsManager to load assets into a container
  73742. */
  73743. export class ContainerAssetTask extends AbstractAssetTask {
  73744. /**
  73745. * Defines the name of the task
  73746. */
  73747. name: string;
  73748. /**
  73749. * Defines the list of mesh's names you want to load
  73750. */
  73751. meshesNames: any;
  73752. /**
  73753. * Defines the root url to use as a base to load your meshes and associated resources
  73754. */
  73755. rootUrl: string;
  73756. /**
  73757. * Defines the filename or File of the scene to load from
  73758. */
  73759. sceneFilename: string | File;
  73760. /**
  73761. * Get the loaded asset container
  73762. */
  73763. loadedContainer: AssetContainer;
  73764. /**
  73765. * Gets the list of loaded meshes
  73766. */
  73767. loadedMeshes: Array<AbstractMesh>;
  73768. /**
  73769. * Gets the list of loaded particle systems
  73770. */
  73771. loadedParticleSystems: Array<IParticleSystem>;
  73772. /**
  73773. * Gets the list of loaded skeletons
  73774. */
  73775. loadedSkeletons: Array<Skeleton>;
  73776. /**
  73777. * Gets the list of loaded animation groups
  73778. */
  73779. loadedAnimationGroups: Array<AnimationGroup>;
  73780. /**
  73781. * Callback called when the task is successful
  73782. */
  73783. onSuccess: (task: ContainerAssetTask) => void;
  73784. /**
  73785. * Callback called when the task is successful
  73786. */
  73787. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73788. /**
  73789. * Creates a new ContainerAssetTask
  73790. * @param name defines the name of the task
  73791. * @param meshesNames defines the list of mesh's names you want to load
  73792. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73793. * @param sceneFilename defines the filename or File of the scene to load from
  73794. */
  73795. constructor(
  73796. /**
  73797. * Defines the name of the task
  73798. */
  73799. name: string,
  73800. /**
  73801. * Defines the list of mesh's names you want to load
  73802. */
  73803. meshesNames: any,
  73804. /**
  73805. * Defines the root url to use as a base to load your meshes and associated resources
  73806. */
  73807. rootUrl: string,
  73808. /**
  73809. * Defines the filename or File of the scene to load from
  73810. */
  73811. sceneFilename: string | File);
  73812. /**
  73813. * Execute the current task
  73814. * @param scene defines the scene where you want your assets to be loaded
  73815. * @param onSuccess is a callback called when the task is successfully executed
  73816. * @param onError is a callback called if an error occurs
  73817. */
  73818. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73819. }
  73820. /**
  73821. * Define a task used by AssetsManager to load meshes
  73822. */
  73823. export class MeshAssetTask extends AbstractAssetTask {
  73824. /**
  73825. * Defines the name of the task
  73826. */
  73827. name: string;
  73828. /**
  73829. * Defines the list of mesh's names you want to load
  73830. */
  73831. meshesNames: any;
  73832. /**
  73833. * Defines the root url to use as a base to load your meshes and associated resources
  73834. */
  73835. rootUrl: string;
  73836. /**
  73837. * Defines the filename or File of the scene to load from
  73838. */
  73839. sceneFilename: string | File;
  73840. /**
  73841. * Gets the list of loaded meshes
  73842. */
  73843. loadedMeshes: Array<AbstractMesh>;
  73844. /**
  73845. * Gets the list of loaded particle systems
  73846. */
  73847. loadedParticleSystems: Array<IParticleSystem>;
  73848. /**
  73849. * Gets the list of loaded skeletons
  73850. */
  73851. loadedSkeletons: Array<Skeleton>;
  73852. /**
  73853. * Gets the list of loaded animation groups
  73854. */
  73855. loadedAnimationGroups: Array<AnimationGroup>;
  73856. /**
  73857. * Callback called when the task is successful
  73858. */
  73859. onSuccess: (task: MeshAssetTask) => void;
  73860. /**
  73861. * Callback called when the task is successful
  73862. */
  73863. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73864. /**
  73865. * Creates a new MeshAssetTask
  73866. * @param name defines the name of the task
  73867. * @param meshesNames defines the list of mesh's names you want to load
  73868. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73869. * @param sceneFilename defines the filename or File of the scene to load from
  73870. */
  73871. constructor(
  73872. /**
  73873. * Defines the name of the task
  73874. */
  73875. name: string,
  73876. /**
  73877. * Defines the list of mesh's names you want to load
  73878. */
  73879. meshesNames: any,
  73880. /**
  73881. * Defines the root url to use as a base to load your meshes and associated resources
  73882. */
  73883. rootUrl: string,
  73884. /**
  73885. * Defines the filename or File of the scene to load from
  73886. */
  73887. sceneFilename: string | File);
  73888. /**
  73889. * Execute the current task
  73890. * @param scene defines the scene where you want your assets to be loaded
  73891. * @param onSuccess is a callback called when the task is successfully executed
  73892. * @param onError is a callback called if an error occurs
  73893. */
  73894. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73895. }
  73896. /**
  73897. * Define a task used by AssetsManager to load text content
  73898. */
  73899. export class TextFileAssetTask extends AbstractAssetTask {
  73900. /**
  73901. * Defines the name of the task
  73902. */
  73903. name: string;
  73904. /**
  73905. * Defines the location of the file to load
  73906. */
  73907. url: string;
  73908. /**
  73909. * Gets the loaded text string
  73910. */
  73911. text: string;
  73912. /**
  73913. * Callback called when the task is successful
  73914. */
  73915. onSuccess: (task: TextFileAssetTask) => void;
  73916. /**
  73917. * Callback called when the task is successful
  73918. */
  73919. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73920. /**
  73921. * Creates a new TextFileAssetTask object
  73922. * @param name defines the name of the task
  73923. * @param url defines the location of the file to load
  73924. */
  73925. constructor(
  73926. /**
  73927. * Defines the name of the task
  73928. */
  73929. name: string,
  73930. /**
  73931. * Defines the location of the file to load
  73932. */
  73933. url: string);
  73934. /**
  73935. * Execute the current task
  73936. * @param scene defines the scene where you want your assets to be loaded
  73937. * @param onSuccess is a callback called when the task is successfully executed
  73938. * @param onError is a callback called if an error occurs
  73939. */
  73940. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73941. }
  73942. /**
  73943. * Define a task used by AssetsManager to load binary data
  73944. */
  73945. export class BinaryFileAssetTask extends AbstractAssetTask {
  73946. /**
  73947. * Defines the name of the task
  73948. */
  73949. name: string;
  73950. /**
  73951. * Defines the location of the file to load
  73952. */
  73953. url: string;
  73954. /**
  73955. * Gets the lodaded data (as an array buffer)
  73956. */
  73957. data: ArrayBuffer;
  73958. /**
  73959. * Callback called when the task is successful
  73960. */
  73961. onSuccess: (task: BinaryFileAssetTask) => void;
  73962. /**
  73963. * Callback called when the task is successful
  73964. */
  73965. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73966. /**
  73967. * Creates a new BinaryFileAssetTask object
  73968. * @param name defines the name of the new task
  73969. * @param url defines the location of the file to load
  73970. */
  73971. constructor(
  73972. /**
  73973. * Defines the name of the task
  73974. */
  73975. name: string,
  73976. /**
  73977. * Defines the location of the file to load
  73978. */
  73979. url: string);
  73980. /**
  73981. * Execute the current task
  73982. * @param scene defines the scene where you want your assets to be loaded
  73983. * @param onSuccess is a callback called when the task is successfully executed
  73984. * @param onError is a callback called if an error occurs
  73985. */
  73986. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73987. }
  73988. /**
  73989. * Define a task used by AssetsManager to load images
  73990. */
  73991. export class ImageAssetTask extends AbstractAssetTask {
  73992. /**
  73993. * Defines the name of the task
  73994. */
  73995. name: string;
  73996. /**
  73997. * Defines the location of the image to load
  73998. */
  73999. url: string;
  74000. /**
  74001. * Gets the loaded images
  74002. */
  74003. image: HTMLImageElement;
  74004. /**
  74005. * Callback called when the task is successful
  74006. */
  74007. onSuccess: (task: ImageAssetTask) => void;
  74008. /**
  74009. * Callback called when the task is successful
  74010. */
  74011. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74012. /**
  74013. * Creates a new ImageAssetTask
  74014. * @param name defines the name of the task
  74015. * @param url defines the location of the image to load
  74016. */
  74017. constructor(
  74018. /**
  74019. * Defines the name of the task
  74020. */
  74021. name: string,
  74022. /**
  74023. * Defines the location of the image to load
  74024. */
  74025. url: string);
  74026. /**
  74027. * Execute the current task
  74028. * @param scene defines the scene where you want your assets to be loaded
  74029. * @param onSuccess is a callback called when the task is successfully executed
  74030. * @param onError is a callback called if an error occurs
  74031. */
  74032. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74033. }
  74034. /**
  74035. * Defines the interface used by texture loading tasks
  74036. */
  74037. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74038. /**
  74039. * Gets the loaded texture
  74040. */
  74041. texture: TEX;
  74042. }
  74043. /**
  74044. * Define a task used by AssetsManager to load 2D textures
  74045. */
  74046. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74047. /**
  74048. * Defines the name of the task
  74049. */
  74050. name: string;
  74051. /**
  74052. * Defines the location of the file to load
  74053. */
  74054. url: string;
  74055. /**
  74056. * Defines if mipmap should not be generated (default is false)
  74057. */
  74058. noMipmap?: boolean | undefined;
  74059. /**
  74060. * Defines if texture must be inverted on Y axis (default is true)
  74061. */
  74062. invertY: boolean;
  74063. /**
  74064. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74065. */
  74066. samplingMode: number;
  74067. /**
  74068. * Gets the loaded texture
  74069. */
  74070. texture: Texture;
  74071. /**
  74072. * Callback called when the task is successful
  74073. */
  74074. onSuccess: (task: TextureAssetTask) => void;
  74075. /**
  74076. * Callback called when the task is successful
  74077. */
  74078. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74079. /**
  74080. * Creates a new TextureAssetTask object
  74081. * @param name defines the name of the task
  74082. * @param url defines the location of the file to load
  74083. * @param noMipmap defines if mipmap should not be generated (default is false)
  74084. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74085. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74086. */
  74087. constructor(
  74088. /**
  74089. * Defines the name of the task
  74090. */
  74091. name: string,
  74092. /**
  74093. * Defines the location of the file to load
  74094. */
  74095. url: string,
  74096. /**
  74097. * Defines if mipmap should not be generated (default is false)
  74098. */
  74099. noMipmap?: boolean | undefined,
  74100. /**
  74101. * Defines if texture must be inverted on Y axis (default is true)
  74102. */
  74103. invertY?: boolean,
  74104. /**
  74105. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74106. */
  74107. samplingMode?: number);
  74108. /**
  74109. * Execute the current task
  74110. * @param scene defines the scene where you want your assets to be loaded
  74111. * @param onSuccess is a callback called when the task is successfully executed
  74112. * @param onError is a callback called if an error occurs
  74113. */
  74114. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74115. }
  74116. /**
  74117. * Define a task used by AssetsManager to load cube textures
  74118. */
  74119. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74120. /**
  74121. * Defines the name of the task
  74122. */
  74123. name: string;
  74124. /**
  74125. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74126. */
  74127. url: string;
  74128. /**
  74129. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74130. */
  74131. extensions?: string[] | undefined;
  74132. /**
  74133. * Defines if mipmaps should not be generated (default is false)
  74134. */
  74135. noMipmap?: boolean | undefined;
  74136. /**
  74137. * Defines the explicit list of files (undefined by default)
  74138. */
  74139. files?: string[] | undefined;
  74140. /**
  74141. * Gets the loaded texture
  74142. */
  74143. texture: CubeTexture;
  74144. /**
  74145. * Callback called when the task is successful
  74146. */
  74147. onSuccess: (task: CubeTextureAssetTask) => void;
  74148. /**
  74149. * Callback called when the task is successful
  74150. */
  74151. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74152. /**
  74153. * Creates a new CubeTextureAssetTask
  74154. * @param name defines the name of the task
  74155. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74156. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74157. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74158. * @param files defines the explicit list of files (undefined by default)
  74159. */
  74160. constructor(
  74161. /**
  74162. * Defines the name of the task
  74163. */
  74164. name: string,
  74165. /**
  74166. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74167. */
  74168. url: string,
  74169. /**
  74170. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74171. */
  74172. extensions?: string[] | undefined,
  74173. /**
  74174. * Defines if mipmaps should not be generated (default is false)
  74175. */
  74176. noMipmap?: boolean | undefined,
  74177. /**
  74178. * Defines the explicit list of files (undefined by default)
  74179. */
  74180. files?: string[] | undefined);
  74181. /**
  74182. * Execute the current task
  74183. * @param scene defines the scene where you want your assets to be loaded
  74184. * @param onSuccess is a callback called when the task is successfully executed
  74185. * @param onError is a callback called if an error occurs
  74186. */
  74187. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74188. }
  74189. /**
  74190. * Define a task used by AssetsManager to load HDR cube textures
  74191. */
  74192. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74193. /**
  74194. * Defines the name of the task
  74195. */
  74196. name: string;
  74197. /**
  74198. * Defines the location of the file to load
  74199. */
  74200. url: string;
  74201. /**
  74202. * Defines the desired size (the more it increases the longer the generation will be)
  74203. */
  74204. size: number;
  74205. /**
  74206. * Defines if mipmaps should not be generated (default is false)
  74207. */
  74208. noMipmap: boolean;
  74209. /**
  74210. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74211. */
  74212. generateHarmonics: boolean;
  74213. /**
  74214. * 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)
  74215. */
  74216. gammaSpace: boolean;
  74217. /**
  74218. * Internal Use Only
  74219. */
  74220. reserved: boolean;
  74221. /**
  74222. * Gets the loaded texture
  74223. */
  74224. texture: HDRCubeTexture;
  74225. /**
  74226. * Callback called when the task is successful
  74227. */
  74228. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74229. /**
  74230. * Callback called when the task is successful
  74231. */
  74232. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74233. /**
  74234. * Creates a new HDRCubeTextureAssetTask object
  74235. * @param name defines the name of the task
  74236. * @param url defines the location of the file to load
  74237. * @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.
  74238. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74239. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74240. * @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)
  74241. * @param reserved Internal use only
  74242. */
  74243. constructor(
  74244. /**
  74245. * Defines the name of the task
  74246. */
  74247. name: string,
  74248. /**
  74249. * Defines the location of the file to load
  74250. */
  74251. url: string,
  74252. /**
  74253. * Defines the desired size (the more it increases the longer the generation will be)
  74254. */
  74255. size: number,
  74256. /**
  74257. * Defines if mipmaps should not be generated (default is false)
  74258. */
  74259. noMipmap?: boolean,
  74260. /**
  74261. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74262. */
  74263. generateHarmonics?: boolean,
  74264. /**
  74265. * 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)
  74266. */
  74267. gammaSpace?: boolean,
  74268. /**
  74269. * Internal Use Only
  74270. */
  74271. reserved?: boolean);
  74272. /**
  74273. * Execute the current task
  74274. * @param scene defines the scene where you want your assets to be loaded
  74275. * @param onSuccess is a callback called when the task is successfully executed
  74276. * @param onError is a callback called if an error occurs
  74277. */
  74278. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74279. }
  74280. /**
  74281. * Define a task used by AssetsManager to load Equirectangular cube textures
  74282. */
  74283. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74284. /**
  74285. * Defines the name of the task
  74286. */
  74287. name: string;
  74288. /**
  74289. * Defines the location of the file to load
  74290. */
  74291. url: string;
  74292. /**
  74293. * Defines the desired size (the more it increases the longer the generation will be)
  74294. */
  74295. size: number;
  74296. /**
  74297. * Defines if mipmaps should not be generated (default is false)
  74298. */
  74299. noMipmap: boolean;
  74300. /**
  74301. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74302. * but the standard material would require them in Gamma space) (default is true)
  74303. */
  74304. gammaSpace: boolean;
  74305. /**
  74306. * Gets the loaded texture
  74307. */
  74308. texture: EquiRectangularCubeTexture;
  74309. /**
  74310. * Callback called when the task is successful
  74311. */
  74312. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74313. /**
  74314. * Callback called when the task is successful
  74315. */
  74316. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74317. /**
  74318. * Creates a new EquiRectangularCubeTextureAssetTask object
  74319. * @param name defines the name of the task
  74320. * @param url defines the location of the file to load
  74321. * @param size defines the desired size (the more it increases the longer the generation will be)
  74322. * If the size is omitted this implies you are using a preprocessed cubemap.
  74323. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74324. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74325. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74326. * (default is true)
  74327. */
  74328. constructor(
  74329. /**
  74330. * Defines the name of the task
  74331. */
  74332. name: string,
  74333. /**
  74334. * Defines the location of the file to load
  74335. */
  74336. url: string,
  74337. /**
  74338. * Defines the desired size (the more it increases the longer the generation will be)
  74339. */
  74340. size: number,
  74341. /**
  74342. * Defines if mipmaps should not be generated (default is false)
  74343. */
  74344. noMipmap?: boolean,
  74345. /**
  74346. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74347. * but the standard material would require them in Gamma space) (default is true)
  74348. */
  74349. gammaSpace?: boolean);
  74350. /**
  74351. * Execute the current task
  74352. * @param scene defines the scene where you want your assets to be loaded
  74353. * @param onSuccess is a callback called when the task is successfully executed
  74354. * @param onError is a callback called if an error occurs
  74355. */
  74356. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74357. }
  74358. /**
  74359. * This class can be used to easily import assets into a scene
  74360. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74361. */
  74362. export class AssetsManager {
  74363. private _scene;
  74364. private _isLoading;
  74365. protected _tasks: AbstractAssetTask[];
  74366. protected _waitingTasksCount: number;
  74367. protected _totalTasksCount: number;
  74368. /**
  74369. * Callback called when all tasks are processed
  74370. */
  74371. onFinish: (tasks: AbstractAssetTask[]) => void;
  74372. /**
  74373. * Callback called when a task is successful
  74374. */
  74375. onTaskSuccess: (task: AbstractAssetTask) => void;
  74376. /**
  74377. * Callback called when a task had an error
  74378. */
  74379. onTaskError: (task: AbstractAssetTask) => void;
  74380. /**
  74381. * Callback called when a task is done (whatever the result is)
  74382. */
  74383. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74384. /**
  74385. * Observable called when all tasks are processed
  74386. */
  74387. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74388. /**
  74389. * Observable called when a task had an error
  74390. */
  74391. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74392. /**
  74393. * Observable called when all tasks were executed
  74394. */
  74395. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74396. /**
  74397. * Observable called when a task is done (whatever the result is)
  74398. */
  74399. onProgressObservable: Observable<IAssetsProgressEvent>;
  74400. /**
  74401. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74402. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74403. */
  74404. useDefaultLoadingScreen: boolean;
  74405. /**
  74406. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74407. * when all assets have been downloaded.
  74408. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74409. */
  74410. autoHideLoadingUI: boolean;
  74411. /**
  74412. * Creates a new AssetsManager
  74413. * @param scene defines the scene to work on
  74414. */
  74415. constructor(scene: Scene);
  74416. /**
  74417. * Add a ContainerAssetTask to the list of active tasks
  74418. * @param taskName defines the name of the new task
  74419. * @param meshesNames defines the name of meshes to load
  74420. * @param rootUrl defines the root url to use to locate files
  74421. * @param sceneFilename defines the filename of the scene file
  74422. * @returns a new ContainerAssetTask object
  74423. */
  74424. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74425. /**
  74426. * Add a MeshAssetTask to the list of active tasks
  74427. * @param taskName defines the name of the new task
  74428. * @param meshesNames defines the name of meshes to load
  74429. * @param rootUrl defines the root url to use to locate files
  74430. * @param sceneFilename defines the filename of the scene file
  74431. * @returns a new MeshAssetTask object
  74432. */
  74433. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74434. /**
  74435. * Add a TextFileAssetTask to the list of active tasks
  74436. * @param taskName defines the name of the new task
  74437. * @param url defines the url of the file to load
  74438. * @returns a new TextFileAssetTask object
  74439. */
  74440. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74441. /**
  74442. * Add a BinaryFileAssetTask to the list of active tasks
  74443. * @param taskName defines the name of the new task
  74444. * @param url defines the url of the file to load
  74445. * @returns a new BinaryFileAssetTask object
  74446. */
  74447. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74448. /**
  74449. * Add a ImageAssetTask to the list of active tasks
  74450. * @param taskName defines the name of the new task
  74451. * @param url defines the url of the file to load
  74452. * @returns a new ImageAssetTask object
  74453. */
  74454. addImageTask(taskName: string, url: string): ImageAssetTask;
  74455. /**
  74456. * Add a TextureAssetTask to the list of active tasks
  74457. * @param taskName defines the name of the new task
  74458. * @param url defines the url of the file to load
  74459. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74460. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74461. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74462. * @returns a new TextureAssetTask object
  74463. */
  74464. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74465. /**
  74466. * Add a CubeTextureAssetTask to the list of active tasks
  74467. * @param taskName defines the name of the new task
  74468. * @param url defines the url of the file to load
  74469. * @param extensions defines the extension to use to load the cube map (can be null)
  74470. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74471. * @param files defines the list of files to load (can be null)
  74472. * @returns a new CubeTextureAssetTask object
  74473. */
  74474. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74475. /**
  74476. *
  74477. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74478. * @param taskName defines the name of the new task
  74479. * @param url defines the url of the file to load
  74480. * @param size defines the size you want for the cubemap (can be null)
  74481. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74482. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74483. * @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)
  74484. * @param reserved Internal use only
  74485. * @returns a new HDRCubeTextureAssetTask object
  74486. */
  74487. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74488. /**
  74489. *
  74490. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74491. * @param taskName defines the name of the new task
  74492. * @param url defines the url of the file to load
  74493. * @param size defines the size you want for the cubemap (can be null)
  74494. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74495. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74496. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74497. * @returns a new EquiRectangularCubeTextureAssetTask object
  74498. */
  74499. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74500. /**
  74501. * Remove a task from the assets manager.
  74502. * @param task the task to remove
  74503. */
  74504. removeTask(task: AbstractAssetTask): void;
  74505. private _decreaseWaitingTasksCount;
  74506. private _runTask;
  74507. /**
  74508. * Reset the AssetsManager and remove all tasks
  74509. * @return the current instance of the AssetsManager
  74510. */
  74511. reset(): AssetsManager;
  74512. /**
  74513. * Start the loading process
  74514. * @return the current instance of the AssetsManager
  74515. */
  74516. load(): AssetsManager;
  74517. /**
  74518. * Start the loading process as an async operation
  74519. * @return a promise returning the list of failed tasks
  74520. */
  74521. loadAsync(): Promise<void>;
  74522. }
  74523. }
  74524. declare module BABYLON {
  74525. /**
  74526. * Wrapper class for promise with external resolve and reject.
  74527. */
  74528. export class Deferred<T> {
  74529. /**
  74530. * The promise associated with this deferred object.
  74531. */
  74532. readonly promise: Promise<T>;
  74533. private _resolve;
  74534. private _reject;
  74535. /**
  74536. * The resolve method of the promise associated with this deferred object.
  74537. */
  74538. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74539. /**
  74540. * The reject method of the promise associated with this deferred object.
  74541. */
  74542. get reject(): (reason?: any) => void;
  74543. /**
  74544. * Constructor for this deferred object.
  74545. */
  74546. constructor();
  74547. }
  74548. }
  74549. declare module BABYLON {
  74550. /**
  74551. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74552. */
  74553. export class MeshExploder {
  74554. private _centerMesh;
  74555. private _meshes;
  74556. private _meshesOrigins;
  74557. private _toCenterVectors;
  74558. private _scaledDirection;
  74559. private _newPosition;
  74560. private _centerPosition;
  74561. /**
  74562. * Explodes meshes from a center mesh.
  74563. * @param meshes The meshes to explode.
  74564. * @param centerMesh The mesh to be center of explosion.
  74565. */
  74566. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74567. private _setCenterMesh;
  74568. /**
  74569. * Get class name
  74570. * @returns "MeshExploder"
  74571. */
  74572. getClassName(): string;
  74573. /**
  74574. * "Exploded meshes"
  74575. * @returns Array of meshes with the centerMesh at index 0.
  74576. */
  74577. getMeshes(): Array<Mesh>;
  74578. /**
  74579. * Explodes meshes giving a specific direction
  74580. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74581. */
  74582. explode(direction?: number): void;
  74583. }
  74584. }
  74585. declare module BABYLON {
  74586. /**
  74587. * Class used to help managing file picking and drag'n'drop
  74588. */
  74589. export class FilesInput {
  74590. /**
  74591. * List of files ready to be loaded
  74592. */
  74593. static get FilesToLoad(): {
  74594. [key: string]: File;
  74595. };
  74596. /**
  74597. * Callback called when a file is processed
  74598. */
  74599. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74600. private _engine;
  74601. private _currentScene;
  74602. private _sceneLoadedCallback;
  74603. private _progressCallback;
  74604. private _additionalRenderLoopLogicCallback;
  74605. private _textureLoadingCallback;
  74606. private _startingProcessingFilesCallback;
  74607. private _onReloadCallback;
  74608. private _errorCallback;
  74609. private _elementToMonitor;
  74610. private _sceneFileToLoad;
  74611. private _filesToLoad;
  74612. /**
  74613. * Creates a new FilesInput
  74614. * @param engine defines the rendering engine
  74615. * @param scene defines the hosting scene
  74616. * @param sceneLoadedCallback callback called when scene is loaded
  74617. * @param progressCallback callback called to track progress
  74618. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74619. * @param textureLoadingCallback callback called when a texture is loading
  74620. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74621. * @param onReloadCallback callback called when a reload is requested
  74622. * @param errorCallback callback call if an error occurs
  74623. */
  74624. 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>);
  74625. private _dragEnterHandler;
  74626. private _dragOverHandler;
  74627. private _dropHandler;
  74628. /**
  74629. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74630. * @param elementToMonitor defines the DOM element to track
  74631. */
  74632. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74633. /** Gets the current list of files to load */
  74634. get filesToLoad(): File[];
  74635. /**
  74636. * Release all associated resources
  74637. */
  74638. dispose(): void;
  74639. private renderFunction;
  74640. private drag;
  74641. private drop;
  74642. private _traverseFolder;
  74643. private _processFiles;
  74644. /**
  74645. * Load files from a drop event
  74646. * @param event defines the drop event to use as source
  74647. */
  74648. loadFiles(event: any): void;
  74649. private _processReload;
  74650. /**
  74651. * Reload the current scene from the loaded files
  74652. */
  74653. reload(): void;
  74654. }
  74655. }
  74656. declare module BABYLON {
  74657. /**
  74658. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74659. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74660. */
  74661. export class SceneOptimization {
  74662. /**
  74663. * Defines the priority of this optimization (0 by default which means first in the list)
  74664. */
  74665. priority: number;
  74666. /**
  74667. * Gets a string describing the action executed by the current optimization
  74668. * @returns description string
  74669. */
  74670. getDescription(): string;
  74671. /**
  74672. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74673. * @param scene defines the current scene where to apply this optimization
  74674. * @param optimizer defines the current optimizer
  74675. * @returns true if everything that can be done was applied
  74676. */
  74677. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74678. /**
  74679. * Creates the SceneOptimization object
  74680. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74681. * @param desc defines the description associated with the optimization
  74682. */
  74683. constructor(
  74684. /**
  74685. * Defines the priority of this optimization (0 by default which means first in the list)
  74686. */
  74687. priority?: number);
  74688. }
  74689. /**
  74690. * Defines an optimization used to reduce the size of render target textures
  74691. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74692. */
  74693. export class TextureOptimization extends SceneOptimization {
  74694. /**
  74695. * Defines the priority of this optimization (0 by default which means first in the list)
  74696. */
  74697. priority: number;
  74698. /**
  74699. * 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
  74700. */
  74701. maximumSize: number;
  74702. /**
  74703. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74704. */
  74705. step: number;
  74706. /**
  74707. * Gets a string describing the action executed by the current optimization
  74708. * @returns description string
  74709. */
  74710. getDescription(): string;
  74711. /**
  74712. * Creates the TextureOptimization object
  74713. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74714. * @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
  74715. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74716. */
  74717. constructor(
  74718. /**
  74719. * Defines the priority of this optimization (0 by default which means first in the list)
  74720. */
  74721. priority?: number,
  74722. /**
  74723. * 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
  74724. */
  74725. maximumSize?: number,
  74726. /**
  74727. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74728. */
  74729. step?: number);
  74730. /**
  74731. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74732. * @param scene defines the current scene where to apply this optimization
  74733. * @param optimizer defines the current optimizer
  74734. * @returns true if everything that can be done was applied
  74735. */
  74736. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74737. }
  74738. /**
  74739. * Defines an optimization used to increase or decrease the rendering resolution
  74740. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74741. */
  74742. export class HardwareScalingOptimization extends SceneOptimization {
  74743. /**
  74744. * Defines the priority of this optimization (0 by default which means first in the list)
  74745. */
  74746. priority: number;
  74747. /**
  74748. * Defines the maximum scale to use (2 by default)
  74749. */
  74750. maximumScale: number;
  74751. /**
  74752. * Defines the step to use between two passes (0.5 by default)
  74753. */
  74754. step: number;
  74755. private _currentScale;
  74756. private _directionOffset;
  74757. /**
  74758. * Gets a string describing the action executed by the current optimization
  74759. * @return description string
  74760. */
  74761. getDescription(): string;
  74762. /**
  74763. * Creates the HardwareScalingOptimization object
  74764. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74765. * @param maximumScale defines the maximum scale to use (2 by default)
  74766. * @param step defines the step to use between two passes (0.5 by default)
  74767. */
  74768. constructor(
  74769. /**
  74770. * Defines the priority of this optimization (0 by default which means first in the list)
  74771. */
  74772. priority?: number,
  74773. /**
  74774. * Defines the maximum scale to use (2 by default)
  74775. */
  74776. maximumScale?: number,
  74777. /**
  74778. * Defines the step to use between two passes (0.5 by default)
  74779. */
  74780. step?: number);
  74781. /**
  74782. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74783. * @param scene defines the current scene where to apply this optimization
  74784. * @param optimizer defines the current optimizer
  74785. * @returns true if everything that can be done was applied
  74786. */
  74787. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74788. }
  74789. /**
  74790. * Defines an optimization used to remove shadows
  74791. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74792. */
  74793. export class ShadowsOptimization extends SceneOptimization {
  74794. /**
  74795. * Gets a string describing the action executed by the current optimization
  74796. * @return description string
  74797. */
  74798. getDescription(): string;
  74799. /**
  74800. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74801. * @param scene defines the current scene where to apply this optimization
  74802. * @param optimizer defines the current optimizer
  74803. * @returns true if everything that can be done was applied
  74804. */
  74805. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74806. }
  74807. /**
  74808. * Defines an optimization used to turn post-processes off
  74809. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74810. */
  74811. export class PostProcessesOptimization extends SceneOptimization {
  74812. /**
  74813. * Gets a string describing the action executed by the current optimization
  74814. * @return description string
  74815. */
  74816. getDescription(): string;
  74817. /**
  74818. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74819. * @param scene defines the current scene where to apply this optimization
  74820. * @param optimizer defines the current optimizer
  74821. * @returns true if everything that can be done was applied
  74822. */
  74823. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74824. }
  74825. /**
  74826. * Defines an optimization used to turn lens flares off
  74827. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74828. */
  74829. export class LensFlaresOptimization extends SceneOptimization {
  74830. /**
  74831. * Gets a string describing the action executed by the current optimization
  74832. * @return description string
  74833. */
  74834. getDescription(): string;
  74835. /**
  74836. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74837. * @param scene defines the current scene where to apply this optimization
  74838. * @param optimizer defines the current optimizer
  74839. * @returns true if everything that can be done was applied
  74840. */
  74841. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74842. }
  74843. /**
  74844. * Defines an optimization based on user defined callback.
  74845. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74846. */
  74847. export class CustomOptimization extends SceneOptimization {
  74848. /**
  74849. * Callback called to apply the custom optimization.
  74850. */
  74851. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74852. /**
  74853. * Callback called to get custom description
  74854. */
  74855. onGetDescription: () => string;
  74856. /**
  74857. * Gets a string describing the action executed by the current optimization
  74858. * @returns description string
  74859. */
  74860. getDescription(): string;
  74861. /**
  74862. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74863. * @param scene defines the current scene where to apply this optimization
  74864. * @param optimizer defines the current optimizer
  74865. * @returns true if everything that can be done was applied
  74866. */
  74867. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74868. }
  74869. /**
  74870. * Defines an optimization used to turn particles off
  74871. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74872. */
  74873. export class ParticlesOptimization extends SceneOptimization {
  74874. /**
  74875. * Gets a string describing the action executed by the current optimization
  74876. * @return description string
  74877. */
  74878. getDescription(): string;
  74879. /**
  74880. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74881. * @param scene defines the current scene where to apply this optimization
  74882. * @param optimizer defines the current optimizer
  74883. * @returns true if everything that can be done was applied
  74884. */
  74885. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74886. }
  74887. /**
  74888. * Defines an optimization used to turn render targets off
  74889. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74890. */
  74891. export class RenderTargetsOptimization extends SceneOptimization {
  74892. /**
  74893. * Gets a string describing the action executed by the current optimization
  74894. * @return description string
  74895. */
  74896. getDescription(): string;
  74897. /**
  74898. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74899. * @param scene defines the current scene where to apply this optimization
  74900. * @param optimizer defines the current optimizer
  74901. * @returns true if everything that can be done was applied
  74902. */
  74903. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74904. }
  74905. /**
  74906. * Defines an optimization used to merge meshes with compatible materials
  74907. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74908. */
  74909. export class MergeMeshesOptimization extends SceneOptimization {
  74910. private static _UpdateSelectionTree;
  74911. /**
  74912. * Gets or sets a boolean which defines if optimization octree has to be updated
  74913. */
  74914. static get UpdateSelectionTree(): boolean;
  74915. /**
  74916. * Gets or sets a boolean which defines if optimization octree has to be updated
  74917. */
  74918. static set UpdateSelectionTree(value: boolean);
  74919. /**
  74920. * Gets a string describing the action executed by the current optimization
  74921. * @return description string
  74922. */
  74923. getDescription(): string;
  74924. private _canBeMerged;
  74925. /**
  74926. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74927. * @param scene defines the current scene where to apply this optimization
  74928. * @param optimizer defines the current optimizer
  74929. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74930. * @returns true if everything that can be done was applied
  74931. */
  74932. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74933. }
  74934. /**
  74935. * Defines a list of options used by SceneOptimizer
  74936. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74937. */
  74938. export class SceneOptimizerOptions {
  74939. /**
  74940. * Defines the target frame rate to reach (60 by default)
  74941. */
  74942. targetFrameRate: number;
  74943. /**
  74944. * Defines the interval between two checkes (2000ms by default)
  74945. */
  74946. trackerDuration: number;
  74947. /**
  74948. * Gets the list of optimizations to apply
  74949. */
  74950. optimizations: SceneOptimization[];
  74951. /**
  74952. * Creates a new list of options used by SceneOptimizer
  74953. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74954. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74955. */
  74956. constructor(
  74957. /**
  74958. * Defines the target frame rate to reach (60 by default)
  74959. */
  74960. targetFrameRate?: number,
  74961. /**
  74962. * Defines the interval between two checkes (2000ms by default)
  74963. */
  74964. trackerDuration?: number);
  74965. /**
  74966. * Add a new optimization
  74967. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74968. * @returns the current SceneOptimizerOptions
  74969. */
  74970. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74971. /**
  74972. * Add a new custom optimization
  74973. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74974. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74975. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74976. * @returns the current SceneOptimizerOptions
  74977. */
  74978. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74979. /**
  74980. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74981. * @param targetFrameRate defines the target frame rate (60 by default)
  74982. * @returns a SceneOptimizerOptions object
  74983. */
  74984. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74985. /**
  74986. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74987. * @param targetFrameRate defines the target frame rate (60 by default)
  74988. * @returns a SceneOptimizerOptions object
  74989. */
  74990. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74991. /**
  74992. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74993. * @param targetFrameRate defines the target frame rate (60 by default)
  74994. * @returns a SceneOptimizerOptions object
  74995. */
  74996. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74997. }
  74998. /**
  74999. * Class used to run optimizations in order to reach a target frame rate
  75000. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75001. */
  75002. export class SceneOptimizer implements IDisposable {
  75003. private _isRunning;
  75004. private _options;
  75005. private _scene;
  75006. private _currentPriorityLevel;
  75007. private _targetFrameRate;
  75008. private _trackerDuration;
  75009. private _currentFrameRate;
  75010. private _sceneDisposeObserver;
  75011. private _improvementMode;
  75012. /**
  75013. * Defines an observable called when the optimizer reaches the target frame rate
  75014. */
  75015. onSuccessObservable: Observable<SceneOptimizer>;
  75016. /**
  75017. * Defines an observable called when the optimizer enables an optimization
  75018. */
  75019. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75020. /**
  75021. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75022. */
  75023. onFailureObservable: Observable<SceneOptimizer>;
  75024. /**
  75025. * Gets a boolean indicating if the optimizer is in improvement mode
  75026. */
  75027. get isInImprovementMode(): boolean;
  75028. /**
  75029. * Gets the current priority level (0 at start)
  75030. */
  75031. get currentPriorityLevel(): number;
  75032. /**
  75033. * Gets the current frame rate checked by the SceneOptimizer
  75034. */
  75035. get currentFrameRate(): number;
  75036. /**
  75037. * Gets or sets the current target frame rate (60 by default)
  75038. */
  75039. get targetFrameRate(): number;
  75040. /**
  75041. * Gets or sets the current target frame rate (60 by default)
  75042. */
  75043. set targetFrameRate(value: number);
  75044. /**
  75045. * Gets or sets the current interval between two checks (every 2000ms by default)
  75046. */
  75047. get trackerDuration(): number;
  75048. /**
  75049. * Gets or sets the current interval between two checks (every 2000ms by default)
  75050. */
  75051. set trackerDuration(value: number);
  75052. /**
  75053. * Gets the list of active optimizations
  75054. */
  75055. get optimizations(): SceneOptimization[];
  75056. /**
  75057. * Creates a new SceneOptimizer
  75058. * @param scene defines the scene to work on
  75059. * @param options defines the options to use with the SceneOptimizer
  75060. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75061. * @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)
  75062. */
  75063. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75064. /**
  75065. * Stops the current optimizer
  75066. */
  75067. stop(): void;
  75068. /**
  75069. * Reset the optimizer to initial step (current priority level = 0)
  75070. */
  75071. reset(): void;
  75072. /**
  75073. * Start the optimizer. By default it will try to reach a specific framerate
  75074. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75075. */
  75076. start(): void;
  75077. private _checkCurrentState;
  75078. /**
  75079. * Release all resources
  75080. */
  75081. dispose(): void;
  75082. /**
  75083. * Helper function to create a SceneOptimizer with one single line of code
  75084. * @param scene defines the scene to work on
  75085. * @param options defines the options to use with the SceneOptimizer
  75086. * @param onSuccess defines a callback to call on success
  75087. * @param onFailure defines a callback to call on failure
  75088. * @returns the new SceneOptimizer object
  75089. */
  75090. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75091. }
  75092. }
  75093. declare module BABYLON {
  75094. /**
  75095. * Class used to serialize a scene into a string
  75096. */
  75097. export class SceneSerializer {
  75098. /**
  75099. * Clear cache used by a previous serialization
  75100. */
  75101. static ClearCache(): void;
  75102. /**
  75103. * Serialize a scene into a JSON compatible object
  75104. * @param scene defines the scene to serialize
  75105. * @returns a JSON compatible object
  75106. */
  75107. static Serialize(scene: Scene): any;
  75108. /**
  75109. * Serialize a mesh into a JSON compatible object
  75110. * @param toSerialize defines the mesh to serialize
  75111. * @param withParents defines if parents must be serialized as well
  75112. * @param withChildren defines if children must be serialized as well
  75113. * @returns a JSON compatible object
  75114. */
  75115. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75116. }
  75117. }
  75118. declare module BABYLON {
  75119. /**
  75120. * Class used to host texture specific utilities
  75121. */
  75122. export class TextureTools {
  75123. /**
  75124. * Uses the GPU to create a copy texture rescaled at a given size
  75125. * @param texture Texture to copy from
  75126. * @param width defines the desired width
  75127. * @param height defines the desired height
  75128. * @param useBilinearMode defines if bilinear mode has to be used
  75129. * @return the generated texture
  75130. */
  75131. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75132. }
  75133. }
  75134. declare module BABYLON {
  75135. /**
  75136. * This represents the different options available for the video capture.
  75137. */
  75138. export interface VideoRecorderOptions {
  75139. /** Defines the mime type of the video. */
  75140. mimeType: string;
  75141. /** Defines the FPS the video should be recorded at. */
  75142. fps: number;
  75143. /** Defines the chunk size for the recording data. */
  75144. recordChunckSize: number;
  75145. /** The audio tracks to attach to the recording. */
  75146. audioTracks?: MediaStreamTrack[];
  75147. }
  75148. /**
  75149. * This can help with recording videos from BabylonJS.
  75150. * This is based on the available WebRTC functionalities of the browser.
  75151. *
  75152. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75153. */
  75154. export class VideoRecorder {
  75155. private static readonly _defaultOptions;
  75156. /**
  75157. * Returns whether or not the VideoRecorder is available in your browser.
  75158. * @param engine Defines the Babylon Engine.
  75159. * @returns true if supported otherwise false.
  75160. */
  75161. static IsSupported(engine: Engine): boolean;
  75162. private readonly _options;
  75163. private _canvas;
  75164. private _mediaRecorder;
  75165. private _recordedChunks;
  75166. private _fileName;
  75167. private _resolve;
  75168. private _reject;
  75169. /**
  75170. * True when a recording is already in progress.
  75171. */
  75172. get isRecording(): boolean;
  75173. /**
  75174. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75175. * @param engine Defines the BabylonJS Engine you wish to record.
  75176. * @param options Defines options that can be used to customize the capture.
  75177. */
  75178. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75179. /**
  75180. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75181. */
  75182. stopRecording(): void;
  75183. /**
  75184. * Starts recording the canvas for a max duration specified in parameters.
  75185. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75186. * If null no automatic download will start and you can rely on the promise to get the data back.
  75187. * @param maxDuration Defines the maximum recording time in seconds.
  75188. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75189. * @return A promise callback at the end of the recording with the video data in Blob.
  75190. */
  75191. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75192. /**
  75193. * Releases internal resources used during the recording.
  75194. */
  75195. dispose(): void;
  75196. private _handleDataAvailable;
  75197. private _handleError;
  75198. private _handleStop;
  75199. }
  75200. }
  75201. declare module BABYLON {
  75202. /**
  75203. * Class containing a set of static utilities functions for screenshots
  75204. */
  75205. export class ScreenshotTools {
  75206. /**
  75207. * Captures a screenshot of the current rendering
  75208. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75209. * @param engine defines the rendering engine
  75210. * @param camera defines the source camera
  75211. * @param size This parameter can be set to a single number or to an object with the
  75212. * following (optional) properties: precision, width, height. If a single number is passed,
  75213. * it will be used for both width and height. If an object is passed, the screenshot size
  75214. * will be derived from the parameters. The precision property is a multiplier allowing
  75215. * rendering at a higher or lower resolution
  75216. * @param successCallback defines the callback receives a single parameter which contains the
  75217. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75218. * src parameter of an <img> to display it
  75219. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75220. * Check your browser for supported MIME types
  75221. */
  75222. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75223. /**
  75224. * Captures a screenshot of the current rendering
  75225. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75226. * @param engine defines the rendering engine
  75227. * @param camera defines the source camera
  75228. * @param size This parameter can be set to a single number or to an object with the
  75229. * following (optional) properties: precision, width, height. If a single number is passed,
  75230. * it will be used for both width and height. If an object is passed, the screenshot size
  75231. * will be derived from the parameters. The precision property is a multiplier allowing
  75232. * rendering at a higher or lower resolution
  75233. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75234. * Check your browser for supported MIME types
  75235. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75236. * to the src parameter of an <img> to display it
  75237. */
  75238. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75239. /**
  75240. * Generates an image screenshot from the specified camera.
  75241. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75242. * @param engine The engine to use for rendering
  75243. * @param camera The camera to use for rendering
  75244. * @param size This parameter can be set to a single number or to an object with the
  75245. * following (optional) properties: precision, width, height. If a single number is passed,
  75246. * it will be used for both width and height. If an object is passed, the screenshot size
  75247. * will be derived from the parameters. The precision property is a multiplier allowing
  75248. * rendering at a higher or lower resolution
  75249. * @param successCallback The callback receives a single parameter which contains the
  75250. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75251. * src parameter of an <img> to display it
  75252. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75253. * Check your browser for supported MIME types
  75254. * @param samples Texture samples (default: 1)
  75255. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75256. * @param fileName A name for for the downloaded file.
  75257. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75258. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75259. */
  75260. 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;
  75261. /**
  75262. * Generates an image screenshot from the specified camera.
  75263. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75264. * @param engine The engine to use for rendering
  75265. * @param camera The camera to use for rendering
  75266. * @param size This parameter can be set to a single number or to an object with the
  75267. * following (optional) properties: precision, width, height. If a single number is passed,
  75268. * it will be used for both width and height. If an object is passed, the screenshot size
  75269. * will be derived from the parameters. The precision property is a multiplier allowing
  75270. * rendering at a higher or lower resolution
  75271. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75272. * Check your browser for supported MIME types
  75273. * @param samples Texture samples (default: 1)
  75274. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75275. * @param fileName A name for for the downloaded file.
  75276. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75277. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75278. * to the src parameter of an <img> to display it
  75279. */
  75280. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75281. /**
  75282. * Gets height and width for screenshot size
  75283. * @private
  75284. */
  75285. private static _getScreenshotSize;
  75286. }
  75287. }
  75288. declare module BABYLON {
  75289. /**
  75290. * Interface for a data buffer
  75291. */
  75292. export interface IDataBuffer {
  75293. /**
  75294. * Reads bytes from the data buffer.
  75295. * @param byteOffset The byte offset to read
  75296. * @param byteLength The byte length to read
  75297. * @returns A promise that resolves when the bytes are read
  75298. */
  75299. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75300. /**
  75301. * The byte length of the buffer.
  75302. */
  75303. readonly byteLength: number;
  75304. }
  75305. /**
  75306. * Utility class for reading from a data buffer
  75307. */
  75308. export class DataReader {
  75309. /**
  75310. * The data buffer associated with this data reader.
  75311. */
  75312. readonly buffer: IDataBuffer;
  75313. /**
  75314. * The current byte offset from the beginning of the data buffer.
  75315. */
  75316. byteOffset: number;
  75317. private _dataView;
  75318. private _dataByteOffset;
  75319. /**
  75320. * Constructor
  75321. * @param buffer The buffer to read
  75322. */
  75323. constructor(buffer: IDataBuffer);
  75324. /**
  75325. * Loads the given byte length.
  75326. * @param byteLength The byte length to load
  75327. * @returns A promise that resolves when the load is complete
  75328. */
  75329. loadAsync(byteLength: number): Promise<void>;
  75330. /**
  75331. * Read a unsigned 32-bit integer from the currently loaded data range.
  75332. * @returns The 32-bit integer read
  75333. */
  75334. readUint32(): number;
  75335. /**
  75336. * Read a byte array from the currently loaded data range.
  75337. * @param byteLength The byte length to read
  75338. * @returns The byte array read
  75339. */
  75340. readUint8Array(byteLength: number): Uint8Array;
  75341. /**
  75342. * Read a string from the currently loaded data range.
  75343. * @param byteLength The byte length to read
  75344. * @returns The string read
  75345. */
  75346. readString(byteLength: number): string;
  75347. /**
  75348. * Skips the given byte length the currently loaded data range.
  75349. * @param byteLength The byte length to skip
  75350. */
  75351. skipBytes(byteLength: number): void;
  75352. }
  75353. }
  75354. declare module BABYLON {
  75355. /**
  75356. * Class for storing data to local storage if available or in-memory storage otherwise
  75357. */
  75358. export class DataStorage {
  75359. private static _Storage;
  75360. private static _GetStorage;
  75361. /**
  75362. * Reads a string from the data storage
  75363. * @param key The key to read
  75364. * @param defaultValue The value if the key doesn't exist
  75365. * @returns The string value
  75366. */
  75367. static ReadString(key: string, defaultValue: string): string;
  75368. /**
  75369. * Writes a string to the data storage
  75370. * @param key The key to write
  75371. * @param value The value to write
  75372. */
  75373. static WriteString(key: string, value: string): void;
  75374. /**
  75375. * Reads a boolean from the data storage
  75376. * @param key The key to read
  75377. * @param defaultValue The value if the key doesn't exist
  75378. * @returns The boolean value
  75379. */
  75380. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75381. /**
  75382. * Writes a boolean to the data storage
  75383. * @param key The key to write
  75384. * @param value The value to write
  75385. */
  75386. static WriteBoolean(key: string, value: boolean): void;
  75387. /**
  75388. * Reads a number from the data storage
  75389. * @param key The key to read
  75390. * @param defaultValue The value if the key doesn't exist
  75391. * @returns The number value
  75392. */
  75393. static ReadNumber(key: string, defaultValue: number): number;
  75394. /**
  75395. * Writes a number to the data storage
  75396. * @param key The key to write
  75397. * @param value The value to write
  75398. */
  75399. static WriteNumber(key: string, value: number): void;
  75400. }
  75401. }
  75402. declare module BABYLON {
  75403. /**
  75404. * Class used to record delta files between 2 scene states
  75405. */
  75406. export class SceneRecorder {
  75407. private _trackedScene;
  75408. private _savedJSON;
  75409. /**
  75410. * Track a given scene. This means the current scene state will be considered the original state
  75411. * @param scene defines the scene to track
  75412. */
  75413. track(scene: Scene): void;
  75414. /**
  75415. * Get the delta between current state and original state
  75416. * @returns a string containing the delta
  75417. */
  75418. getDelta(): any;
  75419. private _compareArray;
  75420. private _compareObjects;
  75421. private _compareCollections;
  75422. private static GetShadowGeneratorById;
  75423. /**
  75424. * Apply a given delta to a given scene
  75425. * @param deltaJSON defines the JSON containing the delta
  75426. * @param scene defines the scene to apply the delta to
  75427. */
  75428. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75429. private static _ApplyPropertiesToEntity;
  75430. private static _ApplyDeltaForEntity;
  75431. }
  75432. }
  75433. declare module BABYLON {
  75434. /**
  75435. * A 3D trajectory consisting of an order list of vectors describing a
  75436. * path of motion through 3D space.
  75437. */
  75438. export class Trajectory {
  75439. private _points;
  75440. private readonly _segmentLength;
  75441. /**
  75442. * Serialize to JSON.
  75443. * @returns serialized JSON string
  75444. */
  75445. serialize(): string;
  75446. /**
  75447. * Deserialize from JSON.
  75448. * @param json serialized JSON string
  75449. * @returns deserialized Trajectory
  75450. */
  75451. static Deserialize(json: string): Trajectory;
  75452. /**
  75453. * Create a new empty Trajectory.
  75454. * @param segmentLength radius of discretization for Trajectory points
  75455. */
  75456. constructor(segmentLength?: number);
  75457. /**
  75458. * Get the length of the Trajectory.
  75459. * @returns length of the Trajectory
  75460. */
  75461. getLength(): number;
  75462. /**
  75463. * Append a new point to the Trajectory.
  75464. * NOTE: This implementation has many allocations.
  75465. * @param point point to append to the Trajectory
  75466. */
  75467. add(point: DeepImmutable<Vector3>): void;
  75468. /**
  75469. * Create a new Trajectory with a segment length chosen to make it
  75470. * probable that the new Trajectory will have a specified number of
  75471. * segments. This operation is imprecise.
  75472. * @param targetResolution number of segments desired
  75473. * @returns new Trajectory with approximately the requested number of segments
  75474. */
  75475. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75476. /**
  75477. * Convert Trajectory segments into tokenized representation. This
  75478. * representation is an array of numbers where each nth number is the
  75479. * index of the token which is most similar to the nth segment of the
  75480. * Trajectory.
  75481. * @param tokens list of vectors which serve as discrete tokens
  75482. * @returns list of indices of most similar token per segment
  75483. */
  75484. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75485. private static _forwardDir;
  75486. private static _inverseFromVec;
  75487. private static _upDir;
  75488. private static _fromToVec;
  75489. private static _lookMatrix;
  75490. /**
  75491. * Transform the rotation (i.e., direction) of a segment to isolate
  75492. * the relative transformation represented by the segment. This operation
  75493. * may or may not succeed due to singularities in the equations that define
  75494. * motion relativity in this context.
  75495. * @param priorVec the origin of the prior segment
  75496. * @param fromVec the origin of the current segment
  75497. * @param toVec the destination of the current segment
  75498. * @param result reference to output variable
  75499. * @returns whether or not transformation was successful
  75500. */
  75501. private static _transformSegmentDirToRef;
  75502. private static _bestMatch;
  75503. private static _score;
  75504. private static _bestScore;
  75505. /**
  75506. * Determine which token vector is most similar to the
  75507. * segment vector.
  75508. * @param segment segment vector
  75509. * @param tokens token vector list
  75510. * @returns index of the most similar token to the segment
  75511. */
  75512. private static _tokenizeSegment;
  75513. }
  75514. /**
  75515. * Class representing a set of known, named trajectories to which Trajectories can be
  75516. * added and using which Trajectories can be recognized.
  75517. */
  75518. export class TrajectoryClassifier {
  75519. private _maximumAllowableMatchCost;
  75520. private _vector3Alphabet;
  75521. private _levenshteinAlphabet;
  75522. private _nameToDescribedTrajectory;
  75523. /**
  75524. * Serialize to JSON.
  75525. * @returns JSON serialization
  75526. */
  75527. serialize(): string;
  75528. /**
  75529. * Deserialize from JSON.
  75530. * @param json JSON serialization
  75531. * @returns deserialized TrajectorySet
  75532. */
  75533. static Deserialize(json: string): TrajectoryClassifier;
  75534. /**
  75535. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75536. * VERY naive, need to be generating these things from known
  75537. * sets. Better version later, probably eliminating this one.
  75538. * @returns auto-generated TrajectorySet
  75539. */
  75540. static Generate(): TrajectoryClassifier;
  75541. private constructor();
  75542. /**
  75543. * Add a new Trajectory to the set with a given name.
  75544. * @param trajectory new Trajectory to be added
  75545. * @param classification name to which to add the Trajectory
  75546. */
  75547. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75548. /**
  75549. * Remove a known named trajectory and all Trajectories associated with it.
  75550. * @param classification name to remove
  75551. * @returns whether anything was removed
  75552. */
  75553. deleteClassification(classification: string): boolean;
  75554. /**
  75555. * Attempt to recognize a Trajectory from among all the classifications
  75556. * already known to the classifier.
  75557. * @param trajectory Trajectory to be recognized
  75558. * @returns classification of Trajectory if recognized, null otherwise
  75559. */
  75560. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75561. }
  75562. }
  75563. declare module BABYLON {
  75564. /**
  75565. * An interface for all Hit test features
  75566. */
  75567. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75568. /**
  75569. * Triggered when new babylon (transformed) hit test results are available
  75570. */
  75571. onHitTestResultObservable: Observable<T[]>;
  75572. }
  75573. /**
  75574. * Options used for hit testing
  75575. */
  75576. export interface IWebXRLegacyHitTestOptions {
  75577. /**
  75578. * Only test when user interacted with the scene. Default - hit test every frame
  75579. */
  75580. testOnPointerDownOnly?: boolean;
  75581. /**
  75582. * The node to use to transform the local results to world coordinates
  75583. */
  75584. worldParentNode?: TransformNode;
  75585. }
  75586. /**
  75587. * Interface defining the babylon result of raycasting/hit-test
  75588. */
  75589. export interface IWebXRLegacyHitResult {
  75590. /**
  75591. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75592. */
  75593. transformationMatrix: Matrix;
  75594. /**
  75595. * The native hit test result
  75596. */
  75597. xrHitResult: XRHitResult | XRHitTestResult;
  75598. }
  75599. /**
  75600. * The currently-working hit-test module.
  75601. * Hit test (or Ray-casting) is used to interact with the real world.
  75602. * For further information read here - https://github.com/immersive-web/hit-test
  75603. */
  75604. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75605. /**
  75606. * options to use when constructing this feature
  75607. */
  75608. readonly options: IWebXRLegacyHitTestOptions;
  75609. private _direction;
  75610. private _mat;
  75611. private _onSelectEnabled;
  75612. private _origin;
  75613. /**
  75614. * The module's name
  75615. */
  75616. static readonly Name: string;
  75617. /**
  75618. * The (Babylon) version of this module.
  75619. * This is an integer representing the implementation version.
  75620. * This number does not correspond to the WebXR specs version
  75621. */
  75622. static readonly Version: number;
  75623. /**
  75624. * Populated with the last native XR Hit Results
  75625. */
  75626. lastNativeXRHitResults: XRHitResult[];
  75627. /**
  75628. * Triggered when new babylon (transformed) hit test results are available
  75629. */
  75630. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75631. /**
  75632. * Creates a new instance of the (legacy version) hit test feature
  75633. * @param _xrSessionManager an instance of WebXRSessionManager
  75634. * @param options options to use when constructing this feature
  75635. */
  75636. constructor(_xrSessionManager: WebXRSessionManager,
  75637. /**
  75638. * options to use when constructing this feature
  75639. */
  75640. options?: IWebXRLegacyHitTestOptions);
  75641. /**
  75642. * execute a hit test with an XR Ray
  75643. *
  75644. * @param xrSession a native xrSession that will execute this hit test
  75645. * @param xrRay the ray (position and direction) to use for ray-casting
  75646. * @param referenceSpace native XR reference space to use for the hit-test
  75647. * @param filter filter function that will filter the results
  75648. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75649. */
  75650. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75651. /**
  75652. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75653. * @param event the (select) event to use to select with
  75654. * @param referenceSpace the reference space to use for this hit test
  75655. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75656. */
  75657. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75658. /**
  75659. * attach this feature
  75660. * Will usually be called by the features manager
  75661. *
  75662. * @returns true if successful.
  75663. */
  75664. attach(): boolean;
  75665. /**
  75666. * detach this feature.
  75667. * Will usually be called by the features manager
  75668. *
  75669. * @returns true if successful.
  75670. */
  75671. detach(): boolean;
  75672. /**
  75673. * Dispose this feature and all of the resources attached
  75674. */
  75675. dispose(): void;
  75676. protected _onXRFrame(frame: XRFrame): void;
  75677. private _onHitTestResults;
  75678. private _onSelect;
  75679. }
  75680. }
  75681. declare module BABYLON {
  75682. /**
  75683. * Options used for hit testing (version 2)
  75684. */
  75685. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75686. /**
  75687. * Do not create a permanent hit test. Will usually be used when only
  75688. * transient inputs are needed.
  75689. */
  75690. disablePermanentHitTest?: boolean;
  75691. /**
  75692. * Enable transient (for example touch-based) hit test inspections
  75693. */
  75694. enableTransientHitTest?: boolean;
  75695. /**
  75696. * Offset ray for the permanent hit test
  75697. */
  75698. offsetRay?: Vector3;
  75699. /**
  75700. * Offset ray for the transient hit test
  75701. */
  75702. transientOffsetRay?: Vector3;
  75703. /**
  75704. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75705. */
  75706. useReferenceSpace?: boolean;
  75707. /**
  75708. * Override the default entity type(s) of the hit-test result
  75709. */
  75710. entityTypes?: XRHitTestTrackableType[];
  75711. }
  75712. /**
  75713. * Interface defining the babylon result of hit-test
  75714. */
  75715. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75716. /**
  75717. * The input source that generated this hit test (if transient)
  75718. */
  75719. inputSource?: XRInputSource;
  75720. /**
  75721. * Is this a transient hit test
  75722. */
  75723. isTransient?: boolean;
  75724. /**
  75725. * Position of the hit test result
  75726. */
  75727. position: Vector3;
  75728. /**
  75729. * Rotation of the hit test result
  75730. */
  75731. rotationQuaternion: Quaternion;
  75732. /**
  75733. * The native hit test result
  75734. */
  75735. xrHitResult: XRHitTestResult;
  75736. }
  75737. /**
  75738. * The currently-working hit-test module.
  75739. * Hit test (or Ray-casting) is used to interact with the real world.
  75740. * For further information read here - https://github.com/immersive-web/hit-test
  75741. *
  75742. * Tested on chrome (mobile) 80.
  75743. */
  75744. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75745. /**
  75746. * options to use when constructing this feature
  75747. */
  75748. readonly options: IWebXRHitTestOptions;
  75749. private _tmpMat;
  75750. private _tmpPos;
  75751. private _tmpQuat;
  75752. private _transientXrHitTestSource;
  75753. private _xrHitTestSource;
  75754. private initHitTestSource;
  75755. /**
  75756. * The module's name
  75757. */
  75758. static readonly Name: string;
  75759. /**
  75760. * The (Babylon) version of this module.
  75761. * This is an integer representing the implementation version.
  75762. * This number does not correspond to the WebXR specs version
  75763. */
  75764. static readonly Version: number;
  75765. /**
  75766. * When set to true, each hit test will have its own position/rotation objects
  75767. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75768. * the developers will clone them or copy them as they see fit.
  75769. */
  75770. autoCloneTransformation: boolean;
  75771. /**
  75772. * Triggered when new babylon (transformed) hit test results are available
  75773. * Note - this will be called when results come back from the device. It can be an empty array!!
  75774. */
  75775. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75776. /**
  75777. * Use this to temporarily pause hit test checks.
  75778. */
  75779. paused: boolean;
  75780. /**
  75781. * Creates a new instance of the hit test feature
  75782. * @param _xrSessionManager an instance of WebXRSessionManager
  75783. * @param options options to use when constructing this feature
  75784. */
  75785. constructor(_xrSessionManager: WebXRSessionManager,
  75786. /**
  75787. * options to use when constructing this feature
  75788. */
  75789. options?: IWebXRHitTestOptions);
  75790. /**
  75791. * attach this feature
  75792. * Will usually be called by the features manager
  75793. *
  75794. * @returns true if successful.
  75795. */
  75796. attach(): boolean;
  75797. /**
  75798. * detach this feature.
  75799. * Will usually be called by the features manager
  75800. *
  75801. * @returns true if successful.
  75802. */
  75803. detach(): boolean;
  75804. /**
  75805. * Dispose this feature and all of the resources attached
  75806. */
  75807. dispose(): void;
  75808. protected _onXRFrame(frame: XRFrame): void;
  75809. private _processWebXRHitTestResult;
  75810. }
  75811. }
  75812. declare module BABYLON {
  75813. /**
  75814. * Configuration options of the anchor system
  75815. */
  75816. export interface IWebXRAnchorSystemOptions {
  75817. /**
  75818. * a node that will be used to convert local to world coordinates
  75819. */
  75820. worldParentNode?: TransformNode;
  75821. /**
  75822. * If set to true a reference of the created anchors will be kept until the next session starts
  75823. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75824. */
  75825. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75826. }
  75827. /**
  75828. * A babylon container for an XR Anchor
  75829. */
  75830. export interface IWebXRAnchor {
  75831. /**
  75832. * A babylon-assigned ID for this anchor
  75833. */
  75834. id: number;
  75835. /**
  75836. * Transformation matrix to apply to an object attached to this anchor
  75837. */
  75838. transformationMatrix: Matrix;
  75839. /**
  75840. * The native anchor object
  75841. */
  75842. xrAnchor: XRAnchor;
  75843. /**
  75844. * if defined, this object will be constantly updated by the anchor's position and rotation
  75845. */
  75846. attachedNode?: TransformNode;
  75847. }
  75848. /**
  75849. * An implementation of the anchor system for WebXR.
  75850. * For further information see https://github.com/immersive-web/anchors/
  75851. */
  75852. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75853. private _options;
  75854. private _lastFrameDetected;
  75855. private _trackedAnchors;
  75856. private _referenceSpaceForFrameAnchors;
  75857. private _futureAnchors;
  75858. /**
  75859. * The module's name
  75860. */
  75861. static readonly Name: string;
  75862. /**
  75863. * The (Babylon) version of this module.
  75864. * This is an integer representing the implementation version.
  75865. * This number does not correspond to the WebXR specs version
  75866. */
  75867. static readonly Version: number;
  75868. /**
  75869. * Observers registered here will be executed when a new anchor was added to the session
  75870. */
  75871. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75872. /**
  75873. * Observers registered here will be executed when an anchor was removed from the session
  75874. */
  75875. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75876. /**
  75877. * Observers registered here will be executed when an existing anchor updates
  75878. * This can execute N times every frame
  75879. */
  75880. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75881. /**
  75882. * Set the reference space to use for anchor creation, when not using a hit test.
  75883. * Will default to the session's reference space if not defined
  75884. */
  75885. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75886. /**
  75887. * constructs a new anchor system
  75888. * @param _xrSessionManager an instance of WebXRSessionManager
  75889. * @param _options configuration object for this feature
  75890. */
  75891. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75892. private _tmpVector;
  75893. private _tmpQuaternion;
  75894. private _populateTmpTransformation;
  75895. /**
  75896. * Create a new anchor point using a hit test result at a specific point in the scene
  75897. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75898. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75899. *
  75900. * @param hitTestResult The hit test result to use for this anchor creation
  75901. * @param position an optional position offset for this anchor
  75902. * @param rotationQuaternion an optional rotation offset for this anchor
  75903. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75904. */
  75905. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75906. /**
  75907. * Add a new anchor at a specific position and rotation
  75908. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75909. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75910. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75911. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75912. *
  75913. * @param position the position in which to add an anchor
  75914. * @param rotationQuaternion an optional rotation for the anchor transformation
  75915. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75916. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75917. */
  75918. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75919. /**
  75920. * detach this feature.
  75921. * Will usually be called by the features manager
  75922. *
  75923. * @returns true if successful.
  75924. */
  75925. detach(): boolean;
  75926. /**
  75927. * Dispose this feature and all of the resources attached
  75928. */
  75929. dispose(): void;
  75930. protected _onXRFrame(frame: XRFrame): void;
  75931. /**
  75932. * avoiding using Array.find for global support.
  75933. * @param xrAnchor the plane to find in the array
  75934. */
  75935. private _findIndexInAnchorArray;
  75936. private _updateAnchorWithXRFrame;
  75937. private _createAnchorAtTransformation;
  75938. }
  75939. }
  75940. declare module BABYLON {
  75941. /**
  75942. * Options used in the plane detector module
  75943. */
  75944. export interface IWebXRPlaneDetectorOptions {
  75945. /**
  75946. * The node to use to transform the local results to world coordinates
  75947. */
  75948. worldParentNode?: TransformNode;
  75949. /**
  75950. * If set to true a reference of the created planes will be kept until the next session starts
  75951. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  75952. */
  75953. doNotRemovePlanesOnSessionEnded?: boolean;
  75954. }
  75955. /**
  75956. * A babylon interface for a WebXR plane.
  75957. * A Plane is actually a polygon, built from N points in space
  75958. *
  75959. * Supported in chrome 79, not supported in canary 81 ATM
  75960. */
  75961. export interface IWebXRPlane {
  75962. /**
  75963. * a babylon-assigned ID for this polygon
  75964. */
  75965. id: number;
  75966. /**
  75967. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75968. */
  75969. polygonDefinition: Array<Vector3>;
  75970. /**
  75971. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75972. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75973. */
  75974. transformationMatrix: Matrix;
  75975. /**
  75976. * the native xr-plane object
  75977. */
  75978. xrPlane: XRPlane;
  75979. }
  75980. /**
  75981. * The plane detector is used to detect planes in the real world when in AR
  75982. * For more information see https://github.com/immersive-web/real-world-geometry/
  75983. */
  75984. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75985. private _options;
  75986. private _detectedPlanes;
  75987. private _enabled;
  75988. private _lastFrameDetected;
  75989. /**
  75990. * The module's name
  75991. */
  75992. static readonly Name: string;
  75993. /**
  75994. * The (Babylon) version of this module.
  75995. * This is an integer representing the implementation version.
  75996. * This number does not correspond to the WebXR specs version
  75997. */
  75998. static readonly Version: number;
  75999. /**
  76000. * Observers registered here will be executed when a new plane was added to the session
  76001. */
  76002. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76003. /**
  76004. * Observers registered here will be executed when a plane is no longer detected in the session
  76005. */
  76006. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76007. /**
  76008. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76009. * This can execute N times every frame
  76010. */
  76011. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76012. /**
  76013. * construct a new Plane Detector
  76014. * @param _xrSessionManager an instance of xr Session manager
  76015. * @param _options configuration to use when constructing this feature
  76016. */
  76017. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76018. /**
  76019. * detach this feature.
  76020. * Will usually be called by the features manager
  76021. *
  76022. * @returns true if successful.
  76023. */
  76024. detach(): boolean;
  76025. /**
  76026. * Dispose this feature and all of the resources attached
  76027. */
  76028. dispose(): void;
  76029. /**
  76030. * Check if the needed objects are defined.
  76031. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76032. */
  76033. isCompatible(): boolean;
  76034. protected _onXRFrame(frame: XRFrame): void;
  76035. private _init;
  76036. private _updatePlaneWithXRPlane;
  76037. /**
  76038. * avoiding using Array.find for global support.
  76039. * @param xrPlane the plane to find in the array
  76040. */
  76041. private findIndexInPlaneArray;
  76042. }
  76043. }
  76044. declare module BABYLON {
  76045. /**
  76046. * Options interface for the background remover plugin
  76047. */
  76048. export interface IWebXRBackgroundRemoverOptions {
  76049. /**
  76050. * Further background meshes to disable when entering AR
  76051. */
  76052. backgroundMeshes?: AbstractMesh[];
  76053. /**
  76054. * flags to configure the removal of the environment helper.
  76055. * If not set, the entire background will be removed. If set, flags should be set as well.
  76056. */
  76057. environmentHelperRemovalFlags?: {
  76058. /**
  76059. * Should the skybox be removed (default false)
  76060. */
  76061. skyBox?: boolean;
  76062. /**
  76063. * Should the ground be removed (default false)
  76064. */
  76065. ground?: boolean;
  76066. };
  76067. /**
  76068. * don't disable the environment helper
  76069. */
  76070. ignoreEnvironmentHelper?: boolean;
  76071. }
  76072. /**
  76073. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76074. */
  76075. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76076. /**
  76077. * read-only options to be used in this module
  76078. */
  76079. readonly options: IWebXRBackgroundRemoverOptions;
  76080. /**
  76081. * The module's name
  76082. */
  76083. static readonly Name: string;
  76084. /**
  76085. * The (Babylon) version of this module.
  76086. * This is an integer representing the implementation version.
  76087. * This number does not correspond to the WebXR specs version
  76088. */
  76089. static readonly Version: number;
  76090. /**
  76091. * registered observers will be triggered when the background state changes
  76092. */
  76093. onBackgroundStateChangedObservable: Observable<boolean>;
  76094. /**
  76095. * constructs a new background remover module
  76096. * @param _xrSessionManager the session manager for this module
  76097. * @param options read-only options to be used in this module
  76098. */
  76099. constructor(_xrSessionManager: WebXRSessionManager,
  76100. /**
  76101. * read-only options to be used in this module
  76102. */
  76103. options?: IWebXRBackgroundRemoverOptions);
  76104. /**
  76105. * attach this feature
  76106. * Will usually be called by the features manager
  76107. *
  76108. * @returns true if successful.
  76109. */
  76110. attach(): boolean;
  76111. /**
  76112. * detach this feature.
  76113. * Will usually be called by the features manager
  76114. *
  76115. * @returns true if successful.
  76116. */
  76117. detach(): boolean;
  76118. /**
  76119. * Dispose this feature and all of the resources attached
  76120. */
  76121. dispose(): void;
  76122. protected _onXRFrame(_xrFrame: XRFrame): void;
  76123. private _setBackgroundState;
  76124. }
  76125. }
  76126. declare module BABYLON {
  76127. /**
  76128. * Options for the controller physics feature
  76129. */
  76130. export class IWebXRControllerPhysicsOptions {
  76131. /**
  76132. * Should the headset get its own impostor
  76133. */
  76134. enableHeadsetImpostor?: boolean;
  76135. /**
  76136. * Optional parameters for the headset impostor
  76137. */
  76138. headsetImpostorParams?: {
  76139. /**
  76140. * The type of impostor to create. Default is sphere
  76141. */
  76142. impostorType: number;
  76143. /**
  76144. * the size of the impostor. Defaults to 10cm
  76145. */
  76146. impostorSize?: number | {
  76147. width: number;
  76148. height: number;
  76149. depth: number;
  76150. };
  76151. /**
  76152. * Friction definitions
  76153. */
  76154. friction?: number;
  76155. /**
  76156. * Restitution
  76157. */
  76158. restitution?: number;
  76159. };
  76160. /**
  76161. * The physics properties of the future impostors
  76162. */
  76163. physicsProperties?: {
  76164. /**
  76165. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76166. * Note that this requires a physics engine that supports mesh impostors!
  76167. */
  76168. useControllerMesh?: boolean;
  76169. /**
  76170. * The type of impostor to create. Default is sphere
  76171. */
  76172. impostorType?: number;
  76173. /**
  76174. * the size of the impostor. Defaults to 10cm
  76175. */
  76176. impostorSize?: number | {
  76177. width: number;
  76178. height: number;
  76179. depth: number;
  76180. };
  76181. /**
  76182. * Friction definitions
  76183. */
  76184. friction?: number;
  76185. /**
  76186. * Restitution
  76187. */
  76188. restitution?: number;
  76189. };
  76190. /**
  76191. * the xr input to use with this pointer selection
  76192. */
  76193. xrInput: WebXRInput;
  76194. }
  76195. /**
  76196. * Add physics impostor to your webxr controllers,
  76197. * including naive calculation of their linear and angular velocity
  76198. */
  76199. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76200. private readonly _options;
  76201. private _attachController;
  76202. private _controllers;
  76203. private _debugMode;
  76204. private _delta;
  76205. private _headsetImpostor?;
  76206. private _headsetMesh?;
  76207. private _lastTimestamp;
  76208. private _tmpQuaternion;
  76209. private _tmpVector;
  76210. /**
  76211. * The module's name
  76212. */
  76213. static readonly Name: string;
  76214. /**
  76215. * The (Babylon) version of this module.
  76216. * This is an integer representing the implementation version.
  76217. * This number does not correspond to the webxr specs version
  76218. */
  76219. static readonly Version: number;
  76220. /**
  76221. * Construct a new Controller Physics Feature
  76222. * @param _xrSessionManager the corresponding xr session manager
  76223. * @param _options options to create this feature with
  76224. */
  76225. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76226. /**
  76227. * @hidden
  76228. * enable debugging - will show console outputs and the impostor mesh
  76229. */
  76230. _enablePhysicsDebug(): void;
  76231. /**
  76232. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76233. * @param xrController the controller to add
  76234. */
  76235. addController(xrController: WebXRInputSource): void;
  76236. /**
  76237. * attach this feature
  76238. * Will usually be called by the features manager
  76239. *
  76240. * @returns true if successful.
  76241. */
  76242. attach(): boolean;
  76243. /**
  76244. * detach this feature.
  76245. * Will usually be called by the features manager
  76246. *
  76247. * @returns true if successful.
  76248. */
  76249. detach(): boolean;
  76250. /**
  76251. * Get the headset impostor, if enabled
  76252. * @returns the impostor
  76253. */
  76254. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76255. /**
  76256. * Get the physics impostor of a specific controller.
  76257. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76258. * @param controller the controller or the controller id of which to get the impostor
  76259. * @returns the impostor or null
  76260. */
  76261. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76262. /**
  76263. * Update the physics properties provided in the constructor
  76264. * @param newProperties the new properties object
  76265. */
  76266. setPhysicsProperties(newProperties: {
  76267. impostorType?: number;
  76268. impostorSize?: number | {
  76269. width: number;
  76270. height: number;
  76271. depth: number;
  76272. };
  76273. friction?: number;
  76274. restitution?: number;
  76275. }): void;
  76276. protected _onXRFrame(_xrFrame: any): void;
  76277. private _detachController;
  76278. }
  76279. }
  76280. declare module BABYLON {
  76281. /**
  76282. * A babylon interface for a "WebXR" feature point.
  76283. * Represents the position and confidence value of a given feature point.
  76284. */
  76285. export interface IWebXRFeaturePoint {
  76286. /**
  76287. * Represents the position of the feature point in world space.
  76288. */
  76289. position: Vector3;
  76290. /**
  76291. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76292. */
  76293. confidenceValue: number;
  76294. }
  76295. /**
  76296. * The feature point system is used to detect feature points from real world geometry.
  76297. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76298. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76299. */
  76300. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76301. private _enabled;
  76302. private _featurePointCloud;
  76303. /**
  76304. * The module's name
  76305. */
  76306. static readonly Name: string;
  76307. /**
  76308. * The (Babylon) version of this module.
  76309. * This is an integer representing the implementation version.
  76310. * This number does not correspond to the WebXR specs version
  76311. */
  76312. static readonly Version: number;
  76313. /**
  76314. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76315. * Will notify the observers about which feature points have been added.
  76316. */
  76317. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76318. /**
  76319. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76320. * Will notify the observers about which feature points have been updated.
  76321. */
  76322. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76323. /**
  76324. * The current feature point cloud maintained across frames.
  76325. */
  76326. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76327. /**
  76328. * construct the feature point system
  76329. * @param _xrSessionManager an instance of xr Session manager
  76330. */
  76331. constructor(_xrSessionManager: WebXRSessionManager);
  76332. /**
  76333. * Detach this feature.
  76334. * Will usually be called by the features manager
  76335. *
  76336. * @returns true if successful.
  76337. */
  76338. detach(): boolean;
  76339. /**
  76340. * Dispose this feature and all of the resources attached
  76341. */
  76342. dispose(): void;
  76343. /**
  76344. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76345. */
  76346. protected _onXRFrame(frame: XRFrame): void;
  76347. /**
  76348. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76349. */
  76350. private _init;
  76351. }
  76352. }
  76353. declare module BABYLON {
  76354. /**
  76355. * Configuration interface for the hand tracking feature
  76356. */
  76357. export interface IWebXRHandTrackingOptions {
  76358. /**
  76359. * The xrInput that will be used as source for new hands
  76360. */
  76361. xrInput: WebXRInput;
  76362. /**
  76363. * Configuration object for the joint meshes
  76364. */
  76365. jointMeshes?: {
  76366. /**
  76367. * Should the meshes created be invisible (defaults to false)
  76368. */
  76369. invisible?: boolean;
  76370. /**
  76371. * A source mesh to be used to create instances. Defaults to a sphere.
  76372. * This mesh will be the source for all other (25) meshes.
  76373. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76374. */
  76375. sourceMesh?: Mesh;
  76376. /**
  76377. * This function will be called after a mesh was created for a specific joint.
  76378. * Using this function you can either manipulate the instance or return a new mesh.
  76379. * When returning a new mesh the instance created before will be disposed
  76380. */
  76381. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76382. /**
  76383. * Should the source mesh stay visible. Defaults to false
  76384. */
  76385. keepOriginalVisible?: boolean;
  76386. /**
  76387. * Scale factor for all instances (defaults to 2)
  76388. */
  76389. scaleFactor?: number;
  76390. /**
  76391. * Should each instance have its own physics impostor
  76392. */
  76393. enablePhysics?: boolean;
  76394. /**
  76395. * If enabled, override default physics properties
  76396. */
  76397. physicsProps?: {
  76398. friction?: number;
  76399. restitution?: number;
  76400. impostorType?: number;
  76401. };
  76402. /**
  76403. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76404. */
  76405. handMesh?: AbstractMesh;
  76406. };
  76407. }
  76408. /**
  76409. * Parts of the hands divided to writs and finger names
  76410. */
  76411. export const enum HandPart {
  76412. /**
  76413. * HandPart - Wrist
  76414. */
  76415. WRIST = "wrist",
  76416. /**
  76417. * HandPart - The THumb
  76418. */
  76419. THUMB = "thumb",
  76420. /**
  76421. * HandPart - Index finger
  76422. */
  76423. INDEX = "index",
  76424. /**
  76425. * HandPart - Middle finger
  76426. */
  76427. MIDDLE = "middle",
  76428. /**
  76429. * HandPart - Ring finger
  76430. */
  76431. RING = "ring",
  76432. /**
  76433. * HandPart - Little finger
  76434. */
  76435. LITTLE = "little"
  76436. }
  76437. /**
  76438. * Representing a single hand (with its corresponding native XRHand object)
  76439. */
  76440. export class WebXRHand implements IDisposable {
  76441. /** the controller to which the hand correlates */
  76442. readonly xrController: WebXRInputSource;
  76443. /** the meshes to be used to track the hand joints */
  76444. readonly trackedMeshes: AbstractMesh[];
  76445. /**
  76446. * Hand-parts definition (key is HandPart)
  76447. */
  76448. handPartsDefinition: {
  76449. [key: string]: number[];
  76450. };
  76451. /**
  76452. * Populate the HandPartsDefinition object.
  76453. * This is called as a side effect since certain browsers don't have XRHand defined.
  76454. */
  76455. private generateHandPartsDefinition;
  76456. /**
  76457. * Construct a new hand object
  76458. * @param xrController the controller to which the hand correlates
  76459. * @param trackedMeshes the meshes to be used to track the hand joints
  76460. */
  76461. constructor(
  76462. /** the controller to which the hand correlates */
  76463. xrController: WebXRInputSource,
  76464. /** the meshes to be used to track the hand joints */
  76465. trackedMeshes: AbstractMesh[]);
  76466. /**
  76467. * Update this hand from the latest xr frame
  76468. * @param xrFrame xrFrame to update from
  76469. * @param referenceSpace The current viewer reference space
  76470. * @param scaleFactor optional scale factor for the meshes
  76471. */
  76472. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76473. /**
  76474. * Get meshes of part of the hand
  76475. * @param part the part of hand to get
  76476. * @returns An array of meshes that correlate to the hand part requested
  76477. */
  76478. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76479. /**
  76480. * Dispose this Hand object
  76481. */
  76482. dispose(): void;
  76483. }
  76484. /**
  76485. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76486. */
  76487. export class WebXRHandTracking extends WebXRAbstractFeature {
  76488. /**
  76489. * options to use when constructing this feature
  76490. */
  76491. readonly options: IWebXRHandTrackingOptions;
  76492. private static _idCounter;
  76493. /**
  76494. * The module's name
  76495. */
  76496. static readonly Name: string;
  76497. /**
  76498. * The (Babylon) version of this module.
  76499. * This is an integer representing the implementation version.
  76500. * This number does not correspond to the WebXR specs version
  76501. */
  76502. static readonly Version: number;
  76503. /**
  76504. * This observable will notify registered observers when a new hand object was added and initialized
  76505. */
  76506. onHandAddedObservable: Observable<WebXRHand>;
  76507. /**
  76508. * This observable will notify its observers right before the hand object is disposed
  76509. */
  76510. onHandRemovedObservable: Observable<WebXRHand>;
  76511. private _hands;
  76512. /**
  76513. * Creates a new instance of the hit test feature
  76514. * @param _xrSessionManager an instance of WebXRSessionManager
  76515. * @param options options to use when constructing this feature
  76516. */
  76517. constructor(_xrSessionManager: WebXRSessionManager,
  76518. /**
  76519. * options to use when constructing this feature
  76520. */
  76521. options: IWebXRHandTrackingOptions);
  76522. /**
  76523. * Check if the needed objects are defined.
  76524. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76525. */
  76526. isCompatible(): boolean;
  76527. /**
  76528. * attach this feature
  76529. * Will usually be called by the features manager
  76530. *
  76531. * @returns true if successful.
  76532. */
  76533. attach(): boolean;
  76534. /**
  76535. * detach this feature.
  76536. * Will usually be called by the features manager
  76537. *
  76538. * @returns true if successful.
  76539. */
  76540. detach(): boolean;
  76541. /**
  76542. * Dispose this feature and all of the resources attached
  76543. */
  76544. dispose(): void;
  76545. /**
  76546. * Get the hand object according to the controller id
  76547. * @param controllerId the controller id to which we want to get the hand
  76548. * @returns null if not found or the WebXRHand object if found
  76549. */
  76550. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76551. /**
  76552. * Get a hand object according to the requested handedness
  76553. * @param handedness the handedness to request
  76554. * @returns null if not found or the WebXRHand object if found
  76555. */
  76556. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76557. protected _onXRFrame(_xrFrame: XRFrame): void;
  76558. private _attachHand;
  76559. private _detachHand;
  76560. }
  76561. }
  76562. declare module BABYLON {
  76563. /**
  76564. * The motion controller class for all microsoft mixed reality controllers
  76565. */
  76566. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76567. protected readonly _mapping: {
  76568. defaultButton: {
  76569. valueNodeName: string;
  76570. unpressedNodeName: string;
  76571. pressedNodeName: string;
  76572. };
  76573. defaultAxis: {
  76574. valueNodeName: string;
  76575. minNodeName: string;
  76576. maxNodeName: string;
  76577. };
  76578. buttons: {
  76579. "xr-standard-trigger": {
  76580. rootNodeName: string;
  76581. componentProperty: string;
  76582. states: string[];
  76583. };
  76584. "xr-standard-squeeze": {
  76585. rootNodeName: string;
  76586. componentProperty: string;
  76587. states: string[];
  76588. };
  76589. "xr-standard-touchpad": {
  76590. rootNodeName: string;
  76591. labelAnchorNodeName: string;
  76592. touchPointNodeName: string;
  76593. };
  76594. "xr-standard-thumbstick": {
  76595. rootNodeName: string;
  76596. componentProperty: string;
  76597. states: string[];
  76598. };
  76599. };
  76600. axes: {
  76601. "xr-standard-touchpad": {
  76602. "x-axis": {
  76603. rootNodeName: string;
  76604. };
  76605. "y-axis": {
  76606. rootNodeName: string;
  76607. };
  76608. };
  76609. "xr-standard-thumbstick": {
  76610. "x-axis": {
  76611. rootNodeName: string;
  76612. };
  76613. "y-axis": {
  76614. rootNodeName: string;
  76615. };
  76616. };
  76617. };
  76618. };
  76619. /**
  76620. * The base url used to load the left and right controller models
  76621. */
  76622. static MODEL_BASE_URL: string;
  76623. /**
  76624. * The name of the left controller model file
  76625. */
  76626. static MODEL_LEFT_FILENAME: string;
  76627. /**
  76628. * The name of the right controller model file
  76629. */
  76630. static MODEL_RIGHT_FILENAME: string;
  76631. profileId: string;
  76632. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76633. protected _getFilenameAndPath(): {
  76634. filename: string;
  76635. path: string;
  76636. };
  76637. protected _getModelLoadingConstraints(): boolean;
  76638. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76639. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76640. protected _updateModel(): void;
  76641. }
  76642. }
  76643. declare module BABYLON {
  76644. /**
  76645. * The motion controller class for oculus touch (quest, rift).
  76646. * This class supports legacy mapping as well the standard xr mapping
  76647. */
  76648. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76649. private _forceLegacyControllers;
  76650. private _modelRootNode;
  76651. /**
  76652. * The base url used to load the left and right controller models
  76653. */
  76654. static MODEL_BASE_URL: string;
  76655. /**
  76656. * The name of the left controller model file
  76657. */
  76658. static MODEL_LEFT_FILENAME: string;
  76659. /**
  76660. * The name of the right controller model file
  76661. */
  76662. static MODEL_RIGHT_FILENAME: string;
  76663. /**
  76664. * Base Url for the Quest controller model.
  76665. */
  76666. static QUEST_MODEL_BASE_URL: string;
  76667. profileId: string;
  76668. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76669. protected _getFilenameAndPath(): {
  76670. filename: string;
  76671. path: string;
  76672. };
  76673. protected _getModelLoadingConstraints(): boolean;
  76674. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76675. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76676. protected _updateModel(): void;
  76677. /**
  76678. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76679. * between the touch and touch 2.
  76680. */
  76681. private _isQuest;
  76682. }
  76683. }
  76684. declare module BABYLON {
  76685. /**
  76686. * The motion controller class for the standard HTC-Vive controllers
  76687. */
  76688. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76689. private _modelRootNode;
  76690. /**
  76691. * The base url used to load the left and right controller models
  76692. */
  76693. static MODEL_BASE_URL: string;
  76694. /**
  76695. * File name for the controller model.
  76696. */
  76697. static MODEL_FILENAME: string;
  76698. profileId: string;
  76699. /**
  76700. * Create a new Vive motion controller object
  76701. * @param scene the scene to use to create this controller
  76702. * @param gamepadObject the corresponding gamepad object
  76703. * @param handedness the handedness of the controller
  76704. */
  76705. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76706. protected _getFilenameAndPath(): {
  76707. filename: string;
  76708. path: string;
  76709. };
  76710. protected _getModelLoadingConstraints(): boolean;
  76711. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76712. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76713. protected _updateModel(): void;
  76714. }
  76715. }
  76716. declare module BABYLON {
  76717. /**
  76718. * A cursor which tracks a point on a path
  76719. */
  76720. export class PathCursor {
  76721. private path;
  76722. /**
  76723. * Stores path cursor callbacks for when an onchange event is triggered
  76724. */
  76725. private _onchange;
  76726. /**
  76727. * The value of the path cursor
  76728. */
  76729. value: number;
  76730. /**
  76731. * The animation array of the path cursor
  76732. */
  76733. animations: Animation[];
  76734. /**
  76735. * Initializes the path cursor
  76736. * @param path The path to track
  76737. */
  76738. constructor(path: Path2);
  76739. /**
  76740. * Gets the cursor point on the path
  76741. * @returns A point on the path cursor at the cursor location
  76742. */
  76743. getPoint(): Vector3;
  76744. /**
  76745. * Moves the cursor ahead by the step amount
  76746. * @param step The amount to move the cursor forward
  76747. * @returns This path cursor
  76748. */
  76749. moveAhead(step?: number): PathCursor;
  76750. /**
  76751. * Moves the cursor behind by the step amount
  76752. * @param step The amount to move the cursor back
  76753. * @returns This path cursor
  76754. */
  76755. moveBack(step?: number): PathCursor;
  76756. /**
  76757. * Moves the cursor by the step amount
  76758. * If the step amount is greater than one, an exception is thrown
  76759. * @param step The amount to move the cursor
  76760. * @returns This path cursor
  76761. */
  76762. move(step: number): PathCursor;
  76763. /**
  76764. * Ensures that the value is limited between zero and one
  76765. * @returns This path cursor
  76766. */
  76767. private ensureLimits;
  76768. /**
  76769. * Runs onchange callbacks on change (used by the animation engine)
  76770. * @returns This path cursor
  76771. */
  76772. private raiseOnChange;
  76773. /**
  76774. * Executes a function on change
  76775. * @param f A path cursor onchange callback
  76776. * @returns This path cursor
  76777. */
  76778. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76779. }
  76780. }
  76781. declare module BABYLON {
  76782. /** @hidden */
  76783. export var blurPixelShader: {
  76784. name: string;
  76785. shader: string;
  76786. };
  76787. }
  76788. declare module BABYLON {
  76789. /** @hidden */
  76790. export var pointCloudVertexDeclaration: {
  76791. name: string;
  76792. shader: string;
  76793. };
  76794. }
  76795. // Mixins
  76796. interface Window {
  76797. mozIndexedDB: IDBFactory;
  76798. webkitIndexedDB: IDBFactory;
  76799. msIndexedDB: IDBFactory;
  76800. webkitURL: typeof URL;
  76801. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  76802. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  76803. WebGLRenderingContext: WebGLRenderingContext;
  76804. MSGesture: MSGesture;
  76805. CANNON: any;
  76806. AudioContext: AudioContext;
  76807. webkitAudioContext: AudioContext;
  76808. PointerEvent: any;
  76809. Math: Math;
  76810. Uint8Array: Uint8ArrayConstructor;
  76811. Float32Array: Float32ArrayConstructor;
  76812. mozURL: typeof URL;
  76813. msURL: typeof URL;
  76814. VRFrameData: any; // WebVR, from specs 1.1
  76815. DracoDecoderModule: any;
  76816. setImmediate(handler: (...args: any[]) => void): number;
  76817. }
  76818. interface HTMLCanvasElement {
  76819. requestPointerLock(): void;
  76820. msRequestPointerLock?(): void;
  76821. mozRequestPointerLock?(): void;
  76822. webkitRequestPointerLock?(): void;
  76823. /** Track wether a record is in progress */
  76824. isRecording: boolean;
  76825. /** Capture Stream method defined by some browsers */
  76826. captureStream(fps?: number): MediaStream;
  76827. }
  76828. interface CanvasRenderingContext2D {
  76829. msImageSmoothingEnabled: boolean;
  76830. }
  76831. interface MouseEvent {
  76832. mozMovementX: number;
  76833. mozMovementY: number;
  76834. webkitMovementX: number;
  76835. webkitMovementY: number;
  76836. msMovementX: number;
  76837. msMovementY: number;
  76838. }
  76839. interface Navigator {
  76840. mozGetVRDevices: (any: any) => any;
  76841. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76842. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76843. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76844. webkitGetGamepads(): Gamepad[];
  76845. msGetGamepads(): Gamepad[];
  76846. webkitGamepads(): Gamepad[];
  76847. }
  76848. interface HTMLVideoElement {
  76849. mozSrcObject: any;
  76850. }
  76851. interface Math {
  76852. fround(x: number): number;
  76853. imul(a: number, b: number): number;
  76854. }
  76855. interface WebGLRenderingContext {
  76856. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76857. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76858. vertexAttribDivisor(index: number, divisor: number): void;
  76859. createVertexArray(): any;
  76860. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76861. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76862. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76863. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76864. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76865. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76866. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76867. // Queries
  76868. createQuery(): WebGLQuery;
  76869. deleteQuery(query: WebGLQuery): void;
  76870. beginQuery(target: number, query: WebGLQuery): void;
  76871. endQuery(target: number): void;
  76872. getQueryParameter(query: WebGLQuery, pname: number): any;
  76873. getQuery(target: number, pname: number): any;
  76874. MAX_SAMPLES: number;
  76875. RGBA8: number;
  76876. READ_FRAMEBUFFER: number;
  76877. DRAW_FRAMEBUFFER: number;
  76878. UNIFORM_BUFFER: number;
  76879. HALF_FLOAT_OES: number;
  76880. RGBA16F: number;
  76881. RGBA32F: number;
  76882. R32F: number;
  76883. RG32F: number;
  76884. RGB32F: number;
  76885. R16F: number;
  76886. RG16F: number;
  76887. RGB16F: number;
  76888. RED: number;
  76889. RG: number;
  76890. R8: number;
  76891. RG8: number;
  76892. UNSIGNED_INT_24_8: number;
  76893. DEPTH24_STENCIL8: number;
  76894. MIN: number;
  76895. MAX: number;
  76896. /* Multiple Render Targets */
  76897. drawBuffers(buffers: number[]): void;
  76898. readBuffer(src: number): void;
  76899. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76900. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76901. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76902. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76903. // Occlusion Query
  76904. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76905. ANY_SAMPLES_PASSED: number;
  76906. QUERY_RESULT_AVAILABLE: number;
  76907. QUERY_RESULT: number;
  76908. }
  76909. interface WebGLProgram {
  76910. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76911. }
  76912. interface EXT_disjoint_timer_query {
  76913. QUERY_COUNTER_BITS_EXT: number;
  76914. TIME_ELAPSED_EXT: number;
  76915. TIMESTAMP_EXT: number;
  76916. GPU_DISJOINT_EXT: number;
  76917. QUERY_RESULT_EXT: number;
  76918. QUERY_RESULT_AVAILABLE_EXT: number;
  76919. queryCounterEXT(query: WebGLQuery, target: number): void;
  76920. createQueryEXT(): WebGLQuery;
  76921. beginQueryEXT(target: number, query: WebGLQuery): void;
  76922. endQueryEXT(target: number): void;
  76923. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76924. deleteQueryEXT(query: WebGLQuery): void;
  76925. }
  76926. interface WebGLUniformLocation {
  76927. _currentState: any;
  76928. }
  76929. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76930. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76931. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76932. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76933. interface WebGLRenderingContext {
  76934. readonly RASTERIZER_DISCARD: number;
  76935. readonly DEPTH_COMPONENT24: number;
  76936. readonly TEXTURE_3D: number;
  76937. readonly TEXTURE_2D_ARRAY: number;
  76938. readonly TEXTURE_COMPARE_FUNC: number;
  76939. readonly TEXTURE_COMPARE_MODE: number;
  76940. readonly COMPARE_REF_TO_TEXTURE: number;
  76941. readonly TEXTURE_WRAP_R: number;
  76942. readonly HALF_FLOAT: number;
  76943. readonly RGB8: number;
  76944. readonly RED_INTEGER: number;
  76945. readonly RG_INTEGER: number;
  76946. readonly RGB_INTEGER: number;
  76947. readonly RGBA_INTEGER: number;
  76948. readonly R8_SNORM: number;
  76949. readonly RG8_SNORM: number;
  76950. readonly RGB8_SNORM: number;
  76951. readonly RGBA8_SNORM: number;
  76952. readonly R8I: number;
  76953. readonly RG8I: number;
  76954. readonly RGB8I: number;
  76955. readonly RGBA8I: number;
  76956. readonly R8UI: number;
  76957. readonly RG8UI: number;
  76958. readonly RGB8UI: number;
  76959. readonly RGBA8UI: number;
  76960. readonly R16I: number;
  76961. readonly RG16I: number;
  76962. readonly RGB16I: number;
  76963. readonly RGBA16I: number;
  76964. readonly R16UI: number;
  76965. readonly RG16UI: number;
  76966. readonly RGB16UI: number;
  76967. readonly RGBA16UI: number;
  76968. readonly R32I: number;
  76969. readonly RG32I: number;
  76970. readonly RGB32I: number;
  76971. readonly RGBA32I: number;
  76972. readonly R32UI: number;
  76973. readonly RG32UI: number;
  76974. readonly RGB32UI: number;
  76975. readonly RGBA32UI: number;
  76976. readonly RGB10_A2UI: number;
  76977. readonly R11F_G11F_B10F: number;
  76978. readonly RGB9_E5: number;
  76979. readonly RGB10_A2: number;
  76980. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  76981. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  76982. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  76983. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76984. readonly DEPTH_COMPONENT32F: number;
  76985. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  76986. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  76987. 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;
  76988. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  76989. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  76990. readonly TRANSFORM_FEEDBACK: number;
  76991. readonly INTERLEAVED_ATTRIBS: number;
  76992. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  76993. createTransformFeedback(): WebGLTransformFeedback;
  76994. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  76995. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  76996. beginTransformFeedback(primitiveMode: number): void;
  76997. endTransformFeedback(): void;
  76998. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  76999. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77000. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77001. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77002. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  77003. }
  77004. interface ImageBitmap {
  77005. readonly width: number;
  77006. readonly height: number;
  77007. close(): void;
  77008. }
  77009. interface WebGLQuery extends WebGLObject {
  77010. }
  77011. declare var WebGLQuery: {
  77012. prototype: WebGLQuery;
  77013. new(): WebGLQuery;
  77014. };
  77015. interface WebGLSampler extends WebGLObject {
  77016. }
  77017. declare var WebGLSampler: {
  77018. prototype: WebGLSampler;
  77019. new(): WebGLSampler;
  77020. };
  77021. interface WebGLSync extends WebGLObject {
  77022. }
  77023. declare var WebGLSync: {
  77024. prototype: WebGLSync;
  77025. new(): WebGLSync;
  77026. };
  77027. interface WebGLTransformFeedback extends WebGLObject {
  77028. }
  77029. declare var WebGLTransformFeedback: {
  77030. prototype: WebGLTransformFeedback;
  77031. new(): WebGLTransformFeedback;
  77032. };
  77033. interface WebGLVertexArrayObject extends WebGLObject {
  77034. }
  77035. declare var WebGLVertexArrayObject: {
  77036. prototype: WebGLVertexArrayObject;
  77037. new(): WebGLVertexArrayObject;
  77038. };
  77039. // Type definitions for WebVR API
  77040. // Project: https://w3c.github.io/webvr/
  77041. // Definitions by: six a <https://github.com/lostfictions>
  77042. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77043. interface VRDisplay extends EventTarget {
  77044. /**
  77045. * Dictionary of capabilities describing the VRDisplay.
  77046. */
  77047. readonly capabilities: VRDisplayCapabilities;
  77048. /**
  77049. * z-depth defining the far plane of the eye view frustum
  77050. * enables mapping of values in the render target depth
  77051. * attachment to scene coordinates. Initially set to 10000.0.
  77052. */
  77053. depthFar: number;
  77054. /**
  77055. * z-depth defining the near plane of the eye view frustum
  77056. * enables mapping of values in the render target depth
  77057. * attachment to scene coordinates. Initially set to 0.01.
  77058. */
  77059. depthNear: number;
  77060. /**
  77061. * An identifier for this distinct VRDisplay. Used as an
  77062. * association point in the Gamepad API.
  77063. */
  77064. readonly displayId: number;
  77065. /**
  77066. * A display name, a user-readable name identifying it.
  77067. */
  77068. readonly displayName: string;
  77069. readonly isConnected: boolean;
  77070. readonly isPresenting: boolean;
  77071. /**
  77072. * If this VRDisplay supports room-scale experiences, the optional
  77073. * stage attribute contains details on the room-scale parameters.
  77074. */
  77075. readonly stageParameters: VRStageParameters | null;
  77076. /**
  77077. * Passing the value returned by `requestAnimationFrame` to
  77078. * `cancelAnimationFrame` will unregister the callback.
  77079. * @param handle Define the hanle of the request to cancel
  77080. */
  77081. cancelAnimationFrame(handle: number): void;
  77082. /**
  77083. * Stops presenting to the VRDisplay.
  77084. * @returns a promise to know when it stopped
  77085. */
  77086. exitPresent(): Promise<void>;
  77087. /**
  77088. * Return the current VREyeParameters for the given eye.
  77089. * @param whichEye Define the eye we want the parameter for
  77090. * @returns the eye parameters
  77091. */
  77092. getEyeParameters(whichEye: string): VREyeParameters;
  77093. /**
  77094. * Populates the passed VRFrameData with the information required to render
  77095. * the current frame.
  77096. * @param frameData Define the data structure to populate
  77097. * @returns true if ok otherwise false
  77098. */
  77099. getFrameData(frameData: VRFrameData): boolean;
  77100. /**
  77101. * Get the layers currently being presented.
  77102. * @returns the list of VR layers
  77103. */
  77104. getLayers(): VRLayer[];
  77105. /**
  77106. * Return a VRPose containing the future predicted pose of the VRDisplay
  77107. * when the current frame will be presented. The value returned will not
  77108. * change until JavaScript has returned control to the browser.
  77109. *
  77110. * The VRPose will contain the position, orientation, velocity,
  77111. * and acceleration of each of these properties.
  77112. * @returns the pose object
  77113. */
  77114. getPose(): VRPose;
  77115. /**
  77116. * Return the current instantaneous pose of the VRDisplay, with no
  77117. * prediction applied.
  77118. * @returns the current instantaneous pose
  77119. */
  77120. getImmediatePose(): VRPose;
  77121. /**
  77122. * The callback passed to `requestAnimationFrame` will be called
  77123. * any time a new frame should be rendered. When the VRDisplay is
  77124. * presenting the callback will be called at the native refresh
  77125. * rate of the HMD. When not presenting this function acts
  77126. * identically to how window.requestAnimationFrame acts. Content should
  77127. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77128. * asynchronously from other displays and at differing refresh rates.
  77129. * @param callback Define the eaction to run next frame
  77130. * @returns the request handle it
  77131. */
  77132. requestAnimationFrame(callback: FrameRequestCallback): number;
  77133. /**
  77134. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77135. * Repeat calls while already presenting will update the VRLayers being displayed.
  77136. * @param layers Define the list of layer to present
  77137. * @returns a promise to know when the request has been fulfilled
  77138. */
  77139. requestPresent(layers: VRLayer[]): Promise<void>;
  77140. /**
  77141. * Reset the pose for this display, treating its current position and
  77142. * orientation as the "origin/zero" values. VRPose.position,
  77143. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77144. * updated when calling resetPose(). This should be called in only
  77145. * sitting-space experiences.
  77146. */
  77147. resetPose(): void;
  77148. /**
  77149. * The VRLayer provided to the VRDisplay will be captured and presented
  77150. * in the HMD. Calling this function has the same effect on the source
  77151. * canvas as any other operation that uses its source image, and canvases
  77152. * created without preserveDrawingBuffer set to true will be cleared.
  77153. * @param pose Define the pose to submit
  77154. */
  77155. submitFrame(pose?: VRPose): void;
  77156. }
  77157. declare var VRDisplay: {
  77158. prototype: VRDisplay;
  77159. new(): VRDisplay;
  77160. };
  77161. interface VRLayer {
  77162. leftBounds?: number[] | Float32Array | null;
  77163. rightBounds?: number[] | Float32Array | null;
  77164. source?: HTMLCanvasElement | null;
  77165. }
  77166. interface VRDisplayCapabilities {
  77167. readonly canPresent: boolean;
  77168. readonly hasExternalDisplay: boolean;
  77169. readonly hasOrientation: boolean;
  77170. readonly hasPosition: boolean;
  77171. readonly maxLayers: number;
  77172. }
  77173. interface VREyeParameters {
  77174. /** @deprecated */
  77175. readonly fieldOfView: VRFieldOfView;
  77176. readonly offset: Float32Array;
  77177. readonly renderHeight: number;
  77178. readonly renderWidth: number;
  77179. }
  77180. interface VRFieldOfView {
  77181. readonly downDegrees: number;
  77182. readonly leftDegrees: number;
  77183. readonly rightDegrees: number;
  77184. readonly upDegrees: number;
  77185. }
  77186. interface VRFrameData {
  77187. readonly leftProjectionMatrix: Float32Array;
  77188. readonly leftViewMatrix: Float32Array;
  77189. readonly pose: VRPose;
  77190. readonly rightProjectionMatrix: Float32Array;
  77191. readonly rightViewMatrix: Float32Array;
  77192. readonly timestamp: number;
  77193. }
  77194. interface VRPose {
  77195. readonly angularAcceleration: Float32Array | null;
  77196. readonly angularVelocity: Float32Array | null;
  77197. readonly linearAcceleration: Float32Array | null;
  77198. readonly linearVelocity: Float32Array | null;
  77199. readonly orientation: Float32Array | null;
  77200. readonly position: Float32Array | null;
  77201. readonly timestamp: number;
  77202. }
  77203. interface VRStageParameters {
  77204. sittingToStandingTransform?: Float32Array;
  77205. sizeX?: number;
  77206. sizeY?: number;
  77207. }
  77208. interface Navigator {
  77209. getVRDisplays(): Promise<VRDisplay[]>;
  77210. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77211. }
  77212. interface Window {
  77213. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77214. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77215. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77216. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77217. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77218. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77219. }
  77220. interface Gamepad {
  77221. readonly displayId: number;
  77222. }
  77223. /**
  77224. * Available session modes
  77225. */
  77226. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77227. /**
  77228. * Reference space types
  77229. */
  77230. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77231. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77232. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77233. /**
  77234. * Handedness types
  77235. */
  77236. type XRHandedness = "none" | "left" | "right";
  77237. /**
  77238. * InputSource target ray modes
  77239. */
  77240. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77241. /**
  77242. * Eye types
  77243. */
  77244. type XREye = "none" | "left" | "right";
  77245. /**
  77246. * Type of XR events available
  77247. */
  77248. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77249. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  77250. type XRPlaneSet = Set<XRPlane>;
  77251. type XRAnchorSet = Set<XRAnchor>;
  77252. type XREventHandler = (callback: any) => void;
  77253. interface XRLayer extends EventTarget {}
  77254. interface XRSessionInit {
  77255. optionalFeatures?: string[];
  77256. requiredFeatures?: string[];
  77257. }
  77258. interface XRSessionEvent extends Event {
  77259. readonly session: XRSession;
  77260. }
  77261. interface XRSystem {
  77262. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  77263. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  77264. }
  77265. interface XRViewport {
  77266. readonly x: number;
  77267. readonly y: number;
  77268. readonly width: number;
  77269. readonly height: number;
  77270. }
  77271. interface XRWebGLLayerInit {
  77272. antialias?: boolean;
  77273. depth?: boolean;
  77274. stencil?: boolean;
  77275. alpha?: boolean;
  77276. multiview?: boolean;
  77277. framebufferScaleFactor?: number;
  77278. }
  77279. declare class XRWebGLLayer {
  77280. static getNativeFramebufferScaleFactor(session: XRSession): number;
  77281. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  77282. readonly antialias: boolean;
  77283. readonly framebuffer: WebGLFramebuffer;
  77284. readonly framebufferWidth: number;
  77285. readonly framebufferHeight: number;
  77286. readonly ignoreDepthValues: boolean;
  77287. getViewport: (view: XRView) => XRViewport;
  77288. }
  77289. // tslint:disable-next-line no-empty-interface
  77290. interface XRSpace extends EventTarget {}
  77291. interface XRRenderState {
  77292. readonly baseLayer?: XRWebGLLayer;
  77293. readonly depthFar: number;
  77294. readonly depthNear: number;
  77295. readonly inlineVerticalFieldOfView?: number;
  77296. }
  77297. interface XRRenderStateInit extends XRRenderState {
  77298. baseLayer: XRWebGLLayer;
  77299. depthFar: number;
  77300. depthNear: number;
  77301. inlineVerticalFieldOfView?: number;
  77302. layers?: XRLayer[];
  77303. }
  77304. interface XRReferenceSpace extends XRSpace {
  77305. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77306. onreset: XREventHandler;
  77307. }
  77308. interface XRBoundedReferenceSpace extends XRSpace {
  77309. readonly boundsGeometry: DOMPointReadOnly[];
  77310. }
  77311. interface XRInputSource {
  77312. readonly handedness: XRHandedness;
  77313. readonly targetRayMode: XRTargetRayMode;
  77314. readonly targetRaySpace: XRSpace;
  77315. readonly gripSpace?: XRSpace;
  77316. readonly gamepad?: Gamepad;
  77317. readonly profiles: Array<string>;
  77318. readonly hand?: XRHand;
  77319. }
  77320. interface XRPose {
  77321. readonly transform: XRRigidTransform;
  77322. readonly emulatedPosition: boolean;
  77323. }
  77324. interface XRFrame {
  77325. readonly session: XRSession;
  77326. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77327. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77328. // AR
  77329. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77330. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77331. // Anchors
  77332. trackedAnchors?: XRAnchorSet;
  77333. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77334. // Planes
  77335. worldInformation?: {
  77336. detectedPlanes?: XRPlaneSet;
  77337. };
  77338. // Hand tracking
  77339. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77340. }
  77341. interface XRInputSourceEvent extends Event {
  77342. readonly frame: XRFrame;
  77343. readonly inputSource: XRInputSource;
  77344. }
  77345. type XRInputSourceArray = XRInputSource[];
  77346. interface XRSession {
  77347. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  77348. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  77349. /**
  77350. * Returns a list of this session's XRInputSources, each representing an input device
  77351. * used to control the camera and/or scene.
  77352. */
  77353. readonly inputSources: Array<XRInputSource>;
  77354. /**
  77355. * object which contains options affecting how the imagery is rendered.
  77356. * This includes things such as the near and far clipping planes
  77357. */
  77358. readonly renderState: XRRenderState;
  77359. readonly visibilityState: XRVisibilityState;
  77360. /**
  77361. * Removes a callback from the animation frame painting callback from
  77362. * XRSession's set of animation frame rendering callbacks, given the
  77363. * identifying handle returned by a previous call to requestAnimationFrame().
  77364. */
  77365. cancelAnimationFrame: (handle: number) => void;
  77366. /**
  77367. * Ends the WebXR session. Returns a promise which resolves when the
  77368. * session has been shut down.
  77369. */
  77370. end(): Promise<void>;
  77371. /**
  77372. * Schedules the specified method to be called the next time the user agent
  77373. * is working on rendering an animation frame for the WebXR device. Returns an
  77374. * integer value which can be used to identify the request for the purposes of
  77375. * canceling the callback using cancelAnimationFrame(). This method is comparable
  77376. * to the Window.requestAnimationFrame() method.
  77377. */
  77378. requestAnimationFrame: XRFrameRequestCallback;
  77379. /**
  77380. * Requests that a new XRReferenceSpace of the specified type be created.
  77381. * Returns a promise which resolves with the XRReferenceSpace or
  77382. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  77383. * the requested space type isn't supported by the device.
  77384. */
  77385. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  77386. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77387. onend: XREventHandler;
  77388. oninputsourceschange: XREventHandler;
  77389. onselect: XREventHandler;
  77390. onselectstart: XREventHandler;
  77391. onselectend: XREventHandler;
  77392. onsqueeze: XREventHandler;
  77393. onsqueezestart: XREventHandler;
  77394. onsqueezeend: XREventHandler;
  77395. onvisibilitychange: XREventHandler;
  77396. // hit test
  77397. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77398. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77399. // legacy AR hit test
  77400. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77401. // legacy plane detection
  77402. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  77403. }
  77404. interface XRViewerPose extends XRPose {
  77405. readonly views: Array<XRView>;
  77406. }
  77407. declare class XRRigidTransform {
  77408. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  77409. position: DOMPointReadOnly;
  77410. orientation: DOMPointReadOnly;
  77411. matrix: Float32Array;
  77412. inverse: XRRigidTransform;
  77413. }
  77414. interface XRView {
  77415. readonly eye: XREye;
  77416. readonly projectionMatrix: Float32Array;
  77417. readonly transform: XRRigidTransform;
  77418. readonly recommendedViewportScale?: number;
  77419. requestViewportScale(scale: number): void;
  77420. }
  77421. interface XRInputSourceChangeEvent extends Event {
  77422. session: XRSession;
  77423. removed: Array<XRInputSource>;
  77424. added: Array<XRInputSource>;
  77425. }
  77426. // Experimental/Draft features
  77427. declare class XRRay {
  77428. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77429. origin: DOMPointReadOnly;
  77430. direction: DOMPointReadOnly;
  77431. matrix: Float32Array;
  77432. }
  77433. declare enum XRHitTestTrackableType {
  77434. "point",
  77435. "plane",
  77436. "mesh",
  77437. }
  77438. interface XRHitResult {
  77439. hitMatrix: Float32Array;
  77440. }
  77441. interface XRTransientInputHitTestResult {
  77442. readonly inputSource: XRInputSource;
  77443. readonly results: Array<XRHitTestResult>;
  77444. }
  77445. interface XRHitTestResult {
  77446. getPose(baseSpace: XRSpace): XRPose | undefined;
  77447. // When anchor system is enabled
  77448. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77449. }
  77450. interface XRHitTestSource {
  77451. cancel(): void;
  77452. }
  77453. interface XRTransientInputHitTestSource {
  77454. cancel(): void;
  77455. }
  77456. interface XRHitTestOptionsInit {
  77457. space: XRSpace;
  77458. entityTypes?: Array<XRHitTestTrackableType>;
  77459. offsetRay?: XRRay;
  77460. }
  77461. interface XRTransientInputHitTestOptionsInit {
  77462. profile: string;
  77463. entityTypes?: Array<XRHitTestTrackableType>;
  77464. offsetRay?: XRRay;
  77465. }
  77466. interface XRAnchor {
  77467. anchorSpace: XRSpace;
  77468. delete(): void;
  77469. }
  77470. interface XRPlane {
  77471. orientation: "Horizontal" | "Vertical";
  77472. planeSpace: XRSpace;
  77473. polygon: Array<DOMPointReadOnly>;
  77474. lastChangedTime: number;
  77475. }
  77476. interface XRJointSpace extends XRSpace {}
  77477. interface XRJointPose extends XRPose {
  77478. radius: number | undefined;
  77479. }
  77480. interface XRHand extends Iterable<XRJointSpace> {
  77481. readonly length: number;
  77482. [index: number]: XRJointSpace;
  77483. readonly WRIST: number;
  77484. readonly THUMB_METACARPAL: number;
  77485. readonly THUMB_PHALANX_PROXIMAL: number;
  77486. readonly THUMB_PHALANX_DISTAL: number;
  77487. readonly THUMB_PHALANX_TIP: number;
  77488. readonly INDEX_METACARPAL: number;
  77489. readonly INDEX_PHALANX_PROXIMAL: number;
  77490. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77491. readonly INDEX_PHALANX_DISTAL: number;
  77492. readonly INDEX_PHALANX_TIP: number;
  77493. readonly MIDDLE_METACARPAL: number;
  77494. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77495. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77496. readonly MIDDLE_PHALANX_DISTAL: number;
  77497. readonly MIDDLE_PHALANX_TIP: number;
  77498. readonly RING_METACARPAL: number;
  77499. readonly RING_PHALANX_PROXIMAL: number;
  77500. readonly RING_PHALANX_INTERMEDIATE: number;
  77501. readonly RING_PHALANX_DISTAL: number;
  77502. readonly RING_PHALANX_TIP: number;
  77503. readonly LITTLE_METACARPAL: number;
  77504. readonly LITTLE_PHALANX_PROXIMAL: number;
  77505. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77506. readonly LITTLE_PHALANX_DISTAL: number;
  77507. readonly LITTLE_PHALANX_TIP: number;
  77508. }
  77509. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77510. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77511. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77512. interface XRSession {
  77513. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77514. }
  77515. interface XRFrame {
  77516. featurePointCloud? : Array<number>;
  77517. }
  77518. /**
  77519. * @ignore
  77520. */
  77521. declare module BABYLON.GLTF2.Exporter {
  77522. }
  77523. /**
  77524. * @ignore
  77525. */
  77526. declare module BABYLON.GLTF1 {
  77527. }
  77528. declare module BABYLON.GUI {
  77529. /**
  77530. * Class used to specific a value and its associated unit
  77531. */
  77532. export class ValueAndUnit {
  77533. /** defines the unit to store */
  77534. unit: number;
  77535. /** defines a boolean indicating if the value can be negative */
  77536. negativeValueAllowed: boolean;
  77537. private _value;
  77538. private _originalUnit;
  77539. /**
  77540. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77541. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77542. */
  77543. ignoreAdaptiveScaling: boolean;
  77544. /**
  77545. * Creates a new ValueAndUnit
  77546. * @param value defines the value to store
  77547. * @param unit defines the unit to store
  77548. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77549. */
  77550. constructor(value: number,
  77551. /** defines the unit to store */
  77552. unit?: number,
  77553. /** defines a boolean indicating if the value can be negative */
  77554. negativeValueAllowed?: boolean);
  77555. /** Gets a boolean indicating if the value is a percentage */
  77556. get isPercentage(): boolean;
  77557. /** Gets a boolean indicating if the value is store as pixel */
  77558. get isPixel(): boolean;
  77559. /** Gets direct internal value */
  77560. get internalValue(): number;
  77561. /**
  77562. * Gets value as pixel
  77563. * @param host defines the root host
  77564. * @param refValue defines the reference value for percentages
  77565. * @returns the value as pixel
  77566. */
  77567. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77568. /**
  77569. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77570. * @param value defines the value to store
  77571. * @param unit defines the unit to store
  77572. * @returns the current ValueAndUnit
  77573. */
  77574. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77575. /**
  77576. * Gets the value accordingly to its unit
  77577. * @param host defines the root host
  77578. * @returns the value
  77579. */
  77580. getValue(host: AdvancedDynamicTexture): number;
  77581. /**
  77582. * Gets a string representation of the value
  77583. * @param host defines the root host
  77584. * @param decimals defines an optional number of decimals to display
  77585. * @returns a string
  77586. */
  77587. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77588. /**
  77589. * Store a value parsed from a string
  77590. * @param source defines the source string
  77591. * @returns true if the value was successfully parsed
  77592. */
  77593. fromString(source: string | number): boolean;
  77594. private static _Regex;
  77595. private static _UNITMODE_PERCENTAGE;
  77596. private static _UNITMODE_PIXEL;
  77597. /** UNITMODE_PERCENTAGE */
  77598. static get UNITMODE_PERCENTAGE(): number;
  77599. /** UNITMODE_PIXEL */
  77600. static get UNITMODE_PIXEL(): number;
  77601. }
  77602. }
  77603. declare module BABYLON.GUI {
  77604. /**
  77605. * Define a style used by control to automatically setup properties based on a template.
  77606. * Only support font related properties so far
  77607. */
  77608. export class Style implements BABYLON.IDisposable {
  77609. private _fontFamily;
  77610. private _fontStyle;
  77611. private _fontWeight;
  77612. /** @hidden */
  77613. _host: AdvancedDynamicTexture;
  77614. /** @hidden */
  77615. _fontSize: ValueAndUnit;
  77616. /**
  77617. * BABYLON.Observable raised when the style values are changed
  77618. */
  77619. onChangedObservable: BABYLON.Observable<Style>;
  77620. /**
  77621. * Creates a new style object
  77622. * @param host defines the AdvancedDynamicTexture which hosts this style
  77623. */
  77624. constructor(host: AdvancedDynamicTexture);
  77625. /**
  77626. * Gets or sets the font size
  77627. */
  77628. get fontSize(): string | number;
  77629. set fontSize(value: string | number);
  77630. /**
  77631. * Gets or sets the font family
  77632. */
  77633. get fontFamily(): string;
  77634. set fontFamily(value: string);
  77635. /**
  77636. * Gets or sets the font style
  77637. */
  77638. get fontStyle(): string;
  77639. set fontStyle(value: string);
  77640. /** Gets or sets font weight */
  77641. get fontWeight(): string;
  77642. set fontWeight(value: string);
  77643. /** Dispose all associated resources */
  77644. dispose(): void;
  77645. }
  77646. }
  77647. declare module BABYLON.GUI {
  77648. /**
  77649. * Class used to transport BABYLON.Vector2 information for pointer events
  77650. */
  77651. export class Vector2WithInfo extends BABYLON.Vector2 {
  77652. /** defines the current mouse button index */
  77653. buttonIndex: number;
  77654. /**
  77655. * Creates a new Vector2WithInfo
  77656. * @param source defines the vector2 data to transport
  77657. * @param buttonIndex defines the current mouse button index
  77658. */
  77659. constructor(source: BABYLON.Vector2,
  77660. /** defines the current mouse button index */
  77661. buttonIndex?: number);
  77662. }
  77663. /** Class used to provide 2D matrix features */
  77664. export class Matrix2D {
  77665. /** Gets the internal array of 6 floats used to store matrix data */
  77666. m: Float32Array;
  77667. /**
  77668. * Creates a new matrix
  77669. * @param m00 defines value for (0, 0)
  77670. * @param m01 defines value for (0, 1)
  77671. * @param m10 defines value for (1, 0)
  77672. * @param m11 defines value for (1, 1)
  77673. * @param m20 defines value for (2, 0)
  77674. * @param m21 defines value for (2, 1)
  77675. */
  77676. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  77677. /**
  77678. * Fills the matrix from direct values
  77679. * @param m00 defines value for (0, 0)
  77680. * @param m01 defines value for (0, 1)
  77681. * @param m10 defines value for (1, 0)
  77682. * @param m11 defines value for (1, 1)
  77683. * @param m20 defines value for (2, 0)
  77684. * @param m21 defines value for (2, 1)
  77685. * @returns the current modified matrix
  77686. */
  77687. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  77688. /**
  77689. * Gets matrix determinant
  77690. * @returns the determinant
  77691. */
  77692. determinant(): number;
  77693. /**
  77694. * Inverses the matrix and stores it in a target matrix
  77695. * @param result defines the target matrix
  77696. * @returns the current matrix
  77697. */
  77698. invertToRef(result: Matrix2D): Matrix2D;
  77699. /**
  77700. * Multiplies the current matrix with another one
  77701. * @param other defines the second operand
  77702. * @param result defines the target matrix
  77703. * @returns the current matrix
  77704. */
  77705. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  77706. /**
  77707. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  77708. * @param x defines the x coordinate to transform
  77709. * @param y defines the x coordinate to transform
  77710. * @param result defines the target vector2
  77711. * @returns the current matrix
  77712. */
  77713. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  77714. /**
  77715. * Creates an identity matrix
  77716. * @returns a new matrix
  77717. */
  77718. static Identity(): Matrix2D;
  77719. /**
  77720. * Creates a translation matrix and stores it in a target matrix
  77721. * @param x defines the x coordinate of the translation
  77722. * @param y defines the y coordinate of the translation
  77723. * @param result defines the target matrix
  77724. */
  77725. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  77726. /**
  77727. * Creates a scaling matrix and stores it in a target matrix
  77728. * @param x defines the x coordinate of the scaling
  77729. * @param y defines the y coordinate of the scaling
  77730. * @param result defines the target matrix
  77731. */
  77732. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  77733. /**
  77734. * Creates a rotation matrix and stores it in a target matrix
  77735. * @param angle defines the rotation angle
  77736. * @param result defines the target matrix
  77737. */
  77738. static RotationToRef(angle: number, result: Matrix2D): void;
  77739. private static _TempPreTranslationMatrix;
  77740. private static _TempPostTranslationMatrix;
  77741. private static _TempRotationMatrix;
  77742. private static _TempScalingMatrix;
  77743. private static _TempCompose0;
  77744. private static _TempCompose1;
  77745. private static _TempCompose2;
  77746. /**
  77747. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77748. * @param tx defines the x coordinate of the translation
  77749. * @param ty defines the y coordinate of the translation
  77750. * @param angle defines the rotation angle
  77751. * @param scaleX defines the x coordinate of the scaling
  77752. * @param scaleY defines the y coordinate of the scaling
  77753. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  77754. * @param result defines the target matrix
  77755. */
  77756. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  77757. }
  77758. }
  77759. declare module BABYLON.GUI {
  77760. /**
  77761. * Class used to store 2D control sizes
  77762. */
  77763. export class Measure {
  77764. /** defines left coordinate */
  77765. left: number;
  77766. /** defines top coordinate */
  77767. top: number;
  77768. /** defines width dimension */
  77769. width: number;
  77770. /** defines height dimension */
  77771. height: number;
  77772. /**
  77773. * Creates a new measure
  77774. * @param left defines left coordinate
  77775. * @param top defines top coordinate
  77776. * @param width defines width dimension
  77777. * @param height defines height dimension
  77778. */
  77779. constructor(
  77780. /** defines left coordinate */
  77781. left: number,
  77782. /** defines top coordinate */
  77783. top: number,
  77784. /** defines width dimension */
  77785. width: number,
  77786. /** defines height dimension */
  77787. height: number);
  77788. /**
  77789. * Copy from another measure
  77790. * @param other defines the other measure to copy from
  77791. */
  77792. copyFrom(other: Measure): void;
  77793. /**
  77794. * Copy from a group of 4 floats
  77795. * @param left defines left coordinate
  77796. * @param top defines top coordinate
  77797. * @param width defines width dimension
  77798. * @param height defines height dimension
  77799. */
  77800. copyFromFloats(left: number, top: number, width: number, height: number): void;
  77801. /**
  77802. * Computes the axis aligned bounding box measure for two given measures
  77803. * @param a Input measure
  77804. * @param b Input measure
  77805. * @param result the resulting bounding measure
  77806. */
  77807. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  77808. /**
  77809. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77810. * @param transform the matrix to transform the measure before computing the AABB
  77811. * @param addX number to add to left
  77812. * @param addY number to add to top
  77813. * @param addWidth number to add to width
  77814. * @param addHeight number to add to height
  77815. * @param result the resulting AABB
  77816. */
  77817. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  77818. /**
  77819. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77820. * @param transform the matrix to transform the measure before computing the AABB
  77821. * @param result the resulting AABB
  77822. */
  77823. transformToRef(transform: Matrix2D, result: Measure): void;
  77824. /**
  77825. * Check equality between this measure and another one
  77826. * @param other defines the other measures
  77827. * @returns true if both measures are equals
  77828. */
  77829. isEqualsTo(other: Measure): boolean;
  77830. /**
  77831. * Creates an empty measure
  77832. * @returns a new measure
  77833. */
  77834. static Empty(): Measure;
  77835. }
  77836. }
  77837. declare module BABYLON.GUI {
  77838. /**
  77839. * Interface used to define a control that can receive focus
  77840. */
  77841. export interface IFocusableControl {
  77842. /**
  77843. * Function called when the control receives the focus
  77844. */
  77845. onFocus(): void;
  77846. /**
  77847. * Function called when the control loses the focus
  77848. */
  77849. onBlur(): void;
  77850. /**
  77851. * Function called to let the control handle keyboard events
  77852. * @param evt defines the current keyboard event
  77853. */
  77854. processKeyboard(evt: KeyboardEvent): void;
  77855. /**
  77856. * Function called to get the list of controls that should not steal the focus from this control
  77857. * @returns an array of controls
  77858. */
  77859. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77860. }
  77861. /**
  77862. * Class used to create texture to support 2D GUI elements
  77863. * @see https://doc.babylonjs.com/how_to/gui
  77864. */
  77865. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  77866. private _isDirty;
  77867. private _renderObserver;
  77868. private _resizeObserver;
  77869. private _preKeyboardObserver;
  77870. private _pointerMoveObserver;
  77871. private _pointerObserver;
  77872. private _canvasPointerOutObserver;
  77873. private _canvasBlurObserver;
  77874. private _background;
  77875. /** @hidden */
  77876. _rootContainer: Container;
  77877. /** @hidden */
  77878. _lastPickedControl: Control;
  77879. /** @hidden */
  77880. _lastControlOver: {
  77881. [pointerId: number]: Control;
  77882. };
  77883. /** @hidden */
  77884. _lastControlDown: {
  77885. [pointerId: number]: Control;
  77886. };
  77887. /** @hidden */
  77888. _capturingControl: {
  77889. [pointerId: number]: Control;
  77890. };
  77891. /** @hidden */
  77892. _shouldBlockPointer: boolean;
  77893. /** @hidden */
  77894. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  77895. /** @hidden */
  77896. _linkedControls: Control[];
  77897. private _isFullscreen;
  77898. private _fullscreenViewport;
  77899. private _idealWidth;
  77900. private _idealHeight;
  77901. private _useSmallestIdeal;
  77902. private _renderAtIdealSize;
  77903. private _focusedControl;
  77904. private _blockNextFocusCheck;
  77905. private _renderScale;
  77906. private _rootElement;
  77907. private _cursorChanged;
  77908. private _defaultMousePointerId;
  77909. /** @hidden */
  77910. _numLayoutCalls: number;
  77911. /** Gets the number of layout calls made the last time the ADT has been rendered */
  77912. get numLayoutCalls(): number;
  77913. /** @hidden */
  77914. _numRenderCalls: number;
  77915. /** Gets the number of render calls made the last time the ADT has been rendered */
  77916. get numRenderCalls(): number;
  77917. /**
  77918. * Define type to string to ensure compatibility across browsers
  77919. * Safari doesn't support DataTransfer constructor
  77920. */
  77921. private _clipboardData;
  77922. /**
  77923. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77924. */
  77925. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77926. /**
  77927. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77928. */
  77929. onControlPickedObservable: BABYLON.Observable<Control>;
  77930. /**
  77931. * BABYLON.Observable event triggered before layout is evaluated
  77932. */
  77933. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77934. /**
  77935. * BABYLON.Observable event triggered after the layout was evaluated
  77936. */
  77937. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77938. /**
  77939. * BABYLON.Observable event triggered before the texture is rendered
  77940. */
  77941. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77942. /**
  77943. * BABYLON.Observable event triggered after the texture was rendered
  77944. */
  77945. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77946. /**
  77947. * Gets or sets a boolean defining if alpha is stored as premultiplied
  77948. */
  77949. premulAlpha: boolean;
  77950. /**
  77951. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  77952. * Useful when you want more antialiasing
  77953. */
  77954. get renderScale(): number;
  77955. set renderScale(value: number);
  77956. /** Gets or sets the background color */
  77957. get background(): string;
  77958. set background(value: string);
  77959. /**
  77960. * Gets or sets the ideal width used to design controls.
  77961. * The GUI will then rescale everything accordingly
  77962. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77963. */
  77964. get idealWidth(): number;
  77965. set idealWidth(value: number);
  77966. /**
  77967. * Gets or sets the ideal height used to design controls.
  77968. * The GUI will then rescale everything accordingly
  77969. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77970. */
  77971. get idealHeight(): number;
  77972. set idealHeight(value: number);
  77973. /**
  77974. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  77975. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77976. */
  77977. get useSmallestIdeal(): boolean;
  77978. set useSmallestIdeal(value: boolean);
  77979. /**
  77980. * Gets or sets a boolean indicating if adaptive scaling must be used
  77981. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77982. */
  77983. get renderAtIdealSize(): boolean;
  77984. set renderAtIdealSize(value: boolean);
  77985. /**
  77986. * Gets the ratio used when in "ideal mode"
  77987. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77988. * */
  77989. get idealRatio(): number;
  77990. /**
  77991. * Gets the underlying layer used to render the texture when in fullscreen mode
  77992. */
  77993. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  77994. /**
  77995. * Gets the root container control
  77996. */
  77997. get rootContainer(): Container;
  77998. /**
  77999. * Returns an array containing the root container.
  78000. * This is mostly used to let the Inspector introspects the ADT
  78001. * @returns an array containing the rootContainer
  78002. */
  78003. getChildren(): Array<Container>;
  78004. /**
  78005. * Will return all controls that are inside this texture
  78006. * @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
  78007. * @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
  78008. * @return all child controls
  78009. */
  78010. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78011. /**
  78012. * Gets or sets the current focused control
  78013. */
  78014. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  78015. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  78016. /**
  78017. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  78018. */
  78019. get isForeground(): boolean;
  78020. set isForeground(value: boolean);
  78021. /**
  78022. * Gets or set information about clipboardData
  78023. */
  78024. get clipboardData(): string;
  78025. set clipboardData(value: string);
  78026. /**
  78027. * Creates a new AdvancedDynamicTexture
  78028. * @param name defines the name of the texture
  78029. * @param width defines the width of the texture
  78030. * @param height defines the height of the texture
  78031. * @param scene defines the hosting scene
  78032. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  78033. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78034. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78035. */
  78036. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  78037. /**
  78038. * Get the current class name of the texture useful for serialization or dynamic coding.
  78039. * @returns "AdvancedDynamicTexture"
  78040. */
  78041. getClassName(): string;
  78042. /**
  78043. * Function used to execute a function on all controls
  78044. * @param func defines the function to execute
  78045. * @param container defines the container where controls belong. If null the root container will be used
  78046. */
  78047. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  78048. private _useInvalidateRectOptimization;
  78049. /**
  78050. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  78051. */
  78052. get useInvalidateRectOptimization(): boolean;
  78053. set useInvalidateRectOptimization(value: boolean);
  78054. private _invalidatedRectangle;
  78055. /**
  78056. * Invalidates a rectangle area on the gui texture
  78057. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  78058. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  78059. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  78060. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  78061. */
  78062. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  78063. /**
  78064. * Marks the texture as dirty forcing a complete update
  78065. */
  78066. markAsDirty(): void;
  78067. /**
  78068. * Helper function used to create a new style
  78069. * @returns a new style
  78070. * @see https://doc.babylonjs.com/how_to/gui#styles
  78071. */
  78072. createStyle(): Style;
  78073. /**
  78074. * Adds a new control to the root container
  78075. * @param control defines the control to add
  78076. * @returns the current texture
  78077. */
  78078. addControl(control: Control): AdvancedDynamicTexture;
  78079. /**
  78080. * Removes a control from the root container
  78081. * @param control defines the control to remove
  78082. * @returns the current texture
  78083. */
  78084. removeControl(control: Control): AdvancedDynamicTexture;
  78085. /**
  78086. * Release all resources
  78087. */
  78088. dispose(): void;
  78089. private _onResize;
  78090. /** @hidden */
  78091. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  78092. /**
  78093. * Get screen coordinates for a vector3
  78094. * @param position defines the position to project
  78095. * @param worldMatrix defines the world matrix to use
  78096. * @returns the projected position
  78097. */
  78098. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  78099. private _checkUpdate;
  78100. private _clearMeasure;
  78101. private _render;
  78102. /** @hidden */
  78103. _changeCursor(cursor: string): void;
  78104. /** @hidden */
  78105. _registerLastControlDown(control: Control, pointerId: number): void;
  78106. private _doPicking;
  78107. /** @hidden */
  78108. _cleanControlAfterRemovalFromList(list: {
  78109. [pointerId: number]: Control;
  78110. }, control: Control): void;
  78111. /** @hidden */
  78112. _cleanControlAfterRemoval(control: Control): void;
  78113. /** Attach to all scene events required to support pointer events */
  78114. attach(): void;
  78115. /** @hidden */
  78116. private onClipboardCopy;
  78117. /** @hidden */
  78118. private onClipboardCut;
  78119. /** @hidden */
  78120. private onClipboardPaste;
  78121. /**
  78122. * Register the clipboard Events onto the canvas
  78123. */
  78124. registerClipboardEvents(): void;
  78125. /**
  78126. * Unregister the clipboard Events from the canvas
  78127. */
  78128. unRegisterClipboardEvents(): void;
  78129. /**
  78130. * Connect the texture to a hosting mesh to enable interactions
  78131. * @param mesh defines the mesh to attach to
  78132. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78133. */
  78134. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78135. /**
  78136. * Move the focus to a specific control
  78137. * @param control defines the control which will receive the focus
  78138. */
  78139. moveFocusToControl(control: IFocusableControl): void;
  78140. private _manageFocus;
  78141. private _attachToOnPointerOut;
  78142. private _attachToOnBlur;
  78143. /**
  78144. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78145. * @param mesh defines the mesh which will receive the texture
  78146. * @param width defines the texture width (1024 by default)
  78147. * @param height defines the texture height (1024 by default)
  78148. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78149. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78150. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78151. * @returns a new AdvancedDynamicTexture
  78152. */
  78153. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78154. /**
  78155. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78156. * In this mode the texture will rely on a layer for its rendering.
  78157. * This allows it to be treated like any other layer.
  78158. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78159. * LayerMask is set through advancedTexture.layer.layerMask
  78160. * @param name defines name for the texture
  78161. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78162. * @param scene defines the hsoting scene
  78163. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78164. * @returns a new AdvancedDynamicTexture
  78165. */
  78166. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78167. }
  78168. }
  78169. declare module BABYLON.GUI {
  78170. /**
  78171. * Root class used for all 2D controls
  78172. * @see https://doc.babylonjs.com/how_to/gui#controls
  78173. */
  78174. export class Control {
  78175. /** defines the name of the control */
  78176. name?: string | undefined;
  78177. /**
  78178. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78179. */
  78180. static AllowAlphaInheritance: boolean;
  78181. private _alpha;
  78182. private _alphaSet;
  78183. private _zIndex;
  78184. /** @hidden */
  78185. _host: AdvancedDynamicTexture;
  78186. /** Gets or sets the control parent */
  78187. parent: BABYLON.Nullable<Container>;
  78188. /** @hidden */
  78189. _currentMeasure: Measure;
  78190. private _fontFamily;
  78191. private _fontStyle;
  78192. private _fontWeight;
  78193. private _fontSize;
  78194. private _font;
  78195. /** @hidden */
  78196. _width: ValueAndUnit;
  78197. /** @hidden */
  78198. _height: ValueAndUnit;
  78199. /** @hidden */
  78200. protected _fontOffset: {
  78201. ascent: number;
  78202. height: number;
  78203. descent: number;
  78204. };
  78205. private _color;
  78206. private _style;
  78207. private _styleObserver;
  78208. /** @hidden */
  78209. protected _horizontalAlignment: number;
  78210. /** @hidden */
  78211. protected _verticalAlignment: number;
  78212. /** @hidden */
  78213. protected _isDirty: boolean;
  78214. /** @hidden */
  78215. protected _wasDirty: boolean;
  78216. /** @hidden */
  78217. _tempParentMeasure: Measure;
  78218. /** @hidden */
  78219. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78220. /** @hidden */
  78221. protected _cachedParentMeasure: Measure;
  78222. private _paddingLeft;
  78223. private _paddingRight;
  78224. private _paddingTop;
  78225. private _paddingBottom;
  78226. /** @hidden */
  78227. _left: ValueAndUnit;
  78228. /** @hidden */
  78229. _top: ValueAndUnit;
  78230. private _scaleX;
  78231. private _scaleY;
  78232. private _rotation;
  78233. private _transformCenterX;
  78234. private _transformCenterY;
  78235. /** @hidden */
  78236. _transformMatrix: Matrix2D;
  78237. /** @hidden */
  78238. protected _invertTransformMatrix: Matrix2D;
  78239. /** @hidden */
  78240. protected _transformedPosition: BABYLON.Vector2;
  78241. private _isMatrixDirty;
  78242. private _cachedOffsetX;
  78243. private _cachedOffsetY;
  78244. private _isVisible;
  78245. private _isHighlighted;
  78246. /** @hidden */
  78247. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78248. private _fontSet;
  78249. private _dummyVector2;
  78250. private _downCount;
  78251. private _enterCount;
  78252. private _doNotRender;
  78253. private _downPointerIds;
  78254. protected _isEnabled: boolean;
  78255. protected _disabledColor: string;
  78256. protected _disabledColorItem: string;
  78257. /** @hidden */
  78258. protected _rebuildLayout: boolean;
  78259. /** @hidden */
  78260. _customData: any;
  78261. /** @hidden */
  78262. _isClipped: boolean;
  78263. /** @hidden */
  78264. _automaticSize: boolean;
  78265. /** @hidden */
  78266. _tag: any;
  78267. /**
  78268. * 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
  78269. */
  78270. uniqueId: number;
  78271. /**
  78272. * Gets or sets an object used to store user defined information for the node
  78273. */
  78274. metadata: any;
  78275. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78276. isHitTestVisible: boolean;
  78277. /** Gets or sets a boolean indicating if the control can block pointer events */
  78278. isPointerBlocker: boolean;
  78279. /** Gets or sets a boolean indicating if the control can be focusable */
  78280. isFocusInvisible: boolean;
  78281. /**
  78282. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78283. * 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
  78284. */
  78285. clipChildren: boolean;
  78286. /**
  78287. * Gets or sets a boolean indicating that control content must be clipped
  78288. * 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
  78289. */
  78290. clipContent: boolean;
  78291. /**
  78292. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78293. */
  78294. useBitmapCache: boolean;
  78295. private _cacheData;
  78296. private _shadowOffsetX;
  78297. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78298. get shadowOffsetX(): number;
  78299. set shadowOffsetX(value: number);
  78300. private _shadowOffsetY;
  78301. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78302. get shadowOffsetY(): number;
  78303. set shadowOffsetY(value: number);
  78304. private _shadowBlur;
  78305. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78306. get shadowBlur(): number;
  78307. set shadowBlur(value: number);
  78308. private _shadowColor;
  78309. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78310. get shadowColor(): string;
  78311. set shadowColor(value: string);
  78312. /** Gets or sets the cursor to use when the control is hovered */
  78313. hoverCursor: string;
  78314. /** @hidden */
  78315. protected _linkOffsetX: ValueAndUnit;
  78316. /** @hidden */
  78317. protected _linkOffsetY: ValueAndUnit;
  78318. /** Gets the control type name */
  78319. get typeName(): string;
  78320. /**
  78321. * Get the current class name of the control.
  78322. * @returns current class name
  78323. */
  78324. getClassName(): string;
  78325. /**
  78326. * An event triggered when pointer wheel is scrolled
  78327. */
  78328. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78329. /**
  78330. * An event triggered when the pointer move over the control.
  78331. */
  78332. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78333. /**
  78334. * An event triggered when the pointer move out of the control.
  78335. */
  78336. onPointerOutObservable: BABYLON.Observable<Control>;
  78337. /**
  78338. * An event triggered when the pointer taps the control
  78339. */
  78340. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78341. /**
  78342. * An event triggered when pointer up
  78343. */
  78344. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78345. /**
  78346. * An event triggered when a control is clicked on
  78347. */
  78348. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78349. /**
  78350. * An event triggered when pointer enters the control
  78351. */
  78352. onPointerEnterObservable: BABYLON.Observable<Control>;
  78353. /**
  78354. * An event triggered when the control is marked as dirty
  78355. */
  78356. onDirtyObservable: BABYLON.Observable<Control>;
  78357. /**
  78358. * An event triggered before drawing the control
  78359. */
  78360. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78361. /**
  78362. * An event triggered after the control was drawn
  78363. */
  78364. onAfterDrawObservable: BABYLON.Observable<Control>;
  78365. /**
  78366. * An event triggered when the control has been disposed
  78367. */
  78368. onDisposeObservable: BABYLON.Observable<Control>;
  78369. /**
  78370. * Get the hosting AdvancedDynamicTexture
  78371. */
  78372. get host(): AdvancedDynamicTexture;
  78373. /** Gets or set information about font offsets (used to render and align text) */
  78374. get fontOffset(): {
  78375. ascent: number;
  78376. height: number;
  78377. descent: number;
  78378. };
  78379. set fontOffset(offset: {
  78380. ascent: number;
  78381. height: number;
  78382. descent: number;
  78383. });
  78384. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78385. get alpha(): number;
  78386. set alpha(value: number);
  78387. /**
  78388. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78389. */
  78390. get isHighlighted(): boolean;
  78391. set isHighlighted(value: boolean);
  78392. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78393. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78394. */
  78395. get scaleX(): number;
  78396. set scaleX(value: number);
  78397. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78398. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78399. */
  78400. get scaleY(): number;
  78401. set scaleY(value: number);
  78402. /** Gets or sets the rotation angle (0 by default)
  78403. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78404. */
  78405. get rotation(): number;
  78406. set rotation(value: number);
  78407. /** Gets or sets the transformation center on Y axis (0 by default)
  78408. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78409. */
  78410. get transformCenterY(): number;
  78411. set transformCenterY(value: number);
  78412. /** Gets or sets the transformation center on X axis (0 by default)
  78413. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78414. */
  78415. get transformCenterX(): number;
  78416. set transformCenterX(value: number);
  78417. /**
  78418. * Gets or sets the horizontal alignment
  78419. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78420. */
  78421. get horizontalAlignment(): number;
  78422. set horizontalAlignment(value: number);
  78423. /**
  78424. * Gets or sets the vertical alignment
  78425. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78426. */
  78427. get verticalAlignment(): number;
  78428. set verticalAlignment(value: number);
  78429. /**
  78430. * Gets or sets a fixed ratio for this control.
  78431. * When different from 0, the ratio is used to compute the "second" dimension.
  78432. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78433. * second dimension is computed as first dimension * fixedRatio
  78434. */
  78435. fixedRatio: number;
  78436. private _fixedRatioMasterIsWidth;
  78437. /**
  78438. * Gets or sets control width
  78439. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78440. */
  78441. get width(): string | number;
  78442. set width(value: string | number);
  78443. /**
  78444. * Gets or sets the control width in pixel
  78445. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78446. */
  78447. get widthInPixels(): number;
  78448. set widthInPixels(value: number);
  78449. /**
  78450. * Gets or sets control height
  78451. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78452. */
  78453. get height(): string | number;
  78454. set height(value: string | number);
  78455. /**
  78456. * Gets or sets control height in pixel
  78457. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78458. */
  78459. get heightInPixels(): number;
  78460. set heightInPixels(value: number);
  78461. /** Gets or set font family */
  78462. get fontFamily(): string;
  78463. set fontFamily(value: string);
  78464. /** Gets or sets font style */
  78465. get fontStyle(): string;
  78466. set fontStyle(value: string);
  78467. /** Gets or sets font weight */
  78468. get fontWeight(): string;
  78469. set fontWeight(value: string);
  78470. /**
  78471. * Gets or sets style
  78472. * @see https://doc.babylonjs.com/how_to/gui#styles
  78473. */
  78474. get style(): BABYLON.Nullable<Style>;
  78475. set style(value: BABYLON.Nullable<Style>);
  78476. /** @hidden */
  78477. get _isFontSizeInPercentage(): boolean;
  78478. /** Gets or sets font size in pixels */
  78479. get fontSizeInPixels(): number;
  78480. set fontSizeInPixels(value: number);
  78481. /** Gets or sets font size */
  78482. get fontSize(): string | number;
  78483. set fontSize(value: string | number);
  78484. /** Gets or sets foreground color */
  78485. get color(): string;
  78486. set color(value: string);
  78487. /** Gets or sets z index which is used to reorder controls on the z axis */
  78488. get zIndex(): number;
  78489. set zIndex(value: number);
  78490. /** Gets or sets a boolean indicating if the control can be rendered */
  78491. get notRenderable(): boolean;
  78492. set notRenderable(value: boolean);
  78493. /** Gets or sets a boolean indicating if the control is visible */
  78494. get isVisible(): boolean;
  78495. set isVisible(value: boolean);
  78496. /** Gets a boolean indicating that the control needs to update its rendering */
  78497. get isDirty(): boolean;
  78498. /**
  78499. * Gets the current linked mesh (or null if none)
  78500. */
  78501. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  78502. /**
  78503. * Gets or sets a value indicating the padding to use on the left of the control
  78504. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78505. */
  78506. get paddingLeft(): string | number;
  78507. set paddingLeft(value: string | number);
  78508. /**
  78509. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78510. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78511. */
  78512. get paddingLeftInPixels(): number;
  78513. set paddingLeftInPixels(value: number);
  78514. /**
  78515. * Gets or sets a value indicating the padding to use on the right of the control
  78516. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78517. */
  78518. get paddingRight(): string | number;
  78519. set paddingRight(value: string | number);
  78520. /**
  78521. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78522. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78523. */
  78524. get paddingRightInPixels(): number;
  78525. set paddingRightInPixels(value: number);
  78526. /**
  78527. * Gets or sets a value indicating the padding to use on the top of the control
  78528. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78529. */
  78530. get paddingTop(): string | number;
  78531. set paddingTop(value: string | number);
  78532. /**
  78533. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78534. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78535. */
  78536. get paddingTopInPixels(): number;
  78537. set paddingTopInPixels(value: number);
  78538. /**
  78539. * Gets or sets a value indicating the padding to use on the bottom of the control
  78540. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78541. */
  78542. get paddingBottom(): string | number;
  78543. set paddingBottom(value: string | number);
  78544. /**
  78545. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78546. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78547. */
  78548. get paddingBottomInPixels(): number;
  78549. set paddingBottomInPixels(value: number);
  78550. /**
  78551. * Gets or sets a value indicating the left coordinate of the control
  78552. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78553. */
  78554. get left(): string | number;
  78555. set left(value: string | number);
  78556. /**
  78557. * Gets or sets a value indicating the left coordinate in pixels of the control
  78558. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78559. */
  78560. get leftInPixels(): number;
  78561. set leftInPixels(value: number);
  78562. /**
  78563. * Gets or sets a value indicating the top coordinate of the control
  78564. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78565. */
  78566. get top(): string | number;
  78567. set top(value: string | number);
  78568. /**
  78569. * Gets or sets a value indicating the top coordinate in pixels of the control
  78570. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78571. */
  78572. get topInPixels(): number;
  78573. set topInPixels(value: number);
  78574. /**
  78575. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78576. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78577. */
  78578. get linkOffsetX(): string | number;
  78579. set linkOffsetX(value: string | number);
  78580. /**
  78581. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78582. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78583. */
  78584. get linkOffsetXInPixels(): number;
  78585. set linkOffsetXInPixels(value: number);
  78586. /**
  78587. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78588. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78589. */
  78590. get linkOffsetY(): string | number;
  78591. set linkOffsetY(value: string | number);
  78592. /**
  78593. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78594. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78595. */
  78596. get linkOffsetYInPixels(): number;
  78597. set linkOffsetYInPixels(value: number);
  78598. /** Gets the center coordinate on X axis */
  78599. get centerX(): number;
  78600. /** Gets the center coordinate on Y axis */
  78601. get centerY(): number;
  78602. /** Gets or sets if control is Enabled*/
  78603. get isEnabled(): boolean;
  78604. set isEnabled(value: boolean);
  78605. /** Gets or sets background color of control if it's disabled*/
  78606. get disabledColor(): string;
  78607. set disabledColor(value: string);
  78608. /** Gets or sets front color of control if it's disabled*/
  78609. get disabledColorItem(): string;
  78610. set disabledColorItem(value: string);
  78611. /**
  78612. * Creates a new control
  78613. * @param name defines the name of the control
  78614. */
  78615. constructor(
  78616. /** defines the name of the control */
  78617. name?: string | undefined);
  78618. /** @hidden */
  78619. protected _getTypeName(): string;
  78620. /**
  78621. * Gets the first ascendant in the hierarchy of the given type
  78622. * @param className defines the required type
  78623. * @returns the ascendant or null if not found
  78624. */
  78625. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78626. /** @hidden */
  78627. _resetFontCache(): void;
  78628. /**
  78629. * Determines if a container is an ascendant of the current control
  78630. * @param container defines the container to look for
  78631. * @returns true if the container is one of the ascendant of the control
  78632. */
  78633. isAscendant(container: Control): boolean;
  78634. /**
  78635. * Gets coordinates in local control space
  78636. * @param globalCoordinates defines the coordinates to transform
  78637. * @returns the new coordinates in local space
  78638. */
  78639. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78640. /**
  78641. * Gets coordinates in local control space
  78642. * @param globalCoordinates defines the coordinates to transform
  78643. * @param result defines the target vector2 where to store the result
  78644. * @returns the current control
  78645. */
  78646. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  78647. /**
  78648. * Gets coordinates in parent local control space
  78649. * @param globalCoordinates defines the coordinates to transform
  78650. * @returns the new coordinates in parent local space
  78651. */
  78652. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78653. /**
  78654. * Move the current control to a vector3 position projected onto the screen.
  78655. * @param position defines the target position
  78656. * @param scene defines the hosting scene
  78657. */
  78658. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  78659. /**
  78660. * Will store all controls that have this control as ascendant in a given array
  78661. * @param results defines the array where to store the descendants
  78662. * @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
  78663. * @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
  78664. */
  78665. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78666. /**
  78667. * Will return all controls that have this control as ascendant
  78668. * @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
  78669. * @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
  78670. * @return all child controls
  78671. */
  78672. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78673. /**
  78674. * Link current control with a target mesh
  78675. * @param mesh defines the mesh to link with
  78676. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78677. */
  78678. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  78679. /** @hidden */
  78680. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  78681. /** @hidden */
  78682. _offsetLeft(offset: number): void;
  78683. /** @hidden */
  78684. _offsetTop(offset: number): void;
  78685. /** @hidden */
  78686. _markMatrixAsDirty(): void;
  78687. /** @hidden */
  78688. _flagDescendantsAsMatrixDirty(): void;
  78689. /** @hidden */
  78690. _intersectsRect(rect: Measure): boolean;
  78691. /** @hidden */
  78692. protected invalidateRect(): void;
  78693. /** @hidden */
  78694. _markAsDirty(force?: boolean): void;
  78695. /** @hidden */
  78696. _markAllAsDirty(): void;
  78697. /** @hidden */
  78698. _link(host: AdvancedDynamicTexture): void;
  78699. /** @hidden */
  78700. protected _transform(context?: CanvasRenderingContext2D): void;
  78701. /** @hidden */
  78702. _renderHighlight(context: CanvasRenderingContext2D): void;
  78703. /** @hidden */
  78704. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78705. /** @hidden */
  78706. protected _applyStates(context: CanvasRenderingContext2D): void;
  78707. /** @hidden */
  78708. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78709. /** @hidden */
  78710. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78711. protected _evaluateClippingState(parentMeasure: Measure): void;
  78712. /** @hidden */
  78713. _measure(): void;
  78714. /** @hidden */
  78715. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78716. /** @hidden */
  78717. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78718. /** @hidden */
  78719. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78720. /** @hidden */
  78721. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78722. private static _ClipMeasure;
  78723. private _tmpMeasureA;
  78724. private _clip;
  78725. /** @hidden */
  78726. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  78727. /** @hidden */
  78728. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78729. /**
  78730. * Tests if a given coordinates belong to the current control
  78731. * @param x defines x coordinate to test
  78732. * @param y defines y coordinate to test
  78733. * @returns true if the coordinates are inside the control
  78734. */
  78735. contains(x: number, y: number): boolean;
  78736. /** @hidden */
  78737. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78738. /** @hidden */
  78739. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  78740. /** @hidden */
  78741. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78742. /** @hidden */
  78743. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  78744. /** @hidden */
  78745. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78746. /** @hidden */
  78747. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  78748. /** @hidden */
  78749. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78750. /** @hidden */
  78751. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  78752. /** @hidden */
  78753. _onCanvasBlur(): void;
  78754. /** @hidden */
  78755. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78756. private _prepareFont;
  78757. /** Releases associated resources */
  78758. dispose(): void;
  78759. private static _HORIZONTAL_ALIGNMENT_LEFT;
  78760. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  78761. private static _HORIZONTAL_ALIGNMENT_CENTER;
  78762. private static _VERTICAL_ALIGNMENT_TOP;
  78763. private static _VERTICAL_ALIGNMENT_BOTTOM;
  78764. private static _VERTICAL_ALIGNMENT_CENTER;
  78765. /** HORIZONTAL_ALIGNMENT_LEFT */
  78766. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  78767. /** HORIZONTAL_ALIGNMENT_RIGHT */
  78768. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  78769. /** HORIZONTAL_ALIGNMENT_CENTER */
  78770. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  78771. /** VERTICAL_ALIGNMENT_TOP */
  78772. static get VERTICAL_ALIGNMENT_TOP(): number;
  78773. /** VERTICAL_ALIGNMENT_BOTTOM */
  78774. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  78775. /** VERTICAL_ALIGNMENT_CENTER */
  78776. static get VERTICAL_ALIGNMENT_CENTER(): number;
  78777. private static _FontHeightSizes;
  78778. /** @hidden */
  78779. static _GetFontOffset(font: string): {
  78780. ascent: number;
  78781. height: number;
  78782. descent: number;
  78783. };
  78784. /**
  78785. * Creates a stack panel that can be used to render headers
  78786. * @param control defines the control to associate with the header
  78787. * @param text defines the text of the header
  78788. * @param size defines the size of the header
  78789. * @param options defines options used to configure the header
  78790. * @returns a new StackPanel
  78791. * @ignore
  78792. * @hidden
  78793. */
  78794. static AddHeader: (control: Control, text: string, size: string | number, options: {
  78795. isHorizontal: boolean;
  78796. controlFirst: boolean;
  78797. }) => any;
  78798. /** @hidden */
  78799. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  78800. }
  78801. }
  78802. declare module BABYLON.GUI {
  78803. /**
  78804. * Root class for 2D containers
  78805. * @see https://doc.babylonjs.com/how_to/gui#containers
  78806. */
  78807. export class Container extends Control {
  78808. name?: string | undefined;
  78809. /** @hidden */
  78810. _children: Control[];
  78811. /** @hidden */
  78812. protected _measureForChildren: Measure;
  78813. /** @hidden */
  78814. protected _background: string;
  78815. /** @hidden */
  78816. protected _adaptWidthToChildren: boolean;
  78817. /** @hidden */
  78818. protected _adaptHeightToChildren: boolean;
  78819. /**
  78820. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  78821. */
  78822. logLayoutCycleErrors: boolean;
  78823. /**
  78824. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  78825. */
  78826. maxLayoutCycle: number;
  78827. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  78828. get adaptHeightToChildren(): boolean;
  78829. set adaptHeightToChildren(value: boolean);
  78830. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  78831. get adaptWidthToChildren(): boolean;
  78832. set adaptWidthToChildren(value: boolean);
  78833. /** Gets or sets background color */
  78834. get background(): string;
  78835. set background(value: string);
  78836. /** Gets the list of children */
  78837. get children(): Control[];
  78838. /**
  78839. * Creates a new Container
  78840. * @param name defines the name of the container
  78841. */
  78842. constructor(name?: string | undefined);
  78843. protected _getTypeName(): string;
  78844. _flagDescendantsAsMatrixDirty(): void;
  78845. /**
  78846. * Gets a child using its name
  78847. * @param name defines the child name to look for
  78848. * @returns the child control if found
  78849. */
  78850. getChildByName(name: string): BABYLON.Nullable<Control>;
  78851. /**
  78852. * Gets a child using its type and its name
  78853. * @param name defines the child name to look for
  78854. * @param type defines the child type to look for
  78855. * @returns the child control if found
  78856. */
  78857. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  78858. /**
  78859. * Search for a specific control in children
  78860. * @param control defines the control to look for
  78861. * @returns true if the control is in child list
  78862. */
  78863. containsControl(control: Control): boolean;
  78864. /**
  78865. * Adds a new control to the current container
  78866. * @param control defines the control to add
  78867. * @returns the current container
  78868. */
  78869. addControl(control: BABYLON.Nullable<Control>): Container;
  78870. /**
  78871. * Removes all controls from the current container
  78872. * @returns the current container
  78873. */
  78874. clearControls(): Container;
  78875. /**
  78876. * Removes a control from the current container
  78877. * @param control defines the control to remove
  78878. * @returns the current container
  78879. */
  78880. removeControl(control: Control): Container;
  78881. /** @hidden */
  78882. _reOrderControl(control: Control): void;
  78883. /** @hidden */
  78884. _offsetLeft(offset: number): void;
  78885. /** @hidden */
  78886. _offsetTop(offset: number): void;
  78887. /** @hidden */
  78888. _markAllAsDirty(): void;
  78889. /** @hidden */
  78890. protected _localDraw(context: CanvasRenderingContext2D): void;
  78891. /** @hidden */
  78892. _link(host: AdvancedDynamicTexture): void;
  78893. /** @hidden */
  78894. protected _beforeLayout(): void;
  78895. /** @hidden */
  78896. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78897. /** @hidden */
  78898. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78899. protected _postMeasure(): void;
  78900. /** @hidden */
  78901. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78902. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78903. /** @hidden */
  78904. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78905. /** @hidden */
  78906. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78907. /** Releases associated resources */
  78908. dispose(): void;
  78909. }
  78910. }
  78911. declare module BABYLON.GUI {
  78912. /** Class used to create rectangle container */
  78913. export class Rectangle extends Container {
  78914. name?: string | undefined;
  78915. private _thickness;
  78916. private _cornerRadius;
  78917. /** Gets or sets border thickness */
  78918. get thickness(): number;
  78919. set thickness(value: number);
  78920. /** Gets or sets the corner radius angle */
  78921. get cornerRadius(): number;
  78922. set cornerRadius(value: number);
  78923. /**
  78924. * Creates a new Rectangle
  78925. * @param name defines the control name
  78926. */
  78927. constructor(name?: string | undefined);
  78928. protected _getTypeName(): string;
  78929. protected _localDraw(context: CanvasRenderingContext2D): void;
  78930. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78931. private _drawRoundedRect;
  78932. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78933. }
  78934. }
  78935. declare module BABYLON.GUI {
  78936. /**
  78937. * Enum that determines the text-wrapping mode to use.
  78938. */
  78939. export enum TextWrapping {
  78940. /**
  78941. * Clip the text when it's larger than Control.width; this is the default mode.
  78942. */
  78943. Clip = 0,
  78944. /**
  78945. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  78946. */
  78947. WordWrap = 1,
  78948. /**
  78949. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  78950. */
  78951. Ellipsis = 2
  78952. }
  78953. /**
  78954. * Class used to create text block control
  78955. */
  78956. export class TextBlock extends Control {
  78957. /**
  78958. * Defines the name of the control
  78959. */
  78960. name?: string | undefined;
  78961. private _text;
  78962. private _textWrapping;
  78963. private _textHorizontalAlignment;
  78964. private _textVerticalAlignment;
  78965. private _lines;
  78966. private _resizeToFit;
  78967. private _lineSpacing;
  78968. private _outlineWidth;
  78969. private _outlineColor;
  78970. private _underline;
  78971. private _lineThrough;
  78972. /**
  78973. * An event triggered after the text is changed
  78974. */
  78975. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  78976. /**
  78977. * An event triggered after the text was broken up into lines
  78978. */
  78979. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  78980. /**
  78981. * Function used to split a string into words. By default, a string is split at each space character found
  78982. */
  78983. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  78984. /**
  78985. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  78986. */
  78987. get lines(): any[];
  78988. /**
  78989. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78990. */
  78991. get resizeToFit(): boolean;
  78992. /**
  78993. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78994. */
  78995. set resizeToFit(value: boolean);
  78996. /**
  78997. * Gets or sets a boolean indicating if text must be wrapped
  78998. */
  78999. get textWrapping(): TextWrapping | boolean;
  79000. /**
  79001. * Gets or sets a boolean indicating if text must be wrapped
  79002. */
  79003. set textWrapping(value: TextWrapping | boolean);
  79004. /**
  79005. * Gets or sets text to display
  79006. */
  79007. get text(): string;
  79008. /**
  79009. * Gets or sets text to display
  79010. */
  79011. set text(value: string);
  79012. /**
  79013. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79014. */
  79015. get textHorizontalAlignment(): number;
  79016. /**
  79017. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79018. */
  79019. set textHorizontalAlignment(value: number);
  79020. /**
  79021. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79022. */
  79023. get textVerticalAlignment(): number;
  79024. /**
  79025. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79026. */
  79027. set textVerticalAlignment(value: number);
  79028. /**
  79029. * Gets or sets line spacing value
  79030. */
  79031. set lineSpacing(value: string | number);
  79032. /**
  79033. * Gets or sets line spacing value
  79034. */
  79035. get lineSpacing(): string | number;
  79036. /**
  79037. * Gets or sets outlineWidth of the text to display
  79038. */
  79039. get outlineWidth(): number;
  79040. /**
  79041. * Gets or sets outlineWidth of the text to display
  79042. */
  79043. set outlineWidth(value: number);
  79044. /**
  79045. * Gets or sets a boolean indicating that text must have underline
  79046. */
  79047. get underline(): boolean;
  79048. /**
  79049. * Gets or sets a boolean indicating that text must have underline
  79050. */
  79051. set underline(value: boolean);
  79052. /**
  79053. * Gets or sets an boolean indicating that text must be crossed out
  79054. */
  79055. get lineThrough(): boolean;
  79056. /**
  79057. * Gets or sets an boolean indicating that text must be crossed out
  79058. */
  79059. set lineThrough(value: boolean);
  79060. /**
  79061. * Gets or sets outlineColor of the text to display
  79062. */
  79063. get outlineColor(): string;
  79064. /**
  79065. * Gets or sets outlineColor of the text to display
  79066. */
  79067. set outlineColor(value: string);
  79068. /**
  79069. * Creates a new TextBlock object
  79070. * @param name defines the name of the control
  79071. * @param text defines the text to display (emptry string by default)
  79072. */
  79073. constructor(
  79074. /**
  79075. * Defines the name of the control
  79076. */
  79077. name?: string | undefined, text?: string);
  79078. protected _getTypeName(): string;
  79079. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79080. private _drawText;
  79081. /** @hidden */
  79082. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79083. protected _applyStates(context: CanvasRenderingContext2D): void;
  79084. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  79085. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  79086. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  79087. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  79088. protected _renderLines(context: CanvasRenderingContext2D): void;
  79089. /**
  79090. * Given a width constraint applied on the text block, find the expected height
  79091. * @returns expected height
  79092. */
  79093. computeExpectedHeight(): number;
  79094. dispose(): void;
  79095. }
  79096. }
  79097. declare module BABYLON.GUI {
  79098. /**
  79099. * Class used to create 2D images
  79100. */
  79101. export class Image extends Control {
  79102. name?: string | undefined;
  79103. private _workingCanvas;
  79104. private _domImage;
  79105. private _imageWidth;
  79106. private _imageHeight;
  79107. private _loaded;
  79108. private _stretch;
  79109. private _source;
  79110. private _autoScale;
  79111. private _sourceLeft;
  79112. private _sourceTop;
  79113. private _sourceWidth;
  79114. private _sourceHeight;
  79115. private _svgAttributesComputationCompleted;
  79116. private _isSVG;
  79117. private _cellWidth;
  79118. private _cellHeight;
  79119. private _cellId;
  79120. private _populateNinePatchSlicesFromImage;
  79121. private _sliceLeft;
  79122. private _sliceRight;
  79123. private _sliceTop;
  79124. private _sliceBottom;
  79125. private _detectPointerOnOpaqueOnly;
  79126. private _imageDataCache;
  79127. /**
  79128. * BABYLON.Observable notified when the content is loaded
  79129. */
  79130. onImageLoadedObservable: BABYLON.Observable<Image>;
  79131. /**
  79132. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79133. */
  79134. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79135. /**
  79136. * Gets a boolean indicating that the content is loaded
  79137. */
  79138. get isLoaded(): boolean;
  79139. /**
  79140. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79141. */
  79142. get populateNinePatchSlicesFromImage(): boolean;
  79143. set populateNinePatchSlicesFromImage(value: boolean);
  79144. /**
  79145. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79146. * Beware using this as this will comsume more memory as the image has to be stored twice
  79147. */
  79148. get detectPointerOnOpaqueOnly(): boolean;
  79149. set detectPointerOnOpaqueOnly(value: boolean);
  79150. /**
  79151. * Gets or sets the left value for slicing (9-patch)
  79152. */
  79153. get sliceLeft(): number;
  79154. set sliceLeft(value: number);
  79155. /**
  79156. * Gets or sets the right value for slicing (9-patch)
  79157. */
  79158. get sliceRight(): number;
  79159. set sliceRight(value: number);
  79160. /**
  79161. * Gets or sets the top value for slicing (9-patch)
  79162. */
  79163. get sliceTop(): number;
  79164. set sliceTop(value: number);
  79165. /**
  79166. * Gets or sets the bottom value for slicing (9-patch)
  79167. */
  79168. get sliceBottom(): number;
  79169. set sliceBottom(value: number);
  79170. /**
  79171. * Gets or sets the left coordinate in the source image
  79172. */
  79173. get sourceLeft(): number;
  79174. set sourceLeft(value: number);
  79175. /**
  79176. * Gets or sets the top coordinate in the source image
  79177. */
  79178. get sourceTop(): number;
  79179. set sourceTop(value: number);
  79180. /**
  79181. * Gets or sets the width to capture in the source image
  79182. */
  79183. get sourceWidth(): number;
  79184. set sourceWidth(value: number);
  79185. /**
  79186. * Gets or sets the height to capture in the source image
  79187. */
  79188. get sourceHeight(): number;
  79189. set sourceHeight(value: number);
  79190. /** Indicates if the format of the image is SVG */
  79191. get isSVG(): boolean;
  79192. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79193. get svgAttributesComputationCompleted(): boolean;
  79194. /**
  79195. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79196. * @see https://doc.babylonjs.com/how_to/gui#image
  79197. */
  79198. get autoScale(): boolean;
  79199. set autoScale(value: boolean);
  79200. /** Gets or sets the streching mode used by the image */
  79201. get stretch(): number;
  79202. set stretch(value: number);
  79203. /** @hidden */
  79204. _rotate90(n: number, preserveProperties?: boolean): Image;
  79205. private _handleRotationForSVGImage;
  79206. private _rotate90SourceProperties;
  79207. /**
  79208. * Gets or sets the internal DOM image used to render the control
  79209. */
  79210. set domImage(value: HTMLImageElement);
  79211. get domImage(): HTMLImageElement;
  79212. private _onImageLoaded;
  79213. private _extractNinePatchSliceDataFromImage;
  79214. /**
  79215. * Gets or sets image source url
  79216. */
  79217. set source(value: BABYLON.Nullable<string>);
  79218. /**
  79219. * Checks for svg document with icon id present
  79220. */
  79221. private _svgCheck;
  79222. /**
  79223. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79224. * given external svg file and icon id
  79225. */
  79226. private _getSVGAttribs;
  79227. /**
  79228. * Gets or sets the cell width to use when animation sheet is enabled
  79229. * @see https://doc.babylonjs.com/how_to/gui#image
  79230. */
  79231. get cellWidth(): number;
  79232. set cellWidth(value: number);
  79233. /**
  79234. * Gets or sets the cell height to use when animation sheet is enabled
  79235. * @see https://doc.babylonjs.com/how_to/gui#image
  79236. */
  79237. get cellHeight(): number;
  79238. set cellHeight(value: number);
  79239. /**
  79240. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79241. * @see https://doc.babylonjs.com/how_to/gui#image
  79242. */
  79243. get cellId(): number;
  79244. set cellId(value: number);
  79245. /**
  79246. * Creates a new Image
  79247. * @param name defines the control name
  79248. * @param url defines the image url
  79249. */
  79250. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79251. /**
  79252. * Tests if a given coordinates belong to the current control
  79253. * @param x defines x coordinate to test
  79254. * @param y defines y coordinate to test
  79255. * @returns true if the coordinates are inside the control
  79256. */
  79257. contains(x: number, y: number): boolean;
  79258. protected _getTypeName(): string;
  79259. /** Force the control to synchronize with its content */
  79260. synchronizeSizeWithContent(): void;
  79261. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79262. private _prepareWorkingCanvasForOpaqueDetection;
  79263. private _drawImage;
  79264. _draw(context: CanvasRenderingContext2D): void;
  79265. private _renderCornerPatch;
  79266. private _renderNinePatch;
  79267. dispose(): void;
  79268. /** STRETCH_NONE */
  79269. static readonly STRETCH_NONE: number;
  79270. /** STRETCH_FILL */
  79271. static readonly STRETCH_FILL: number;
  79272. /** STRETCH_UNIFORM */
  79273. static readonly STRETCH_UNIFORM: number;
  79274. /** STRETCH_EXTEND */
  79275. static readonly STRETCH_EXTEND: number;
  79276. /** NINE_PATCH */
  79277. static readonly STRETCH_NINE_PATCH: number;
  79278. }
  79279. }
  79280. declare module BABYLON.GUI {
  79281. /**
  79282. * Class used to create 2D buttons
  79283. */
  79284. export class Button extends Rectangle {
  79285. name?: string | undefined;
  79286. /**
  79287. * Function called to generate a pointer enter animation
  79288. */
  79289. pointerEnterAnimation: () => void;
  79290. /**
  79291. * Function called to generate a pointer out animation
  79292. */
  79293. pointerOutAnimation: () => void;
  79294. /**
  79295. * Function called to generate a pointer down animation
  79296. */
  79297. pointerDownAnimation: () => void;
  79298. /**
  79299. * Function called to generate a pointer up animation
  79300. */
  79301. pointerUpAnimation: () => void;
  79302. /**
  79303. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79304. */
  79305. delegatePickingToChildren: boolean;
  79306. private _image;
  79307. /**
  79308. * Returns the image part of the button (if any)
  79309. */
  79310. get image(): BABYLON.Nullable<Image>;
  79311. private _textBlock;
  79312. /**
  79313. * Returns the image part of the button (if any)
  79314. */
  79315. get textBlock(): BABYLON.Nullable<TextBlock>;
  79316. /**
  79317. * Creates a new Button
  79318. * @param name defines the name of the button
  79319. */
  79320. constructor(name?: string | undefined);
  79321. protected _getTypeName(): string;
  79322. /** @hidden */
  79323. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79324. /** @hidden */
  79325. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79326. /** @hidden */
  79327. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79328. /** @hidden */
  79329. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79330. /** @hidden */
  79331. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79332. /**
  79333. * Creates a new button made with an image and a text
  79334. * @param name defines the name of the button
  79335. * @param text defines the text of the button
  79336. * @param imageUrl defines the url of the image
  79337. * @returns a new Button
  79338. */
  79339. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79340. /**
  79341. * Creates a new button made with an image
  79342. * @param name defines the name of the button
  79343. * @param imageUrl defines the url of the image
  79344. * @returns a new Button
  79345. */
  79346. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79347. /**
  79348. * Creates a new button made with a text
  79349. * @param name defines the name of the button
  79350. * @param text defines the text of the button
  79351. * @returns a new Button
  79352. */
  79353. static CreateSimpleButton(name: string, text: string): Button;
  79354. /**
  79355. * Creates a new button made with an image and a centered text
  79356. * @param name defines the name of the button
  79357. * @param text defines the text of the button
  79358. * @param imageUrl defines the url of the image
  79359. * @returns a new Button
  79360. */
  79361. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79362. }
  79363. }
  79364. declare module BABYLON.GUI {
  79365. /**
  79366. * Class used to create a 2D stack panel container
  79367. */
  79368. export class StackPanel extends Container {
  79369. name?: string | undefined;
  79370. private _isVertical;
  79371. private _manualWidth;
  79372. private _manualHeight;
  79373. private _doNotTrackManualChanges;
  79374. /**
  79375. * Gets or sets a boolean indicating that layou warnings should be ignored
  79376. */
  79377. ignoreLayoutWarnings: boolean;
  79378. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79379. get isVertical(): boolean;
  79380. set isVertical(value: boolean);
  79381. /**
  79382. * Gets or sets panel width.
  79383. * This value should not be set when in horizontal mode as it will be computed automatically
  79384. */
  79385. set width(value: string | number);
  79386. get width(): string | number;
  79387. /**
  79388. * Gets or sets panel height.
  79389. * This value should not be set when in vertical mode as it will be computed automatically
  79390. */
  79391. set height(value: string | number);
  79392. get height(): string | number;
  79393. /**
  79394. * Creates a new StackPanel
  79395. * @param name defines control name
  79396. */
  79397. constructor(name?: string | undefined);
  79398. protected _getTypeName(): string;
  79399. /** @hidden */
  79400. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79401. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79402. protected _postMeasure(): void;
  79403. }
  79404. }
  79405. declare module BABYLON.GUI {
  79406. /**
  79407. * Class used to represent a 2D checkbox
  79408. */
  79409. export class Checkbox extends Control {
  79410. name?: string | undefined;
  79411. private _isChecked;
  79412. private _background;
  79413. private _checkSizeRatio;
  79414. private _thickness;
  79415. /** Gets or sets border thickness */
  79416. get thickness(): number;
  79417. set thickness(value: number);
  79418. /**
  79419. * BABYLON.Observable raised when isChecked property changes
  79420. */
  79421. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79422. /** Gets or sets a value indicating the ratio between overall size and check size */
  79423. get checkSizeRatio(): number;
  79424. set checkSizeRatio(value: number);
  79425. /** Gets or sets background color */
  79426. get background(): string;
  79427. set background(value: string);
  79428. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79429. get isChecked(): boolean;
  79430. set isChecked(value: boolean);
  79431. /**
  79432. * Creates a new CheckBox
  79433. * @param name defines the control name
  79434. */
  79435. constructor(name?: string | undefined);
  79436. protected _getTypeName(): string;
  79437. /** @hidden */
  79438. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79439. /** @hidden */
  79440. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79441. /**
  79442. * Utility function to easily create a checkbox with a header
  79443. * @param title defines the label to use for the header
  79444. * @param onValueChanged defines the callback to call when value changes
  79445. * @returns a StackPanel containing the checkbox and a textBlock
  79446. */
  79447. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79448. }
  79449. }
  79450. declare module BABYLON.GUI {
  79451. /**
  79452. * Class used to store key control properties
  79453. */
  79454. export class KeyPropertySet {
  79455. /** Width */
  79456. width?: string;
  79457. /** Height */
  79458. height?: string;
  79459. /** Left padding */
  79460. paddingLeft?: string;
  79461. /** Right padding */
  79462. paddingRight?: string;
  79463. /** Top padding */
  79464. paddingTop?: string;
  79465. /** Bottom padding */
  79466. paddingBottom?: string;
  79467. /** Foreground color */
  79468. color?: string;
  79469. /** Background color */
  79470. background?: string;
  79471. }
  79472. /**
  79473. * Class used to create virtual keyboard
  79474. */
  79475. export class VirtualKeyboard extends StackPanel {
  79476. /** BABYLON.Observable raised when a key is pressed */
  79477. onKeyPressObservable: BABYLON.Observable<string>;
  79478. /** Gets or sets default key button width */
  79479. defaultButtonWidth: string;
  79480. /** Gets or sets default key button height */
  79481. defaultButtonHeight: string;
  79482. /** Gets or sets default key button left padding */
  79483. defaultButtonPaddingLeft: string;
  79484. /** Gets or sets default key button right padding */
  79485. defaultButtonPaddingRight: string;
  79486. /** Gets or sets default key button top padding */
  79487. defaultButtonPaddingTop: string;
  79488. /** Gets or sets default key button bottom padding */
  79489. defaultButtonPaddingBottom: string;
  79490. /** Gets or sets default key button foreground color */
  79491. defaultButtonColor: string;
  79492. /** Gets or sets default key button background color */
  79493. defaultButtonBackground: string;
  79494. /** Gets or sets shift button foreground color */
  79495. shiftButtonColor: string;
  79496. /** Gets or sets shift button thickness*/
  79497. selectedShiftThickness: number;
  79498. /** Gets shift key state */
  79499. shiftState: number;
  79500. protected _getTypeName(): string;
  79501. private _createKey;
  79502. /**
  79503. * Adds a new row of keys
  79504. * @param keys defines the list of keys to add
  79505. * @param propertySets defines the associated property sets
  79506. */
  79507. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79508. /**
  79509. * Set the shift key to a specific state
  79510. * @param shiftState defines the new shift state
  79511. */
  79512. applyShiftState(shiftState: number): void;
  79513. private _currentlyConnectedInputText;
  79514. private _connectedInputTexts;
  79515. private _onKeyPressObserver;
  79516. /** Gets the input text control currently attached to the keyboard */
  79517. get connectedInputText(): BABYLON.Nullable<InputText>;
  79518. /**
  79519. * Connects the keyboard with an input text control
  79520. *
  79521. * @param input defines the target control
  79522. */
  79523. connect(input: InputText): void;
  79524. /**
  79525. * Disconnects the keyboard from connected InputText controls
  79526. *
  79527. * @param input optionally defines a target control, otherwise all are disconnected
  79528. */
  79529. disconnect(input?: InputText): void;
  79530. private _removeConnectedInputObservables;
  79531. /**
  79532. * Release all resources
  79533. */
  79534. dispose(): void;
  79535. /**
  79536. * Creates a new keyboard using a default layout
  79537. *
  79538. * @param name defines control name
  79539. * @returns a new VirtualKeyboard
  79540. */
  79541. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79542. }
  79543. }
  79544. declare module BABYLON.GUI {
  79545. /**
  79546. * Class used to create input text control
  79547. */
  79548. export class InputText extends Control implements IFocusableControl {
  79549. name?: string | undefined;
  79550. private _text;
  79551. private _placeholderText;
  79552. private _background;
  79553. private _focusedBackground;
  79554. private _focusedColor;
  79555. private _placeholderColor;
  79556. private _thickness;
  79557. private _margin;
  79558. private _autoStretchWidth;
  79559. private _maxWidth;
  79560. private _isFocused;
  79561. private _blinkTimeout;
  79562. private _blinkIsEven;
  79563. private _cursorOffset;
  79564. private _scrollLeft;
  79565. private _textWidth;
  79566. private _clickedCoordinate;
  79567. private _deadKey;
  79568. private _addKey;
  79569. private _currentKey;
  79570. private _isTextHighlightOn;
  79571. private _textHighlightColor;
  79572. private _highligherOpacity;
  79573. private _highlightedText;
  79574. private _startHighlightIndex;
  79575. private _endHighlightIndex;
  79576. private _cursorIndex;
  79577. private _onFocusSelectAll;
  79578. private _isPointerDown;
  79579. private _onClipboardObserver;
  79580. private _onPointerDblTapObserver;
  79581. /** @hidden */
  79582. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  79583. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  79584. promptMessage: string;
  79585. /** Force disable prompt on mobile device */
  79586. disableMobilePrompt: boolean;
  79587. /** BABYLON.Observable raised when the text changes */
  79588. onTextChangedObservable: BABYLON.Observable<InputText>;
  79589. /** BABYLON.Observable raised just before an entered character is to be added */
  79590. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79591. /** BABYLON.Observable raised when the control gets the focus */
  79592. onFocusObservable: BABYLON.Observable<InputText>;
  79593. /** BABYLON.Observable raised when the control loses the focus */
  79594. onBlurObservable: BABYLON.Observable<InputText>;
  79595. /**Observable raised when the text is highlighted */
  79596. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79597. /**Observable raised when copy event is triggered */
  79598. onTextCopyObservable: BABYLON.Observable<InputText>;
  79599. /** BABYLON.Observable raised when cut event is triggered */
  79600. onTextCutObservable: BABYLON.Observable<InputText>;
  79601. /** BABYLON.Observable raised when paste event is triggered */
  79602. onTextPasteObservable: BABYLON.Observable<InputText>;
  79603. /** BABYLON.Observable raised when a key event was processed */
  79604. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79605. /** Gets or sets the maximum width allowed by the control */
  79606. get maxWidth(): string | number;
  79607. /** Gets the maximum width allowed by the control in pixels */
  79608. get maxWidthInPixels(): number;
  79609. set maxWidth(value: string | number);
  79610. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79611. get highligherOpacity(): number;
  79612. set highligherOpacity(value: number);
  79613. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79614. get onFocusSelectAll(): boolean;
  79615. set onFocusSelectAll(value: boolean);
  79616. /** Gets or sets the text hightlight color */
  79617. get textHighlightColor(): string;
  79618. set textHighlightColor(value: string);
  79619. /** Gets or sets control margin */
  79620. get margin(): string;
  79621. /** Gets control margin in pixels */
  79622. get marginInPixels(): number;
  79623. set margin(value: string);
  79624. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  79625. get autoStretchWidth(): boolean;
  79626. set autoStretchWidth(value: boolean);
  79627. /** Gets or sets border thickness */
  79628. get thickness(): number;
  79629. set thickness(value: number);
  79630. /** Gets or sets the background color when focused */
  79631. get focusedBackground(): string;
  79632. set focusedBackground(value: string);
  79633. /** Gets or sets the background color when focused */
  79634. get focusedColor(): string;
  79635. set focusedColor(value: string);
  79636. /** Gets or sets the background color */
  79637. get background(): string;
  79638. set background(value: string);
  79639. /** Gets or sets the placeholder color */
  79640. get placeholderColor(): string;
  79641. set placeholderColor(value: string);
  79642. /** Gets or sets the text displayed when the control is empty */
  79643. get placeholderText(): string;
  79644. set placeholderText(value: string);
  79645. /** Gets or sets the dead key flag */
  79646. get deadKey(): boolean;
  79647. set deadKey(flag: boolean);
  79648. /** Gets or sets the highlight text */
  79649. get highlightedText(): string;
  79650. set highlightedText(text: string);
  79651. /** Gets or sets if the current key should be added */
  79652. get addKey(): boolean;
  79653. set addKey(flag: boolean);
  79654. /** Gets or sets the value of the current key being entered */
  79655. get currentKey(): string;
  79656. set currentKey(key: string);
  79657. /** Gets or sets the text displayed in the control */
  79658. get text(): string;
  79659. set text(value: string);
  79660. /** Gets or sets control width */
  79661. get width(): string | number;
  79662. set width(value: string | number);
  79663. /**
  79664. * Creates a new InputText
  79665. * @param name defines the control name
  79666. * @param text defines the text of the control
  79667. */
  79668. constructor(name?: string | undefined, text?: string);
  79669. /** @hidden */
  79670. onBlur(): void;
  79671. /** @hidden */
  79672. onFocus(): void;
  79673. protected _getTypeName(): string;
  79674. /**
  79675. * Function called to get the list of controls that should not steal the focus from this control
  79676. * @returns an array of controls
  79677. */
  79678. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  79679. /** @hidden */
  79680. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  79681. /** @hidden */
  79682. private _updateValueFromCursorIndex;
  79683. /** @hidden */
  79684. private _processDblClick;
  79685. /** @hidden */
  79686. private _selectAllText;
  79687. /**
  79688. * Handles the keyboard event
  79689. * @param evt Defines the KeyboardEvent
  79690. */
  79691. processKeyboard(evt: KeyboardEvent): void;
  79692. /** @hidden */
  79693. private _onCopyText;
  79694. /** @hidden */
  79695. private _onCutText;
  79696. /** @hidden */
  79697. private _onPasteText;
  79698. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79699. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79700. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79701. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79702. protected _beforeRenderText(text: string): string;
  79703. dispose(): void;
  79704. }
  79705. }
  79706. declare module BABYLON.GUI {
  79707. /**
  79708. * Class used to create a 2D grid container
  79709. */
  79710. export class Grid extends Container {
  79711. name?: string | undefined;
  79712. private _rowDefinitions;
  79713. private _columnDefinitions;
  79714. private _cells;
  79715. private _childControls;
  79716. /**
  79717. * Gets the number of columns
  79718. */
  79719. get columnCount(): number;
  79720. /**
  79721. * Gets the number of rows
  79722. */
  79723. get rowCount(): number;
  79724. /** Gets the list of children */
  79725. get children(): Control[];
  79726. /** Gets the list of cells (e.g. the containers) */
  79727. get cells(): {
  79728. [key: string]: Container;
  79729. };
  79730. /**
  79731. * Gets the definition of a specific row
  79732. * @param index defines the index of the row
  79733. * @returns the row definition
  79734. */
  79735. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79736. /**
  79737. * Gets the definition of a specific column
  79738. * @param index defines the index of the column
  79739. * @returns the column definition
  79740. */
  79741. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79742. /**
  79743. * Adds a new row to the grid
  79744. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79745. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  79746. * @returns the current grid
  79747. */
  79748. addRowDefinition(height: number, isPixel?: boolean): Grid;
  79749. /**
  79750. * Adds a new column to the grid
  79751. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79752. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79753. * @returns the current grid
  79754. */
  79755. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  79756. /**
  79757. * Update a row definition
  79758. * @param index defines the index of the row to update
  79759. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79760. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  79761. * @returns the current grid
  79762. */
  79763. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  79764. /**
  79765. * Update a column definition
  79766. * @param index defines the index of the column to update
  79767. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79768. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79769. * @returns the current grid
  79770. */
  79771. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  79772. /**
  79773. * Gets the list of children stored in a specific cell
  79774. * @param row defines the row to check
  79775. * @param column defines the column to check
  79776. * @returns the list of controls
  79777. */
  79778. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  79779. /**
  79780. * Gets a string representing the child cell info (row x column)
  79781. * @param child defines the control to get info from
  79782. * @returns a string containing the child cell info (row x column)
  79783. */
  79784. getChildCellInfo(child: Control): string;
  79785. private _removeCell;
  79786. private _offsetCell;
  79787. /**
  79788. * Remove a column definition at specified index
  79789. * @param index defines the index of the column to remove
  79790. * @returns the current grid
  79791. */
  79792. removeColumnDefinition(index: number): Grid;
  79793. /**
  79794. * Remove a row definition at specified index
  79795. * @param index defines the index of the row to remove
  79796. * @returns the current grid
  79797. */
  79798. removeRowDefinition(index: number): Grid;
  79799. /**
  79800. * Adds a new control to the current grid
  79801. * @param control defines the control to add
  79802. * @param row defines the row where to add the control (0 by default)
  79803. * @param column defines the column where to add the control (0 by default)
  79804. * @returns the current grid
  79805. */
  79806. addControl(control: Control, row?: number, column?: number): Grid;
  79807. /**
  79808. * Removes a control from the current container
  79809. * @param control defines the control to remove
  79810. * @returns the current container
  79811. */
  79812. removeControl(control: Control): Container;
  79813. /**
  79814. * Creates a new Grid
  79815. * @param name defines control name
  79816. */
  79817. constructor(name?: string | undefined);
  79818. protected _getTypeName(): string;
  79819. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  79820. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79821. _flagDescendantsAsMatrixDirty(): void;
  79822. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79823. /** Releases associated resources */
  79824. dispose(): void;
  79825. }
  79826. }
  79827. declare module BABYLON.GUI {
  79828. /** Class used to create color pickers */
  79829. export class ColorPicker extends Control {
  79830. name?: string | undefined;
  79831. private static _Epsilon;
  79832. private _colorWheelCanvas;
  79833. private _value;
  79834. private _tmpColor;
  79835. private _pointerStartedOnSquare;
  79836. private _pointerStartedOnWheel;
  79837. private _squareLeft;
  79838. private _squareTop;
  79839. private _squareSize;
  79840. private _h;
  79841. private _s;
  79842. private _v;
  79843. private _lastPointerDownID;
  79844. /**
  79845. * BABYLON.Observable raised when the value changes
  79846. */
  79847. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  79848. /** Gets or sets the color of the color picker */
  79849. get value(): BABYLON.Color3;
  79850. set value(value: BABYLON.Color3);
  79851. /**
  79852. * Gets or sets control width
  79853. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79854. */
  79855. get width(): string | number;
  79856. set width(value: string | number);
  79857. /**
  79858. * Gets or sets control height
  79859. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79860. */
  79861. get height(): string | number;
  79862. /** Gets or sets control height */
  79863. set height(value: string | number);
  79864. /** Gets or sets control size */
  79865. get size(): string | number;
  79866. set size(value: string | number);
  79867. /**
  79868. * Creates a new ColorPicker
  79869. * @param name defines the control name
  79870. */
  79871. constructor(name?: string | undefined);
  79872. protected _getTypeName(): string;
  79873. /** @hidden */
  79874. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79875. private _updateSquareProps;
  79876. private _drawGradientSquare;
  79877. private _drawCircle;
  79878. private _createColorWheelCanvas;
  79879. /** @hidden */
  79880. _draw(context: CanvasRenderingContext2D): void;
  79881. private _pointerIsDown;
  79882. private _updateValueFromPointer;
  79883. private _isPointOnSquare;
  79884. private _isPointOnWheel;
  79885. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79886. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79887. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79888. _onCanvasBlur(): void;
  79889. /**
  79890. * This function expands the color picker by creating a color picker dialog with manual
  79891. * color value input and the ability to save colors into an array to be used later in
  79892. * subsequent launches of the dialogue.
  79893. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  79894. * @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.
  79895. * @returns picked color as a hex string and the saved colors array as hex strings.
  79896. */
  79897. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  79898. pickerWidth?: string;
  79899. pickerHeight?: string;
  79900. headerHeight?: string;
  79901. lastColor?: string;
  79902. swatchLimit?: number;
  79903. numSwatchesPerLine?: number;
  79904. savedColors?: Array<string>;
  79905. }): Promise<{
  79906. savedColors?: string[];
  79907. pickedColor: string;
  79908. }>;
  79909. }
  79910. }
  79911. declare module BABYLON.GUI {
  79912. /** Class used to create 2D ellipse containers */
  79913. export class Ellipse extends Container {
  79914. name?: string | undefined;
  79915. private _thickness;
  79916. /** Gets or sets border thickness */
  79917. get thickness(): number;
  79918. set thickness(value: number);
  79919. /**
  79920. * Creates a new Ellipse
  79921. * @param name defines the control name
  79922. */
  79923. constructor(name?: string | undefined);
  79924. protected _getTypeName(): string;
  79925. protected _localDraw(context: CanvasRenderingContext2D): void;
  79926. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79927. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79928. }
  79929. }
  79930. declare module BABYLON.GUI {
  79931. /**
  79932. * Class used to create a password control
  79933. */
  79934. export class InputPassword extends InputText {
  79935. protected _beforeRenderText(text: string): string;
  79936. }
  79937. }
  79938. declare module BABYLON.GUI {
  79939. /** Class used to render 2D lines */
  79940. export class Line extends Control {
  79941. name?: string | undefined;
  79942. private _lineWidth;
  79943. private _x1;
  79944. private _y1;
  79945. private _x2;
  79946. private _y2;
  79947. private _dash;
  79948. private _connectedControl;
  79949. private _connectedControlDirtyObserver;
  79950. /** Gets or sets the dash pattern */
  79951. get dash(): Array<number>;
  79952. set dash(value: Array<number>);
  79953. /** Gets or sets the control connected with the line end */
  79954. get connectedControl(): Control;
  79955. set connectedControl(value: Control);
  79956. /** Gets or sets start coordinates on X axis */
  79957. get x1(): string | number;
  79958. set x1(value: string | number);
  79959. /** Gets or sets start coordinates on Y axis */
  79960. get y1(): string | number;
  79961. set y1(value: string | number);
  79962. /** Gets or sets end coordinates on X axis */
  79963. get x2(): string | number;
  79964. set x2(value: string | number);
  79965. /** Gets or sets end coordinates on Y axis */
  79966. get y2(): string | number;
  79967. set y2(value: string | number);
  79968. /** Gets or sets line width */
  79969. get lineWidth(): number;
  79970. set lineWidth(value: number);
  79971. /** Gets or sets horizontal alignment */
  79972. set horizontalAlignment(value: number);
  79973. /** Gets or sets vertical alignment */
  79974. set verticalAlignment(value: number);
  79975. private get _effectiveX2();
  79976. private get _effectiveY2();
  79977. /**
  79978. * Creates a new Line
  79979. * @param name defines the control name
  79980. */
  79981. constructor(name?: string | undefined);
  79982. protected _getTypeName(): string;
  79983. _draw(context: CanvasRenderingContext2D): void;
  79984. _measure(): void;
  79985. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79986. /**
  79987. * Move one end of the line given 3D cartesian coordinates.
  79988. * @param position Targeted world position
  79989. * @param scene BABYLON.Scene
  79990. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79991. */
  79992. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  79993. /**
  79994. * Move one end of the line to a position in screen absolute space.
  79995. * @param projectedPosition Position in screen absolute space (X, Y)
  79996. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79997. */
  79998. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  79999. }
  80000. }
  80001. declare module BABYLON.GUI {
  80002. /**
  80003. * Class used to store a point for a MultiLine object.
  80004. * The point can be pure 2D coordinates, a mesh or a control
  80005. */
  80006. export class MultiLinePoint {
  80007. private _multiLine;
  80008. private _x;
  80009. private _y;
  80010. private _control;
  80011. private _mesh;
  80012. private _controlObserver;
  80013. private _meshObserver;
  80014. /** @hidden */
  80015. _point: BABYLON.Vector2;
  80016. /**
  80017. * Creates a new MultiLinePoint
  80018. * @param multiLine defines the source MultiLine object
  80019. */
  80020. constructor(multiLine: MultiLine);
  80021. /** Gets or sets x coordinate */
  80022. get x(): string | number;
  80023. set x(value: string | number);
  80024. /** Gets or sets y coordinate */
  80025. get y(): string | number;
  80026. set y(value: string | number);
  80027. /** Gets or sets the control associated with this point */
  80028. get control(): BABYLON.Nullable<Control>;
  80029. set control(value: BABYLON.Nullable<Control>);
  80030. /** Gets or sets the mesh associated with this point */
  80031. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80032. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  80033. /** Resets links */
  80034. resetLinks(): void;
  80035. /**
  80036. * Gets a translation vector
  80037. * @returns the translation vector
  80038. */
  80039. translate(): BABYLON.Vector2;
  80040. private _translatePoint;
  80041. /** Release associated resources */
  80042. dispose(): void;
  80043. }
  80044. }
  80045. declare module BABYLON.GUI {
  80046. /**
  80047. * Class used to create multi line control
  80048. */
  80049. export class MultiLine extends Control {
  80050. name?: string | undefined;
  80051. private _lineWidth;
  80052. private _dash;
  80053. private _points;
  80054. private _minX;
  80055. private _minY;
  80056. private _maxX;
  80057. private _maxY;
  80058. /**
  80059. * Creates a new MultiLine
  80060. * @param name defines the control name
  80061. */
  80062. constructor(name?: string | undefined);
  80063. /** Gets or sets dash pattern */
  80064. get dash(): Array<number>;
  80065. set dash(value: Array<number>);
  80066. /**
  80067. * Gets point stored at specified index
  80068. * @param index defines the index to look for
  80069. * @returns the requested point if found
  80070. */
  80071. getAt(index: number): MultiLinePoint;
  80072. /** Function called when a point is updated */
  80073. onPointUpdate: () => void;
  80074. /**
  80075. * Adds new points to the point collection
  80076. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  80077. * @returns the list of created MultiLinePoint
  80078. */
  80079. add(...items: (AbstractMesh | Control | {
  80080. x: string | number;
  80081. y: string | number;
  80082. })[]): MultiLinePoint[];
  80083. /**
  80084. * Adds a new point to the point collection
  80085. * @param item defines the item (mesh, control or 2d coordiantes) to add
  80086. * @returns the created MultiLinePoint
  80087. */
  80088. push(item?: (AbstractMesh | Control | {
  80089. x: string | number;
  80090. y: string | number;
  80091. })): MultiLinePoint;
  80092. /**
  80093. * Remove a specific value or point from the active point collection
  80094. * @param value defines the value or point to remove
  80095. */
  80096. remove(value: number | MultiLinePoint): void;
  80097. /**
  80098. * Resets this object to initial state (no point)
  80099. */
  80100. reset(): void;
  80101. /**
  80102. * Resets all links
  80103. */
  80104. resetLinks(): void;
  80105. /** Gets or sets line width */
  80106. get lineWidth(): number;
  80107. set lineWidth(value: number);
  80108. set horizontalAlignment(value: number);
  80109. set verticalAlignment(value: number);
  80110. protected _getTypeName(): string;
  80111. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80112. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80113. _measure(): void;
  80114. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80115. dispose(): void;
  80116. }
  80117. }
  80118. declare module BABYLON.GUI {
  80119. /**
  80120. * Class used to create radio button controls
  80121. */
  80122. export class RadioButton extends Control {
  80123. name?: string | undefined;
  80124. private _isChecked;
  80125. private _background;
  80126. private _checkSizeRatio;
  80127. private _thickness;
  80128. /** Gets or sets border thickness */
  80129. get thickness(): number;
  80130. set thickness(value: number);
  80131. /** Gets or sets group name */
  80132. group: string;
  80133. /** BABYLON.Observable raised when isChecked is changed */
  80134. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80135. /** Gets or sets a value indicating the ratio between overall size and check size */
  80136. get checkSizeRatio(): number;
  80137. set checkSizeRatio(value: number);
  80138. /** Gets or sets background color */
  80139. get background(): string;
  80140. set background(value: string);
  80141. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80142. get isChecked(): boolean;
  80143. set isChecked(value: boolean);
  80144. /**
  80145. * Creates a new RadioButton
  80146. * @param name defines the control name
  80147. */
  80148. constructor(name?: string | undefined);
  80149. protected _getTypeName(): string;
  80150. _draw(context: CanvasRenderingContext2D): void;
  80151. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80152. /**
  80153. * Utility function to easily create a radio button with a header
  80154. * @param title defines the label to use for the header
  80155. * @param group defines the group to use for the radio button
  80156. * @param isChecked defines the initial state of the radio button
  80157. * @param onValueChanged defines the callback to call when value changes
  80158. * @returns a StackPanel containing the radio button and a textBlock
  80159. */
  80160. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80161. }
  80162. }
  80163. declare module BABYLON.GUI {
  80164. /**
  80165. * Class used to create slider controls
  80166. */
  80167. export class BaseSlider extends Control {
  80168. name?: string | undefined;
  80169. protected _thumbWidth: ValueAndUnit;
  80170. private _minimum;
  80171. private _maximum;
  80172. private _value;
  80173. private _isVertical;
  80174. protected _barOffset: ValueAndUnit;
  80175. private _isThumbClamped;
  80176. protected _displayThumb: boolean;
  80177. private _step;
  80178. private _lastPointerDownID;
  80179. protected _effectiveBarOffset: number;
  80180. protected _renderLeft: number;
  80181. protected _renderTop: number;
  80182. protected _renderWidth: number;
  80183. protected _renderHeight: number;
  80184. protected _backgroundBoxLength: number;
  80185. protected _backgroundBoxThickness: number;
  80186. protected _effectiveThumbThickness: number;
  80187. /** BABYLON.Observable raised when the sldier value changes */
  80188. onValueChangedObservable: BABYLON.Observable<number>;
  80189. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80190. get displayThumb(): boolean;
  80191. set displayThumb(value: boolean);
  80192. /** Gets or sets a step to apply to values (0 by default) */
  80193. get step(): number;
  80194. set step(value: number);
  80195. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80196. get barOffset(): string | number;
  80197. /** Gets main bar offset in pixels*/
  80198. get barOffsetInPixels(): number;
  80199. set barOffset(value: string | number);
  80200. /** Gets or sets thumb width */
  80201. get thumbWidth(): string | number;
  80202. /** Gets thumb width in pixels */
  80203. get thumbWidthInPixels(): number;
  80204. set thumbWidth(value: string | number);
  80205. /** Gets or sets minimum value */
  80206. get minimum(): number;
  80207. set minimum(value: number);
  80208. /** Gets or sets maximum value */
  80209. get maximum(): number;
  80210. set maximum(value: number);
  80211. /** Gets or sets current value */
  80212. get value(): number;
  80213. set value(value: number);
  80214. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80215. get isVertical(): boolean;
  80216. set isVertical(value: boolean);
  80217. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80218. get isThumbClamped(): boolean;
  80219. set isThumbClamped(value: boolean);
  80220. /**
  80221. * Creates a new BaseSlider
  80222. * @param name defines the control name
  80223. */
  80224. constructor(name?: string | undefined);
  80225. protected _getTypeName(): string;
  80226. protected _getThumbPosition(): number;
  80227. protected _getThumbThickness(type: string): number;
  80228. protected _prepareRenderingData(type: string): void;
  80229. private _pointerIsDown;
  80230. /** @hidden */
  80231. protected _updateValueFromPointer(x: number, y: number): void;
  80232. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80233. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80234. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80235. _onCanvasBlur(): void;
  80236. }
  80237. }
  80238. declare module BABYLON.GUI {
  80239. /**
  80240. * Class used to create slider controls
  80241. */
  80242. export class Slider extends BaseSlider {
  80243. name?: string | undefined;
  80244. private _background;
  80245. private _borderColor;
  80246. private _thumbColor;
  80247. private _isThumbCircle;
  80248. protected _displayValueBar: boolean;
  80249. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80250. get displayValueBar(): boolean;
  80251. set displayValueBar(value: boolean);
  80252. /** Gets or sets border color */
  80253. get borderColor(): string;
  80254. set borderColor(value: string);
  80255. /** Gets or sets background color */
  80256. get background(): string;
  80257. set background(value: string);
  80258. /** Gets or sets thumb's color */
  80259. get thumbColor(): string;
  80260. set thumbColor(value: string);
  80261. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80262. get isThumbCircle(): boolean;
  80263. set isThumbCircle(value: boolean);
  80264. /**
  80265. * Creates a new Slider
  80266. * @param name defines the control name
  80267. */
  80268. constructor(name?: string | undefined);
  80269. protected _getTypeName(): string;
  80270. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80271. }
  80272. }
  80273. declare module BABYLON.GUI {
  80274. /** Class used to create a RadioGroup
  80275. * which contains groups of radio buttons
  80276. */
  80277. export class SelectorGroup {
  80278. /** name of SelectorGroup */
  80279. name: string;
  80280. private _groupPanel;
  80281. private _selectors;
  80282. private _groupHeader;
  80283. /**
  80284. * Creates a new SelectorGroup
  80285. * @param name of group, used as a group heading
  80286. */
  80287. constructor(
  80288. /** name of SelectorGroup */
  80289. name: string);
  80290. /** Gets the groupPanel of the SelectorGroup */
  80291. get groupPanel(): StackPanel;
  80292. /** Gets the selectors array */
  80293. get selectors(): StackPanel[];
  80294. /** Gets and sets the group header */
  80295. get header(): string;
  80296. set header(label: string);
  80297. /** @hidden */
  80298. private _addGroupHeader;
  80299. /** @hidden*/
  80300. _getSelector(selectorNb: number): StackPanel | undefined;
  80301. /** Removes the selector at the given position
  80302. * @param selectorNb the position of the selector within the group
  80303. */
  80304. removeSelector(selectorNb: number): void;
  80305. }
  80306. /** Class used to create a CheckboxGroup
  80307. * which contains groups of checkbox buttons
  80308. */
  80309. export class CheckboxGroup extends SelectorGroup {
  80310. /** Adds a checkbox as a control
  80311. * @param text is the label for the selector
  80312. * @param func is the function called when the Selector is checked
  80313. * @param checked is true when Selector is checked
  80314. */
  80315. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80316. /** @hidden */
  80317. _setSelectorLabel(selectorNb: number, label: string): void;
  80318. /** @hidden */
  80319. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80320. /** @hidden */
  80321. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80322. /** @hidden */
  80323. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80324. }
  80325. /** Class used to create a RadioGroup
  80326. * which contains groups of radio buttons
  80327. */
  80328. export class RadioGroup extends SelectorGroup {
  80329. private _selectNb;
  80330. /** Adds a radio button as a control
  80331. * @param label is the label for the selector
  80332. * @param func is the function called when the Selector is checked
  80333. * @param checked is true when Selector is checked
  80334. */
  80335. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80336. /** @hidden */
  80337. _setSelectorLabel(selectorNb: number, label: string): void;
  80338. /** @hidden */
  80339. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80340. /** @hidden */
  80341. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80342. /** @hidden */
  80343. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80344. }
  80345. /** Class used to create a SliderGroup
  80346. * which contains groups of slider buttons
  80347. */
  80348. export class SliderGroup extends SelectorGroup {
  80349. /**
  80350. * Adds a slider to the SelectorGroup
  80351. * @param label is the label for the SliderBar
  80352. * @param func is the function called when the Slider moves
  80353. * @param unit is a string describing the units used, eg degrees or metres
  80354. * @param min is the minimum value for the Slider
  80355. * @param max is the maximum value for the Slider
  80356. * @param value is the start value for the Slider between min and max
  80357. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80358. */
  80359. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80360. /** @hidden */
  80361. _setSelectorLabel(selectorNb: number, label: string): void;
  80362. /** @hidden */
  80363. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80364. /** @hidden */
  80365. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80366. /** @hidden */
  80367. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80368. }
  80369. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80370. * @see https://doc.babylonjs.com/how_to/selector
  80371. */
  80372. export class SelectionPanel extends Rectangle {
  80373. /** name of SelectionPanel */
  80374. name: string;
  80375. /** an array of SelectionGroups */
  80376. groups: SelectorGroup[];
  80377. private _panel;
  80378. private _buttonColor;
  80379. private _buttonBackground;
  80380. private _headerColor;
  80381. private _barColor;
  80382. private _barHeight;
  80383. private _spacerHeight;
  80384. private _labelColor;
  80385. private _groups;
  80386. private _bars;
  80387. /**
  80388. * Creates a new SelectionPanel
  80389. * @param name of SelectionPanel
  80390. * @param groups is an array of SelectionGroups
  80391. */
  80392. constructor(
  80393. /** name of SelectionPanel */
  80394. name: string,
  80395. /** an array of SelectionGroups */
  80396. groups?: SelectorGroup[]);
  80397. protected _getTypeName(): string;
  80398. /** Gets the (stack) panel of the SelectionPanel */
  80399. get panel(): StackPanel;
  80400. /** Gets or sets the headerColor */
  80401. get headerColor(): string;
  80402. set headerColor(color: string);
  80403. private _setHeaderColor;
  80404. /** Gets or sets the button color */
  80405. get buttonColor(): string;
  80406. set buttonColor(color: string);
  80407. private _setbuttonColor;
  80408. /** Gets or sets the label color */
  80409. get labelColor(): string;
  80410. set labelColor(color: string);
  80411. private _setLabelColor;
  80412. /** Gets or sets the button background */
  80413. get buttonBackground(): string;
  80414. set buttonBackground(color: string);
  80415. private _setButtonBackground;
  80416. /** Gets or sets the color of separator bar */
  80417. get barColor(): string;
  80418. set barColor(color: string);
  80419. private _setBarColor;
  80420. /** Gets or sets the height of separator bar */
  80421. get barHeight(): string;
  80422. set barHeight(value: string);
  80423. private _setBarHeight;
  80424. /** Gets or sets the height of spacers*/
  80425. get spacerHeight(): string;
  80426. set spacerHeight(value: string);
  80427. private _setSpacerHeight;
  80428. /** Adds a bar between groups */
  80429. private _addSpacer;
  80430. /** Add a group to the selection panel
  80431. * @param group is the selector group to add
  80432. */
  80433. addGroup(group: SelectorGroup): void;
  80434. /** Remove the group from the given position
  80435. * @param groupNb is the position of the group in the list
  80436. */
  80437. removeGroup(groupNb: number): void;
  80438. /** Change a group header label
  80439. * @param label is the new group header label
  80440. * @param groupNb is the number of the group to relabel
  80441. * */
  80442. setHeaderName(label: string, groupNb: number): void;
  80443. /** Change selector label to the one given
  80444. * @param label is the new selector label
  80445. * @param groupNb is the number of the groupcontaining the selector
  80446. * @param selectorNb is the number of the selector within a group to relabel
  80447. * */
  80448. relabel(label: string, groupNb: number, selectorNb: number): void;
  80449. /** For a given group position remove the selector at the given position
  80450. * @param groupNb is the number of the group to remove the selector from
  80451. * @param selectorNb is the number of the selector within the group
  80452. */
  80453. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80454. /** For a given group position of correct type add a checkbox button
  80455. * @param groupNb is the number of the group to remove the selector from
  80456. * @param label is the label for the selector
  80457. * @param func is the function called when the Selector is checked
  80458. * @param checked is true when Selector is checked
  80459. */
  80460. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80461. /** For a given group position of correct type add a radio button
  80462. * @param groupNb is the number of the group to remove the selector from
  80463. * @param label is the label for the selector
  80464. * @param func is the function called when the Selector is checked
  80465. * @param checked is true when Selector is checked
  80466. */
  80467. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80468. /**
  80469. * For a given slider group add a slider
  80470. * @param groupNb is the number of the group to add the slider to
  80471. * @param label is the label for the Slider
  80472. * @param func is the function called when the Slider moves
  80473. * @param unit is a string describing the units used, eg degrees or metres
  80474. * @param min is the minimum value for the Slider
  80475. * @param max is the maximum value for the Slider
  80476. * @param value is the start value for the Slider between min and max
  80477. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80478. */
  80479. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80480. }
  80481. }
  80482. declare module BABYLON.GUI {
  80483. /**
  80484. * Class used to hold a the container for ScrollViewer
  80485. * @hidden
  80486. */
  80487. export class _ScrollViewerWindow extends Container {
  80488. parentClientWidth: number;
  80489. parentClientHeight: number;
  80490. private _freezeControls;
  80491. private _parentMeasure;
  80492. private _oldLeft;
  80493. private _oldTop;
  80494. get freezeControls(): boolean;
  80495. set freezeControls(value: boolean);
  80496. private _bucketWidth;
  80497. private _bucketHeight;
  80498. private _buckets;
  80499. private _bucketLen;
  80500. get bucketWidth(): number;
  80501. get bucketHeight(): number;
  80502. setBucketSizes(width: number, height: number): void;
  80503. private _useBuckets;
  80504. private _makeBuckets;
  80505. private _dispatchInBuckets;
  80506. private _updateMeasures;
  80507. private _updateChildrenMeasures;
  80508. private _restoreMeasures;
  80509. /**
  80510. * Creates a new ScrollViewerWindow
  80511. * @param name of ScrollViewerWindow
  80512. */
  80513. constructor(name?: string);
  80514. protected _getTypeName(): string;
  80515. /** @hidden */
  80516. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80517. /** @hidden */
  80518. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  80519. private _scrollChildren;
  80520. private _scrollChildrenWithBuckets;
  80521. /** @hidden */
  80522. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  80523. protected _postMeasure(): void;
  80524. }
  80525. }
  80526. declare module BABYLON.GUI {
  80527. /**
  80528. * Class used to create slider controls
  80529. */
  80530. export class ScrollBar extends BaseSlider {
  80531. name?: string | undefined;
  80532. private _background;
  80533. private _borderColor;
  80534. private _tempMeasure;
  80535. /** Gets or sets border color */
  80536. get borderColor(): string;
  80537. set borderColor(value: string);
  80538. /** Gets or sets background color */
  80539. get background(): string;
  80540. set background(value: string);
  80541. /**
  80542. * Creates a new Slider
  80543. * @param name defines the control name
  80544. */
  80545. constructor(name?: string | undefined);
  80546. protected _getTypeName(): string;
  80547. protected _getThumbThickness(): number;
  80548. _draw(context: CanvasRenderingContext2D): void;
  80549. private _first;
  80550. private _originX;
  80551. private _originY;
  80552. /** @hidden */
  80553. protected _updateValueFromPointer(x: number, y: number): void;
  80554. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80555. }
  80556. }
  80557. declare module BABYLON.GUI {
  80558. /**
  80559. * Class used to create slider controls
  80560. */
  80561. export class ImageScrollBar extends BaseSlider {
  80562. name?: string | undefined;
  80563. private _backgroundBaseImage;
  80564. private _backgroundImage;
  80565. private _thumbImage;
  80566. private _thumbBaseImage;
  80567. private _thumbLength;
  80568. private _thumbHeight;
  80569. private _barImageHeight;
  80570. private _tempMeasure;
  80571. /** Number of 90° rotation to apply on the images when in vertical mode */
  80572. num90RotationInVerticalMode: number;
  80573. /**
  80574. * Gets or sets the image used to render the background for horizontal bar
  80575. */
  80576. get backgroundImage(): Image;
  80577. set backgroundImage(value: Image);
  80578. /**
  80579. * Gets or sets the image used to render the thumb
  80580. */
  80581. get thumbImage(): Image;
  80582. set thumbImage(value: Image);
  80583. /**
  80584. * Gets or sets the length of the thumb
  80585. */
  80586. get thumbLength(): number;
  80587. set thumbLength(value: number);
  80588. /**
  80589. * Gets or sets the height of the thumb
  80590. */
  80591. get thumbHeight(): number;
  80592. set thumbHeight(value: number);
  80593. /**
  80594. * Gets or sets the height of the bar image
  80595. */
  80596. get barImageHeight(): number;
  80597. set barImageHeight(value: number);
  80598. /**
  80599. * Creates a new ImageScrollBar
  80600. * @param name defines the control name
  80601. */
  80602. constructor(name?: string | undefined);
  80603. protected _getTypeName(): string;
  80604. protected _getThumbThickness(): number;
  80605. _draw(context: CanvasRenderingContext2D): void;
  80606. private _first;
  80607. private _originX;
  80608. private _originY;
  80609. /** @hidden */
  80610. protected _updateValueFromPointer(x: number, y: number): void;
  80611. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80612. }
  80613. }
  80614. declare module BABYLON.GUI {
  80615. /**
  80616. * Class used to hold a viewer window and sliders in a grid
  80617. */
  80618. export class ScrollViewer extends Rectangle {
  80619. private _grid;
  80620. private _horizontalBarSpace;
  80621. private _verticalBarSpace;
  80622. private _dragSpace;
  80623. private _horizontalBar;
  80624. private _verticalBar;
  80625. private _barColor;
  80626. private _barBackground;
  80627. private _barImage;
  80628. private _horizontalBarImage;
  80629. private _verticalBarImage;
  80630. private _barBackgroundImage;
  80631. private _horizontalBarBackgroundImage;
  80632. private _verticalBarBackgroundImage;
  80633. private _barSize;
  80634. private _window;
  80635. private _pointerIsOver;
  80636. private _wheelPrecision;
  80637. private _onWheelObserver;
  80638. private _clientWidth;
  80639. private _clientHeight;
  80640. private _useImageBar;
  80641. private _thumbLength;
  80642. private _thumbHeight;
  80643. private _barImageHeight;
  80644. private _horizontalBarImageHeight;
  80645. private _verticalBarImageHeight;
  80646. private _oldWindowContentsWidth;
  80647. private _oldWindowContentsHeight;
  80648. /**
  80649. * Gets the horizontal scrollbar
  80650. */
  80651. get horizontalBar(): ScrollBar | ImageScrollBar;
  80652. /**
  80653. * Gets the vertical scrollbar
  80654. */
  80655. get verticalBar(): ScrollBar | ImageScrollBar;
  80656. /**
  80657. * Adds a new control to the current container
  80658. * @param control defines the control to add
  80659. * @returns the current container
  80660. */
  80661. addControl(control: BABYLON.Nullable<Control>): Container;
  80662. /**
  80663. * Removes a control from the current container
  80664. * @param control defines the control to remove
  80665. * @returns the current container
  80666. */
  80667. removeControl(control: Control): Container;
  80668. /** Gets the list of children */
  80669. get children(): Control[];
  80670. _flagDescendantsAsMatrixDirty(): void;
  80671. /**
  80672. * Freezes or unfreezes the controls in the window.
  80673. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  80674. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  80675. */
  80676. get freezeControls(): boolean;
  80677. set freezeControls(value: boolean);
  80678. /** Gets the bucket width */
  80679. get bucketWidth(): number;
  80680. /** Gets the bucket height */
  80681. get bucketHeight(): number;
  80682. /**
  80683. * Sets the bucket sizes.
  80684. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  80685. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  80686. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  80687. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  80688. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  80689. * used), that's why it is not enabled by default.
  80690. * @param width width of the bucket
  80691. * @param height height of the bucket
  80692. */
  80693. setBucketSizes(width: number, height: number): void;
  80694. private _forceHorizontalBar;
  80695. private _forceVerticalBar;
  80696. /**
  80697. * Forces the horizontal scroll bar to be displayed
  80698. */
  80699. get forceHorizontalBar(): boolean;
  80700. set forceHorizontalBar(value: boolean);
  80701. /**
  80702. * Forces the vertical scroll bar to be displayed
  80703. */
  80704. get forceVerticalBar(): boolean;
  80705. set forceVerticalBar(value: boolean);
  80706. /**
  80707. * Creates a new ScrollViewer
  80708. * @param name of ScrollViewer
  80709. */
  80710. constructor(name?: string, isImageBased?: boolean);
  80711. /** Reset the scroll viewer window to initial size */
  80712. resetWindow(): void;
  80713. protected _getTypeName(): string;
  80714. private _buildClientSizes;
  80715. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80716. protected _postMeasure(): void;
  80717. /**
  80718. * Gets or sets the mouse wheel precision
  80719. * from 0 to 1 with a default value of 0.05
  80720. * */
  80721. get wheelPrecision(): number;
  80722. set wheelPrecision(value: number);
  80723. /** Gets or sets the scroll bar container background color */
  80724. get scrollBackground(): string;
  80725. set scrollBackground(color: string);
  80726. /** Gets or sets the bar color */
  80727. get barColor(): string;
  80728. set barColor(color: string);
  80729. /** Gets or sets the bar image */
  80730. get thumbImage(): Image;
  80731. set thumbImage(value: Image);
  80732. /** Gets or sets the horizontal bar image */
  80733. get horizontalThumbImage(): Image;
  80734. set horizontalThumbImage(value: Image);
  80735. /** Gets or sets the vertical bar image */
  80736. get verticalThumbImage(): Image;
  80737. set verticalThumbImage(value: Image);
  80738. /** Gets or sets the size of the bar */
  80739. get barSize(): number;
  80740. set barSize(value: number);
  80741. /** Gets or sets the length of the thumb */
  80742. get thumbLength(): number;
  80743. set thumbLength(value: number);
  80744. /** Gets or sets the height of the thumb */
  80745. get thumbHeight(): number;
  80746. set thumbHeight(value: number);
  80747. /** Gets or sets the height of the bar image */
  80748. get barImageHeight(): number;
  80749. set barImageHeight(value: number);
  80750. /** Gets or sets the height of the horizontal bar image */
  80751. get horizontalBarImageHeight(): number;
  80752. set horizontalBarImageHeight(value: number);
  80753. /** Gets or sets the height of the vertical bar image */
  80754. get verticalBarImageHeight(): number;
  80755. set verticalBarImageHeight(value: number);
  80756. /** Gets or sets the bar background */
  80757. get barBackground(): string;
  80758. set barBackground(color: string);
  80759. /** Gets or sets the bar background image */
  80760. get barImage(): Image;
  80761. set barImage(value: Image);
  80762. /** Gets or sets the horizontal bar background image */
  80763. get horizontalBarImage(): Image;
  80764. set horizontalBarImage(value: Image);
  80765. /** Gets or sets the vertical bar background image */
  80766. get verticalBarImage(): Image;
  80767. set verticalBarImage(value: Image);
  80768. private _setWindowPosition;
  80769. /** @hidden */
  80770. private _updateScroller;
  80771. _link(host: AdvancedDynamicTexture): void;
  80772. /** @hidden */
  80773. private _addBar;
  80774. /** @hidden */
  80775. private _attachWheel;
  80776. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80777. /** Releases associated resources */
  80778. dispose(): void;
  80779. }
  80780. }
  80781. declare module BABYLON.GUI {
  80782. /** Class used to render a grid */
  80783. export class DisplayGrid extends Control {
  80784. name?: string | undefined;
  80785. private _cellWidth;
  80786. private _cellHeight;
  80787. private _minorLineTickness;
  80788. private _minorLineColor;
  80789. private _majorLineTickness;
  80790. private _majorLineColor;
  80791. private _majorLineFrequency;
  80792. private _background;
  80793. private _displayMajorLines;
  80794. private _displayMinorLines;
  80795. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  80796. get displayMinorLines(): boolean;
  80797. set displayMinorLines(value: boolean);
  80798. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  80799. get displayMajorLines(): boolean;
  80800. set displayMajorLines(value: boolean);
  80801. /** Gets or sets background color (Black by default) */
  80802. get background(): string;
  80803. set background(value: string);
  80804. /** Gets or sets the width of each cell (20 by default) */
  80805. get cellWidth(): number;
  80806. set cellWidth(value: number);
  80807. /** Gets or sets the height of each cell (20 by default) */
  80808. get cellHeight(): number;
  80809. set cellHeight(value: number);
  80810. /** Gets or sets the tickness of minor lines (1 by default) */
  80811. get minorLineTickness(): number;
  80812. set minorLineTickness(value: number);
  80813. /** Gets or sets the color of minor lines (DarkGray by default) */
  80814. get minorLineColor(): string;
  80815. set minorLineColor(value: string);
  80816. /** Gets or sets the tickness of major lines (2 by default) */
  80817. get majorLineTickness(): number;
  80818. set majorLineTickness(value: number);
  80819. /** Gets or sets the color of major lines (White by default) */
  80820. get majorLineColor(): string;
  80821. set majorLineColor(value: string);
  80822. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  80823. get majorLineFrequency(): number;
  80824. set majorLineFrequency(value: number);
  80825. /**
  80826. * Creates a new GridDisplayRectangle
  80827. * @param name defines the control name
  80828. */
  80829. constructor(name?: string | undefined);
  80830. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80831. protected _getTypeName(): string;
  80832. }
  80833. }
  80834. declare module BABYLON.GUI {
  80835. /**
  80836. * Class used to create slider controls based on images
  80837. */
  80838. export class ImageBasedSlider extends BaseSlider {
  80839. name?: string | undefined;
  80840. private _backgroundImage;
  80841. private _thumbImage;
  80842. private _valueBarImage;
  80843. private _tempMeasure;
  80844. get displayThumb(): boolean;
  80845. set displayThumb(value: boolean);
  80846. /**
  80847. * Gets or sets the image used to render the background
  80848. */
  80849. get backgroundImage(): Image;
  80850. set backgroundImage(value: Image);
  80851. /**
  80852. * Gets or sets the image used to render the value bar
  80853. */
  80854. get valueBarImage(): Image;
  80855. set valueBarImage(value: Image);
  80856. /**
  80857. * Gets or sets the image used to render the thumb
  80858. */
  80859. get thumbImage(): Image;
  80860. set thumbImage(value: Image);
  80861. /**
  80862. * Creates a new ImageBasedSlider
  80863. * @param name defines the control name
  80864. */
  80865. constructor(name?: string | undefined);
  80866. protected _getTypeName(): string;
  80867. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80868. }
  80869. }
  80870. declare module BABYLON.GUI {
  80871. /**
  80872. * Forcing an export so that this code will execute
  80873. * @hidden
  80874. */
  80875. const name = "Statics";
  80876. }
  80877. declare module BABYLON.GUI {
  80878. /**
  80879. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  80880. */
  80881. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  80882. /**
  80883. * Define the instrumented AdvancedDynamicTexture.
  80884. */
  80885. texture: AdvancedDynamicTexture;
  80886. private _captureRenderTime;
  80887. private _renderTime;
  80888. private _captureLayoutTime;
  80889. private _layoutTime;
  80890. private _onBeginRenderObserver;
  80891. private _onEndRenderObserver;
  80892. private _onBeginLayoutObserver;
  80893. private _onEndLayoutObserver;
  80894. /**
  80895. * Gets the perf counter used to capture render time
  80896. */
  80897. get renderTimeCounter(): BABYLON.PerfCounter;
  80898. /**
  80899. * Gets the perf counter used to capture layout time
  80900. */
  80901. get layoutTimeCounter(): BABYLON.PerfCounter;
  80902. /**
  80903. * Enable or disable the render time capture
  80904. */
  80905. get captureRenderTime(): boolean;
  80906. set captureRenderTime(value: boolean);
  80907. /**
  80908. * Enable or disable the layout time capture
  80909. */
  80910. get captureLayoutTime(): boolean;
  80911. set captureLayoutTime(value: boolean);
  80912. /**
  80913. * Instantiates a new advanced dynamic texture instrumentation.
  80914. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  80915. * @param texture Defines the AdvancedDynamicTexture to instrument
  80916. */
  80917. constructor(
  80918. /**
  80919. * Define the instrumented AdvancedDynamicTexture.
  80920. */
  80921. texture: AdvancedDynamicTexture);
  80922. /**
  80923. * Dispose and release associated resources.
  80924. */
  80925. dispose(): void;
  80926. }
  80927. }
  80928. declare module BABYLON.GUI {
  80929. /**
  80930. * Class used to load GUI via XML.
  80931. */
  80932. export class XmlLoader {
  80933. private _nodes;
  80934. private _nodeTypes;
  80935. private _isLoaded;
  80936. private _objectAttributes;
  80937. private _parentClass;
  80938. /**
  80939. * Create a new xml loader
  80940. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80941. */
  80942. constructor(parentClass?: null);
  80943. private _getChainElement;
  80944. private _getClassAttribute;
  80945. private _createGuiElement;
  80946. private _parseGrid;
  80947. private _parseElement;
  80948. private _prepareSourceElement;
  80949. private _parseElementsFromSource;
  80950. private _parseXml;
  80951. /**
  80952. * Gets if the loading has finished.
  80953. * @returns whether the loading has finished or not
  80954. */
  80955. isLoaded(): boolean;
  80956. /**
  80957. * Gets a loaded node / control by id.
  80958. * @param id the Controls id set in the xml
  80959. * @returns element of type Control
  80960. */
  80961. getNodeById(id: string): any;
  80962. /**
  80963. * Gets all loaded nodes / controls
  80964. * @returns Array of controls
  80965. */
  80966. getNodes(): any;
  80967. /**
  80968. * Initiates the xml layout loading
  80969. * @param xmlFile defines the xml layout to load
  80970. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  80971. * @param callback defines the callback called on layout load.
  80972. */
  80973. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  80974. }
  80975. }
  80976. declare module BABYLON.GUI {
  80977. /**
  80978. * Class used to create containers for controls
  80979. */
  80980. export class Container3D extends Control3D {
  80981. private _blockLayout;
  80982. /**
  80983. * Gets the list of child controls
  80984. */
  80985. protected _children: Control3D[];
  80986. /**
  80987. * Gets the list of child controls
  80988. */
  80989. get children(): Array<Control3D>;
  80990. /**
  80991. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  80992. * This is helpful to optimize layout operation when adding multiple children in a row
  80993. */
  80994. get blockLayout(): boolean;
  80995. set blockLayout(value: boolean);
  80996. /**
  80997. * Creates a new container
  80998. * @param name defines the container name
  80999. */
  81000. constructor(name?: string);
  81001. /**
  81002. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  81003. * @returns the current container
  81004. */
  81005. updateLayout(): Container3D;
  81006. /**
  81007. * Gets a boolean indicating if the given control is in the children of this control
  81008. * @param control defines the control to check
  81009. * @returns true if the control is in the child list
  81010. */
  81011. containsControl(control: Control3D): boolean;
  81012. /**
  81013. * Adds a control to the children of this control
  81014. * @param control defines the control to add
  81015. * @returns the current container
  81016. */
  81017. addControl(control: Control3D): Container3D;
  81018. /**
  81019. * This function will be called everytime a new control is added
  81020. */
  81021. protected _arrangeChildren(): void;
  81022. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81023. /**
  81024. * Removes a control from the children of this control
  81025. * @param control defines the control to remove
  81026. * @returns the current container
  81027. */
  81028. removeControl(control: Control3D): Container3D;
  81029. protected _getTypeName(): string;
  81030. /**
  81031. * Releases all associated resources
  81032. */
  81033. dispose(): void;
  81034. /** Control rotation will remain unchanged */
  81035. static readonly UNSET_ORIENTATION: number;
  81036. /** Control will rotate to make it look at sphere central axis */
  81037. static readonly FACEORIGIN_ORIENTATION: number;
  81038. /** Control will rotate to make it look back at sphere central axis */
  81039. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  81040. /** Control will rotate to look at z axis (0, 0, 1) */
  81041. static readonly FACEFORWARD_ORIENTATION: number;
  81042. /** Control will rotate to look at negative z axis (0, 0, -1) */
  81043. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  81044. }
  81045. }
  81046. declare module BABYLON.GUI {
  81047. /**
  81048. * Class used to manage 3D user interface
  81049. * @see https://doc.babylonjs.com/how_to/gui3d
  81050. */
  81051. export class GUI3DManager implements BABYLON.IDisposable {
  81052. private _scene;
  81053. private _sceneDisposeObserver;
  81054. private _utilityLayer;
  81055. private _rootContainer;
  81056. private _pointerObserver;
  81057. private _pointerOutObserver;
  81058. /** @hidden */
  81059. _lastPickedControl: Control3D;
  81060. /** @hidden */
  81061. _lastControlOver: {
  81062. [pointerId: number]: Control3D;
  81063. };
  81064. /** @hidden */
  81065. _lastControlDown: {
  81066. [pointerId: number]: Control3D;
  81067. };
  81068. /**
  81069. * BABYLON.Observable raised when the point picked by the pointer events changed
  81070. */
  81071. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  81072. /** @hidden */
  81073. _sharedMaterials: {
  81074. [key: string]: BABYLON.Material;
  81075. };
  81076. /** Gets the hosting scene */
  81077. get scene(): BABYLON.Scene;
  81078. /** Gets associated utility layer */
  81079. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  81080. /**
  81081. * Creates a new GUI3DManager
  81082. * @param scene
  81083. */
  81084. constructor(scene?: BABYLON.Scene);
  81085. private _handlePointerOut;
  81086. private _doPicking;
  81087. /**
  81088. * Gets the root container
  81089. */
  81090. get rootContainer(): Container3D;
  81091. /**
  81092. * Gets a boolean indicating if the given control is in the root child list
  81093. * @param control defines the control to check
  81094. * @returns true if the control is in the root child list
  81095. */
  81096. containsControl(control: Control3D): boolean;
  81097. /**
  81098. * Adds a control to the root child list
  81099. * @param control defines the control to add
  81100. * @returns the current manager
  81101. */
  81102. addControl(control: Control3D): GUI3DManager;
  81103. /**
  81104. * Removes a control from the root child list
  81105. * @param control defines the control to remove
  81106. * @returns the current container
  81107. */
  81108. removeControl(control: Control3D): GUI3DManager;
  81109. /**
  81110. * Releases all associated resources
  81111. */
  81112. dispose(): void;
  81113. }
  81114. }
  81115. declare module BABYLON.GUI {
  81116. /**
  81117. * Class used to transport BABYLON.Vector3 information for pointer events
  81118. */
  81119. export class Vector3WithInfo extends BABYLON.Vector3 {
  81120. /** defines the current mouse button index */
  81121. buttonIndex: number;
  81122. /**
  81123. * Creates a new Vector3WithInfo
  81124. * @param source defines the vector3 data to transport
  81125. * @param buttonIndex defines the current mouse button index
  81126. */
  81127. constructor(source: BABYLON.Vector3,
  81128. /** defines the current mouse button index */
  81129. buttonIndex?: number);
  81130. }
  81131. }
  81132. declare module BABYLON.GUI {
  81133. /**
  81134. * Class used as base class for controls
  81135. */
  81136. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81137. /** Defines the control name */
  81138. name?: string | undefined;
  81139. /** @hidden */
  81140. _host: GUI3DManager;
  81141. private _node;
  81142. private _downCount;
  81143. private _enterCount;
  81144. private _downPointerIds;
  81145. private _isVisible;
  81146. /** Gets or sets the control position in world space */
  81147. get position(): BABYLON.Vector3;
  81148. set position(value: BABYLON.Vector3);
  81149. /** Gets or sets the control scaling in world space */
  81150. get scaling(): BABYLON.Vector3;
  81151. set scaling(value: BABYLON.Vector3);
  81152. /** Callback used to start pointer enter animation */
  81153. pointerEnterAnimation: () => void;
  81154. /** Callback used to start pointer out animation */
  81155. pointerOutAnimation: () => void;
  81156. /** Callback used to start pointer down animation */
  81157. pointerDownAnimation: () => void;
  81158. /** Callback used to start pointer up animation */
  81159. pointerUpAnimation: () => void;
  81160. /**
  81161. * An event triggered when the pointer move over the control
  81162. */
  81163. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81164. /**
  81165. * An event triggered when the pointer move out of the control
  81166. */
  81167. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81168. /**
  81169. * An event triggered when the pointer taps the control
  81170. */
  81171. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81172. /**
  81173. * An event triggered when pointer is up
  81174. */
  81175. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81176. /**
  81177. * An event triggered when a control is clicked on (with a mouse)
  81178. */
  81179. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81180. /**
  81181. * An event triggered when pointer enters the control
  81182. */
  81183. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81184. /**
  81185. * Gets or sets the parent container
  81186. */
  81187. parent: BABYLON.Nullable<Container3D>;
  81188. private _behaviors;
  81189. /**
  81190. * Gets the list of attached behaviors
  81191. * @see https://doc.babylonjs.com/features/behaviour
  81192. */
  81193. get behaviors(): BABYLON.Behavior<Control3D>[];
  81194. /**
  81195. * Attach a behavior to the control
  81196. * @see https://doc.babylonjs.com/features/behaviour
  81197. * @param behavior defines the behavior to attach
  81198. * @returns the current control
  81199. */
  81200. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81201. /**
  81202. * Remove an attached behavior
  81203. * @see https://doc.babylonjs.com/features/behaviour
  81204. * @param behavior defines the behavior to attach
  81205. * @returns the current control
  81206. */
  81207. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81208. /**
  81209. * Gets an attached behavior by name
  81210. * @param name defines the name of the behavior to look for
  81211. * @see https://doc.babylonjs.com/features/behaviour
  81212. * @returns null if behavior was not found else the requested behavior
  81213. */
  81214. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81215. /** Gets or sets a boolean indicating if the control is visible */
  81216. get isVisible(): boolean;
  81217. set isVisible(value: boolean);
  81218. /**
  81219. * Creates a new control
  81220. * @param name defines the control name
  81221. */
  81222. constructor(
  81223. /** Defines the control name */
  81224. name?: string | undefined);
  81225. /**
  81226. * Gets a string representing the class name
  81227. */
  81228. get typeName(): string;
  81229. /**
  81230. * Get the current class name of the control.
  81231. * @returns current class name
  81232. */
  81233. getClassName(): string;
  81234. protected _getTypeName(): string;
  81235. /**
  81236. * Gets the transform node used by this control
  81237. */
  81238. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81239. /**
  81240. * Gets the mesh used to render this control
  81241. */
  81242. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81243. /**
  81244. * Link the control as child of the given node
  81245. * @param node defines the node to link to. Use null to unlink the control
  81246. * @returns the current control
  81247. */
  81248. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81249. /** @hidden **/
  81250. _prepareNode(scene: BABYLON.Scene): void;
  81251. /**
  81252. * Node creation.
  81253. * Can be overriden by children
  81254. * @param scene defines the scene where the node must be attached
  81255. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81256. */
  81257. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81258. /**
  81259. * Affect a material to the given mesh
  81260. * @param mesh defines the mesh which will represent the control
  81261. */
  81262. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81263. /** @hidden */
  81264. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81265. /** @hidden */
  81266. _onPointerEnter(target: Control3D): boolean;
  81267. /** @hidden */
  81268. _onPointerOut(target: Control3D): void;
  81269. /** @hidden */
  81270. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81271. /** @hidden */
  81272. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81273. /** @hidden */
  81274. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81275. /** @hidden */
  81276. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81277. /** @hidden */
  81278. _disposeNode(): void;
  81279. /**
  81280. * Releases all associated resources
  81281. */
  81282. dispose(): void;
  81283. }
  81284. }
  81285. declare module BABYLON.GUI {
  81286. /**
  81287. * Class used as a root to all buttons
  81288. */
  81289. export class AbstractButton3D extends Control3D {
  81290. /**
  81291. * Creates a new button
  81292. * @param name defines the control name
  81293. */
  81294. constructor(name?: string);
  81295. protected _getTypeName(): string;
  81296. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81297. }
  81298. }
  81299. declare module BABYLON.GUI {
  81300. /**
  81301. * Class used to create a button in 3D
  81302. */
  81303. export class Button3D extends AbstractButton3D {
  81304. /** @hidden */
  81305. protected _currentMaterial: BABYLON.Material;
  81306. private _facadeTexture;
  81307. private _content;
  81308. private _contentResolution;
  81309. private _contentScaleRatio;
  81310. /**
  81311. * Gets or sets the texture resolution used to render content (512 by default)
  81312. */
  81313. get contentResolution(): BABYLON.int;
  81314. set contentResolution(value: BABYLON.int);
  81315. /**
  81316. * Gets or sets the texture scale ratio used to render content (2 by default)
  81317. */
  81318. get contentScaleRatio(): number;
  81319. set contentScaleRatio(value: number);
  81320. protected _disposeFacadeTexture(): void;
  81321. protected _resetContent(): void;
  81322. /**
  81323. * Creates a new button
  81324. * @param name defines the control name
  81325. */
  81326. constructor(name?: string);
  81327. /**
  81328. * Gets or sets the GUI 2D content used to display the button's facade
  81329. */
  81330. get content(): Control;
  81331. set content(value: Control);
  81332. /**
  81333. * Apply the facade texture (created from the content property).
  81334. * This function can be overloaded by child classes
  81335. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81336. */
  81337. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81338. protected _getTypeName(): string;
  81339. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81340. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81341. /**
  81342. * Releases all associated resources
  81343. */
  81344. dispose(): void;
  81345. }
  81346. }
  81347. declare module BABYLON.GUI {
  81348. /**
  81349. * Abstract class used to create a container panel deployed on the surface of a volume
  81350. */
  81351. export abstract class VolumeBasedPanel extends Container3D {
  81352. private _columns;
  81353. private _rows;
  81354. private _rowThenColum;
  81355. private _orientation;
  81356. protected _cellWidth: number;
  81357. protected _cellHeight: number;
  81358. /**
  81359. * Gets or sets the distance between elements
  81360. */
  81361. margin: number;
  81362. /**
  81363. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81364. * | Value | Type | Description |
  81365. * | ----- | ----------------------------------- | ----------- |
  81366. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81367. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81368. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81369. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81370. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  81371. */
  81372. get orientation(): number;
  81373. set orientation(value: number);
  81374. /**
  81375. * Gets or sets the number of columns requested (10 by default).
  81376. * The panel will automatically compute the number of rows based on number of child controls.
  81377. */
  81378. get columns(): BABYLON.int;
  81379. set columns(value: BABYLON.int);
  81380. /**
  81381. * Gets or sets a the number of rows requested.
  81382. * The panel will automatically compute the number of columns based on number of child controls.
  81383. */
  81384. get rows(): BABYLON.int;
  81385. set rows(value: BABYLON.int);
  81386. /**
  81387. * Creates new VolumeBasedPanel
  81388. */
  81389. constructor();
  81390. protected _arrangeChildren(): void;
  81391. /** Child classes must implement this function to provide correct control positioning */
  81392. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81393. /** Child classes can implement this function to provide additional processing */
  81394. protected _finalProcessing(): void;
  81395. }
  81396. }
  81397. declare module BABYLON.GUI {
  81398. /**
  81399. * Class used to create a container panel deployed on the surface of a cylinder
  81400. */
  81401. export class CylinderPanel extends VolumeBasedPanel {
  81402. private _radius;
  81403. /**
  81404. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  81405. */
  81406. get radius(): BABYLON.float;
  81407. set radius(value: BABYLON.float);
  81408. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81409. private _cylindricalMapping;
  81410. }
  81411. }
  81412. declare module BABYLON.GUI {
  81413. /** @hidden */
  81414. export var fluentVertexShader: {
  81415. name: string;
  81416. shader: string;
  81417. };
  81418. }
  81419. declare module BABYLON.GUI {
  81420. /** @hidden */
  81421. export var fluentPixelShader: {
  81422. name: string;
  81423. shader: string;
  81424. };
  81425. }
  81426. declare module BABYLON.GUI {
  81427. /** @hidden */
  81428. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81429. INNERGLOW: boolean;
  81430. BORDER: boolean;
  81431. HOVERLIGHT: boolean;
  81432. TEXTURE: boolean;
  81433. constructor();
  81434. }
  81435. /**
  81436. * Class used to render controls with fluent desgin
  81437. */
  81438. export class FluentMaterial extends BABYLON.PushMaterial {
  81439. /**
  81440. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81441. */
  81442. innerGlowColorIntensity: number;
  81443. /**
  81444. * Gets or sets the inner glow color (white by default)
  81445. */
  81446. innerGlowColor: BABYLON.Color3;
  81447. /**
  81448. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81449. */
  81450. albedoColor: BABYLON.Color3;
  81451. /**
  81452. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81453. */
  81454. renderBorders: boolean;
  81455. /**
  81456. * Gets or sets border width (default is 0.5)
  81457. */
  81458. borderWidth: number;
  81459. /**
  81460. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  81461. */
  81462. edgeSmoothingValue: number;
  81463. /**
  81464. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81465. */
  81466. borderMinValue: number;
  81467. /**
  81468. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81469. */
  81470. renderHoverLight: boolean;
  81471. /**
  81472. * Gets or sets the radius used to render the hover light (default is 1.0)
  81473. */
  81474. hoverRadius: number;
  81475. /**
  81476. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81477. */
  81478. hoverColor: BABYLON.Color4;
  81479. /**
  81480. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81481. */
  81482. hoverPosition: BABYLON.Vector3;
  81483. private _albedoTexture;
  81484. /** Gets or sets the texture to use for albedo color */
  81485. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81486. /**
  81487. * Creates a new Fluent material
  81488. * @param name defines the name of the material
  81489. * @param scene defines the hosting scene
  81490. */
  81491. constructor(name: string, scene: BABYLON.Scene);
  81492. needAlphaBlending(): boolean;
  81493. needAlphaTesting(): boolean;
  81494. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81495. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81496. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81497. getActiveTextures(): BABYLON.BaseTexture[];
  81498. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81499. dispose(forceDisposeEffect?: boolean): void;
  81500. clone(name: string): FluentMaterial;
  81501. serialize(): any;
  81502. getClassName(): string;
  81503. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81504. }
  81505. }
  81506. declare module BABYLON.GUI {
  81507. /**
  81508. * Class used to create a holographic button in 3D
  81509. */
  81510. export class HolographicButton extends Button3D {
  81511. private _backPlate;
  81512. private _textPlate;
  81513. private _frontPlate;
  81514. private _text;
  81515. private _imageUrl;
  81516. private _shareMaterials;
  81517. private _frontMaterial;
  81518. private _backMaterial;
  81519. private _plateMaterial;
  81520. private _pickedPointObserver;
  81521. private _tooltipFade;
  81522. private _tooltipTextBlock;
  81523. private _tooltipTexture;
  81524. private _tooltipMesh;
  81525. private _tooltipHoverObserver;
  81526. private _tooltipOutObserver;
  81527. private _disposeTooltip;
  81528. /**
  81529. * Rendering ground id of all the mesh in the button
  81530. */
  81531. set renderingGroupId(id: number);
  81532. get renderingGroupId(): number;
  81533. /**
  81534. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81535. */
  81536. set tooltipText(text: BABYLON.Nullable<string>);
  81537. get tooltipText(): BABYLON.Nullable<string>;
  81538. /**
  81539. * Gets or sets text for the button
  81540. */
  81541. get text(): string;
  81542. set text(value: string);
  81543. /**
  81544. * Gets or sets the image url for the button
  81545. */
  81546. get imageUrl(): string;
  81547. set imageUrl(value: string);
  81548. /**
  81549. * Gets the back material used by this button
  81550. */
  81551. get backMaterial(): FluentMaterial;
  81552. /**
  81553. * Gets the front material used by this button
  81554. */
  81555. get frontMaterial(): FluentMaterial;
  81556. /**
  81557. * Gets the plate material used by this button
  81558. */
  81559. get plateMaterial(): BABYLON.StandardMaterial;
  81560. /**
  81561. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81562. */
  81563. get shareMaterials(): boolean;
  81564. /**
  81565. * Creates a new button
  81566. * @param name defines the control name
  81567. */
  81568. constructor(name?: string, shareMaterials?: boolean);
  81569. protected _getTypeName(): string;
  81570. private _rebuildContent;
  81571. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81572. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81573. private _createBackMaterial;
  81574. private _createFrontMaterial;
  81575. private _createPlateMaterial;
  81576. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  81577. /**
  81578. * Releases all associated resources
  81579. */
  81580. dispose(): void;
  81581. }
  81582. }
  81583. declare module BABYLON.GUI {
  81584. /**
  81585. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  81586. */
  81587. export class MeshButton3D extends Button3D {
  81588. /** @hidden */
  81589. protected _currentMesh: BABYLON.Mesh;
  81590. /**
  81591. * Creates a new 3D button based on a mesh
  81592. * @param mesh mesh to become a 3D button
  81593. * @param name defines the control name
  81594. */
  81595. constructor(mesh: BABYLON.Mesh, name?: string);
  81596. protected _getTypeName(): string;
  81597. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81598. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81599. }
  81600. }
  81601. declare module BABYLON.GUI {
  81602. /**
  81603. * Class used to create a container panel deployed on the surface of a plane
  81604. */
  81605. export class PlanePanel extends VolumeBasedPanel {
  81606. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81607. }
  81608. }
  81609. declare module BABYLON.GUI {
  81610. /**
  81611. * Class used to create a container panel where items get randomized planar mapping
  81612. */
  81613. export class ScatterPanel extends VolumeBasedPanel {
  81614. private _iteration;
  81615. /**
  81616. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81617. */
  81618. get iteration(): BABYLON.float;
  81619. set iteration(value: BABYLON.float);
  81620. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81621. private _scatterMapping;
  81622. protected _finalProcessing(): void;
  81623. }
  81624. }
  81625. declare module BABYLON.GUI {
  81626. /**
  81627. * Class used to create a container panel deployed on the surface of a sphere
  81628. */
  81629. export class SpherePanel extends VolumeBasedPanel {
  81630. private _radius;
  81631. /**
  81632. * Gets or sets the radius of the sphere where to project controls (5 by default)
  81633. */
  81634. get radius(): BABYLON.float;
  81635. set radius(value: BABYLON.float);
  81636. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81637. private _sphericalMapping;
  81638. }
  81639. }
  81640. declare module BABYLON.GUI {
  81641. /**
  81642. * Class used to create a stack panel in 3D on XY plane
  81643. */
  81644. export class StackPanel3D extends Container3D {
  81645. private _isVertical;
  81646. /**
  81647. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  81648. */
  81649. get isVertical(): boolean;
  81650. set isVertical(value: boolean);
  81651. /**
  81652. * Gets or sets the distance between elements
  81653. */
  81654. margin: number;
  81655. /**
  81656. * Creates new StackPanel
  81657. * @param isVertical
  81658. */
  81659. constructor(isVertical?: boolean);
  81660. protected _arrangeChildren(): void;
  81661. }
  81662. }
  81663. declare module BABYLON {
  81664. /**
  81665. * Configuration for glTF validation
  81666. */
  81667. export interface IGLTFValidationConfiguration {
  81668. /**
  81669. * The url of the glTF validator.
  81670. */
  81671. url: string;
  81672. }
  81673. /**
  81674. * glTF validation
  81675. */
  81676. export class GLTFValidation {
  81677. /**
  81678. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  81679. */
  81680. static Configuration: IGLTFValidationConfiguration;
  81681. private static _LoadScriptPromise;
  81682. /**
  81683. * Validate a glTF asset using the glTF-Validator.
  81684. * @param data The JSON of a glTF or the array buffer of a binary glTF
  81685. * @param rootUrl The root url for the glTF
  81686. * @param fileName The file name for the glTF
  81687. * @param getExternalResource The callback to get external resources for the glTF validator
  81688. * @returns A promise that resolves with the glTF validation results once complete
  81689. */
  81690. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  81691. }
  81692. }
  81693. declare module BABYLON {
  81694. /**
  81695. * Mode that determines the coordinate system to use.
  81696. */
  81697. export enum GLTFLoaderCoordinateSystemMode {
  81698. /**
  81699. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  81700. */
  81701. AUTO = 0,
  81702. /**
  81703. * Sets the useRightHandedSystem flag on the scene.
  81704. */
  81705. FORCE_RIGHT_HANDED = 1
  81706. }
  81707. /**
  81708. * Mode that determines what animations will start.
  81709. */
  81710. export enum GLTFLoaderAnimationStartMode {
  81711. /**
  81712. * No animation will start.
  81713. */
  81714. NONE = 0,
  81715. /**
  81716. * The first animation will start.
  81717. */
  81718. FIRST = 1,
  81719. /**
  81720. * All animations will start.
  81721. */
  81722. ALL = 2
  81723. }
  81724. /**
  81725. * Interface that contains the data for the glTF asset.
  81726. */
  81727. export interface IGLTFLoaderData {
  81728. /**
  81729. * The object that represents the glTF JSON.
  81730. */
  81731. json: Object;
  81732. /**
  81733. * The BIN chunk of a binary glTF.
  81734. */
  81735. bin: Nullable<IDataBuffer>;
  81736. }
  81737. /**
  81738. * Interface for extending the loader.
  81739. */
  81740. export interface IGLTFLoaderExtension {
  81741. /**
  81742. * The name of this extension.
  81743. */
  81744. readonly name: string;
  81745. /**
  81746. * Defines whether this extension is enabled.
  81747. */
  81748. enabled: boolean;
  81749. /**
  81750. * Defines the order of this extension.
  81751. * The loader sorts the extensions using these values when loading.
  81752. */
  81753. order?: number;
  81754. }
  81755. /**
  81756. * Loader state.
  81757. */
  81758. export enum GLTFLoaderState {
  81759. /**
  81760. * The asset is loading.
  81761. */
  81762. LOADING = 0,
  81763. /**
  81764. * The asset is ready for rendering.
  81765. */
  81766. READY = 1,
  81767. /**
  81768. * The asset is completely loaded.
  81769. */
  81770. COMPLETE = 2
  81771. }
  81772. /** @hidden */
  81773. export interface IImportMeshAsyncOutput {
  81774. meshes: AbstractMesh[];
  81775. geometries: Geometry[];
  81776. particleSystems: IParticleSystem[];
  81777. skeletons: Skeleton[];
  81778. animationGroups: AnimationGroup[];
  81779. lights: Light[];
  81780. transformNodes: TransformNode[];
  81781. }
  81782. /** @hidden */
  81783. export interface IGLTFLoader extends IDisposable {
  81784. readonly state: Nullable<GLTFLoaderState>;
  81785. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  81786. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  81787. }
  81788. /**
  81789. * File loader for loading glTF files into a scene.
  81790. */
  81791. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81792. /** @hidden */
  81793. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81794. /** @hidden */
  81795. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81796. /**
  81797. * Raised when the asset has been parsed
  81798. */
  81799. onParsedObservable: Observable<IGLTFLoaderData>;
  81800. private _onParsedObserver;
  81801. /**
  81802. * Raised when the asset has been parsed
  81803. */
  81804. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  81805. /**
  81806. * 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.
  81807. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  81808. * Defaults to true.
  81809. * @hidden
  81810. */
  81811. static IncrementalLoading: boolean;
  81812. /**
  81813. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  81814. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  81815. * @hidden
  81816. */
  81817. static HomogeneousCoordinates: boolean;
  81818. /**
  81819. * The coordinate system mode. Defaults to AUTO.
  81820. */
  81821. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  81822. /**
  81823. * The animation start mode. Defaults to FIRST.
  81824. */
  81825. animationStartMode: GLTFLoaderAnimationStartMode;
  81826. /**
  81827. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  81828. */
  81829. compileMaterials: boolean;
  81830. /**
  81831. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  81832. */
  81833. useClipPlane: boolean;
  81834. /**
  81835. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  81836. */
  81837. compileShadowGenerators: boolean;
  81838. /**
  81839. * Defines if the Alpha blended materials are only applied as coverage.
  81840. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  81841. * If true, no extra effects are applied to transparent pixels.
  81842. */
  81843. transparencyAsCoverage: boolean;
  81844. /**
  81845. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  81846. * Enabling will disable offline support and glTF validator.
  81847. * Defaults to false.
  81848. */
  81849. useRangeRequests: boolean;
  81850. /**
  81851. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  81852. */
  81853. createInstances: boolean;
  81854. /**
  81855. * 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.
  81856. */
  81857. alwaysComputeBoundingBox: boolean;
  81858. /**
  81859. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  81860. */
  81861. loadAllMaterials: boolean;
  81862. /**
  81863. * Function called before loading a url referenced by the asset.
  81864. */
  81865. preprocessUrlAsync: (url: string) => Promise<string>;
  81866. /**
  81867. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81868. * 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, ...)
  81869. */
  81870. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  81871. private _onMeshLoadedObserver;
  81872. /**
  81873. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81874. * 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, ...)
  81875. */
  81876. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  81877. /**
  81878. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  81879. */
  81880. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  81881. private _onTextureLoadedObserver;
  81882. /**
  81883. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  81884. */
  81885. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  81886. /**
  81887. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  81888. */
  81889. readonly onMaterialLoadedObservable: Observable<Material>;
  81890. private _onMaterialLoadedObserver;
  81891. /**
  81892. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  81893. */
  81894. set onMaterialLoaded(callback: (material: Material) => void);
  81895. /**
  81896. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  81897. */
  81898. readonly onCameraLoadedObservable: Observable<Camera>;
  81899. private _onCameraLoadedObserver;
  81900. /**
  81901. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  81902. */
  81903. set onCameraLoaded(callback: (camera: Camera) => void);
  81904. /**
  81905. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  81906. * For assets with LODs, raised when all of the LODs are complete.
  81907. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81908. */
  81909. readonly onCompleteObservable: Observable<void>;
  81910. private _onCompleteObserver;
  81911. /**
  81912. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  81913. * For assets with LODs, raised when all of the LODs are complete.
  81914. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81915. */
  81916. set onComplete(callback: () => void);
  81917. /**
  81918. * Observable raised when an error occurs.
  81919. */
  81920. readonly onErrorObservable: Observable<any>;
  81921. private _onErrorObserver;
  81922. /**
  81923. * Callback raised when an error occurs.
  81924. */
  81925. set onError(callback: (reason: any) => void);
  81926. /**
  81927. * Observable raised after the loader is disposed.
  81928. */
  81929. readonly onDisposeObservable: Observable<void>;
  81930. private _onDisposeObserver;
  81931. /**
  81932. * Callback raised after the loader is disposed.
  81933. */
  81934. set onDispose(callback: () => void);
  81935. /**
  81936. * Observable raised after a loader extension is created.
  81937. * Set additional options for a loader extension in this event.
  81938. */
  81939. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81940. private _onExtensionLoadedObserver;
  81941. /**
  81942. * Callback raised after a loader extension is created.
  81943. */
  81944. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  81945. /**
  81946. * Defines if the loader logging is enabled.
  81947. */
  81948. get loggingEnabled(): boolean;
  81949. set loggingEnabled(value: boolean);
  81950. /**
  81951. * Defines if the loader should capture performance counters.
  81952. */
  81953. get capturePerformanceCounters(): boolean;
  81954. set capturePerformanceCounters(value: boolean);
  81955. /**
  81956. * Defines if the loader should validate the asset.
  81957. */
  81958. validate: boolean;
  81959. /**
  81960. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  81961. */
  81962. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  81963. private _onValidatedObserver;
  81964. /**
  81965. * Callback raised after a loader extension is created.
  81966. */
  81967. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  81968. private _loader;
  81969. private _progressCallback?;
  81970. private _requests;
  81971. private static magicBase64Encoded;
  81972. /**
  81973. * Name of the loader ("gltf")
  81974. */
  81975. name: string;
  81976. /** @hidden */
  81977. extensions: ISceneLoaderPluginExtensions;
  81978. /**
  81979. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  81980. */
  81981. dispose(): void;
  81982. /** @hidden */
  81983. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81984. /** @hidden */
  81985. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81986. /** @hidden */
  81987. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81988. meshes: AbstractMesh[];
  81989. particleSystems: IParticleSystem[];
  81990. skeletons: Skeleton[];
  81991. animationGroups: AnimationGroup[];
  81992. }>;
  81993. /** @hidden */
  81994. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81995. /** @hidden */
  81996. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81997. /** @hidden */
  81998. canDirectLoad(data: string): boolean;
  81999. /** @hidden */
  82000. directLoad(scene: Scene, data: string): Promise<any>;
  82001. /**
  82002. * The callback that allows custom handling of the root url based on the response url.
  82003. * @param rootUrl the original root url
  82004. * @param responseURL the response url if available
  82005. * @returns the new root url
  82006. */
  82007. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  82008. /** @hidden */
  82009. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  82010. /**
  82011. * The loader state or null if the loader is not active.
  82012. */
  82013. get loaderState(): Nullable<GLTFLoaderState>;
  82014. /**
  82015. * Returns a promise that resolves when the asset is completely loaded.
  82016. * @returns a promise that resolves when the asset is completely loaded.
  82017. */
  82018. whenCompleteAsync(): Promise<void>;
  82019. /** @hidden */
  82020. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  82021. /** @hidden */
  82022. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  82023. private _onProgress;
  82024. private _validate;
  82025. private _getLoader;
  82026. private _parseJson;
  82027. private _unpackBinaryAsync;
  82028. private _unpackBinaryV1Async;
  82029. private _unpackBinaryV2Async;
  82030. private static _parseVersion;
  82031. private static _compareVersion;
  82032. private static readonly _logSpaces;
  82033. private _logIndentLevel;
  82034. private _loggingEnabled;
  82035. /** @hidden */
  82036. _log: (message: string) => void;
  82037. /** @hidden */
  82038. _logOpen(message: string): void;
  82039. /** @hidden */
  82040. _logClose(): void;
  82041. private _logEnabled;
  82042. private _logDisabled;
  82043. private _capturePerformanceCounters;
  82044. /** @hidden */
  82045. _startPerformanceCounter: (counterName: string) => void;
  82046. /** @hidden */
  82047. _endPerformanceCounter: (counterName: string) => void;
  82048. private _startPerformanceCounterEnabled;
  82049. private _startPerformanceCounterDisabled;
  82050. private _endPerformanceCounterEnabled;
  82051. private _endPerformanceCounterDisabled;
  82052. }
  82053. }
  82054. declare module BABYLON.GLTF1 {
  82055. /**
  82056. * Enums
  82057. * @hidden
  82058. */
  82059. export enum EComponentType {
  82060. BYTE = 5120,
  82061. UNSIGNED_BYTE = 5121,
  82062. SHORT = 5122,
  82063. UNSIGNED_SHORT = 5123,
  82064. FLOAT = 5126
  82065. }
  82066. /** @hidden */
  82067. export enum EShaderType {
  82068. FRAGMENT = 35632,
  82069. VERTEX = 35633
  82070. }
  82071. /** @hidden */
  82072. export enum EParameterType {
  82073. BYTE = 5120,
  82074. UNSIGNED_BYTE = 5121,
  82075. SHORT = 5122,
  82076. UNSIGNED_SHORT = 5123,
  82077. INT = 5124,
  82078. UNSIGNED_INT = 5125,
  82079. FLOAT = 5126,
  82080. FLOAT_VEC2 = 35664,
  82081. FLOAT_VEC3 = 35665,
  82082. FLOAT_VEC4 = 35666,
  82083. INT_VEC2 = 35667,
  82084. INT_VEC3 = 35668,
  82085. INT_VEC4 = 35669,
  82086. BOOL = 35670,
  82087. BOOL_VEC2 = 35671,
  82088. BOOL_VEC3 = 35672,
  82089. BOOL_VEC4 = 35673,
  82090. FLOAT_MAT2 = 35674,
  82091. FLOAT_MAT3 = 35675,
  82092. FLOAT_MAT4 = 35676,
  82093. SAMPLER_2D = 35678
  82094. }
  82095. /** @hidden */
  82096. export enum ETextureWrapMode {
  82097. CLAMP_TO_EDGE = 33071,
  82098. MIRRORED_REPEAT = 33648,
  82099. REPEAT = 10497
  82100. }
  82101. /** @hidden */
  82102. export enum ETextureFilterType {
  82103. NEAREST = 9728,
  82104. LINEAR = 9728,
  82105. NEAREST_MIPMAP_NEAREST = 9984,
  82106. LINEAR_MIPMAP_NEAREST = 9985,
  82107. NEAREST_MIPMAP_LINEAR = 9986,
  82108. LINEAR_MIPMAP_LINEAR = 9987
  82109. }
  82110. /** @hidden */
  82111. export enum ETextureFormat {
  82112. ALPHA = 6406,
  82113. RGB = 6407,
  82114. RGBA = 6408,
  82115. LUMINANCE = 6409,
  82116. LUMINANCE_ALPHA = 6410
  82117. }
  82118. /** @hidden */
  82119. export enum ECullingType {
  82120. FRONT = 1028,
  82121. BACK = 1029,
  82122. FRONT_AND_BACK = 1032
  82123. }
  82124. /** @hidden */
  82125. export enum EBlendingFunction {
  82126. ZERO = 0,
  82127. ONE = 1,
  82128. SRC_COLOR = 768,
  82129. ONE_MINUS_SRC_COLOR = 769,
  82130. DST_COLOR = 774,
  82131. ONE_MINUS_DST_COLOR = 775,
  82132. SRC_ALPHA = 770,
  82133. ONE_MINUS_SRC_ALPHA = 771,
  82134. DST_ALPHA = 772,
  82135. ONE_MINUS_DST_ALPHA = 773,
  82136. CONSTANT_COLOR = 32769,
  82137. ONE_MINUS_CONSTANT_COLOR = 32770,
  82138. CONSTANT_ALPHA = 32771,
  82139. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82140. SRC_ALPHA_SATURATE = 776
  82141. }
  82142. /** @hidden */
  82143. export interface IGLTFProperty {
  82144. extensions?: {
  82145. [key: string]: any;
  82146. };
  82147. extras?: Object;
  82148. }
  82149. /** @hidden */
  82150. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82151. name?: string;
  82152. }
  82153. /** @hidden */
  82154. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82155. bufferView: string;
  82156. byteOffset: number;
  82157. byteStride: number;
  82158. count: number;
  82159. type: string;
  82160. componentType: EComponentType;
  82161. max?: number[];
  82162. min?: number[];
  82163. name?: string;
  82164. }
  82165. /** @hidden */
  82166. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82167. buffer: string;
  82168. byteOffset: number;
  82169. byteLength: number;
  82170. byteStride: number;
  82171. target?: number;
  82172. }
  82173. /** @hidden */
  82174. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82175. uri: string;
  82176. byteLength?: number;
  82177. type?: string;
  82178. }
  82179. /** @hidden */
  82180. export interface IGLTFShader extends IGLTFChildRootProperty {
  82181. uri: string;
  82182. type: EShaderType;
  82183. }
  82184. /** @hidden */
  82185. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82186. attributes: string[];
  82187. fragmentShader: string;
  82188. vertexShader: string;
  82189. }
  82190. /** @hidden */
  82191. export interface IGLTFTechniqueParameter {
  82192. type: number;
  82193. count?: number;
  82194. semantic?: string;
  82195. node?: string;
  82196. value?: number | boolean | string | Array<any>;
  82197. source?: string;
  82198. babylonValue?: any;
  82199. }
  82200. /** @hidden */
  82201. export interface IGLTFTechniqueCommonProfile {
  82202. lightingModel: string;
  82203. texcoordBindings: Object;
  82204. parameters?: Array<any>;
  82205. }
  82206. /** @hidden */
  82207. export interface IGLTFTechniqueStatesFunctions {
  82208. blendColor?: number[];
  82209. blendEquationSeparate?: number[];
  82210. blendFuncSeparate?: number[];
  82211. colorMask: boolean[];
  82212. cullFace: number[];
  82213. }
  82214. /** @hidden */
  82215. export interface IGLTFTechniqueStates {
  82216. enable: number[];
  82217. functions: IGLTFTechniqueStatesFunctions;
  82218. }
  82219. /** @hidden */
  82220. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82221. parameters: {
  82222. [key: string]: IGLTFTechniqueParameter;
  82223. };
  82224. program: string;
  82225. attributes: {
  82226. [key: string]: string;
  82227. };
  82228. uniforms: {
  82229. [key: string]: string;
  82230. };
  82231. states: IGLTFTechniqueStates;
  82232. }
  82233. /** @hidden */
  82234. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82235. technique?: string;
  82236. values: string[];
  82237. }
  82238. /** @hidden */
  82239. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82240. attributes: {
  82241. [key: string]: string;
  82242. };
  82243. indices: string;
  82244. material: string;
  82245. mode?: number;
  82246. }
  82247. /** @hidden */
  82248. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82249. primitives: IGLTFMeshPrimitive[];
  82250. }
  82251. /** @hidden */
  82252. export interface IGLTFImage extends IGLTFChildRootProperty {
  82253. uri: string;
  82254. }
  82255. /** @hidden */
  82256. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82257. magFilter?: number;
  82258. minFilter?: number;
  82259. wrapS?: number;
  82260. wrapT?: number;
  82261. }
  82262. /** @hidden */
  82263. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82264. sampler: string;
  82265. source: string;
  82266. format?: ETextureFormat;
  82267. internalFormat?: ETextureFormat;
  82268. target?: number;
  82269. type?: number;
  82270. babylonTexture?: Texture;
  82271. }
  82272. /** @hidden */
  82273. export interface IGLTFAmbienLight {
  82274. color?: number[];
  82275. }
  82276. /** @hidden */
  82277. export interface IGLTFDirectionalLight {
  82278. color?: number[];
  82279. }
  82280. /** @hidden */
  82281. export interface IGLTFPointLight {
  82282. color?: number[];
  82283. constantAttenuation?: number;
  82284. linearAttenuation?: number;
  82285. quadraticAttenuation?: number;
  82286. }
  82287. /** @hidden */
  82288. export interface IGLTFSpotLight {
  82289. color?: number[];
  82290. constantAttenuation?: number;
  82291. fallOfAngle?: number;
  82292. fallOffExponent?: number;
  82293. linearAttenuation?: number;
  82294. quadraticAttenuation?: number;
  82295. }
  82296. /** @hidden */
  82297. export interface IGLTFLight extends IGLTFChildRootProperty {
  82298. type: string;
  82299. }
  82300. /** @hidden */
  82301. export interface IGLTFCameraOrthographic {
  82302. xmag: number;
  82303. ymag: number;
  82304. zfar: number;
  82305. znear: number;
  82306. }
  82307. /** @hidden */
  82308. export interface IGLTFCameraPerspective {
  82309. aspectRatio: number;
  82310. yfov: number;
  82311. zfar: number;
  82312. znear: number;
  82313. }
  82314. /** @hidden */
  82315. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82316. type: string;
  82317. }
  82318. /** @hidden */
  82319. export interface IGLTFAnimationChannelTarget {
  82320. id: string;
  82321. path: string;
  82322. }
  82323. /** @hidden */
  82324. export interface IGLTFAnimationChannel {
  82325. sampler: string;
  82326. target: IGLTFAnimationChannelTarget;
  82327. }
  82328. /** @hidden */
  82329. export interface IGLTFAnimationSampler {
  82330. input: string;
  82331. output: string;
  82332. interpolation?: string;
  82333. }
  82334. /** @hidden */
  82335. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82336. channels?: IGLTFAnimationChannel[];
  82337. parameters?: {
  82338. [key: string]: string;
  82339. };
  82340. samplers?: {
  82341. [key: string]: IGLTFAnimationSampler;
  82342. };
  82343. }
  82344. /** @hidden */
  82345. export interface IGLTFNodeInstanceSkin {
  82346. skeletons: string[];
  82347. skin: string;
  82348. meshes: string[];
  82349. }
  82350. /** @hidden */
  82351. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82352. bindShapeMatrix: number[];
  82353. inverseBindMatrices: string;
  82354. jointNames: string[];
  82355. babylonSkeleton?: Skeleton;
  82356. }
  82357. /** @hidden */
  82358. export interface IGLTFNode extends IGLTFChildRootProperty {
  82359. camera?: string;
  82360. children: string[];
  82361. skin?: string;
  82362. jointName?: string;
  82363. light?: string;
  82364. matrix: number[];
  82365. mesh?: string;
  82366. meshes?: string[];
  82367. rotation?: number[];
  82368. scale?: number[];
  82369. translation?: number[];
  82370. babylonNode?: Node;
  82371. }
  82372. /** @hidden */
  82373. export interface IGLTFScene extends IGLTFChildRootProperty {
  82374. nodes: string[];
  82375. }
  82376. /** @hidden */
  82377. export interface IGLTFRuntime {
  82378. extensions: {
  82379. [key: string]: any;
  82380. };
  82381. accessors: {
  82382. [key: string]: IGLTFAccessor;
  82383. };
  82384. buffers: {
  82385. [key: string]: IGLTFBuffer;
  82386. };
  82387. bufferViews: {
  82388. [key: string]: IGLTFBufferView;
  82389. };
  82390. meshes: {
  82391. [key: string]: IGLTFMesh;
  82392. };
  82393. lights: {
  82394. [key: string]: IGLTFLight;
  82395. };
  82396. cameras: {
  82397. [key: string]: IGLTFCamera;
  82398. };
  82399. nodes: {
  82400. [key: string]: IGLTFNode;
  82401. };
  82402. images: {
  82403. [key: string]: IGLTFImage;
  82404. };
  82405. textures: {
  82406. [key: string]: IGLTFTexture;
  82407. };
  82408. shaders: {
  82409. [key: string]: IGLTFShader;
  82410. };
  82411. programs: {
  82412. [key: string]: IGLTFProgram;
  82413. };
  82414. samplers: {
  82415. [key: string]: IGLTFSampler;
  82416. };
  82417. techniques: {
  82418. [key: string]: IGLTFTechnique;
  82419. };
  82420. materials: {
  82421. [key: string]: IGLTFMaterial;
  82422. };
  82423. animations: {
  82424. [key: string]: IGLTFAnimation;
  82425. };
  82426. skins: {
  82427. [key: string]: IGLTFSkins;
  82428. };
  82429. currentScene?: Object;
  82430. scenes: {
  82431. [key: string]: IGLTFScene;
  82432. };
  82433. extensionsUsed: string[];
  82434. extensionsRequired?: string[];
  82435. buffersCount: number;
  82436. shaderscount: number;
  82437. scene: Scene;
  82438. rootUrl: string;
  82439. loadedBufferCount: number;
  82440. loadedBufferViews: {
  82441. [name: string]: ArrayBufferView;
  82442. };
  82443. loadedShaderCount: number;
  82444. importOnlyMeshes: boolean;
  82445. importMeshesNames?: string[];
  82446. dummyNodes: Node[];
  82447. forAssetContainer: boolean;
  82448. }
  82449. /** @hidden */
  82450. export interface INodeToRoot {
  82451. bone: Bone;
  82452. node: IGLTFNode;
  82453. id: string;
  82454. }
  82455. /** @hidden */
  82456. export interface IJointNode {
  82457. node: IGLTFNode;
  82458. id: string;
  82459. }
  82460. }
  82461. declare module BABYLON.GLTF1 {
  82462. /**
  82463. * Utils functions for GLTF
  82464. * @hidden
  82465. */
  82466. export class GLTFUtils {
  82467. /**
  82468. * Sets the given "parameter" matrix
  82469. * @param scene: the Scene object
  82470. * @param source: the source node where to pick the matrix
  82471. * @param parameter: the GLTF technique parameter
  82472. * @param uniformName: the name of the shader's uniform
  82473. * @param shaderMaterial: the shader material
  82474. */
  82475. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82476. /**
  82477. * Sets the given "parameter" matrix
  82478. * @param shaderMaterial: the shader material
  82479. * @param uniform: the name of the shader's uniform
  82480. * @param value: the value of the uniform
  82481. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82482. */
  82483. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82484. /**
  82485. * Returns the wrap mode of the texture
  82486. * @param mode: the mode value
  82487. */
  82488. static GetWrapMode(mode: number): number;
  82489. /**
  82490. * Returns the byte stride giving an accessor
  82491. * @param accessor: the GLTF accessor objet
  82492. */
  82493. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82494. /**
  82495. * Returns the texture filter mode giving a mode value
  82496. * @param mode: the filter mode value
  82497. */
  82498. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82499. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82500. /**
  82501. * Returns a buffer from its accessor
  82502. * @param gltfRuntime: the GLTF runtime
  82503. * @param accessor: the GLTF accessor
  82504. */
  82505. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82506. /**
  82507. * Decodes a buffer view into a string
  82508. * @param view: the buffer view
  82509. */
  82510. static DecodeBufferToText(view: ArrayBufferView): string;
  82511. /**
  82512. * Returns the default material of gltf. Related to
  82513. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82514. * @param scene: the Babylon.js scene
  82515. */
  82516. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82517. private static _DefaultMaterial;
  82518. }
  82519. }
  82520. declare module BABYLON.GLTF1 {
  82521. /**
  82522. * Implementation of the base glTF spec
  82523. * @hidden
  82524. */
  82525. export class GLTFLoaderBase {
  82526. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82527. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82528. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82529. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82530. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82531. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82532. }
  82533. /**
  82534. * glTF V1 Loader
  82535. * @hidden
  82536. */
  82537. export class GLTFLoader implements IGLTFLoader {
  82538. static Extensions: {
  82539. [name: string]: GLTFLoaderExtension;
  82540. };
  82541. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82542. state: Nullable<GLTFLoaderState>;
  82543. dispose(): void;
  82544. private _importMeshAsync;
  82545. /**
  82546. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82547. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82548. * @param scene the scene the meshes should be added to
  82549. * @param forAssetContainer defines if the entities must be stored in the scene
  82550. * @param data gltf data containing information of the meshes in a loaded file
  82551. * @param rootUrl root url to load from
  82552. * @param onProgress event that fires when loading progress has occured
  82553. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82554. */
  82555. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  82556. private _loadAsync;
  82557. /**
  82558. * Imports all objects from a loaded gltf file and adds them to the scene
  82559. * @param scene the scene the objects should be added to
  82560. * @param data gltf data containing information of the meshes in a loaded file
  82561. * @param rootUrl root url to load from
  82562. * @param onProgress event that fires when loading progress has occured
  82563. * @returns a promise which completes when objects have been loaded to the scene
  82564. */
  82565. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82566. private _loadShadersAsync;
  82567. private _loadBuffersAsync;
  82568. private _createNodes;
  82569. }
  82570. /** @hidden */
  82571. export abstract class GLTFLoaderExtension {
  82572. private _name;
  82573. constructor(name: string);
  82574. get name(): string;
  82575. /**
  82576. * Defines an override for loading the runtime
  82577. * Return true to stop further extensions from loading the runtime
  82578. */
  82579. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82580. /**
  82581. * Defines an onverride for creating gltf runtime
  82582. * Return true to stop further extensions from creating the runtime
  82583. */
  82584. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  82585. /**
  82586. * Defines an override for loading buffers
  82587. * Return true to stop further extensions from loading this buffer
  82588. */
  82589. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82590. /**
  82591. * Defines an override for loading texture buffers
  82592. * Return true to stop further extensions from loading this texture data
  82593. */
  82594. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82595. /**
  82596. * Defines an override for creating textures
  82597. * Return true to stop further extensions from loading this texture
  82598. */
  82599. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82600. /**
  82601. * Defines an override for loading shader strings
  82602. * Return true to stop further extensions from loading this shader data
  82603. */
  82604. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82605. /**
  82606. * Defines an override for loading materials
  82607. * Return true to stop further extensions from loading this material
  82608. */
  82609. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82610. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82611. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82612. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82613. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82614. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82615. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82616. private static LoadTextureBufferAsync;
  82617. private static CreateTextureAsync;
  82618. private static ApplyExtensions;
  82619. }
  82620. }
  82621. declare module BABYLON.GLTF1 {
  82622. /** @hidden */
  82623. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82624. private _bin;
  82625. constructor();
  82626. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82627. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82628. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82629. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82630. }
  82631. }
  82632. declare module BABYLON.GLTF1 {
  82633. /** @hidden */
  82634. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  82635. constructor();
  82636. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  82637. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82638. private _loadTexture;
  82639. }
  82640. }
  82641. declare module BABYLON.GLTF2.Loader {
  82642. /**
  82643. * Loader interface with an index field.
  82644. */
  82645. export interface IArrayItem {
  82646. /**
  82647. * The index of this item in the array.
  82648. */
  82649. index: number;
  82650. }
  82651. /**
  82652. * Loader interface with additional members.
  82653. */
  82654. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  82655. /** @hidden */
  82656. _data?: Promise<ArrayBufferView>;
  82657. /** @hidden */
  82658. _babylonVertexBuffer?: Promise<VertexBuffer>;
  82659. }
  82660. /**
  82661. * Loader interface with additional members.
  82662. */
  82663. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  82664. }
  82665. /** @hidden */
  82666. export interface _IAnimationSamplerData {
  82667. input: Float32Array;
  82668. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  82669. output: Float32Array;
  82670. }
  82671. /**
  82672. * Loader interface with additional members.
  82673. */
  82674. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  82675. /** @hidden */
  82676. _data?: Promise<_IAnimationSamplerData>;
  82677. }
  82678. /**
  82679. * Loader interface with additional members.
  82680. */
  82681. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  82682. channels: IAnimationChannel[];
  82683. samplers: IAnimationSampler[];
  82684. /** @hidden */
  82685. _babylonAnimationGroup?: AnimationGroup;
  82686. }
  82687. /**
  82688. * Loader interface with additional members.
  82689. */
  82690. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  82691. /** @hidden */
  82692. _data?: Promise<ArrayBufferView>;
  82693. }
  82694. /**
  82695. * Loader interface with additional members.
  82696. */
  82697. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  82698. /** @hidden */
  82699. _data?: Promise<ArrayBufferView>;
  82700. /** @hidden */
  82701. _babylonBuffer?: Promise<Buffer>;
  82702. }
  82703. /**
  82704. * Loader interface with additional members.
  82705. */
  82706. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  82707. }
  82708. /**
  82709. * Loader interface with additional members.
  82710. */
  82711. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  82712. /** @hidden */
  82713. _data?: Promise<ArrayBufferView>;
  82714. }
  82715. /**
  82716. * Loader interface with additional members.
  82717. */
  82718. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  82719. }
  82720. /**
  82721. * Loader interface with additional members.
  82722. */
  82723. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  82724. }
  82725. /**
  82726. * Loader interface with additional members.
  82727. */
  82728. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  82729. baseColorTexture?: ITextureInfo;
  82730. metallicRoughnessTexture?: ITextureInfo;
  82731. }
  82732. /**
  82733. * Loader interface with additional members.
  82734. */
  82735. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  82736. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82737. normalTexture?: IMaterialNormalTextureInfo;
  82738. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82739. emissiveTexture?: ITextureInfo;
  82740. /** @hidden */
  82741. _data?: {
  82742. [babylonDrawMode: number]: {
  82743. babylonMaterial: Material;
  82744. babylonMeshes: AbstractMesh[];
  82745. promise: Promise<void>;
  82746. };
  82747. };
  82748. }
  82749. /**
  82750. * Loader interface with additional members.
  82751. */
  82752. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  82753. primitives: IMeshPrimitive[];
  82754. }
  82755. /**
  82756. * Loader interface with additional members.
  82757. */
  82758. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  82759. /** @hidden */
  82760. _instanceData?: {
  82761. babylonSourceMesh: Mesh;
  82762. promise: Promise<any>;
  82763. };
  82764. }
  82765. /**
  82766. * Loader interface with additional members.
  82767. */
  82768. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  82769. /**
  82770. * The parent glTF node.
  82771. */
  82772. parent?: INode;
  82773. /** @hidden */
  82774. _babylonTransformNode?: TransformNode;
  82775. /** @hidden */
  82776. _primitiveBabylonMeshes?: AbstractMesh[];
  82777. /** @hidden */
  82778. _babylonBones?: Bone[];
  82779. /** @hidden */
  82780. _numMorphTargets?: number;
  82781. }
  82782. /** @hidden */
  82783. export interface _ISamplerData {
  82784. noMipMaps: boolean;
  82785. samplingMode: number;
  82786. wrapU: number;
  82787. wrapV: number;
  82788. }
  82789. /**
  82790. * Loader interface with additional members.
  82791. */
  82792. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  82793. /** @hidden */
  82794. _data?: _ISamplerData;
  82795. }
  82796. /**
  82797. * Loader interface with additional members.
  82798. */
  82799. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  82800. }
  82801. /**
  82802. * Loader interface with additional members.
  82803. */
  82804. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  82805. /** @hidden */
  82806. _data?: {
  82807. babylonSkeleton: Skeleton;
  82808. promise: Promise<void>;
  82809. };
  82810. }
  82811. /**
  82812. * Loader interface with additional members.
  82813. */
  82814. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  82815. /** @hidden */
  82816. _textureInfo: ITextureInfo;
  82817. }
  82818. /**
  82819. * Loader interface with additional members.
  82820. */
  82821. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  82822. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  82823. nonColorData?: boolean;
  82824. }
  82825. /**
  82826. * Loader interface with additional members.
  82827. */
  82828. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  82829. accessors?: IAccessor[];
  82830. animations?: IAnimation[];
  82831. buffers?: IBuffer[];
  82832. bufferViews?: IBufferView[];
  82833. cameras?: ICamera[];
  82834. images?: IImage[];
  82835. materials?: IMaterial[];
  82836. meshes?: IMesh[];
  82837. nodes?: INode[];
  82838. samplers?: ISampler[];
  82839. scenes?: IScene[];
  82840. skins?: ISkin[];
  82841. textures?: ITexture[];
  82842. }
  82843. }
  82844. declare module BABYLON.GLTF2 {
  82845. /**
  82846. * Interface for a glTF loader extension.
  82847. */
  82848. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  82849. /**
  82850. * Called after the loader state changes to LOADING.
  82851. */
  82852. onLoading?(): void;
  82853. /**
  82854. * Called after the loader state changes to READY.
  82855. */
  82856. onReady?(): void;
  82857. /**
  82858. * Define this method to modify the default behavior when loading scenes.
  82859. * @param context The context when loading the asset
  82860. * @param scene The glTF scene property
  82861. * @returns A promise that resolves when the load is complete or null if not handled
  82862. */
  82863. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  82864. /**
  82865. * Define this method to modify the default behavior when loading nodes.
  82866. * @param context The context when loading the asset
  82867. * @param node The glTF node property
  82868. * @param assign A function called synchronously after parsing the glTF properties
  82869. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  82870. */
  82871. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82872. /**
  82873. * Define this method to modify the default behavior when loading cameras.
  82874. * @param context The context when loading the asset
  82875. * @param camera The glTF camera property
  82876. * @param assign A function called synchronously after parsing the glTF properties
  82877. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  82878. */
  82879. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82880. /**
  82881. * @hidden
  82882. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  82883. * @param context The context when loading the asset
  82884. * @param primitive The glTF mesh primitive property
  82885. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  82886. */
  82887. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82888. /**
  82889. * @hidden
  82890. * Define this method to modify the default behavior when loading data for mesh primitives.
  82891. * @param context The context when loading the asset
  82892. * @param name The mesh name when loading the asset
  82893. * @param node The glTF node when loading the asset
  82894. * @param mesh The glTF mesh when loading the asset
  82895. * @param primitive The glTF mesh primitive property
  82896. * @param assign A function called synchronously after parsing the glTF properties
  82897. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82898. */
  82899. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82900. /**
  82901. * @hidden
  82902. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  82903. * @param context The context when loading the asset
  82904. * @param material The glTF material property
  82905. * @param assign A function called synchronously after parsing the glTF properties
  82906. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  82907. */
  82908. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82909. /**
  82910. * Define this method to modify the default behavior when creating materials.
  82911. * @param context The context when loading the asset
  82912. * @param material The glTF material property
  82913. * @param babylonDrawMode The draw mode for the Babylon material
  82914. * @returns The Babylon material or null if not handled
  82915. */
  82916. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82917. /**
  82918. * Define this method to modify the default behavior when loading material properties.
  82919. * @param context The context when loading the asset
  82920. * @param material The glTF material property
  82921. * @param babylonMaterial The Babylon material
  82922. * @returns A promise that resolves when the load is complete or null if not handled
  82923. */
  82924. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82925. /**
  82926. * Define this method to modify the default behavior when loading texture infos.
  82927. * @param context The context when loading the asset
  82928. * @param textureInfo The glTF texture info property
  82929. * @param assign A function called synchronously after parsing the glTF properties
  82930. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82931. */
  82932. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82933. /**
  82934. * @hidden
  82935. * Define this method to modify the default behavior when loading textures.
  82936. * @param context The context when loading the asset
  82937. * @param texture The glTF texture property
  82938. * @param assign A function called synchronously after parsing the glTF properties
  82939. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82940. */
  82941. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82942. /**
  82943. * Define this method to modify the default behavior when loading animations.
  82944. * @param context The context when loading the asset
  82945. * @param animation The glTF animation property
  82946. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82947. */
  82948. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82949. /**
  82950. * @hidden
  82951. * Define this method to modify the default behavior when loading skins.
  82952. * @param context The context when loading the asset
  82953. * @param node The glTF node property
  82954. * @param skin The glTF skin property
  82955. * @returns A promise that resolves when the load is complete or null if not handled
  82956. */
  82957. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  82958. /**
  82959. * @hidden
  82960. * Define this method to modify the default behavior when loading uris.
  82961. * @param context The context when loading the asset
  82962. * @param property The glTF property associated with the uri
  82963. * @param uri The uri to load
  82964. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82965. */
  82966. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82967. /**
  82968. * Define this method to modify the default behavior when loading buffer views.
  82969. * @param context The context when loading the asset
  82970. * @param bufferView The glTF buffer view property
  82971. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82972. */
  82973. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  82974. /**
  82975. * Define this method to modify the default behavior when loading buffers.
  82976. * @param context The context when loading the asset
  82977. * @param buffer The glTF buffer property
  82978. * @param byteOffset The byte offset to load
  82979. * @param byteLength The byte length to load
  82980. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82981. */
  82982. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82983. }
  82984. }
  82985. declare module BABYLON.GLTF2 {
  82986. /**
  82987. * Helper class for working with arrays when loading the glTF asset
  82988. */
  82989. export class ArrayItem {
  82990. /**
  82991. * Gets an item from the given array.
  82992. * @param context The context when loading the asset
  82993. * @param array The array to get the item from
  82994. * @param index The index to the array
  82995. * @returns The array item
  82996. */
  82997. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  82998. /**
  82999. * Assign an `index` field to each item of the given array.
  83000. * @param array The array of items
  83001. */
  83002. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  83003. }
  83004. /**
  83005. * The glTF 2.0 loader
  83006. */
  83007. export class GLTFLoader implements IGLTFLoader {
  83008. /** @hidden */
  83009. _completePromises: Promise<any>[];
  83010. /** @hidden */
  83011. _forAssetContainer: boolean;
  83012. /** Storage */
  83013. _babylonLights: Light[];
  83014. /** @hidden */
  83015. _disableInstancedMesh: number;
  83016. private _disposed;
  83017. private _parent;
  83018. private _state;
  83019. private _extensions;
  83020. private _rootUrl;
  83021. private _fileName;
  83022. private _uniqueRootUrl;
  83023. private _gltf;
  83024. private _bin;
  83025. private _babylonScene;
  83026. private _rootBabylonMesh;
  83027. private _defaultBabylonMaterialData;
  83028. private static _RegisteredExtensions;
  83029. /**
  83030. * The default glTF sampler.
  83031. */
  83032. static readonly DefaultSampler: ISampler;
  83033. /**
  83034. * Registers a loader extension.
  83035. * @param name The name of the loader extension.
  83036. * @param factory The factory function that creates the loader extension.
  83037. */
  83038. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  83039. /**
  83040. * Unregisters a loader extension.
  83041. * @param name The name of the loader extension.
  83042. * @returns A boolean indicating whether the extension has been unregistered
  83043. */
  83044. static UnregisterExtension(name: string): boolean;
  83045. /**
  83046. * The loader state.
  83047. */
  83048. get state(): Nullable<GLTFLoaderState>;
  83049. /**
  83050. * The object that represents the glTF JSON.
  83051. */
  83052. get gltf(): IGLTF;
  83053. /**
  83054. * The BIN chunk of a binary glTF.
  83055. */
  83056. get bin(): Nullable<IDataBuffer>;
  83057. /**
  83058. * The parent file loader.
  83059. */
  83060. get parent(): GLTFFileLoader;
  83061. /**
  83062. * The Babylon scene when loading the asset.
  83063. */
  83064. get babylonScene(): Scene;
  83065. /**
  83066. * The root Babylon mesh when loading the asset.
  83067. */
  83068. get rootBabylonMesh(): Mesh;
  83069. /** @hidden */
  83070. constructor(parent: GLTFFileLoader);
  83071. /** @hidden */
  83072. dispose(): void;
  83073. /** @hidden */
  83074. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  83075. /** @hidden */
  83076. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83077. private _loadAsync;
  83078. private _loadData;
  83079. private _setupData;
  83080. private _loadExtensions;
  83081. private _checkExtensions;
  83082. private _setState;
  83083. private _createRootNode;
  83084. /**
  83085. * Loads a glTF scene.
  83086. * @param context The context when loading the asset
  83087. * @param scene The glTF scene property
  83088. * @returns A promise that resolves when the load is complete
  83089. */
  83090. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  83091. private _forEachPrimitive;
  83092. private _getGeometries;
  83093. private _getMeshes;
  83094. private _getTransformNodes;
  83095. private _getSkeletons;
  83096. private _getAnimationGroups;
  83097. private _startAnimations;
  83098. /**
  83099. * Loads a glTF node.
  83100. * @param context The context when loading the asset
  83101. * @param node The glTF node property
  83102. * @param assign A function called synchronously after parsing the glTF properties
  83103. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  83104. */
  83105. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  83106. private _loadMeshAsync;
  83107. /**
  83108. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83109. * @param context The context when loading the asset
  83110. * @param name The mesh name when loading the asset
  83111. * @param node The glTF node when loading the asset
  83112. * @param mesh The glTF mesh when loading the asset
  83113. * @param primitive The glTF mesh primitive property
  83114. * @param assign A function called synchronously after parsing the glTF properties
  83115. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83116. */
  83117. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83118. private _loadVertexDataAsync;
  83119. private _createMorphTargets;
  83120. private _loadMorphTargetsAsync;
  83121. private _loadMorphTargetVertexDataAsync;
  83122. private static _LoadTransform;
  83123. private _loadSkinAsync;
  83124. private _loadBones;
  83125. private _loadBone;
  83126. private _loadSkinInverseBindMatricesDataAsync;
  83127. private _updateBoneMatrices;
  83128. private _getNodeMatrix;
  83129. /**
  83130. * Loads a glTF camera.
  83131. * @param context The context when loading the asset
  83132. * @param camera The glTF camera property
  83133. * @param assign A function called synchronously after parsing the glTF properties
  83134. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83135. */
  83136. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83137. private _loadAnimationsAsync;
  83138. /**
  83139. * Loads a glTF animation.
  83140. * @param context The context when loading the asset
  83141. * @param animation The glTF animation property
  83142. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83143. */
  83144. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83145. /**
  83146. * @hidden Loads a glTF animation channel.
  83147. * @param context The context when loading the asset
  83148. * @param animationContext The context of the animation when loading the asset
  83149. * @param animation The glTF animation property
  83150. * @param channel The glTF animation channel property
  83151. * @param babylonAnimationGroup The babylon animation group property
  83152. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83153. * @returns A void promise when the channel load is complete
  83154. */
  83155. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83156. private _loadAnimationSamplerAsync;
  83157. private _loadBufferAsync;
  83158. /**
  83159. * Loads a glTF buffer view.
  83160. * @param context The context when loading the asset
  83161. * @param bufferView The glTF buffer view property
  83162. * @returns A promise that resolves with the loaded data when the load is complete
  83163. */
  83164. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83165. private _loadAccessorAsync;
  83166. /** @hidden */
  83167. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83168. private _loadIndicesAccessorAsync;
  83169. private _loadVertexBufferViewAsync;
  83170. private _loadVertexAccessorAsync;
  83171. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83172. /** @hidden */
  83173. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83174. private _createDefaultMaterial;
  83175. /**
  83176. * Creates a Babylon material from a glTF material.
  83177. * @param context The context when loading the asset
  83178. * @param material The glTF material property
  83179. * @param babylonDrawMode The draw mode for the Babylon material
  83180. * @returns The Babylon material
  83181. */
  83182. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83183. /**
  83184. * Loads properties from a glTF material into a Babylon material.
  83185. * @param context The context when loading the asset
  83186. * @param material The glTF material property
  83187. * @param babylonMaterial The Babylon material
  83188. * @returns A promise that resolves when the load is complete
  83189. */
  83190. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83191. /**
  83192. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  83193. * @param context The context when loading the asset
  83194. * @param material The glTF material property
  83195. * @param babylonMaterial The Babylon material
  83196. * @returns A promise that resolves when the load is complete
  83197. */
  83198. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83199. /**
  83200. * Loads the alpha properties from a glTF material into a Babylon material.
  83201. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83202. * @param context The context when loading the asset
  83203. * @param material The glTF material property
  83204. * @param babylonMaterial The Babylon material
  83205. */
  83206. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83207. /**
  83208. * Loads a glTF texture info.
  83209. * @param context The context when loading the asset
  83210. * @param textureInfo The glTF texture info property
  83211. * @param assign A function called synchronously after parsing the glTF properties
  83212. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83213. */
  83214. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83215. /** @hidden */
  83216. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83217. /** @hidden */
  83218. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83219. private _loadSampler;
  83220. /**
  83221. * Loads a glTF image.
  83222. * @param context The context when loading the asset
  83223. * @param image The glTF image property
  83224. * @returns A promise that resolves with the loaded data when the load is complete
  83225. */
  83226. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83227. /**
  83228. * Loads a glTF uri.
  83229. * @param context The context when loading the asset
  83230. * @param property The glTF property associated with the uri
  83231. * @param uri The base64 or relative uri
  83232. * @returns A promise that resolves with the loaded data when the load is complete
  83233. */
  83234. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83235. /**
  83236. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83237. * @param babylonObject the Babylon object with metadata
  83238. * @param pointer the JSON pointer
  83239. */
  83240. static AddPointerMetadata(babylonObject: {
  83241. metadata: any;
  83242. }, pointer: string): void;
  83243. private static _GetTextureWrapMode;
  83244. private static _GetTextureSamplingMode;
  83245. private static _GetTypedArrayConstructor;
  83246. private static _GetTypedArray;
  83247. private static _GetNumComponents;
  83248. private static _ValidateUri;
  83249. /** @hidden */
  83250. static _GetDrawMode(context: string, mode: number | undefined): number;
  83251. private _compileMaterialsAsync;
  83252. private _compileShadowGeneratorsAsync;
  83253. private _forEachExtensions;
  83254. private _applyExtensions;
  83255. private _extensionsOnLoading;
  83256. private _extensionsOnReady;
  83257. private _extensionsLoadSceneAsync;
  83258. private _extensionsLoadNodeAsync;
  83259. private _extensionsLoadCameraAsync;
  83260. private _extensionsLoadVertexDataAsync;
  83261. private _extensionsLoadMeshPrimitiveAsync;
  83262. private _extensionsLoadMaterialAsync;
  83263. private _extensionsCreateMaterial;
  83264. private _extensionsLoadMaterialPropertiesAsync;
  83265. private _extensionsLoadTextureInfoAsync;
  83266. private _extensionsLoadTextureAsync;
  83267. private _extensionsLoadAnimationAsync;
  83268. private _extensionsLoadSkinAsync;
  83269. private _extensionsLoadUriAsync;
  83270. private _extensionsLoadBufferViewAsync;
  83271. private _extensionsLoadBufferAsync;
  83272. /**
  83273. * Helper method called by a loader extension to load an glTF extension.
  83274. * @param context The context when loading the asset
  83275. * @param property The glTF property to load the extension from
  83276. * @param extensionName The name of the extension to load
  83277. * @param actionAsync The action to run
  83278. * @returns The promise returned by actionAsync or null if the extension does not exist
  83279. */
  83280. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83281. /**
  83282. * Helper method called by a loader extension to load a glTF extra.
  83283. * @param context The context when loading the asset
  83284. * @param property The glTF property to load the extra from
  83285. * @param extensionName The name of the extension to load
  83286. * @param actionAsync The action to run
  83287. * @returns The promise returned by actionAsync or null if the extra does not exist
  83288. */
  83289. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83290. /**
  83291. * Checks for presence of an extension.
  83292. * @param name The name of the extension to check
  83293. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83294. */
  83295. isExtensionUsed(name: string): boolean;
  83296. /**
  83297. * Increments the indentation level and logs a message.
  83298. * @param message The message to log
  83299. */
  83300. logOpen(message: string): void;
  83301. /**
  83302. * Decrements the indentation level.
  83303. */
  83304. logClose(): void;
  83305. /**
  83306. * Logs a message
  83307. * @param message The message to log
  83308. */
  83309. log(message: string): void;
  83310. /**
  83311. * Starts a performance counter.
  83312. * @param counterName The name of the performance counter
  83313. */
  83314. startPerformanceCounter(counterName: string): void;
  83315. /**
  83316. * Ends a performance counter.
  83317. * @param counterName The name of the performance counter
  83318. */
  83319. endPerformanceCounter(counterName: string): void;
  83320. }
  83321. }
  83322. declare module BABYLON.GLTF2.Loader.Extensions {
  83323. /** @hidden */
  83324. interface IEXTLightsImageBased_LightImageBased {
  83325. _babylonTexture?: BaseTexture;
  83326. _loaded?: Promise<void>;
  83327. }
  83328. /**
  83329. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83330. */
  83331. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83332. /**
  83333. * The name of this extension.
  83334. */
  83335. readonly name: string;
  83336. /**
  83337. * Defines whether this extension is enabled.
  83338. */
  83339. enabled: boolean;
  83340. private _loader;
  83341. private _lights?;
  83342. /** @hidden */
  83343. constructor(loader: GLTFLoader);
  83344. /** @hidden */
  83345. dispose(): void;
  83346. /** @hidden */
  83347. onLoading(): void;
  83348. /** @hidden */
  83349. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83350. private _loadLightAsync;
  83351. }
  83352. }
  83353. declare module BABYLON.GLTF2.Loader.Extensions {
  83354. /**
  83355. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83356. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83357. * !!! Experimental Extension Subject to Changes !!!
  83358. */
  83359. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83360. /**
  83361. * The name of this extension.
  83362. */
  83363. readonly name: string;
  83364. /**
  83365. * Defines whether this extension is enabled.
  83366. */
  83367. enabled: boolean;
  83368. private _loader;
  83369. /** @hidden */
  83370. constructor(loader: GLTFLoader);
  83371. /** @hidden */
  83372. dispose(): void;
  83373. /** @hidden */
  83374. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83375. }
  83376. }
  83377. declare module BABYLON.GLTF2.Loader.Extensions {
  83378. /**
  83379. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  83380. */
  83381. export class EXT_texture_webp implements IGLTFLoaderExtension {
  83382. /** The name of this extension. */
  83383. readonly name: string;
  83384. /** Defines whether this extension is enabled. */
  83385. enabled: boolean;
  83386. private _loader;
  83387. /** @hidden */
  83388. constructor(loader: GLTFLoader);
  83389. /** @hidden */
  83390. dispose(): void;
  83391. /** @hidden */
  83392. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83393. }
  83394. }
  83395. declare module BABYLON.GLTF2.Loader.Extensions {
  83396. /**
  83397. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  83398. */
  83399. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  83400. /**
  83401. * The name of this extension.
  83402. */
  83403. readonly name: string;
  83404. /**
  83405. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83406. */
  83407. dracoCompression?: DracoCompression;
  83408. /**
  83409. * Defines whether this extension is enabled.
  83410. */
  83411. enabled: boolean;
  83412. private _loader;
  83413. /** @hidden */
  83414. constructor(loader: GLTFLoader);
  83415. /** @hidden */
  83416. dispose(): void;
  83417. /** @hidden */
  83418. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83419. }
  83420. }
  83421. declare module BABYLON.GLTF2.Loader.Extensions {
  83422. /**
  83423. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83424. */
  83425. export class KHR_lights implements IGLTFLoaderExtension {
  83426. /**
  83427. * The name of this extension.
  83428. */
  83429. readonly name: string;
  83430. /**
  83431. * Defines whether this extension is enabled.
  83432. */
  83433. enabled: boolean;
  83434. private _loader;
  83435. private _lights?;
  83436. /** @hidden */
  83437. constructor(loader: GLTFLoader);
  83438. /** @hidden */
  83439. dispose(): void;
  83440. /** @hidden */
  83441. onLoading(): void;
  83442. /** @hidden */
  83443. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83444. }
  83445. }
  83446. declare module BABYLON.GLTF2.Loader.Extensions {
  83447. /**
  83448. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83449. */
  83450. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  83451. /**
  83452. * The name of this extension.
  83453. */
  83454. readonly name: string;
  83455. /**
  83456. * Defines whether this extension is enabled.
  83457. */
  83458. enabled: boolean;
  83459. /**
  83460. * Defines a number that determines the order the extensions are applied.
  83461. */
  83462. order: number;
  83463. private _loader;
  83464. /** @hidden */
  83465. constructor(loader: GLTFLoader);
  83466. /** @hidden */
  83467. dispose(): void;
  83468. /** @hidden */
  83469. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83470. private _loadSpecularGlossinessPropertiesAsync;
  83471. }
  83472. }
  83473. declare module BABYLON.GLTF2.Loader.Extensions {
  83474. /**
  83475. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83476. */
  83477. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  83478. /**
  83479. * The name of this extension.
  83480. */
  83481. readonly name: string;
  83482. /**
  83483. * Defines whether this extension is enabled.
  83484. */
  83485. enabled: boolean;
  83486. /**
  83487. * Defines a number that determines the order the extensions are applied.
  83488. */
  83489. order: number;
  83490. private _loader;
  83491. /** @hidden */
  83492. constructor(loader: GLTFLoader);
  83493. /** @hidden */
  83494. dispose(): void;
  83495. /** @hidden */
  83496. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83497. private _loadUnlitPropertiesAsync;
  83498. }
  83499. }
  83500. declare module BABYLON.GLTF2.Loader.Extensions {
  83501. /**
  83502. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  83503. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83504. */
  83505. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83506. /**
  83507. * The name of this extension.
  83508. */
  83509. readonly name: string;
  83510. /**
  83511. * Defines whether this extension is enabled.
  83512. */
  83513. enabled: boolean;
  83514. /**
  83515. * Defines a number that determines the order the extensions are applied.
  83516. */
  83517. order: number;
  83518. private _loader;
  83519. /** @hidden */
  83520. constructor(loader: GLTFLoader);
  83521. /** @hidden */
  83522. dispose(): void;
  83523. /** @hidden */
  83524. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83525. private _loadClearCoatPropertiesAsync;
  83526. }
  83527. }
  83528. declare module BABYLON.GLTF2.Loader.Extensions {
  83529. /**
  83530. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  83531. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  83532. * !!! Experimental Extension Subject to Changes !!!
  83533. */
  83534. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83535. /**
  83536. * The name of this extension.
  83537. */
  83538. readonly name: string;
  83539. /**
  83540. * Defines whether this extension is enabled.
  83541. */
  83542. enabled: boolean;
  83543. /**
  83544. * Defines a number that determines the order the extensions are applied.
  83545. */
  83546. order: number;
  83547. private _loader;
  83548. /** @hidden */
  83549. constructor(loader: GLTFLoader);
  83550. /** @hidden */
  83551. dispose(): void;
  83552. /** @hidden */
  83553. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83554. private _loadSheenPropertiesAsync;
  83555. }
  83556. }
  83557. declare module BABYLON.GLTF2.Loader.Extensions {
  83558. /**
  83559. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83560. * !!! Experimental Extension Subject to Changes !!!
  83561. */
  83562. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83563. /**
  83564. * The name of this extension.
  83565. */
  83566. readonly name: string;
  83567. /**
  83568. * Defines whether this extension is enabled.
  83569. */
  83570. enabled: boolean;
  83571. /**
  83572. * Defines a number that determines the order the extensions are applied.
  83573. */
  83574. order: number;
  83575. private _loader;
  83576. /** @hidden */
  83577. constructor(loader: GLTFLoader);
  83578. /** @hidden */
  83579. dispose(): void;
  83580. /** @hidden */
  83581. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83582. private _loadSpecularPropertiesAsync;
  83583. }
  83584. }
  83585. declare module BABYLON.GLTF2.Loader.Extensions {
  83586. /**
  83587. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  83588. * !!! Experimental Extension Subject to Changes !!!
  83589. */
  83590. export class KHR_materials_ior implements IGLTFLoaderExtension {
  83591. /**
  83592. * Default ior Value from the spec.
  83593. */
  83594. private static readonly _DEFAULT_IOR;
  83595. /**
  83596. * The name of this extension.
  83597. */
  83598. readonly name: string;
  83599. /**
  83600. * Defines whether this extension is enabled.
  83601. */
  83602. enabled: boolean;
  83603. /**
  83604. * Defines a number that determines the order the extensions are applied.
  83605. */
  83606. order: number;
  83607. private _loader;
  83608. /** @hidden */
  83609. constructor(loader: GLTFLoader);
  83610. /** @hidden */
  83611. dispose(): void;
  83612. /** @hidden */
  83613. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83614. private _loadIorPropertiesAsync;
  83615. }
  83616. }
  83617. declare module BABYLON.GLTF2.Loader.Extensions {
  83618. /**
  83619. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83620. * !!! Experimental Extension Subject to Changes !!!
  83621. */
  83622. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83623. /**
  83624. * The name of this extension.
  83625. */
  83626. readonly name: string;
  83627. /**
  83628. * Defines whether this extension is enabled.
  83629. */
  83630. enabled: boolean;
  83631. private _loader;
  83632. private _variants?;
  83633. /** @hidden */
  83634. constructor(loader: GLTFLoader);
  83635. /** @hidden */
  83636. dispose(): void;
  83637. /**
  83638. * Gets the list of available variant names for this asset.
  83639. * @param rootMesh The glTF root mesh
  83640. * @returns the list of all the variant names for this model
  83641. */
  83642. static GetAvailableVariants(rootMesh: Mesh): string[];
  83643. /**
  83644. * Gets the list of available variant names for this asset.
  83645. * @param rootMesh The glTF root mesh
  83646. * @returns the list of all the variant names for this model
  83647. */
  83648. getAvailableVariants(rootMesh: Mesh): string[];
  83649. /**
  83650. * Select a variant given a variant name or a list of variant names.
  83651. * @param rootMesh The glTF root mesh
  83652. * @param variantName The variant name(s) to select.
  83653. */
  83654. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83655. /**
  83656. * Select a variant given a variant name or a list of variant names.
  83657. * @param rootMesh The glTF root mesh
  83658. * @param variantName The variant name(s) to select.
  83659. */
  83660. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83661. /**
  83662. * Reset back to the original before selecting a variant.
  83663. * @param rootMesh The glTF root mesh
  83664. */
  83665. static Reset(rootMesh: Mesh): void;
  83666. /**
  83667. * Reset back to the original before selecting a variant.
  83668. * @param rootMesh The glTF root mesh
  83669. */
  83670. reset(rootMesh: Mesh): void;
  83671. /**
  83672. * Gets the last selected variant name(s) or null if original.
  83673. * @param rootMesh The glTF root mesh
  83674. * @returns The selected variant name(s).
  83675. */
  83676. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83677. /**
  83678. * Gets the last selected variant name(s) or null if original.
  83679. * @param rootMesh The glTF root mesh
  83680. * @returns The selected variant name(s).
  83681. */
  83682. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83683. private static _GetExtensionMetadata;
  83684. /** @hidden */
  83685. onLoading(): void;
  83686. /** @hidden */
  83687. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83688. }
  83689. }
  83690. declare module BABYLON.GLTF2.Loader.Extensions {
  83691. /**
  83692. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  83693. * !!! Experimental Extension Subject to Changes !!!
  83694. */
  83695. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  83696. /**
  83697. * The name of this extension.
  83698. */
  83699. readonly name: string;
  83700. /**
  83701. * Defines whether this extension is enabled.
  83702. */
  83703. enabled: boolean;
  83704. /**
  83705. * Defines a number that determines the order the extensions are applied.
  83706. */
  83707. order: number;
  83708. private _loader;
  83709. /** @hidden */
  83710. constructor(loader: GLTFLoader);
  83711. /** @hidden */
  83712. dispose(): void;
  83713. /** @hidden */
  83714. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83715. private _loadTransparentPropertiesAsync;
  83716. }
  83717. }
  83718. declare module BABYLON.GLTF2.Loader.Extensions {
  83719. /**
  83720. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  83721. */
  83722. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  83723. /**
  83724. * The name of this extension.
  83725. */
  83726. readonly name: string;
  83727. /**
  83728. * Defines whether this extension is enabled.
  83729. */
  83730. enabled: boolean;
  83731. /** @hidden */
  83732. constructor(loader: GLTFLoader);
  83733. /** @hidden */
  83734. dispose(): void;
  83735. }
  83736. }
  83737. declare module BABYLON.GLTF2.Loader.Extensions {
  83738. /**
  83739. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  83740. * !!! Experimental Extension Subject to Changes !!!
  83741. */
  83742. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  83743. /** The name of this extension. */
  83744. readonly name: string;
  83745. /** Defines whether this extension is enabled. */
  83746. enabled: boolean;
  83747. private _loader;
  83748. /** @hidden */
  83749. constructor(loader: GLTFLoader);
  83750. /** @hidden */
  83751. dispose(): void;
  83752. /** @hidden */
  83753. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83754. }
  83755. }
  83756. declare module BABYLON.GLTF2.Loader.Extensions {
  83757. /**
  83758. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  83759. */
  83760. export class KHR_texture_transform implements IGLTFLoaderExtension {
  83761. /**
  83762. * The name of this extension.
  83763. */
  83764. readonly name: string;
  83765. /**
  83766. * Defines whether this extension is enabled.
  83767. */
  83768. enabled: boolean;
  83769. private _loader;
  83770. /** @hidden */
  83771. constructor(loader: GLTFLoader);
  83772. /** @hidden */
  83773. dispose(): void;
  83774. /** @hidden */
  83775. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83776. }
  83777. }
  83778. declare module BABYLON.GLTF2.Loader.Extensions {
  83779. /**
  83780. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  83781. * !!! Experimental Extension Subject to Changes !!!
  83782. */
  83783. export class KHR_xmp implements IGLTFLoaderExtension {
  83784. /**
  83785. * The name of this extension.
  83786. */
  83787. readonly name: string;
  83788. /**
  83789. * Defines whether this extension is enabled.
  83790. */
  83791. enabled: boolean;
  83792. /**
  83793. * Defines a number that determines the order the extensions are applied.
  83794. */
  83795. order: number;
  83796. private _loader;
  83797. /** @hidden */
  83798. constructor(loader: GLTFLoader);
  83799. /** @hidden */
  83800. dispose(): void;
  83801. /**
  83802. * Called after the loader state changes to LOADING.
  83803. */
  83804. onLoading(): void;
  83805. }
  83806. }
  83807. declare module BABYLON.GLTF2.Loader.Extensions {
  83808. /**
  83809. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  83810. */
  83811. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  83812. /**
  83813. * The name of this extension.
  83814. */
  83815. readonly name: string;
  83816. /**
  83817. * Defines whether this extension is enabled.
  83818. */
  83819. enabled: boolean;
  83820. private _loader;
  83821. private _clips;
  83822. private _emitters;
  83823. /** @hidden */
  83824. constructor(loader: GLTFLoader);
  83825. /** @hidden */
  83826. dispose(): void;
  83827. /** @hidden */
  83828. onLoading(): void;
  83829. /** @hidden */
  83830. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83831. /** @hidden */
  83832. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83833. /** @hidden */
  83834. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83835. private _loadClipAsync;
  83836. private _loadEmitterAsync;
  83837. private _getEventAction;
  83838. private _loadAnimationEventAsync;
  83839. }
  83840. }
  83841. declare module BABYLON.GLTF2.Loader.Extensions {
  83842. /**
  83843. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  83844. */
  83845. export class MSFT_lod implements IGLTFLoaderExtension {
  83846. /**
  83847. * The name of this extension.
  83848. */
  83849. readonly name: string;
  83850. /**
  83851. * Defines whether this extension is enabled.
  83852. */
  83853. enabled: boolean;
  83854. /**
  83855. * Defines a number that determines the order the extensions are applied.
  83856. */
  83857. order: number;
  83858. /**
  83859. * Maximum number of LODs to load, starting from the lowest LOD.
  83860. */
  83861. maxLODsToLoad: number;
  83862. /**
  83863. * Observable raised when all node LODs of one level are loaded.
  83864. * The event data is the index of the loaded LOD starting from zero.
  83865. * Dispose the loader to cancel the loading of the next level of LODs.
  83866. */
  83867. onNodeLODsLoadedObservable: Observable<number>;
  83868. /**
  83869. * Observable raised when all material LODs of one level are loaded.
  83870. * The event data is the index of the loaded LOD starting from zero.
  83871. * Dispose the loader to cancel the loading of the next level of LODs.
  83872. */
  83873. onMaterialLODsLoadedObservable: Observable<number>;
  83874. private _loader;
  83875. private _bufferLODs;
  83876. private _nodeIndexLOD;
  83877. private _nodeSignalLODs;
  83878. private _nodePromiseLODs;
  83879. private _nodeBufferLODs;
  83880. private _materialIndexLOD;
  83881. private _materialSignalLODs;
  83882. private _materialPromiseLODs;
  83883. private _materialBufferLODs;
  83884. /** @hidden */
  83885. constructor(loader: GLTFLoader);
  83886. /** @hidden */
  83887. dispose(): void;
  83888. /** @hidden */
  83889. onReady(): void;
  83890. /** @hidden */
  83891. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83892. /** @hidden */
  83893. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83894. /** @hidden */
  83895. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83896. /** @hidden */
  83897. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83898. /** @hidden */
  83899. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83900. private _loadBufferLOD;
  83901. /**
  83902. * Gets an array of LOD properties from lowest to highest.
  83903. */
  83904. private _getLODs;
  83905. private _disposeTransformNode;
  83906. private _disposeMaterials;
  83907. }
  83908. }
  83909. declare module BABYLON.GLTF2.Loader.Extensions {
  83910. /** @hidden */
  83911. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  83912. readonly name: string;
  83913. enabled: boolean;
  83914. private _loader;
  83915. constructor(loader: GLTFLoader);
  83916. dispose(): void;
  83917. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83918. }
  83919. }
  83920. declare module BABYLON.GLTF2.Loader.Extensions {
  83921. /** @hidden */
  83922. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  83923. readonly name: string;
  83924. enabled: boolean;
  83925. private _loader;
  83926. constructor(loader: GLTFLoader);
  83927. dispose(): void;
  83928. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83929. }
  83930. }
  83931. declare module BABYLON.GLTF2.Loader.Extensions {
  83932. /**
  83933. * Store glTF extras (if present) in BJS objects' metadata
  83934. */
  83935. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  83936. /**
  83937. * The name of this extension.
  83938. */
  83939. readonly name: string;
  83940. /**
  83941. * Defines whether this extension is enabled.
  83942. */
  83943. enabled: boolean;
  83944. private _loader;
  83945. private _assignExtras;
  83946. /** @hidden */
  83947. constructor(loader: GLTFLoader);
  83948. /** @hidden */
  83949. dispose(): void;
  83950. /** @hidden */
  83951. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83952. /** @hidden */
  83953. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83954. /** @hidden */
  83955. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83956. }
  83957. }
  83958. declare module BABYLON {
  83959. /**
  83960. * Class reading and parsing the MTL file bundled with the obj file.
  83961. */
  83962. export class MTLFileLoader {
  83963. /**
  83964. * Invert Y-Axis of referenced textures on load
  83965. */
  83966. static INVERT_TEXTURE_Y: boolean;
  83967. /**
  83968. * All material loaded from the mtl will be set here
  83969. */
  83970. materials: StandardMaterial[];
  83971. /**
  83972. * This function will read the mtl file and create each material described inside
  83973. * This function could be improve by adding :
  83974. * -some component missing (Ni, Tf...)
  83975. * -including the specific options available
  83976. *
  83977. * @param scene defines the scene the material will be created in
  83978. * @param data defines the mtl data to parse
  83979. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  83980. * @param forAssetContainer defines if the material should be registered in the scene
  83981. */
  83982. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  83983. /**
  83984. * Gets the texture for the material.
  83985. *
  83986. * If the material is imported from input file,
  83987. * We sanitize the url to ensure it takes the textre from aside the material.
  83988. *
  83989. * @param rootUrl The root url to load from
  83990. * @param value The value stored in the mtl
  83991. * @return The Texture
  83992. */
  83993. private static _getTexture;
  83994. }
  83995. }
  83996. declare module BABYLON {
  83997. /**
  83998. * Options for loading OBJ/MTL files
  83999. */
  84000. type MeshLoadOptions = {
  84001. /**
  84002. * Defines if UVs are optimized by default during load.
  84003. */
  84004. OptimizeWithUV: boolean;
  84005. /**
  84006. * Defines custom scaling of UV coordinates of loaded meshes.
  84007. */
  84008. UVScaling: Vector2;
  84009. /**
  84010. * Invert model on y-axis (does a model scaling inversion)
  84011. */
  84012. InvertY: boolean;
  84013. /**
  84014. * Invert Y-Axis of referenced textures on load
  84015. */
  84016. InvertTextureY: boolean;
  84017. /**
  84018. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84019. */
  84020. ImportVertexColors: boolean;
  84021. /**
  84022. * Compute the normals for the model, even if normals are present in the file.
  84023. */
  84024. ComputeNormals: boolean;
  84025. /**
  84026. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84027. */
  84028. SkipMaterials: boolean;
  84029. /**
  84030. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84031. */
  84032. MaterialLoadingFailsSilently: boolean;
  84033. };
  84034. /**
  84035. * OBJ file type loader.
  84036. * This is a babylon scene loader plugin.
  84037. */
  84038. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  84039. /**
  84040. * Defines if UVs are optimized by default during load.
  84041. */
  84042. static OPTIMIZE_WITH_UV: boolean;
  84043. /**
  84044. * Invert model on y-axis (does a model scaling inversion)
  84045. */
  84046. static INVERT_Y: boolean;
  84047. /**
  84048. * Invert Y-Axis of referenced textures on load
  84049. */
  84050. static get INVERT_TEXTURE_Y(): boolean;
  84051. static set INVERT_TEXTURE_Y(value: boolean);
  84052. /**
  84053. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84054. */
  84055. static IMPORT_VERTEX_COLORS: boolean;
  84056. /**
  84057. * Compute the normals for the model, even if normals are present in the file.
  84058. */
  84059. static COMPUTE_NORMALS: boolean;
  84060. /**
  84061. * Defines custom scaling of UV coordinates of loaded meshes.
  84062. */
  84063. static UV_SCALING: Vector2;
  84064. /**
  84065. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84066. */
  84067. static SKIP_MATERIALS: boolean;
  84068. /**
  84069. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84070. *
  84071. * Defaults to true for backwards compatibility.
  84072. */
  84073. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  84074. /**
  84075. * Defines the name of the plugin.
  84076. */
  84077. name: string;
  84078. /**
  84079. * Defines the extension the plugin is able to load.
  84080. */
  84081. extensions: string;
  84082. /** @hidden */
  84083. obj: RegExp;
  84084. /** @hidden */
  84085. group: RegExp;
  84086. /** @hidden */
  84087. mtllib: RegExp;
  84088. /** @hidden */
  84089. usemtl: RegExp;
  84090. /** @hidden */
  84091. smooth: RegExp;
  84092. /** @hidden */
  84093. vertexPattern: RegExp;
  84094. /** @hidden */
  84095. normalPattern: RegExp;
  84096. /** @hidden */
  84097. uvPattern: RegExp;
  84098. /** @hidden */
  84099. facePattern1: RegExp;
  84100. /** @hidden */
  84101. facePattern2: RegExp;
  84102. /** @hidden */
  84103. facePattern3: RegExp;
  84104. /** @hidden */
  84105. facePattern4: RegExp;
  84106. /** @hidden */
  84107. facePattern5: RegExp;
  84108. private _forAssetContainer;
  84109. private _meshLoadOptions;
  84110. /**
  84111. * Creates loader for .OBJ files
  84112. *
  84113. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84114. */
  84115. constructor(meshLoadOptions?: MeshLoadOptions);
  84116. private static get currentMeshLoadOptions();
  84117. /**
  84118. * Calls synchronously the MTL file attached to this obj.
  84119. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84120. * Without this function materials are not displayed in the first frame (but displayed after).
  84121. * In consequence it is impossible to get material information in your HTML file
  84122. *
  84123. * @param url The URL of the MTL file
  84124. * @param rootUrl
  84125. * @param onSuccess Callback function to be called when the MTL file is loaded
  84126. * @private
  84127. */
  84128. private _loadMTL;
  84129. /**
  84130. * Instantiates a OBJ file loader plugin.
  84131. * @returns the created plugin
  84132. */
  84133. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84134. /**
  84135. * If the data string can be loaded directly.
  84136. *
  84137. * @param data string containing the file data
  84138. * @returns if the data can be loaded directly
  84139. */
  84140. canDirectLoad(data: string): boolean;
  84141. /**
  84142. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84143. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84144. * @param scene the scene the meshes should be added to
  84145. * @param data the OBJ data to load
  84146. * @param rootUrl root url to load from
  84147. * @param onProgress event that fires when loading progress has occured
  84148. * @param fileName Defines the name of the file to load
  84149. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84150. */
  84151. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  84152. meshes: AbstractMesh[];
  84153. particleSystems: IParticleSystem[];
  84154. skeletons: Skeleton[];
  84155. animationGroups: AnimationGroup[];
  84156. }>;
  84157. /**
  84158. * Imports all objects from the loaded OBJ data and adds them to the scene
  84159. * @param scene the scene the objects should be added to
  84160. * @param data the OBJ data to load
  84161. * @param rootUrl root url to load from
  84162. * @param onProgress event that fires when loading progress has occured
  84163. * @param fileName Defines the name of the file to load
  84164. * @returns a promise which completes when objects have been loaded to the scene
  84165. */
  84166. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84167. /**
  84168. * Load into an asset container.
  84169. * @param scene The scene to load into
  84170. * @param data The data to import
  84171. * @param rootUrl The root url for scene and resources
  84172. * @param onProgress The callback when the load progresses
  84173. * @param fileName Defines the name of the file to load
  84174. * @returns The loaded asset container
  84175. */
  84176. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84177. /**
  84178. * Read the OBJ file and create an Array of meshes.
  84179. * Each mesh contains all information given by the OBJ and the MTL file.
  84180. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84181. *
  84182. * @param meshesNames
  84183. * @param scene Scene The scene where are displayed the data
  84184. * @param data String The content of the obj file
  84185. * @param rootUrl String The path to the folder
  84186. * @returns Array<AbstractMesh>
  84187. * @private
  84188. */
  84189. private _parseSolid;
  84190. }
  84191. }
  84192. declare module BABYLON {
  84193. /**
  84194. * STL file type loader.
  84195. * This is a babylon scene loader plugin.
  84196. */
  84197. export class STLFileLoader implements ISceneLoaderPlugin {
  84198. /** @hidden */
  84199. solidPattern: RegExp;
  84200. /** @hidden */
  84201. facetsPattern: RegExp;
  84202. /** @hidden */
  84203. normalPattern: RegExp;
  84204. /** @hidden */
  84205. vertexPattern: RegExp;
  84206. /**
  84207. * Defines the name of the plugin.
  84208. */
  84209. name: string;
  84210. /**
  84211. * Defines the extensions the stl loader is able to load.
  84212. * force data to come in as an ArrayBuffer
  84213. * we'll convert to string if it looks like it's an ASCII .stl
  84214. */
  84215. extensions: ISceneLoaderPluginExtensions;
  84216. /**
  84217. * Import meshes into a scene.
  84218. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84219. * @param scene The scene to import into
  84220. * @param data The data to import
  84221. * @param rootUrl The root url for scene and resources
  84222. * @param meshes The meshes array to import into
  84223. * @param particleSystems The particle systems array to import into
  84224. * @param skeletons The skeletons array to import into
  84225. * @param onError The callback when import fails
  84226. * @returns True if successful or false otherwise
  84227. */
  84228. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84229. /**
  84230. * Load into a scene.
  84231. * @param scene The scene to load into
  84232. * @param data The data to import
  84233. * @param rootUrl The root url for scene and resources
  84234. * @param onError The callback when import fails
  84235. * @returns true if successful or false otherwise
  84236. */
  84237. load(scene: Scene, data: any, rootUrl: string): boolean;
  84238. /**
  84239. * Load into an asset container.
  84240. * @param scene The scene to load into
  84241. * @param data The data to import
  84242. * @param rootUrl The root url for scene and resources
  84243. * @param onError The callback when import fails
  84244. * @returns The loaded asset container
  84245. */
  84246. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84247. private _isBinary;
  84248. private _parseBinary;
  84249. private _parseASCII;
  84250. }
  84251. }
  84252. declare module BABYLON {
  84253. /**
  84254. * Class for generating OBJ data from a Babylon scene.
  84255. */
  84256. export class OBJExport {
  84257. /**
  84258. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84259. * @param mesh defines the list of meshes to serialize
  84260. * @param materials defines if materials should be exported
  84261. * @param matlibname defines the name of the associated mtl file
  84262. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84263. * @returns the OBJ content
  84264. */
  84265. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84266. /**
  84267. * Exports the material(s) of a mesh in .MTL file format (text)
  84268. * @param mesh defines the mesh to extract the material from
  84269. * @returns the mtl content
  84270. */
  84271. static MTL(mesh: Mesh): string;
  84272. }
  84273. }
  84274. declare module BABYLON {
  84275. /** @hidden */
  84276. export var __IGLTFExporterExtension: number;
  84277. /**
  84278. * Interface for extending the exporter
  84279. * @hidden
  84280. */
  84281. export interface IGLTFExporterExtension {
  84282. /**
  84283. * The name of this extension
  84284. */
  84285. readonly name: string;
  84286. /**
  84287. * Defines whether this extension is enabled
  84288. */
  84289. enabled: boolean;
  84290. /**
  84291. * Defines whether this extension is required
  84292. */
  84293. required: boolean;
  84294. }
  84295. }
  84296. declare module BABYLON.GLTF2.Exporter {
  84297. /** @hidden */
  84298. export var __IGLTFExporterExtensionV2: number;
  84299. /**
  84300. * Interface for a glTF exporter extension
  84301. * @hidden
  84302. */
  84303. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84304. /**
  84305. * Define this method to modify the default behavior before exporting a texture
  84306. * @param context The context when loading the asset
  84307. * @param babylonTexture The Babylon.js texture
  84308. * @param mimeType The mime-type of the generated image
  84309. * @returns A promise that resolves with the exported texture
  84310. */
  84311. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84312. /**
  84313. * Define this method to get notified when a texture info is created
  84314. * @param context The context when loading the asset
  84315. * @param textureInfo The glTF texture info
  84316. * @param babylonTexture The Babylon.js texture
  84317. */
  84318. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84319. /**
  84320. * Define this method to modify the default behavior when exporting texture info
  84321. * @param context The context when loading the asset
  84322. * @param meshPrimitive glTF mesh primitive
  84323. * @param babylonSubMesh Babylon submesh
  84324. * @param binaryWriter glTF serializer binary writer instance
  84325. * @returns nullable IMeshPrimitive promise
  84326. */
  84327. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84328. /**
  84329. * Define this method to modify the default behavior when exporting a node
  84330. * @param context The context when exporting the node
  84331. * @param node glTF node
  84332. * @param babylonNode BabylonJS node
  84333. * @returns nullable INode promise
  84334. */
  84335. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84336. [key: number]: number;
  84337. }): Promise<Nullable<INode>>;
  84338. /**
  84339. * Define this method to modify the default behavior when exporting a material
  84340. * @param material glTF material
  84341. * @param babylonMaterial BabylonJS material
  84342. * @returns nullable IMaterial promise
  84343. */
  84344. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84345. /**
  84346. * Define this method to return additional textures to export from a material
  84347. * @param material glTF material
  84348. * @param babylonMaterial BabylonJS material
  84349. * @returns List of textures
  84350. */
  84351. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84352. /** Gets a boolean indicating that this extension was used */
  84353. wasUsed: boolean;
  84354. /** Gets a boolean indicating that this extension is required for the file to work */
  84355. required: boolean;
  84356. /**
  84357. * Called after the exporter state changes to EXPORTING
  84358. */
  84359. onExporting?(): void;
  84360. }
  84361. }
  84362. declare module BABYLON.GLTF2.Exporter {
  84363. /**
  84364. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  84365. * @hidden
  84366. */
  84367. export class _GLTFMaterialExporter {
  84368. /**
  84369. * Represents the dielectric specular values for R, G and B
  84370. */
  84371. private static readonly _DielectricSpecular;
  84372. /**
  84373. * Allows the maximum specular power to be defined for material calculations
  84374. */
  84375. private static readonly _MaxSpecularPower;
  84376. /**
  84377. * Mapping to store textures
  84378. */
  84379. private _textureMap;
  84380. /**
  84381. * Numeric tolerance value
  84382. */
  84383. private static readonly _Epsilon;
  84384. /**
  84385. * Reference to the glTF Exporter
  84386. */
  84387. private _exporter;
  84388. constructor(exporter: _Exporter);
  84389. /**
  84390. * Specifies if two colors are approximately equal in value
  84391. * @param color1 first color to compare to
  84392. * @param color2 second color to compare to
  84393. * @param epsilon threshold value
  84394. */
  84395. private static FuzzyEquals;
  84396. /**
  84397. * Gets the materials from a Babylon scene and converts them to glTF materials
  84398. * @param scene babylonjs scene
  84399. * @param mimeType texture mime type
  84400. * @param images array of images
  84401. * @param textures array of textures
  84402. * @param materials array of materials
  84403. * @param imageData mapping of texture names to base64 textures
  84404. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84405. */
  84406. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84407. /**
  84408. * Makes a copy of the glTF material without the texture parameters
  84409. * @param originalMaterial original glTF material
  84410. * @returns glTF material without texture parameters
  84411. */
  84412. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84413. /**
  84414. * Specifies if the material has any texture parameters present
  84415. * @param material glTF Material
  84416. * @returns boolean specifying if texture parameters are present
  84417. */
  84418. _hasTexturesPresent(material: IMaterial): boolean;
  84419. /**
  84420. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84421. * @param babylonStandardMaterial
  84422. * @returns glTF Metallic Roughness Material representation
  84423. */
  84424. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84425. /**
  84426. * Computes the metallic factor
  84427. * @param diffuse diffused value
  84428. * @param specular specular value
  84429. * @param oneMinusSpecularStrength one minus the specular strength
  84430. * @returns metallic value
  84431. */
  84432. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84433. /**
  84434. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84435. * @param glTFMaterial glTF material
  84436. * @param babylonMaterial Babylon material
  84437. */
  84438. private static _SetAlphaMode;
  84439. /**
  84440. * Converts a Babylon Standard Material to a glTF Material
  84441. * @param babylonStandardMaterial BJS Standard Material
  84442. * @param mimeType mime type to use for the textures
  84443. * @param images array of glTF image interfaces
  84444. * @param textures array of glTF texture interfaces
  84445. * @param materials array of glTF material interfaces
  84446. * @param imageData map of image file name to data
  84447. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84448. */
  84449. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84450. private _finishMaterial;
  84451. /**
  84452. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84453. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84454. * @param mimeType mime type to use for the textures
  84455. * @param images array of glTF image interfaces
  84456. * @param textures array of glTF texture interfaces
  84457. * @param materials array of glTF material interfaces
  84458. * @param imageData map of image file name to data
  84459. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84460. */
  84461. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84462. /**
  84463. * Converts an image typed array buffer to a base64 image
  84464. * @param buffer typed array buffer
  84465. * @param width width of the image
  84466. * @param height height of the image
  84467. * @param mimeType mimetype of the image
  84468. * @returns base64 image string
  84469. */
  84470. private _createBase64FromCanvasAsync;
  84471. /**
  84472. * Generates a white texture based on the specified width and height
  84473. * @param width width of the texture in pixels
  84474. * @param height height of the texture in pixels
  84475. * @param scene babylonjs scene
  84476. * @returns white texture
  84477. */
  84478. private _createWhiteTexture;
  84479. /**
  84480. * 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
  84481. * @param texture1 first texture to resize
  84482. * @param texture2 second texture to resize
  84483. * @param scene babylonjs scene
  84484. * @returns resized textures or null
  84485. */
  84486. private _resizeTexturesToSameDimensions;
  84487. /**
  84488. * Converts an array of pixels to a Float32Array
  84489. * Throws an error if the pixel format is not supported
  84490. * @param pixels - array buffer containing pixel values
  84491. * @returns Float32 of pixels
  84492. */
  84493. private _convertPixelArrayToFloat32;
  84494. /**
  84495. * Convert Specular Glossiness Textures to Metallic Roughness
  84496. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84497. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84498. * @param diffuseTexture texture used to store diffuse information
  84499. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84500. * @param factors specular glossiness material factors
  84501. * @param mimeType the mime type to use for the texture
  84502. * @returns pbr metallic roughness interface or null
  84503. */
  84504. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84505. /**
  84506. * Converts specular glossiness material properties to metallic roughness
  84507. * @param specularGlossiness interface with specular glossiness material properties
  84508. * @returns interface with metallic roughness material properties
  84509. */
  84510. private _convertSpecularGlossinessToMetallicRoughness;
  84511. /**
  84512. * Calculates the surface reflectance, independent of lighting conditions
  84513. * @param color Color source to calculate brightness from
  84514. * @returns number representing the perceived brightness, or zero if color is undefined
  84515. */
  84516. private _getPerceivedBrightness;
  84517. /**
  84518. * Returns the maximum color component value
  84519. * @param color
  84520. * @returns maximum color component value, or zero if color is null or undefined
  84521. */
  84522. private _getMaxComponent;
  84523. /**
  84524. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84525. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84526. * @param mimeType mime type to use for the textures
  84527. * @param images array of glTF image interfaces
  84528. * @param textures array of glTF texture interfaces
  84529. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84530. * @param imageData map of image file name to data
  84531. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84532. * @returns glTF PBR Metallic Roughness factors
  84533. */
  84534. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84535. private _getGLTFTextureSampler;
  84536. private _getGLTFTextureWrapMode;
  84537. private _getGLTFTextureWrapModesSampler;
  84538. /**
  84539. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84540. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84541. * @param mimeType mime type to use for the textures
  84542. * @param images array of glTF image interfaces
  84543. * @param textures array of glTF texture interfaces
  84544. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84545. * @param imageData map of image file name to data
  84546. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84547. * @returns glTF PBR Metallic Roughness factors
  84548. */
  84549. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84550. /**
  84551. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84552. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84553. * @param mimeType mime type to use for the textures
  84554. * @param images array of glTF image interfaces
  84555. * @param textures array of glTF texture interfaces
  84556. * @param materials array of glTF material interfaces
  84557. * @param imageData map of image file name to data
  84558. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84559. */
  84560. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84561. private setMetallicRoughnessPbrMaterial;
  84562. private getPixelsFromTexture;
  84563. /**
  84564. * Extracts a texture from a Babylon texture into file data and glTF data
  84565. * @param babylonTexture Babylon texture to extract
  84566. * @param mimeType Mime Type of the babylonTexture
  84567. * @return glTF texture info, or null if the texture format is not supported
  84568. */
  84569. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84570. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84571. /**
  84572. * Builds a texture from base64 string
  84573. * @param base64Texture base64 texture string
  84574. * @param baseTextureName Name to use for the texture
  84575. * @param mimeType image mime type for the texture
  84576. * @param images array of images
  84577. * @param textures array of textures
  84578. * @param imageData map of image data
  84579. * @returns glTF texture info, or null if the texture format is not supported
  84580. */
  84581. private _getTextureInfoFromBase64;
  84582. }
  84583. }
  84584. declare module BABYLON {
  84585. /**
  84586. * Class for holding and downloading glTF file data
  84587. */
  84588. export class GLTFData {
  84589. /**
  84590. * Object which contains the file name as the key and its data as the value
  84591. */
  84592. glTFFiles: {
  84593. [fileName: string]: string | Blob;
  84594. };
  84595. /**
  84596. * Initializes the glTF file object
  84597. */
  84598. constructor();
  84599. /**
  84600. * Downloads the glTF data as files based on their names and data
  84601. */
  84602. downloadFiles(): void;
  84603. }
  84604. }
  84605. declare module BABYLON {
  84606. /**
  84607. * Holds a collection of exporter options and parameters
  84608. */
  84609. export interface IExportOptions {
  84610. /**
  84611. * Function which indicates whether a babylon node should be exported or not
  84612. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84613. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84614. */
  84615. shouldExportNode?(node: Node): boolean;
  84616. /**
  84617. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84618. * @param metadata source metadata to read from
  84619. * @returns the data to store to glTF node extras
  84620. */
  84621. metadataSelector?(metadata: any): any;
  84622. /**
  84623. * The sample rate to bake animation curves
  84624. */
  84625. animationSampleRate?: number;
  84626. /**
  84627. * Begin serialization without waiting for the scene to be ready
  84628. */
  84629. exportWithoutWaitingForScene?: boolean;
  84630. /**
  84631. * Indicates if coordinate system swapping root nodes should be included in export
  84632. */
  84633. includeCoordinateSystemConversionNodes?: boolean;
  84634. }
  84635. /**
  84636. * Class for generating glTF data from a Babylon scene.
  84637. */
  84638. export class GLTF2Export {
  84639. /**
  84640. * Exports the geometry of the scene to .gltf file format asynchronously
  84641. * @param scene Babylon scene with scene hierarchy information
  84642. * @param filePrefix File prefix to use when generating the glTF file
  84643. * @param options Exporter options
  84644. * @returns Returns an object with a .gltf file and associates texture names
  84645. * as keys and their data and paths as values
  84646. */
  84647. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84648. private static _PreExportAsync;
  84649. private static _PostExportAsync;
  84650. /**
  84651. * Exports the geometry of the scene to .glb file format asychronously
  84652. * @param scene Babylon scene with scene hierarchy information
  84653. * @param filePrefix File prefix to use when generating glb file
  84654. * @param options Exporter options
  84655. * @returns Returns an object with a .glb filename as key and data as value
  84656. */
  84657. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84658. }
  84659. }
  84660. declare module BABYLON.GLTF2.Exporter {
  84661. /**
  84662. * @hidden
  84663. */
  84664. export class _GLTFUtilities {
  84665. /**
  84666. * Creates a buffer view based on the supplied arguments
  84667. * @param bufferIndex index value of the specified buffer
  84668. * @param byteOffset byte offset value
  84669. * @param byteLength byte length of the bufferView
  84670. * @param byteStride byte distance between conequential elements
  84671. * @param name name of the buffer view
  84672. * @returns bufferView for glTF
  84673. */
  84674. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  84675. /**
  84676. * Creates an accessor based on the supplied arguments
  84677. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  84678. * @param name The name of the accessor
  84679. * @param type The type of the accessor
  84680. * @param componentType The datatype of components in the attribute
  84681. * @param count The number of attributes referenced by this accessor
  84682. * @param byteOffset The offset relative to the start of the bufferView in bytes
  84683. * @param min Minimum value of each component in this attribute
  84684. * @param max Maximum value of each component in this attribute
  84685. * @returns accessor for glTF
  84686. */
  84687. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  84688. /**
  84689. * Calculates the minimum and maximum values of an array of position floats
  84690. * @param positions Positions array of a mesh
  84691. * @param vertexStart Starting vertex offset to calculate min and max values
  84692. * @param vertexCount Number of vertices to check for min and max values
  84693. * @returns min number array and max number array
  84694. */
  84695. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  84696. min: number[];
  84697. max: number[];
  84698. };
  84699. /**
  84700. * Converts a new right-handed Vector3
  84701. * @param vector vector3 array
  84702. * @returns right-handed Vector3
  84703. */
  84704. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  84705. /**
  84706. * Converts a Vector3 to right-handed
  84707. * @param vector Vector3 to convert to right-handed
  84708. */
  84709. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  84710. /**
  84711. * Converts a three element number array to right-handed
  84712. * @param vector number array to convert to right-handed
  84713. */
  84714. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  84715. /**
  84716. * Converts a new right-handed Vector3
  84717. * @param vector vector3 array
  84718. * @returns right-handed Vector3
  84719. */
  84720. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  84721. /**
  84722. * Converts a Vector3 to right-handed
  84723. * @param vector Vector3 to convert to right-handed
  84724. */
  84725. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  84726. /**
  84727. * Converts a three element number array to right-handed
  84728. * @param vector number array to convert to right-handed
  84729. */
  84730. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  84731. /**
  84732. * Converts a Vector4 to right-handed
  84733. * @param vector Vector4 to convert to right-handed
  84734. */
  84735. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  84736. /**
  84737. * Converts a Vector4 to right-handed
  84738. * @param vector Vector4 to convert to right-handed
  84739. */
  84740. static _GetRightHandedArray4FromRef(vector: number[]): void;
  84741. /**
  84742. * Converts a Quaternion to right-handed
  84743. * @param quaternion Source quaternion to convert to right-handed
  84744. */
  84745. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  84746. /**
  84747. * Converts a Quaternion to right-handed
  84748. * @param quaternion Source quaternion to convert to right-handed
  84749. */
  84750. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  84751. static _NormalizeTangentFromRef(tangent: Vector4): void;
  84752. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  84753. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  84754. }
  84755. }
  84756. declare module BABYLON.GLTF2.Exporter {
  84757. /**
  84758. * Converts Babylon Scene into glTF 2.0.
  84759. * @hidden
  84760. */
  84761. export class _Exporter {
  84762. /**
  84763. * Stores the glTF to export
  84764. */
  84765. _glTF: IGLTF;
  84766. /**
  84767. * Stores all generated buffer views, which represents views into the main glTF buffer data
  84768. */
  84769. _bufferViews: IBufferView[];
  84770. /**
  84771. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  84772. */
  84773. _accessors: IAccessor[];
  84774. /**
  84775. * Stores all the generated nodes, which contains transform and/or mesh information per node
  84776. */
  84777. _nodes: INode[];
  84778. /**
  84779. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  84780. */
  84781. private _scenes;
  84782. /**
  84783. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  84784. */
  84785. private _meshes;
  84786. /**
  84787. * Stores all the generated material information, which represents the appearance of each primitive
  84788. */
  84789. _materials: IMaterial[];
  84790. _materialMap: {
  84791. [materialID: number]: number;
  84792. };
  84793. /**
  84794. * Stores all the generated texture information, which is referenced by glTF materials
  84795. */
  84796. _textures: ITexture[];
  84797. /**
  84798. * Stores all the generated image information, which is referenced by glTF textures
  84799. */
  84800. _images: IImage[];
  84801. /**
  84802. * Stores all the texture samplers
  84803. */
  84804. _samplers: ISampler[];
  84805. /**
  84806. * Stores all the generated glTF skins
  84807. */
  84808. _skins: ISkin[];
  84809. /**
  84810. * Stores all the generated animation samplers, which is referenced by glTF animations
  84811. */
  84812. /**
  84813. * Stores the animations for glTF models
  84814. */
  84815. private _animations;
  84816. /**
  84817. * Stores the total amount of bytes stored in the glTF buffer
  84818. */
  84819. private _totalByteLength;
  84820. /**
  84821. * Stores a reference to the Babylon scene containing the source geometry and material information
  84822. */
  84823. _babylonScene: Scene;
  84824. /**
  84825. * Stores a map of the image data, where the key is the file name and the value
  84826. * is the image data
  84827. */
  84828. _imageData: {
  84829. [fileName: string]: {
  84830. data: Uint8Array;
  84831. mimeType: ImageMimeType;
  84832. };
  84833. };
  84834. protected _orderedImageData: Array<{
  84835. data: Uint8Array;
  84836. mimeType: ImageMimeType;
  84837. }>;
  84838. /**
  84839. * Stores a map of the unique id of a node to its index in the node array
  84840. */
  84841. _nodeMap: {
  84842. [key: number]: number;
  84843. };
  84844. /**
  84845. * Specifies if the source Babylon scene was left handed, and needed conversion.
  84846. */
  84847. _convertToRightHandedSystem: boolean;
  84848. /**
  84849. * Specifies if a Babylon node should be converted to right-handed on export
  84850. */
  84851. _convertToRightHandedSystemMap: {
  84852. [nodeId: number]: boolean;
  84853. };
  84854. _includeCoordinateSystemConversionNodes: boolean;
  84855. /**
  84856. * Baked animation sample rate
  84857. */
  84858. private _animationSampleRate;
  84859. private _options;
  84860. private _localEngine;
  84861. _glTFMaterialExporter: _GLTFMaterialExporter;
  84862. private _extensions;
  84863. private static _ExtensionNames;
  84864. private static _ExtensionFactories;
  84865. private _applyExtension;
  84866. private _applyExtensions;
  84867. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  84868. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  84869. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84870. [key: number]: number;
  84871. }): Promise<Nullable<INode>>;
  84872. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  84873. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  84874. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84875. private _forEachExtensions;
  84876. private _extensionsOnExporting;
  84877. /**
  84878. * Load glTF serializer extensions
  84879. */
  84880. private _loadExtensions;
  84881. /**
  84882. * Creates a glTF Exporter instance, which can accept optional exporter options
  84883. * @param babylonScene Babylon scene object
  84884. * @param options Options to modify the behavior of the exporter
  84885. */
  84886. constructor(babylonScene: Scene, options?: IExportOptions);
  84887. dispose(): void;
  84888. /**
  84889. * Registers a glTF exporter extension
  84890. * @param name Name of the extension to export
  84891. * @param factory The factory function that creates the exporter extension
  84892. */
  84893. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  84894. /**
  84895. * Un-registers an exporter extension
  84896. * @param name The name fo the exporter extension
  84897. * @returns A boolean indicating whether the extension has been un-registered
  84898. */
  84899. static UnregisterExtension(name: string): boolean;
  84900. /**
  84901. * Lazy load a local engine
  84902. */
  84903. _getLocalEngine(): Engine;
  84904. private reorderIndicesBasedOnPrimitiveMode;
  84905. /**
  84906. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  84907. * clock-wise during export to glTF
  84908. * @param submesh BabylonJS submesh
  84909. * @param primitiveMode Primitive mode of the mesh
  84910. * @param sideOrientation the winding order of the submesh
  84911. * @param vertexBufferKind The type of vertex attribute
  84912. * @param meshAttributeArray The vertex attribute data
  84913. * @param byteOffset The offset to the binary data
  84914. * @param binaryWriter The binary data for the glTF file
  84915. * @param convertToRightHandedSystem Converts the values to right-handed
  84916. */
  84917. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  84918. /**
  84919. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  84920. * clock-wise during export to glTF
  84921. * @param submesh BabylonJS submesh
  84922. * @param primitiveMode Primitive mode of the mesh
  84923. * @param sideOrientation the winding order of the submesh
  84924. * @param vertexBufferKind The type of vertex attribute
  84925. * @param meshAttributeArray The vertex attribute data
  84926. * @param byteOffset The offset to the binary data
  84927. * @param binaryWriter The binary data for the glTF file
  84928. * @param convertToRightHandedSystem Converts the values to right-handed
  84929. */
  84930. private reorderTriangleFillMode;
  84931. /**
  84932. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84933. * clock-wise during export to glTF
  84934. * @param submesh BabylonJS submesh
  84935. * @param primitiveMode Primitive mode of the mesh
  84936. * @param sideOrientation the winding order of the submesh
  84937. * @param vertexBufferKind The type of vertex attribute
  84938. * @param meshAttributeArray The vertex attribute data
  84939. * @param byteOffset The offset to the binary data
  84940. * @param binaryWriter The binary data for the glTF file
  84941. * @param convertToRightHandedSystem Converts the values to right-handed
  84942. */
  84943. private reorderTriangleStripDrawMode;
  84944. /**
  84945. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  84946. * clock-wise during export to glTF
  84947. * @param submesh BabylonJS submesh
  84948. * @param primitiveMode Primitive mode of the mesh
  84949. * @param sideOrientation the winding order of the submesh
  84950. * @param vertexBufferKind The type of vertex attribute
  84951. * @param meshAttributeArray The vertex attribute data
  84952. * @param byteOffset The offset to the binary data
  84953. * @param binaryWriter The binary data for the glTF file
  84954. * @param convertToRightHandedSystem Converts the values to right-handed
  84955. */
  84956. private reorderTriangleFanMode;
  84957. /**
  84958. * Writes the vertex attribute data to binary
  84959. * @param vertices The vertices to write to the binary writer
  84960. * @param byteOffset The offset into the binary writer to overwrite binary data
  84961. * @param vertexAttributeKind The vertex attribute type
  84962. * @param meshAttributeArray The vertex attribute data
  84963. * @param binaryWriter The writer containing the binary data
  84964. * @param convertToRightHandedSystem Converts the values to right-handed
  84965. */
  84966. private writeVertexAttributeData;
  84967. /**
  84968. * Writes mesh attribute data to a data buffer
  84969. * Returns the bytelength of the data
  84970. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84971. * @param meshAttributeArray Array containing the attribute data
  84972. * @param byteStride Specifies the space between data
  84973. * @param binaryWriter The buffer to write the binary data to
  84974. * @param convertToRightHandedSystem Converts the values to right-handed
  84975. */
  84976. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  84977. /**
  84978. * Writes mesh attribute data to a data buffer
  84979. * Returns the bytelength of the data
  84980. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84981. * @param meshAttributeArray Array containing the attribute data
  84982. * @param byteStride Specifies the space between data
  84983. * @param binaryWriter The buffer to write the binary data to
  84984. * @param convertToRightHandedSystem Converts the values to right-handed
  84985. */
  84986. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  84987. /**
  84988. * Generates glTF json data
  84989. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  84990. * @param glTFPrefix Text to use when prefixing a glTF file
  84991. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  84992. * @returns json data as string
  84993. */
  84994. private generateJSON;
  84995. /**
  84996. * Generates data for .gltf and .bin files based on the glTF prefix string
  84997. * @param glTFPrefix Text to use when prefixing a glTF file
  84998. * @param dispose Dispose the exporter
  84999. * @returns GLTFData with glTF file data
  85000. */
  85001. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85002. /**
  85003. * Creates a binary buffer for glTF
  85004. * @returns array buffer for binary data
  85005. */
  85006. private _generateBinaryAsync;
  85007. /**
  85008. * Pads the number to a multiple of 4
  85009. * @param num number to pad
  85010. * @returns padded number
  85011. */
  85012. private _getPadding;
  85013. /**
  85014. * @hidden
  85015. */
  85016. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85017. /**
  85018. * Sets the TRS for each node
  85019. * @param node glTF Node for storing the transformation data
  85020. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  85021. * @param convertToRightHandedSystem Converts the values to right-handed
  85022. */
  85023. private setNodeTransformation;
  85024. private getVertexBufferFromMesh;
  85025. /**
  85026. * Creates a bufferview based on the vertices type for the Babylon mesh
  85027. * @param kind Indicates the type of vertices data
  85028. * @param componentType Indicates the numerical type used to store the data
  85029. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  85030. * @param binaryWriter The buffer to write the bufferview data to
  85031. * @param convertToRightHandedSystem Converts the values to right-handed
  85032. */
  85033. private createBufferViewKind;
  85034. /**
  85035. * Creates a bufferview based on the vertices type for the Babylon mesh
  85036. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  85037. * @param babylonMorphTarget the morph target to be exported
  85038. * @param binaryWriter The buffer to write the bufferview data to
  85039. * @param convertToRightHandedSystem Converts the values to right-handed
  85040. */
  85041. private setMorphTargetAttributes;
  85042. /**
  85043. * The primitive mode of the Babylon mesh
  85044. * @param babylonMesh The BabylonJS mesh
  85045. */
  85046. private getMeshPrimitiveMode;
  85047. /**
  85048. * Sets the primitive mode of the glTF mesh primitive
  85049. * @param meshPrimitive glTF mesh primitive
  85050. * @param primitiveMode The primitive mode
  85051. */
  85052. private setPrimitiveMode;
  85053. /**
  85054. * Sets the vertex attribute accessor based of the glTF mesh primitive
  85055. * @param meshPrimitive glTF mesh primitive
  85056. * @param attributeKind vertex attribute
  85057. * @returns boolean specifying if uv coordinates are present
  85058. */
  85059. private setAttributeKind;
  85060. /**
  85061. * Sets data for the primitive attributes of each submesh
  85062. * @param mesh glTF Mesh object to store the primitive attribute information
  85063. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  85064. * @param binaryWriter Buffer to write the attribute data to
  85065. * @param convertToRightHandedSystem Converts the values to right-handed
  85066. */
  85067. private setPrimitiveAttributesAsync;
  85068. /**
  85069. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  85070. * @param node The node to check
  85071. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  85072. */
  85073. private isBabylonCoordinateSystemConvertingNode;
  85074. /**
  85075. * Creates a glTF scene based on the array of meshes
  85076. * Returns the the total byte offset
  85077. * @param babylonScene Babylon scene to get the mesh data from
  85078. * @param binaryWriter Buffer to write binary data to
  85079. */
  85080. private createSceneAsync;
  85081. /**
  85082. * Creates a mapping of Node unique id to node index and handles animations
  85083. * @param babylonScene Babylon Scene
  85084. * @param nodes Babylon transform nodes
  85085. * @param binaryWriter Buffer to write binary data to
  85086. * @returns Node mapping of unique id to index
  85087. */
  85088. private createNodeMapAndAnimationsAsync;
  85089. /**
  85090. * Creates a glTF node from a Babylon mesh
  85091. * @param babylonMesh Source Babylon mesh
  85092. * @param binaryWriter Buffer for storing geometry data
  85093. * @param convertToRightHandedSystem Converts the values to right-handed
  85094. * @param nodeMap Node mapping of unique id to glTF node index
  85095. * @returns glTF node
  85096. */
  85097. private createNodeAsync;
  85098. /**
  85099. * Creates a glTF skin from a Babylon skeleton
  85100. * @param babylonScene Babylon Scene
  85101. * @param nodes Babylon transform nodes
  85102. * @param binaryWriter Buffer to write binary data to
  85103. * @returns Node mapping of unique id to index
  85104. */
  85105. private createSkinsAsync;
  85106. }
  85107. /**
  85108. * @hidden
  85109. *
  85110. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85111. */
  85112. export class _BinaryWriter {
  85113. /**
  85114. * Array buffer which stores all binary data
  85115. */
  85116. private _arrayBuffer;
  85117. /**
  85118. * View of the array buffer
  85119. */
  85120. private _dataView;
  85121. /**
  85122. * byte offset of data in array buffer
  85123. */
  85124. private _byteOffset;
  85125. /**
  85126. * Initialize binary writer with an initial byte length
  85127. * @param byteLength Initial byte length of the array buffer
  85128. */
  85129. constructor(byteLength: number);
  85130. /**
  85131. * Resize the array buffer to the specified byte length
  85132. * @param byteLength
  85133. */
  85134. private resizeBuffer;
  85135. /**
  85136. * Get an array buffer with the length of the byte offset
  85137. * @returns ArrayBuffer resized to the byte offset
  85138. */
  85139. getArrayBuffer(): ArrayBuffer;
  85140. /**
  85141. * Get the byte offset of the array buffer
  85142. * @returns byte offset
  85143. */
  85144. getByteOffset(): number;
  85145. /**
  85146. * Stores an UInt8 in the array buffer
  85147. * @param entry
  85148. * @param byteOffset If defined, specifies where to set the value as an offset.
  85149. */
  85150. setUInt8(entry: number, byteOffset?: number): void;
  85151. /**
  85152. * Stores an UInt16 in the array buffer
  85153. * @param entry
  85154. * @param byteOffset If defined, specifies where to set the value as an offset.
  85155. */
  85156. setUInt16(entry: number, byteOffset?: number): void;
  85157. /**
  85158. * Gets an UInt32 in the array buffer
  85159. * @param entry
  85160. * @param byteOffset If defined, specifies where to set the value as an offset.
  85161. */
  85162. getUInt32(byteOffset: number): number;
  85163. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85164. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85165. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85166. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85167. /**
  85168. * Stores a Float32 in the array buffer
  85169. * @param entry
  85170. */
  85171. setFloat32(entry: number, byteOffset?: number): void;
  85172. /**
  85173. * Stores an UInt32 in the array buffer
  85174. * @param entry
  85175. * @param byteOffset If defined, specifies where to set the value as an offset.
  85176. */
  85177. setUInt32(entry: number, byteOffset?: number): void;
  85178. }
  85179. }
  85180. declare module BABYLON.GLTF2.Exporter {
  85181. /**
  85182. * @hidden
  85183. * Interface to store animation data.
  85184. */
  85185. export interface _IAnimationData {
  85186. /**
  85187. * Keyframe data.
  85188. */
  85189. inputs: number[];
  85190. /**
  85191. * Value data.
  85192. */
  85193. outputs: number[][];
  85194. /**
  85195. * Animation interpolation data.
  85196. */
  85197. samplerInterpolation: AnimationSamplerInterpolation;
  85198. /**
  85199. * Minimum keyframe value.
  85200. */
  85201. inputsMin: number;
  85202. /**
  85203. * Maximum keyframe value.
  85204. */
  85205. inputsMax: number;
  85206. }
  85207. /**
  85208. * @hidden
  85209. */
  85210. export interface _IAnimationInfo {
  85211. /**
  85212. * The target channel for the animation
  85213. */
  85214. animationChannelTargetPath: AnimationChannelTargetPath;
  85215. /**
  85216. * The glTF accessor type for the data.
  85217. */
  85218. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85219. /**
  85220. * Specifies if quaternions should be used.
  85221. */
  85222. useQuaternion: boolean;
  85223. }
  85224. /**
  85225. * @hidden
  85226. * Utility class for generating glTF animation data from BabylonJS.
  85227. */
  85228. export class _GLTFAnimation {
  85229. /**
  85230. * @ignore
  85231. *
  85232. * Creates glTF channel animation from BabylonJS animation.
  85233. * @param babylonTransformNode - BabylonJS mesh.
  85234. * @param animation - animation.
  85235. * @param animationChannelTargetPath - The target animation channel.
  85236. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85237. * @param useQuaternion - Specifies if quaternions are used.
  85238. * @returns nullable IAnimationData
  85239. */
  85240. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85241. private static _DeduceAnimationInfo;
  85242. /**
  85243. * @ignore
  85244. * Create node animations from the transform node animations
  85245. * @param babylonNode
  85246. * @param runtimeGLTFAnimation
  85247. * @param idleGLTFAnimations
  85248. * @param nodeMap
  85249. * @param nodes
  85250. * @param binaryWriter
  85251. * @param bufferViews
  85252. * @param accessors
  85253. * @param convertToRightHandedSystem
  85254. * @param animationSampleRate
  85255. */
  85256. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85257. [key: number]: number;
  85258. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85259. /**
  85260. * @ignore
  85261. * Create individual morph animations from the mesh's morph target animation tracks
  85262. * @param babylonNode
  85263. * @param runtimeGLTFAnimation
  85264. * @param idleGLTFAnimations
  85265. * @param nodeMap
  85266. * @param nodes
  85267. * @param binaryWriter
  85268. * @param bufferViews
  85269. * @param accessors
  85270. * @param convertToRightHandedSystem
  85271. * @param animationSampleRate
  85272. */
  85273. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85274. [key: number]: number;
  85275. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85276. /**
  85277. * @ignore
  85278. * Create node and morph animations from the animation groups
  85279. * @param babylonScene
  85280. * @param glTFAnimations
  85281. * @param nodeMap
  85282. * @param nodes
  85283. * @param binaryWriter
  85284. * @param bufferViews
  85285. * @param accessors
  85286. * @param convertToRightHandedSystemMap
  85287. * @param animationSampleRate
  85288. */
  85289. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85290. [key: number]: number;
  85291. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85292. [nodeId: number]: boolean;
  85293. }, animationSampleRate: number): void;
  85294. private static AddAnimation;
  85295. /**
  85296. * Create a baked animation
  85297. * @param babylonTransformNode BabylonJS mesh
  85298. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85299. * @param animationChannelTargetPath animation target channel
  85300. * @param minFrame minimum animation frame
  85301. * @param maxFrame maximum animation frame
  85302. * @param fps frames per second of the animation
  85303. * @param inputs input key frames of the animation
  85304. * @param outputs output key frame data of the animation
  85305. * @param convertToRightHandedSystem converts the values to right-handed
  85306. * @param useQuaternion specifies if quaternions should be used
  85307. */
  85308. private static _CreateBakedAnimation;
  85309. private static _ConvertFactorToVector3OrQuaternion;
  85310. private static _SetInterpolatedValue;
  85311. /**
  85312. * Creates linear animation from the animation key frames
  85313. * @param babylonTransformNode BabylonJS mesh
  85314. * @param animation BabylonJS animation
  85315. * @param animationChannelTargetPath The target animation channel
  85316. * @param frameDelta The difference between the last and first frame of the animation
  85317. * @param inputs Array to store the key frame times
  85318. * @param outputs Array to store the key frame data
  85319. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85320. * @param useQuaternion Specifies if quaternions are used in the animation
  85321. */
  85322. private static _CreateLinearOrStepAnimation;
  85323. /**
  85324. * Creates cubic spline animation from the animation key frames
  85325. * @param babylonTransformNode BabylonJS mesh
  85326. * @param animation BabylonJS animation
  85327. * @param animationChannelTargetPath The target animation channel
  85328. * @param frameDelta The difference between the last and first frame of the animation
  85329. * @param inputs Array to store the key frame times
  85330. * @param outputs Array to store the key frame data
  85331. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85332. * @param useQuaternion Specifies if quaternions are used in the animation
  85333. */
  85334. private static _CreateCubicSplineAnimation;
  85335. private static _GetBasePositionRotationOrScale;
  85336. /**
  85337. * Adds a key frame value
  85338. * @param keyFrame
  85339. * @param animation
  85340. * @param outputs
  85341. * @param animationChannelTargetPath
  85342. * @param basePositionRotationOrScale
  85343. * @param convertToRightHandedSystem
  85344. * @param useQuaternion
  85345. */
  85346. private static _AddKeyframeValue;
  85347. /**
  85348. * Determine the interpolation based on the key frames
  85349. * @param keyFrames
  85350. * @param animationChannelTargetPath
  85351. * @param useQuaternion
  85352. */
  85353. private static _DeduceInterpolation;
  85354. /**
  85355. * Adds an input tangent or output tangent to the output data
  85356. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85357. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85358. * @param outputs The animation data by keyframe
  85359. * @param animationChannelTargetPath The target animation channel
  85360. * @param interpolation The interpolation type
  85361. * @param keyFrame The key frame with the animation data
  85362. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85363. * @param useQuaternion Specifies if quaternions are used
  85364. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  85365. */
  85366. private static AddSplineTangent;
  85367. /**
  85368. * Get the minimum and maximum key frames' frame values
  85369. * @param keyFrames animation key frames
  85370. * @returns the minimum and maximum key frame value
  85371. */
  85372. private static calculateMinMaxKeyFrames;
  85373. }
  85374. }
  85375. declare module BABYLON.GLTF2.Exporter {
  85376. /** @hidden */
  85377. export var textureTransformPixelShader: {
  85378. name: string;
  85379. shader: string;
  85380. };
  85381. }
  85382. declare module BABYLON.GLTF2.Exporter.Extensions {
  85383. /**
  85384. * @hidden
  85385. */
  85386. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  85387. private _recordedTextures;
  85388. /** Name of this extension */
  85389. readonly name: string;
  85390. /** Defines whether this extension is enabled */
  85391. enabled: boolean;
  85392. /** Defines whether this extension is required */
  85393. required: boolean;
  85394. /** Reference to the glTF exporter */
  85395. private _wasUsed;
  85396. constructor(exporter: _Exporter);
  85397. dispose(): void;
  85398. /** @hidden */
  85399. get wasUsed(): boolean;
  85400. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85401. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85402. /**
  85403. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85404. * @param babylonTexture
  85405. * @param offset
  85406. * @param rotation
  85407. * @param scale
  85408. * @param scene
  85409. */
  85410. private _textureTransformTextureAsync;
  85411. }
  85412. }
  85413. declare module BABYLON.GLTF2.Exporter.Extensions {
  85414. /**
  85415. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85416. */
  85417. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85418. /** The name of this extension. */
  85419. readonly name: string;
  85420. /** Defines whether this extension is enabled. */
  85421. enabled: boolean;
  85422. /** Defines whether this extension is required */
  85423. required: boolean;
  85424. /** Reference to the glTF exporter */
  85425. private _exporter;
  85426. private _lights;
  85427. /** @hidden */
  85428. constructor(exporter: _Exporter);
  85429. /** @hidden */
  85430. dispose(): void;
  85431. /** @hidden */
  85432. get wasUsed(): boolean;
  85433. /** @hidden */
  85434. onExporting(): void;
  85435. /**
  85436. * Define this method to modify the default behavior when exporting a node
  85437. * @param context The context when exporting the node
  85438. * @param node glTF node
  85439. * @param babylonNode BabylonJS node
  85440. * @param nodeMap Node mapping of unique id to glTF node index
  85441. * @returns nullable INode promise
  85442. */
  85443. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85444. [key: number]: number;
  85445. }): Promise<Nullable<INode>>;
  85446. }
  85447. }
  85448. declare module BABYLON.GLTF2.Exporter.Extensions {
  85449. /**
  85450. * @hidden
  85451. */
  85452. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85453. /** Name of this extension */
  85454. readonly name: string;
  85455. /** Defines whether this extension is enabled */
  85456. enabled: boolean;
  85457. /** Defines whether this extension is required */
  85458. required: boolean;
  85459. /** Reference to the glTF exporter */
  85460. private _textureInfos;
  85461. private _exportedTextures;
  85462. private _wasUsed;
  85463. constructor(exporter: _Exporter);
  85464. dispose(): void;
  85465. /** @hidden */
  85466. get wasUsed(): boolean;
  85467. private _getTextureIndex;
  85468. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85469. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85470. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85471. }
  85472. }
  85473. declare module BABYLON.GLTF2.Exporter.Extensions {
  85474. /**
  85475. * @hidden
  85476. */
  85477. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85478. /** Name of this extension */
  85479. readonly name: string;
  85480. /** Defines whether this extension is enabled */
  85481. enabled: boolean;
  85482. /** Defines whether this extension is required */
  85483. required: boolean;
  85484. private _wasUsed;
  85485. constructor(exporter: _Exporter);
  85486. /** @hidden */
  85487. get wasUsed(): boolean;
  85488. dispose(): void;
  85489. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85490. }
  85491. }
  85492. declare module BABYLON {
  85493. /**
  85494. * Class for generating STL data from a Babylon scene.
  85495. */
  85496. export class STLExport {
  85497. /**
  85498. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85499. * @param meshes list defines the mesh to serialize
  85500. * @param download triggers the automatic download of the file.
  85501. * @param fileName changes the downloads fileName.
  85502. * @param binary changes the STL to a binary type.
  85503. * @param isLittleEndian toggle for binary type exporter.
  85504. * @returns the STL as UTF8 string
  85505. */
  85506. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  85507. }
  85508. }
  85509. declare module "babylonjs-gltf2interface" {
  85510. export = BABYLON.GLTF2;
  85511. }
  85512. /**
  85513. * Module for glTF 2.0 Interface
  85514. */
  85515. declare module BABYLON.GLTF2 {
  85516. /**
  85517. * The datatype of the components in the attribute
  85518. */
  85519. const enum AccessorComponentType {
  85520. /**
  85521. * Byte
  85522. */
  85523. BYTE = 5120,
  85524. /**
  85525. * Unsigned Byte
  85526. */
  85527. UNSIGNED_BYTE = 5121,
  85528. /**
  85529. * Short
  85530. */
  85531. SHORT = 5122,
  85532. /**
  85533. * Unsigned Short
  85534. */
  85535. UNSIGNED_SHORT = 5123,
  85536. /**
  85537. * Unsigned Int
  85538. */
  85539. UNSIGNED_INT = 5125,
  85540. /**
  85541. * Float
  85542. */
  85543. FLOAT = 5126,
  85544. }
  85545. /**
  85546. * Specifies if the attirbute is a scalar, vector, or matrix
  85547. */
  85548. const enum AccessorType {
  85549. /**
  85550. * Scalar
  85551. */
  85552. SCALAR = "SCALAR",
  85553. /**
  85554. * Vector2
  85555. */
  85556. VEC2 = "VEC2",
  85557. /**
  85558. * Vector3
  85559. */
  85560. VEC3 = "VEC3",
  85561. /**
  85562. * Vector4
  85563. */
  85564. VEC4 = "VEC4",
  85565. /**
  85566. * Matrix2x2
  85567. */
  85568. MAT2 = "MAT2",
  85569. /**
  85570. * Matrix3x3
  85571. */
  85572. MAT3 = "MAT3",
  85573. /**
  85574. * Matrix4x4
  85575. */
  85576. MAT4 = "MAT4",
  85577. }
  85578. /**
  85579. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85580. */
  85581. const enum AnimationChannelTargetPath {
  85582. /**
  85583. * Translation
  85584. */
  85585. TRANSLATION = "translation",
  85586. /**
  85587. * Rotation
  85588. */
  85589. ROTATION = "rotation",
  85590. /**
  85591. * Scale
  85592. */
  85593. SCALE = "scale",
  85594. /**
  85595. * Weights
  85596. */
  85597. WEIGHTS = "weights",
  85598. }
  85599. /**
  85600. * Interpolation algorithm
  85601. */
  85602. const enum AnimationSamplerInterpolation {
  85603. /**
  85604. * The animated values are linearly interpolated between keyframes
  85605. */
  85606. LINEAR = "LINEAR",
  85607. /**
  85608. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85609. */
  85610. STEP = "STEP",
  85611. /**
  85612. * The animation's interpolation is computed using a cubic spline with specified tangents
  85613. */
  85614. CUBICSPLINE = "CUBICSPLINE",
  85615. }
  85616. /**
  85617. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85618. */
  85619. const enum CameraType {
  85620. /**
  85621. * A perspective camera containing properties to create a perspective projection matrix
  85622. */
  85623. PERSPECTIVE = "perspective",
  85624. /**
  85625. * An orthographic camera containing properties to create an orthographic projection matrix
  85626. */
  85627. ORTHOGRAPHIC = "orthographic",
  85628. }
  85629. /**
  85630. * The mime-type of the image
  85631. */
  85632. const enum ImageMimeType {
  85633. /**
  85634. * JPEG Mime-type
  85635. */
  85636. JPEG = "image/jpeg",
  85637. /**
  85638. * PNG Mime-type
  85639. */
  85640. PNG = "image/png",
  85641. }
  85642. /**
  85643. * The alpha rendering mode of the material
  85644. */
  85645. const enum MaterialAlphaMode {
  85646. /**
  85647. * The alpha value is ignored and the rendered output is fully opaque
  85648. */
  85649. OPAQUE = "OPAQUE",
  85650. /**
  85651. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  85652. */
  85653. MASK = "MASK",
  85654. /**
  85655. * 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)
  85656. */
  85657. BLEND = "BLEND",
  85658. }
  85659. /**
  85660. * The type of the primitives to render
  85661. */
  85662. const enum MeshPrimitiveMode {
  85663. /**
  85664. * Points
  85665. */
  85666. POINTS = 0,
  85667. /**
  85668. * Lines
  85669. */
  85670. LINES = 1,
  85671. /**
  85672. * Line Loop
  85673. */
  85674. LINE_LOOP = 2,
  85675. /**
  85676. * Line Strip
  85677. */
  85678. LINE_STRIP = 3,
  85679. /**
  85680. * Triangles
  85681. */
  85682. TRIANGLES = 4,
  85683. /**
  85684. * Triangle Strip
  85685. */
  85686. TRIANGLE_STRIP = 5,
  85687. /**
  85688. * Triangle Fan
  85689. */
  85690. TRIANGLE_FAN = 6,
  85691. }
  85692. /**
  85693. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85694. */
  85695. const enum TextureMagFilter {
  85696. /**
  85697. * Nearest
  85698. */
  85699. NEAREST = 9728,
  85700. /**
  85701. * Linear
  85702. */
  85703. LINEAR = 9729,
  85704. }
  85705. /**
  85706. * Minification filter. All valid values correspond to WebGL enums
  85707. */
  85708. const enum TextureMinFilter {
  85709. /**
  85710. * Nearest
  85711. */
  85712. NEAREST = 9728,
  85713. /**
  85714. * Linear
  85715. */
  85716. LINEAR = 9729,
  85717. /**
  85718. * Nearest Mip-Map Nearest
  85719. */
  85720. NEAREST_MIPMAP_NEAREST = 9984,
  85721. /**
  85722. * Linear Mipmap Nearest
  85723. */
  85724. LINEAR_MIPMAP_NEAREST = 9985,
  85725. /**
  85726. * Nearest Mipmap Linear
  85727. */
  85728. NEAREST_MIPMAP_LINEAR = 9986,
  85729. /**
  85730. * Linear Mipmap Linear
  85731. */
  85732. LINEAR_MIPMAP_LINEAR = 9987,
  85733. }
  85734. /**
  85735. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85736. */
  85737. const enum TextureWrapMode {
  85738. /**
  85739. * Clamp to Edge
  85740. */
  85741. CLAMP_TO_EDGE = 33071,
  85742. /**
  85743. * Mirrored Repeat
  85744. */
  85745. MIRRORED_REPEAT = 33648,
  85746. /**
  85747. * Repeat
  85748. */
  85749. REPEAT = 10497,
  85750. }
  85751. /**
  85752. * glTF Property
  85753. */
  85754. interface IProperty {
  85755. /**
  85756. * Dictionary object with extension-specific objects
  85757. */
  85758. extensions?: {
  85759. [key: string]: any;
  85760. };
  85761. /**
  85762. * Application-Specific data
  85763. */
  85764. extras?: any;
  85765. }
  85766. /**
  85767. * glTF Child of Root Property
  85768. */
  85769. interface IChildRootProperty extends IProperty {
  85770. /**
  85771. * The user-defined name of this object
  85772. */
  85773. name?: string;
  85774. }
  85775. /**
  85776. * Indices of those attributes that deviate from their initialization value
  85777. */
  85778. interface IAccessorSparseIndices extends IProperty {
  85779. /**
  85780. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85781. */
  85782. bufferView: number;
  85783. /**
  85784. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85785. */
  85786. byteOffset?: number;
  85787. /**
  85788. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  85789. */
  85790. componentType: AccessorComponentType;
  85791. }
  85792. /**
  85793. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  85794. */
  85795. interface IAccessorSparseValues extends IProperty {
  85796. /**
  85797. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85798. */
  85799. bufferView: number;
  85800. /**
  85801. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85802. */
  85803. byteOffset?: number;
  85804. }
  85805. /**
  85806. * Sparse storage of attributes that deviate from their initialization value
  85807. */
  85808. interface IAccessorSparse extends IProperty {
  85809. /**
  85810. * The number of attributes encoded in this sparse accessor
  85811. */
  85812. count: number;
  85813. /**
  85814. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  85815. */
  85816. indices: IAccessorSparseIndices;
  85817. /**
  85818. * 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
  85819. */
  85820. values: IAccessorSparseValues;
  85821. }
  85822. /**
  85823. * 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
  85824. */
  85825. interface IAccessor extends IChildRootProperty {
  85826. /**
  85827. * The index of the bufferview
  85828. */
  85829. bufferView?: number;
  85830. /**
  85831. * The offset relative to the start of the bufferView in bytes
  85832. */
  85833. byteOffset?: number;
  85834. /**
  85835. * The datatype of components in the attribute
  85836. */
  85837. componentType: AccessorComponentType;
  85838. /**
  85839. * Specifies whether integer data values should be normalized
  85840. */
  85841. normalized?: boolean;
  85842. /**
  85843. * The number of attributes referenced by this accessor
  85844. */
  85845. count: number;
  85846. /**
  85847. * Specifies if the attribute is a scalar, vector, or matrix
  85848. */
  85849. type: AccessorType;
  85850. /**
  85851. * Maximum value of each component in this attribute
  85852. */
  85853. max?: number[];
  85854. /**
  85855. * Minimum value of each component in this attribute
  85856. */
  85857. min?: number[];
  85858. /**
  85859. * Sparse storage of attributes that deviate from their initialization value
  85860. */
  85861. sparse?: IAccessorSparse;
  85862. }
  85863. /**
  85864. * Targets an animation's sampler at a node's property
  85865. */
  85866. interface IAnimationChannel extends IProperty {
  85867. /**
  85868. * The index of a sampler in this animation used to compute the value for the target
  85869. */
  85870. sampler: number;
  85871. /**
  85872. * The index of the node and TRS property to target
  85873. */
  85874. target: IAnimationChannelTarget;
  85875. }
  85876. /**
  85877. * The index of the node and TRS property that an animation channel targets
  85878. */
  85879. interface IAnimationChannelTarget extends IProperty {
  85880. /**
  85881. * The index of the node to target
  85882. */
  85883. node: number;
  85884. /**
  85885. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85886. */
  85887. path: AnimationChannelTargetPath;
  85888. }
  85889. /**
  85890. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85891. */
  85892. interface IAnimationSampler extends IProperty {
  85893. /**
  85894. * The index of an accessor containing keyframe input values, e.g., time
  85895. */
  85896. input: number;
  85897. /**
  85898. * Interpolation algorithm
  85899. */
  85900. interpolation?: AnimationSamplerInterpolation;
  85901. /**
  85902. * The index of an accessor, containing keyframe output values
  85903. */
  85904. output: number;
  85905. }
  85906. /**
  85907. * A keyframe animation
  85908. */
  85909. interface IAnimation extends IChildRootProperty {
  85910. /**
  85911. * An array of channels, each of which targets an animation's sampler at a node's property
  85912. */
  85913. channels: IAnimationChannel[];
  85914. /**
  85915. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85916. */
  85917. samplers: IAnimationSampler[];
  85918. }
  85919. /**
  85920. * Metadata about the glTF asset
  85921. */
  85922. interface IAsset extends IChildRootProperty {
  85923. /**
  85924. * A copyright message suitable for display to credit the content creator
  85925. */
  85926. copyright?: string;
  85927. /**
  85928. * Tool that generated this glTF model. Useful for debugging
  85929. */
  85930. generator?: string;
  85931. /**
  85932. * The glTF version that this asset targets
  85933. */
  85934. version: string;
  85935. /**
  85936. * The minimum glTF version that this asset targets
  85937. */
  85938. minVersion?: string;
  85939. }
  85940. /**
  85941. * A buffer points to binary geometry, animation, or skins
  85942. */
  85943. interface IBuffer extends IChildRootProperty {
  85944. /**
  85945. * 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
  85946. */
  85947. uri?: string;
  85948. /**
  85949. * The length of the buffer in bytes
  85950. */
  85951. byteLength: number;
  85952. }
  85953. /**
  85954. * A view into a buffer generally representing a subset of the buffer
  85955. */
  85956. interface IBufferView extends IChildRootProperty {
  85957. /**
  85958. * The index of the buffer
  85959. */
  85960. buffer: number;
  85961. /**
  85962. * The offset into the buffer in bytes
  85963. */
  85964. byteOffset?: number;
  85965. /**
  85966. * The lenth of the bufferView in bytes
  85967. */
  85968. byteLength: number;
  85969. /**
  85970. * The stride, in bytes
  85971. */
  85972. byteStride?: number;
  85973. }
  85974. /**
  85975. * An orthographic camera containing properties to create an orthographic projection matrix
  85976. */
  85977. interface ICameraOrthographic extends IProperty {
  85978. /**
  85979. * The floating-point horizontal magnification of the view. Must not be zero
  85980. */
  85981. xmag: number;
  85982. /**
  85983. * The floating-point vertical magnification of the view. Must not be zero
  85984. */
  85985. ymag: number;
  85986. /**
  85987. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  85988. */
  85989. zfar: number;
  85990. /**
  85991. * The floating-point distance to the near clipping plane
  85992. */
  85993. znear: number;
  85994. }
  85995. /**
  85996. * A perspective camera containing properties to create a perspective projection matrix
  85997. */
  85998. interface ICameraPerspective extends IProperty {
  85999. /**
  86000. * The floating-point aspect ratio of the field of view
  86001. */
  86002. aspectRatio?: number;
  86003. /**
  86004. * The floating-point vertical field of view in radians
  86005. */
  86006. yfov: number;
  86007. /**
  86008. * The floating-point distance to the far clipping plane
  86009. */
  86010. zfar?: number;
  86011. /**
  86012. * The floating-point distance to the near clipping plane
  86013. */
  86014. znear: number;
  86015. }
  86016. /**
  86017. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86018. */
  86019. interface ICamera extends IChildRootProperty {
  86020. /**
  86021. * An orthographic camera containing properties to create an orthographic projection matrix
  86022. */
  86023. orthographic?: ICameraOrthographic;
  86024. /**
  86025. * A perspective camera containing properties to create a perspective projection matrix
  86026. */
  86027. perspective?: ICameraPerspective;
  86028. /**
  86029. * Specifies if the camera uses a perspective or orthographic projection
  86030. */
  86031. type: CameraType;
  86032. }
  86033. /**
  86034. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  86035. */
  86036. interface IImage extends IChildRootProperty {
  86037. /**
  86038. * 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
  86039. */
  86040. uri?: string;
  86041. /**
  86042. * The image's MIME type
  86043. */
  86044. mimeType?: ImageMimeType;
  86045. /**
  86046. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  86047. */
  86048. bufferView?: number;
  86049. }
  86050. /**
  86051. * Material Normal Texture Info
  86052. */
  86053. interface IMaterialNormalTextureInfo extends ITextureInfo {
  86054. /**
  86055. * The scalar multiplier applied to each normal vector of the normal texture
  86056. */
  86057. scale?: number;
  86058. }
  86059. /**
  86060. * Material Occlusion Texture Info
  86061. */
  86062. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  86063. /**
  86064. * A scalar multiplier controlling the amount of occlusion applied
  86065. */
  86066. strength?: number;
  86067. }
  86068. /**
  86069. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  86070. */
  86071. interface IMaterialPbrMetallicRoughness {
  86072. /**
  86073. * The material's base color factor
  86074. */
  86075. baseColorFactor?: number[];
  86076. /**
  86077. * The base color texture
  86078. */
  86079. baseColorTexture?: ITextureInfo;
  86080. /**
  86081. * The metalness of the material
  86082. */
  86083. metallicFactor?: number;
  86084. /**
  86085. * The roughness of the material
  86086. */
  86087. roughnessFactor?: number;
  86088. /**
  86089. * The metallic-roughness texture
  86090. */
  86091. metallicRoughnessTexture?: ITextureInfo;
  86092. }
  86093. /**
  86094. * The material appearance of a primitive
  86095. */
  86096. interface IMaterial extends IChildRootProperty {
  86097. /**
  86098. * 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
  86099. */
  86100. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86101. /**
  86102. * The normal map texture
  86103. */
  86104. normalTexture?: IMaterialNormalTextureInfo;
  86105. /**
  86106. * The occlusion map texture
  86107. */
  86108. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86109. /**
  86110. * The emissive map texture
  86111. */
  86112. emissiveTexture?: ITextureInfo;
  86113. /**
  86114. * 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
  86115. */
  86116. emissiveFactor?: number[];
  86117. /**
  86118. * The alpha rendering mode of the material
  86119. */
  86120. alphaMode?: MaterialAlphaMode;
  86121. /**
  86122. * The alpha cutoff value of the material
  86123. */
  86124. alphaCutoff?: number;
  86125. /**
  86126. * Specifies whether the material is double sided
  86127. */
  86128. doubleSided?: boolean;
  86129. }
  86130. /**
  86131. * Geometry to be rendered with the given material
  86132. */
  86133. interface IMeshPrimitive extends IProperty {
  86134. /**
  86135. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86136. */
  86137. attributes: {
  86138. [name: string]: number;
  86139. };
  86140. /**
  86141. * The index of the accessor that contains the indices
  86142. */
  86143. indices?: number;
  86144. /**
  86145. * The index of the material to apply to this primitive when rendering
  86146. */
  86147. material?: number;
  86148. /**
  86149. * The type of primitives to render. All valid values correspond to WebGL enums
  86150. */
  86151. mode?: MeshPrimitiveMode;
  86152. /**
  86153. * 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
  86154. */
  86155. targets?: {
  86156. [name: string]: number;
  86157. }[];
  86158. }
  86159. /**
  86160. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86161. */
  86162. interface IMesh extends IChildRootProperty {
  86163. /**
  86164. * An array of primitives, each defining geometry to be rendered with a material
  86165. */
  86166. primitives: IMeshPrimitive[];
  86167. /**
  86168. * Array of weights to be applied to the Morph Targets
  86169. */
  86170. weights?: number[];
  86171. }
  86172. /**
  86173. * A node in the node hierarchy
  86174. */
  86175. interface INode extends IChildRootProperty {
  86176. /**
  86177. * The index of the camera referenced by this node
  86178. */
  86179. camera?: number;
  86180. /**
  86181. * The indices of this node's children
  86182. */
  86183. children?: number[];
  86184. /**
  86185. * The index of the skin referenced by this node
  86186. */
  86187. skin?: number;
  86188. /**
  86189. * A floating-point 4x4 transformation matrix stored in column-major order
  86190. */
  86191. matrix?: number[];
  86192. /**
  86193. * The index of the mesh in this node
  86194. */
  86195. mesh?: number;
  86196. /**
  86197. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86198. */
  86199. rotation?: number[];
  86200. /**
  86201. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86202. */
  86203. scale?: number[];
  86204. /**
  86205. * The node's translation along the x, y, and z axes
  86206. */
  86207. translation?: number[];
  86208. /**
  86209. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86210. */
  86211. weights?: number[];
  86212. }
  86213. /**
  86214. * Texture sampler properties for filtering and wrapping modes
  86215. */
  86216. interface ISampler extends IChildRootProperty {
  86217. /**
  86218. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86219. */
  86220. magFilter?: TextureMagFilter;
  86221. /**
  86222. * Minification filter. All valid values correspond to WebGL enums
  86223. */
  86224. minFilter?: TextureMinFilter;
  86225. /**
  86226. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86227. */
  86228. wrapS?: TextureWrapMode;
  86229. /**
  86230. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86231. */
  86232. wrapT?: TextureWrapMode;
  86233. }
  86234. /**
  86235. * The root nodes of a scene
  86236. */
  86237. interface IScene extends IChildRootProperty {
  86238. /**
  86239. * The indices of each root node
  86240. */
  86241. nodes: number[];
  86242. }
  86243. /**
  86244. * Joints and matrices defining a skin
  86245. */
  86246. interface ISkin extends IChildRootProperty {
  86247. /**
  86248. * 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
  86249. */
  86250. inverseBindMatrices?: number;
  86251. /**
  86252. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86253. */
  86254. skeleton?: number;
  86255. /**
  86256. * 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)
  86257. */
  86258. joints: number[];
  86259. }
  86260. /**
  86261. * A texture and its sampler
  86262. */
  86263. interface ITexture extends IChildRootProperty {
  86264. /**
  86265. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86266. */
  86267. sampler?: number;
  86268. /**
  86269. * The index of the image used by this texture
  86270. */
  86271. source: number;
  86272. }
  86273. /**
  86274. * Reference to a texture
  86275. */
  86276. interface ITextureInfo extends IProperty {
  86277. /**
  86278. * The index of the texture
  86279. */
  86280. index: number;
  86281. /**
  86282. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86283. */
  86284. texCoord?: number;
  86285. }
  86286. /**
  86287. * The root object for a glTF asset
  86288. */
  86289. interface IGLTF extends IProperty {
  86290. /**
  86291. * An array of accessors. An accessor is a typed view into a bufferView
  86292. */
  86293. accessors?: IAccessor[];
  86294. /**
  86295. * An array of keyframe animations
  86296. */
  86297. animations?: IAnimation[];
  86298. /**
  86299. * Metadata about the glTF asset
  86300. */
  86301. asset: IAsset;
  86302. /**
  86303. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86304. */
  86305. buffers?: IBuffer[];
  86306. /**
  86307. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86308. */
  86309. bufferViews?: IBufferView[];
  86310. /**
  86311. * An array of cameras
  86312. */
  86313. cameras?: ICamera[];
  86314. /**
  86315. * Names of glTF extensions used somewhere in this asset
  86316. */
  86317. extensionsUsed?: string[];
  86318. /**
  86319. * Names of glTF extensions required to properly load this asset
  86320. */
  86321. extensionsRequired?: string[];
  86322. /**
  86323. * An array of images. An image defines data used to create a texture
  86324. */
  86325. images?: IImage[];
  86326. /**
  86327. * An array of materials. A material defines the appearance of a primitive
  86328. */
  86329. materials?: IMaterial[];
  86330. /**
  86331. * An array of meshes. A mesh is a set of primitives to be rendered
  86332. */
  86333. meshes?: IMesh[];
  86334. /**
  86335. * An array of nodes
  86336. */
  86337. nodes?: INode[];
  86338. /**
  86339. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86340. */
  86341. samplers?: ISampler[];
  86342. /**
  86343. * The index of the default scene
  86344. */
  86345. scene?: number;
  86346. /**
  86347. * An array of scenes
  86348. */
  86349. scenes?: IScene[];
  86350. /**
  86351. * An array of skins. A skin is defined by joints and matrices
  86352. */
  86353. skins?: ISkin[];
  86354. /**
  86355. * An array of textures
  86356. */
  86357. textures?: ITexture[];
  86358. }
  86359. /**
  86360. * The glTF validation results
  86361. * @ignore
  86362. */
  86363. interface IGLTFValidationResults {
  86364. info: {
  86365. generator: string;
  86366. hasAnimations: boolean;
  86367. hasDefaultScene: boolean;
  86368. hasMaterials: boolean;
  86369. hasMorphTargets: boolean;
  86370. hasSkins: boolean;
  86371. hasTextures: boolean;
  86372. maxAttributesUsed: number;
  86373. primitivesCount: number
  86374. };
  86375. issues: {
  86376. messages: Array<string>;
  86377. numErrors: number;
  86378. numHints: number;
  86379. numInfos: number;
  86380. numWarnings: number;
  86381. truncated: boolean
  86382. };
  86383. mimeType: string;
  86384. uri: string;
  86385. validatedAt: string;
  86386. validatorVersion: string;
  86387. }
  86388. /**
  86389. * The glTF validation options
  86390. */
  86391. interface IGLTFValidationOptions {
  86392. /** Uri to use */
  86393. uri?: string;
  86394. /** Function used to load external resources */
  86395. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  86396. /** Boolean indicating that we need to validate accessor data */
  86397. validateAccessorData?: boolean;
  86398. /** max number of issues allowed */
  86399. maxIssues?: number;
  86400. /** Ignored issues */
  86401. ignoredIssues?: Array<string>;
  86402. /** Value to override severy settings */
  86403. severityOverrides?: Object;
  86404. }
  86405. /**
  86406. * The glTF validator object
  86407. * @ignore
  86408. */
  86409. interface IGLTFValidator {
  86410. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86411. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86412. }
  86413. /**
  86414. * Interfaces from the EXT_lights_image_based extension
  86415. */
  86416. /** @hidden */
  86417. interface IEXTLightsImageBased_LightReferenceImageBased {
  86418. light: number;
  86419. }
  86420. /** @hidden */
  86421. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86422. intensity: number;
  86423. rotation: number[];
  86424. specularImageSize: number;
  86425. specularImages: number[][];
  86426. irradianceCoefficients: number[][];
  86427. }
  86428. /** @hidden */
  86429. interface IEXTLightsImageBased {
  86430. lights: IEXTLightsImageBased_LightImageBased[];
  86431. }
  86432. /**
  86433. * Interfaces from the EXT_mesh_gpu_instancing extension
  86434. * !!! Experimental Extension Subject to Changes !!!
  86435. */
  86436. /** @hidden */
  86437. interface IEXTMeshGpuInstancing {
  86438. mesh?: number;
  86439. attributes: { [name: string]: number };
  86440. }
  86441. /**
  86442. * Interfaces from the KHR_draco_mesh_compression extension
  86443. */
  86444. /** @hidden */
  86445. interface IKHRDracoMeshCompression {
  86446. bufferView: number;
  86447. attributes: { [name: string]: number };
  86448. }
  86449. /**
  86450. * Interfaces from the KHR_lights_punctual extension
  86451. */
  86452. /** @hidden */
  86453. const enum IKHRLightsPunctual_LightType {
  86454. DIRECTIONAL = "directional",
  86455. POINT = "point",
  86456. SPOT = "spot"
  86457. }
  86458. /** @hidden */
  86459. interface IKHRLightsPunctual_LightReference {
  86460. light: number;
  86461. }
  86462. /** @hidden */
  86463. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86464. type: IKHRLightsPunctual_LightType;
  86465. color?: number[];
  86466. intensity?: number;
  86467. range?: number;
  86468. spot?: {
  86469. innerConeAngle?: number;
  86470. outerConeAngle?: number;
  86471. };
  86472. }
  86473. /** @hidden */
  86474. interface IKHRLightsPunctual {
  86475. lights: IKHRLightsPunctual_Light[];
  86476. }
  86477. /**
  86478. * Interfaces from the KHR_materials_clearcoat extension
  86479. * !!! Experimental Extension Subject to Changes !!!
  86480. */
  86481. /** @hidden */
  86482. interface IKHRMaterialsClearcoat {
  86483. clearcoatFactor: number;
  86484. clearcoatTexture: ITextureInfo;
  86485. clearcoatRoughnessFactor: number;
  86486. clearcoatRoughnessTexture: ITextureInfo;
  86487. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86488. }
  86489. /**
  86490. * Interfaces from the KHR_materials_ior extension
  86491. * !!! Experimental Extension Subject to Changes !!!
  86492. */
  86493. /** @hidden */
  86494. interface IKHRMaterialsIor {
  86495. ior: number;
  86496. }
  86497. /**
  86498. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86499. */
  86500. /** @hidden */
  86501. interface IKHRMaterialsPbrSpecularGlossiness {
  86502. diffuseFactor: number[];
  86503. diffuseTexture: ITextureInfo;
  86504. specularFactor: number[];
  86505. glossinessFactor: number;
  86506. specularGlossinessTexture: ITextureInfo;
  86507. }
  86508. /**
  86509. * Interfaces from the KHR_materials_sheen extension
  86510. * !!! Experimental Extension Subject to Changes !!!
  86511. */
  86512. /** @hidden */
  86513. interface IKHRMaterialsSheen {
  86514. sheenColorFactor?: number[];
  86515. sheenColorTexture?: ITextureInfo;
  86516. sheenRoughnessFactor?: number;
  86517. sheenRoughnessTexture?: ITextureInfo;
  86518. }
  86519. /**
  86520. * Interfaces from the KHR_materials_specular extension
  86521. * !!! Experimental Extension Subject to Changes !!!
  86522. */
  86523. /** @hidden */
  86524. interface IKHRMaterialsSpecular {
  86525. specularFactor: number;
  86526. specularColorFactor: number[];
  86527. specularTexture: ITextureInfo;
  86528. }
  86529. /**
  86530. * Interfaces from the KHR_materials_transmission extension
  86531. * !!! Experimental Extension Subject to Changes !!!
  86532. */
  86533. /** @hidden */
  86534. interface IKHRMaterialsTransmission {
  86535. transmissionFactor?: number;
  86536. transmissionTexture?: ITextureInfo;
  86537. }
  86538. /**
  86539. * Interfaces from the KHR_materials_variants extension
  86540. * !!! Experimental Extension Subject to Changes !!!
  86541. */
  86542. /** @hidden */
  86543. interface IKHRMaterialVariants_Mapping extends IProperty {
  86544. mappings: Array<{
  86545. variants: number[];
  86546. material: number;
  86547. }>;
  86548. }
  86549. /** @hidden */
  86550. interface IKHRMaterialVariants_Variant extends IProperty {
  86551. name: string;
  86552. }
  86553. /** @hidden */
  86554. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86555. variants: Array<IKHRMaterialVariants_Variant>;
  86556. }
  86557. /**
  86558. * Interfaces from the KHR_texture_basisu extension
  86559. * !!! Experimental Extension Subject to Changes !!!
  86560. */
  86561. /** @hidden */
  86562. interface IKHRTextureBasisU {
  86563. source: number;
  86564. }
  86565. /**
  86566. * Interfaces from the EXT_texture_webp extension
  86567. */
  86568. /** @hidden */
  86569. interface IEXTTextureWebP {
  86570. source: number;
  86571. }
  86572. /**
  86573. * Interfaces from the KHR_texture_transform extension
  86574. */
  86575. /** @hidden */
  86576. interface IKHRTextureTransform {
  86577. offset?: number[];
  86578. rotation?: number;
  86579. scale?: number[];
  86580. texCoord?: number;
  86581. }
  86582. /**
  86583. * Interfaces from the KHR_xmp extension
  86584. * !!! Experimental Extension Subject to Changes !!!
  86585. */
  86586. /** @hidden */
  86587. interface IKHRXmp_Data {
  86588. [key: string]: unknown;
  86589. }
  86590. /** @hidden */
  86591. interface IKHRXmp_Gltf {
  86592. packets: IKHRXmp_Data[];
  86593. }
  86594. /** @hidden */
  86595. interface IKHRXmp_Node {
  86596. packet: number;
  86597. }
  86598. /**
  86599. * Interfaces from the MSFT_audio_emitter extension
  86600. */
  86601. /** @hidden */
  86602. interface IMSFTAudioEmitter_ClipReference {
  86603. clip: number;
  86604. weight?: number;
  86605. }
  86606. /** @hidden */
  86607. interface IMSFTAudioEmitter_EmittersReference {
  86608. emitters: number[];
  86609. }
  86610. /** @hidden */
  86611. const enum IMSFTAudioEmitter_DistanceModel {
  86612. linear = "linear",
  86613. inverse = "inverse",
  86614. exponential = "exponential",
  86615. }
  86616. /** @hidden */
  86617. interface IMSFTAudioEmitter_Emitter {
  86618. name?: string;
  86619. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86620. refDistance?: number;
  86621. maxDistance?: number;
  86622. rolloffFactor?: number;
  86623. innerAngle?: number;
  86624. outerAngle?: number;
  86625. loop?: boolean;
  86626. volume?: number;
  86627. clips: IMSFTAudioEmitter_ClipReference[];
  86628. }
  86629. /** @hidden */
  86630. const enum IMSFTAudioEmitter_AudioMimeType {
  86631. WAV = "audio/wav",
  86632. }
  86633. /** @hidden */
  86634. interface IMSFTAudioEmitter_Clip extends IProperty {
  86635. uri?: string;
  86636. bufferView?: number;
  86637. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  86638. }
  86639. /** @hidden */
  86640. const enum IMSFTAudioEmitter_AnimationEventAction {
  86641. play = "play",
  86642. pause = "pause",
  86643. stop = "stop",
  86644. }
  86645. /** @hidden */
  86646. interface IMSFTAudioEmitter_AnimationEvent {
  86647. action: IMSFTAudioEmitter_AnimationEventAction;
  86648. emitter: number;
  86649. time: number;
  86650. startOffset?: number;
  86651. }
  86652. /**
  86653. * Interfaces from the MSFT_lod extension
  86654. */
  86655. /** @hidden */
  86656. interface IMSFTLOD {
  86657. ids: number[];
  86658. }
  86659. }
  86660. declare module BABYLON {
  86661. /** @hidden */
  86662. export var cellPixelShader: {
  86663. name: string;
  86664. shader: string;
  86665. };
  86666. }
  86667. declare module BABYLON {
  86668. /** @hidden */
  86669. export var cellVertexShader: {
  86670. name: string;
  86671. shader: string;
  86672. };
  86673. }
  86674. declare module BABYLON {
  86675. export class CellMaterial extends BABYLON.PushMaterial {
  86676. private _diffuseTexture;
  86677. diffuseTexture: BABYLON.BaseTexture;
  86678. diffuseColor: BABYLON.Color3;
  86679. _computeHighLevel: boolean;
  86680. computeHighLevel: boolean;
  86681. private _disableLighting;
  86682. disableLighting: boolean;
  86683. private _maxSimultaneousLights;
  86684. maxSimultaneousLights: number;
  86685. constructor(name: string, scene: BABYLON.Scene);
  86686. needAlphaBlending(): boolean;
  86687. needAlphaTesting(): boolean;
  86688. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86689. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86690. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86691. getAnimatables(): BABYLON.IAnimatable[];
  86692. getActiveTextures(): BABYLON.BaseTexture[];
  86693. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86694. dispose(forceDisposeEffect?: boolean): void;
  86695. getClassName(): string;
  86696. clone(name: string): CellMaterial;
  86697. serialize(): any;
  86698. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  86699. }
  86700. }
  86701. declare module BABYLON {
  86702. export class CustomShaderStructure {
  86703. FragmentStore: string;
  86704. VertexStore: string;
  86705. constructor();
  86706. }
  86707. export class ShaderSpecialParts {
  86708. constructor();
  86709. Fragment_Begin: string;
  86710. Fragment_Definitions: string;
  86711. Fragment_MainBegin: string;
  86712. Fragment_Custom_Diffuse: string;
  86713. Fragment_Before_Lights: string;
  86714. Fragment_Before_Fog: string;
  86715. Fragment_Custom_Alpha: string;
  86716. Fragment_Before_FragColor: string;
  86717. Vertex_Begin: string;
  86718. Vertex_Definitions: string;
  86719. Vertex_MainBegin: string;
  86720. Vertex_Before_PositionUpdated: string;
  86721. Vertex_Before_NormalUpdated: string;
  86722. Vertex_After_WorldPosComputed: string;
  86723. Vertex_MainEnd: string;
  86724. }
  86725. export class CustomMaterial extends BABYLON.StandardMaterial {
  86726. static ShaderIndexer: number;
  86727. CustomParts: ShaderSpecialParts;
  86728. _isCreatedShader: boolean;
  86729. _createdShaderName: string;
  86730. _customUniform: string[];
  86731. _newUniforms: string[];
  86732. _newUniformInstances: {
  86733. [name: string]: any;
  86734. };
  86735. _newSamplerInstances: {
  86736. [name: string]: BABYLON.Texture;
  86737. };
  86738. _customAttributes: string[];
  86739. FragmentShader: string;
  86740. VertexShader: string;
  86741. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86742. ReviewUniform(name: string, arr: string[]): string[];
  86743. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86744. constructor(name: string, scene: BABYLON.Scene);
  86745. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  86746. AddAttribute(name: string): CustomMaterial;
  86747. Fragment_Begin(shaderPart: string): CustomMaterial;
  86748. Fragment_Definitions(shaderPart: string): CustomMaterial;
  86749. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  86750. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  86751. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  86752. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  86753. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  86754. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  86755. Vertex_Begin(shaderPart: string): CustomMaterial;
  86756. Vertex_Definitions(shaderPart: string): CustomMaterial;
  86757. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  86758. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  86759. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  86760. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  86761. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  86762. }
  86763. }
  86764. declare module BABYLON {
  86765. export class ShaderAlebdoParts {
  86766. constructor();
  86767. Fragment_Begin: string;
  86768. Fragment_Definitions: string;
  86769. Fragment_MainBegin: string;
  86770. Fragment_Custom_Albedo: string;
  86771. Fragment_Before_Lights: string;
  86772. Fragment_Custom_MetallicRoughness: string;
  86773. Fragment_Custom_MicroSurface: string;
  86774. Fragment_Before_Fog: string;
  86775. Fragment_Custom_Alpha: string;
  86776. Fragment_Before_FragColor: string;
  86777. Vertex_Begin: string;
  86778. Vertex_Definitions: string;
  86779. Vertex_MainBegin: string;
  86780. Vertex_Before_PositionUpdated: string;
  86781. Vertex_Before_NormalUpdated: string;
  86782. Vertex_After_WorldPosComputed: string;
  86783. Vertex_MainEnd: string;
  86784. }
  86785. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  86786. static ShaderIndexer: number;
  86787. CustomParts: ShaderAlebdoParts;
  86788. _isCreatedShader: boolean;
  86789. _createdShaderName: string;
  86790. _customUniform: string[];
  86791. _newUniforms: string[];
  86792. _newUniformInstances: {
  86793. [name: string]: any;
  86794. };
  86795. _newSamplerInstances: {
  86796. [name: string]: BABYLON.Texture;
  86797. };
  86798. _customAttributes: string[];
  86799. FragmentShader: string;
  86800. VertexShader: string;
  86801. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86802. ReviewUniform(name: string, arr: string[]): string[];
  86803. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86804. constructor(name: string, scene: BABYLON.Scene);
  86805. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  86806. AddAttribute(name: string): PBRCustomMaterial;
  86807. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  86808. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  86809. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  86810. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  86811. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  86812. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  86813. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  86814. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  86815. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  86816. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  86817. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  86818. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  86819. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  86820. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  86821. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  86822. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  86823. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  86824. }
  86825. }
  86826. declare module BABYLON {
  86827. /** @hidden */
  86828. export var firePixelShader: {
  86829. name: string;
  86830. shader: string;
  86831. };
  86832. }
  86833. declare module BABYLON {
  86834. /** @hidden */
  86835. export var fireVertexShader: {
  86836. name: string;
  86837. shader: string;
  86838. };
  86839. }
  86840. declare module BABYLON {
  86841. export class FireMaterial extends BABYLON.PushMaterial {
  86842. private _diffuseTexture;
  86843. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86844. private _distortionTexture;
  86845. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86846. private _opacityTexture;
  86847. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86848. diffuseColor: BABYLON.Color3;
  86849. speed: number;
  86850. private _scaledDiffuse;
  86851. private _lastTime;
  86852. constructor(name: string, scene: BABYLON.Scene);
  86853. needAlphaBlending(): boolean;
  86854. needAlphaTesting(): boolean;
  86855. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86856. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86857. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86858. getAnimatables(): BABYLON.IAnimatable[];
  86859. getActiveTextures(): BABYLON.BaseTexture[];
  86860. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86861. getClassName(): string;
  86862. dispose(forceDisposeEffect?: boolean): void;
  86863. clone(name: string): FireMaterial;
  86864. serialize(): any;
  86865. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  86866. }
  86867. }
  86868. declare module BABYLON {
  86869. /** @hidden */
  86870. export var furPixelShader: {
  86871. name: string;
  86872. shader: string;
  86873. };
  86874. }
  86875. declare module BABYLON {
  86876. /** @hidden */
  86877. export var furVertexShader: {
  86878. name: string;
  86879. shader: string;
  86880. };
  86881. }
  86882. declare module BABYLON {
  86883. export class FurMaterial extends BABYLON.PushMaterial {
  86884. private _diffuseTexture;
  86885. diffuseTexture: BABYLON.BaseTexture;
  86886. private _heightTexture;
  86887. heightTexture: BABYLON.BaseTexture;
  86888. diffuseColor: BABYLON.Color3;
  86889. furLength: number;
  86890. furAngle: number;
  86891. furColor: BABYLON.Color3;
  86892. furOffset: number;
  86893. furSpacing: number;
  86894. furGravity: BABYLON.Vector3;
  86895. furSpeed: number;
  86896. furDensity: number;
  86897. furOcclusion: number;
  86898. furTexture: BABYLON.DynamicTexture;
  86899. private _disableLighting;
  86900. disableLighting: boolean;
  86901. private _maxSimultaneousLights;
  86902. maxSimultaneousLights: number;
  86903. highLevelFur: boolean;
  86904. _meshes: BABYLON.AbstractMesh[];
  86905. private _furTime;
  86906. constructor(name: string, scene: BABYLON.Scene);
  86907. get furTime(): number;
  86908. set furTime(furTime: number);
  86909. needAlphaBlending(): boolean;
  86910. needAlphaTesting(): boolean;
  86911. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86912. updateFur(): void;
  86913. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86914. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86915. getAnimatables(): BABYLON.IAnimatable[];
  86916. getActiveTextures(): BABYLON.BaseTexture[];
  86917. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86918. dispose(forceDisposeEffect?: boolean): void;
  86919. clone(name: string): FurMaterial;
  86920. serialize(): any;
  86921. getClassName(): string;
  86922. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  86923. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  86924. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  86925. }
  86926. }
  86927. declare module BABYLON {
  86928. /** @hidden */
  86929. export var gradientPixelShader: {
  86930. name: string;
  86931. shader: string;
  86932. };
  86933. }
  86934. declare module BABYLON {
  86935. /** @hidden */
  86936. export var gradientVertexShader: {
  86937. name: string;
  86938. shader: string;
  86939. };
  86940. }
  86941. declare module BABYLON {
  86942. export class GradientMaterial extends BABYLON.PushMaterial {
  86943. private _maxSimultaneousLights;
  86944. maxSimultaneousLights: number;
  86945. topColor: BABYLON.Color3;
  86946. topColorAlpha: number;
  86947. bottomColor: BABYLON.Color3;
  86948. bottomColorAlpha: number;
  86949. offset: number;
  86950. scale: number;
  86951. smoothness: number;
  86952. private _disableLighting;
  86953. disableLighting: boolean;
  86954. constructor(name: string, scene: BABYLON.Scene);
  86955. needAlphaBlending(): boolean;
  86956. needAlphaTesting(): boolean;
  86957. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86958. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86959. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86960. getAnimatables(): BABYLON.IAnimatable[];
  86961. dispose(forceDisposeEffect?: boolean): void;
  86962. clone(name: string): GradientMaterial;
  86963. serialize(): any;
  86964. getClassName(): string;
  86965. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  86966. }
  86967. }
  86968. declare module BABYLON {
  86969. /** @hidden */
  86970. export var gridPixelShader: {
  86971. name: string;
  86972. shader: string;
  86973. };
  86974. }
  86975. declare module BABYLON {
  86976. /** @hidden */
  86977. export var gridVertexShader: {
  86978. name: string;
  86979. shader: string;
  86980. };
  86981. }
  86982. declare module BABYLON {
  86983. /**
  86984. * The grid materials allows you to wrap any shape with a grid.
  86985. * Colors are customizable.
  86986. */
  86987. export class GridMaterial extends BABYLON.PushMaterial {
  86988. /**
  86989. * Main color of the grid (e.g. between lines)
  86990. */
  86991. mainColor: BABYLON.Color3;
  86992. /**
  86993. * Color of the grid lines.
  86994. */
  86995. lineColor: BABYLON.Color3;
  86996. /**
  86997. * The scale of the grid compared to unit.
  86998. */
  86999. gridRatio: number;
  87000. /**
  87001. * Allows setting an offset for the grid lines.
  87002. */
  87003. gridOffset: BABYLON.Vector3;
  87004. /**
  87005. * The frequency of thicker lines.
  87006. */
  87007. majorUnitFrequency: number;
  87008. /**
  87009. * The visibility of minor units in the grid.
  87010. */
  87011. minorUnitVisibility: number;
  87012. /**
  87013. * The grid opacity outside of the lines.
  87014. */
  87015. opacity: number;
  87016. /**
  87017. * Determine RBG output is premultiplied by alpha value.
  87018. */
  87019. preMultiplyAlpha: boolean;
  87020. private _opacityTexture;
  87021. opacityTexture: BABYLON.BaseTexture;
  87022. private _gridControl;
  87023. /**
  87024. * constructor
  87025. * @param name The name given to the material in order to identify it afterwards.
  87026. * @param scene The scene the material is used in.
  87027. */
  87028. constructor(name: string, scene: BABYLON.Scene);
  87029. /**
  87030. * Returns wehter or not the grid requires alpha blending.
  87031. */
  87032. needAlphaBlending(): boolean;
  87033. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87034. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87035. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87036. /**
  87037. * Dispose the material and its associated resources.
  87038. * @param forceDisposeEffect will also dispose the used effect when true
  87039. */
  87040. dispose(forceDisposeEffect?: boolean): void;
  87041. clone(name: string): GridMaterial;
  87042. serialize(): any;
  87043. getClassName(): string;
  87044. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  87045. }
  87046. }
  87047. declare module BABYLON {
  87048. /** @hidden */
  87049. export var lavaPixelShader: {
  87050. name: string;
  87051. shader: string;
  87052. };
  87053. }
  87054. declare module BABYLON {
  87055. /** @hidden */
  87056. export var lavaVertexShader: {
  87057. name: string;
  87058. shader: string;
  87059. };
  87060. }
  87061. declare module BABYLON {
  87062. export class LavaMaterial extends BABYLON.PushMaterial {
  87063. private _diffuseTexture;
  87064. diffuseTexture: BABYLON.BaseTexture;
  87065. noiseTexture: BABYLON.BaseTexture;
  87066. fogColor: BABYLON.Color3;
  87067. speed: number;
  87068. movingSpeed: number;
  87069. lowFrequencySpeed: number;
  87070. fogDensity: number;
  87071. private _lastTime;
  87072. diffuseColor: BABYLON.Color3;
  87073. private _disableLighting;
  87074. disableLighting: boolean;
  87075. private _unlit;
  87076. unlit: boolean;
  87077. private _maxSimultaneousLights;
  87078. maxSimultaneousLights: number;
  87079. private _scaledDiffuse;
  87080. constructor(name: string, scene: BABYLON.Scene);
  87081. needAlphaBlending(): boolean;
  87082. needAlphaTesting(): boolean;
  87083. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87084. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87085. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87086. getAnimatables(): BABYLON.IAnimatable[];
  87087. getActiveTextures(): BABYLON.BaseTexture[];
  87088. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87089. dispose(forceDisposeEffect?: boolean): void;
  87090. clone(name: string): LavaMaterial;
  87091. serialize(): any;
  87092. getClassName(): string;
  87093. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  87094. }
  87095. }
  87096. declare module BABYLON {
  87097. /** @hidden */
  87098. export var mixPixelShader: {
  87099. name: string;
  87100. shader: string;
  87101. };
  87102. }
  87103. declare module BABYLON {
  87104. /** @hidden */
  87105. export var mixVertexShader: {
  87106. name: string;
  87107. shader: string;
  87108. };
  87109. }
  87110. declare module BABYLON {
  87111. export class MixMaterial extends BABYLON.PushMaterial {
  87112. /**
  87113. * Mix textures
  87114. */
  87115. private _mixTexture1;
  87116. mixTexture1: BABYLON.BaseTexture;
  87117. private _mixTexture2;
  87118. mixTexture2: BABYLON.BaseTexture;
  87119. /**
  87120. * Diffuse textures
  87121. */
  87122. private _diffuseTexture1;
  87123. diffuseTexture1: BABYLON.Texture;
  87124. private _diffuseTexture2;
  87125. diffuseTexture2: BABYLON.Texture;
  87126. private _diffuseTexture3;
  87127. diffuseTexture3: BABYLON.Texture;
  87128. private _diffuseTexture4;
  87129. diffuseTexture4: BABYLON.Texture;
  87130. private _diffuseTexture5;
  87131. diffuseTexture5: BABYLON.Texture;
  87132. private _diffuseTexture6;
  87133. diffuseTexture6: BABYLON.Texture;
  87134. private _diffuseTexture7;
  87135. diffuseTexture7: BABYLON.Texture;
  87136. private _diffuseTexture8;
  87137. diffuseTexture8: BABYLON.Texture;
  87138. /**
  87139. * Uniforms
  87140. */
  87141. diffuseColor: BABYLON.Color3;
  87142. specularColor: BABYLON.Color3;
  87143. specularPower: number;
  87144. private _disableLighting;
  87145. disableLighting: boolean;
  87146. private _maxSimultaneousLights;
  87147. maxSimultaneousLights: number;
  87148. constructor(name: string, scene: BABYLON.Scene);
  87149. needAlphaBlending(): boolean;
  87150. needAlphaTesting(): boolean;
  87151. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87152. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87153. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87154. getAnimatables(): BABYLON.IAnimatable[];
  87155. getActiveTextures(): BABYLON.BaseTexture[];
  87156. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87157. dispose(forceDisposeEffect?: boolean): void;
  87158. clone(name: string): MixMaterial;
  87159. serialize(): any;
  87160. getClassName(): string;
  87161. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87162. }
  87163. }
  87164. declare module BABYLON {
  87165. /** @hidden */
  87166. export var normalPixelShader: {
  87167. name: string;
  87168. shader: string;
  87169. };
  87170. }
  87171. declare module BABYLON {
  87172. /** @hidden */
  87173. export var normalVertexShader: {
  87174. name: string;
  87175. shader: string;
  87176. };
  87177. }
  87178. declare module BABYLON {
  87179. export class NormalMaterial extends BABYLON.PushMaterial {
  87180. private _diffuseTexture;
  87181. diffuseTexture: BABYLON.BaseTexture;
  87182. diffuseColor: BABYLON.Color3;
  87183. private _disableLighting;
  87184. disableLighting: boolean;
  87185. private _maxSimultaneousLights;
  87186. maxSimultaneousLights: number;
  87187. constructor(name: string, scene: BABYLON.Scene);
  87188. needAlphaBlending(): boolean;
  87189. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87190. needAlphaTesting(): boolean;
  87191. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87192. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87193. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87194. getAnimatables(): BABYLON.IAnimatable[];
  87195. getActiveTextures(): BABYLON.BaseTexture[];
  87196. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87197. dispose(forceDisposeEffect?: boolean): void;
  87198. clone(name: string): NormalMaterial;
  87199. serialize(): any;
  87200. getClassName(): string;
  87201. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87202. }
  87203. }
  87204. declare module BABYLON {
  87205. /** @hidden */
  87206. export var shadowOnlyPixelShader: {
  87207. name: string;
  87208. shader: string;
  87209. };
  87210. }
  87211. declare module BABYLON {
  87212. /** @hidden */
  87213. export var shadowOnlyVertexShader: {
  87214. name: string;
  87215. shader: string;
  87216. };
  87217. }
  87218. declare module BABYLON {
  87219. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87220. private _activeLight;
  87221. private _needAlphaBlending;
  87222. constructor(name: string, scene: BABYLON.Scene);
  87223. shadowColor: BABYLON.Color3;
  87224. needAlphaBlending(): boolean;
  87225. needAlphaTesting(): boolean;
  87226. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87227. get activeLight(): BABYLON.IShadowLight;
  87228. set activeLight(light: BABYLON.IShadowLight);
  87229. private _getFirstShadowLightForMesh;
  87230. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87231. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87232. clone(name: string): ShadowOnlyMaterial;
  87233. serialize(): any;
  87234. getClassName(): string;
  87235. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87236. }
  87237. }
  87238. declare module BABYLON {
  87239. /** @hidden */
  87240. export var simplePixelShader: {
  87241. name: string;
  87242. shader: string;
  87243. };
  87244. }
  87245. declare module BABYLON {
  87246. /** @hidden */
  87247. export var simpleVertexShader: {
  87248. name: string;
  87249. shader: string;
  87250. };
  87251. }
  87252. declare module BABYLON {
  87253. export class SimpleMaterial extends BABYLON.PushMaterial {
  87254. private _diffuseTexture;
  87255. diffuseTexture: BABYLON.BaseTexture;
  87256. diffuseColor: BABYLON.Color3;
  87257. private _disableLighting;
  87258. disableLighting: boolean;
  87259. private _maxSimultaneousLights;
  87260. maxSimultaneousLights: number;
  87261. constructor(name: string, scene: BABYLON.Scene);
  87262. needAlphaBlending(): boolean;
  87263. needAlphaTesting(): boolean;
  87264. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87265. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87266. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87267. getAnimatables(): BABYLON.IAnimatable[];
  87268. getActiveTextures(): BABYLON.BaseTexture[];
  87269. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87270. dispose(forceDisposeEffect?: boolean): void;
  87271. clone(name: string): SimpleMaterial;
  87272. serialize(): any;
  87273. getClassName(): string;
  87274. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87275. }
  87276. }
  87277. declare module BABYLON {
  87278. /** @hidden */
  87279. export var skyPixelShader: {
  87280. name: string;
  87281. shader: string;
  87282. };
  87283. }
  87284. declare module BABYLON {
  87285. /** @hidden */
  87286. export var skyVertexShader: {
  87287. name: string;
  87288. shader: string;
  87289. };
  87290. }
  87291. declare module BABYLON {
  87292. /**
  87293. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87294. * @see https://doc.babylonjs.com/extensions/sky
  87295. */
  87296. export class SkyMaterial extends BABYLON.PushMaterial {
  87297. /**
  87298. * Defines the overall luminance of sky in interval ]0, 1[.
  87299. */
  87300. luminance: number;
  87301. /**
  87302. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87303. */
  87304. turbidity: number;
  87305. /**
  87306. * Defines the sky appearance (light intensity).
  87307. */
  87308. rayleigh: number;
  87309. /**
  87310. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87311. */
  87312. mieCoefficient: number;
  87313. /**
  87314. * Defines the amount of haze particles following the Mie scattering theory.
  87315. */
  87316. mieDirectionalG: number;
  87317. /**
  87318. * Defines the distance of the sun according to the active scene camera.
  87319. */
  87320. distance: number;
  87321. /**
  87322. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87323. * "inclined".
  87324. */
  87325. inclination: number;
  87326. /**
  87327. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87328. * an object direction and a reference direction.
  87329. */
  87330. azimuth: number;
  87331. /**
  87332. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87333. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87334. */
  87335. sunPosition: BABYLON.Vector3;
  87336. /**
  87337. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87338. * .sunPosition property.
  87339. */
  87340. useSunPosition: boolean;
  87341. /**
  87342. * Defines an offset vector used to get a horizon offset.
  87343. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87344. */
  87345. cameraOffset: BABYLON.Vector3;
  87346. private _cameraPosition;
  87347. /**
  87348. * Instantiates a new sky material.
  87349. * This material allows to create dynamic and texture free
  87350. * effects for skyboxes by taking care of the atmosphere state.
  87351. * @see https://doc.babylonjs.com/extensions/sky
  87352. * @param name Define the name of the material in the scene
  87353. * @param scene Define the scene the material belong to
  87354. */
  87355. constructor(name: string, scene: BABYLON.Scene);
  87356. /**
  87357. * Specifies if the material will require alpha blending
  87358. * @returns a boolean specifying if alpha blending is needed
  87359. */
  87360. needAlphaBlending(): boolean;
  87361. /**
  87362. * Specifies if this material should be rendered in alpha test mode
  87363. * @returns false as the sky material doesn't need alpha testing.
  87364. */
  87365. needAlphaTesting(): boolean;
  87366. /**
  87367. * Get the texture used for alpha test purpose.
  87368. * @returns null as the sky material has no texture.
  87369. */
  87370. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87371. /**
  87372. * Get if the submesh is ready to be used and all its information available.
  87373. * Child classes can use it to update shaders
  87374. * @param mesh defines the mesh to check
  87375. * @param subMesh defines which submesh to check
  87376. * @param useInstances specifies that instances should be used
  87377. * @returns a boolean indicating that the submesh is ready or not
  87378. */
  87379. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87380. /**
  87381. * Binds the submesh to this material by preparing the effect and shader to draw
  87382. * @param world defines the world transformation matrix
  87383. * @param mesh defines the mesh containing the submesh
  87384. * @param subMesh defines the submesh to bind the material to
  87385. */
  87386. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87387. /**
  87388. * Get the list of animatables in the material.
  87389. * @returns the list of animatables object used in the material
  87390. */
  87391. getAnimatables(): BABYLON.IAnimatable[];
  87392. /**
  87393. * Disposes the material
  87394. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87395. */
  87396. dispose(forceDisposeEffect?: boolean): void;
  87397. /**
  87398. * Makes a duplicate of the material, and gives it a new name
  87399. * @param name defines the new name for the duplicated material
  87400. * @returns the cloned material
  87401. */
  87402. clone(name: string): SkyMaterial;
  87403. /**
  87404. * Serializes this material in a JSON representation
  87405. * @returns the serialized material object
  87406. */
  87407. serialize(): any;
  87408. /**
  87409. * Gets the current class name of the material e.g. "SkyMaterial"
  87410. * Mainly use in serialization.
  87411. * @returns the class name
  87412. */
  87413. getClassName(): string;
  87414. /**
  87415. * Creates a sky material from parsed material data
  87416. * @param source defines the JSON representation of the material
  87417. * @param scene defines the hosting scene
  87418. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87419. * @returns a new sky material
  87420. */
  87421. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87422. }
  87423. }
  87424. declare module BABYLON {
  87425. /** @hidden */
  87426. export var terrainPixelShader: {
  87427. name: string;
  87428. shader: string;
  87429. };
  87430. }
  87431. declare module BABYLON {
  87432. /** @hidden */
  87433. export var terrainVertexShader: {
  87434. name: string;
  87435. shader: string;
  87436. };
  87437. }
  87438. declare module BABYLON {
  87439. export class TerrainMaterial extends BABYLON.PushMaterial {
  87440. private _mixTexture;
  87441. mixTexture: BABYLON.BaseTexture;
  87442. private _diffuseTexture1;
  87443. diffuseTexture1: BABYLON.Texture;
  87444. private _diffuseTexture2;
  87445. diffuseTexture2: BABYLON.Texture;
  87446. private _diffuseTexture3;
  87447. diffuseTexture3: BABYLON.Texture;
  87448. private _bumpTexture1;
  87449. bumpTexture1: BABYLON.Texture;
  87450. private _bumpTexture2;
  87451. bumpTexture2: BABYLON.Texture;
  87452. private _bumpTexture3;
  87453. bumpTexture3: BABYLON.Texture;
  87454. diffuseColor: BABYLON.Color3;
  87455. specularColor: BABYLON.Color3;
  87456. specularPower: number;
  87457. private _disableLighting;
  87458. disableLighting: boolean;
  87459. private _maxSimultaneousLights;
  87460. maxSimultaneousLights: number;
  87461. constructor(name: string, scene: BABYLON.Scene);
  87462. needAlphaBlending(): boolean;
  87463. needAlphaTesting(): boolean;
  87464. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87465. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87466. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87467. getAnimatables(): BABYLON.IAnimatable[];
  87468. getActiveTextures(): BABYLON.BaseTexture[];
  87469. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87470. dispose(forceDisposeEffect?: boolean): void;
  87471. clone(name: string): TerrainMaterial;
  87472. serialize(): any;
  87473. getClassName(): string;
  87474. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87475. }
  87476. }
  87477. declare module BABYLON {
  87478. /** @hidden */
  87479. export var triplanarPixelShader: {
  87480. name: string;
  87481. shader: string;
  87482. };
  87483. }
  87484. declare module BABYLON {
  87485. /** @hidden */
  87486. export var triplanarVertexShader: {
  87487. name: string;
  87488. shader: string;
  87489. };
  87490. }
  87491. declare module BABYLON {
  87492. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87493. mixTexture: BABYLON.BaseTexture;
  87494. private _diffuseTextureX;
  87495. diffuseTextureX: BABYLON.BaseTexture;
  87496. private _diffuseTextureY;
  87497. diffuseTextureY: BABYLON.BaseTexture;
  87498. private _diffuseTextureZ;
  87499. diffuseTextureZ: BABYLON.BaseTexture;
  87500. private _normalTextureX;
  87501. normalTextureX: BABYLON.BaseTexture;
  87502. private _normalTextureY;
  87503. normalTextureY: BABYLON.BaseTexture;
  87504. private _normalTextureZ;
  87505. normalTextureZ: BABYLON.BaseTexture;
  87506. tileSize: number;
  87507. diffuseColor: BABYLON.Color3;
  87508. specularColor: BABYLON.Color3;
  87509. specularPower: number;
  87510. private _disableLighting;
  87511. disableLighting: boolean;
  87512. private _maxSimultaneousLights;
  87513. maxSimultaneousLights: number;
  87514. constructor(name: string, scene: BABYLON.Scene);
  87515. needAlphaBlending(): boolean;
  87516. needAlphaTesting(): boolean;
  87517. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87518. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87519. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87520. getAnimatables(): BABYLON.IAnimatable[];
  87521. getActiveTextures(): BABYLON.BaseTexture[];
  87522. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87523. dispose(forceDisposeEffect?: boolean): void;
  87524. clone(name: string): TriPlanarMaterial;
  87525. serialize(): any;
  87526. getClassName(): string;
  87527. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  87528. }
  87529. }
  87530. declare module BABYLON {
  87531. /** @hidden */
  87532. export var waterPixelShader: {
  87533. name: string;
  87534. shader: string;
  87535. };
  87536. }
  87537. declare module BABYLON {
  87538. /** @hidden */
  87539. export var waterVertexShader: {
  87540. name: string;
  87541. shader: string;
  87542. };
  87543. }
  87544. declare module BABYLON {
  87545. export class WaterMaterial extends BABYLON.PushMaterial {
  87546. renderTargetSize: BABYLON.Vector2;
  87547. private _bumpTexture;
  87548. bumpTexture: BABYLON.BaseTexture;
  87549. diffuseColor: BABYLON.Color3;
  87550. specularColor: BABYLON.Color3;
  87551. specularPower: number;
  87552. private _disableLighting;
  87553. disableLighting: boolean;
  87554. private _maxSimultaneousLights;
  87555. maxSimultaneousLights: number;
  87556. /**
  87557. * Defines the wind force.
  87558. */
  87559. windForce: number;
  87560. /**
  87561. * Defines the direction of the wind in the plane (X, Z).
  87562. */
  87563. windDirection: BABYLON.Vector2;
  87564. /**
  87565. * Defines the height of the waves.
  87566. */
  87567. waveHeight: number;
  87568. /**
  87569. * Defines the bump height related to the bump map.
  87570. */
  87571. bumpHeight: number;
  87572. /**
  87573. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87574. */
  87575. private _bumpSuperimpose;
  87576. bumpSuperimpose: boolean;
  87577. /**
  87578. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87579. */
  87580. private _fresnelSeparate;
  87581. fresnelSeparate: boolean;
  87582. /**
  87583. * Defines wether or not bump Wwves modify the reflection.
  87584. */
  87585. private _bumpAffectsReflection;
  87586. bumpAffectsReflection: boolean;
  87587. /**
  87588. * Defines the water color blended with the refraction (near).
  87589. */
  87590. waterColor: BABYLON.Color3;
  87591. /**
  87592. * Defines the blend factor related to the water color.
  87593. */
  87594. colorBlendFactor: number;
  87595. /**
  87596. * Defines the water color blended with the reflection (far).
  87597. */
  87598. waterColor2: BABYLON.Color3;
  87599. /**
  87600. * Defines the blend factor related to the water color (reflection, far).
  87601. */
  87602. colorBlendFactor2: number;
  87603. /**
  87604. * Defines the maximum length of a wave.
  87605. */
  87606. waveLength: number;
  87607. /**
  87608. * Defines the waves speed.
  87609. */
  87610. waveSpeed: number;
  87611. /**
  87612. * 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.
  87613. */
  87614. waveCount: number;
  87615. /**
  87616. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87617. * will avoid calculating useless pixels in the pixel shader of the water material.
  87618. */
  87619. disableClipPlane: boolean;
  87620. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87621. private _mesh;
  87622. private _refractionRTT;
  87623. private _reflectionRTT;
  87624. private _reflectionTransform;
  87625. private _lastTime;
  87626. private _lastDeltaTime;
  87627. private _useLogarithmicDepth;
  87628. private _waitingRenderList;
  87629. private _imageProcessingConfiguration;
  87630. private _imageProcessingObserver;
  87631. /**
  87632. * Gets a boolean indicating that current material needs to register RTT
  87633. */
  87634. get hasRenderTargetTextures(): boolean;
  87635. /**
  87636. * Constructor
  87637. */
  87638. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  87639. get useLogarithmicDepth(): boolean;
  87640. set useLogarithmicDepth(value: boolean);
  87641. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87642. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87643. addToRenderList(node: any): void;
  87644. enableRenderTargets(enable: boolean): void;
  87645. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  87646. get renderTargetsEnabled(): boolean;
  87647. needAlphaBlending(): boolean;
  87648. needAlphaTesting(): boolean;
  87649. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87650. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87651. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87652. private _createRenderTargets;
  87653. getAnimatables(): BABYLON.IAnimatable[];
  87654. getActiveTextures(): BABYLON.BaseTexture[];
  87655. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87656. dispose(forceDisposeEffect?: boolean): void;
  87657. clone(name: string): WaterMaterial;
  87658. serialize(): any;
  87659. getClassName(): string;
  87660. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  87661. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  87662. }
  87663. }
  87664. declare module BABYLON {
  87665. /** @hidden */
  87666. export var asciiartPixelShader: {
  87667. name: string;
  87668. shader: string;
  87669. };
  87670. }
  87671. declare module BABYLON {
  87672. /**
  87673. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  87674. *
  87675. * It basically takes care rendering the font front the given font size to a texture.
  87676. * This is used later on in the postprocess.
  87677. */
  87678. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  87679. private _font;
  87680. private _text;
  87681. private _charSize;
  87682. /**
  87683. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87684. */
  87685. get charSize(): number;
  87686. /**
  87687. * Create a new instance of the Ascii Art FontTexture class
  87688. * @param name the name of the texture
  87689. * @param font the font to use, use the W3C CSS notation
  87690. * @param text the caracter set to use in the rendering.
  87691. * @param scene the scene that owns the texture
  87692. */
  87693. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87694. /**
  87695. * Gets the max char width of a font.
  87696. * @param font the font to use, use the W3C CSS notation
  87697. * @return the max char width
  87698. */
  87699. private getFontWidth;
  87700. /**
  87701. * Gets the max char height of a font.
  87702. * @param font the font to use, use the W3C CSS notation
  87703. * @return the max char height
  87704. */
  87705. private getFontHeight;
  87706. /**
  87707. * Clones the current AsciiArtTexture.
  87708. * @return the clone of the texture.
  87709. */
  87710. clone(): AsciiArtFontTexture;
  87711. /**
  87712. * Parses a json object representing the texture and returns an instance of it.
  87713. * @param source the source JSON representation
  87714. * @param scene the scene to create the texture for
  87715. * @return the parsed texture
  87716. */
  87717. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  87718. }
  87719. /**
  87720. * Option available in the Ascii Art Post Process.
  87721. */
  87722. export interface IAsciiArtPostProcessOptions {
  87723. /**
  87724. * The font to use following the w3c font definition.
  87725. */
  87726. font?: string;
  87727. /**
  87728. * The character set to use in the postprocess.
  87729. */
  87730. characterSet?: string;
  87731. /**
  87732. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87733. * This number is defined between 0 and 1;
  87734. */
  87735. mixToTile?: number;
  87736. /**
  87737. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87738. * This number is defined between 0 and 1;
  87739. */
  87740. mixToNormal?: number;
  87741. }
  87742. /**
  87743. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  87744. *
  87745. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87746. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  87747. */
  87748. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  87749. /**
  87750. * The font texture used to render the char in the post process.
  87751. */
  87752. private _asciiArtFontTexture;
  87753. /**
  87754. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87755. * This number is defined between 0 and 1;
  87756. */
  87757. mixToTile: number;
  87758. /**
  87759. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87760. * This number is defined between 0 and 1;
  87761. */
  87762. mixToNormal: number;
  87763. /**
  87764. * Instantiates a new Ascii Art Post Process.
  87765. * @param name the name to give to the postprocess
  87766. * @camera the camera to apply the post process to.
  87767. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  87768. */
  87769. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  87770. }
  87771. }
  87772. declare module BABYLON {
  87773. /** @hidden */
  87774. export var digitalrainPixelShader: {
  87775. name: string;
  87776. shader: string;
  87777. };
  87778. }
  87779. declare module BABYLON {
  87780. /**
  87781. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  87782. *
  87783. * It basically takes care rendering the font front the given font size to a texture.
  87784. * This is used later on in the postprocess.
  87785. */
  87786. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  87787. private _font;
  87788. private _text;
  87789. private _charSize;
  87790. /**
  87791. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87792. */
  87793. get charSize(): number;
  87794. /**
  87795. * Create a new instance of the Digital Rain FontTexture class
  87796. * @param name the name of the texture
  87797. * @param font the font to use, use the W3C CSS notation
  87798. * @param text the caracter set to use in the rendering.
  87799. * @param scene the scene that owns the texture
  87800. */
  87801. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87802. /**
  87803. * Gets the max char width of a font.
  87804. * @param font the font to use, use the W3C CSS notation
  87805. * @return the max char width
  87806. */
  87807. private getFontWidth;
  87808. /**
  87809. * Gets the max char height of a font.
  87810. * @param font the font to use, use the W3C CSS notation
  87811. * @return the max char height
  87812. */
  87813. private getFontHeight;
  87814. /**
  87815. * Clones the current DigitalRainFontTexture.
  87816. * @return the clone of the texture.
  87817. */
  87818. clone(): DigitalRainFontTexture;
  87819. /**
  87820. * Parses a json object representing the texture and returns an instance of it.
  87821. * @param source the source JSON representation
  87822. * @param scene the scene to create the texture for
  87823. * @return the parsed texture
  87824. */
  87825. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  87826. }
  87827. /**
  87828. * Option available in the Digital Rain Post Process.
  87829. */
  87830. export interface IDigitalRainPostProcessOptions {
  87831. /**
  87832. * The font to use following the w3c font definition.
  87833. */
  87834. font?: string;
  87835. /**
  87836. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87837. * This number is defined between 0 and 1;
  87838. */
  87839. mixToTile?: number;
  87840. /**
  87841. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87842. * This number is defined between 0 and 1;
  87843. */
  87844. mixToNormal?: number;
  87845. }
  87846. /**
  87847. * DigitalRainPostProcess helps rendering everithing in digital rain.
  87848. *
  87849. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87850. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  87851. */
  87852. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  87853. /**
  87854. * The font texture used to render the char in the post process.
  87855. */
  87856. private _digitalRainFontTexture;
  87857. /**
  87858. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87859. * This number is defined between 0 and 1;
  87860. */
  87861. mixToTile: number;
  87862. /**
  87863. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87864. * This number is defined between 0 and 1;
  87865. */
  87866. mixToNormal: number;
  87867. /**
  87868. * Instantiates a new Digital Rain Post Process.
  87869. * @param name the name to give to the postprocess
  87870. * @camera the camera to apply the post process to.
  87871. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  87872. */
  87873. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  87874. }
  87875. }
  87876. declare module BABYLON {
  87877. /** @hidden */
  87878. export var brickProceduralTexturePixelShader: {
  87879. name: string;
  87880. shader: string;
  87881. };
  87882. }
  87883. declare module BABYLON {
  87884. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  87885. private _numberOfBricksHeight;
  87886. private _numberOfBricksWidth;
  87887. private _jointColor;
  87888. private _brickColor;
  87889. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87890. updateShaderUniforms(): void;
  87891. get numberOfBricksHeight(): number;
  87892. set numberOfBricksHeight(value: number);
  87893. get numberOfBricksWidth(): number;
  87894. set numberOfBricksWidth(value: number);
  87895. get jointColor(): BABYLON.Color3;
  87896. set jointColor(value: BABYLON.Color3);
  87897. get brickColor(): BABYLON.Color3;
  87898. set brickColor(value: BABYLON.Color3);
  87899. /**
  87900. * Serializes this brick procedural texture
  87901. * @returns a serialized brick procedural texture object
  87902. */
  87903. serialize(): any;
  87904. /**
  87905. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  87906. * @param parsedTexture defines parsed texture data
  87907. * @param scene defines the current scene
  87908. * @param rootUrl defines the root URL containing brick procedural texture information
  87909. * @returns a parsed Brick Procedural BABYLON.Texture
  87910. */
  87911. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  87912. }
  87913. }
  87914. declare module BABYLON {
  87915. /** @hidden */
  87916. export var cloudProceduralTexturePixelShader: {
  87917. name: string;
  87918. shader: string;
  87919. };
  87920. }
  87921. declare module BABYLON {
  87922. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  87923. private _skyColor;
  87924. private _cloudColor;
  87925. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87926. updateShaderUniforms(): void;
  87927. get skyColor(): BABYLON.Color4;
  87928. set skyColor(value: BABYLON.Color4);
  87929. get cloudColor(): BABYLON.Color4;
  87930. set cloudColor(value: BABYLON.Color4);
  87931. /**
  87932. * Serializes this cloud procedural texture
  87933. * @returns a serialized cloud procedural texture object
  87934. */
  87935. serialize(): any;
  87936. /**
  87937. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  87938. * @param parsedTexture defines parsed texture data
  87939. * @param scene defines the current scene
  87940. * @param rootUrl defines the root URL containing cloud procedural texture information
  87941. * @returns a parsed Cloud Procedural BABYLON.Texture
  87942. */
  87943. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  87944. }
  87945. }
  87946. declare module BABYLON {
  87947. /** @hidden */
  87948. export var fireProceduralTexturePixelShader: {
  87949. name: string;
  87950. shader: string;
  87951. };
  87952. }
  87953. declare module BABYLON {
  87954. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  87955. private _time;
  87956. private _speed;
  87957. private _autoGenerateTime;
  87958. private _fireColors;
  87959. private _alphaThreshold;
  87960. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87961. updateShaderUniforms(): void;
  87962. render(useCameraPostProcess?: boolean): void;
  87963. static get PurpleFireColors(): BABYLON.Color3[];
  87964. static get GreenFireColors(): BABYLON.Color3[];
  87965. static get RedFireColors(): BABYLON.Color3[];
  87966. static get BlueFireColors(): BABYLON.Color3[];
  87967. get autoGenerateTime(): boolean;
  87968. set autoGenerateTime(value: boolean);
  87969. get fireColors(): BABYLON.Color3[];
  87970. set fireColors(value: BABYLON.Color3[]);
  87971. get time(): number;
  87972. set time(value: number);
  87973. get speed(): BABYLON.Vector2;
  87974. set speed(value: BABYLON.Vector2);
  87975. get alphaThreshold(): number;
  87976. set alphaThreshold(value: number);
  87977. /**
  87978. * Serializes this fire procedural texture
  87979. * @returns a serialized fire procedural texture object
  87980. */
  87981. serialize(): any;
  87982. /**
  87983. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  87984. * @param parsedTexture defines parsed texture data
  87985. * @param scene defines the current scene
  87986. * @param rootUrl defines the root URL containing fire procedural texture information
  87987. * @returns a parsed Fire Procedural BABYLON.Texture
  87988. */
  87989. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  87990. }
  87991. }
  87992. declare module BABYLON {
  87993. /** @hidden */
  87994. export var grassProceduralTexturePixelShader: {
  87995. name: string;
  87996. shader: string;
  87997. };
  87998. }
  87999. declare module BABYLON {
  88000. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  88001. private _grassColors;
  88002. private _groundColor;
  88003. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88004. updateShaderUniforms(): void;
  88005. get grassColors(): BABYLON.Color3[];
  88006. set grassColors(value: BABYLON.Color3[]);
  88007. get groundColor(): BABYLON.Color3;
  88008. set groundColor(value: BABYLON.Color3);
  88009. /**
  88010. * Serializes this grass procedural texture
  88011. * @returns a serialized grass procedural texture object
  88012. */
  88013. serialize(): any;
  88014. /**
  88015. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  88016. * @param parsedTexture defines parsed texture data
  88017. * @param scene defines the current scene
  88018. * @param rootUrl defines the root URL containing grass procedural texture information
  88019. * @returns a parsed Grass Procedural BABYLON.Texture
  88020. */
  88021. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  88022. }
  88023. }
  88024. declare module BABYLON {
  88025. /** @hidden */
  88026. export var marbleProceduralTexturePixelShader: {
  88027. name: string;
  88028. shader: string;
  88029. };
  88030. }
  88031. declare module BABYLON {
  88032. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  88033. private _numberOfTilesHeight;
  88034. private _numberOfTilesWidth;
  88035. private _amplitude;
  88036. private _jointColor;
  88037. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88038. updateShaderUniforms(): void;
  88039. get numberOfTilesHeight(): number;
  88040. set numberOfTilesHeight(value: number);
  88041. get amplitude(): number;
  88042. set amplitude(value: number);
  88043. get numberOfTilesWidth(): number;
  88044. set numberOfTilesWidth(value: number);
  88045. get jointColor(): BABYLON.Color3;
  88046. set jointColor(value: BABYLON.Color3);
  88047. /**
  88048. * Serializes this marble procedural texture
  88049. * @returns a serialized marble procedural texture object
  88050. */
  88051. serialize(): any;
  88052. /**
  88053. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  88054. * @param parsedTexture defines parsed texture data
  88055. * @param scene defines the current scene
  88056. * @param rootUrl defines the root URL containing marble procedural texture information
  88057. * @returns a parsed Marble Procedural BABYLON.Texture
  88058. */
  88059. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  88060. }
  88061. }
  88062. declare module BABYLON {
  88063. /** @hidden */
  88064. export var normalMapProceduralTexturePixelShader: {
  88065. name: string;
  88066. shader: string;
  88067. };
  88068. }
  88069. declare module BABYLON {
  88070. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  88071. private _baseTexture;
  88072. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88073. updateShaderUniforms(): void;
  88074. render(useCameraPostProcess?: boolean): void;
  88075. resize(size: any, generateMipMaps: any): void;
  88076. get baseTexture(): BABYLON.Texture;
  88077. set baseTexture(texture: BABYLON.Texture);
  88078. /**
  88079. * Serializes this normal map procedural texture
  88080. * @returns a serialized normal map procedural texture object
  88081. */
  88082. serialize(): any;
  88083. /**
  88084. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  88085. * @param parsedTexture defines parsed texture data
  88086. * @param scene defines the current scene
  88087. * @param rootUrl defines the root URL containing normal map procedural texture information
  88088. * @returns a parsed Normal Map Procedural BABYLON.Texture
  88089. */
  88090. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  88091. }
  88092. }
  88093. declare module BABYLON {
  88094. /** @hidden */
  88095. export var perlinNoiseProceduralTexturePixelShader: {
  88096. name: string;
  88097. shader: string;
  88098. };
  88099. }
  88100. declare module BABYLON {
  88101. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  88102. time: number;
  88103. timeScale: number;
  88104. translationSpeed: number;
  88105. private _currentTranslation;
  88106. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88107. updateShaderUniforms(): void;
  88108. render(useCameraPostProcess?: boolean): void;
  88109. resize(size: any, generateMipMaps: any): void;
  88110. /**
  88111. * Serializes this perlin noise procedural texture
  88112. * @returns a serialized perlin noise procedural texture object
  88113. */
  88114. serialize(): any;
  88115. /**
  88116. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88117. * @param parsedTexture defines parsed texture data
  88118. * @param scene defines the current scene
  88119. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88120. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88121. */
  88122. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88123. }
  88124. }
  88125. declare module BABYLON {
  88126. /** @hidden */
  88127. export var roadProceduralTexturePixelShader: {
  88128. name: string;
  88129. shader: string;
  88130. };
  88131. }
  88132. declare module BABYLON {
  88133. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88134. private _roadColor;
  88135. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88136. updateShaderUniforms(): void;
  88137. get roadColor(): BABYLON.Color3;
  88138. set roadColor(value: BABYLON.Color3);
  88139. /**
  88140. * Serializes this road procedural texture
  88141. * @returns a serialized road procedural texture object
  88142. */
  88143. serialize(): any;
  88144. /**
  88145. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88146. * @param parsedTexture defines parsed texture data
  88147. * @param scene defines the current scene
  88148. * @param rootUrl defines the root URL containing road procedural texture information
  88149. * @returns a parsed Road Procedural BABYLON.Texture
  88150. */
  88151. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88152. }
  88153. }
  88154. declare module BABYLON {
  88155. /** @hidden */
  88156. export var starfieldProceduralTexturePixelShader: {
  88157. name: string;
  88158. shader: string;
  88159. };
  88160. }
  88161. declare module BABYLON {
  88162. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88163. private _time;
  88164. private _alpha;
  88165. private _beta;
  88166. private _zoom;
  88167. private _formuparam;
  88168. private _stepsize;
  88169. private _tile;
  88170. private _brightness;
  88171. private _darkmatter;
  88172. private _distfading;
  88173. private _saturation;
  88174. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88175. updateShaderUniforms(): void;
  88176. get time(): number;
  88177. set time(value: number);
  88178. get alpha(): number;
  88179. set alpha(value: number);
  88180. get beta(): number;
  88181. set beta(value: number);
  88182. get formuparam(): number;
  88183. set formuparam(value: number);
  88184. get stepsize(): number;
  88185. set stepsize(value: number);
  88186. get zoom(): number;
  88187. set zoom(value: number);
  88188. get tile(): number;
  88189. set tile(value: number);
  88190. get brightness(): number;
  88191. set brightness(value: number);
  88192. get darkmatter(): number;
  88193. set darkmatter(value: number);
  88194. get distfading(): number;
  88195. set distfading(value: number);
  88196. get saturation(): number;
  88197. set saturation(value: number);
  88198. /**
  88199. * Serializes this starfield procedural texture
  88200. * @returns a serialized starfield procedural texture object
  88201. */
  88202. serialize(): any;
  88203. /**
  88204. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88205. * @param parsedTexture defines parsed texture data
  88206. * @param scene defines the current scene
  88207. * @param rootUrl defines the root URL containing startfield procedural texture information
  88208. * @returns a parsed Starfield Procedural BABYLON.Texture
  88209. */
  88210. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88211. }
  88212. }
  88213. declare module BABYLON {
  88214. /** @hidden */
  88215. export var woodProceduralTexturePixelShader: {
  88216. name: string;
  88217. shader: string;
  88218. };
  88219. }
  88220. declare module BABYLON {
  88221. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88222. private _ampScale;
  88223. private _woodColor;
  88224. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88225. updateShaderUniforms(): void;
  88226. get ampScale(): number;
  88227. set ampScale(value: number);
  88228. get woodColor(): BABYLON.Color3;
  88229. set woodColor(value: BABYLON.Color3);
  88230. /**
  88231. * Serializes this wood procedural texture
  88232. * @returns a serialized wood procedural texture object
  88233. */
  88234. serialize(): any;
  88235. /**
  88236. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88237. * @param parsedTexture defines parsed texture data
  88238. * @param scene defines the current scene
  88239. * @param rootUrl defines the root URL containing wood procedural texture information
  88240. * @returns a parsed Wood Procedural BABYLON.Texture
  88241. */
  88242. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88243. }
  88244. }