documentation.d.ts 3.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. private static _LogCache;
  333. /**
  334. * Gets a value indicating the number of loading errors
  335. * @ignorenaming
  336. */
  337. static errorsCount: number;
  338. /**
  339. * Callback called when a new log is added
  340. */
  341. static OnNewCacheEntry: (entry: string) => void;
  342. private static _AddLogEntry;
  343. private static _FormatMessage;
  344. private static _LogDisabled;
  345. private static _LogEnabled;
  346. private static _WarnDisabled;
  347. private static _WarnEnabled;
  348. private static _ErrorDisabled;
  349. private static _ErrorEnabled;
  350. /**
  351. * Log a message to the console
  352. */
  353. static Log: (message: string) => void;
  354. /**
  355. * Write a warning message to the console
  356. */
  357. static Warn: (message: string) => void;
  358. /**
  359. * Write an error message to the console
  360. */
  361. static Error: (message: string) => void;
  362. /**
  363. * Gets current log cache (list of logs)
  364. */
  365. static get LogCache(): string;
  366. /**
  367. * Clears the log cache
  368. */
  369. static ClearLogCache(): void;
  370. /**
  371. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  372. */
  373. static set LogLevels(level: number);
  374. }
  375. }
  376. declare module BABYLON {
  377. /** @hidden */
  378. export class _TypeStore {
  379. /** @hidden */
  380. static RegisteredTypes: {
  381. [key: string]: Object;
  382. };
  383. /** @hidden */
  384. static GetClass(fqdn: string): any;
  385. }
  386. }
  387. declare module BABYLON {
  388. /**
  389. * Helper to manipulate strings
  390. */
  391. export class StringTools {
  392. /**
  393. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  394. * @param str Source string
  395. * @param suffix Suffix to search for in the source string
  396. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  397. */
  398. static EndsWith(str: string, suffix: string): boolean;
  399. /**
  400. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static StartsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Decodes a buffer into a string
  408. * @param buffer The buffer to decode
  409. * @returns The decoded string
  410. */
  411. static Decode(buffer: Uint8Array | Uint16Array): string;
  412. /**
  413. * Encode a buffer to a base64 string
  414. * @param buffer defines the buffer to encode
  415. * @returns the encoded string
  416. */
  417. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  418. /**
  419. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  420. * @param num the number to convert and pad
  421. * @param length the expected length of the string
  422. * @returns the padded string
  423. */
  424. static PadNumber(num: number, length: number): string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Class containing a set of static utilities functions for deep copy.
  430. */
  431. export class DeepCopier {
  432. /**
  433. * Tries to copy an object by duplicating every property
  434. * @param source defines the source object
  435. * @param destination defines the target object
  436. * @param doNotCopyList defines a list of properties to avoid
  437. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  438. */
  439. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  440. }
  441. }
  442. declare module BABYLON {
  443. /**
  444. * Class containing a set of static utilities functions for precision date
  445. */
  446. export class PrecisionDate {
  447. /**
  448. * Gets either window.performance.now() if supported or Date.now() else
  449. */
  450. static get Now(): number;
  451. }
  452. }
  453. declare module BABYLON {
  454. /** @hidden */
  455. export class _DevTools {
  456. static WarnImport(name: string): string;
  457. }
  458. }
  459. declare module BABYLON {
  460. /**
  461. * Interface used to define the mechanism to get data from the network
  462. */
  463. export interface IWebRequest {
  464. /**
  465. * Returns client's response url
  466. */
  467. responseURL: string;
  468. /**
  469. * Returns client's status
  470. */
  471. status: number;
  472. /**
  473. * Returns client's status as a text
  474. */
  475. statusText: string;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  481. */
  482. export class WebRequest implements IWebRequest {
  483. private readonly _xhr;
  484. /**
  485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  486. * i.e. when loading files, where the server/service expects an Authorization header
  487. */
  488. static CustomRequestHeaders: {
  489. [key: string]: string;
  490. };
  491. /**
  492. * Add callback functions in this array to update all the requests before they get sent to the network
  493. */
  494. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  495. private _injectCustomRequestHeaders;
  496. /**
  497. * Gets or sets a function to be called when loading progress changes
  498. */
  499. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  500. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  501. /**
  502. * Returns client's state
  503. */
  504. get readyState(): number;
  505. /**
  506. * Returns client's status
  507. */
  508. get status(): number;
  509. /**
  510. * Returns client's status as a text
  511. */
  512. get statusText(): string;
  513. /**
  514. * Returns client's response
  515. */
  516. get response(): any;
  517. /**
  518. * Returns client's response url
  519. */
  520. get responseURL(): string;
  521. /**
  522. * Returns client's response as text
  523. */
  524. get responseText(): string;
  525. /**
  526. * Gets or sets the expected response type
  527. */
  528. get responseType(): XMLHttpRequestResponseType;
  529. set responseType(value: XMLHttpRequestResponseType);
  530. /** @hidden */
  531. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  532. /** @hidden */
  533. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  534. /**
  535. * Cancels any network activity
  536. */
  537. abort(): void;
  538. /**
  539. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  540. * @param body defines an optional request body
  541. */
  542. send(body?: Document | BodyInit | null): void;
  543. /**
  544. * Sets the request method, request URL
  545. * @param method defines the method to use (GET, POST, etc..)
  546. * @param url defines the url to connect with
  547. */
  548. open(method: string, url: string): void;
  549. /**
  550. * Sets the value of a request header.
  551. * @param name The name of the header whose value is to be set
  552. * @param value The value to set as the body of the header
  553. */
  554. setRequestHeader(name: string, value: string): void;
  555. /**
  556. * Get the string containing the text of a particular header's value.
  557. * @param name The name of the header
  558. * @returns The string containing the text of the given header name
  559. */
  560. getResponseHeader(name: string): Nullable<string>;
  561. }
  562. }
  563. declare module BABYLON {
  564. /**
  565. * File request interface
  566. */
  567. export interface IFileRequest {
  568. /**
  569. * Raised when the request is complete (success or error).
  570. */
  571. onCompleteObservable: Observable<IFileRequest>;
  572. /**
  573. * Aborts the request for a file.
  574. */
  575. abort: () => void;
  576. }
  577. }
  578. declare module BABYLON {
  579. /**
  580. * Define options used to create a render target texture
  581. */
  582. export class RenderTargetCreationOptions {
  583. /**
  584. * Specifies is mipmaps must be generated
  585. */
  586. generateMipMaps?: boolean;
  587. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  588. generateDepthBuffer?: boolean;
  589. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  590. generateStencilBuffer?: boolean;
  591. /** Defines texture type (int by default) */
  592. type?: number;
  593. /** Defines sampling mode (trilinear by default) */
  594. samplingMode?: number;
  595. /** Defines format (RGBA by default) */
  596. format?: number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /** Defines the cross module used constants to avoid circular dependncies */
  601. export class Constants {
  602. /** Defines that alpha blending is disabled */
  603. static readonly ALPHA_DISABLE: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  605. static readonly ALPHA_ADD: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  607. static readonly ALPHA_COMBINE: number;
  608. /** Defines that alpha blending is DEST - SRC * DEST */
  609. static readonly ALPHA_SUBTRACT: number;
  610. /** Defines that alpha blending is SRC * DEST */
  611. static readonly ALPHA_MULTIPLY: number;
  612. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  613. static readonly ALPHA_MAXIMIZED: number;
  614. /** Defines that alpha blending is SRC + DEST */
  615. static readonly ALPHA_ONEONE: number;
  616. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  617. static readonly ALPHA_PREMULTIPLIED: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  620. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  623. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  624. static readonly ALPHA_INTERPOLATE: number;
  625. /**
  626. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  627. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  628. */
  629. static readonly ALPHA_SCREENMODE: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST
  632. * Alpha will be set to SRC ALPHA + DST ALPHA
  633. */
  634. static readonly ALPHA_ONEONE_ONEONE: number;
  635. /**
  636. * Defines that alpha blending is SRC * DST ALPHA + DST
  637. * Alpha will be set to 0
  638. */
  639. static readonly ALPHA_ALPHATOCOLOR: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. */
  643. static readonly ALPHA_REVERSEONEMINUS: number;
  644. /**
  645. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  646. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  647. */
  648. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  649. /**
  650. * Defines that alpha blending is SRC + DST
  651. * Alpha will be set to SRC ALPHA
  652. */
  653. static readonly ALPHA_ONEONE_ONEZERO: number;
  654. /**
  655. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  656. * Alpha will be set to DST ALPHA
  657. */
  658. static readonly ALPHA_EXCLUSION: number;
  659. /** Defines that alpha blending equation a SUM */
  660. static readonly ALPHA_EQUATION_ADD: number;
  661. /** Defines that alpha blending equation a SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  663. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  664. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  665. /** Defines that alpha blending equation a MAX operation */
  666. static readonly ALPHA_EQUATION_MAX: number;
  667. /** Defines that alpha blending equation a MIN operation */
  668. static readonly ALPHA_EQUATION_MIN: number;
  669. /**
  670. * Defines that alpha blending equation a DARKEN operation:
  671. * It takes the min of the src and sums the alpha channels.
  672. */
  673. static readonly ALPHA_EQUATION_DARKEN: number;
  674. /** Defines that the ressource is not delayed*/
  675. static readonly DELAYLOADSTATE_NONE: number;
  676. /** Defines that the ressource was successfully delay loaded */
  677. static readonly DELAYLOADSTATE_LOADED: number;
  678. /** Defines that the ressource is currently delay loading */
  679. static readonly DELAYLOADSTATE_LOADING: number;
  680. /** Defines that the ressource is delayed and has not started loading */
  681. static readonly DELAYLOADSTATE_NOTLOADED: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  683. static readonly NEVER: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  685. static readonly ALWAYS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  687. static readonly LESS: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  689. static readonly EQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  691. static readonly LEQUAL: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  693. static readonly GREATER: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  695. static readonly GEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  697. static readonly NOTEQUAL: number;
  698. /** Passed to stencilOperation to specify that stencil value must be kept */
  699. static readonly KEEP: number;
  700. /** Passed to stencilOperation to specify that stencil value must be replaced */
  701. static readonly REPLACE: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented */
  703. static readonly INCR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented */
  705. static readonly DECR: number;
  706. /** Passed to stencilOperation to specify that stencil value must be inverted */
  707. static readonly INVERT: number;
  708. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  709. static readonly INCR_WRAP: number;
  710. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  711. static readonly DECR_WRAP: number;
  712. /** Texture is not repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  714. /** Texture is repeating outside of 0..1 UVs */
  715. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  716. /** Texture is repeating and mirrored */
  717. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  718. /** ALPHA */
  719. static readonly TEXTUREFORMAT_ALPHA: number;
  720. /** LUMINANCE */
  721. static readonly TEXTUREFORMAT_LUMINANCE: number;
  722. /** LUMINANCE_ALPHA */
  723. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  724. /** RGB */
  725. static readonly TEXTUREFORMAT_RGB: number;
  726. /** RGBA */
  727. static readonly TEXTUREFORMAT_RGBA: number;
  728. /** RED */
  729. static readonly TEXTUREFORMAT_RED: number;
  730. /** RED (2nd reference) */
  731. static readonly TEXTUREFORMAT_R: number;
  732. /** RG */
  733. static readonly TEXTUREFORMAT_RG: number;
  734. /** RED_INTEGER */
  735. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  736. /** RED_INTEGER (2nd reference) */
  737. static readonly TEXTUREFORMAT_R_INTEGER: number;
  738. /** RG_INTEGER */
  739. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  740. /** RGB_INTEGER */
  741. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  742. /** RGBA_INTEGER */
  743. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  744. /** UNSIGNED_BYTE */
  745. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  746. /** UNSIGNED_BYTE (2nd reference) */
  747. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  748. /** FLOAT */
  749. static readonly TEXTURETYPE_FLOAT: number;
  750. /** HALF_FLOAT */
  751. static readonly TEXTURETYPE_HALF_FLOAT: number;
  752. /** BYTE */
  753. static readonly TEXTURETYPE_BYTE: number;
  754. /** SHORT */
  755. static readonly TEXTURETYPE_SHORT: number;
  756. /** UNSIGNED_SHORT */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  758. /** INT */
  759. static readonly TEXTURETYPE_INT: number;
  760. /** UNSIGNED_INT */
  761. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  762. /** UNSIGNED_SHORT_4_4_4_4 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  764. /** UNSIGNED_SHORT_5_5_5_1 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  766. /** UNSIGNED_SHORT_5_6_5 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  768. /** UNSIGNED_INT_2_10_10_10_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  770. /** UNSIGNED_INT_24_8 */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  772. /** UNSIGNED_INT_10F_11F_11F_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  774. /** UNSIGNED_INT_5_9_9_9_REV */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  776. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  777. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  778. /** nearest is mag = nearest and min = nearest and no mip */
  779. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  780. /** mag = nearest and min = nearest and mip = none */
  781. static readonly TEXTURE_NEAREST_NEAREST: number;
  782. /** Bilinear is mag = linear and min = linear and no mip */
  783. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  784. /** mag = linear and min = linear and mip = none */
  785. static readonly TEXTURE_LINEAR_LINEAR: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  788. /** Trilinear is mag = linear and min = linear and mip = linear */
  789. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = nearest and mip = nearest */
  791. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = nearest */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  794. /** mag = nearest and min = linear and mip = linear */
  795. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  796. /** mag = nearest and min = linear and mip = none */
  797. static readonly TEXTURE_NEAREST_LINEAR: number;
  798. /** nearest is mag = nearest and min = nearest and mip = linear */
  799. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = nearest and mip = nearest */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  802. /** mag = linear and min = nearest and mip = linear */
  803. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  804. /** Bilinear is mag = linear and min = linear and mip = nearest */
  805. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = none */
  807. static readonly TEXTURE_LINEAR_NEAREST: number;
  808. /** Explicit coordinates mode */
  809. static readonly TEXTURE_EXPLICIT_MODE: number;
  810. /** Spherical coordinates mode */
  811. static readonly TEXTURE_SPHERICAL_MODE: number;
  812. /** Planar coordinates mode */
  813. static readonly TEXTURE_PLANAR_MODE: number;
  814. /** Cubic coordinates mode */
  815. static readonly TEXTURE_CUBIC_MODE: number;
  816. /** Projection coordinates mode */
  817. static readonly TEXTURE_PROJECTION_MODE: number;
  818. /** Skybox coordinates mode */
  819. static readonly TEXTURE_SKYBOX_MODE: number;
  820. /** Inverse Cubic coordinates mode */
  821. static readonly TEXTURE_INVCUBIC_MODE: number;
  822. /** Equirectangular coordinates mode */
  823. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  826. /** Equirectangular Fixed Mirrored coordinates mode */
  827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  828. /** Offline (baking) quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  830. /** High quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  832. /** Medium quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  834. /** Low quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  836. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  837. static readonly SCALEMODE_FLOOR: number;
  838. /** Defines that texture rescaling will look for the nearest power of 2 size */
  839. static readonly SCALEMODE_NEAREST: number;
  840. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  841. static readonly SCALEMODE_CEILING: number;
  842. /**
  843. * The dirty texture flag value
  844. */
  845. static readonly MATERIAL_TextureDirtyFlag: number;
  846. /**
  847. * The dirty light flag value
  848. */
  849. static readonly MATERIAL_LightDirtyFlag: number;
  850. /**
  851. * The dirty fresnel flag value
  852. */
  853. static readonly MATERIAL_FresnelDirtyFlag: number;
  854. /**
  855. * The dirty attribute flag value
  856. */
  857. static readonly MATERIAL_AttributesDirtyFlag: number;
  858. /**
  859. * The dirty misc flag value
  860. */
  861. static readonly MATERIAL_MiscDirtyFlag: number;
  862. /**
  863. * The dirty prepass flag value
  864. */
  865. static readonly MATERIAL_PrePassDirtyFlag: number;
  866. /**
  867. * The all dirty flag value
  868. */
  869. static readonly MATERIAL_AllDirtyFlag: number;
  870. /**
  871. * Returns the triangle fill mode
  872. */
  873. static readonly MATERIAL_TriangleFillMode: number;
  874. /**
  875. * Returns the wireframe mode
  876. */
  877. static readonly MATERIAL_WireFrameFillMode: number;
  878. /**
  879. * Returns the point fill mode
  880. */
  881. static readonly MATERIAL_PointFillMode: number;
  882. /**
  883. * Returns the point list draw mode
  884. */
  885. static readonly MATERIAL_PointListDrawMode: number;
  886. /**
  887. * Returns the line list draw mode
  888. */
  889. static readonly MATERIAL_LineListDrawMode: number;
  890. /**
  891. * Returns the line loop draw mode
  892. */
  893. static readonly MATERIAL_LineLoopDrawMode: number;
  894. /**
  895. * Returns the line strip draw mode
  896. */
  897. static readonly MATERIAL_LineStripDrawMode: number;
  898. /**
  899. * Returns the triangle strip draw mode
  900. */
  901. static readonly MATERIAL_TriangleStripDrawMode: number;
  902. /**
  903. * Returns the triangle fan draw mode
  904. */
  905. static readonly MATERIAL_TriangleFanDrawMode: number;
  906. /**
  907. * Stores the clock-wise side orientation
  908. */
  909. static readonly MATERIAL_ClockWiseSideOrientation: number;
  910. /**
  911. * Stores the counter clock-wise side orientation
  912. */
  913. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  914. /**
  915. * Nothing
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_NothingTrigger: number;
  919. /**
  920. * On pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickTrigger: number;
  924. /**
  925. * On left pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnLeftPickTrigger: number;
  929. /**
  930. * On right pick
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnRightPickTrigger: number;
  934. /**
  935. * On center pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnCenterPickTrigger: number;
  939. /**
  940. * On pick down
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickDownTrigger: number;
  944. /**
  945. * On double pick
  946. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnDoublePickTrigger: number;
  949. /**
  950. * On pick up
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickUpTrigger: number;
  954. /**
  955. * On pick out.
  956. * This trigger will only be raised if you also declared a OnPickDown
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPickOutTrigger: number;
  960. /**
  961. * On long press
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnLongPressTrigger: number;
  965. /**
  966. * On pointer over
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnPointerOverTrigger: number;
  970. /**
  971. * On pointer out
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnPointerOutTrigger: number;
  975. /**
  976. * On every frame
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnEveryFrameTrigger: number;
  980. /**
  981. * On intersection enter
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnIntersectionEnterTrigger: number;
  985. /**
  986. * On intersection exit
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnIntersectionExitTrigger: number;
  990. /**
  991. * On key down
  992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  993. */
  994. static readonly ACTION_OnKeyDownTrigger: number;
  995. /**
  996. * On key up
  997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  998. */
  999. static readonly ACTION_OnKeyUpTrigger: number;
  1000. /**
  1001. * Billboard mode will only apply to Y axis
  1002. */
  1003. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1004. /**
  1005. * Billboard mode will apply to all axes
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1008. /**
  1009. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1012. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1013. * Test order :
  1014. * Is the bounding sphere outside the frustum ?
  1015. * If not, are the bounding box vertices outside the frustum ?
  1016. * It not, then the cullable object is in the frustum.
  1017. */
  1018. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1019. /** Culling strategy : Bounding Sphere Only.
  1020. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1021. * It's also less accurate than the standard because some not visible objects can still be selected.
  1022. * Test : is the bounding sphere outside the frustum ?
  1023. * If not, then the cullable object is in the frustum.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1026. /** Culling strategy : Optimistic Inclusion.
  1027. * This in an inclusion test first, then the standard exclusion test.
  1028. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1030. * Anyway, it's as accurate as the standard strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the default culling strategy.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1036. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1037. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1038. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1039. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1040. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1041. * Test :
  1042. * Is the cullable object bounding sphere center in the frustum ?
  1043. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1044. */
  1045. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1046. /**
  1047. * No logging while loading
  1048. */
  1049. static readonly SCENELOADER_NO_LOGGING: number;
  1050. /**
  1051. * Minimal logging while loading
  1052. */
  1053. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1054. /**
  1055. * Summary logging while loading
  1056. */
  1057. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1058. /**
  1059. * Detailled logging while loading
  1060. */
  1061. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1062. /**
  1063. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1064. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1065. */
  1066. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1067. /**
  1068. * Constant used to retrieve the position texture index in the textures array in the prepass
  1069. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1070. */
  1071. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1072. /**
  1073. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1074. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1075. */
  1076. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1077. /**
  1078. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1079. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1080. */
  1081. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1082. /**
  1083. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1084. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1085. */
  1086. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1087. /**
  1088. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1089. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1090. */
  1091. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1092. /**
  1093. * Constant used to retrieve albedo index in the textures array in the prepass
  1094. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1095. */
  1096. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1097. }
  1098. }
  1099. declare module BABYLON {
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. * @param options options to be passed to the loader
  1123. */
  1124. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1125. /**
  1126. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1127. * @param data contains the texture data
  1128. * @param texture defines the BabylonJS internal texture
  1129. * @param callback defines the method to call once ready to upload
  1130. * @param options options to be passed to the loader
  1131. */
  1132. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1133. }
  1134. }
  1135. declare module BABYLON {
  1136. /**
  1137. * Class used to store and describe the pipeline context associated with an effect
  1138. */
  1139. export interface IPipelineContext {
  1140. /**
  1141. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1142. */
  1143. isAsync: boolean;
  1144. /**
  1145. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1146. */
  1147. isReady: boolean;
  1148. /** @hidden */
  1149. _getVertexShaderCode(): string | null;
  1150. /** @hidden */
  1151. _getFragmentShaderCode(): string | null;
  1152. /** @hidden */
  1153. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1154. }
  1155. }
  1156. declare module BABYLON {
  1157. /**
  1158. * Class used to store gfx data (like WebGLBuffer)
  1159. */
  1160. export class DataBuffer {
  1161. /**
  1162. * Gets or sets the number of objects referencing this buffer
  1163. */
  1164. references: number;
  1165. /** Gets or sets the size of the underlying buffer */
  1166. capacity: number;
  1167. /**
  1168. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1169. */
  1170. is32Bits: boolean;
  1171. /**
  1172. * Gets the underlying buffer
  1173. */
  1174. get underlyingResource(): any;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export interface IShaderProcessor {
  1180. attributeProcessor?: (attribute: string) => string;
  1181. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1182. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1183. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1184. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1185. lineProcessor?: (line: string, isFragment: boolean) => string;
  1186. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1187. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export interface ProcessingOptions {
  1193. defines: string[];
  1194. indexParameters: any;
  1195. isFragment: boolean;
  1196. shouldUseHighPrecisionShader: boolean;
  1197. supportsUniformBuffers: boolean;
  1198. shadersRepository: string;
  1199. includesShadersStore: {
  1200. [key: string]: string;
  1201. };
  1202. processor?: IShaderProcessor;
  1203. version: string;
  1204. platformName: string;
  1205. lookForClosingBracketForUniformBuffer?: boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderCodeNode {
  1211. line: string;
  1212. children: ShaderCodeNode[];
  1213. additionalDefineKey?: string;
  1214. additionalDefineValue?: string;
  1215. isValid(preprocessors: {
  1216. [key: string]: string;
  1217. }): boolean;
  1218. process(preprocessors: {
  1219. [key: string]: string;
  1220. }, options: ProcessingOptions): string;
  1221. }
  1222. }
  1223. declare module BABYLON {
  1224. /** @hidden */
  1225. export class ShaderCodeCursor {
  1226. private _lines;
  1227. lineIndex: number;
  1228. get currentLine(): string;
  1229. get canRead(): boolean;
  1230. set lines(value: string[]);
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /** @hidden */
  1235. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1236. process(preprocessors: {
  1237. [key: string]: string;
  1238. }, options: ProcessingOptions): string;
  1239. }
  1240. }
  1241. declare module BABYLON {
  1242. /** @hidden */
  1243. export class ShaderDefineExpression {
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. private static _OperatorPriority;
  1248. private static _Stack;
  1249. static postfixToInfix(postfix: string[]): string;
  1250. static infixToPostfix(infix: string): string[];
  1251. }
  1252. }
  1253. declare module BABYLON {
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. not: boolean;
  1267. constructor(define: string, not?: boolean);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module BABYLON {
  1274. /** @hidden */
  1275. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1276. leftOperand: ShaderDefineExpression;
  1277. rightOperand: ShaderDefineExpression;
  1278. isTrue(preprocessors: {
  1279. [key: string]: string;
  1280. }): boolean;
  1281. }
  1282. }
  1283. declare module BABYLON {
  1284. /** @hidden */
  1285. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1286. leftOperand: ShaderDefineExpression;
  1287. rightOperand: ShaderDefineExpression;
  1288. isTrue(preprocessors: {
  1289. [key: string]: string;
  1290. }): boolean;
  1291. }
  1292. }
  1293. declare module BABYLON {
  1294. /** @hidden */
  1295. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1296. define: string;
  1297. operand: string;
  1298. testValue: string;
  1299. constructor(define: string, operand: string, testValue: string);
  1300. isTrue(preprocessors: {
  1301. [key: string]: string;
  1302. }): boolean;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * Class used to enable access to offline support
  1308. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1309. */
  1310. export interface IOfflineProvider {
  1311. /**
  1312. * Gets a boolean indicating if scene must be saved in the database
  1313. */
  1314. enableSceneOffline: boolean;
  1315. /**
  1316. * Gets a boolean indicating if textures must be saved in the database
  1317. */
  1318. enableTexturesOffline: boolean;
  1319. /**
  1320. * Open the offline support and make it available
  1321. * @param successCallback defines the callback to call on success
  1322. * @param errorCallback defines the callback to call on error
  1323. */
  1324. open(successCallback: () => void, errorCallback: () => void): void;
  1325. /**
  1326. * Loads an image from the offline support
  1327. * @param url defines the url to load from
  1328. * @param image defines the target DOM image
  1329. */
  1330. loadImage(url: string, image: HTMLImageElement): void;
  1331. /**
  1332. * Loads a file from offline support
  1333. * @param url defines the URL to load from
  1334. * @param sceneLoaded defines a callback to call on success
  1335. * @param progressCallBack defines a callback to call when progress changed
  1336. * @param errorCallback defines a callback to call on error
  1337. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1338. */
  1339. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1340. }
  1341. }
  1342. declare module BABYLON {
  1343. /**
  1344. * Class used to help managing file picking and drag'n'drop
  1345. * File Storage
  1346. */
  1347. export class FilesInputStore {
  1348. /**
  1349. * List of files ready to be loaded
  1350. */
  1351. static FilesToLoad: {
  1352. [key: string]: File;
  1353. };
  1354. }
  1355. }
  1356. declare module BABYLON {
  1357. /**
  1358. * Class used to define a retry strategy when error happens while loading assets
  1359. */
  1360. export class RetryStrategy {
  1361. /**
  1362. * Function used to defines an exponential back off strategy
  1363. * @param maxRetries defines the maximum number of retries (3 by default)
  1364. * @param baseInterval defines the interval between retries
  1365. * @returns the strategy function to use
  1366. */
  1367. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1368. }
  1369. }
  1370. declare module BABYLON {
  1371. /**
  1372. * @ignore
  1373. * Application error to support additional information when loading a file
  1374. */
  1375. export abstract class BaseError extends Error {
  1376. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1377. }
  1378. }
  1379. declare module BABYLON {
  1380. /** @ignore */
  1381. export class LoadFileError extends BaseError {
  1382. request?: WebRequest;
  1383. file?: File;
  1384. /**
  1385. * Creates a new LoadFileError
  1386. * @param message defines the message of the error
  1387. * @param request defines the optional web request
  1388. * @param file defines the optional file
  1389. */
  1390. constructor(message: string, object?: WebRequest | File);
  1391. }
  1392. /** @ignore */
  1393. export class RequestFileError extends BaseError {
  1394. request: WebRequest;
  1395. /**
  1396. * Creates a new LoadFileError
  1397. * @param message defines the message of the error
  1398. * @param request defines the optional web request
  1399. */
  1400. constructor(message: string, request: WebRequest);
  1401. }
  1402. /** @ignore */
  1403. export class ReadFileError extends BaseError {
  1404. file: File;
  1405. /**
  1406. * Creates a new ReadFileError
  1407. * @param message defines the message of the error
  1408. * @param file defines the optional file
  1409. */
  1410. constructor(message: string, file: File);
  1411. }
  1412. /**
  1413. * @hidden
  1414. */
  1415. export class FileTools {
  1416. /**
  1417. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1418. */
  1419. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1420. /**
  1421. * Gets or sets the base URL to use to load assets
  1422. */
  1423. static BaseUrl: string;
  1424. /**
  1425. * Default behaviour for cors in the application.
  1426. * It can be a string if the expected behavior is identical in the entire app.
  1427. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1428. */
  1429. static CorsBehavior: string | ((url: string | string[]) => string);
  1430. /**
  1431. * Gets or sets a function used to pre-process url before using them to load assets
  1432. */
  1433. static PreprocessUrl: (url: string) => string;
  1434. /**
  1435. * Removes unwanted characters from an url
  1436. * @param url defines the url to clean
  1437. * @returns the cleaned url
  1438. */
  1439. private static _CleanUrl;
  1440. /**
  1441. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1442. * @param url define the url we are trying
  1443. * @param element define the dom element where to configure the cors policy
  1444. */
  1445. static SetCorsBehavior(url: string | string[], element: {
  1446. crossOrigin: string | null;
  1447. }): void;
  1448. /**
  1449. * Loads an image as an HTMLImageElement.
  1450. * @param input url string, ArrayBuffer, or Blob to load
  1451. * @param onLoad callback called when the image successfully loads
  1452. * @param onError callback called when the image fails to load
  1453. * @param offlineProvider offline provider for caching
  1454. * @param mimeType optional mime type
  1455. * @returns the HTMLImageElement of the loaded image
  1456. */
  1457. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1458. /**
  1459. * Reads a file from a File object
  1460. * @param file defines the file to load
  1461. * @param onSuccess defines the callback to call when data is loaded
  1462. * @param onProgress defines the callback to call during loading process
  1463. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1464. * @param onError defines the callback to call when an error occurs
  1465. * @returns a file request object
  1466. */
  1467. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1468. /**
  1469. * Loads a file from a url
  1470. * @param url url to load
  1471. * @param onSuccess callback called when the file successfully loads
  1472. * @param onProgress callback called while file is loading (if the server supports this mode)
  1473. * @param offlineProvider defines the offline provider for caching
  1474. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1475. * @param onError callback called when the file fails to load
  1476. * @returns a file request object
  1477. */
  1478. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1479. /**
  1480. * Loads a file
  1481. * @param url url to load
  1482. * @param onSuccess callback called when the file successfully loads
  1483. * @param onProgress callback called while file is loading (if the server supports this mode)
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @param onOpened callback called when the web request is opened
  1487. * @returns a file request object
  1488. */
  1489. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1490. /**
  1491. * Checks if the loaded document was accessed via `file:`-Protocol.
  1492. * @returns boolean
  1493. */
  1494. static IsFileURL(): boolean;
  1495. }
  1496. }
  1497. declare module BABYLON {
  1498. /** @hidden */
  1499. export class ShaderProcessor {
  1500. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1501. private static _ProcessPrecision;
  1502. private static _ExtractOperation;
  1503. private static _BuildSubExpression;
  1504. private static _BuildExpression;
  1505. private static _MoveCursorWithinIf;
  1506. private static _MoveCursor;
  1507. private static _EvaluatePreProcessors;
  1508. private static _PreparePreProcessors;
  1509. private static _ProcessShaderConversion;
  1510. private static _ProcessIncludes;
  1511. /**
  1512. * Loads a file from a url
  1513. * @param url url to load
  1514. * @param onSuccess callback called when the file successfully loads
  1515. * @param onProgress callback called while file is loading (if the server supports this mode)
  1516. * @param offlineProvider defines the offline provider for caching
  1517. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1518. * @param onError callback called when the file fails to load
  1519. * @returns a file request object
  1520. * @hidden
  1521. */
  1522. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1523. }
  1524. }
  1525. declare module BABYLON {
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IColor4Like {
  1530. r: float;
  1531. g: float;
  1532. b: float;
  1533. a: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IColor3Like {
  1539. r: float;
  1540. g: float;
  1541. b: float;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IVector4Like {
  1547. x: float;
  1548. y: float;
  1549. z: float;
  1550. w: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IVector3Like {
  1556. x: float;
  1557. y: float;
  1558. z: float;
  1559. }
  1560. /**
  1561. * @hidden
  1562. */
  1563. export interface IVector2Like {
  1564. x: float;
  1565. y: float;
  1566. }
  1567. /**
  1568. * @hidden
  1569. */
  1570. export interface IMatrixLike {
  1571. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1572. updateFlag: int;
  1573. }
  1574. /**
  1575. * @hidden
  1576. */
  1577. export interface IViewportLike {
  1578. x: float;
  1579. y: float;
  1580. width: float;
  1581. height: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IPlaneLike {
  1587. normal: IVector3Like;
  1588. d: float;
  1589. normalize(): void;
  1590. }
  1591. }
  1592. declare module BABYLON {
  1593. /**
  1594. * Interface used to define common properties for effect fallbacks
  1595. */
  1596. export interface IEffectFallbacks {
  1597. /**
  1598. * Removes the defines that should be removed when falling back.
  1599. * @param currentDefines defines the current define statements for the shader.
  1600. * @param effect defines the current effect we try to compile
  1601. * @returns The resulting defines with defines of the current rank removed.
  1602. */
  1603. reduce(currentDefines: string, effect: Effect): string;
  1604. /**
  1605. * Removes the fallback from the bound mesh.
  1606. */
  1607. unBindMesh(): void;
  1608. /**
  1609. * Checks to see if more fallbacks are still availible.
  1610. */
  1611. hasMoreFallbacks: boolean;
  1612. }
  1613. }
  1614. declare module BABYLON {
  1615. /**
  1616. * Class used to evalaute queries containing `and` and `or` operators
  1617. */
  1618. export class AndOrNotEvaluator {
  1619. /**
  1620. * Evaluate a query
  1621. * @param query defines the query to evaluate
  1622. * @param evaluateCallback defines the callback used to filter result
  1623. * @returns true if the query matches
  1624. */
  1625. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1626. private static _HandleParenthesisContent;
  1627. private static _SimplifyNegation;
  1628. }
  1629. }
  1630. declare module BABYLON {
  1631. /**
  1632. * Class used to store custom tags
  1633. */
  1634. export class Tags {
  1635. /**
  1636. * Adds support for tags on the given object
  1637. * @param obj defines the object to use
  1638. */
  1639. static EnableFor(obj: any): void;
  1640. /**
  1641. * Removes tags support
  1642. * @param obj defines the object to use
  1643. */
  1644. static DisableFor(obj: any): void;
  1645. /**
  1646. * Gets a boolean indicating if the given object has tags
  1647. * @param obj defines the object to use
  1648. * @returns a boolean
  1649. */
  1650. static HasTags(obj: any): boolean;
  1651. /**
  1652. * Gets the tags available on a given object
  1653. * @param obj defines the object to use
  1654. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1655. * @returns the tags
  1656. */
  1657. static GetTags(obj: any, asString?: boolean): any;
  1658. /**
  1659. * Adds tags to an object
  1660. * @param obj defines the object to use
  1661. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1662. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1663. */
  1664. static AddTagsTo(obj: any, tagsString: string): void;
  1665. /**
  1666. * @hidden
  1667. */
  1668. static _AddTagTo(obj: any, tag: string): void;
  1669. /**
  1670. * Removes specific tags from a specific object
  1671. * @param obj defines the object to use
  1672. * @param tagsString defines the tags to remove
  1673. */
  1674. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1675. /**
  1676. * @hidden
  1677. */
  1678. static _RemoveTagFrom(obj: any, tag: string): void;
  1679. /**
  1680. * Defines if tags hosted on an object match a given query
  1681. * @param obj defines the object to use
  1682. * @param tagsQuery defines the tag query
  1683. * @returns a boolean
  1684. */
  1685. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1686. }
  1687. }
  1688. declare module BABYLON {
  1689. /**
  1690. * Scalar computation library
  1691. */
  1692. export class Scalar {
  1693. /**
  1694. * Two pi constants convenient for computation.
  1695. */
  1696. static TwoPi: number;
  1697. /**
  1698. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1699. * @param a number
  1700. * @param b number
  1701. * @param epsilon (default = 1.401298E-45)
  1702. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1703. */
  1704. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1705. /**
  1706. * Returns a string : the upper case translation of the number i to hexadecimal.
  1707. * @param i number
  1708. * @returns the upper case translation of the number i to hexadecimal.
  1709. */
  1710. static ToHex(i: number): string;
  1711. /**
  1712. * Returns -1 if value is negative and +1 is value is positive.
  1713. * @param value the value
  1714. * @returns the value itself if it's equal to zero.
  1715. */
  1716. static Sign(value: number): number;
  1717. /**
  1718. * Returns the value itself if it's between min and max.
  1719. * Returns min if the value is lower than min.
  1720. * Returns max if the value is greater than max.
  1721. * @param value the value to clmap
  1722. * @param min the min value to clamp to (default: 0)
  1723. * @param max the max value to clamp to (default: 1)
  1724. * @returns the clamped value
  1725. */
  1726. static Clamp(value: number, min?: number, max?: number): number;
  1727. /**
  1728. * the log2 of value.
  1729. * @param value the value to compute log2 of
  1730. * @returns the log2 of value.
  1731. */
  1732. static Log2(value: number): number;
  1733. /**
  1734. * Loops the value, so that it is never larger than length and never smaller than 0.
  1735. *
  1736. * This is similar to the modulo operator but it works with floating point numbers.
  1737. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1738. * With t = 5 and length = 2.5, the result would be 0.0.
  1739. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1740. * @param value the value
  1741. * @param length the length
  1742. * @returns the looped value
  1743. */
  1744. static Repeat(value: number, length: number): number;
  1745. /**
  1746. * Normalize the value between 0.0 and 1.0 using min and max values
  1747. * @param value value to normalize
  1748. * @param min max to normalize between
  1749. * @param max min to normalize between
  1750. * @returns the normalized value
  1751. */
  1752. static Normalize(value: number, min: number, max: number): number;
  1753. /**
  1754. * Denormalize the value from 0.0 and 1.0 using min and max values
  1755. * @param normalized value to denormalize
  1756. * @param min max to denormalize between
  1757. * @param max min to denormalize between
  1758. * @returns the denormalized value
  1759. */
  1760. static Denormalize(normalized: number, min: number, max: number): number;
  1761. /**
  1762. * Calculates the shortest difference between two given angles given in degrees.
  1763. * @param current current angle in degrees
  1764. * @param target target angle in degrees
  1765. * @returns the delta
  1766. */
  1767. static DeltaAngle(current: number, target: number): number;
  1768. /**
  1769. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1770. * @param tx value
  1771. * @param length length
  1772. * @returns The returned value will move back and forth between 0 and length
  1773. */
  1774. static PingPong(tx: number, length: number): number;
  1775. /**
  1776. * Interpolates between min and max with smoothing at the limits.
  1777. *
  1778. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1779. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1780. * @param from from
  1781. * @param to to
  1782. * @param tx value
  1783. * @returns the smooth stepped value
  1784. */
  1785. static SmoothStep(from: number, to: number, tx: number): number;
  1786. /**
  1787. * Moves a value current towards target.
  1788. *
  1789. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1790. * Negative values of maxDelta pushes the value away from target.
  1791. * @param current current value
  1792. * @param target target value
  1793. * @param maxDelta max distance to move
  1794. * @returns resulting value
  1795. */
  1796. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1797. /**
  1798. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1799. *
  1800. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1801. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1802. * @param current current value
  1803. * @param target target value
  1804. * @param maxDelta max distance to move
  1805. * @returns resulting angle
  1806. */
  1807. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1808. /**
  1809. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1810. * @param start start value
  1811. * @param end target value
  1812. * @param amount amount to lerp between
  1813. * @returns the lerped value
  1814. */
  1815. static Lerp(start: number, end: number, amount: number): number;
  1816. /**
  1817. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1818. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1819. * @param start start value
  1820. * @param end target value
  1821. * @param amount amount to lerp between
  1822. * @returns the lerped value
  1823. */
  1824. static LerpAngle(start: number, end: number, amount: number): number;
  1825. /**
  1826. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1827. * @param a start value
  1828. * @param b target value
  1829. * @param value value between a and b
  1830. * @returns the inverseLerp value
  1831. */
  1832. static InverseLerp(a: number, b: number, value: number): number;
  1833. /**
  1834. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1835. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1836. * @param value1 spline value
  1837. * @param tangent1 spline value
  1838. * @param value2 spline value
  1839. * @param tangent2 spline value
  1840. * @param amount input value
  1841. * @returns hermite result
  1842. */
  1843. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1844. /**
  1845. * Returns a random float number between and min and max values
  1846. * @param min min value of random
  1847. * @param max max value of random
  1848. * @returns random value
  1849. */
  1850. static RandomRange(min: number, max: number): number;
  1851. /**
  1852. * This function returns percentage of a number in a given range.
  1853. *
  1854. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1855. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1856. * @param number to convert to percentage
  1857. * @param min min range
  1858. * @param max max range
  1859. * @returns the percentage
  1860. */
  1861. static RangeToPercent(number: number, min: number, max: number): number;
  1862. /**
  1863. * This function returns number that corresponds to the percentage in a given range.
  1864. *
  1865. * PercentToRange(0.34,0,100) will return 34.
  1866. * @param percent to convert to number
  1867. * @param min min range
  1868. * @param max max range
  1869. * @returns the number
  1870. */
  1871. static PercentToRange(percent: number, min: number, max: number): number;
  1872. /**
  1873. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1874. * @param angle The angle to normalize in radian.
  1875. * @return The converted angle.
  1876. */
  1877. static NormalizeRadians(angle: number): number;
  1878. }
  1879. }
  1880. declare module BABYLON {
  1881. /**
  1882. * Constant used to convert a value to gamma space
  1883. * @ignorenaming
  1884. */
  1885. export const ToGammaSpace: number;
  1886. /**
  1887. * Constant used to convert a value to linear space
  1888. * @ignorenaming
  1889. */
  1890. export const ToLinearSpace = 2.2;
  1891. /**
  1892. * Constant used to define the minimal number value in Babylon.js
  1893. * @ignorenaming
  1894. */
  1895. let Epsilon: number;
  1896. }
  1897. declare module BABYLON {
  1898. /**
  1899. * Class used to represent a viewport on screen
  1900. */
  1901. export class Viewport {
  1902. /** viewport left coordinate */
  1903. x: number;
  1904. /** viewport top coordinate */
  1905. y: number;
  1906. /**viewport width */
  1907. width: number;
  1908. /** viewport height */
  1909. height: number;
  1910. /**
  1911. * Creates a Viewport object located at (x, y) and sized (width, height)
  1912. * @param x defines viewport left coordinate
  1913. * @param y defines viewport top coordinate
  1914. * @param width defines the viewport width
  1915. * @param height defines the viewport height
  1916. */
  1917. constructor(
  1918. /** viewport left coordinate */
  1919. x: number,
  1920. /** viewport top coordinate */
  1921. y: number,
  1922. /**viewport width */
  1923. width: number,
  1924. /** viewport height */
  1925. height: number);
  1926. /**
  1927. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1928. * @param renderWidth defines the rendering width
  1929. * @param renderHeight defines the rendering height
  1930. * @returns a new Viewport
  1931. */
  1932. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1933. /**
  1934. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1935. * @param renderWidth defines the rendering width
  1936. * @param renderHeight defines the rendering height
  1937. * @param ref defines the target viewport
  1938. * @returns the current viewport
  1939. */
  1940. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1941. /**
  1942. * Returns a new Viewport copied from the current one
  1943. * @returns a new Viewport
  1944. */
  1945. clone(): Viewport;
  1946. }
  1947. }
  1948. declare module BABYLON {
  1949. /**
  1950. * Class containing a set of static utilities functions for arrays.
  1951. */
  1952. export class ArrayTools {
  1953. /**
  1954. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1955. * @param size the number of element to construct and put in the array
  1956. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1957. * @returns a new array filled with new objects
  1958. */
  1959. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1960. }
  1961. }
  1962. declare module BABYLON {
  1963. /**
  1964. * Represents a plane by the equation ax + by + cz + d = 0
  1965. */
  1966. export class Plane {
  1967. private static _TmpMatrix;
  1968. /**
  1969. * Normal of the plane (a,b,c)
  1970. */
  1971. normal: Vector3;
  1972. /**
  1973. * d component of the plane
  1974. */
  1975. d: number;
  1976. /**
  1977. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1978. * @param a a component of the plane
  1979. * @param b b component of the plane
  1980. * @param c c component of the plane
  1981. * @param d d component of the plane
  1982. */
  1983. constructor(a: number, b: number, c: number, d: number);
  1984. /**
  1985. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1986. */
  1987. asArray(): number[];
  1988. /**
  1989. * @returns a new plane copied from the current Plane.
  1990. */
  1991. clone(): Plane;
  1992. /**
  1993. * @returns the string "Plane".
  1994. */
  1995. getClassName(): string;
  1996. /**
  1997. * @returns the Plane hash code.
  1998. */
  1999. getHashCode(): number;
  2000. /**
  2001. * Normalize the current Plane in place.
  2002. * @returns the updated Plane.
  2003. */
  2004. normalize(): Plane;
  2005. /**
  2006. * Applies a transformation the plane and returns the result
  2007. * @param transformation the transformation matrix to be applied to the plane
  2008. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2009. */
  2010. transform(transformation: DeepImmutable<Matrix>): Plane;
  2011. /**
  2012. * Compute the dot product between the point and the plane normal
  2013. * @param point point to calculate the dot product with
  2014. * @returns the dot product (float) of the point coordinates and the plane normal.
  2015. */
  2016. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2017. /**
  2018. * Updates the current Plane from the plane defined by the three given points.
  2019. * @param point1 one of the points used to contruct the plane
  2020. * @param point2 one of the points used to contruct the plane
  2021. * @param point3 one of the points used to contruct the plane
  2022. * @returns the updated Plane.
  2023. */
  2024. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2025. /**
  2026. * Checks if the plane is facing a given direction
  2027. * @param direction the direction to check if the plane is facing
  2028. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2029. * @returns True is the vector "direction" is the same side than the plane normal.
  2030. */
  2031. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2032. /**
  2033. * Calculates the distance to a point
  2034. * @param point point to calculate distance to
  2035. * @returns the signed distance (float) from the given point to the Plane.
  2036. */
  2037. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2038. /**
  2039. * Creates a plane from an array
  2040. * @param array the array to create a plane from
  2041. * @returns a new Plane from the given array.
  2042. */
  2043. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2044. /**
  2045. * Creates a plane from three points
  2046. * @param point1 point used to create the plane
  2047. * @param point2 point used to create the plane
  2048. * @param point3 point used to create the plane
  2049. * @returns a new Plane defined by the three given points.
  2050. */
  2051. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2052. /**
  2053. * Creates a plane from an origin point and a normal
  2054. * @param origin origin of the plane to be constructed
  2055. * @param normal normal of the plane to be constructed
  2056. * @returns a new Plane the normal vector to this plane at the given origin point.
  2057. * Note : the vector "normal" is updated because normalized.
  2058. */
  2059. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2060. /**
  2061. * Calculates the distance from a plane and a point
  2062. * @param origin origin of the plane to be constructed
  2063. * @param normal normal of the plane to be constructed
  2064. * @param point point to calculate distance to
  2065. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2066. */
  2067. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2068. }
  2069. }
  2070. declare module BABYLON {
  2071. /** @hidden */
  2072. export class PerformanceConfigurator {
  2073. /** @hidden */
  2074. static MatrixUse64Bits: boolean;
  2075. /** @hidden */
  2076. static MatrixTrackPrecisionChange: boolean;
  2077. /** @hidden */
  2078. static MatrixCurrentType: any;
  2079. /** @hidden */
  2080. static MatrixTrackedMatrices: Array<any> | null;
  2081. /** @hidden */
  2082. static SetMatrixPrecision(use64bits: boolean): void;
  2083. }
  2084. }
  2085. declare module BABYLON {
  2086. /**
  2087. * Class representing a vector containing 2 coordinates
  2088. */
  2089. export class Vector2 {
  2090. /** defines the first coordinate */
  2091. x: number;
  2092. /** defines the second coordinate */
  2093. y: number;
  2094. /**
  2095. * Creates a new Vector2 from the given x and y coordinates
  2096. * @param x defines the first coordinate
  2097. * @param y defines the second coordinate
  2098. */
  2099. constructor(
  2100. /** defines the first coordinate */
  2101. x?: number,
  2102. /** defines the second coordinate */
  2103. y?: number);
  2104. /**
  2105. * Gets a string with the Vector2 coordinates
  2106. * @returns a string with the Vector2 coordinates
  2107. */
  2108. toString(): string;
  2109. /**
  2110. * Gets class name
  2111. * @returns the string "Vector2"
  2112. */
  2113. getClassName(): string;
  2114. /**
  2115. * Gets current vector hash code
  2116. * @returns the Vector2 hash code as a number
  2117. */
  2118. getHashCode(): number;
  2119. /**
  2120. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2121. * @param array defines the source array
  2122. * @param index defines the offset in source array
  2123. * @returns the current Vector2
  2124. */
  2125. toArray(array: FloatArray, index?: number): Vector2;
  2126. /**
  2127. * Update the current vector from an array
  2128. * @param array defines the destination array
  2129. * @param index defines the offset in the destination array
  2130. * @returns the current Vector3
  2131. */
  2132. fromArray(array: FloatArray, index?: number): Vector2;
  2133. /**
  2134. * Copy the current vector to an array
  2135. * @returns a new array with 2 elements: the Vector2 coordinates.
  2136. */
  2137. asArray(): number[];
  2138. /**
  2139. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2140. * @param source defines the source Vector2
  2141. * @returns the current updated Vector2
  2142. */
  2143. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Sets the Vector2 coordinates with the given floats
  2146. * @param x defines the first coordinate
  2147. * @param y defines the second coordinate
  2148. * @returns the current updated Vector2
  2149. */
  2150. copyFromFloats(x: number, y: number): Vector2;
  2151. /**
  2152. * Sets the Vector2 coordinates with the given floats
  2153. * @param x defines the first coordinate
  2154. * @param y defines the second coordinate
  2155. * @returns the current updated Vector2
  2156. */
  2157. set(x: number, y: number): Vector2;
  2158. /**
  2159. * Add another vector with the current one
  2160. * @param otherVector defines the other vector
  2161. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2162. */
  2163. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2164. /**
  2165. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2166. * @param otherVector defines the other vector
  2167. * @param result defines the target vector
  2168. * @returns the unmodified current Vector2
  2169. */
  2170. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2171. /**
  2172. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. addVector3(otherVector: Vector3): Vector2;
  2183. /**
  2184. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2185. * @param otherVector defines the other vector
  2186. * @returns a new Vector2
  2187. */
  2188. subtract(otherVector: Vector2): Vector2;
  2189. /**
  2190. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2191. * @param otherVector defines the other vector
  2192. * @param result defines the target vector
  2193. * @returns the unmodified current Vector2
  2194. */
  2195. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2196. /**
  2197. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2198. * @param otherVector defines the other vector
  2199. * @returns the current updated Vector2
  2200. */
  2201. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2202. /**
  2203. * Multiplies in place the current Vector2 coordinates by the given ones
  2204. * @param otherVector defines the other vector
  2205. * @returns the current updated Vector2
  2206. */
  2207. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2208. /**
  2209. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2210. * @param otherVector defines the other vector
  2211. * @returns a new Vector2
  2212. */
  2213. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2216. * @param otherVector defines the other vector
  2217. * @param result defines the target vector
  2218. * @returns the unmodified current Vector2
  2219. */
  2220. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2223. * @param x defines the first coordinate
  2224. * @param y defines the second coordinate
  2225. * @returns a new Vector2
  2226. */
  2227. multiplyByFloats(x: number, y: number): Vector2;
  2228. /**
  2229. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2230. * @param otherVector defines the other vector
  2231. * @returns a new Vector2
  2232. */
  2233. divide(otherVector: Vector2): Vector2;
  2234. /**
  2235. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2236. * @param otherVector defines the other vector
  2237. * @param result defines the target vector
  2238. * @returns the unmodified current Vector2
  2239. */
  2240. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2241. /**
  2242. * Divides the current Vector2 coordinates by the given ones
  2243. * @param otherVector defines the other vector
  2244. * @returns the current updated Vector2
  2245. */
  2246. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2247. /**
  2248. * Gets a new Vector2 with current Vector2 negated coordinates
  2249. * @returns a new Vector2
  2250. */
  2251. negate(): Vector2;
  2252. /**
  2253. * Negate this vector in place
  2254. * @returns this
  2255. */
  2256. negateInPlace(): Vector2;
  2257. /**
  2258. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2259. * @param result defines the Vector3 object where to store the result
  2260. * @returns the current Vector2
  2261. */
  2262. negateToRef(result: Vector2): Vector2;
  2263. /**
  2264. * Multiply the Vector2 coordinates by scale
  2265. * @param scale defines the scaling factor
  2266. * @returns the current updated Vector2
  2267. */
  2268. scaleInPlace(scale: number): Vector2;
  2269. /**
  2270. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2271. * @param scale defines the scaling factor
  2272. * @returns a new Vector2
  2273. */
  2274. scale(scale: number): Vector2;
  2275. /**
  2276. * Scale the current Vector2 values by a factor to a given Vector2
  2277. * @param scale defines the scale factor
  2278. * @param result defines the Vector2 object where to store the result
  2279. * @returns the unmodified current Vector2
  2280. */
  2281. scaleToRef(scale: number, result: Vector2): Vector2;
  2282. /**
  2283. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2284. * @param scale defines the scale factor
  2285. * @param result defines the Vector2 object where to store the result
  2286. * @returns the unmodified current Vector2
  2287. */
  2288. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2289. /**
  2290. * Gets a boolean if two vectors are equals
  2291. * @param otherVector defines the other vector
  2292. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2293. */
  2294. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2295. /**
  2296. * Gets a boolean if two vectors are equals (using an epsilon value)
  2297. * @param otherVector defines the other vector
  2298. * @param epsilon defines the minimal distance to consider equality
  2299. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2300. */
  2301. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2302. /**
  2303. * Gets a new Vector2 from current Vector2 floored values
  2304. * @returns a new Vector2
  2305. */
  2306. floor(): Vector2;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. fract(): Vector2;
  2312. /**
  2313. * Gets the length of the vector
  2314. * @returns the vector length (float)
  2315. */
  2316. length(): number;
  2317. /**
  2318. * Gets the vector squared length
  2319. * @returns the vector squared length (float)
  2320. */
  2321. lengthSquared(): number;
  2322. /**
  2323. * Normalize the vector
  2324. * @returns the current updated Vector2
  2325. */
  2326. normalize(): Vector2;
  2327. /**
  2328. * Gets a new Vector2 copied from the Vector2
  2329. * @returns a new Vector2
  2330. */
  2331. clone(): Vector2;
  2332. /**
  2333. * Gets a new Vector2(0, 0)
  2334. * @returns a new Vector2
  2335. */
  2336. static Zero(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(1, 1)
  2339. * @returns a new Vector2
  2340. */
  2341. static One(): Vector2;
  2342. /**
  2343. * Gets a new Vector2 set from the given index element of the given array
  2344. * @param array defines the data source
  2345. * @param offset defines the offset in the data source
  2346. * @returns a new Vector2
  2347. */
  2348. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2349. /**
  2350. * Sets "result" from the given index element of the given array
  2351. * @param array defines the data source
  2352. * @param offset defines the offset in the data source
  2353. * @param result defines the target vector
  2354. */
  2355. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2356. /**
  2357. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2358. * @param value1 defines 1st point of control
  2359. * @param value2 defines 2nd point of control
  2360. * @param value3 defines 3rd point of control
  2361. * @param value4 defines 4th point of control
  2362. * @param amount defines the interpolation factor
  2363. * @returns a new Vector2
  2364. */
  2365. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2366. /**
  2367. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2368. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2369. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2370. * @param value defines the value to clamp
  2371. * @param min defines the lower limit
  2372. * @param max defines the upper limit
  2373. * @returns a new Vector2
  2374. */
  2375. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2378. * @param value1 defines the 1st control point
  2379. * @param tangent1 defines the outgoing tangent
  2380. * @param value2 defines the 2nd control point
  2381. * @param tangent2 defines the incoming tangent
  2382. * @param amount defines the interpolation factor
  2383. * @returns a new Vector2
  2384. */
  2385. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2386. /**
  2387. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2388. * @param start defines the start vector
  2389. * @param end defines the end vector
  2390. * @param amount defines the interpolation factor
  2391. * @returns a new Vector2
  2392. */
  2393. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2394. /**
  2395. * Gets the dot product of the vector "left" and the vector "right"
  2396. * @param left defines first vector
  2397. * @param right defines second vector
  2398. * @returns the dot product (float)
  2399. */
  2400. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2401. /**
  2402. * Returns a new Vector2 equal to the normalized given vector
  2403. * @param vector defines the vector to normalize
  2404. * @returns a new Vector2
  2405. */
  2406. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2407. /**
  2408. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2409. * @param left defines 1st vector
  2410. * @param right defines 2nd vector
  2411. * @returns a new Vector2
  2412. */
  2413. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2414. /**
  2415. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2416. * @param left defines 1st vector
  2417. * @param right defines 2nd vector
  2418. * @returns a new Vector2
  2419. */
  2420. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2421. /**
  2422. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2423. * @param vector defines the vector to transform
  2424. * @param transformation defines the matrix to apply
  2425. * @returns a new Vector2
  2426. */
  2427. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2428. /**
  2429. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2430. * @param vector defines the vector to transform
  2431. * @param transformation defines the matrix to apply
  2432. * @param result defines the target vector
  2433. */
  2434. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2435. /**
  2436. * Determines if a given vector is included in a triangle
  2437. * @param p defines the vector to test
  2438. * @param p0 defines 1st triangle point
  2439. * @param p1 defines 2nd triangle point
  2440. * @param p2 defines 3rd triangle point
  2441. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2442. */
  2443. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2444. /**
  2445. * Gets the distance between the vectors "value1" and "value2"
  2446. * @param value1 defines first vector
  2447. * @param value2 defines second vector
  2448. * @returns the distance between vectors
  2449. */
  2450. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2451. /**
  2452. * Returns the squared distance between the vectors "value1" and "value2"
  2453. * @param value1 defines first vector
  2454. * @param value2 defines second vector
  2455. * @returns the squared distance between vectors
  2456. */
  2457. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2458. /**
  2459. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2460. * @param value1 defines first vector
  2461. * @param value2 defines second vector
  2462. * @returns a new Vector2
  2463. */
  2464. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2465. /**
  2466. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2467. * @param p defines the middle point
  2468. * @param segA defines one point of the segment
  2469. * @param segB defines the other point of the segment
  2470. * @returns the shortest distance
  2471. */
  2472. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2473. }
  2474. /**
  2475. * Class used to store (x,y,z) vector representation
  2476. * A Vector3 is the main object used in 3D geometry
  2477. * It can represent etiher the coordinates of a point the space, either a direction
  2478. * Reminder: js uses a left handed forward facing system
  2479. */
  2480. export class Vector3 {
  2481. private static _UpReadOnly;
  2482. private static _ZeroReadOnly;
  2483. /** @hidden */
  2484. _x: number;
  2485. /** @hidden */
  2486. _y: number;
  2487. /** @hidden */
  2488. _z: number;
  2489. /** @hidden */
  2490. _isDirty: boolean;
  2491. /** Gets or sets the x coordinate */
  2492. get x(): number;
  2493. set x(value: number);
  2494. /** Gets or sets the y coordinate */
  2495. get y(): number;
  2496. set y(value: number);
  2497. /** Gets or sets the z coordinate */
  2498. get z(): number;
  2499. set z(value: number);
  2500. /**
  2501. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2502. * @param x defines the first coordinates (on X axis)
  2503. * @param y defines the second coordinates (on Y axis)
  2504. * @param z defines the third coordinates (on Z axis)
  2505. */
  2506. constructor(x?: number, y?: number, z?: number);
  2507. /**
  2508. * Creates a string representation of the Vector3
  2509. * @returns a string with the Vector3 coordinates.
  2510. */
  2511. toString(): string;
  2512. /**
  2513. * Gets the class name
  2514. * @returns the string "Vector3"
  2515. */
  2516. getClassName(): string;
  2517. /**
  2518. * Creates the Vector3 hash code
  2519. * @returns a number which tends to be unique between Vector3 instances
  2520. */
  2521. getHashCode(): number;
  2522. /**
  2523. * Creates an array containing three elements : the coordinates of the Vector3
  2524. * @returns a new array of numbers
  2525. */
  2526. asArray(): number[];
  2527. /**
  2528. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2529. * @param array defines the destination array
  2530. * @param index defines the offset in the destination array
  2531. * @returns the current Vector3
  2532. */
  2533. toArray(array: FloatArray, index?: number): Vector3;
  2534. /**
  2535. * Update the current vector from an array
  2536. * @param array defines the destination array
  2537. * @param index defines the offset in the destination array
  2538. * @returns the current Vector3
  2539. */
  2540. fromArray(array: FloatArray, index?: number): Vector3;
  2541. /**
  2542. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2543. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2544. */
  2545. toQuaternion(): Quaternion;
  2546. /**
  2547. * Adds the given vector to the current Vector3
  2548. * @param otherVector defines the second operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2552. /**
  2553. * Adds the given coordinates to the current Vector3
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the current updated Vector3
  2558. */
  2559. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2562. * @param otherVector defines the second operand
  2563. * @returns the resulting Vector3
  2564. */
  2565. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2566. /**
  2567. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2568. * @param otherVector defines the second operand
  2569. * @param result defines the Vector3 object where to store the result
  2570. * @returns the current Vector3
  2571. */
  2572. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2573. /**
  2574. * Subtract the given vector from the current Vector3
  2575. * @param otherVector defines the second operand
  2576. * @returns the current updated Vector3
  2577. */
  2578. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2579. /**
  2580. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2581. * @param otherVector defines the second operand
  2582. * @returns the resulting Vector3
  2583. */
  2584. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2585. /**
  2586. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2587. * @param otherVector defines the second operand
  2588. * @param result defines the Vector3 object where to store the result
  2589. * @returns the current Vector3
  2590. */
  2591. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2592. /**
  2593. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2594. * @param x defines the x coordinate of the operand
  2595. * @param y defines the y coordinate of the operand
  2596. * @param z defines the z coordinate of the operand
  2597. * @returns the resulting Vector3
  2598. */
  2599. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2600. /**
  2601. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2602. * @param x defines the x coordinate of the operand
  2603. * @param y defines the y coordinate of the operand
  2604. * @param z defines the z coordinate of the operand
  2605. * @param result defines the Vector3 object where to store the result
  2606. * @returns the current Vector3
  2607. */
  2608. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2609. /**
  2610. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2611. * @returns a new Vector3
  2612. */
  2613. negate(): Vector3;
  2614. /**
  2615. * Negate this vector in place
  2616. * @returns this
  2617. */
  2618. negateInPlace(): Vector3;
  2619. /**
  2620. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2621. * @param result defines the Vector3 object where to store the result
  2622. * @returns the current Vector3
  2623. */
  2624. negateToRef(result: Vector3): Vector3;
  2625. /**
  2626. * Multiplies the Vector3 coordinates by the float "scale"
  2627. * @param scale defines the multiplier factor
  2628. * @returns the current updated Vector3
  2629. */
  2630. scaleInPlace(scale: number): Vector3;
  2631. /**
  2632. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2633. * @param scale defines the multiplier factor
  2634. * @returns a new Vector3
  2635. */
  2636. scale(scale: number): Vector3;
  2637. /**
  2638. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2639. * @param scale defines the multiplier factor
  2640. * @param result defines the Vector3 object where to store the result
  2641. * @returns the current Vector3
  2642. */
  2643. scaleToRef(scale: number, result: Vector3): Vector3;
  2644. /**
  2645. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2646. * @param scale defines the scale factor
  2647. * @param result defines the Vector3 object where to store the result
  2648. * @returns the unmodified current Vector3
  2649. */
  2650. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2651. /**
  2652. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2653. * @param origin defines the origin of the projection ray
  2654. * @param plane defines the plane to project to
  2655. * @returns the projected vector3
  2656. */
  2657. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2658. /**
  2659. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2660. * @param origin defines the origin of the projection ray
  2661. * @param plane defines the plane to project to
  2662. * @param result defines the Vector3 where to store the result
  2663. */
  2664. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2665. /**
  2666. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2667. * @param otherVector defines the second operand
  2668. * @returns true if both vectors are equals
  2669. */
  2670. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2671. /**
  2672. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2673. * @param otherVector defines the second operand
  2674. * @param epsilon defines the minimal distance to define values as equals
  2675. * @returns true if both vectors are distant less than epsilon
  2676. */
  2677. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2678. /**
  2679. * Returns true if the current Vector3 coordinates equals the given floats
  2680. * @param x defines the x coordinate of the operand
  2681. * @param y defines the y coordinate of the operand
  2682. * @param z defines the z coordinate of the operand
  2683. * @returns true if both vectors are equals
  2684. */
  2685. equalsToFloats(x: number, y: number, z: number): boolean;
  2686. /**
  2687. * Multiplies the current Vector3 coordinates by the given ones
  2688. * @param otherVector defines the second operand
  2689. * @returns the current updated Vector3
  2690. */
  2691. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2692. /**
  2693. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2694. * @param otherVector defines the second operand
  2695. * @returns the new Vector3
  2696. */
  2697. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2698. /**
  2699. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2700. * @param otherVector defines the second operand
  2701. * @param result defines the Vector3 object where to store the result
  2702. * @returns the current Vector3
  2703. */
  2704. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2705. /**
  2706. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2707. * @param x defines the x coordinate of the operand
  2708. * @param y defines the y coordinate of the operand
  2709. * @param z defines the z coordinate of the operand
  2710. * @returns the new Vector3
  2711. */
  2712. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2713. /**
  2714. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2715. * @param otherVector defines the second operand
  2716. * @returns the new Vector3
  2717. */
  2718. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2719. /**
  2720. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2721. * @param otherVector defines the second operand
  2722. * @param result defines the Vector3 object where to store the result
  2723. * @returns the current Vector3
  2724. */
  2725. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2726. /**
  2727. * Divides the current Vector3 coordinates by the given ones.
  2728. * @param otherVector defines the second operand
  2729. * @returns the current updated Vector3
  2730. */
  2731. divideInPlace(otherVector: Vector3): Vector3;
  2732. /**
  2733. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2734. * @param other defines the second operand
  2735. * @returns the current updated Vector3
  2736. */
  2737. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2738. /**
  2739. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2740. * @param other defines the second operand
  2741. * @returns the current updated Vector3
  2742. */
  2743. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2744. /**
  2745. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2746. * @param x defines the x coordinate of the operand
  2747. * @param y defines the y coordinate of the operand
  2748. * @param z defines the z coordinate of the operand
  2749. * @returns the current updated Vector3
  2750. */
  2751. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2752. /**
  2753. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2754. * @param x defines the x coordinate of the operand
  2755. * @param y defines the y coordinate of the operand
  2756. * @param z defines the z coordinate of the operand
  2757. * @returns the current updated Vector3
  2758. */
  2759. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2760. /**
  2761. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2762. * Check if is non uniform within a certain amount of decimal places to account for this
  2763. * @param epsilon the amount the values can differ
  2764. * @returns if the the vector is non uniform to a certain number of decimal places
  2765. */
  2766. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2767. /**
  2768. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2769. */
  2770. get isNonUniform(): boolean;
  2771. /**
  2772. * Gets a new Vector3 from current Vector3 floored values
  2773. * @returns a new Vector3
  2774. */
  2775. floor(): Vector3;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. fract(): Vector3;
  2781. /**
  2782. * Gets the length of the Vector3
  2783. * @returns the length of the Vector3
  2784. */
  2785. length(): number;
  2786. /**
  2787. * Gets the squared length of the Vector3
  2788. * @returns squared length of the Vector3
  2789. */
  2790. lengthSquared(): number;
  2791. /**
  2792. * Normalize the current Vector3.
  2793. * Please note that this is an in place operation.
  2794. * @returns the current updated Vector3
  2795. */
  2796. normalize(): Vector3;
  2797. /**
  2798. * Reorders the x y z properties of the vector in place
  2799. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2800. * @returns the current updated vector
  2801. */
  2802. reorderInPlace(order: string): this;
  2803. /**
  2804. * Rotates the vector around 0,0,0 by a quaternion
  2805. * @param quaternion the rotation quaternion
  2806. * @param result vector to store the result
  2807. * @returns the resulting vector
  2808. */
  2809. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2810. /**
  2811. * Rotates a vector around a given point
  2812. * @param quaternion the rotation quaternion
  2813. * @param point the point to rotate around
  2814. * @param result vector to store the result
  2815. * @returns the resulting vector
  2816. */
  2817. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2818. /**
  2819. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2820. * The cross product is then orthogonal to both current and "other"
  2821. * @param other defines the right operand
  2822. * @returns the cross product
  2823. */
  2824. cross(other: Vector3): Vector3;
  2825. /**
  2826. * Normalize the current Vector3 with the given input length.
  2827. * Please note that this is an in place operation.
  2828. * @param len the length of the vector
  2829. * @returns the current updated Vector3
  2830. */
  2831. normalizeFromLength(len: number): Vector3;
  2832. /**
  2833. * Normalize the current Vector3 to a new vector
  2834. * @returns the new Vector3
  2835. */
  2836. normalizeToNew(): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to the reference
  2839. * @param reference define the Vector3 to update
  2840. * @returns the updated Vector3
  2841. */
  2842. normalizeToRef(reference: Vector3): Vector3;
  2843. /**
  2844. * Creates a new Vector3 copied from the current Vector3
  2845. * @returns the new Vector3
  2846. */
  2847. clone(): Vector3;
  2848. /**
  2849. * Copies the given vector coordinates to the current Vector3 ones
  2850. * @param source defines the source Vector3
  2851. * @returns the current updated Vector3
  2852. */
  2853. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2854. /**
  2855. * Copies the given floats to the current Vector3 coordinates
  2856. * @param x defines the x coordinate of the operand
  2857. * @param y defines the y coordinate of the operand
  2858. * @param z defines the z coordinate of the operand
  2859. * @returns the current updated Vector3
  2860. */
  2861. copyFromFloats(x: number, y: number, z: number): Vector3;
  2862. /**
  2863. * Copies the given floats to the current Vector3 coordinates
  2864. * @param x defines the x coordinate of the operand
  2865. * @param y defines the y coordinate of the operand
  2866. * @param z defines the z coordinate of the operand
  2867. * @returns the current updated Vector3
  2868. */
  2869. set(x: number, y: number, z: number): Vector3;
  2870. /**
  2871. * Copies the given float to the current Vector3 coordinates
  2872. * @param v defines the x, y and z coordinates of the operand
  2873. * @returns the current updated Vector3
  2874. */
  2875. setAll(v: number): Vector3;
  2876. /**
  2877. * Get the clip factor between two vectors
  2878. * @param vector0 defines the first operand
  2879. * @param vector1 defines the second operand
  2880. * @param axis defines the axis to use
  2881. * @param size defines the size along the axis
  2882. * @returns the clip factor
  2883. */
  2884. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2885. /**
  2886. * Get angle between two vectors
  2887. * @param vector0 angle between vector0 and vector1
  2888. * @param vector1 angle between vector0 and vector1
  2889. * @param normal direction of the normal
  2890. * @return the angle between vector0 and vector1
  2891. */
  2892. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2893. /**
  2894. * Returns a new Vector3 set from the index "offset" of the given array
  2895. * @param array defines the source array
  2896. * @param offset defines the offset in the source array
  2897. * @returns the new Vector3
  2898. */
  2899. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2900. /**
  2901. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2902. * @param array defines the source array
  2903. * @param offset defines the offset in the source array
  2904. * @returns the new Vector3
  2905. * @deprecated Please use FromArray instead.
  2906. */
  2907. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2908. /**
  2909. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2910. * @param array defines the source array
  2911. * @param offset defines the offset in the source array
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2915. /**
  2916. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2917. * @param array defines the source array
  2918. * @param offset defines the offset in the source array
  2919. * @param result defines the Vector3 where to store the result
  2920. * @deprecated Please use FromArrayToRef instead.
  2921. */
  2922. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2923. /**
  2924. * Sets the given vector "result" with the given floats.
  2925. * @param x defines the x coordinate of the source
  2926. * @param y defines the y coordinate of the source
  2927. * @param z defines the z coordinate of the source
  2928. * @param result defines the Vector3 where to store the result
  2929. */
  2930. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2931. /**
  2932. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2933. * @returns a new empty Vector3
  2934. */
  2935. static Zero(): Vector3;
  2936. /**
  2937. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2938. * @returns a new unit Vector3
  2939. */
  2940. static One(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2943. * @returns a new up Vector3
  2944. */
  2945. static Up(): Vector3;
  2946. /**
  2947. * Gets a up Vector3 that must not be updated
  2948. */
  2949. static get UpReadOnly(): DeepImmutable<Vector3>;
  2950. /**
  2951. * Gets a zero Vector3 that must not be updated
  2952. */
  2953. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2954. /**
  2955. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2956. * @returns a new down Vector3
  2957. */
  2958. static Down(): Vector3;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2961. * @param rightHandedSystem is the scene right-handed (negative z)
  2962. * @returns a new forward Vector3
  2963. */
  2964. static Forward(rightHandedSystem?: boolean): Vector3;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2967. * @param rightHandedSystem is the scene right-handed (negative-z)
  2968. * @returns a new forward Vector3
  2969. */
  2970. static Backward(rightHandedSystem?: boolean): Vector3;
  2971. /**
  2972. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2973. * @returns a new right Vector3
  2974. */
  2975. static Right(): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2978. * @returns a new left Vector3
  2979. */
  2980. static Left(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2983. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2984. * @param vector defines the Vector3 to transform
  2985. * @param transformation defines the transformation matrix
  2986. * @returns the transformed Vector3
  2987. */
  2988. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2989. /**
  2990. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2991. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2992. * @param vector defines the Vector3 to transform
  2993. * @param transformation defines the transformation matrix
  2994. * @param result defines the Vector3 where to store the result
  2995. */
  2996. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2997. /**
  2998. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2999. * This method computes tranformed coordinates only, not transformed direction vectors
  3000. * @param x define the x coordinate of the source vector
  3001. * @param y define the y coordinate of the source vector
  3002. * @param z define the z coordinate of the source vector
  3003. * @param transformation defines the transformation matrix
  3004. * @param result defines the Vector3 where to store the result
  3005. */
  3006. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3007. /**
  3008. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3009. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3010. * @param vector defines the Vector3 to transform
  3011. * @param transformation defines the transformation matrix
  3012. * @returns the new Vector3
  3013. */
  3014. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3015. /**
  3016. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3017. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3018. * @param vector defines the Vector3 to transform
  3019. * @param transformation defines the transformation matrix
  3020. * @param result defines the Vector3 where to store the result
  3021. */
  3022. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3023. /**
  3024. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3025. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3026. * @param x define the x coordinate of the source vector
  3027. * @param y define the y coordinate of the source vector
  3028. * @param z define the z coordinate of the source vector
  3029. * @param transformation defines the transformation matrix
  3030. * @param result defines the Vector3 where to store the result
  3031. */
  3032. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3033. /**
  3034. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3035. * @param value1 defines the first control point
  3036. * @param value2 defines the second control point
  3037. * @param value3 defines the third control point
  3038. * @param value4 defines the fourth control point
  3039. * @param amount defines the amount on the spline to use
  3040. * @returns the new Vector3
  3041. */
  3042. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3043. /**
  3044. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3045. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3046. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3047. * @param value defines the current value
  3048. * @param min defines the lower range value
  3049. * @param max defines the upper range value
  3050. * @returns the new Vector3
  3051. */
  3052. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3053. /**
  3054. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3055. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3056. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3057. * @param value defines the current value
  3058. * @param min defines the lower range value
  3059. * @param max defines the upper range value
  3060. * @param result defines the Vector3 where to store the result
  3061. */
  3062. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3063. /**
  3064. * Checks if a given vector is inside a specific range
  3065. * @param v defines the vector to test
  3066. * @param min defines the minimum range
  3067. * @param max defines the maximum range
  3068. */
  3069. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3070. /**
  3071. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3072. * @param value1 defines the first control point
  3073. * @param tangent1 defines the first tangent vector
  3074. * @param value2 defines the second control point
  3075. * @param tangent2 defines the second tangent vector
  3076. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3077. * @returns the new Vector3
  3078. */
  3079. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3080. /**
  3081. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3082. * @param start defines the start value
  3083. * @param end defines the end value
  3084. * @param amount max defines amount between both (between 0 and 1)
  3085. * @returns the new Vector3
  3086. */
  3087. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3088. /**
  3089. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3090. * @param start defines the start value
  3091. * @param end defines the end value
  3092. * @param amount max defines amount between both (between 0 and 1)
  3093. * @param result defines the Vector3 where to store the result
  3094. */
  3095. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3096. /**
  3097. * Returns the dot product (float) between the vectors "left" and "right"
  3098. * @param left defines the left operand
  3099. * @param right defines the right operand
  3100. * @returns the dot product
  3101. */
  3102. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3103. /**
  3104. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3105. * The cross product is then orthogonal to both "left" and "right"
  3106. * @param left defines the left operand
  3107. * @param right defines the right operand
  3108. * @returns the cross product
  3109. */
  3110. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3111. /**
  3112. * Sets the given vector "result" with the cross product of "left" and "right"
  3113. * The cross product is then orthogonal to both "left" and "right"
  3114. * @param left defines the left operand
  3115. * @param right defines the right operand
  3116. * @param result defines the Vector3 where to store the result
  3117. */
  3118. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3119. /**
  3120. * Returns a new Vector3 as the normalization of the given vector
  3121. * @param vector defines the Vector3 to normalize
  3122. * @returns the new Vector3
  3123. */
  3124. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3125. /**
  3126. * Sets the given vector "result" with the normalization of the given first vector
  3127. * @param vector defines the Vector3 to normalize
  3128. * @param result defines the Vector3 where to store the result
  3129. */
  3130. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3131. /**
  3132. * Project a Vector3 onto screen space
  3133. * @param vector defines the Vector3 to project
  3134. * @param world defines the world matrix to use
  3135. * @param transform defines the transform (view x projection) matrix to use
  3136. * @param viewport defines the screen viewport to use
  3137. * @returns the new Vector3
  3138. */
  3139. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3140. /**
  3141. * Project a Vector3 onto screen space to reference
  3142. * @param vector defines the Vector3 to project
  3143. * @param world defines the world matrix to use
  3144. * @param transform defines the transform (view x projection) matrix to use
  3145. * @param viewport defines the screen viewport to use
  3146. * @param result the vector in which the screen space will be stored
  3147. * @returns the new Vector3
  3148. */
  3149. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3150. /** @hidden */
  3151. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3152. /**
  3153. * Unproject from screen space to object space
  3154. * @param source defines the screen space Vector3 to use
  3155. * @param viewportWidth defines the current width of the viewport
  3156. * @param viewportHeight defines the current height of the viewport
  3157. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3158. * @param transform defines the transform (view x projection) matrix to use
  3159. * @returns the new Vector3
  3160. */
  3161. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3162. /**
  3163. * Unproject from screen space to object space
  3164. * @param source defines the screen space Vector3 to use
  3165. * @param viewportWidth defines the current width of the viewport
  3166. * @param viewportHeight defines the current height of the viewport
  3167. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3168. * @param view defines the view matrix to use
  3169. * @param projection defines the projection matrix to use
  3170. * @returns the new Vector3
  3171. */
  3172. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3173. /**
  3174. * Unproject from screen space to object space
  3175. * @param source defines the screen space Vector3 to use
  3176. * @param viewportWidth defines the current width of the viewport
  3177. * @param viewportHeight defines the current height of the viewport
  3178. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3179. * @param view defines the view matrix to use
  3180. * @param projection defines the projection matrix to use
  3181. * @param result defines the Vector3 where to store the result
  3182. */
  3183. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3184. /**
  3185. * Unproject from screen space to object space
  3186. * @param sourceX defines the screen space x coordinate to use
  3187. * @param sourceY defines the screen space y coordinate to use
  3188. * @param sourceZ defines the screen space z coordinate to use
  3189. * @param viewportWidth defines the current width of the viewport
  3190. * @param viewportHeight defines the current height of the viewport
  3191. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3192. * @param view defines the view matrix to use
  3193. * @param projection defines the projection matrix to use
  3194. * @param result defines the Vector3 where to store the result
  3195. */
  3196. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3197. /**
  3198. * Gets the minimal coordinate values between two Vector3
  3199. * @param left defines the first operand
  3200. * @param right defines the second operand
  3201. * @returns the new Vector3
  3202. */
  3203. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3204. /**
  3205. * Gets the maximal coordinate values between two Vector3
  3206. * @param left defines the first operand
  3207. * @param right defines the second operand
  3208. * @returns the new Vector3
  3209. */
  3210. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3211. /**
  3212. * Returns the distance between the vectors "value1" and "value2"
  3213. * @param value1 defines the first operand
  3214. * @param value2 defines the second operand
  3215. * @returns the distance
  3216. */
  3217. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3218. /**
  3219. * Returns the squared distance between the vectors "value1" and "value2"
  3220. * @param value1 defines the first operand
  3221. * @param value2 defines the second operand
  3222. * @returns the squared distance
  3223. */
  3224. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3225. /**
  3226. * Returns a new Vector3 located at the center between "value1" and "value2"
  3227. * @param value1 defines the first operand
  3228. * @param value2 defines the second operand
  3229. * @returns the new Vector3
  3230. */
  3231. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3232. /**
  3233. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3234. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3235. * to something in order to rotate it from its local system to the given target system
  3236. * Note: axis1, axis2 and axis3 are normalized during this operation
  3237. * @param axis1 defines the first axis
  3238. * @param axis2 defines the second axis
  3239. * @param axis3 defines the third axis
  3240. * @returns a new Vector3
  3241. */
  3242. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3243. /**
  3244. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3245. * @param axis1 defines the first axis
  3246. * @param axis2 defines the second axis
  3247. * @param axis3 defines the third axis
  3248. * @param ref defines the Vector3 where to store the result
  3249. */
  3250. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3251. }
  3252. /**
  3253. * Vector4 class created for EulerAngle class conversion to Quaternion
  3254. */
  3255. export class Vector4 {
  3256. /** x value of the vector */
  3257. x: number;
  3258. /** y value of the vector */
  3259. y: number;
  3260. /** z value of the vector */
  3261. z: number;
  3262. /** w value of the vector */
  3263. w: number;
  3264. /**
  3265. * Creates a Vector4 object from the given floats.
  3266. * @param x x value of the vector
  3267. * @param y y value of the vector
  3268. * @param z z value of the vector
  3269. * @param w w value of the vector
  3270. */
  3271. constructor(
  3272. /** x value of the vector */
  3273. x: number,
  3274. /** y value of the vector */
  3275. y: number,
  3276. /** z value of the vector */
  3277. z: number,
  3278. /** w value of the vector */
  3279. w: number);
  3280. /**
  3281. * Returns the string with the Vector4 coordinates.
  3282. * @returns a string containing all the vector values
  3283. */
  3284. toString(): string;
  3285. /**
  3286. * Returns the string "Vector4".
  3287. * @returns "Vector4"
  3288. */
  3289. getClassName(): string;
  3290. /**
  3291. * Returns the Vector4 hash code.
  3292. * @returns a unique hash code
  3293. */
  3294. getHashCode(): number;
  3295. /**
  3296. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3297. * @returns the resulting array
  3298. */
  3299. asArray(): number[];
  3300. /**
  3301. * Populates the given array from the given index with the Vector4 coordinates.
  3302. * @param array array to populate
  3303. * @param index index of the array to start at (default: 0)
  3304. * @returns the Vector4.
  3305. */
  3306. toArray(array: FloatArray, index?: number): Vector4;
  3307. /**
  3308. * Update the current vector from an array
  3309. * @param array defines the destination array
  3310. * @param index defines the offset in the destination array
  3311. * @returns the current Vector3
  3312. */
  3313. fromArray(array: FloatArray, index?: number): Vector4;
  3314. /**
  3315. * Adds the given vector to the current Vector4.
  3316. * @param otherVector the vector to add
  3317. * @returns the updated Vector4.
  3318. */
  3319. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3320. /**
  3321. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3322. * @param otherVector the vector to add
  3323. * @returns the resulting vector
  3324. */
  3325. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3326. /**
  3327. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3328. * @param otherVector the vector to add
  3329. * @param result the vector to store the result
  3330. * @returns the current Vector4.
  3331. */
  3332. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3333. /**
  3334. * Subtract in place the given vector from the current Vector4.
  3335. * @param otherVector the vector to subtract
  3336. * @returns the updated Vector4.
  3337. */
  3338. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3339. /**
  3340. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3341. * @param otherVector the vector to add
  3342. * @returns the new vector with the result
  3343. */
  3344. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3345. /**
  3346. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3347. * @param otherVector the vector to subtract
  3348. * @param result the vector to store the result
  3349. * @returns the current Vector4.
  3350. */
  3351. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3352. /**
  3353. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3354. */
  3355. /**
  3356. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3357. * @param x value to subtract
  3358. * @param y value to subtract
  3359. * @param z value to subtract
  3360. * @param w value to subtract
  3361. * @returns new vector containing the result
  3362. */
  3363. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3364. /**
  3365. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3366. * @param x value to subtract
  3367. * @param y value to subtract
  3368. * @param z value to subtract
  3369. * @param w value to subtract
  3370. * @param result the vector to store the result in
  3371. * @returns the current Vector4.
  3372. */
  3373. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3374. /**
  3375. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3376. * @returns a new vector with the negated values
  3377. */
  3378. negate(): Vector4;
  3379. /**
  3380. * Negate this vector in place
  3381. * @returns this
  3382. */
  3383. negateInPlace(): Vector4;
  3384. /**
  3385. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3386. * @param result defines the Vector3 object where to store the result
  3387. * @returns the current Vector4
  3388. */
  3389. negateToRef(result: Vector4): Vector4;
  3390. /**
  3391. * Multiplies the current Vector4 coordinates by scale (float).
  3392. * @param scale the number to scale with
  3393. * @returns the updated Vector4.
  3394. */
  3395. scaleInPlace(scale: number): Vector4;
  3396. /**
  3397. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3398. * @param scale the number to scale with
  3399. * @returns a new vector with the result
  3400. */
  3401. scale(scale: number): Vector4;
  3402. /**
  3403. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3404. * @param scale the number to scale with
  3405. * @param result a vector to store the result in
  3406. * @returns the current Vector4.
  3407. */
  3408. scaleToRef(scale: number, result: Vector4): Vector4;
  3409. /**
  3410. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3411. * @param scale defines the scale factor
  3412. * @param result defines the Vector4 object where to store the result
  3413. * @returns the unmodified current Vector4
  3414. */
  3415. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3416. /**
  3417. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3418. * @param otherVector the vector to compare against
  3419. * @returns true if they are equal
  3420. */
  3421. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3422. /**
  3423. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3424. * @param otherVector vector to compare against
  3425. * @param epsilon (Default: very small number)
  3426. * @returns true if they are equal
  3427. */
  3428. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3429. /**
  3430. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3431. * @param x x value to compare against
  3432. * @param y y value to compare against
  3433. * @param z z value to compare against
  3434. * @param w w value to compare against
  3435. * @returns true if equal
  3436. */
  3437. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3438. /**
  3439. * Multiplies in place the current Vector4 by the given one.
  3440. * @param otherVector vector to multiple with
  3441. * @returns the updated Vector4.
  3442. */
  3443. multiplyInPlace(otherVector: Vector4): Vector4;
  3444. /**
  3445. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3446. * @param otherVector vector to multiple with
  3447. * @returns resulting new vector
  3448. */
  3449. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3452. * @param otherVector vector to multiple with
  3453. * @param result vector to store the result
  3454. * @returns the current Vector4.
  3455. */
  3456. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3457. /**
  3458. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3459. * @param x x value multiply with
  3460. * @param y y value multiply with
  3461. * @param z z value multiply with
  3462. * @param w w value multiply with
  3463. * @returns resulting new vector
  3464. */
  3465. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3466. /**
  3467. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3468. * @param otherVector vector to devide with
  3469. * @returns resulting new vector
  3470. */
  3471. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3472. /**
  3473. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3474. * @param otherVector vector to devide with
  3475. * @param result vector to store the result
  3476. * @returns the current Vector4.
  3477. */
  3478. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3479. /**
  3480. * Divides the current Vector3 coordinates by the given ones.
  3481. * @param otherVector vector to devide with
  3482. * @returns the updated Vector3.
  3483. */
  3484. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3485. /**
  3486. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3487. * @param other defines the second operand
  3488. * @returns the current updated Vector4
  3489. */
  3490. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3491. /**
  3492. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3493. * @param other defines the second operand
  3494. * @returns the current updated Vector4
  3495. */
  3496. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector4 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. floor(): Vector4;
  3502. /**
  3503. * Gets a new Vector4 from current Vector3 floored values
  3504. * @returns a new Vector4
  3505. */
  3506. fract(): Vector4;
  3507. /**
  3508. * Returns the Vector4 length (float).
  3509. * @returns the length
  3510. */
  3511. length(): number;
  3512. /**
  3513. * Returns the Vector4 squared length (float).
  3514. * @returns the length squared
  3515. */
  3516. lengthSquared(): number;
  3517. /**
  3518. * Normalizes in place the Vector4.
  3519. * @returns the updated Vector4.
  3520. */
  3521. normalize(): Vector4;
  3522. /**
  3523. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3524. * @returns this converted to a new vector3
  3525. */
  3526. toVector3(): Vector3;
  3527. /**
  3528. * Returns a new Vector4 copied from the current one.
  3529. * @returns the new cloned vector
  3530. */
  3531. clone(): Vector4;
  3532. /**
  3533. * Updates the current Vector4 with the given one coordinates.
  3534. * @param source the source vector to copy from
  3535. * @returns the updated Vector4.
  3536. */
  3537. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3538. /**
  3539. * Updates the current Vector4 coordinates with the given floats.
  3540. * @param x float to copy from
  3541. * @param y float to copy from
  3542. * @param z float to copy from
  3543. * @param w float to copy from
  3544. * @returns the updated Vector4.
  3545. */
  3546. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3547. /**
  3548. * Updates the current Vector4 coordinates with the given floats.
  3549. * @param x float to set from
  3550. * @param y float to set from
  3551. * @param z float to set from
  3552. * @param w float to set from
  3553. * @returns the updated Vector4.
  3554. */
  3555. set(x: number, y: number, z: number, w: number): Vector4;
  3556. /**
  3557. * Copies the given float to the current Vector3 coordinates
  3558. * @param v defines the x, y, z and w coordinates of the operand
  3559. * @returns the current updated Vector3
  3560. */
  3561. setAll(v: number): Vector4;
  3562. /**
  3563. * Returns a new Vector4 set from the starting index of the given array.
  3564. * @param array the array to pull values from
  3565. * @param offset the offset into the array to start at
  3566. * @returns the new vector
  3567. */
  3568. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3569. /**
  3570. * Updates the given vector "result" from the starting index of the given array.
  3571. * @param array the array to pull values from
  3572. * @param offset the offset into the array to start at
  3573. * @param result the vector to store the result in
  3574. */
  3575. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3576. /**
  3577. * Updates the given vector "result" from the starting index of the given Float32Array.
  3578. * @param array the array to pull values from
  3579. * @param offset the offset into the array to start at
  3580. * @param result the vector to store the result in
  3581. */
  3582. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3583. /**
  3584. * Updates the given vector "result" coordinates from the given floats.
  3585. * @param x float to set from
  3586. * @param y float to set from
  3587. * @param z float to set from
  3588. * @param w float to set from
  3589. * @param result the vector to the floats in
  3590. */
  3591. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3592. /**
  3593. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3594. * @returns the new vector
  3595. */
  3596. static Zero(): Vector4;
  3597. /**
  3598. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3599. * @returns the new vector
  3600. */
  3601. static One(): Vector4;
  3602. /**
  3603. * Returns a new normalized Vector4 from the given one.
  3604. * @param vector the vector to normalize
  3605. * @returns the vector
  3606. */
  3607. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Updates the given vector "result" from the normalization of the given one.
  3610. * @param vector the vector to normalize
  3611. * @param result the vector to store the result in
  3612. */
  3613. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3614. /**
  3615. * Returns a vector with the minimum values from the left and right vectors
  3616. * @param left left vector to minimize
  3617. * @param right right vector to minimize
  3618. * @returns a new vector with the minimum of the left and right vector values
  3619. */
  3620. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3621. /**
  3622. * Returns a vector with the maximum values from the left and right vectors
  3623. * @param left left vector to maximize
  3624. * @param right right vector to maximize
  3625. * @returns a new vector with the maximum of the left and right vector values
  3626. */
  3627. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3628. /**
  3629. * Returns the distance (float) between the vectors "value1" and "value2".
  3630. * @param value1 value to calulate the distance between
  3631. * @param value2 value to calulate the distance between
  3632. * @return the distance between the two vectors
  3633. */
  3634. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3635. /**
  3636. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3637. * @param value1 value to calulate the distance between
  3638. * @param value2 value to calulate the distance between
  3639. * @return the distance between the two vectors squared
  3640. */
  3641. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3642. /**
  3643. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3644. * @param value1 value to calulate the center between
  3645. * @param value2 value to calulate the center between
  3646. * @return the center between the two vectors
  3647. */
  3648. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3649. /**
  3650. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3651. * This methods computes transformed normalized direction vectors only.
  3652. * @param vector the vector to transform
  3653. * @param transformation the transformation matrix to apply
  3654. * @returns the new vector
  3655. */
  3656. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3657. /**
  3658. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3659. * This methods computes transformed normalized direction vectors only.
  3660. * @param vector the vector to transform
  3661. * @param transformation the transformation matrix to apply
  3662. * @param result the vector to store the result in
  3663. */
  3664. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3665. /**
  3666. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3667. * This methods computes transformed normalized direction vectors only.
  3668. * @param x value to transform
  3669. * @param y value to transform
  3670. * @param z value to transform
  3671. * @param w value to transform
  3672. * @param transformation the transformation matrix to apply
  3673. * @param result the vector to store the results in
  3674. */
  3675. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3676. /**
  3677. * Creates a new Vector4 from a Vector3
  3678. * @param source defines the source data
  3679. * @param w defines the 4th component (default is 0)
  3680. * @returns a new Vector4
  3681. */
  3682. static FromVector3(source: Vector3, w?: number): Vector4;
  3683. }
  3684. /**
  3685. * Class used to store quaternion data
  3686. * @see https://en.wikipedia.org/wiki/Quaternion
  3687. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3688. */
  3689. export class Quaternion {
  3690. /** @hidden */
  3691. _x: number;
  3692. /** @hidden */
  3693. _y: number;
  3694. /** @hidden */
  3695. _z: number;
  3696. /** @hidden */
  3697. _w: number;
  3698. /** @hidden */
  3699. _isDirty: boolean;
  3700. /** Gets or sets the x coordinate */
  3701. get x(): number;
  3702. set x(value: number);
  3703. /** Gets or sets the y coordinate */
  3704. get y(): number;
  3705. set y(value: number);
  3706. /** Gets or sets the z coordinate */
  3707. get z(): number;
  3708. set z(value: number);
  3709. /** Gets or sets the w coordinate */
  3710. get w(): number;
  3711. set w(value: number);
  3712. /**
  3713. * Creates a new Quaternion from the given floats
  3714. * @param x defines the first component (0 by default)
  3715. * @param y defines the second component (0 by default)
  3716. * @param z defines the third component (0 by default)
  3717. * @param w defines the fourth component (1.0 by default)
  3718. */
  3719. constructor(x?: number, y?: number, z?: number, w?: number);
  3720. /**
  3721. * Gets a string representation for the current quaternion
  3722. * @returns a string with the Quaternion coordinates
  3723. */
  3724. toString(): string;
  3725. /**
  3726. * Gets the class name of the quaternion
  3727. * @returns the string "Quaternion"
  3728. */
  3729. getClassName(): string;
  3730. /**
  3731. * Gets a hash code for this quaternion
  3732. * @returns the quaternion hash code
  3733. */
  3734. getHashCode(): number;
  3735. /**
  3736. * Copy the quaternion to an array
  3737. * @returns a new array populated with 4 elements from the quaternion coordinates
  3738. */
  3739. asArray(): number[];
  3740. /**
  3741. * Check if two quaternions are equals
  3742. * @param otherQuaternion defines the second operand
  3743. * @return true if the current quaternion and the given one coordinates are strictly equals
  3744. */
  3745. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3746. /**
  3747. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3748. * @param otherQuaternion defines the other quaternion
  3749. * @param epsilon defines the minimal distance to consider equality
  3750. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3751. */
  3752. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3753. /**
  3754. * Clone the current quaternion
  3755. * @returns a new quaternion copied from the current one
  3756. */
  3757. clone(): Quaternion;
  3758. /**
  3759. * Copy a quaternion to the current one
  3760. * @param other defines the other quaternion
  3761. * @returns the updated current quaternion
  3762. */
  3763. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3764. /**
  3765. * Updates the current quaternion with the given float coordinates
  3766. * @param x defines the x coordinate
  3767. * @param y defines the y coordinate
  3768. * @param z defines the z coordinate
  3769. * @param w defines the w coordinate
  3770. * @returns the updated current quaternion
  3771. */
  3772. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3773. /**
  3774. * Updates the current quaternion from the given float coordinates
  3775. * @param x defines the x coordinate
  3776. * @param y defines the y coordinate
  3777. * @param z defines the z coordinate
  3778. * @param w defines the w coordinate
  3779. * @returns the updated current quaternion
  3780. */
  3781. set(x: number, y: number, z: number, w: number): Quaternion;
  3782. /**
  3783. * Adds two quaternions
  3784. * @param other defines the second operand
  3785. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3786. */
  3787. add(other: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Add a quaternion to the current one
  3790. * @param other defines the quaternion to add
  3791. * @returns the current quaternion
  3792. */
  3793. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3794. /**
  3795. * Subtract two quaternions
  3796. * @param other defines the second operand
  3797. * @returns a new quaternion as the subtraction result of the given one from the current one
  3798. */
  3799. subtract(other: Quaternion): Quaternion;
  3800. /**
  3801. * Multiplies the current quaternion by a scale factor
  3802. * @param value defines the scale factor
  3803. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3804. */
  3805. scale(value: number): Quaternion;
  3806. /**
  3807. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3808. * @param scale defines the scale factor
  3809. * @param result defines the Quaternion object where to store the result
  3810. * @returns the unmodified current quaternion
  3811. */
  3812. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3813. /**
  3814. * Multiplies in place the current quaternion by a scale factor
  3815. * @param value defines the scale factor
  3816. * @returns the current modified quaternion
  3817. */
  3818. scaleInPlace(value: number): Quaternion;
  3819. /**
  3820. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3821. * @param scale defines the scale factor
  3822. * @param result defines the Quaternion object where to store the result
  3823. * @returns the unmodified current quaternion
  3824. */
  3825. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3826. /**
  3827. * Multiplies two quaternions
  3828. * @param q1 defines the second operand
  3829. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3830. */
  3831. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3832. /**
  3833. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3834. * @param q1 defines the second operand
  3835. * @param result defines the target quaternion
  3836. * @returns the current quaternion
  3837. */
  3838. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3839. /**
  3840. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3841. * @param q1 defines the second operand
  3842. * @returns the currentupdated quaternion
  3843. */
  3844. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3845. /**
  3846. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3847. * @param ref defines the target quaternion
  3848. * @returns the current quaternion
  3849. */
  3850. conjugateToRef(ref: Quaternion): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns the current updated quaternion
  3854. */
  3855. conjugateInPlace(): Quaternion;
  3856. /**
  3857. * Conjugates in place (1-q) the current quaternion
  3858. * @returns a new quaternion
  3859. */
  3860. conjugate(): Quaternion;
  3861. /**
  3862. * Gets length of current quaternion
  3863. * @returns the quaternion length (float)
  3864. */
  3865. length(): number;
  3866. /**
  3867. * Normalize in place the current quaternion
  3868. * @returns the current updated quaternion
  3869. */
  3870. normalize(): Quaternion;
  3871. /**
  3872. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3873. * @param order is a reserved parameter and is ignored for now
  3874. * @returns a new Vector3 containing the Euler angles
  3875. */
  3876. toEulerAngles(order?: string): Vector3;
  3877. /**
  3878. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3879. * @param result defines the vector which will be filled with the Euler angles
  3880. * @returns the current unchanged quaternion
  3881. */
  3882. toEulerAnglesToRef(result: Vector3): Quaternion;
  3883. /**
  3884. * Updates the given rotation matrix with the current quaternion values
  3885. * @param result defines the target matrix
  3886. * @returns the current unchanged quaternion
  3887. */
  3888. toRotationMatrix(result: Matrix): Quaternion;
  3889. /**
  3890. * Updates the current quaternion from the given rotation matrix values
  3891. * @param matrix defines the source matrix
  3892. * @returns the current updated quaternion
  3893. */
  3894. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3895. /**
  3896. * Creates a new quaternion from a rotation matrix
  3897. * @param matrix defines the source matrix
  3898. * @returns a new quaternion created from the given rotation matrix values
  3899. */
  3900. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3901. /**
  3902. * Updates the given quaternion with the given rotation matrix values
  3903. * @param matrix defines the source matrix
  3904. * @param result defines the target quaternion
  3905. */
  3906. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3907. /**
  3908. * Returns the dot product (float) between the quaternions "left" and "right"
  3909. * @param left defines the left operand
  3910. * @param right defines the right operand
  3911. * @returns the dot product
  3912. */
  3913. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3914. /**
  3915. * Checks if the two quaternions are close to each other
  3916. * @param quat0 defines the first quaternion to check
  3917. * @param quat1 defines the second quaternion to check
  3918. * @returns true if the two quaternions are close to each other
  3919. */
  3920. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3921. /**
  3922. * Creates an empty quaternion
  3923. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3924. */
  3925. static Zero(): Quaternion;
  3926. /**
  3927. * Inverse a given quaternion
  3928. * @param q defines the source quaternion
  3929. * @returns a new quaternion as the inverted current quaternion
  3930. */
  3931. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3932. /**
  3933. * Inverse a given quaternion
  3934. * @param q defines the source quaternion
  3935. * @param result the quaternion the result will be stored in
  3936. * @returns the result quaternion
  3937. */
  3938. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3939. /**
  3940. * Creates an identity quaternion
  3941. * @returns the identity quaternion
  3942. */
  3943. static Identity(): Quaternion;
  3944. /**
  3945. * Gets a boolean indicating if the given quaternion is identity
  3946. * @param quaternion defines the quaternion to check
  3947. * @returns true if the quaternion is identity
  3948. */
  3949. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3950. /**
  3951. * Creates a quaternion from a rotation around an axis
  3952. * @param axis defines the axis to use
  3953. * @param angle defines the angle to use
  3954. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3955. */
  3956. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3957. /**
  3958. * Creates a rotation around an axis and stores it into the given quaternion
  3959. * @param axis defines the axis to use
  3960. * @param angle defines the angle to use
  3961. * @param result defines the target quaternion
  3962. * @returns the target quaternion
  3963. */
  3964. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3965. /**
  3966. * Creates a new quaternion from data stored into an array
  3967. * @param array defines the data source
  3968. * @param offset defines the offset in the source array where the data starts
  3969. * @returns a new quaternion
  3970. */
  3971. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3972. /**
  3973. * Updates the given quaternion "result" from the starting index of the given array.
  3974. * @param array the array to pull values from
  3975. * @param offset the offset into the array to start at
  3976. * @param result the quaternion to store the result in
  3977. */
  3978. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3979. /**
  3980. * Create a quaternion from Euler rotation angles
  3981. * @param x Pitch
  3982. * @param y Yaw
  3983. * @param z Roll
  3984. * @returns the new Quaternion
  3985. */
  3986. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3987. /**
  3988. * Updates a quaternion from Euler rotation angles
  3989. * @param x Pitch
  3990. * @param y Yaw
  3991. * @param z Roll
  3992. * @param result the quaternion to store the result
  3993. * @returns the updated quaternion
  3994. */
  3995. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3996. /**
  3997. * Create a quaternion from Euler rotation vector
  3998. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3999. * @returns the new Quaternion
  4000. */
  4001. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4002. /**
  4003. * Updates a quaternion from Euler rotation vector
  4004. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4005. * @param result the quaternion to store the result
  4006. * @returns the updated quaternion
  4007. */
  4008. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4009. /**
  4010. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4011. * @param yaw defines the rotation around Y axis
  4012. * @param pitch defines the rotation around X axis
  4013. * @param roll defines the rotation around Z axis
  4014. * @returns the new quaternion
  4015. */
  4016. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4017. /**
  4018. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4019. * @param yaw defines the rotation around Y axis
  4020. * @param pitch defines the rotation around X axis
  4021. * @param roll defines the rotation around Z axis
  4022. * @param result defines the target quaternion
  4023. */
  4024. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4025. /**
  4026. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4027. * @param alpha defines the rotation around first axis
  4028. * @param beta defines the rotation around second axis
  4029. * @param gamma defines the rotation around third axis
  4030. * @returns the new quaternion
  4031. */
  4032. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4033. /**
  4034. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4035. * @param alpha defines the rotation around first axis
  4036. * @param beta defines the rotation around second axis
  4037. * @param gamma defines the rotation around third axis
  4038. * @param result defines the target quaternion
  4039. */
  4040. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4041. /**
  4042. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4043. * @param axis1 defines the first axis
  4044. * @param axis2 defines the second axis
  4045. * @param axis3 defines the third axis
  4046. * @returns the new quaternion
  4047. */
  4048. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4049. /**
  4050. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4051. * @param axis1 defines the first axis
  4052. * @param axis2 defines the second axis
  4053. * @param axis3 defines the third axis
  4054. * @param ref defines the target quaternion
  4055. */
  4056. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4057. /**
  4058. * Interpolates between two quaternions
  4059. * @param left defines first quaternion
  4060. * @param right defines second quaternion
  4061. * @param amount defines the gradient to use
  4062. * @returns the new interpolated quaternion
  4063. */
  4064. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4065. /**
  4066. * Interpolates between two quaternions and stores it into a target quaternion
  4067. * @param left defines first quaternion
  4068. * @param right defines second quaternion
  4069. * @param amount defines the gradient to use
  4070. * @param result defines the target quaternion
  4071. */
  4072. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4073. /**
  4074. * Interpolate between two quaternions using Hermite interpolation
  4075. * @param value1 defines first quaternion
  4076. * @param tangent1 defines the incoming tangent
  4077. * @param value2 defines second quaternion
  4078. * @param tangent2 defines the outgoing tangent
  4079. * @param amount defines the target quaternion
  4080. * @returns the new interpolated quaternion
  4081. */
  4082. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4083. }
  4084. /**
  4085. * Class used to store matrix data (4x4)
  4086. */
  4087. export class Matrix {
  4088. /**
  4089. * Gets the precision of matrix computations
  4090. */
  4091. static get Use64Bits(): boolean;
  4092. private static _updateFlagSeed;
  4093. private static _identityReadOnly;
  4094. private _isIdentity;
  4095. private _isIdentityDirty;
  4096. private _isIdentity3x2;
  4097. private _isIdentity3x2Dirty;
  4098. /**
  4099. * Gets the update flag of the matrix which is an unique number for the matrix.
  4100. * It will be incremented every time the matrix data change.
  4101. * You can use it to speed the comparison between two versions of the same matrix.
  4102. */
  4103. updateFlag: number;
  4104. private readonly _m;
  4105. /**
  4106. * Gets the internal data of the matrix
  4107. */
  4108. get m(): DeepImmutable<Float32Array | Array<number>>;
  4109. /** @hidden */
  4110. _markAsUpdated(): void;
  4111. /** @hidden */
  4112. private _updateIdentityStatus;
  4113. /**
  4114. * Creates an empty matrix (filled with zeros)
  4115. */
  4116. constructor();
  4117. /**
  4118. * Check if the current matrix is identity
  4119. * @returns true is the matrix is the identity matrix
  4120. */
  4121. isIdentity(): boolean;
  4122. /**
  4123. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4124. * @returns true is the matrix is the identity matrix
  4125. */
  4126. isIdentityAs3x2(): boolean;
  4127. /**
  4128. * Gets the determinant of the matrix
  4129. * @returns the matrix determinant
  4130. */
  4131. determinant(): number;
  4132. /**
  4133. * Returns the matrix as a Float32Array or Array<number>
  4134. * @returns the matrix underlying array
  4135. */
  4136. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4137. /**
  4138. * Returns the matrix as a Float32Array or Array<number>
  4139. * @returns the matrix underlying array.
  4140. */
  4141. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4142. /**
  4143. * Inverts the current matrix in place
  4144. * @returns the current inverted matrix
  4145. */
  4146. invert(): Matrix;
  4147. /**
  4148. * Sets all the matrix elements to zero
  4149. * @returns the current matrix
  4150. */
  4151. reset(): Matrix;
  4152. /**
  4153. * Adds the current matrix with a second one
  4154. * @param other defines the matrix to add
  4155. * @returns a new matrix as the addition of the current matrix and the given one
  4156. */
  4157. add(other: DeepImmutable<Matrix>): Matrix;
  4158. /**
  4159. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4160. * @param other defines the matrix to add
  4161. * @param result defines the target matrix
  4162. * @returns the current matrix
  4163. */
  4164. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4165. /**
  4166. * Adds in place the given matrix to the current matrix
  4167. * @param other defines the second operand
  4168. * @returns the current updated matrix
  4169. */
  4170. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4171. /**
  4172. * Sets the given matrix to the current inverted Matrix
  4173. * @param other defines the target matrix
  4174. * @returns the unmodified current matrix
  4175. */
  4176. invertToRef(other: Matrix): Matrix;
  4177. /**
  4178. * add a value at the specified position in the current Matrix
  4179. * @param index the index of the value within the matrix. between 0 and 15.
  4180. * @param value the value to be added
  4181. * @returns the current updated matrix
  4182. */
  4183. addAtIndex(index: number, value: number): Matrix;
  4184. /**
  4185. * mutiply the specified position in the current Matrix by a value
  4186. * @param index the index of the value within the matrix. between 0 and 15.
  4187. * @param value the value to be added
  4188. * @returns the current updated matrix
  4189. */
  4190. multiplyAtIndex(index: number, value: number): Matrix;
  4191. /**
  4192. * Inserts the translation vector (using 3 floats) in the current matrix
  4193. * @param x defines the 1st component of the translation
  4194. * @param y defines the 2nd component of the translation
  4195. * @param z defines the 3rd component of the translation
  4196. * @returns the current updated matrix
  4197. */
  4198. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4199. /**
  4200. * Adds the translation vector (using 3 floats) in the current matrix
  4201. * @param x defines the 1st component of the translation
  4202. * @param y defines the 2nd component of the translation
  4203. * @param z defines the 3rd component of the translation
  4204. * @returns the current updated matrix
  4205. */
  4206. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4207. /**
  4208. * Inserts the translation vector in the current matrix
  4209. * @param vector3 defines the translation to insert
  4210. * @returns the current updated matrix
  4211. */
  4212. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4213. /**
  4214. * Gets the translation value of the current matrix
  4215. * @returns a new Vector3 as the extracted translation from the matrix
  4216. */
  4217. getTranslation(): Vector3;
  4218. /**
  4219. * Fill a Vector3 with the extracted translation from the matrix
  4220. * @param result defines the Vector3 where to store the translation
  4221. * @returns the current matrix
  4222. */
  4223. getTranslationToRef(result: Vector3): Matrix;
  4224. /**
  4225. * Remove rotation and scaling part from the matrix
  4226. * @returns the updated matrix
  4227. */
  4228. removeRotationAndScaling(): Matrix;
  4229. /**
  4230. * Multiply two matrices
  4231. * @param other defines the second operand
  4232. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4233. */
  4234. multiply(other: DeepImmutable<Matrix>): Matrix;
  4235. /**
  4236. * Copy the current matrix from the given one
  4237. * @param other defines the source matrix
  4238. * @returns the current updated matrix
  4239. */
  4240. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4241. /**
  4242. * Populates the given array from the starting index with the current matrix values
  4243. * @param array defines the target array
  4244. * @param offset defines the offset in the target array where to start storing values
  4245. * @returns the current matrix
  4246. */
  4247. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4248. /**
  4249. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4250. * @param other defines the second operand
  4251. * @param result defines the matrix where to store the multiplication
  4252. * @returns the current matrix
  4253. */
  4254. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4255. /**
  4256. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4257. * @param other defines the second operand
  4258. * @param result defines the array where to store the multiplication
  4259. * @param offset defines the offset in the target array where to start storing values
  4260. * @returns the current matrix
  4261. */
  4262. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4263. /**
  4264. * Check equality between this matrix and a second one
  4265. * @param value defines the second matrix to compare
  4266. * @returns true is the current matrix and the given one values are strictly equal
  4267. */
  4268. equals(value: DeepImmutable<Matrix>): boolean;
  4269. /**
  4270. * Clone the current matrix
  4271. * @returns a new matrix from the current matrix
  4272. */
  4273. clone(): Matrix;
  4274. /**
  4275. * Returns the name of the current matrix class
  4276. * @returns the string "Matrix"
  4277. */
  4278. getClassName(): string;
  4279. /**
  4280. * Gets the hash code of the current matrix
  4281. * @returns the hash code
  4282. */
  4283. getHashCode(): number;
  4284. /**
  4285. * Decomposes the current Matrix into a translation, rotation and scaling components
  4286. * @param scale defines the scale vector3 given as a reference to update
  4287. * @param rotation defines the rotation quaternion given as a reference to update
  4288. * @param translation defines the translation vector3 given as a reference to update
  4289. * @returns true if operation was successful
  4290. */
  4291. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4292. /**
  4293. * Gets specific row of the matrix
  4294. * @param index defines the number of the row to get
  4295. * @returns the index-th row of the current matrix as a new Vector4
  4296. */
  4297. getRow(index: number): Nullable<Vector4>;
  4298. /**
  4299. * Sets the index-th row of the current matrix to the vector4 values
  4300. * @param index defines the number of the row to set
  4301. * @param row defines the target vector4
  4302. * @returns the updated current matrix
  4303. */
  4304. setRow(index: number, row: Vector4): Matrix;
  4305. /**
  4306. * Compute the transpose of the matrix
  4307. * @returns the new transposed matrix
  4308. */
  4309. transpose(): Matrix;
  4310. /**
  4311. * Compute the transpose of the matrix and store it in a given matrix
  4312. * @param result defines the target matrix
  4313. * @returns the current matrix
  4314. */
  4315. transposeToRef(result: Matrix): Matrix;
  4316. /**
  4317. * Sets the index-th row of the current matrix with the given 4 x float values
  4318. * @param index defines the row index
  4319. * @param x defines the x component to set
  4320. * @param y defines the y component to set
  4321. * @param z defines the z component to set
  4322. * @param w defines the w component to set
  4323. * @returns the updated current matrix
  4324. */
  4325. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4326. /**
  4327. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4328. * @param scale defines the scale factor
  4329. * @returns a new matrix
  4330. */
  4331. scale(scale: number): Matrix;
  4332. /**
  4333. * Scale the current matrix values by a factor to a given result matrix
  4334. * @param scale defines the scale factor
  4335. * @param result defines the matrix to store the result
  4336. * @returns the current matrix
  4337. */
  4338. scaleToRef(scale: number, result: Matrix): Matrix;
  4339. /**
  4340. * Scale the current matrix values by a factor and add the result to a given matrix
  4341. * @param scale defines the scale factor
  4342. * @param result defines the Matrix to store the result
  4343. * @returns the current matrix
  4344. */
  4345. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4346. /**
  4347. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4348. * @param ref matrix to store the result
  4349. */
  4350. toNormalMatrix(ref: Matrix): void;
  4351. /**
  4352. * Gets only rotation part of the current matrix
  4353. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4354. */
  4355. getRotationMatrix(): Matrix;
  4356. /**
  4357. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4358. * @param result defines the target matrix to store data to
  4359. * @returns the current matrix
  4360. */
  4361. getRotationMatrixToRef(result: Matrix): Matrix;
  4362. /**
  4363. * Toggles model matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleModelMatrixHandInPlace(): void;
  4366. /**
  4367. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4368. */
  4369. toggleProjectionMatrixHandInPlace(): void;
  4370. /**
  4371. * Creates a matrix from an array
  4372. * @param array defines the source array
  4373. * @param offset defines an offset in the source array
  4374. * @returns a new Matrix set from the starting index of the given array
  4375. */
  4376. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4377. /**
  4378. * Copy the content of an array into a given matrix
  4379. * @param array defines the source array
  4380. * @param offset defines an offset in the source array
  4381. * @param result defines the target matrix
  4382. */
  4383. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4384. /**
  4385. * Stores an array into a matrix after having multiplied each component by a given factor
  4386. * @param array defines the source array
  4387. * @param offset defines the offset in the source array
  4388. * @param scale defines the scaling factor
  4389. * @param result defines the target matrix
  4390. */
  4391. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4392. /**
  4393. * Gets an identity matrix that must not be updated
  4394. */
  4395. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4396. /**
  4397. * Stores a list of values (16) inside a given matrix
  4398. * @param initialM11 defines 1st value of 1st row
  4399. * @param initialM12 defines 2nd value of 1st row
  4400. * @param initialM13 defines 3rd value of 1st row
  4401. * @param initialM14 defines 4th value of 1st row
  4402. * @param initialM21 defines 1st value of 2nd row
  4403. * @param initialM22 defines 2nd value of 2nd row
  4404. * @param initialM23 defines 3rd value of 2nd row
  4405. * @param initialM24 defines 4th value of 2nd row
  4406. * @param initialM31 defines 1st value of 3rd row
  4407. * @param initialM32 defines 2nd value of 3rd row
  4408. * @param initialM33 defines 3rd value of 3rd row
  4409. * @param initialM34 defines 4th value of 3rd row
  4410. * @param initialM41 defines 1st value of 4th row
  4411. * @param initialM42 defines 2nd value of 4th row
  4412. * @param initialM43 defines 3rd value of 4th row
  4413. * @param initialM44 defines 4th value of 4th row
  4414. * @param result defines the target matrix
  4415. */
  4416. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4417. /**
  4418. * Creates new matrix from a list of values (16)
  4419. * @param initialM11 defines 1st value of 1st row
  4420. * @param initialM12 defines 2nd value of 1st row
  4421. * @param initialM13 defines 3rd value of 1st row
  4422. * @param initialM14 defines 4th value of 1st row
  4423. * @param initialM21 defines 1st value of 2nd row
  4424. * @param initialM22 defines 2nd value of 2nd row
  4425. * @param initialM23 defines 3rd value of 2nd row
  4426. * @param initialM24 defines 4th value of 2nd row
  4427. * @param initialM31 defines 1st value of 3rd row
  4428. * @param initialM32 defines 2nd value of 3rd row
  4429. * @param initialM33 defines 3rd value of 3rd row
  4430. * @param initialM34 defines 4th value of 3rd row
  4431. * @param initialM41 defines 1st value of 4th row
  4432. * @param initialM42 defines 2nd value of 4th row
  4433. * @param initialM43 defines 3rd value of 4th row
  4434. * @param initialM44 defines 4th value of 4th row
  4435. * @returns the new matrix
  4436. */
  4437. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4438. /**
  4439. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4440. * @param scale defines the scale vector3
  4441. * @param rotation defines the rotation quaternion
  4442. * @param translation defines the translation vector3
  4443. * @returns a new matrix
  4444. */
  4445. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4446. /**
  4447. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4448. * @param scale defines the scale vector3
  4449. * @param rotation defines the rotation quaternion
  4450. * @param translation defines the translation vector3
  4451. * @param result defines the target matrix
  4452. */
  4453. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4454. /**
  4455. * Creates a new identity matrix
  4456. * @returns a new identity matrix
  4457. */
  4458. static Identity(): Matrix;
  4459. /**
  4460. * Creates a new identity matrix and stores the result in a given matrix
  4461. * @param result defines the target matrix
  4462. */
  4463. static IdentityToRef(result: Matrix): void;
  4464. /**
  4465. * Creates a new zero matrix
  4466. * @returns a new zero matrix
  4467. */
  4468. static Zero(): Matrix;
  4469. /**
  4470. * Creates a new rotation matrix for "angle" radians around the X axis
  4471. * @param angle defines the angle (in radians) to use
  4472. * @return the new matrix
  4473. */
  4474. static RotationX(angle: number): Matrix;
  4475. /**
  4476. * Creates a new matrix as the invert of a given matrix
  4477. * @param source defines the source matrix
  4478. * @returns the new matrix
  4479. */
  4480. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4481. /**
  4482. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4483. * @param angle defines the angle (in radians) to use
  4484. * @param result defines the target matrix
  4485. */
  4486. static RotationXToRef(angle: number, result: Matrix): void;
  4487. /**
  4488. * Creates a new rotation matrix for "angle" radians around the Y axis
  4489. * @param angle defines the angle (in radians) to use
  4490. * @return the new matrix
  4491. */
  4492. static RotationY(angle: number): Matrix;
  4493. /**
  4494. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4495. * @param angle defines the angle (in radians) to use
  4496. * @param result defines the target matrix
  4497. */
  4498. static RotationYToRef(angle: number, result: Matrix): void;
  4499. /**
  4500. * Creates a new rotation matrix for "angle" radians around the Z axis
  4501. * @param angle defines the angle (in radians) to use
  4502. * @return the new matrix
  4503. */
  4504. static RotationZ(angle: number): Matrix;
  4505. /**
  4506. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4507. * @param angle defines the angle (in radians) to use
  4508. * @param result defines the target matrix
  4509. */
  4510. static RotationZToRef(angle: number, result: Matrix): void;
  4511. /**
  4512. * Creates a new rotation matrix for "angle" radians around the given axis
  4513. * @param axis defines the axis to use
  4514. * @param angle defines the angle (in radians) to use
  4515. * @return the new matrix
  4516. */
  4517. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4518. /**
  4519. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4520. * @param axis defines the axis to use
  4521. * @param angle defines the angle (in radians) to use
  4522. * @param result defines the target matrix
  4523. */
  4524. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4525. /**
  4526. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4527. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4528. * @param from defines the vector to align
  4529. * @param to defines the vector to align to
  4530. * @param result defines the target matrix
  4531. */
  4532. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4533. /**
  4534. * Creates a rotation matrix
  4535. * @param yaw defines the yaw angle in radians (Y axis)
  4536. * @param pitch defines the pitch angle in radians (X axis)
  4537. * @param roll defines the roll angle in radians (Z axis)
  4538. * @returns the new rotation matrix
  4539. */
  4540. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4541. /**
  4542. * Creates a rotation matrix and stores it in a given matrix
  4543. * @param yaw defines the yaw angle in radians (Y axis)
  4544. * @param pitch defines the pitch angle in radians (X axis)
  4545. * @param roll defines the roll angle in radians (Z axis)
  4546. * @param result defines the target matrix
  4547. */
  4548. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4549. /**
  4550. * Creates a scaling matrix
  4551. * @param x defines the scale factor on X axis
  4552. * @param y defines the scale factor on Y axis
  4553. * @param z defines the scale factor on Z axis
  4554. * @returns the new matrix
  4555. */
  4556. static Scaling(x: number, y: number, z: number): Matrix;
  4557. /**
  4558. * Creates a scaling matrix and stores it in a given matrix
  4559. * @param x defines the scale factor on X axis
  4560. * @param y defines the scale factor on Y axis
  4561. * @param z defines the scale factor on Z axis
  4562. * @param result defines the target matrix
  4563. */
  4564. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4565. /**
  4566. * Creates a translation matrix
  4567. * @param x defines the translation on X axis
  4568. * @param y defines the translation on Y axis
  4569. * @param z defines the translationon Z axis
  4570. * @returns the new matrix
  4571. */
  4572. static Translation(x: number, y: number, z: number): Matrix;
  4573. /**
  4574. * Creates a translation matrix and stores it in a given matrix
  4575. * @param x defines the translation on X axis
  4576. * @param y defines the translation on Y axis
  4577. * @param z defines the translationon Z axis
  4578. * @param result defines the target matrix
  4579. */
  4580. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4581. /**
  4582. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4583. * @param startValue defines the start value
  4584. * @param endValue defines the end value
  4585. * @param gradient defines the gradient factor
  4586. * @returns the new matrix
  4587. */
  4588. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4589. /**
  4590. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4591. * @param startValue defines the start value
  4592. * @param endValue defines the end value
  4593. * @param gradient defines the gradient factor
  4594. * @param result defines the Matrix object where to store data
  4595. */
  4596. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4597. /**
  4598. * Builds a new matrix whose values are computed by:
  4599. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4600. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4601. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4602. * @param startValue defines the first matrix
  4603. * @param endValue defines the second matrix
  4604. * @param gradient defines the gradient between the two matrices
  4605. * @returns the new matrix
  4606. */
  4607. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4608. /**
  4609. * Update a matrix to values which are computed by:
  4610. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4611. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4612. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4613. * @param startValue defines the first matrix
  4614. * @param endValue defines the second matrix
  4615. * @param gradient defines the gradient between the two matrices
  4616. * @param result defines the target matrix
  4617. */
  4618. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4619. /**
  4620. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4621. * This function works in left handed mode
  4622. * @param eye defines the final position of the entity
  4623. * @param target defines where the entity should look at
  4624. * @param up defines the up vector for the entity
  4625. * @returns the new matrix
  4626. */
  4627. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4628. /**
  4629. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4630. * This function works in left handed mode
  4631. * @param eye defines the final position of the entity
  4632. * @param target defines where the entity should look at
  4633. * @param up defines the up vector for the entity
  4634. * @param result defines the target matrix
  4635. */
  4636. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4637. /**
  4638. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4639. * This function works in right handed mode
  4640. * @param eye defines the final position of the entity
  4641. * @param target defines where the entity should look at
  4642. * @param up defines the up vector for the entity
  4643. * @returns the new matrix
  4644. */
  4645. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4646. /**
  4647. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4648. * This function works in right handed mode
  4649. * @param eye defines the final position of the entity
  4650. * @param target defines where the entity should look at
  4651. * @param up defines the up vector for the entity
  4652. * @param result defines the target matrix
  4653. */
  4654. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4655. /**
  4656. * Create a left-handed orthographic projection matrix
  4657. * @param width defines the viewport width
  4658. * @param height defines the viewport height
  4659. * @param znear defines the near clip plane
  4660. * @param zfar defines the far clip plane
  4661. * @returns a new matrix as a left-handed orthographic projection matrix
  4662. */
  4663. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4664. /**
  4665. * Store a left-handed orthographic projection to a given matrix
  4666. * @param width defines the viewport width
  4667. * @param height defines the viewport height
  4668. * @param znear defines the near clip plane
  4669. * @param zfar defines the far clip plane
  4670. * @param result defines the target matrix
  4671. */
  4672. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4673. /**
  4674. * Create a left-handed orthographic projection matrix
  4675. * @param left defines the viewport left coordinate
  4676. * @param right defines the viewport right coordinate
  4677. * @param bottom defines the viewport bottom coordinate
  4678. * @param top defines the viewport top coordinate
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @returns a new matrix as a left-handed orthographic projection matrix
  4682. */
  4683. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4684. /**
  4685. * Stores a left-handed orthographic projection into a given matrix
  4686. * @param left defines the viewport left coordinate
  4687. * @param right defines the viewport right coordinate
  4688. * @param bottom defines the viewport bottom coordinate
  4689. * @param top defines the viewport top coordinate
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @param result defines the target matrix
  4693. */
  4694. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4695. /**
  4696. * Creates a right-handed orthographic projection matrix
  4697. * @param left defines the viewport left coordinate
  4698. * @param right defines the viewport right coordinate
  4699. * @param bottom defines the viewport bottom coordinate
  4700. * @param top defines the viewport top coordinate
  4701. * @param znear defines the near clip plane
  4702. * @param zfar defines the far clip plane
  4703. * @returns a new matrix as a right-handed orthographic projection matrix
  4704. */
  4705. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4706. /**
  4707. * Stores a right-handed orthographic projection into a given matrix
  4708. * @param left defines the viewport left coordinate
  4709. * @param right defines the viewport right coordinate
  4710. * @param bottom defines the viewport bottom coordinate
  4711. * @param top defines the viewport top coordinate
  4712. * @param znear defines the near clip plane
  4713. * @param zfar defines the far clip plane
  4714. * @param result defines the target matrix
  4715. */
  4716. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4717. /**
  4718. * Creates a left-handed perspective projection matrix
  4719. * @param width defines the viewport width
  4720. * @param height defines the viewport height
  4721. * @param znear defines the near clip plane
  4722. * @param zfar defines the far clip plane
  4723. * @returns a new matrix as a left-handed perspective projection matrix
  4724. */
  4725. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4726. /**
  4727. * Creates a left-handed perspective projection matrix
  4728. * @param fov defines the horizontal field of view
  4729. * @param aspect defines the aspect ratio
  4730. * @param znear defines the near clip plane
  4731. * @param zfar defines the far clip plane
  4732. * @returns a new matrix as a left-handed perspective projection matrix
  4733. */
  4734. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4735. /**
  4736. * Stores a left-handed perspective projection into a given matrix
  4737. * @param fov defines the horizontal field of view
  4738. * @param aspect defines the aspect ratio
  4739. * @param znear defines the near clip plane
  4740. * @param zfar defines the far clip plane
  4741. * @param result defines the target matrix
  4742. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4743. */
  4744. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4745. /**
  4746. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4747. * @param fov defines the horizontal field of view
  4748. * @param aspect defines the aspect ratio
  4749. * @param znear defines the near clip plane
  4750. * @param zfar not used as infinity is used as far clip
  4751. * @param result defines the target matrix
  4752. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4753. */
  4754. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4755. /**
  4756. * Creates a right-handed perspective projection matrix
  4757. * @param fov defines the horizontal field of view
  4758. * @param aspect defines the aspect ratio
  4759. * @param znear defines the near clip plane
  4760. * @param zfar defines the far clip plane
  4761. * @returns a new matrix as a right-handed perspective projection matrix
  4762. */
  4763. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4764. /**
  4765. * Stores a right-handed perspective projection into a given matrix
  4766. * @param fov defines the horizontal field of view
  4767. * @param aspect defines the aspect ratio
  4768. * @param znear defines the near clip plane
  4769. * @param zfar defines the far clip plane
  4770. * @param result defines the target matrix
  4771. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4772. */
  4773. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4774. /**
  4775. * Stores a right-handed perspective projection into a given matrix
  4776. * @param fov defines the horizontal field of view
  4777. * @param aspect defines the aspect ratio
  4778. * @param znear defines the near clip plane
  4779. * @param zfar not used as infinity is used as far clip
  4780. * @param result defines the target matrix
  4781. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4782. */
  4783. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4784. /**
  4785. * Stores a perspective projection for WebVR info a given matrix
  4786. * @param fov defines the field of view
  4787. * @param znear defines the near clip plane
  4788. * @param zfar defines the far clip plane
  4789. * @param result defines the target matrix
  4790. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4791. */
  4792. static PerspectiveFovWebVRToRef(fov: {
  4793. upDegrees: number;
  4794. downDegrees: number;
  4795. leftDegrees: number;
  4796. rightDegrees: number;
  4797. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4798. /**
  4799. * Computes a complete transformation matrix
  4800. * @param viewport defines the viewport to use
  4801. * @param world defines the world matrix
  4802. * @param view defines the view matrix
  4803. * @param projection defines the projection matrix
  4804. * @param zmin defines the near clip plane
  4805. * @param zmax defines the far clip plane
  4806. * @returns the transformation matrix
  4807. */
  4808. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4809. /**
  4810. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4811. * @param matrix defines the matrix to use
  4812. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4813. */
  4814. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4815. /**
  4816. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4817. * @param matrix defines the matrix to use
  4818. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4819. */
  4820. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4821. /**
  4822. * Compute the transpose of a given matrix
  4823. * @param matrix defines the matrix to transpose
  4824. * @returns the new matrix
  4825. */
  4826. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4827. /**
  4828. * Compute the transpose of a matrix and store it in a target matrix
  4829. * @param matrix defines the matrix to transpose
  4830. * @param result defines the target matrix
  4831. */
  4832. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4833. /**
  4834. * Computes a reflection matrix from a plane
  4835. * @param plane defines the reflection plane
  4836. * @returns a new matrix
  4837. */
  4838. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4839. /**
  4840. * Computes a reflection matrix from a plane
  4841. * @param plane defines the reflection plane
  4842. * @param result defines the target matrix
  4843. */
  4844. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4845. /**
  4846. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4847. * @param xaxis defines the value of the 1st axis
  4848. * @param yaxis defines the value of the 2nd axis
  4849. * @param zaxis defines the value of the 3rd axis
  4850. * @param result defines the target matrix
  4851. */
  4852. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4853. /**
  4854. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4855. * @param quat defines the quaternion to use
  4856. * @param result defines the target matrix
  4857. */
  4858. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4859. }
  4860. /**
  4861. * @hidden
  4862. */
  4863. export class TmpVectors {
  4864. static Vector2: Vector2[];
  4865. static Vector3: Vector3[];
  4866. static Vector4: Vector4[];
  4867. static Quaternion: Quaternion[];
  4868. static Matrix: Matrix[];
  4869. }
  4870. }
  4871. declare module BABYLON {
  4872. /**
  4873. * Defines potential orientation for back face culling
  4874. */
  4875. export enum Orientation {
  4876. /**
  4877. * Clockwise
  4878. */
  4879. CW = 0,
  4880. /** Counter clockwise */
  4881. CCW = 1
  4882. }
  4883. /** Class used to represent a Bezier curve */
  4884. export class BezierCurve {
  4885. /**
  4886. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4887. * @param t defines the time
  4888. * @param x1 defines the left coordinate on X axis
  4889. * @param y1 defines the left coordinate on Y axis
  4890. * @param x2 defines the right coordinate on X axis
  4891. * @param y2 defines the right coordinate on Y axis
  4892. * @returns the interpolated value
  4893. */
  4894. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4895. }
  4896. /**
  4897. * Defines angle representation
  4898. */
  4899. export class Angle {
  4900. private _radians;
  4901. /**
  4902. * Creates an Angle object of "radians" radians (float).
  4903. * @param radians the angle in radians
  4904. */
  4905. constructor(radians: number);
  4906. /**
  4907. * Get value in degrees
  4908. * @returns the Angle value in degrees (float)
  4909. */
  4910. degrees(): number;
  4911. /**
  4912. * Get value in radians
  4913. * @returns the Angle value in radians (float)
  4914. */
  4915. radians(): number;
  4916. /**
  4917. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4918. * @param a defines first point as the origin
  4919. * @param b defines point
  4920. * @returns a new Angle
  4921. */
  4922. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4923. /**
  4924. * Gets a new Angle object from the given float in radians
  4925. * @param radians defines the angle value in radians
  4926. * @returns a new Angle
  4927. */
  4928. static FromRadians(radians: number): Angle;
  4929. /**
  4930. * Gets a new Angle object from the given float in degrees
  4931. * @param degrees defines the angle value in degrees
  4932. * @returns a new Angle
  4933. */
  4934. static FromDegrees(degrees: number): Angle;
  4935. }
  4936. /**
  4937. * This represents an arc in a 2d space.
  4938. */
  4939. export class Arc2 {
  4940. /** Defines the start point of the arc */
  4941. startPoint: Vector2;
  4942. /** Defines the mid point of the arc */
  4943. midPoint: Vector2;
  4944. /** Defines the end point of the arc */
  4945. endPoint: Vector2;
  4946. /**
  4947. * Defines the center point of the arc.
  4948. */
  4949. centerPoint: Vector2;
  4950. /**
  4951. * Defines the radius of the arc.
  4952. */
  4953. radius: number;
  4954. /**
  4955. * Defines the angle of the arc (from mid point to end point).
  4956. */
  4957. angle: Angle;
  4958. /**
  4959. * Defines the start angle of the arc (from start point to middle point).
  4960. */
  4961. startAngle: Angle;
  4962. /**
  4963. * Defines the orientation of the arc (clock wise/counter clock wise).
  4964. */
  4965. orientation: Orientation;
  4966. /**
  4967. * Creates an Arc object from the three given points : start, middle and end.
  4968. * @param startPoint Defines the start point of the arc
  4969. * @param midPoint Defines the midlle point of the arc
  4970. * @param endPoint Defines the end point of the arc
  4971. */
  4972. constructor(
  4973. /** Defines the start point of the arc */
  4974. startPoint: Vector2,
  4975. /** Defines the mid point of the arc */
  4976. midPoint: Vector2,
  4977. /** Defines the end point of the arc */
  4978. endPoint: Vector2);
  4979. }
  4980. /**
  4981. * Represents a 2D path made up of multiple 2D points
  4982. */
  4983. export class Path2 {
  4984. private _points;
  4985. private _length;
  4986. /**
  4987. * If the path start and end point are the same
  4988. */
  4989. closed: boolean;
  4990. /**
  4991. * Creates a Path2 object from the starting 2D coordinates x and y.
  4992. * @param x the starting points x value
  4993. * @param y the starting points y value
  4994. */
  4995. constructor(x: number, y: number);
  4996. /**
  4997. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4998. * @param x the added points x value
  4999. * @param y the added points y value
  5000. * @returns the updated Path2.
  5001. */
  5002. addLineTo(x: number, y: number): Path2;
  5003. /**
  5004. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5005. * @param midX middle point x value
  5006. * @param midY middle point y value
  5007. * @param endX end point x value
  5008. * @param endY end point y value
  5009. * @param numberOfSegments (default: 36)
  5010. * @returns the updated Path2.
  5011. */
  5012. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5013. /**
  5014. * Closes the Path2.
  5015. * @returns the Path2.
  5016. */
  5017. close(): Path2;
  5018. /**
  5019. * Gets the sum of the distance between each sequential point in the path
  5020. * @returns the Path2 total length (float).
  5021. */
  5022. length(): number;
  5023. /**
  5024. * Gets the points which construct the path
  5025. * @returns the Path2 internal array of points.
  5026. */
  5027. getPoints(): Vector2[];
  5028. /**
  5029. * Retreives the point at the distance aways from the starting point
  5030. * @param normalizedLengthPosition the length along the path to retreive the point from
  5031. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5032. */
  5033. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5034. /**
  5035. * Creates a new path starting from an x and y position
  5036. * @param x starting x value
  5037. * @param y starting y value
  5038. * @returns a new Path2 starting at the coordinates (x, y).
  5039. */
  5040. static StartingAt(x: number, y: number): Path2;
  5041. }
  5042. /**
  5043. * Represents a 3D path made up of multiple 3D points
  5044. */
  5045. export class Path3D {
  5046. /**
  5047. * an array of Vector3, the curve axis of the Path3D
  5048. */
  5049. path: Vector3[];
  5050. private _curve;
  5051. private _distances;
  5052. private _tangents;
  5053. private _normals;
  5054. private _binormals;
  5055. private _raw;
  5056. private _alignTangentsWithPath;
  5057. private readonly _pointAtData;
  5058. /**
  5059. * new Path3D(path, normal, raw)
  5060. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5061. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5062. * @param path an array of Vector3, the curve axis of the Path3D
  5063. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5064. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5065. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5066. */
  5067. constructor(
  5068. /**
  5069. * an array of Vector3, the curve axis of the Path3D
  5070. */
  5071. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5072. /**
  5073. * Returns the Path3D array of successive Vector3 designing its curve.
  5074. * @returns the Path3D array of successive Vector3 designing its curve.
  5075. */
  5076. getCurve(): Vector3[];
  5077. /**
  5078. * Returns the Path3D array of successive Vector3 designing its curve.
  5079. * @returns the Path3D array of successive Vector3 designing its curve.
  5080. */
  5081. getPoints(): Vector3[];
  5082. /**
  5083. * @returns the computed length (float) of the path.
  5084. */
  5085. length(): number;
  5086. /**
  5087. * Returns an array populated with tangent vectors on each Path3D curve point.
  5088. * @returns an array populated with tangent vectors on each Path3D curve point.
  5089. */
  5090. getTangents(): Vector3[];
  5091. /**
  5092. * Returns an array populated with normal vectors on each Path3D curve point.
  5093. * @returns an array populated with normal vectors on each Path3D curve point.
  5094. */
  5095. getNormals(): Vector3[];
  5096. /**
  5097. * Returns an array populated with binormal vectors on each Path3D curve point.
  5098. * @returns an array populated with binormal vectors on each Path3D curve point.
  5099. */
  5100. getBinormals(): Vector3[];
  5101. /**
  5102. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5103. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5104. */
  5105. getDistances(): number[];
  5106. /**
  5107. * Returns an interpolated point along this path
  5108. * @param position the position of the point along this path, from 0.0 to 1.0
  5109. * @returns a new Vector3 as the point
  5110. */
  5111. getPointAt(position: number): Vector3;
  5112. /**
  5113. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5114. * @param position the position of the point along this path, from 0.0 to 1.0
  5115. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5116. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5117. */
  5118. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5119. /**
  5120. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5121. * @param position the position of the point along this path, from 0.0 to 1.0
  5122. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5123. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5124. */
  5125. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5126. /**
  5127. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5128. * @param position the position of the point along this path, from 0.0 to 1.0
  5129. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5130. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5131. */
  5132. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5133. /**
  5134. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5135. * @param position the position of the point along this path, from 0.0 to 1.0
  5136. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5137. */
  5138. getDistanceAt(position: number): number;
  5139. /**
  5140. * Returns the array index of the previous point of an interpolated point along this path
  5141. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5142. * @returns the array index
  5143. */
  5144. getPreviousPointIndexAt(position: number): number;
  5145. /**
  5146. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5147. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5148. * @returns the sub position
  5149. */
  5150. getSubPositionAt(position: number): number;
  5151. /**
  5152. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5153. * @param target the vector of which to get the closest position to
  5154. * @returns the position of the closest virtual point on this path to the target vector
  5155. */
  5156. getClosestPositionTo(target: Vector3): number;
  5157. /**
  5158. * Returns a sub path (slice) of this path
  5159. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5160. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5161. * @returns a sub path (slice) of this path
  5162. */
  5163. slice(start?: number, end?: number): Path3D;
  5164. /**
  5165. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5166. * @param path path which all values are copied into the curves points
  5167. * @param firstNormal which should be projected onto the curve
  5168. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5169. * @returns the same object updated.
  5170. */
  5171. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5172. private _compute;
  5173. private _getFirstNonNullVector;
  5174. private _getLastNonNullVector;
  5175. private _normalVector;
  5176. /**
  5177. * Updates the point at data for an interpolated point along this curve
  5178. * @param position the position of the point along this curve, from 0.0 to 1.0
  5179. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5180. * @returns the (updated) point at data
  5181. */
  5182. private _updatePointAtData;
  5183. /**
  5184. * Updates the point at data from the specified parameters
  5185. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5186. * @param point the interpolated point
  5187. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5188. */
  5189. private _setPointAtData;
  5190. /**
  5191. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5192. */
  5193. private _updateInterpolationMatrix;
  5194. }
  5195. /**
  5196. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5197. * A Curve3 is designed from a series of successive Vector3.
  5198. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5199. */
  5200. export class Curve3 {
  5201. private _points;
  5202. private _length;
  5203. /**
  5204. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5205. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5206. * @param v1 (Vector3) the control point
  5207. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5208. * @param nbPoints (integer) the wanted number of points in the curve
  5209. * @returns the created Curve3
  5210. */
  5211. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5212. /**
  5213. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5214. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5215. * @param v1 (Vector3) the first control point
  5216. * @param v2 (Vector3) the second control point
  5217. * @param v3 (Vector3) the end point of the Cubic Bezier
  5218. * @param nbPoints (integer) the wanted number of points in the curve
  5219. * @returns the created Curve3
  5220. */
  5221. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5222. /**
  5223. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5224. * @param p1 (Vector3) the origin point of the Hermite Spline
  5225. * @param t1 (Vector3) the tangent vector at the origin point
  5226. * @param p2 (Vector3) the end point of the Hermite Spline
  5227. * @param t2 (Vector3) the tangent vector at the end point
  5228. * @param nbPoints (integer) the wanted number of points in the curve
  5229. * @returns the created Curve3
  5230. */
  5231. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5232. /**
  5233. * Returns a Curve3 object along a CatmullRom Spline curve :
  5234. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5235. * @param nbPoints (integer) the wanted number of points between each curve control points
  5236. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5237. * @returns the created Curve3
  5238. */
  5239. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5240. /**
  5241. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5242. * A Curve3 is designed from a series of successive Vector3.
  5243. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5244. * @param points points which make up the curve
  5245. */
  5246. constructor(points: Vector3[]);
  5247. /**
  5248. * @returns the Curve3 stored array of successive Vector3
  5249. */
  5250. getPoints(): Vector3[];
  5251. /**
  5252. * @returns the computed length (float) of the curve.
  5253. */
  5254. length(): number;
  5255. /**
  5256. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5257. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5258. * curveA and curveB keep unchanged.
  5259. * @param curve the curve to continue from this curve
  5260. * @returns the newly constructed curve
  5261. */
  5262. continue(curve: DeepImmutable<Curve3>): Curve3;
  5263. private _computeLength;
  5264. }
  5265. }
  5266. declare module BABYLON {
  5267. /**
  5268. * This represents the main contract an easing function should follow.
  5269. * Easing functions are used throughout the animation system.
  5270. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5271. */
  5272. export interface IEasingFunction {
  5273. /**
  5274. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5275. * of the easing function.
  5276. * The link below provides some of the most common examples of easing functions.
  5277. * @see https://easings.net/
  5278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5279. * @returns the corresponding value on the curve defined by the easing function
  5280. */
  5281. ease(gradient: number): number;
  5282. }
  5283. /**
  5284. * Base class used for every default easing function.
  5285. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5286. */
  5287. export class EasingFunction implements IEasingFunction {
  5288. /**
  5289. * Interpolation follows the mathematical formula associated with the easing function.
  5290. */
  5291. static readonly EASINGMODE_EASEIN: number;
  5292. /**
  5293. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5294. */
  5295. static readonly EASINGMODE_EASEOUT: number;
  5296. /**
  5297. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5298. */
  5299. static readonly EASINGMODE_EASEINOUT: number;
  5300. private _easingMode;
  5301. /**
  5302. * Sets the easing mode of the current function.
  5303. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5304. */
  5305. setEasingMode(easingMode: number): void;
  5306. /**
  5307. * Gets the current easing mode.
  5308. * @returns the easing mode
  5309. */
  5310. getEasingMode(): number;
  5311. /**
  5312. * @hidden
  5313. */
  5314. easeInCore(gradient: number): number;
  5315. /**
  5316. * Given an input gradient between 0 and 1, this returns the corresponding value
  5317. * of the easing function.
  5318. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5319. * @returns the corresponding value on the curve defined by the easing function
  5320. */
  5321. ease(gradient: number): number;
  5322. }
  5323. /**
  5324. * Easing function with a circle shape (see link below).
  5325. * @see https://easings.net/#easeInCirc
  5326. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5327. */
  5328. export class CircleEase extends EasingFunction implements IEasingFunction {
  5329. /** @hidden */
  5330. easeInCore(gradient: number): number;
  5331. }
  5332. /**
  5333. * Easing function with a ease back shape (see link below).
  5334. * @see https://easings.net/#easeInBack
  5335. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5336. */
  5337. export class BackEase extends EasingFunction implements IEasingFunction {
  5338. /** Defines the amplitude of the function */
  5339. amplitude: number;
  5340. /**
  5341. * Instantiates a back ease easing
  5342. * @see https://easings.net/#easeInBack
  5343. * @param amplitude Defines the amplitude of the function
  5344. */
  5345. constructor(
  5346. /** Defines the amplitude of the function */
  5347. amplitude?: number);
  5348. /** @hidden */
  5349. easeInCore(gradient: number): number;
  5350. }
  5351. /**
  5352. * Easing function with a bouncing shape (see link below).
  5353. * @see https://easings.net/#easeInBounce
  5354. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5355. */
  5356. export class BounceEase extends EasingFunction implements IEasingFunction {
  5357. /** Defines the number of bounces */
  5358. bounces: number;
  5359. /** Defines the amplitude of the bounce */
  5360. bounciness: number;
  5361. /**
  5362. * Instantiates a bounce easing
  5363. * @see https://easings.net/#easeInBounce
  5364. * @param bounces Defines the number of bounces
  5365. * @param bounciness Defines the amplitude of the bounce
  5366. */
  5367. constructor(
  5368. /** Defines the number of bounces */
  5369. bounces?: number,
  5370. /** Defines the amplitude of the bounce */
  5371. bounciness?: number);
  5372. /** @hidden */
  5373. easeInCore(gradient: number): number;
  5374. }
  5375. /**
  5376. * Easing function with a power of 3 shape (see link below).
  5377. * @see https://easings.net/#easeInCubic
  5378. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5379. */
  5380. export class CubicEase extends EasingFunction implements IEasingFunction {
  5381. /** @hidden */
  5382. easeInCore(gradient: number): number;
  5383. }
  5384. /**
  5385. * Easing function with an elastic shape (see link below).
  5386. * @see https://easings.net/#easeInElastic
  5387. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5388. */
  5389. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5390. /** Defines the number of oscillations*/
  5391. oscillations: number;
  5392. /** Defines the amplitude of the oscillations*/
  5393. springiness: number;
  5394. /**
  5395. * Instantiates an elastic easing function
  5396. * @see https://easings.net/#easeInElastic
  5397. * @param oscillations Defines the number of oscillations
  5398. * @param springiness Defines the amplitude of the oscillations
  5399. */
  5400. constructor(
  5401. /** Defines the number of oscillations*/
  5402. oscillations?: number,
  5403. /** Defines the amplitude of the oscillations*/
  5404. springiness?: number);
  5405. /** @hidden */
  5406. easeInCore(gradient: number): number;
  5407. }
  5408. /**
  5409. * Easing function with an exponential shape (see link below).
  5410. * @see https://easings.net/#easeInExpo
  5411. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5412. */
  5413. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5414. /** Defines the exponent of the function */
  5415. exponent: number;
  5416. /**
  5417. * Instantiates an exponential easing function
  5418. * @see https://easings.net/#easeInExpo
  5419. * @param exponent Defines the exponent of the function
  5420. */
  5421. constructor(
  5422. /** Defines the exponent of the function */
  5423. exponent?: number);
  5424. /** @hidden */
  5425. easeInCore(gradient: number): number;
  5426. }
  5427. /**
  5428. * Easing function with a power shape (see link below).
  5429. * @see https://easings.net/#easeInQuad
  5430. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5431. */
  5432. export class PowerEase extends EasingFunction implements IEasingFunction {
  5433. /** Defines the power of the function */
  5434. power: number;
  5435. /**
  5436. * Instantiates an power base easing function
  5437. * @see https://easings.net/#easeInQuad
  5438. * @param power Defines the power of the function
  5439. */
  5440. constructor(
  5441. /** Defines the power of the function */
  5442. power?: number);
  5443. /** @hidden */
  5444. easeInCore(gradient: number): number;
  5445. }
  5446. /**
  5447. * Easing function with a power of 2 shape (see link below).
  5448. * @see https://easings.net/#easeInQuad
  5449. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5450. */
  5451. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5452. /** @hidden */
  5453. easeInCore(gradient: number): number;
  5454. }
  5455. /**
  5456. * Easing function with a power of 4 shape (see link below).
  5457. * @see https://easings.net/#easeInQuart
  5458. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5459. */
  5460. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5461. /** @hidden */
  5462. easeInCore(gradient: number): number;
  5463. }
  5464. /**
  5465. * Easing function with a power of 5 shape (see link below).
  5466. * @see https://easings.net/#easeInQuint
  5467. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5468. */
  5469. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5470. /** @hidden */
  5471. easeInCore(gradient: number): number;
  5472. }
  5473. /**
  5474. * Easing function with a sin shape (see link below).
  5475. * @see https://easings.net/#easeInSine
  5476. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5477. */
  5478. export class SineEase extends EasingFunction implements IEasingFunction {
  5479. /** @hidden */
  5480. easeInCore(gradient: number): number;
  5481. }
  5482. /**
  5483. * Easing function with a bezier shape (see link below).
  5484. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5485. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5486. */
  5487. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5488. /** Defines the x component of the start tangent in the bezier curve */
  5489. x1: number;
  5490. /** Defines the y component of the start tangent in the bezier curve */
  5491. y1: number;
  5492. /** Defines the x component of the end tangent in the bezier curve */
  5493. x2: number;
  5494. /** Defines the y component of the end tangent in the bezier curve */
  5495. y2: number;
  5496. /**
  5497. * Instantiates a bezier function
  5498. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5499. * @param x1 Defines the x component of the start tangent in the bezier curve
  5500. * @param y1 Defines the y component of the start tangent in the bezier curve
  5501. * @param x2 Defines the x component of the end tangent in the bezier curve
  5502. * @param y2 Defines the y component of the end tangent in the bezier curve
  5503. */
  5504. constructor(
  5505. /** Defines the x component of the start tangent in the bezier curve */
  5506. x1?: number,
  5507. /** Defines the y component of the start tangent in the bezier curve */
  5508. y1?: number,
  5509. /** Defines the x component of the end tangent in the bezier curve */
  5510. x2?: number,
  5511. /** Defines the y component of the end tangent in the bezier curve */
  5512. y2?: number);
  5513. /** @hidden */
  5514. easeInCore(gradient: number): number;
  5515. }
  5516. }
  5517. declare module BABYLON {
  5518. /**
  5519. * Class used to hold a RBG color
  5520. */
  5521. export class Color3 {
  5522. /**
  5523. * Defines the red component (between 0 and 1, default is 0)
  5524. */
  5525. r: number;
  5526. /**
  5527. * Defines the green component (between 0 and 1, default is 0)
  5528. */
  5529. g: number;
  5530. /**
  5531. * Defines the blue component (between 0 and 1, default is 0)
  5532. */
  5533. b: number;
  5534. /**
  5535. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5536. * @param r defines the red component (between 0 and 1, default is 0)
  5537. * @param g defines the green component (between 0 and 1, default is 0)
  5538. * @param b defines the blue component (between 0 and 1, default is 0)
  5539. */
  5540. constructor(
  5541. /**
  5542. * Defines the red component (between 0 and 1, default is 0)
  5543. */
  5544. r?: number,
  5545. /**
  5546. * Defines the green component (between 0 and 1, default is 0)
  5547. */
  5548. g?: number,
  5549. /**
  5550. * Defines the blue component (between 0 and 1, default is 0)
  5551. */
  5552. b?: number);
  5553. /**
  5554. * Creates a string with the Color3 current values
  5555. * @returns the string representation of the Color3 object
  5556. */
  5557. toString(): string;
  5558. /**
  5559. * Returns the string "Color3"
  5560. * @returns "Color3"
  5561. */
  5562. getClassName(): string;
  5563. /**
  5564. * Compute the Color3 hash code
  5565. * @returns an unique number that can be used to hash Color3 objects
  5566. */
  5567. getHashCode(): number;
  5568. /**
  5569. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5570. * @param array defines the array where to store the r,g,b components
  5571. * @param index defines an optional index in the target array to define where to start storing values
  5572. * @returns the current Color3 object
  5573. */
  5574. toArray(array: FloatArray, index?: number): Color3;
  5575. /**
  5576. * Update the current color with values stored in an array from the starting index of the given array
  5577. * @param array defines the source array
  5578. * @param offset defines an offset in the source array
  5579. * @returns the current Color3 object
  5580. */
  5581. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5582. /**
  5583. * Returns a new Color4 object from the current Color3 and the given alpha
  5584. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5585. * @returns a new Color4 object
  5586. */
  5587. toColor4(alpha?: number): Color4;
  5588. /**
  5589. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5590. * @returns the new array
  5591. */
  5592. asArray(): number[];
  5593. /**
  5594. * Returns the luminance value
  5595. * @returns a float value
  5596. */
  5597. toLuminance(): number;
  5598. /**
  5599. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5600. * @param otherColor defines the second operand
  5601. * @returns the new Color3 object
  5602. */
  5603. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5604. /**
  5605. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5606. * @param otherColor defines the second operand
  5607. * @param result defines the Color3 object where to store the result
  5608. * @returns the current Color3
  5609. */
  5610. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5611. /**
  5612. * Determines equality between Color3 objects
  5613. * @param otherColor defines the second operand
  5614. * @returns true if the rgb values are equal to the given ones
  5615. */
  5616. equals(otherColor: DeepImmutable<Color3>): boolean;
  5617. /**
  5618. * Determines equality between the current Color3 object and a set of r,b,g values
  5619. * @param r defines the red component to check
  5620. * @param g defines the green component to check
  5621. * @param b defines the blue component to check
  5622. * @returns true if the rgb values are equal to the given ones
  5623. */
  5624. equalsFloats(r: number, g: number, b: number): boolean;
  5625. /**
  5626. * Multiplies in place each rgb value by scale
  5627. * @param scale defines the scaling factor
  5628. * @returns the updated Color3
  5629. */
  5630. scale(scale: number): Color3;
  5631. /**
  5632. * Multiplies the rgb values by scale and stores the result into "result"
  5633. * @param scale defines the scaling factor
  5634. * @param result defines the Color3 object where to store the result
  5635. * @returns the unmodified current Color3
  5636. */
  5637. scaleToRef(scale: number, result: Color3): Color3;
  5638. /**
  5639. * Scale the current Color3 values by a factor and add the result to a given Color3
  5640. * @param scale defines the scale factor
  5641. * @param result defines color to store the result into
  5642. * @returns the unmodified current Color3
  5643. */
  5644. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5645. /**
  5646. * Clamps the rgb values by the min and max values and stores the result into "result"
  5647. * @param min defines minimum clamping value (default is 0)
  5648. * @param max defines maximum clamping value (default is 1)
  5649. * @param result defines color to store the result into
  5650. * @returns the original Color3
  5651. */
  5652. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5653. /**
  5654. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5655. * @param otherColor defines the second operand
  5656. * @returns the new Color3
  5657. */
  5658. add(otherColor: DeepImmutable<Color3>): Color3;
  5659. /**
  5660. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5661. * @param otherColor defines the second operand
  5662. * @param result defines Color3 object to store the result into
  5663. * @returns the unmodified current Color3
  5664. */
  5665. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5666. /**
  5667. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5668. * @param otherColor defines the second operand
  5669. * @returns the new Color3
  5670. */
  5671. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5672. /**
  5673. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5674. * @param otherColor defines the second operand
  5675. * @param result defines Color3 object to store the result into
  5676. * @returns the unmodified current Color3
  5677. */
  5678. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5679. /**
  5680. * Copy the current object
  5681. * @returns a new Color3 copied the current one
  5682. */
  5683. clone(): Color3;
  5684. /**
  5685. * Copies the rgb values from the source in the current Color3
  5686. * @param source defines the source Color3 object
  5687. * @returns the updated Color3 object
  5688. */
  5689. copyFrom(source: DeepImmutable<Color3>): Color3;
  5690. /**
  5691. * Updates the Color3 rgb values from the given floats
  5692. * @param r defines the red component to read from
  5693. * @param g defines the green component to read from
  5694. * @param b defines the blue component to read from
  5695. * @returns the current Color3 object
  5696. */
  5697. copyFromFloats(r: number, g: number, b: number): Color3;
  5698. /**
  5699. * Updates the Color3 rgb values from the given floats
  5700. * @param r defines the red component to read from
  5701. * @param g defines the green component to read from
  5702. * @param b defines the blue component to read from
  5703. * @returns the current Color3 object
  5704. */
  5705. set(r: number, g: number, b: number): Color3;
  5706. /**
  5707. * Compute the Color3 hexadecimal code as a string
  5708. * @returns a string containing the hexadecimal representation of the Color3 object
  5709. */
  5710. toHexString(): string;
  5711. /**
  5712. * Computes a new Color3 converted from the current one to linear space
  5713. * @returns a new Color3 object
  5714. */
  5715. toLinearSpace(): Color3;
  5716. /**
  5717. * Converts current color in rgb space to HSV values
  5718. * @returns a new color3 representing the HSV values
  5719. */
  5720. toHSV(): Color3;
  5721. /**
  5722. * Converts current color in rgb space to HSV values
  5723. * @param result defines the Color3 where to store the HSV values
  5724. */
  5725. toHSVToRef(result: Color3): void;
  5726. /**
  5727. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5728. * @param convertedColor defines the Color3 object where to store the linear space version
  5729. * @returns the unmodified Color3
  5730. */
  5731. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5732. /**
  5733. * Computes a new Color3 converted from the current one to gamma space
  5734. * @returns a new Color3 object
  5735. */
  5736. toGammaSpace(): Color3;
  5737. /**
  5738. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5739. * @param convertedColor defines the Color3 object where to store the gamma space version
  5740. * @returns the unmodified Color3
  5741. */
  5742. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5743. private static _BlackReadOnly;
  5744. /**
  5745. * Convert Hue, saturation and value to a Color3 (RGB)
  5746. * @param hue defines the hue
  5747. * @param saturation defines the saturation
  5748. * @param value defines the value
  5749. * @param result defines the Color3 where to store the RGB values
  5750. */
  5751. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5752. /**
  5753. * Creates a new Color3 from the string containing valid hexadecimal values
  5754. * @param hex defines a string containing valid hexadecimal values
  5755. * @returns a new Color3 object
  5756. */
  5757. static FromHexString(hex: string): Color3;
  5758. /**
  5759. * Creates a new Color3 from the starting index of the given array
  5760. * @param array defines the source array
  5761. * @param offset defines an offset in the source array
  5762. * @returns a new Color3 object
  5763. */
  5764. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5765. /**
  5766. * Creates a new Color3 from the starting index element of the given array
  5767. * @param array defines the source array to read from
  5768. * @param offset defines the offset in the source array
  5769. * @param result defines the target Color3 object
  5770. */
  5771. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5772. /**
  5773. * Creates a new Color3 from integer values (< 256)
  5774. * @param r defines the red component to read from (value between 0 and 255)
  5775. * @param g defines the green component to read from (value between 0 and 255)
  5776. * @param b defines the blue component to read from (value between 0 and 255)
  5777. * @returns a new Color3 object
  5778. */
  5779. static FromInts(r: number, g: number, b: number): Color3;
  5780. /**
  5781. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5782. * @param start defines the start Color3 value
  5783. * @param end defines the end Color3 value
  5784. * @param amount defines the gradient value between start and end
  5785. * @returns a new Color3 object
  5786. */
  5787. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5788. /**
  5789. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5790. * @param left defines the start value
  5791. * @param right defines the end value
  5792. * @param amount defines the gradient factor
  5793. * @param result defines the Color3 object where to store the result
  5794. */
  5795. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5796. /**
  5797. * Returns a Color3 value containing a red color
  5798. * @returns a new Color3 object
  5799. */
  5800. static Red(): Color3;
  5801. /**
  5802. * Returns a Color3 value containing a green color
  5803. * @returns a new Color3 object
  5804. */
  5805. static Green(): Color3;
  5806. /**
  5807. * Returns a Color3 value containing a blue color
  5808. * @returns a new Color3 object
  5809. */
  5810. static Blue(): Color3;
  5811. /**
  5812. * Returns a Color3 value containing a black color
  5813. * @returns a new Color3 object
  5814. */
  5815. static Black(): Color3;
  5816. /**
  5817. * Gets a Color3 value containing a black color that must not be updated
  5818. */
  5819. static get BlackReadOnly(): DeepImmutable<Color3>;
  5820. /**
  5821. * Returns a Color3 value containing a white color
  5822. * @returns a new Color3 object
  5823. */
  5824. static White(): Color3;
  5825. /**
  5826. * Returns a Color3 value containing a purple color
  5827. * @returns a new Color3 object
  5828. */
  5829. static Purple(): Color3;
  5830. /**
  5831. * Returns a Color3 value containing a magenta color
  5832. * @returns a new Color3 object
  5833. */
  5834. static Magenta(): Color3;
  5835. /**
  5836. * Returns a Color3 value containing a yellow color
  5837. * @returns a new Color3 object
  5838. */
  5839. static Yellow(): Color3;
  5840. /**
  5841. * Returns a Color3 value containing a gray color
  5842. * @returns a new Color3 object
  5843. */
  5844. static Gray(): Color3;
  5845. /**
  5846. * Returns a Color3 value containing a teal color
  5847. * @returns a new Color3 object
  5848. */
  5849. static Teal(): Color3;
  5850. /**
  5851. * Returns a Color3 value containing a random color
  5852. * @returns a new Color3 object
  5853. */
  5854. static Random(): Color3;
  5855. }
  5856. /**
  5857. * Class used to hold a RBGA color
  5858. */
  5859. export class Color4 {
  5860. /**
  5861. * Defines the red component (between 0 and 1, default is 0)
  5862. */
  5863. r: number;
  5864. /**
  5865. * Defines the green component (between 0 and 1, default is 0)
  5866. */
  5867. g: number;
  5868. /**
  5869. * Defines the blue component (between 0 and 1, default is 0)
  5870. */
  5871. b: number;
  5872. /**
  5873. * Defines the alpha component (between 0 and 1, default is 1)
  5874. */
  5875. a: number;
  5876. /**
  5877. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5878. * @param r defines the red component (between 0 and 1, default is 0)
  5879. * @param g defines the green component (between 0 and 1, default is 0)
  5880. * @param b defines the blue component (between 0 and 1, default is 0)
  5881. * @param a defines the alpha component (between 0 and 1, default is 1)
  5882. */
  5883. constructor(
  5884. /**
  5885. * Defines the red component (between 0 and 1, default is 0)
  5886. */
  5887. r?: number,
  5888. /**
  5889. * Defines the green component (between 0 and 1, default is 0)
  5890. */
  5891. g?: number,
  5892. /**
  5893. * Defines the blue component (between 0 and 1, default is 0)
  5894. */
  5895. b?: number,
  5896. /**
  5897. * Defines the alpha component (between 0 and 1, default is 1)
  5898. */
  5899. a?: number);
  5900. /**
  5901. * Adds in place the given Color4 values to the current Color4 object
  5902. * @param right defines the second operand
  5903. * @returns the current updated Color4 object
  5904. */
  5905. addInPlace(right: DeepImmutable<Color4>): Color4;
  5906. /**
  5907. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5908. * @returns the new array
  5909. */
  5910. asArray(): number[];
  5911. /**
  5912. * Stores from the starting index in the given array the Color4 successive values
  5913. * @param array defines the array where to store the r,g,b components
  5914. * @param index defines an optional index in the target array to define where to start storing values
  5915. * @returns the current Color4 object
  5916. */
  5917. toArray(array: number[], index?: number): Color4;
  5918. /**
  5919. * Update the current color with values stored in an array from the starting index of the given array
  5920. * @param array defines the source array
  5921. * @param offset defines an offset in the source array
  5922. * @returns the current Color4 object
  5923. */
  5924. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5925. /**
  5926. * Determines equality between Color4 objects
  5927. * @param otherColor defines the second operand
  5928. * @returns true if the rgba values are equal to the given ones
  5929. */
  5930. equals(otherColor: DeepImmutable<Color4>): boolean;
  5931. /**
  5932. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5933. * @param right defines the second operand
  5934. * @returns a new Color4 object
  5935. */
  5936. add(right: DeepImmutable<Color4>): Color4;
  5937. /**
  5938. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5939. * @param right defines the second operand
  5940. * @returns a new Color4 object
  5941. */
  5942. subtract(right: DeepImmutable<Color4>): Color4;
  5943. /**
  5944. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5945. * @param right defines the second operand
  5946. * @param result defines the Color4 object where to store the result
  5947. * @returns the current Color4 object
  5948. */
  5949. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5950. /**
  5951. * Creates a new Color4 with the current Color4 values multiplied by scale
  5952. * @param scale defines the scaling factor to apply
  5953. * @returns a new Color4 object
  5954. */
  5955. scale(scale: number): Color4;
  5956. /**
  5957. * Multiplies the current Color4 values by scale and stores the result in "result"
  5958. * @param scale defines the scaling factor to apply
  5959. * @param result defines the Color4 object where to store the result
  5960. * @returns the current unmodified Color4
  5961. */
  5962. scaleToRef(scale: number, result: Color4): Color4;
  5963. /**
  5964. * Scale the current Color4 values by a factor and add the result to a given Color4
  5965. * @param scale defines the scale factor
  5966. * @param result defines the Color4 object where to store the result
  5967. * @returns the unmodified current Color4
  5968. */
  5969. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5970. /**
  5971. * Clamps the rgb values by the min and max values and stores the result into "result"
  5972. * @param min defines minimum clamping value (default is 0)
  5973. * @param max defines maximum clamping value (default is 1)
  5974. * @param result defines color to store the result into.
  5975. * @returns the cuurent Color4
  5976. */
  5977. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5978. /**
  5979. * Multipy an Color4 value by another and return a new Color4 object
  5980. * @param color defines the Color4 value to multiply by
  5981. * @returns a new Color4 object
  5982. */
  5983. multiply(color: Color4): Color4;
  5984. /**
  5985. * Multipy a Color4 value by another and push the result in a reference value
  5986. * @param color defines the Color4 value to multiply by
  5987. * @param result defines the Color4 to fill the result in
  5988. * @returns the result Color4
  5989. */
  5990. multiplyToRef(color: Color4, result: Color4): Color4;
  5991. /**
  5992. * Creates a string with the Color4 current values
  5993. * @returns the string representation of the Color4 object
  5994. */
  5995. toString(): string;
  5996. /**
  5997. * Returns the string "Color4"
  5998. * @returns "Color4"
  5999. */
  6000. getClassName(): string;
  6001. /**
  6002. * Compute the Color4 hash code
  6003. * @returns an unique number that can be used to hash Color4 objects
  6004. */
  6005. getHashCode(): number;
  6006. /**
  6007. * Creates a new Color4 copied from the current one
  6008. * @returns a new Color4 object
  6009. */
  6010. clone(): Color4;
  6011. /**
  6012. * Copies the given Color4 values into the current one
  6013. * @param source defines the source Color4 object
  6014. * @returns the current updated Color4 object
  6015. */
  6016. copyFrom(source: Color4): Color4;
  6017. /**
  6018. * Copies the given float values into the current one
  6019. * @param r defines the red component to read from
  6020. * @param g defines the green component to read from
  6021. * @param b defines the blue component to read from
  6022. * @param a defines the alpha component to read from
  6023. * @returns the current updated Color4 object
  6024. */
  6025. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6026. /**
  6027. * Copies the given float values into the current one
  6028. * @param r defines the red component to read from
  6029. * @param g defines the green component to read from
  6030. * @param b defines the blue component to read from
  6031. * @param a defines the alpha component to read from
  6032. * @returns the current updated Color4 object
  6033. */
  6034. set(r: number, g: number, b: number, a: number): Color4;
  6035. /**
  6036. * Compute the Color4 hexadecimal code as a string
  6037. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6038. * @returns a string containing the hexadecimal representation of the Color4 object
  6039. */
  6040. toHexString(returnAsColor3?: boolean): string;
  6041. /**
  6042. * Computes a new Color4 converted from the current one to linear space
  6043. * @returns a new Color4 object
  6044. */
  6045. toLinearSpace(): Color4;
  6046. /**
  6047. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6048. * @param convertedColor defines the Color4 object where to store the linear space version
  6049. * @returns the unmodified Color4
  6050. */
  6051. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6052. /**
  6053. * Computes a new Color4 converted from the current one to gamma space
  6054. * @returns a new Color4 object
  6055. */
  6056. toGammaSpace(): Color4;
  6057. /**
  6058. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6059. * @param convertedColor defines the Color4 object where to store the gamma space version
  6060. * @returns the unmodified Color4
  6061. */
  6062. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6063. /**
  6064. * Creates a new Color4 from the string containing valid hexadecimal values
  6065. * @param hex defines a string containing valid hexadecimal values
  6066. * @returns a new Color4 object
  6067. */
  6068. static FromHexString(hex: string): Color4;
  6069. /**
  6070. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6071. * @param left defines the start value
  6072. * @param right defines the end value
  6073. * @param amount defines the gradient factor
  6074. * @returns a new Color4 object
  6075. */
  6076. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6077. /**
  6078. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6079. * @param left defines the start value
  6080. * @param right defines the end value
  6081. * @param amount defines the gradient factor
  6082. * @param result defines the Color4 object where to store data
  6083. */
  6084. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6085. /**
  6086. * Creates a new Color4 from a Color3 and an alpha value
  6087. * @param color3 defines the source Color3 to read from
  6088. * @param alpha defines the alpha component (1.0 by default)
  6089. * @returns a new Color4 object
  6090. */
  6091. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6092. /**
  6093. * Creates a new Color4 from the starting index element of the given array
  6094. * @param array defines the source array to read from
  6095. * @param offset defines the offset in the source array
  6096. * @returns a new Color4 object
  6097. */
  6098. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6099. /**
  6100. * Creates a new Color4 from the starting index element of the given array
  6101. * @param array defines the source array to read from
  6102. * @param offset defines the offset in the source array
  6103. * @param result defines the target Color4 object
  6104. */
  6105. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6106. /**
  6107. * Creates a new Color3 from integer values (< 256)
  6108. * @param r defines the red component to read from (value between 0 and 255)
  6109. * @param g defines the green component to read from (value between 0 and 255)
  6110. * @param b defines the blue component to read from (value between 0 and 255)
  6111. * @param a defines the alpha component to read from (value between 0 and 255)
  6112. * @returns a new Color3 object
  6113. */
  6114. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6115. /**
  6116. * Check the content of a given array and convert it to an array containing RGBA data
  6117. * If the original array was already containing count * 4 values then it is returned directly
  6118. * @param colors defines the array to check
  6119. * @param count defines the number of RGBA data to expect
  6120. * @returns an array containing count * 4 values (RGBA)
  6121. */
  6122. static CheckColors4(colors: number[], count: number): number[];
  6123. }
  6124. /**
  6125. * @hidden
  6126. */
  6127. export class TmpColors {
  6128. static Color3: Color3[];
  6129. static Color4: Color4[];
  6130. }
  6131. }
  6132. declare module BABYLON {
  6133. /**
  6134. * Defines an interface which represents an animation key frame
  6135. */
  6136. export interface IAnimationKey {
  6137. /**
  6138. * Frame of the key frame
  6139. */
  6140. frame: number;
  6141. /**
  6142. * Value at the specifies key frame
  6143. */
  6144. value: any;
  6145. /**
  6146. * The input tangent for the cubic hermite spline
  6147. */
  6148. inTangent?: any;
  6149. /**
  6150. * The output tangent for the cubic hermite spline
  6151. */
  6152. outTangent?: any;
  6153. /**
  6154. * The animation interpolation type
  6155. */
  6156. interpolation?: AnimationKeyInterpolation;
  6157. }
  6158. /**
  6159. * Enum for the animation key frame interpolation type
  6160. */
  6161. export enum AnimationKeyInterpolation {
  6162. /**
  6163. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6164. */
  6165. STEP = 1
  6166. }
  6167. }
  6168. declare module BABYLON {
  6169. /**
  6170. * Represents the range of an animation
  6171. */
  6172. export class AnimationRange {
  6173. /**The name of the animation range**/
  6174. name: string;
  6175. /**The starting frame of the animation */
  6176. from: number;
  6177. /**The ending frame of the animation*/
  6178. to: number;
  6179. /**
  6180. * Initializes the range of an animation
  6181. * @param name The name of the animation range
  6182. * @param from The starting frame of the animation
  6183. * @param to The ending frame of the animation
  6184. */
  6185. constructor(
  6186. /**The name of the animation range**/
  6187. name: string,
  6188. /**The starting frame of the animation */
  6189. from: number,
  6190. /**The ending frame of the animation*/
  6191. to: number);
  6192. /**
  6193. * Makes a copy of the animation range
  6194. * @returns A copy of the animation range
  6195. */
  6196. clone(): AnimationRange;
  6197. }
  6198. }
  6199. declare module BABYLON {
  6200. /**
  6201. * Composed of a frame, and an action function
  6202. */
  6203. export class AnimationEvent {
  6204. /** The frame for which the event is triggered **/
  6205. frame: number;
  6206. /** The event to perform when triggered **/
  6207. action: (currentFrame: number) => void;
  6208. /** Specifies if the event should be triggered only once**/
  6209. onlyOnce?: boolean | undefined;
  6210. /**
  6211. * Specifies if the animation event is done
  6212. */
  6213. isDone: boolean;
  6214. /**
  6215. * Initializes the animation event
  6216. * @param frame The frame for which the event is triggered
  6217. * @param action The event to perform when triggered
  6218. * @param onlyOnce Specifies if the event should be triggered only once
  6219. */
  6220. constructor(
  6221. /** The frame for which the event is triggered **/
  6222. frame: number,
  6223. /** The event to perform when triggered **/
  6224. action: (currentFrame: number) => void,
  6225. /** Specifies if the event should be triggered only once**/
  6226. onlyOnce?: boolean | undefined);
  6227. /** @hidden */
  6228. _clone(): AnimationEvent;
  6229. }
  6230. }
  6231. declare module BABYLON {
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module BABYLON {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module BABYLON {
  6383. /**
  6384. * @ignore
  6385. * This is a list of all the different input types that are available in the application.
  6386. * Fo instance: ArcRotateCameraGamepadInput...
  6387. */
  6388. export var CameraInputTypes: {};
  6389. /**
  6390. * This is the contract to implement in order to create a new input class.
  6391. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6392. */
  6393. export interface ICameraInput<TCamera extends Camera> {
  6394. /**
  6395. * Defines the camera the input is attached to.
  6396. */
  6397. camera: Nullable<TCamera>;
  6398. /**
  6399. * Gets the class name of the current intput.
  6400. * @returns the class name
  6401. */
  6402. getClassName(): string;
  6403. /**
  6404. * Get the friendly name associated with the input class.
  6405. * @returns the input friendly name
  6406. */
  6407. getSimpleName(): string;
  6408. /**
  6409. * Attach the input controls to a specific dom element to get the input from.
  6410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6411. */
  6412. attachControl(noPreventDefault?: boolean): void;
  6413. /**
  6414. * Detach the current controls from the specified dom element.
  6415. */
  6416. detachControl(): void;
  6417. /**
  6418. * Update the current camera state depending on the inputs that have been used this frame.
  6419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6420. */
  6421. checkInputs?: () => void;
  6422. }
  6423. /**
  6424. * Represents a map of input types to input instance or input index to input instance.
  6425. */
  6426. export interface CameraInputsMap<TCamera extends Camera> {
  6427. /**
  6428. * Accessor to the input by input type.
  6429. */
  6430. [name: string]: ICameraInput<TCamera>;
  6431. /**
  6432. * Accessor to the input by input index.
  6433. */
  6434. [idx: number]: ICameraInput<TCamera>;
  6435. }
  6436. /**
  6437. * This represents the input manager used within a camera.
  6438. * It helps dealing with all the different kind of input attached to a camera.
  6439. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6440. */
  6441. export class CameraInputsManager<TCamera extends Camera> {
  6442. /**
  6443. * Defines the list of inputs attahed to the camera.
  6444. */
  6445. attached: CameraInputsMap<TCamera>;
  6446. /**
  6447. * Defines the dom element the camera is collecting inputs from.
  6448. * This is null if the controls have not been attached.
  6449. */
  6450. attachedToElement: boolean;
  6451. /**
  6452. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6453. */
  6454. noPreventDefault: boolean;
  6455. /**
  6456. * Defined the camera the input manager belongs to.
  6457. */
  6458. camera: TCamera;
  6459. /**
  6460. * Update the current camera state depending on the inputs that have been used this frame.
  6461. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6462. */
  6463. checkInputs: () => void;
  6464. /**
  6465. * Instantiate a new Camera Input Manager.
  6466. * @param camera Defines the camera the input manager blongs to
  6467. */
  6468. constructor(camera: TCamera);
  6469. /**
  6470. * Add an input method to a camera
  6471. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6472. * @param input camera input method
  6473. */
  6474. add(input: ICameraInput<TCamera>): void;
  6475. /**
  6476. * Remove a specific input method from a camera
  6477. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6478. * @param inputToRemove camera input method
  6479. */
  6480. remove(inputToRemove: ICameraInput<TCamera>): void;
  6481. /**
  6482. * Remove a specific input type from a camera
  6483. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6484. * @param inputType the type of the input to remove
  6485. */
  6486. removeByType(inputType: string): void;
  6487. private _addCheckInputs;
  6488. /**
  6489. * Attach the input controls to the currently attached dom element to listen the events from.
  6490. * @param input Defines the input to attach
  6491. */
  6492. attachInput(input: ICameraInput<TCamera>): void;
  6493. /**
  6494. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6495. * @param element Defines the dom element to collect the events from
  6496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6497. */
  6498. attachElement(noPreventDefault?: boolean): void;
  6499. /**
  6500. * Detach the current manager inputs controls from a specific dom element.
  6501. * @param element Defines the dom element to collect the events from
  6502. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6503. */
  6504. detachElement(disconnect?: boolean): void;
  6505. /**
  6506. * Rebuild the dynamic inputCheck function from the current list of
  6507. * defined inputs in the manager.
  6508. */
  6509. rebuildInputCheck(): void;
  6510. /**
  6511. * Remove all attached input methods from a camera
  6512. */
  6513. clear(): void;
  6514. /**
  6515. * Serialize the current input manager attached to a camera.
  6516. * This ensures than once parsed,
  6517. * the input associated to the camera will be identical to the current ones
  6518. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6519. */
  6520. serialize(serializedCamera: any): void;
  6521. /**
  6522. * Parses an input manager serialized JSON to restore the previous list of inputs
  6523. * and states associated to a camera.
  6524. * @param parsedCamera Defines the JSON to parse
  6525. */
  6526. parse(parsedCamera: any): void;
  6527. }
  6528. }
  6529. declare module BABYLON {
  6530. /**
  6531. * Class used to store data that will be store in GPU memory
  6532. */
  6533. export class Buffer {
  6534. private _engine;
  6535. private _buffer;
  6536. /** @hidden */
  6537. _data: Nullable<DataArray>;
  6538. private _updatable;
  6539. private _instanced;
  6540. private _divisor;
  6541. /**
  6542. * Gets the byte stride.
  6543. */
  6544. readonly byteStride: number;
  6545. /**
  6546. * Constructor
  6547. * @param engine the engine
  6548. * @param data the data to use for this buffer
  6549. * @param updatable whether the data is updatable
  6550. * @param stride the stride (optional)
  6551. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6552. * @param instanced whether the buffer is instanced (optional)
  6553. * @param useBytes set to true if the stride in in bytes (optional)
  6554. * @param divisor sets an optional divisor for instances (1 by default)
  6555. */
  6556. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6557. /**
  6558. * Create a new VertexBuffer based on the current buffer
  6559. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6560. * @param offset defines offset in the buffer (0 by default)
  6561. * @param size defines the size in floats of attributes (position is 3 for instance)
  6562. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6563. * @param instanced defines if the vertex buffer contains indexed data
  6564. * @param useBytes defines if the offset and stride are in bytes *
  6565. * @param divisor sets an optional divisor for instances (1 by default)
  6566. * @returns the new vertex buffer
  6567. */
  6568. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6569. /**
  6570. * Gets a boolean indicating if the Buffer is updatable?
  6571. * @returns true if the buffer is updatable
  6572. */
  6573. isUpdatable(): boolean;
  6574. /**
  6575. * Gets current buffer's data
  6576. * @returns a DataArray or null
  6577. */
  6578. getData(): Nullable<DataArray>;
  6579. /**
  6580. * Gets underlying native buffer
  6581. * @returns underlying native buffer
  6582. */
  6583. getBuffer(): Nullable<DataBuffer>;
  6584. /**
  6585. * Gets the stride in float32 units (i.e. byte stride / 4).
  6586. * May not be an integer if the byte stride is not divisible by 4.
  6587. * @returns the stride in float32 units
  6588. * @deprecated Please use byteStride instead.
  6589. */
  6590. getStrideSize(): number;
  6591. /**
  6592. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6593. * @param data defines the data to store
  6594. */
  6595. create(data?: Nullable<DataArray>): void;
  6596. /** @hidden */
  6597. _rebuild(): void;
  6598. /**
  6599. * Update current buffer data
  6600. * @param data defines the data to store
  6601. */
  6602. update(data: DataArray): void;
  6603. /**
  6604. * Updates the data directly.
  6605. * @param data the new data
  6606. * @param offset the new offset
  6607. * @param vertexCount the vertex count (optional)
  6608. * @param useBytes set to true if the offset is in bytes
  6609. */
  6610. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6611. /**
  6612. * Release all resources
  6613. */
  6614. dispose(): void;
  6615. }
  6616. /**
  6617. * Specialized buffer used to store vertex data
  6618. */
  6619. export class VertexBuffer {
  6620. /** @hidden */
  6621. _buffer: Buffer;
  6622. private _kind;
  6623. private _size;
  6624. private _ownsBuffer;
  6625. private _instanced;
  6626. private _instanceDivisor;
  6627. /**
  6628. * The byte type.
  6629. */
  6630. static readonly BYTE: number;
  6631. /**
  6632. * The unsigned byte type.
  6633. */
  6634. static readonly UNSIGNED_BYTE: number;
  6635. /**
  6636. * The short type.
  6637. */
  6638. static readonly SHORT: number;
  6639. /**
  6640. * The unsigned short type.
  6641. */
  6642. static readonly UNSIGNED_SHORT: number;
  6643. /**
  6644. * The integer type.
  6645. */
  6646. static readonly INT: number;
  6647. /**
  6648. * The unsigned integer type.
  6649. */
  6650. static readonly UNSIGNED_INT: number;
  6651. /**
  6652. * The float type.
  6653. */
  6654. static readonly FLOAT: number;
  6655. /**
  6656. * Gets or sets the instance divisor when in instanced mode
  6657. */
  6658. get instanceDivisor(): number;
  6659. set instanceDivisor(value: number);
  6660. /**
  6661. * Gets the byte stride.
  6662. */
  6663. readonly byteStride: number;
  6664. /**
  6665. * Gets the byte offset.
  6666. */
  6667. readonly byteOffset: number;
  6668. /**
  6669. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6670. */
  6671. readonly normalized: boolean;
  6672. /**
  6673. * Gets the data type of each component in the array.
  6674. */
  6675. readonly type: number;
  6676. /**
  6677. * Constructor
  6678. * @param engine the engine
  6679. * @param data the data to use for this vertex buffer
  6680. * @param kind the vertex buffer kind
  6681. * @param updatable whether the data is updatable
  6682. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6683. * @param stride the stride (optional)
  6684. * @param instanced whether the buffer is instanced (optional)
  6685. * @param offset the offset of the data (optional)
  6686. * @param size the number of components (optional)
  6687. * @param type the type of the component (optional)
  6688. * @param normalized whether the data contains normalized data (optional)
  6689. * @param useBytes set to true if stride and offset are in bytes (optional)
  6690. * @param divisor defines the instance divisor to use (1 by default)
  6691. */
  6692. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6693. /** @hidden */
  6694. _rebuild(): void;
  6695. /**
  6696. * Returns the kind of the VertexBuffer (string)
  6697. * @returns a string
  6698. */
  6699. getKind(): string;
  6700. /**
  6701. * Gets a boolean indicating if the VertexBuffer is updatable?
  6702. * @returns true if the buffer is updatable
  6703. */
  6704. isUpdatable(): boolean;
  6705. /**
  6706. * Gets current buffer's data
  6707. * @returns a DataArray or null
  6708. */
  6709. getData(): Nullable<DataArray>;
  6710. /**
  6711. * Gets underlying native buffer
  6712. * @returns underlying native buffer
  6713. */
  6714. getBuffer(): Nullable<DataBuffer>;
  6715. /**
  6716. * Gets the stride in float32 units (i.e. byte stride / 4).
  6717. * May not be an integer if the byte stride is not divisible by 4.
  6718. * @returns the stride in float32 units
  6719. * @deprecated Please use byteStride instead.
  6720. */
  6721. getStrideSize(): number;
  6722. /**
  6723. * Returns the offset as a multiple of the type byte length.
  6724. * @returns the offset in bytes
  6725. * @deprecated Please use byteOffset instead.
  6726. */
  6727. getOffset(): number;
  6728. /**
  6729. * Returns the number of components per vertex attribute (integer)
  6730. * @returns the size in float
  6731. */
  6732. getSize(): number;
  6733. /**
  6734. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6735. * @returns true if this buffer is instanced
  6736. */
  6737. getIsInstanced(): boolean;
  6738. /**
  6739. * Returns the instancing divisor, zero for non-instanced (integer).
  6740. * @returns a number
  6741. */
  6742. getInstanceDivisor(): number;
  6743. /**
  6744. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6745. * @param data defines the data to store
  6746. */
  6747. create(data?: DataArray): void;
  6748. /**
  6749. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6750. * This function will create a new buffer if the current one is not updatable
  6751. * @param data defines the data to store
  6752. */
  6753. update(data: DataArray): void;
  6754. /**
  6755. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6756. * Returns the directly updated WebGLBuffer.
  6757. * @param data the new data
  6758. * @param offset the new offset
  6759. * @param useBytes set to true if the offset is in bytes
  6760. */
  6761. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6762. /**
  6763. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6764. */
  6765. dispose(): void;
  6766. /**
  6767. * Enumerates each value of this vertex buffer as numbers.
  6768. * @param count the number of values to enumerate
  6769. * @param callback the callback function called for each value
  6770. */
  6771. forEach(count: number, callback: (value: number, index: number) => void): void;
  6772. /**
  6773. * Positions
  6774. */
  6775. static readonly PositionKind: string;
  6776. /**
  6777. * Normals
  6778. */
  6779. static readonly NormalKind: string;
  6780. /**
  6781. * Tangents
  6782. */
  6783. static readonly TangentKind: string;
  6784. /**
  6785. * Texture coordinates
  6786. */
  6787. static readonly UVKind: string;
  6788. /**
  6789. * Texture coordinates 2
  6790. */
  6791. static readonly UV2Kind: string;
  6792. /**
  6793. * Texture coordinates 3
  6794. */
  6795. static readonly UV3Kind: string;
  6796. /**
  6797. * Texture coordinates 4
  6798. */
  6799. static readonly UV4Kind: string;
  6800. /**
  6801. * Texture coordinates 5
  6802. */
  6803. static readonly UV5Kind: string;
  6804. /**
  6805. * Texture coordinates 6
  6806. */
  6807. static readonly UV6Kind: string;
  6808. /**
  6809. * Colors
  6810. */
  6811. static readonly ColorKind: string;
  6812. /**
  6813. * Matrix indices (for bones)
  6814. */
  6815. static readonly MatricesIndicesKind: string;
  6816. /**
  6817. * Matrix weights (for bones)
  6818. */
  6819. static readonly MatricesWeightsKind: string;
  6820. /**
  6821. * Additional matrix indices (for bones)
  6822. */
  6823. static readonly MatricesIndicesExtraKind: string;
  6824. /**
  6825. * Additional matrix weights (for bones)
  6826. */
  6827. static readonly MatricesWeightsExtraKind: string;
  6828. /**
  6829. * Deduces the stride given a kind.
  6830. * @param kind The kind string to deduce
  6831. * @returns The deduced stride
  6832. */
  6833. static DeduceStride(kind: string): number;
  6834. /**
  6835. * Gets the byte length of the given type.
  6836. * @param type the type
  6837. * @returns the number of bytes
  6838. */
  6839. static GetTypeByteLength(type: number): number;
  6840. /**
  6841. * Enumerates each value of the given parameters as numbers.
  6842. * @param data the data to enumerate
  6843. * @param byteOffset the byte offset of the data
  6844. * @param byteStride the byte stride of the data
  6845. * @param componentCount the number of components per element
  6846. * @param componentType the type of the component
  6847. * @param count the number of values to enumerate
  6848. * @param normalized whether the data is normalized
  6849. * @param callback the callback function called for each value
  6850. */
  6851. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6852. private static _GetFloatValue;
  6853. }
  6854. }
  6855. declare module BABYLON {
  6856. /**
  6857. * The options Interface for creating a Capsule Mesh
  6858. */
  6859. export interface ICreateCapsuleOptions {
  6860. /** The Orientation of the capsule. Default : Vector3.Up() */
  6861. orientation?: Vector3;
  6862. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6863. subdivisions: number;
  6864. /** Number of cylindrical segments on the capsule. */
  6865. tessellation: number;
  6866. /** Height or Length of the capsule. */
  6867. height: number;
  6868. /** Radius of the capsule. */
  6869. radius: number;
  6870. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6871. capSubdivisions: number;
  6872. /** Overwrite for the top radius. */
  6873. radiusTop?: number;
  6874. /** Overwrite for the bottom radius. */
  6875. radiusBottom?: number;
  6876. /** Overwrite for the top capSubdivisions. */
  6877. topCapSubdivisions?: number;
  6878. /** Overwrite for the bottom capSubdivisions. */
  6879. bottomCapSubdivisions?: number;
  6880. }
  6881. /**
  6882. * Class containing static functions to help procedurally build meshes
  6883. */
  6884. export class CapsuleBuilder {
  6885. /**
  6886. * Creates a capsule or a pill mesh
  6887. * @param name defines the name of the mesh
  6888. * @param options The constructors options.
  6889. * @param scene The scene the mesh is scoped to.
  6890. * @returns Capsule Mesh
  6891. */
  6892. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6893. }
  6894. }
  6895. declare module BABYLON {
  6896. /**
  6897. * @hidden
  6898. */
  6899. export class IntersectionInfo {
  6900. bu: Nullable<number>;
  6901. bv: Nullable<number>;
  6902. distance: number;
  6903. faceId: number;
  6904. subMeshId: number;
  6905. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6906. }
  6907. }
  6908. declare module BABYLON {
  6909. /**
  6910. * Class used to store bounding sphere information
  6911. */
  6912. export class BoundingSphere {
  6913. /**
  6914. * Gets the center of the bounding sphere in local space
  6915. */
  6916. readonly center: Vector3;
  6917. /**
  6918. * Radius of the bounding sphere in local space
  6919. */
  6920. radius: number;
  6921. /**
  6922. * Gets the center of the bounding sphere in world space
  6923. */
  6924. readonly centerWorld: Vector3;
  6925. /**
  6926. * Radius of the bounding sphere in world space
  6927. */
  6928. radiusWorld: number;
  6929. /**
  6930. * Gets the minimum vector in local space
  6931. */
  6932. readonly minimum: Vector3;
  6933. /**
  6934. * Gets the maximum vector in local space
  6935. */
  6936. readonly maximum: Vector3;
  6937. private _worldMatrix;
  6938. private static readonly TmpVector3;
  6939. /**
  6940. * Creates a new bounding sphere
  6941. * @param min defines the minimum vector (in local space)
  6942. * @param max defines the maximum vector (in local space)
  6943. * @param worldMatrix defines the new world matrix
  6944. */
  6945. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6946. /**
  6947. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6948. * @param min defines the new minimum vector (in local space)
  6949. * @param max defines the new maximum vector (in local space)
  6950. * @param worldMatrix defines the new world matrix
  6951. */
  6952. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6953. /**
  6954. * Scale the current bounding sphere by applying a scale factor
  6955. * @param factor defines the scale factor to apply
  6956. * @returns the current bounding box
  6957. */
  6958. scale(factor: number): BoundingSphere;
  6959. /**
  6960. * Gets the world matrix of the bounding box
  6961. * @returns a matrix
  6962. */
  6963. getWorldMatrix(): DeepImmutable<Matrix>;
  6964. /** @hidden */
  6965. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6966. /**
  6967. * Tests if the bounding sphere is intersecting the frustum planes
  6968. * @param frustumPlanes defines the frustum planes to test
  6969. * @returns true if there is an intersection
  6970. */
  6971. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6972. /**
  6973. * Tests if the bounding sphere center is in between the frustum planes.
  6974. * Used for optimistic fast inclusion.
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @returns true if the sphere center is in between the frustum planes
  6977. */
  6978. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. /**
  6980. * Tests if a point is inside the bounding sphere
  6981. * @param point defines the point to test
  6982. * @returns true if the point is inside the bounding sphere
  6983. */
  6984. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6985. /**
  6986. * Checks if two sphere intersct
  6987. * @param sphere0 sphere 0
  6988. * @param sphere1 sphere 1
  6989. * @returns true if the speres intersect
  6990. */
  6991. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6992. }
  6993. }
  6994. declare module BABYLON {
  6995. /**
  6996. * Class used to store bounding box information
  6997. */
  6998. export class BoundingBox implements ICullable {
  6999. /**
  7000. * Gets the 8 vectors representing the bounding box in local space
  7001. */
  7002. readonly vectors: Vector3[];
  7003. /**
  7004. * Gets the center of the bounding box in local space
  7005. */
  7006. readonly center: Vector3;
  7007. /**
  7008. * Gets the center of the bounding box in world space
  7009. */
  7010. readonly centerWorld: Vector3;
  7011. /**
  7012. * Gets the extend size in local space
  7013. */
  7014. readonly extendSize: Vector3;
  7015. /**
  7016. * Gets the extend size in world space
  7017. */
  7018. readonly extendSizeWorld: Vector3;
  7019. /**
  7020. * Gets the OBB (object bounding box) directions
  7021. */
  7022. readonly directions: Vector3[];
  7023. /**
  7024. * Gets the 8 vectors representing the bounding box in world space
  7025. */
  7026. readonly vectorsWorld: Vector3[];
  7027. /**
  7028. * Gets the minimum vector in world space
  7029. */
  7030. readonly minimumWorld: Vector3;
  7031. /**
  7032. * Gets the maximum vector in world space
  7033. */
  7034. readonly maximumWorld: Vector3;
  7035. /**
  7036. * Gets the minimum vector in local space
  7037. */
  7038. readonly minimum: Vector3;
  7039. /**
  7040. * Gets the maximum vector in local space
  7041. */
  7042. readonly maximum: Vector3;
  7043. private _worldMatrix;
  7044. private static readonly TmpVector3;
  7045. /**
  7046. * @hidden
  7047. */
  7048. _tag: number;
  7049. /**
  7050. * Creates a new bounding box
  7051. * @param min defines the minimum vector (in local space)
  7052. * @param max defines the maximum vector (in local space)
  7053. * @param worldMatrix defines the new world matrix
  7054. */
  7055. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7056. /**
  7057. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7058. * @param min defines the new minimum vector (in local space)
  7059. * @param max defines the new maximum vector (in local space)
  7060. * @param worldMatrix defines the new world matrix
  7061. */
  7062. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7063. /**
  7064. * Scale the current bounding box by applying a scale factor
  7065. * @param factor defines the scale factor to apply
  7066. * @returns the current bounding box
  7067. */
  7068. scale(factor: number): BoundingBox;
  7069. /**
  7070. * Gets the world matrix of the bounding box
  7071. * @returns a matrix
  7072. */
  7073. getWorldMatrix(): DeepImmutable<Matrix>;
  7074. /** @hidden */
  7075. _update(world: DeepImmutable<Matrix>): void;
  7076. /**
  7077. * Tests if the bounding box is intersecting the frustum planes
  7078. * @param frustumPlanes defines the frustum planes to test
  7079. * @returns true if there is an intersection
  7080. */
  7081. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7082. /**
  7083. * Tests if the bounding box is entirely inside the frustum planes
  7084. * @param frustumPlanes defines the frustum planes to test
  7085. * @returns true if there is an inclusion
  7086. */
  7087. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7088. /**
  7089. * Tests if a point is inside the bounding box
  7090. * @param point defines the point to test
  7091. * @returns true if the point is inside the bounding box
  7092. */
  7093. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7094. /**
  7095. * Tests if the bounding box intersects with a bounding sphere
  7096. * @param sphere defines the sphere to test
  7097. * @returns true if there is an intersection
  7098. */
  7099. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7100. /**
  7101. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7102. * @param min defines the min vector to use
  7103. * @param max defines the max vector to use
  7104. * @returns true if there is an intersection
  7105. */
  7106. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7107. /**
  7108. * Tests if two bounding boxes are intersections
  7109. * @param box0 defines the first box to test
  7110. * @param box1 defines the second box to test
  7111. * @returns true if there is an intersection
  7112. */
  7113. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7114. /**
  7115. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7116. * @param minPoint defines the minimum vector of the bounding box
  7117. * @param maxPoint defines the maximum vector of the bounding box
  7118. * @param sphereCenter defines the sphere center
  7119. * @param sphereRadius defines the sphere radius
  7120. * @returns true if there is an intersection
  7121. */
  7122. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7123. /**
  7124. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7125. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7126. * @param frustumPlanes defines the frustum planes to test
  7127. * @return true if there is an inclusion
  7128. */
  7129. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7130. /**
  7131. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7132. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7133. * @param frustumPlanes defines the frustum planes to test
  7134. * @return true if there is an intersection
  7135. */
  7136. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. }
  7138. }
  7139. declare module BABYLON {
  7140. /** @hidden */
  7141. export class Collider {
  7142. /** Define if a collision was found */
  7143. collisionFound: boolean;
  7144. /**
  7145. * Define last intersection point in local space
  7146. */
  7147. intersectionPoint: Vector3;
  7148. /**
  7149. * Define last collided mesh
  7150. */
  7151. collidedMesh: Nullable<AbstractMesh>;
  7152. private _collisionPoint;
  7153. private _planeIntersectionPoint;
  7154. private _tempVector;
  7155. private _tempVector2;
  7156. private _tempVector3;
  7157. private _tempVector4;
  7158. private _edge;
  7159. private _baseToVertex;
  7160. private _destinationPoint;
  7161. private _slidePlaneNormal;
  7162. private _displacementVector;
  7163. /** @hidden */
  7164. _radius: Vector3;
  7165. /** @hidden */
  7166. _retry: number;
  7167. private _velocity;
  7168. private _basePoint;
  7169. private _epsilon;
  7170. /** @hidden */
  7171. _velocityWorldLength: number;
  7172. /** @hidden */
  7173. _basePointWorld: Vector3;
  7174. private _velocityWorld;
  7175. private _normalizedVelocity;
  7176. /** @hidden */
  7177. _initialVelocity: Vector3;
  7178. /** @hidden */
  7179. _initialPosition: Vector3;
  7180. private _nearestDistance;
  7181. private _collisionMask;
  7182. get collisionMask(): number;
  7183. set collisionMask(mask: number);
  7184. /**
  7185. * Gets the plane normal used to compute the sliding response (in local space)
  7186. */
  7187. get slidePlaneNormal(): Vector3;
  7188. /** @hidden */
  7189. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7190. /** @hidden */
  7191. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7192. /** @hidden */
  7193. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7194. /** @hidden */
  7195. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7196. /** @hidden */
  7197. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7198. /** @hidden */
  7199. _getResponse(pos: Vector3, vel: Vector3): void;
  7200. }
  7201. }
  7202. declare module BABYLON {
  7203. /**
  7204. * Interface for cullable objects
  7205. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7206. */
  7207. export interface ICullable {
  7208. /**
  7209. * Checks if the object or part of the object is in the frustum
  7210. * @param frustumPlanes Camera near/planes
  7211. * @returns true if the object is in frustum otherwise false
  7212. */
  7213. isInFrustum(frustumPlanes: Plane[]): boolean;
  7214. /**
  7215. * Checks if a cullable object (mesh...) is in the camera frustum
  7216. * Unlike isInFrustum this cheks the full bounding box
  7217. * @param frustumPlanes Camera near/planes
  7218. * @returns true if the object is in frustum otherwise false
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7221. }
  7222. /**
  7223. * Info for a bounding data of a mesh
  7224. */
  7225. export class BoundingInfo implements ICullable {
  7226. /**
  7227. * Bounding box for the mesh
  7228. */
  7229. readonly boundingBox: BoundingBox;
  7230. /**
  7231. * Bounding sphere for the mesh
  7232. */
  7233. readonly boundingSphere: BoundingSphere;
  7234. private _isLocked;
  7235. private static readonly TmpVector3;
  7236. /**
  7237. * Constructs bounding info
  7238. * @param minimum min vector of the bounding box/sphere
  7239. * @param maximum max vector of the bounding box/sphere
  7240. * @param worldMatrix defines the new world matrix
  7241. */
  7242. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7243. /**
  7244. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7245. * @param min defines the new minimum vector (in local space)
  7246. * @param max defines the new maximum vector (in local space)
  7247. * @param worldMatrix defines the new world matrix
  7248. */
  7249. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7250. /**
  7251. * min vector of the bounding box/sphere
  7252. */
  7253. get minimum(): Vector3;
  7254. /**
  7255. * max vector of the bounding box/sphere
  7256. */
  7257. get maximum(): Vector3;
  7258. /**
  7259. * If the info is locked and won't be updated to avoid perf overhead
  7260. */
  7261. get isLocked(): boolean;
  7262. set isLocked(value: boolean);
  7263. /**
  7264. * Updates the bounding sphere and box
  7265. * @param world world matrix to be used to update
  7266. */
  7267. update(world: DeepImmutable<Matrix>): void;
  7268. /**
  7269. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7270. * @param center New center of the bounding info
  7271. * @param extend New extend of the bounding info
  7272. * @returns the current bounding info
  7273. */
  7274. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7275. /**
  7276. * Scale the current bounding info by applying a scale factor
  7277. * @param factor defines the scale factor to apply
  7278. * @returns the current bounding info
  7279. */
  7280. scale(factor: number): BoundingInfo;
  7281. /**
  7282. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7283. * @param frustumPlanes defines the frustum to test
  7284. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7285. * @returns true if the bounding info is in the frustum planes
  7286. */
  7287. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7288. /**
  7289. * Gets the world distance between the min and max points of the bounding box
  7290. */
  7291. get diagonalLength(): number;
  7292. /**
  7293. * Checks if a cullable object (mesh...) is in the camera frustum
  7294. * Unlike isInFrustum this cheks the full bounding box
  7295. * @param frustumPlanes Camera near/planes
  7296. * @returns true if the object is in frustum otherwise false
  7297. */
  7298. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7299. /** @hidden */
  7300. _checkCollision(collider: Collider): boolean;
  7301. /**
  7302. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7303. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7304. * @param point the point to check intersection with
  7305. * @returns if the point intersects
  7306. */
  7307. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7308. /**
  7309. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7310. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7311. * @param boundingInfo the bounding info to check intersection with
  7312. * @param precise if the intersection should be done using OBB
  7313. * @returns if the bounding info intersects
  7314. */
  7315. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7316. }
  7317. }
  7318. declare module BABYLON {
  7319. /**
  7320. * Extracts minimum and maximum values from a list of indexed positions
  7321. * @param positions defines the positions to use
  7322. * @param indices defines the indices to the positions
  7323. * @param indexStart defines the start index
  7324. * @param indexCount defines the end index
  7325. * @param bias defines bias value to add to the result
  7326. * @return minimum and maximum values
  7327. */
  7328. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7329. minimum: Vector3;
  7330. maximum: Vector3;
  7331. };
  7332. /**
  7333. * Extracts minimum and maximum values from a list of positions
  7334. * @param positions defines the positions to use
  7335. * @param start defines the start index in the positions array
  7336. * @param count defines the number of positions to handle
  7337. * @param bias defines bias value to add to the result
  7338. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7339. * @return minimum and maximum values
  7340. */
  7341. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7342. minimum: Vector3;
  7343. maximum: Vector3;
  7344. };
  7345. }
  7346. declare module BABYLON {
  7347. /** @hidden */
  7348. export class WebGLDataBuffer extends DataBuffer {
  7349. private _buffer;
  7350. constructor(resource: WebGLBuffer);
  7351. get underlyingResource(): any;
  7352. }
  7353. }
  7354. declare module BABYLON {
  7355. /** @hidden */
  7356. export class WebGLPipelineContext implements IPipelineContext {
  7357. engine: ThinEngine;
  7358. program: Nullable<WebGLProgram>;
  7359. context?: WebGLRenderingContext;
  7360. vertexShader?: WebGLShader;
  7361. fragmentShader?: WebGLShader;
  7362. isParallelCompiled: boolean;
  7363. onCompiled?: () => void;
  7364. transformFeedback?: WebGLTransformFeedback | null;
  7365. vertexCompilationError: Nullable<string>;
  7366. fragmentCompilationError: Nullable<string>;
  7367. programLinkError: Nullable<string>;
  7368. programValidationError: Nullable<string>;
  7369. get isAsync(): boolean;
  7370. get isReady(): boolean;
  7371. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7372. _getVertexShaderCode(): string | null;
  7373. _getFragmentShaderCode(): string | null;
  7374. }
  7375. }
  7376. declare module BABYLON {
  7377. interface ThinEngine {
  7378. /**
  7379. * Create an uniform buffer
  7380. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7381. * @param elements defines the content of the uniform buffer
  7382. * @returns the webGL uniform buffer
  7383. */
  7384. createUniformBuffer(elements: FloatArray): DataBuffer;
  7385. /**
  7386. * Create a dynamic uniform buffer
  7387. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7388. * @param elements defines the content of the uniform buffer
  7389. * @returns the webGL uniform buffer
  7390. */
  7391. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7392. /**
  7393. * Update an existing uniform buffer
  7394. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7395. * @param uniformBuffer defines the target uniform buffer
  7396. * @param elements defines the content to update
  7397. * @param offset defines the offset in the uniform buffer where update should start
  7398. * @param count defines the size of the data to update
  7399. */
  7400. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7401. /**
  7402. * Bind an uniform buffer to the current webGL context
  7403. * @param buffer defines the buffer to bind
  7404. */
  7405. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7406. /**
  7407. * Bind a buffer to the current webGL context at a given location
  7408. * @param buffer defines the buffer to bind
  7409. * @param location defines the index where to bind the buffer
  7410. */
  7411. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7412. /**
  7413. * Bind a specific block at a given index in a specific shader program
  7414. * @param pipelineContext defines the pipeline context to use
  7415. * @param blockName defines the block name
  7416. * @param index defines the index where to bind the block
  7417. */
  7418. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7419. }
  7420. }
  7421. declare module BABYLON {
  7422. /**
  7423. * Uniform buffer objects.
  7424. *
  7425. * Handles blocks of uniform on the GPU.
  7426. *
  7427. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7428. *
  7429. * For more information, please refer to :
  7430. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7431. */
  7432. export class UniformBuffer {
  7433. private _engine;
  7434. private _buffer;
  7435. private _data;
  7436. private _bufferData;
  7437. private _dynamic?;
  7438. private _uniformLocations;
  7439. private _uniformSizes;
  7440. private _uniformLocationPointer;
  7441. private _needSync;
  7442. private _noUBO;
  7443. private _currentEffect;
  7444. /** @hidden */
  7445. _alreadyBound: boolean;
  7446. private static _MAX_UNIFORM_SIZE;
  7447. private static _tempBuffer;
  7448. /**
  7449. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7450. * This is dynamic to allow compat with webgl 1 and 2.
  7451. * You will need to pass the name of the uniform as well as the value.
  7452. */
  7453. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7454. /**
  7455. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7456. * This is dynamic to allow compat with webgl 1 and 2.
  7457. * You will need to pass the name of the uniform as well as the value.
  7458. */
  7459. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7460. /**
  7461. * Lambda to Update a single float in a uniform buffer.
  7462. * This is dynamic to allow compat with webgl 1 and 2.
  7463. * You will need to pass the name of the uniform as well as the value.
  7464. */
  7465. updateFloat: (name: string, x: number) => void;
  7466. /**
  7467. * Lambda to Update a vec2 of float in a uniform buffer.
  7468. * This is dynamic to allow compat with webgl 1 and 2.
  7469. * You will need to pass the name of the uniform as well as the value.
  7470. */
  7471. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7472. /**
  7473. * Lambda to Update a vec3 of float in a uniform buffer.
  7474. * This is dynamic to allow compat with webgl 1 and 2.
  7475. * You will need to pass the name of the uniform as well as the value.
  7476. */
  7477. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7478. /**
  7479. * Lambda to Update a vec4 of float in a uniform buffer.
  7480. * This is dynamic to allow compat with webgl 1 and 2.
  7481. * You will need to pass the name of the uniform as well as the value.
  7482. */
  7483. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7484. /**
  7485. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7486. * This is dynamic to allow compat with webgl 1 and 2.
  7487. * You will need to pass the name of the uniform as well as the value.
  7488. */
  7489. updateMatrix: (name: string, mat: Matrix) => void;
  7490. /**
  7491. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7492. * This is dynamic to allow compat with webgl 1 and 2.
  7493. * You will need to pass the name of the uniform as well as the value.
  7494. */
  7495. updateVector3: (name: string, vector: Vector3) => void;
  7496. /**
  7497. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7498. * This is dynamic to allow compat with webgl 1 and 2.
  7499. * You will need to pass the name of the uniform as well as the value.
  7500. */
  7501. updateVector4: (name: string, vector: Vector4) => void;
  7502. /**
  7503. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7504. * This is dynamic to allow compat with webgl 1 and 2.
  7505. * You will need to pass the name of the uniform as well as the value.
  7506. */
  7507. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7508. /**
  7509. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7510. * This is dynamic to allow compat with webgl 1 and 2.
  7511. * You will need to pass the name of the uniform as well as the value.
  7512. */
  7513. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7514. /**
  7515. * Instantiates a new Uniform buffer objects.
  7516. *
  7517. * Handles blocks of uniform on the GPU.
  7518. *
  7519. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7520. *
  7521. * For more information, please refer to :
  7522. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7523. * @param engine Define the engine the buffer is associated with
  7524. * @param data Define the data contained in the buffer
  7525. * @param dynamic Define if the buffer is updatable
  7526. */
  7527. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7528. /**
  7529. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7530. * or just falling back on setUniformXXX calls.
  7531. */
  7532. get useUbo(): boolean;
  7533. /**
  7534. * Indicates if the WebGL underlying uniform buffer is in sync
  7535. * with the javascript cache data.
  7536. */
  7537. get isSync(): boolean;
  7538. /**
  7539. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7540. * Also, a dynamic UniformBuffer will disable cache verification and always
  7541. * update the underlying WebGL uniform buffer to the GPU.
  7542. * @returns if Dynamic, otherwise false
  7543. */
  7544. isDynamic(): boolean;
  7545. /**
  7546. * The data cache on JS side.
  7547. * @returns the underlying data as a float array
  7548. */
  7549. getData(): Float32Array;
  7550. /**
  7551. * The underlying WebGL Uniform buffer.
  7552. * @returns the webgl buffer
  7553. */
  7554. getBuffer(): Nullable<DataBuffer>;
  7555. /**
  7556. * std140 layout specifies how to align data within an UBO structure.
  7557. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7558. * for specs.
  7559. */
  7560. private _fillAlignment;
  7561. /**
  7562. * Adds an uniform in the buffer.
  7563. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7564. * for the layout to be correct !
  7565. * @param name Name of the uniform, as used in the uniform block in the shader.
  7566. * @param size Data size, or data directly.
  7567. */
  7568. addUniform(name: string, size: number | number[]): void;
  7569. /**
  7570. * Adds a Matrix 4x4 to the uniform buffer.
  7571. * @param name Name of the uniform, as used in the uniform block in the shader.
  7572. * @param mat A 4x4 matrix.
  7573. */
  7574. addMatrix(name: string, mat: Matrix): void;
  7575. /**
  7576. * Adds a vec2 to the uniform buffer.
  7577. * @param name Name of the uniform, as used in the uniform block in the shader.
  7578. * @param x Define the x component value of the vec2
  7579. * @param y Define the y component value of the vec2
  7580. */
  7581. addFloat2(name: string, x: number, y: number): void;
  7582. /**
  7583. * Adds a vec3 to the uniform buffer.
  7584. * @param name Name of the uniform, as used in the uniform block in the shader.
  7585. * @param x Define the x component value of the vec3
  7586. * @param y Define the y component value of the vec3
  7587. * @param z Define the z component value of the vec3
  7588. */
  7589. addFloat3(name: string, x: number, y: number, z: number): void;
  7590. /**
  7591. * Adds a vec3 to the uniform buffer.
  7592. * @param name Name of the uniform, as used in the uniform block in the shader.
  7593. * @param color Define the vec3 from a Color
  7594. */
  7595. addColor3(name: string, color: Color3): void;
  7596. /**
  7597. * Adds a vec4 to the uniform buffer.
  7598. * @param name Name of the uniform, as used in the uniform block in the shader.
  7599. * @param color Define the rgb components from a Color
  7600. * @param alpha Define the a component of the vec4
  7601. */
  7602. addColor4(name: string, color: Color3, alpha: number): void;
  7603. /**
  7604. * Adds a vec3 to the uniform buffer.
  7605. * @param name Name of the uniform, as used in the uniform block in the shader.
  7606. * @param vector Define the vec3 components from a Vector
  7607. */
  7608. addVector3(name: string, vector: Vector3): void;
  7609. /**
  7610. * Adds a Matrix 3x3 to the uniform buffer.
  7611. * @param name Name of the uniform, as used in the uniform block in the shader.
  7612. */
  7613. addMatrix3x3(name: string): void;
  7614. /**
  7615. * Adds a Matrix 2x2 to the uniform buffer.
  7616. * @param name Name of the uniform, as used in the uniform block in the shader.
  7617. */
  7618. addMatrix2x2(name: string): void;
  7619. /**
  7620. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7621. */
  7622. create(): void;
  7623. /** @hidden */
  7624. _rebuild(): void;
  7625. /**
  7626. * Updates the WebGL Uniform Buffer on the GPU.
  7627. * If the `dynamic` flag is set to true, no cache comparison is done.
  7628. * Otherwise, the buffer will be updated only if the cache differs.
  7629. */
  7630. update(): void;
  7631. /**
  7632. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7633. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7634. * @param data Define the flattened data
  7635. * @param size Define the size of the data.
  7636. */
  7637. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7638. private _valueCache;
  7639. private _cacheMatrix;
  7640. private _updateMatrix3x3ForUniform;
  7641. private _updateMatrix3x3ForEffect;
  7642. private _updateMatrix2x2ForEffect;
  7643. private _updateMatrix2x2ForUniform;
  7644. private _updateFloatForEffect;
  7645. private _updateFloatForUniform;
  7646. private _updateFloat2ForEffect;
  7647. private _updateFloat2ForUniform;
  7648. private _updateFloat3ForEffect;
  7649. private _updateFloat3ForUniform;
  7650. private _updateFloat4ForEffect;
  7651. private _updateFloat4ForUniform;
  7652. private _updateMatrixForEffect;
  7653. private _updateMatrixForUniform;
  7654. private _updateVector3ForEffect;
  7655. private _updateVector3ForUniform;
  7656. private _updateVector4ForEffect;
  7657. private _updateVector4ForUniform;
  7658. private _updateColor3ForEffect;
  7659. private _updateColor3ForUniform;
  7660. private _updateColor4ForEffect;
  7661. private _updateColor4ForUniform;
  7662. /**
  7663. * Sets a sampler uniform on the effect.
  7664. * @param name Define the name of the sampler.
  7665. * @param texture Define the texture to set in the sampler
  7666. */
  7667. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7668. /**
  7669. * Directly updates the value of the uniform in the cache AND on the GPU.
  7670. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7671. * @param data Define the flattened data
  7672. */
  7673. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7674. /**
  7675. * Binds this uniform buffer to an effect.
  7676. * @param effect Define the effect to bind the buffer to
  7677. * @param name Name of the uniform block in the shader.
  7678. */
  7679. bindToEffect(effect: Effect, name: string): void;
  7680. /**
  7681. * Disposes the uniform buffer.
  7682. */
  7683. dispose(): void;
  7684. }
  7685. }
  7686. declare module BABYLON {
  7687. /**
  7688. * Enum that determines the text-wrapping mode to use.
  7689. */
  7690. export enum InspectableType {
  7691. /**
  7692. * Checkbox for booleans
  7693. */
  7694. Checkbox = 0,
  7695. /**
  7696. * Sliders for numbers
  7697. */
  7698. Slider = 1,
  7699. /**
  7700. * Vector3
  7701. */
  7702. Vector3 = 2,
  7703. /**
  7704. * Quaternions
  7705. */
  7706. Quaternion = 3,
  7707. /**
  7708. * Color3
  7709. */
  7710. Color3 = 4,
  7711. /**
  7712. * String
  7713. */
  7714. String = 5
  7715. }
  7716. /**
  7717. * Interface used to define custom inspectable properties.
  7718. * This interface is used by the inspector to display custom property grids
  7719. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7720. */
  7721. export interface IInspectable {
  7722. /**
  7723. * Gets the label to display
  7724. */
  7725. label: string;
  7726. /**
  7727. * Gets the name of the property to edit
  7728. */
  7729. propertyName: string;
  7730. /**
  7731. * Gets the type of the editor to use
  7732. */
  7733. type: InspectableType;
  7734. /**
  7735. * Gets the minimum value of the property when using in "slider" mode
  7736. */
  7737. min?: number;
  7738. /**
  7739. * Gets the maximum value of the property when using in "slider" mode
  7740. */
  7741. max?: number;
  7742. /**
  7743. * Gets the setp to use when using in "slider" mode
  7744. */
  7745. step?: number;
  7746. }
  7747. }
  7748. declare module BABYLON {
  7749. /**
  7750. * Class used to provide helper for timing
  7751. */
  7752. export class TimingTools {
  7753. /**
  7754. * Polyfill for setImmediate
  7755. * @param action defines the action to execute after the current execution block
  7756. */
  7757. static SetImmediate(action: () => void): void;
  7758. }
  7759. }
  7760. declare module BABYLON {
  7761. /**
  7762. * Class used to enable instatition of objects by class name
  7763. */
  7764. export class InstantiationTools {
  7765. /**
  7766. * Use this object to register external classes like custom textures or material
  7767. * to allow the laoders to instantiate them
  7768. */
  7769. static RegisteredExternalClasses: {
  7770. [key: string]: Object;
  7771. };
  7772. /**
  7773. * Tries to instantiate a new object from a given class name
  7774. * @param className defines the class name to instantiate
  7775. * @returns the new object or null if the system was not able to do the instantiation
  7776. */
  7777. static Instantiate(className: string): any;
  7778. }
  7779. }
  7780. declare module BABYLON {
  7781. /**
  7782. * Class used to host copy specific utilities
  7783. */
  7784. export class CopyTools {
  7785. /**
  7786. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  7787. * @param texture defines the texture to read pixels from
  7788. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7789. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7790. * @returns The base64 encoded string or null
  7791. */
  7792. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  7793. }
  7794. }
  7795. declare module BABYLON {
  7796. /**
  7797. * Define options used to create a depth texture
  7798. */
  7799. export class DepthTextureCreationOptions {
  7800. /** Specifies whether or not a stencil should be allocated in the texture */
  7801. generateStencil?: boolean;
  7802. /** Specifies whether or not bilinear filtering is enable on the texture */
  7803. bilinearFiltering?: boolean;
  7804. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7805. comparisonFunction?: number;
  7806. /** Specifies if the created texture is a cube texture */
  7807. isCube?: boolean;
  7808. }
  7809. }
  7810. declare module BABYLON {
  7811. interface ThinEngine {
  7812. /**
  7813. * Creates a depth stencil cube texture.
  7814. * This is only available in WebGL 2.
  7815. * @param size The size of face edge in the cube texture.
  7816. * @param options The options defining the cube texture.
  7817. * @returns The cube texture
  7818. */
  7819. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7820. /**
  7821. * Creates a cube texture
  7822. * @param rootUrl defines the url where the files to load is located
  7823. * @param scene defines the current scene
  7824. * @param files defines the list of files to load (1 per face)
  7825. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7826. * @param onLoad defines an optional callback raised when the texture is loaded
  7827. * @param onError defines an optional callback raised if there is an issue to load the texture
  7828. * @param format defines the format of the data
  7829. * @param forcedExtension defines the extension to use to pick the right loader
  7830. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7831. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7832. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7833. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7834. * @param loaderOptions options to be passed to the loader
  7835. * @returns the cube texture as an InternalTexture
  7836. */
  7837. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  7838. /**
  7839. * Creates a cube texture
  7840. * @param rootUrl defines the url where the files to load is located
  7841. * @param scene defines the current scene
  7842. * @param files defines the list of files to load (1 per face)
  7843. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7844. * @param onLoad defines an optional callback raised when the texture is loaded
  7845. * @param onError defines an optional callback raised if there is an issue to load the texture
  7846. * @param format defines the format of the data
  7847. * @param forcedExtension defines the extension to use to pick the right loader
  7848. * @returns the cube texture as an InternalTexture
  7849. */
  7850. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7851. /**
  7852. * Creates a cube texture
  7853. * @param rootUrl defines the url where the files to load is located
  7854. * @param scene defines the current scene
  7855. * @param files defines the list of files to load (1 per face)
  7856. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7857. * @param onLoad defines an optional callback raised when the texture is loaded
  7858. * @param onError defines an optional callback raised if there is an issue to load the texture
  7859. * @param format defines the format of the data
  7860. * @param forcedExtension defines the extension to use to pick the right loader
  7861. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7862. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7863. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7864. * @returns the cube texture as an InternalTexture
  7865. */
  7866. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7867. /** @hidden */
  7868. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7869. /** @hidden */
  7870. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7871. /** @hidden */
  7872. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7873. /** @hidden */
  7874. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7875. /**
  7876. * @hidden
  7877. */
  7878. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  7879. }
  7880. }
  7881. declare module BABYLON {
  7882. /**
  7883. * Class for creating a cube texture
  7884. */
  7885. export class CubeTexture extends BaseTexture {
  7886. private _delayedOnLoad;
  7887. /**
  7888. * Observable triggered once the texture has been loaded.
  7889. */
  7890. onLoadObservable: Observable<CubeTexture>;
  7891. /**
  7892. * The url of the texture
  7893. */
  7894. url: string;
  7895. /**
  7896. * Gets or sets the center of the bounding box associated with the cube texture.
  7897. * It must define where the camera used to render the texture was set
  7898. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7899. */
  7900. boundingBoxPosition: Vector3;
  7901. private _boundingBoxSize;
  7902. /**
  7903. * Gets or sets the size of the bounding box associated with the cube texture
  7904. * When defined, the cubemap will switch to local mode
  7905. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7906. * @example https://www.babylonjs-playground.com/#RNASML
  7907. */
  7908. set boundingBoxSize(value: Vector3);
  7909. /**
  7910. * Returns the bounding box size
  7911. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7912. */
  7913. get boundingBoxSize(): Vector3;
  7914. protected _rotationY: number;
  7915. /**
  7916. * Sets texture matrix rotation angle around Y axis in radians.
  7917. */
  7918. set rotationY(value: number);
  7919. /**
  7920. * Gets texture matrix rotation angle around Y axis radians.
  7921. */
  7922. get rotationY(): number;
  7923. /**
  7924. * Are mip maps generated for this texture or not.
  7925. */
  7926. get noMipmap(): boolean;
  7927. private _noMipmap;
  7928. private _files;
  7929. protected _forcedExtension: Nullable<string>;
  7930. private _extensions;
  7931. private _textureMatrix;
  7932. private _format;
  7933. private _createPolynomials;
  7934. private _loaderOptions;
  7935. /**
  7936. * Creates a cube texture from an array of image urls
  7937. * @param files defines an array of image urls
  7938. * @param scene defines the hosting scene
  7939. * @param noMipmap specifies if mip maps are not used
  7940. * @returns a cube texture
  7941. */
  7942. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7943. /**
  7944. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7945. * @param url defines the url of the prefiltered texture
  7946. * @param scene defines the scene the texture is attached to
  7947. * @param forcedExtension defines the extension of the file if different from the url
  7948. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7949. * @return the prefiltered texture
  7950. */
  7951. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7952. /**
  7953. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7954. * as prefiltered data.
  7955. * @param rootUrl defines the url of the texture or the root name of the six images
  7956. * @param null defines the scene or engine the texture is attached to
  7957. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7958. * @param noMipmap defines if mipmaps should be created or not
  7959. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7960. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7961. * @param onError defines a callback triggered in case of error during load
  7962. * @param format defines the internal format to use for the texture once loaded
  7963. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7964. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7965. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7966. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7967. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7968. * @param loaderOptions options to be passed to the loader
  7969. * @return the cube texture
  7970. */
  7971. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  7972. /**
  7973. * Get the current class name of the texture useful for serialization or dynamic coding.
  7974. * @returns "CubeTexture"
  7975. */
  7976. getClassName(): string;
  7977. /**
  7978. * Update the url (and optional buffer) of this texture if url was null during construction.
  7979. * @param url the url of the texture
  7980. * @param forcedExtension defines the extension to use
  7981. * @param onLoad callback called when the texture is loaded (defaults to null)
  7982. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7983. */
  7984. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7985. /**
  7986. * Delays loading of the cube texture
  7987. * @param forcedExtension defines the extension to use
  7988. */
  7989. delayLoad(forcedExtension?: string): void;
  7990. /**
  7991. * Returns the reflection texture matrix
  7992. * @returns the reflection texture matrix
  7993. */
  7994. getReflectionTextureMatrix(): Matrix;
  7995. /**
  7996. * Sets the reflection texture matrix
  7997. * @param value Reflection texture matrix
  7998. */
  7999. setReflectionTextureMatrix(value: Matrix): void;
  8000. /**
  8001. * Parses text to create a cube texture
  8002. * @param parsedTexture define the serialized text to read from
  8003. * @param scene defines the hosting scene
  8004. * @param rootUrl defines the root url of the cube texture
  8005. * @returns a cube texture
  8006. */
  8007. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8008. /**
  8009. * Makes a clone, or deep copy, of the cube texture
  8010. * @returns a new cube texture
  8011. */
  8012. clone(): CubeTexture;
  8013. }
  8014. }
  8015. declare module BABYLON {
  8016. /**
  8017. * Manages the defines for the Material
  8018. */
  8019. export class MaterialDefines {
  8020. /** @hidden */
  8021. protected _keys: string[];
  8022. private _isDirty;
  8023. /** @hidden */
  8024. _renderId: number;
  8025. /** @hidden */
  8026. _areLightsDirty: boolean;
  8027. /** @hidden */
  8028. _areLightsDisposed: boolean;
  8029. /** @hidden */
  8030. _areAttributesDirty: boolean;
  8031. /** @hidden */
  8032. _areTexturesDirty: boolean;
  8033. /** @hidden */
  8034. _areFresnelDirty: boolean;
  8035. /** @hidden */
  8036. _areMiscDirty: boolean;
  8037. /** @hidden */
  8038. _arePrePassDirty: boolean;
  8039. /** @hidden */
  8040. _areImageProcessingDirty: boolean;
  8041. /** @hidden */
  8042. _normals: boolean;
  8043. /** @hidden */
  8044. _uvs: boolean;
  8045. /** @hidden */
  8046. _needNormals: boolean;
  8047. /** @hidden */
  8048. _needUVs: boolean;
  8049. [id: string]: any;
  8050. /**
  8051. * Specifies if the material needs to be re-calculated
  8052. */
  8053. get isDirty(): boolean;
  8054. /**
  8055. * Marks the material to indicate that it has been re-calculated
  8056. */
  8057. markAsProcessed(): void;
  8058. /**
  8059. * Marks the material to indicate that it needs to be re-calculated
  8060. */
  8061. markAsUnprocessed(): void;
  8062. /**
  8063. * Marks the material to indicate all of its defines need to be re-calculated
  8064. */
  8065. markAllAsDirty(): void;
  8066. /**
  8067. * Marks the material to indicate that image processing needs to be re-calculated
  8068. */
  8069. markAsImageProcessingDirty(): void;
  8070. /**
  8071. * Marks the material to indicate the lights need to be re-calculated
  8072. * @param disposed Defines whether the light is dirty due to dispose or not
  8073. */
  8074. markAsLightDirty(disposed?: boolean): void;
  8075. /**
  8076. * Marks the attribute state as changed
  8077. */
  8078. markAsAttributesDirty(): void;
  8079. /**
  8080. * Marks the texture state as changed
  8081. */
  8082. markAsTexturesDirty(): void;
  8083. /**
  8084. * Marks the fresnel state as changed
  8085. */
  8086. markAsFresnelDirty(): void;
  8087. /**
  8088. * Marks the misc state as changed
  8089. */
  8090. markAsMiscDirty(): void;
  8091. /**
  8092. * Marks the prepass state as changed
  8093. */
  8094. markAsPrePassDirty(): void;
  8095. /**
  8096. * Rebuilds the material defines
  8097. */
  8098. rebuild(): void;
  8099. /**
  8100. * Specifies if two material defines are equal
  8101. * @param other - A material define instance to compare to
  8102. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8103. */
  8104. isEqual(other: MaterialDefines): boolean;
  8105. /**
  8106. * Clones this instance's defines to another instance
  8107. * @param other - material defines to clone values to
  8108. */
  8109. cloneTo(other: MaterialDefines): void;
  8110. /**
  8111. * Resets the material define values
  8112. */
  8113. reset(): void;
  8114. /**
  8115. * Converts the material define values to a string
  8116. * @returns - String of material define information
  8117. */
  8118. toString(): string;
  8119. }
  8120. }
  8121. declare module BABYLON {
  8122. /**
  8123. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8124. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8125. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8126. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8127. */
  8128. export class ColorCurves {
  8129. private _dirty;
  8130. private _tempColor;
  8131. private _globalCurve;
  8132. private _highlightsCurve;
  8133. private _midtonesCurve;
  8134. private _shadowsCurve;
  8135. private _positiveCurve;
  8136. private _negativeCurve;
  8137. private _globalHue;
  8138. private _globalDensity;
  8139. private _globalSaturation;
  8140. private _globalExposure;
  8141. /**
  8142. * Gets the global Hue value.
  8143. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8144. */
  8145. get globalHue(): number;
  8146. /**
  8147. * Sets the global Hue value.
  8148. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8149. */
  8150. set globalHue(value: number);
  8151. /**
  8152. * Gets the global Density value.
  8153. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8154. * Values less than zero provide a filter of opposite hue.
  8155. */
  8156. get globalDensity(): number;
  8157. /**
  8158. * Sets the global Density value.
  8159. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8160. * Values less than zero provide a filter of opposite hue.
  8161. */
  8162. set globalDensity(value: number);
  8163. /**
  8164. * Gets the global Saturation value.
  8165. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8166. */
  8167. get globalSaturation(): number;
  8168. /**
  8169. * Sets the global Saturation value.
  8170. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8171. */
  8172. set globalSaturation(value: number);
  8173. /**
  8174. * Gets the global Exposure value.
  8175. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8176. */
  8177. get globalExposure(): number;
  8178. /**
  8179. * Sets the global Exposure value.
  8180. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8181. */
  8182. set globalExposure(value: number);
  8183. private _highlightsHue;
  8184. private _highlightsDensity;
  8185. private _highlightsSaturation;
  8186. private _highlightsExposure;
  8187. /**
  8188. * Gets the highlights Hue value.
  8189. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8190. */
  8191. get highlightsHue(): number;
  8192. /**
  8193. * Sets the highlights Hue value.
  8194. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8195. */
  8196. set highlightsHue(value: number);
  8197. /**
  8198. * Gets the highlights Density value.
  8199. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8200. * Values less than zero provide a filter of opposite hue.
  8201. */
  8202. get highlightsDensity(): number;
  8203. /**
  8204. * Sets the highlights Density value.
  8205. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8206. * Values less than zero provide a filter of opposite hue.
  8207. */
  8208. set highlightsDensity(value: number);
  8209. /**
  8210. * Gets the highlights Saturation value.
  8211. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8212. */
  8213. get highlightsSaturation(): number;
  8214. /**
  8215. * Sets the highlights Saturation value.
  8216. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8217. */
  8218. set highlightsSaturation(value: number);
  8219. /**
  8220. * Gets the highlights Exposure value.
  8221. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8222. */
  8223. get highlightsExposure(): number;
  8224. /**
  8225. * Sets the highlights Exposure value.
  8226. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8227. */
  8228. set highlightsExposure(value: number);
  8229. private _midtonesHue;
  8230. private _midtonesDensity;
  8231. private _midtonesSaturation;
  8232. private _midtonesExposure;
  8233. /**
  8234. * Gets the midtones Hue value.
  8235. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8236. */
  8237. get midtonesHue(): number;
  8238. /**
  8239. * Sets the midtones Hue value.
  8240. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8241. */
  8242. set midtonesHue(value: number);
  8243. /**
  8244. * Gets the midtones Density value.
  8245. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8246. * Values less than zero provide a filter of opposite hue.
  8247. */
  8248. get midtonesDensity(): number;
  8249. /**
  8250. * Sets the midtones Density value.
  8251. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8252. * Values less than zero provide a filter of opposite hue.
  8253. */
  8254. set midtonesDensity(value: number);
  8255. /**
  8256. * Gets the midtones Saturation value.
  8257. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8258. */
  8259. get midtonesSaturation(): number;
  8260. /**
  8261. * Sets the midtones Saturation value.
  8262. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8263. */
  8264. set midtonesSaturation(value: number);
  8265. /**
  8266. * Gets the midtones Exposure value.
  8267. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8268. */
  8269. get midtonesExposure(): number;
  8270. /**
  8271. * Sets the midtones Exposure value.
  8272. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8273. */
  8274. set midtonesExposure(value: number);
  8275. private _shadowsHue;
  8276. private _shadowsDensity;
  8277. private _shadowsSaturation;
  8278. private _shadowsExposure;
  8279. /**
  8280. * Gets the shadows Hue value.
  8281. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8282. */
  8283. get shadowsHue(): number;
  8284. /**
  8285. * Sets the shadows Hue value.
  8286. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8287. */
  8288. set shadowsHue(value: number);
  8289. /**
  8290. * Gets the shadows Density value.
  8291. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8292. * Values less than zero provide a filter of opposite hue.
  8293. */
  8294. get shadowsDensity(): number;
  8295. /**
  8296. * Sets the shadows Density value.
  8297. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8298. * Values less than zero provide a filter of opposite hue.
  8299. */
  8300. set shadowsDensity(value: number);
  8301. /**
  8302. * Gets the shadows Saturation value.
  8303. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8304. */
  8305. get shadowsSaturation(): number;
  8306. /**
  8307. * Sets the shadows Saturation value.
  8308. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8309. */
  8310. set shadowsSaturation(value: number);
  8311. /**
  8312. * Gets the shadows Exposure value.
  8313. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8314. */
  8315. get shadowsExposure(): number;
  8316. /**
  8317. * Sets the shadows Exposure value.
  8318. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8319. */
  8320. set shadowsExposure(value: number);
  8321. /**
  8322. * Returns the class name
  8323. * @returns The class name
  8324. */
  8325. getClassName(): string;
  8326. /**
  8327. * Binds the color curves to the shader.
  8328. * @param colorCurves The color curve to bind
  8329. * @param effect The effect to bind to
  8330. * @param positiveUniform The positive uniform shader parameter
  8331. * @param neutralUniform The neutral uniform shader parameter
  8332. * @param negativeUniform The negative uniform shader parameter
  8333. */
  8334. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8335. /**
  8336. * Prepare the list of uniforms associated with the ColorCurves effects.
  8337. * @param uniformsList The list of uniforms used in the effect
  8338. */
  8339. static PrepareUniforms(uniformsList: string[]): void;
  8340. /**
  8341. * Returns color grading data based on a hue, density, saturation and exposure value.
  8342. * @param filterHue The hue of the color filter.
  8343. * @param filterDensity The density of the color filter.
  8344. * @param saturation The saturation.
  8345. * @param exposure The exposure.
  8346. * @param result The result data container.
  8347. */
  8348. private getColorGradingDataToRef;
  8349. /**
  8350. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8351. * @param value The input slider value in range [-100,100].
  8352. * @returns Adjusted value.
  8353. */
  8354. private static applyColorGradingSliderNonlinear;
  8355. /**
  8356. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8357. * @param hue The hue (H) input.
  8358. * @param saturation The saturation (S) input.
  8359. * @param brightness The brightness (B) input.
  8360. * @result An RGBA color represented as Vector4.
  8361. */
  8362. private static fromHSBToRef;
  8363. /**
  8364. * Returns a value clamped between min and max
  8365. * @param value The value to clamp
  8366. * @param min The minimum of value
  8367. * @param max The maximum of value
  8368. * @returns The clamped value.
  8369. */
  8370. private static clamp;
  8371. /**
  8372. * Clones the current color curve instance.
  8373. * @return The cloned curves
  8374. */
  8375. clone(): ColorCurves;
  8376. /**
  8377. * Serializes the current color curve instance to a json representation.
  8378. * @return a JSON representation
  8379. */
  8380. serialize(): any;
  8381. /**
  8382. * Parses the color curve from a json representation.
  8383. * @param source the JSON source to parse
  8384. * @return The parsed curves
  8385. */
  8386. static Parse(source: any): ColorCurves;
  8387. }
  8388. }
  8389. declare module BABYLON {
  8390. /**
  8391. * Interface to follow in your material defines to integrate easily the
  8392. * Image proccessing functions.
  8393. * @hidden
  8394. */
  8395. export interface IImageProcessingConfigurationDefines {
  8396. IMAGEPROCESSING: boolean;
  8397. VIGNETTE: boolean;
  8398. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8399. VIGNETTEBLENDMODEOPAQUE: boolean;
  8400. TONEMAPPING: boolean;
  8401. TONEMAPPING_ACES: boolean;
  8402. CONTRAST: boolean;
  8403. EXPOSURE: boolean;
  8404. COLORCURVES: boolean;
  8405. COLORGRADING: boolean;
  8406. COLORGRADING3D: boolean;
  8407. SAMPLER3DGREENDEPTH: boolean;
  8408. SAMPLER3DBGRMAP: boolean;
  8409. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8410. }
  8411. /**
  8412. * @hidden
  8413. */
  8414. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8415. IMAGEPROCESSING: boolean;
  8416. VIGNETTE: boolean;
  8417. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8418. VIGNETTEBLENDMODEOPAQUE: boolean;
  8419. TONEMAPPING: boolean;
  8420. TONEMAPPING_ACES: boolean;
  8421. CONTRAST: boolean;
  8422. COLORCURVES: boolean;
  8423. COLORGRADING: boolean;
  8424. COLORGRADING3D: boolean;
  8425. SAMPLER3DGREENDEPTH: boolean;
  8426. SAMPLER3DBGRMAP: boolean;
  8427. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8428. EXPOSURE: boolean;
  8429. constructor();
  8430. }
  8431. /**
  8432. * This groups together the common properties used for image processing either in direct forward pass
  8433. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8434. * or not.
  8435. */
  8436. export class ImageProcessingConfiguration {
  8437. /**
  8438. * Default tone mapping applied in BabylonJS.
  8439. */
  8440. static readonly TONEMAPPING_STANDARD: number;
  8441. /**
  8442. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8443. * to other engines rendering to increase portability.
  8444. */
  8445. static readonly TONEMAPPING_ACES: number;
  8446. /**
  8447. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8448. */
  8449. colorCurves: Nullable<ColorCurves>;
  8450. private _colorCurvesEnabled;
  8451. /**
  8452. * Gets wether the color curves effect is enabled.
  8453. */
  8454. get colorCurvesEnabled(): boolean;
  8455. /**
  8456. * Sets wether the color curves effect is enabled.
  8457. */
  8458. set colorCurvesEnabled(value: boolean);
  8459. private _colorGradingTexture;
  8460. /**
  8461. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8462. */
  8463. get colorGradingTexture(): Nullable<BaseTexture>;
  8464. /**
  8465. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8466. */
  8467. set colorGradingTexture(value: Nullable<BaseTexture>);
  8468. private _colorGradingEnabled;
  8469. /**
  8470. * Gets wether the color grading effect is enabled.
  8471. */
  8472. get colorGradingEnabled(): boolean;
  8473. /**
  8474. * Sets wether the color grading effect is enabled.
  8475. */
  8476. set colorGradingEnabled(value: boolean);
  8477. private _colorGradingWithGreenDepth;
  8478. /**
  8479. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8480. */
  8481. get colorGradingWithGreenDepth(): boolean;
  8482. /**
  8483. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8484. */
  8485. set colorGradingWithGreenDepth(value: boolean);
  8486. private _colorGradingBGR;
  8487. /**
  8488. * Gets wether the color grading texture contains BGR values.
  8489. */
  8490. get colorGradingBGR(): boolean;
  8491. /**
  8492. * Sets wether the color grading texture contains BGR values.
  8493. */
  8494. set colorGradingBGR(value: boolean);
  8495. /** @hidden */
  8496. _exposure: number;
  8497. /**
  8498. * Gets the Exposure used in the effect.
  8499. */
  8500. get exposure(): number;
  8501. /**
  8502. * Sets the Exposure used in the effect.
  8503. */
  8504. set exposure(value: number);
  8505. private _toneMappingEnabled;
  8506. /**
  8507. * Gets wether the tone mapping effect is enabled.
  8508. */
  8509. get toneMappingEnabled(): boolean;
  8510. /**
  8511. * Sets wether the tone mapping effect is enabled.
  8512. */
  8513. set toneMappingEnabled(value: boolean);
  8514. private _toneMappingType;
  8515. /**
  8516. * Gets the type of tone mapping effect.
  8517. */
  8518. get toneMappingType(): number;
  8519. /**
  8520. * Sets the type of tone mapping effect used in BabylonJS.
  8521. */
  8522. set toneMappingType(value: number);
  8523. protected _contrast: number;
  8524. /**
  8525. * Gets the contrast used in the effect.
  8526. */
  8527. get contrast(): number;
  8528. /**
  8529. * Sets the contrast used in the effect.
  8530. */
  8531. set contrast(value: number);
  8532. /**
  8533. * Vignette stretch size.
  8534. */
  8535. vignetteStretch: number;
  8536. /**
  8537. * Vignette centre X Offset.
  8538. */
  8539. vignetteCentreX: number;
  8540. /**
  8541. * Vignette centre Y Offset.
  8542. */
  8543. vignetteCentreY: number;
  8544. /**
  8545. * Vignette weight or intensity of the vignette effect.
  8546. */
  8547. vignetteWeight: number;
  8548. /**
  8549. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8550. * if vignetteEnabled is set to true.
  8551. */
  8552. vignetteColor: Color4;
  8553. /**
  8554. * Camera field of view used by the Vignette effect.
  8555. */
  8556. vignetteCameraFov: number;
  8557. private _vignetteBlendMode;
  8558. /**
  8559. * Gets the vignette blend mode allowing different kind of effect.
  8560. */
  8561. get vignetteBlendMode(): number;
  8562. /**
  8563. * Sets the vignette blend mode allowing different kind of effect.
  8564. */
  8565. set vignetteBlendMode(value: number);
  8566. private _vignetteEnabled;
  8567. /**
  8568. * Gets wether the vignette effect is enabled.
  8569. */
  8570. get vignetteEnabled(): boolean;
  8571. /**
  8572. * Sets wether the vignette effect is enabled.
  8573. */
  8574. set vignetteEnabled(value: boolean);
  8575. private _applyByPostProcess;
  8576. /**
  8577. * Gets wether the image processing is applied through a post process or not.
  8578. */
  8579. get applyByPostProcess(): boolean;
  8580. /**
  8581. * Sets wether the image processing is applied through a post process or not.
  8582. */
  8583. set applyByPostProcess(value: boolean);
  8584. private _isEnabled;
  8585. /**
  8586. * Gets wether the image processing is enabled or not.
  8587. */
  8588. get isEnabled(): boolean;
  8589. /**
  8590. * Sets wether the image processing is enabled or not.
  8591. */
  8592. set isEnabled(value: boolean);
  8593. /**
  8594. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8595. */
  8596. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8597. /**
  8598. * Method called each time the image processing information changes requires to recompile the effect.
  8599. */
  8600. protected _updateParameters(): void;
  8601. /**
  8602. * Gets the current class name.
  8603. * @return "ImageProcessingConfiguration"
  8604. */
  8605. getClassName(): string;
  8606. /**
  8607. * Prepare the list of uniforms associated with the Image Processing effects.
  8608. * @param uniforms The list of uniforms used in the effect
  8609. * @param defines the list of defines currently in use
  8610. */
  8611. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8612. /**
  8613. * Prepare the list of samplers associated with the Image Processing effects.
  8614. * @param samplersList The list of uniforms used in the effect
  8615. * @param defines the list of defines currently in use
  8616. */
  8617. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8618. /**
  8619. * Prepare the list of defines associated to the shader.
  8620. * @param defines the list of defines to complete
  8621. * @param forPostProcess Define if we are currently in post process mode or not
  8622. */
  8623. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8624. /**
  8625. * Returns true if all the image processing information are ready.
  8626. * @returns True if ready, otherwise, false
  8627. */
  8628. isReady(): boolean;
  8629. /**
  8630. * Binds the image processing to the shader.
  8631. * @param effect The effect to bind to
  8632. * @param overrideAspectRatio Override the aspect ratio of the effect
  8633. */
  8634. bind(effect: Effect, overrideAspectRatio?: number): void;
  8635. /**
  8636. * Clones the current image processing instance.
  8637. * @return The cloned image processing
  8638. */
  8639. clone(): ImageProcessingConfiguration;
  8640. /**
  8641. * Serializes the current image processing instance to a json representation.
  8642. * @return a JSON representation
  8643. */
  8644. serialize(): any;
  8645. /**
  8646. * Parses the image processing from a json representation.
  8647. * @param source the JSON source to parse
  8648. * @return The parsed image processing
  8649. */
  8650. static Parse(source: any): ImageProcessingConfiguration;
  8651. private static _VIGNETTEMODE_MULTIPLY;
  8652. private static _VIGNETTEMODE_OPAQUE;
  8653. /**
  8654. * Used to apply the vignette as a mix with the pixel color.
  8655. */
  8656. static get VIGNETTEMODE_MULTIPLY(): number;
  8657. /**
  8658. * Used to apply the vignette as a replacement of the pixel color.
  8659. */
  8660. static get VIGNETTEMODE_OPAQUE(): number;
  8661. }
  8662. }
  8663. declare module BABYLON {
  8664. /** @hidden */
  8665. export var postprocessVertexShader: {
  8666. name: string;
  8667. shader: string;
  8668. };
  8669. }
  8670. declare module BABYLON {
  8671. /**
  8672. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8673. */
  8674. export type RenderTargetTextureSize = number | {
  8675. width: number;
  8676. height: number;
  8677. layers?: number;
  8678. };
  8679. interface ThinEngine {
  8680. /**
  8681. * Creates a new render target texture
  8682. * @param size defines the size of the texture
  8683. * @param options defines the options used to create the texture
  8684. * @returns a new render target texture stored in an InternalTexture
  8685. */
  8686. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8687. /**
  8688. * Creates a depth stencil texture.
  8689. * This is only available in WebGL 2 or with the depth texture extension available.
  8690. * @param size The size of face edge in the texture.
  8691. * @param options The options defining the texture.
  8692. * @returns The texture
  8693. */
  8694. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8695. /** @hidden */
  8696. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8697. }
  8698. }
  8699. declare module BABYLON {
  8700. /**
  8701. * Defines the kind of connection point for node based material
  8702. */
  8703. export enum NodeMaterialBlockConnectionPointTypes {
  8704. /** Float */
  8705. Float = 1,
  8706. /** Int */
  8707. Int = 2,
  8708. /** Vector2 */
  8709. Vector2 = 4,
  8710. /** Vector3 */
  8711. Vector3 = 8,
  8712. /** Vector4 */
  8713. Vector4 = 16,
  8714. /** Color3 */
  8715. Color3 = 32,
  8716. /** Color4 */
  8717. Color4 = 64,
  8718. /** Matrix */
  8719. Matrix = 128,
  8720. /** Custom object */
  8721. Object = 256,
  8722. /** Detect type based on connection */
  8723. AutoDetect = 1024,
  8724. /** Output type that will be defined by input type */
  8725. BasedOnInput = 2048
  8726. }
  8727. }
  8728. declare module BABYLON {
  8729. /**
  8730. * Enum used to define the target of a block
  8731. */
  8732. export enum NodeMaterialBlockTargets {
  8733. /** Vertex shader */
  8734. Vertex = 1,
  8735. /** Fragment shader */
  8736. Fragment = 2,
  8737. /** Neutral */
  8738. Neutral = 4,
  8739. /** Vertex and Fragment */
  8740. VertexAndFragment = 3
  8741. }
  8742. }
  8743. declare module BABYLON {
  8744. /**
  8745. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8746. */
  8747. export enum NodeMaterialBlockConnectionPointMode {
  8748. /** Value is an uniform */
  8749. Uniform = 0,
  8750. /** Value is a mesh attribute */
  8751. Attribute = 1,
  8752. /** Value is a varying between vertex and fragment shaders */
  8753. Varying = 2,
  8754. /** Mode is undefined */
  8755. Undefined = 3
  8756. }
  8757. }
  8758. declare module BABYLON {
  8759. /**
  8760. * Enum used to define system values e.g. values automatically provided by the system
  8761. */
  8762. export enum NodeMaterialSystemValues {
  8763. /** World */
  8764. World = 1,
  8765. /** View */
  8766. View = 2,
  8767. /** Projection */
  8768. Projection = 3,
  8769. /** ViewProjection */
  8770. ViewProjection = 4,
  8771. /** WorldView */
  8772. WorldView = 5,
  8773. /** WorldViewProjection */
  8774. WorldViewProjection = 6,
  8775. /** CameraPosition */
  8776. CameraPosition = 7,
  8777. /** Fog Color */
  8778. FogColor = 8,
  8779. /** Delta time */
  8780. DeltaTime = 9
  8781. }
  8782. }
  8783. declare module BABYLON {
  8784. /** Defines supported spaces */
  8785. export enum Space {
  8786. /** Local (object) space */
  8787. LOCAL = 0,
  8788. /** World space */
  8789. WORLD = 1,
  8790. /** Bone space */
  8791. BONE = 2
  8792. }
  8793. /** Defines the 3 main axes */
  8794. export class Axis {
  8795. /** X axis */
  8796. static X: Vector3;
  8797. /** Y axis */
  8798. static Y: Vector3;
  8799. /** Z axis */
  8800. static Z: Vector3;
  8801. }
  8802. /**
  8803. * Defines cartesian components.
  8804. */
  8805. export enum Coordinate {
  8806. /** X axis */
  8807. X = 0,
  8808. /** Y axis */
  8809. Y = 1,
  8810. /** Z axis */
  8811. Z = 2
  8812. }
  8813. }
  8814. declare module BABYLON {
  8815. /**
  8816. * Represents a camera frustum
  8817. */
  8818. export class Frustum {
  8819. /**
  8820. * Gets the planes representing the frustum
  8821. * @param transform matrix to be applied to the returned planes
  8822. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8823. */
  8824. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8825. /**
  8826. * Gets the near frustum plane transformed by the transform matrix
  8827. * @param transform transformation matrix to be applied to the resulting frustum plane
  8828. * @param frustumPlane the resuling frustum plane
  8829. */
  8830. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8831. /**
  8832. * Gets the far frustum plane transformed by the transform matrix
  8833. * @param transform transformation matrix to be applied to the resulting frustum plane
  8834. * @param frustumPlane the resuling frustum plane
  8835. */
  8836. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8837. /**
  8838. * Gets the left frustum plane transformed by the transform matrix
  8839. * @param transform transformation matrix to be applied to the resulting frustum plane
  8840. * @param frustumPlane the resuling frustum plane
  8841. */
  8842. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8843. /**
  8844. * Gets the right frustum plane transformed by the transform matrix
  8845. * @param transform transformation matrix to be applied to the resulting frustum plane
  8846. * @param frustumPlane the resuling frustum plane
  8847. */
  8848. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8849. /**
  8850. * Gets the top frustum plane transformed by the transform matrix
  8851. * @param transform transformation matrix to be applied to the resulting frustum plane
  8852. * @param frustumPlane the resuling frustum plane
  8853. */
  8854. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8855. /**
  8856. * Gets the bottom frustum plane transformed by the transform matrix
  8857. * @param transform transformation matrix to be applied to the resulting frustum plane
  8858. * @param frustumPlane the resuling frustum plane
  8859. */
  8860. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8861. /**
  8862. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8863. * @param transform transformation matrix to be applied to the resulting frustum planes
  8864. * @param frustumPlanes the resuling frustum planes
  8865. */
  8866. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8867. }
  8868. }
  8869. declare module BABYLON {
  8870. /**
  8871. * Interface for the size containing width and height
  8872. */
  8873. export interface ISize {
  8874. /**
  8875. * Width
  8876. */
  8877. width: number;
  8878. /**
  8879. * Heighht
  8880. */
  8881. height: number;
  8882. }
  8883. /**
  8884. * Size containing widht and height
  8885. */
  8886. export class Size implements ISize {
  8887. /**
  8888. * Width
  8889. */
  8890. width: number;
  8891. /**
  8892. * Height
  8893. */
  8894. height: number;
  8895. /**
  8896. * Creates a Size object from the given width and height (floats).
  8897. * @param width width of the new size
  8898. * @param height height of the new size
  8899. */
  8900. constructor(width: number, height: number);
  8901. /**
  8902. * Returns a string with the Size width and height
  8903. * @returns a string with the Size width and height
  8904. */
  8905. toString(): string;
  8906. /**
  8907. * "Size"
  8908. * @returns the string "Size"
  8909. */
  8910. getClassName(): string;
  8911. /**
  8912. * Returns the Size hash code.
  8913. * @returns a hash code for a unique width and height
  8914. */
  8915. getHashCode(): number;
  8916. /**
  8917. * Updates the current size from the given one.
  8918. * @param src the given size
  8919. */
  8920. copyFrom(src: Size): void;
  8921. /**
  8922. * Updates in place the current Size from the given floats.
  8923. * @param width width of the new size
  8924. * @param height height of the new size
  8925. * @returns the updated Size.
  8926. */
  8927. copyFromFloats(width: number, height: number): Size;
  8928. /**
  8929. * Updates in place the current Size from the given floats.
  8930. * @param width width to set
  8931. * @param height height to set
  8932. * @returns the updated Size.
  8933. */
  8934. set(width: number, height: number): Size;
  8935. /**
  8936. * Multiplies the width and height by numbers
  8937. * @param w factor to multiple the width by
  8938. * @param h factor to multiple the height by
  8939. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8940. */
  8941. multiplyByFloats(w: number, h: number): Size;
  8942. /**
  8943. * Clones the size
  8944. * @returns a new Size copied from the given one.
  8945. */
  8946. clone(): Size;
  8947. /**
  8948. * True if the current Size and the given one width and height are strictly equal.
  8949. * @param other the other size to compare against
  8950. * @returns True if the current Size and the given one width and height are strictly equal.
  8951. */
  8952. equals(other: Size): boolean;
  8953. /**
  8954. * The surface of the Size : width * height (float).
  8955. */
  8956. get surface(): number;
  8957. /**
  8958. * Create a new size of zero
  8959. * @returns a new Size set to (0.0, 0.0)
  8960. */
  8961. static Zero(): Size;
  8962. /**
  8963. * Sums the width and height of two sizes
  8964. * @param otherSize size to add to this size
  8965. * @returns a new Size set as the addition result of the current Size and the given one.
  8966. */
  8967. add(otherSize: Size): Size;
  8968. /**
  8969. * Subtracts the width and height of two
  8970. * @param otherSize size to subtract to this size
  8971. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8972. */
  8973. subtract(otherSize: Size): Size;
  8974. /**
  8975. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8976. * @param start starting size to lerp between
  8977. * @param end end size to lerp between
  8978. * @param amount amount to lerp between the start and end values
  8979. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8980. */
  8981. static Lerp(start: Size, end: Size, amount: number): Size;
  8982. }
  8983. }
  8984. declare module BABYLON {
  8985. /**
  8986. * Contains position and normal vectors for a vertex
  8987. */
  8988. export class PositionNormalVertex {
  8989. /** the position of the vertex (defaut: 0,0,0) */
  8990. position: Vector3;
  8991. /** the normal of the vertex (defaut: 0,1,0) */
  8992. normal: Vector3;
  8993. /**
  8994. * Creates a PositionNormalVertex
  8995. * @param position the position of the vertex (defaut: 0,0,0)
  8996. * @param normal the normal of the vertex (defaut: 0,1,0)
  8997. */
  8998. constructor(
  8999. /** the position of the vertex (defaut: 0,0,0) */
  9000. position?: Vector3,
  9001. /** the normal of the vertex (defaut: 0,1,0) */
  9002. normal?: Vector3);
  9003. /**
  9004. * Clones the PositionNormalVertex
  9005. * @returns the cloned PositionNormalVertex
  9006. */
  9007. clone(): PositionNormalVertex;
  9008. }
  9009. /**
  9010. * Contains position, normal and uv vectors for a vertex
  9011. */
  9012. export class PositionNormalTextureVertex {
  9013. /** the position of the vertex (defaut: 0,0,0) */
  9014. position: Vector3;
  9015. /** the normal of the vertex (defaut: 0,1,0) */
  9016. normal: Vector3;
  9017. /** the uv of the vertex (default: 0,0) */
  9018. uv: Vector2;
  9019. /**
  9020. * Creates a PositionNormalTextureVertex
  9021. * @param position the position of the vertex (defaut: 0,0,0)
  9022. * @param normal the normal of the vertex (defaut: 0,1,0)
  9023. * @param uv the uv of the vertex (default: 0,0)
  9024. */
  9025. constructor(
  9026. /** the position of the vertex (defaut: 0,0,0) */
  9027. position?: Vector3,
  9028. /** the normal of the vertex (defaut: 0,1,0) */
  9029. normal?: Vector3,
  9030. /** the uv of the vertex (default: 0,0) */
  9031. uv?: Vector2);
  9032. /**
  9033. * Clones the PositionNormalTextureVertex
  9034. * @returns the cloned PositionNormalTextureVertex
  9035. */
  9036. clone(): PositionNormalTextureVertex;
  9037. }
  9038. }
  9039. declare module BABYLON {
  9040. /**
  9041. * Enum defining the type of animations supported by InputBlock
  9042. */
  9043. export enum AnimatedInputBlockTypes {
  9044. /** No animation */
  9045. None = 0,
  9046. /** Time based animation. Will only work for floats */
  9047. Time = 1
  9048. }
  9049. }
  9050. declare module BABYLON {
  9051. /**
  9052. * Interface describing all the common properties and methods a shadow light needs to implement.
  9053. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9054. * as well as binding the different shadow properties to the effects.
  9055. */
  9056. export interface IShadowLight extends Light {
  9057. /**
  9058. * The light id in the scene (used in scene.findLighById for instance)
  9059. */
  9060. id: string;
  9061. /**
  9062. * The position the shdow will be casted from.
  9063. */
  9064. position: Vector3;
  9065. /**
  9066. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9067. */
  9068. direction: Vector3;
  9069. /**
  9070. * The transformed position. Position of the light in world space taking parenting in account.
  9071. */
  9072. transformedPosition: Vector3;
  9073. /**
  9074. * The transformed direction. Direction of the light in world space taking parenting in account.
  9075. */
  9076. transformedDirection: Vector3;
  9077. /**
  9078. * The friendly name of the light in the scene.
  9079. */
  9080. name: string;
  9081. /**
  9082. * Defines the shadow projection clipping minimum z value.
  9083. */
  9084. shadowMinZ: number;
  9085. /**
  9086. * Defines the shadow projection clipping maximum z value.
  9087. */
  9088. shadowMaxZ: number;
  9089. /**
  9090. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9091. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9092. */
  9093. computeTransformedInformation(): boolean;
  9094. /**
  9095. * Gets the scene the light belongs to.
  9096. * @returns The scene
  9097. */
  9098. getScene(): Scene;
  9099. /**
  9100. * Callback defining a custom Projection Matrix Builder.
  9101. * This can be used to override the default projection matrix computation.
  9102. */
  9103. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9104. /**
  9105. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9106. * @param matrix The materix to updated with the projection information
  9107. * @param viewMatrix The transform matrix of the light
  9108. * @param renderList The list of mesh to render in the map
  9109. * @returns The current light
  9110. */
  9111. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9112. /**
  9113. * Gets the current depth scale used in ESM.
  9114. * @returns The scale
  9115. */
  9116. getDepthScale(): number;
  9117. /**
  9118. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9119. * @returns true if a cube texture needs to be use
  9120. */
  9121. needCube(): boolean;
  9122. /**
  9123. * Detects if the projection matrix requires to be recomputed this frame.
  9124. * @returns true if it requires to be recomputed otherwise, false.
  9125. */
  9126. needProjectionMatrixCompute(): boolean;
  9127. /**
  9128. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9129. */
  9130. forceProjectionMatrixCompute(): void;
  9131. /**
  9132. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9133. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9134. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9135. */
  9136. getShadowDirection(faceIndex?: number): Vector3;
  9137. /**
  9138. * Gets the minZ used for shadow according to both the scene and the light.
  9139. * @param activeCamera The camera we are returning the min for
  9140. * @returns the depth min z
  9141. */
  9142. getDepthMinZ(activeCamera: Camera): number;
  9143. /**
  9144. * Gets the maxZ used for shadow according to both the scene and the light.
  9145. * @param activeCamera The camera we are returning the max for
  9146. * @returns the depth max z
  9147. */
  9148. getDepthMaxZ(activeCamera: Camera): number;
  9149. }
  9150. /**
  9151. * Base implementation IShadowLight
  9152. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9153. */
  9154. export abstract class ShadowLight extends Light implements IShadowLight {
  9155. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9156. protected _position: Vector3;
  9157. protected _setPosition(value: Vector3): void;
  9158. /**
  9159. * Sets the position the shadow will be casted from. Also use as the light position for both
  9160. * point and spot lights.
  9161. */
  9162. get position(): Vector3;
  9163. /**
  9164. * Sets the position the shadow will be casted from. Also use as the light position for both
  9165. * point and spot lights.
  9166. */
  9167. set position(value: Vector3);
  9168. protected _direction: Vector3;
  9169. protected _setDirection(value: Vector3): void;
  9170. /**
  9171. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9172. * Also use as the light direction on spot and directional lights.
  9173. */
  9174. get direction(): Vector3;
  9175. /**
  9176. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9177. * Also use as the light direction on spot and directional lights.
  9178. */
  9179. set direction(value: Vector3);
  9180. protected _shadowMinZ: number;
  9181. /**
  9182. * Gets the shadow projection clipping minimum z value.
  9183. */
  9184. get shadowMinZ(): number;
  9185. /**
  9186. * Sets the shadow projection clipping minimum z value.
  9187. */
  9188. set shadowMinZ(value: number);
  9189. protected _shadowMaxZ: number;
  9190. /**
  9191. * Sets the shadow projection clipping maximum z value.
  9192. */
  9193. get shadowMaxZ(): number;
  9194. /**
  9195. * Gets the shadow projection clipping maximum z value.
  9196. */
  9197. set shadowMaxZ(value: number);
  9198. /**
  9199. * Callback defining a custom Projection Matrix Builder.
  9200. * This can be used to override the default projection matrix computation.
  9201. */
  9202. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9203. /**
  9204. * The transformed position. Position of the light in world space taking parenting in account.
  9205. */
  9206. transformedPosition: Vector3;
  9207. /**
  9208. * The transformed direction. Direction of the light in world space taking parenting in account.
  9209. */
  9210. transformedDirection: Vector3;
  9211. private _needProjectionMatrixCompute;
  9212. /**
  9213. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9214. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9215. */
  9216. computeTransformedInformation(): boolean;
  9217. /**
  9218. * Return the depth scale used for the shadow map.
  9219. * @returns the depth scale.
  9220. */
  9221. getDepthScale(): number;
  9222. /**
  9223. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9224. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9225. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9226. */
  9227. getShadowDirection(faceIndex?: number): Vector3;
  9228. /**
  9229. * Returns the ShadowLight absolute position in the World.
  9230. * @returns the position vector in world space
  9231. */
  9232. getAbsolutePosition(): Vector3;
  9233. /**
  9234. * Sets the ShadowLight direction toward the passed target.
  9235. * @param target The point to target in local space
  9236. * @returns the updated ShadowLight direction
  9237. */
  9238. setDirectionToTarget(target: Vector3): Vector3;
  9239. /**
  9240. * Returns the light rotation in euler definition.
  9241. * @returns the x y z rotation in local space.
  9242. */
  9243. getRotation(): Vector3;
  9244. /**
  9245. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9246. * @returns true if a cube texture needs to be use
  9247. */
  9248. needCube(): boolean;
  9249. /**
  9250. * Detects if the projection matrix requires to be recomputed this frame.
  9251. * @returns true if it requires to be recomputed otherwise, false.
  9252. */
  9253. needProjectionMatrixCompute(): boolean;
  9254. /**
  9255. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9256. */
  9257. forceProjectionMatrixCompute(): void;
  9258. /** @hidden */
  9259. _initCache(): void;
  9260. /** @hidden */
  9261. _isSynchronized(): boolean;
  9262. /**
  9263. * Computes the world matrix of the node
  9264. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9265. * @returns the world matrix
  9266. */
  9267. computeWorldMatrix(force?: boolean): Matrix;
  9268. /**
  9269. * Gets the minZ used for shadow according to both the scene and the light.
  9270. * @param activeCamera The camera we are returning the min for
  9271. * @returns the depth min z
  9272. */
  9273. getDepthMinZ(activeCamera: Camera): number;
  9274. /**
  9275. * Gets the maxZ used for shadow according to both the scene and the light.
  9276. * @param activeCamera The camera we are returning the max for
  9277. * @returns the depth max z
  9278. */
  9279. getDepthMaxZ(activeCamera: Camera): number;
  9280. /**
  9281. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9282. * @param matrix The materix to updated with the projection information
  9283. * @param viewMatrix The transform matrix of the light
  9284. * @param renderList The list of mesh to render in the map
  9285. * @returns The current light
  9286. */
  9287. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9288. }
  9289. }
  9290. declare module BABYLON {
  9291. /** @hidden */
  9292. export var packingFunctions: {
  9293. name: string;
  9294. shader: string;
  9295. };
  9296. }
  9297. declare module BABYLON {
  9298. /** @hidden */
  9299. export var bayerDitherFunctions: {
  9300. name: string;
  9301. shader: string;
  9302. };
  9303. }
  9304. declare module BABYLON {
  9305. /** @hidden */
  9306. export var shadowMapFragmentDeclaration: {
  9307. name: string;
  9308. shader: string;
  9309. };
  9310. }
  9311. declare module BABYLON {
  9312. /** @hidden */
  9313. export var clipPlaneFragmentDeclaration: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module BABYLON {
  9319. /** @hidden */
  9320. export var clipPlaneFragment: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module BABYLON {
  9326. /** @hidden */
  9327. export var shadowMapFragment: {
  9328. name: string;
  9329. shader: string;
  9330. };
  9331. }
  9332. declare module BABYLON {
  9333. /** @hidden */
  9334. export var shadowMapPixelShader: {
  9335. name: string;
  9336. shader: string;
  9337. };
  9338. }
  9339. declare module BABYLON {
  9340. /** @hidden */
  9341. export var bonesDeclaration: {
  9342. name: string;
  9343. shader: string;
  9344. };
  9345. }
  9346. declare module BABYLON {
  9347. /** @hidden */
  9348. export var morphTargetsVertexGlobalDeclaration: {
  9349. name: string;
  9350. shader: string;
  9351. };
  9352. }
  9353. declare module BABYLON {
  9354. /** @hidden */
  9355. export var morphTargetsVertexDeclaration: {
  9356. name: string;
  9357. shader: string;
  9358. };
  9359. }
  9360. declare module BABYLON {
  9361. /** @hidden */
  9362. export var instancesDeclaration: {
  9363. name: string;
  9364. shader: string;
  9365. };
  9366. }
  9367. declare module BABYLON {
  9368. /** @hidden */
  9369. export var helperFunctions: {
  9370. name: string;
  9371. shader: string;
  9372. };
  9373. }
  9374. declare module BABYLON {
  9375. /** @hidden */
  9376. export var shadowMapVertexDeclaration: {
  9377. name: string;
  9378. shader: string;
  9379. };
  9380. }
  9381. declare module BABYLON {
  9382. /** @hidden */
  9383. export var clipPlaneVertexDeclaration: {
  9384. name: string;
  9385. shader: string;
  9386. };
  9387. }
  9388. declare module BABYLON {
  9389. /** @hidden */
  9390. export var morphTargetsVertex: {
  9391. name: string;
  9392. shader: string;
  9393. };
  9394. }
  9395. declare module BABYLON {
  9396. /** @hidden */
  9397. export var instancesVertex: {
  9398. name: string;
  9399. shader: string;
  9400. };
  9401. }
  9402. declare module BABYLON {
  9403. /** @hidden */
  9404. export var bonesVertex: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module BABYLON {
  9410. /** @hidden */
  9411. export var shadowMapVertexNormalBias: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module BABYLON {
  9417. /** @hidden */
  9418. export var shadowMapVertexMetric: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module BABYLON {
  9424. /** @hidden */
  9425. export var clipPlaneVertex: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module BABYLON {
  9431. /** @hidden */
  9432. export var shadowMapVertexShader: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module BABYLON {
  9438. /** @hidden */
  9439. export var depthBoxBlurPixelShader: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module BABYLON {
  9445. /** @hidden */
  9446. export var shadowMapFragmentSoftTransparentShadow: {
  9447. name: string;
  9448. shader: string;
  9449. };
  9450. }
  9451. declare module BABYLON {
  9452. /**
  9453. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9454. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9455. */
  9456. export class EffectFallbacks implements IEffectFallbacks {
  9457. private _defines;
  9458. private _currentRank;
  9459. private _maxRank;
  9460. private _mesh;
  9461. /**
  9462. * Removes the fallback from the bound mesh.
  9463. */
  9464. unBindMesh(): void;
  9465. /**
  9466. * Adds a fallback on the specified property.
  9467. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9468. * @param define The name of the define in the shader
  9469. */
  9470. addFallback(rank: number, define: string): void;
  9471. /**
  9472. * Sets the mesh to use CPU skinning when needing to fallback.
  9473. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9474. * @param mesh The mesh to use the fallbacks.
  9475. */
  9476. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9477. /**
  9478. * Checks to see if more fallbacks are still availible.
  9479. */
  9480. get hasMoreFallbacks(): boolean;
  9481. /**
  9482. * Removes the defines that should be removed when falling back.
  9483. * @param currentDefines defines the current define statements for the shader.
  9484. * @param effect defines the current effect we try to compile
  9485. * @returns The resulting defines with defines of the current rank removed.
  9486. */
  9487. reduce(currentDefines: string, effect: Effect): string;
  9488. }
  9489. }
  9490. declare module BABYLON {
  9491. /**
  9492. * Interface used to define Action
  9493. */
  9494. export interface IAction {
  9495. /**
  9496. * Trigger for the action
  9497. */
  9498. trigger: number;
  9499. /** Options of the trigger */
  9500. triggerOptions: any;
  9501. /**
  9502. * Gets the trigger parameters
  9503. * @returns the trigger parameters
  9504. */
  9505. getTriggerParameter(): any;
  9506. /**
  9507. * Internal only - executes current action event
  9508. * @hidden
  9509. */
  9510. _executeCurrent(evt?: ActionEvent): void;
  9511. /**
  9512. * Serialize placeholder for child classes
  9513. * @param parent of child
  9514. * @returns the serialized object
  9515. */
  9516. serialize(parent: any): any;
  9517. /**
  9518. * Internal only
  9519. * @hidden
  9520. */
  9521. _prepare(): void;
  9522. /**
  9523. * Internal only - manager for action
  9524. * @hidden
  9525. */
  9526. _actionManager: Nullable<AbstractActionManager>;
  9527. /**
  9528. * Adds action to chain of actions, may be a DoNothingAction
  9529. * @param action defines the next action to execute
  9530. * @returns The action passed in
  9531. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9532. */
  9533. then(action: IAction): IAction;
  9534. }
  9535. /**
  9536. * The action to be carried out following a trigger
  9537. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9538. */
  9539. export class Action implements IAction {
  9540. /** the trigger, with or without parameters, for the action */
  9541. triggerOptions: any;
  9542. /**
  9543. * Trigger for the action
  9544. */
  9545. trigger: number;
  9546. /**
  9547. * Internal only - manager for action
  9548. * @hidden
  9549. */
  9550. _actionManager: ActionManager;
  9551. private _nextActiveAction;
  9552. private _child;
  9553. private _condition?;
  9554. private _triggerParameter;
  9555. /**
  9556. * An event triggered prior to action being executed.
  9557. */
  9558. onBeforeExecuteObservable: Observable<Action>;
  9559. /**
  9560. * Creates a new Action
  9561. * @param triggerOptions the trigger, with or without parameters, for the action
  9562. * @param condition an optional determinant of action
  9563. */
  9564. constructor(
  9565. /** the trigger, with or without parameters, for the action */
  9566. triggerOptions: any, condition?: Condition);
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _prepare(): void;
  9572. /**
  9573. * Gets the trigger parameters
  9574. * @returns the trigger parameters
  9575. */
  9576. getTriggerParameter(): any;
  9577. /**
  9578. * Internal only - executes current action event
  9579. * @hidden
  9580. */
  9581. _executeCurrent(evt?: ActionEvent): void;
  9582. /**
  9583. * Execute placeholder for child classes
  9584. * @param evt optional action event
  9585. */
  9586. execute(evt?: ActionEvent): void;
  9587. /**
  9588. * Skips to next active action
  9589. */
  9590. skipToNextActiveAction(): void;
  9591. /**
  9592. * Adds action to chain of actions, may be a DoNothingAction
  9593. * @param action defines the next action to execute
  9594. * @returns The action passed in
  9595. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9596. */
  9597. then(action: Action): Action;
  9598. /**
  9599. * Internal only
  9600. * @hidden
  9601. */
  9602. _getProperty(propertyPath: string): string;
  9603. /**
  9604. * Internal only
  9605. * @hidden
  9606. */
  9607. _getEffectiveTarget(target: any, propertyPath: string): any;
  9608. /**
  9609. * Serialize placeholder for child classes
  9610. * @param parent of child
  9611. * @returns the serialized object
  9612. */
  9613. serialize(parent: any): any;
  9614. /**
  9615. * Internal only called by serialize
  9616. * @hidden
  9617. */
  9618. protected _serialize(serializedAction: any, parent?: any): any;
  9619. /**
  9620. * Internal only
  9621. * @hidden
  9622. */
  9623. static _SerializeValueAsString: (value: any) => string;
  9624. /**
  9625. * Internal only
  9626. * @hidden
  9627. */
  9628. static _GetTargetProperty: (target: Scene | Node) => {
  9629. name: string;
  9630. targetType: string;
  9631. value: string;
  9632. };
  9633. }
  9634. }
  9635. declare module BABYLON {
  9636. /**
  9637. * A Condition applied to an Action
  9638. */
  9639. export class Condition {
  9640. /**
  9641. * Internal only - manager for action
  9642. * @hidden
  9643. */
  9644. _actionManager: ActionManager;
  9645. /**
  9646. * Internal only
  9647. * @hidden
  9648. */
  9649. _evaluationId: number;
  9650. /**
  9651. * Internal only
  9652. * @hidden
  9653. */
  9654. _currentResult: boolean;
  9655. /**
  9656. * Creates a new Condition
  9657. * @param actionManager the manager of the action the condition is applied to
  9658. */
  9659. constructor(actionManager: ActionManager);
  9660. /**
  9661. * Check if the current condition is valid
  9662. * @returns a boolean
  9663. */
  9664. isValid(): boolean;
  9665. /**
  9666. * Internal only
  9667. * @hidden
  9668. */
  9669. _getProperty(propertyPath: string): string;
  9670. /**
  9671. * Internal only
  9672. * @hidden
  9673. */
  9674. _getEffectiveTarget(target: any, propertyPath: string): any;
  9675. /**
  9676. * Serialize placeholder for child classes
  9677. * @returns the serialized object
  9678. */
  9679. serialize(): any;
  9680. /**
  9681. * Internal only
  9682. * @hidden
  9683. */
  9684. protected _serialize(serializedCondition: any): any;
  9685. }
  9686. /**
  9687. * Defines specific conditional operators as extensions of Condition
  9688. */
  9689. export class ValueCondition extends Condition {
  9690. /** path to specify the property of the target the conditional operator uses */
  9691. propertyPath: string;
  9692. /** the value compared by the conditional operator against the current value of the property */
  9693. value: any;
  9694. /** the conditional operator, default ValueCondition.IsEqual */
  9695. operator: number;
  9696. /**
  9697. * Internal only
  9698. * @hidden
  9699. */
  9700. private static _IsEqual;
  9701. /**
  9702. * Internal only
  9703. * @hidden
  9704. */
  9705. private static _IsDifferent;
  9706. /**
  9707. * Internal only
  9708. * @hidden
  9709. */
  9710. private static _IsGreater;
  9711. /**
  9712. * Internal only
  9713. * @hidden
  9714. */
  9715. private static _IsLesser;
  9716. /**
  9717. * returns the number for IsEqual
  9718. */
  9719. static get IsEqual(): number;
  9720. /**
  9721. * Returns the number for IsDifferent
  9722. */
  9723. static get IsDifferent(): number;
  9724. /**
  9725. * Returns the number for IsGreater
  9726. */
  9727. static get IsGreater(): number;
  9728. /**
  9729. * Returns the number for IsLesser
  9730. */
  9731. static get IsLesser(): number;
  9732. /**
  9733. * Internal only The action manager for the condition
  9734. * @hidden
  9735. */
  9736. _actionManager: ActionManager;
  9737. /**
  9738. * Internal only
  9739. * @hidden
  9740. */
  9741. private _target;
  9742. /**
  9743. * Internal only
  9744. * @hidden
  9745. */
  9746. private _effectiveTarget;
  9747. /**
  9748. * Internal only
  9749. * @hidden
  9750. */
  9751. private _property;
  9752. /**
  9753. * Creates a new ValueCondition
  9754. * @param actionManager manager for the action the condition applies to
  9755. * @param target for the action
  9756. * @param propertyPath path to specify the property of the target the conditional operator uses
  9757. * @param value the value compared by the conditional operator against the current value of the property
  9758. * @param operator the conditional operator, default ValueCondition.IsEqual
  9759. */
  9760. constructor(actionManager: ActionManager, target: any,
  9761. /** path to specify the property of the target the conditional operator uses */
  9762. propertyPath: string,
  9763. /** the value compared by the conditional operator against the current value of the property */
  9764. value: any,
  9765. /** the conditional operator, default ValueCondition.IsEqual */
  9766. operator?: number);
  9767. /**
  9768. * Compares the given value with the property value for the specified conditional operator
  9769. * @returns the result of the comparison
  9770. */
  9771. isValid(): boolean;
  9772. /**
  9773. * Serialize the ValueCondition into a JSON compatible object
  9774. * @returns serialization object
  9775. */
  9776. serialize(): any;
  9777. /**
  9778. * Gets the name of the conditional operator for the ValueCondition
  9779. * @param operator the conditional operator
  9780. * @returns the name
  9781. */
  9782. static GetOperatorName(operator: number): string;
  9783. }
  9784. /**
  9785. * Defines a predicate condition as an extension of Condition
  9786. */
  9787. export class PredicateCondition extends Condition {
  9788. /** defines the predicate function used to validate the condition */
  9789. predicate: () => boolean;
  9790. /**
  9791. * Internal only - manager for action
  9792. * @hidden
  9793. */
  9794. _actionManager: ActionManager;
  9795. /**
  9796. * Creates a new PredicateCondition
  9797. * @param actionManager manager for the action the condition applies to
  9798. * @param predicate defines the predicate function used to validate the condition
  9799. */
  9800. constructor(actionManager: ActionManager,
  9801. /** defines the predicate function used to validate the condition */
  9802. predicate: () => boolean);
  9803. /**
  9804. * @returns the validity of the predicate condition
  9805. */
  9806. isValid(): boolean;
  9807. }
  9808. /**
  9809. * Defines a state condition as an extension of Condition
  9810. */
  9811. export class StateCondition extends Condition {
  9812. /** Value to compare with target state */
  9813. value: string;
  9814. /**
  9815. * Internal only - manager for action
  9816. * @hidden
  9817. */
  9818. _actionManager: ActionManager;
  9819. /**
  9820. * Internal only
  9821. * @hidden
  9822. */
  9823. private _target;
  9824. /**
  9825. * Creates a new StateCondition
  9826. * @param actionManager manager for the action the condition applies to
  9827. * @param target of the condition
  9828. * @param value to compare with target state
  9829. */
  9830. constructor(actionManager: ActionManager, target: any,
  9831. /** Value to compare with target state */
  9832. value: string);
  9833. /**
  9834. * Gets a boolean indicating if the current condition is met
  9835. * @returns the validity of the state
  9836. */
  9837. isValid(): boolean;
  9838. /**
  9839. * Serialize the StateCondition into a JSON compatible object
  9840. * @returns serialization object
  9841. */
  9842. serialize(): any;
  9843. }
  9844. }
  9845. declare module BABYLON {
  9846. /**
  9847. * This defines an action responsible to toggle a boolean once triggered.
  9848. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9849. */
  9850. export class SwitchBooleanAction extends Action {
  9851. /**
  9852. * The path to the boolean property in the target object
  9853. */
  9854. propertyPath: string;
  9855. private _target;
  9856. private _effectiveTarget;
  9857. private _property;
  9858. /**
  9859. * Instantiate the action
  9860. * @param triggerOptions defines the trigger options
  9861. * @param target defines the object containing the boolean
  9862. * @param propertyPath defines the path to the boolean property in the target object
  9863. * @param condition defines the trigger related conditions
  9864. */
  9865. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9866. /** @hidden */
  9867. _prepare(): void;
  9868. /**
  9869. * Execute the action toggle the boolean value.
  9870. */
  9871. execute(): void;
  9872. /**
  9873. * Serializes the actions and its related information.
  9874. * @param parent defines the object to serialize in
  9875. * @returns the serialized object
  9876. */
  9877. serialize(parent: any): any;
  9878. }
  9879. /**
  9880. * This defines an action responsible to set a the state field of the target
  9881. * to a desired value once triggered.
  9882. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9883. */
  9884. export class SetStateAction extends Action {
  9885. /**
  9886. * The value to store in the state field.
  9887. */
  9888. value: string;
  9889. private _target;
  9890. /**
  9891. * Instantiate the action
  9892. * @param triggerOptions defines the trigger options
  9893. * @param target defines the object containing the state property
  9894. * @param value defines the value to store in the state field
  9895. * @param condition defines the trigger related conditions
  9896. */
  9897. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9898. /**
  9899. * Execute the action and store the value on the target state property.
  9900. */
  9901. execute(): void;
  9902. /**
  9903. * Serializes the actions and its related information.
  9904. * @param parent defines the object to serialize in
  9905. * @returns the serialized object
  9906. */
  9907. serialize(parent: any): any;
  9908. }
  9909. /**
  9910. * This defines an action responsible to set a property of the target
  9911. * to a desired value once triggered.
  9912. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9913. */
  9914. export class SetValueAction extends Action {
  9915. /**
  9916. * The path of the property to set in the target.
  9917. */
  9918. propertyPath: string;
  9919. /**
  9920. * The value to set in the property
  9921. */
  9922. value: any;
  9923. private _target;
  9924. private _effectiveTarget;
  9925. private _property;
  9926. /**
  9927. * Instantiate the action
  9928. * @param triggerOptions defines the trigger options
  9929. * @param target defines the object containing the property
  9930. * @param propertyPath defines the path of the property to set in the target
  9931. * @param value defines the value to set in the property
  9932. * @param condition defines the trigger related conditions
  9933. */
  9934. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9935. /** @hidden */
  9936. _prepare(): void;
  9937. /**
  9938. * Execute the action and set the targetted property to the desired value.
  9939. */
  9940. execute(): void;
  9941. /**
  9942. * Serializes the actions and its related information.
  9943. * @param parent defines the object to serialize in
  9944. * @returns the serialized object
  9945. */
  9946. serialize(parent: any): any;
  9947. }
  9948. /**
  9949. * This defines an action responsible to increment the target value
  9950. * to a desired value once triggered.
  9951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9952. */
  9953. export class IncrementValueAction extends Action {
  9954. /**
  9955. * The path of the property to increment in the target.
  9956. */
  9957. propertyPath: string;
  9958. /**
  9959. * The value we should increment the property by.
  9960. */
  9961. value: any;
  9962. private _target;
  9963. private _effectiveTarget;
  9964. private _property;
  9965. /**
  9966. * Instantiate the action
  9967. * @param triggerOptions defines the trigger options
  9968. * @param target defines the object containing the property
  9969. * @param propertyPath defines the path of the property to increment in the target
  9970. * @param value defines the value value we should increment the property by
  9971. * @param condition defines the trigger related conditions
  9972. */
  9973. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9974. /** @hidden */
  9975. _prepare(): void;
  9976. /**
  9977. * Execute the action and increment the target of the value amount.
  9978. */
  9979. execute(): void;
  9980. /**
  9981. * Serializes the actions and its related information.
  9982. * @param parent defines the object to serialize in
  9983. * @returns the serialized object
  9984. */
  9985. serialize(parent: any): any;
  9986. }
  9987. /**
  9988. * This defines an action responsible to start an animation once triggered.
  9989. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9990. */
  9991. export class PlayAnimationAction extends Action {
  9992. /**
  9993. * Where the animation should start (animation frame)
  9994. */
  9995. from: number;
  9996. /**
  9997. * Where the animation should stop (animation frame)
  9998. */
  9999. to: number;
  10000. /**
  10001. * Define if the animation should loop or stop after the first play.
  10002. */
  10003. loop?: boolean;
  10004. private _target;
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param target defines the target animation or animation name
  10009. * @param from defines from where the animation should start (animation frame)
  10010. * @param end defines where the animation should stop (animation frame)
  10011. * @param loop defines if the animation should loop or stop after the first play
  10012. * @param condition defines the trigger related conditions
  10013. */
  10014. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10015. /** @hidden */
  10016. _prepare(): void;
  10017. /**
  10018. * Execute the action and play the animation.
  10019. */
  10020. execute(): void;
  10021. /**
  10022. * Serializes the actions and its related information.
  10023. * @param parent defines the object to serialize in
  10024. * @returns the serialized object
  10025. */
  10026. serialize(parent: any): any;
  10027. }
  10028. /**
  10029. * This defines an action responsible to stop an animation once triggered.
  10030. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10031. */
  10032. export class StopAnimationAction extends Action {
  10033. private _target;
  10034. /**
  10035. * Instantiate the action
  10036. * @param triggerOptions defines the trigger options
  10037. * @param target defines the target animation or animation name
  10038. * @param condition defines the trigger related conditions
  10039. */
  10040. constructor(triggerOptions: any, target: any, condition?: Condition);
  10041. /** @hidden */
  10042. _prepare(): void;
  10043. /**
  10044. * Execute the action and stop the animation.
  10045. */
  10046. execute(): void;
  10047. /**
  10048. * Serializes the actions and its related information.
  10049. * @param parent defines the object to serialize in
  10050. * @returns the serialized object
  10051. */
  10052. serialize(parent: any): any;
  10053. }
  10054. /**
  10055. * This defines an action responsible that does nothing once triggered.
  10056. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10057. */
  10058. export class DoNothingAction extends Action {
  10059. /**
  10060. * Instantiate the action
  10061. * @param triggerOptions defines the trigger options
  10062. * @param condition defines the trigger related conditions
  10063. */
  10064. constructor(triggerOptions?: any, condition?: Condition);
  10065. /**
  10066. * Execute the action and do nothing.
  10067. */
  10068. execute(): void;
  10069. /**
  10070. * Serializes the actions and its related information.
  10071. * @param parent defines the object to serialize in
  10072. * @returns the serialized object
  10073. */
  10074. serialize(parent: any): any;
  10075. }
  10076. /**
  10077. * This defines an action responsible to trigger several actions once triggered.
  10078. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10079. */
  10080. export class CombineAction extends Action {
  10081. /**
  10082. * The list of aggregated animations to run.
  10083. */
  10084. children: Action[];
  10085. /**
  10086. * Instantiate the action
  10087. * @param triggerOptions defines the trigger options
  10088. * @param children defines the list of aggregated animations to run
  10089. * @param condition defines the trigger related conditions
  10090. */
  10091. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10092. /** @hidden */
  10093. _prepare(): void;
  10094. /**
  10095. * Execute the action and executes all the aggregated actions.
  10096. */
  10097. execute(evt: ActionEvent): void;
  10098. /**
  10099. * Serializes the actions and its related information.
  10100. * @param parent defines the object to serialize in
  10101. * @returns the serialized object
  10102. */
  10103. serialize(parent: any): any;
  10104. }
  10105. /**
  10106. * This defines an action responsible to run code (external event) once triggered.
  10107. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10108. */
  10109. export class ExecuteCodeAction extends Action {
  10110. /**
  10111. * The callback function to run.
  10112. */
  10113. func: (evt: ActionEvent) => void;
  10114. /**
  10115. * Instantiate the action
  10116. * @param triggerOptions defines the trigger options
  10117. * @param func defines the callback function to run
  10118. * @param condition defines the trigger related conditions
  10119. */
  10120. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10121. /**
  10122. * Execute the action and run the attached code.
  10123. */
  10124. execute(evt: ActionEvent): void;
  10125. }
  10126. /**
  10127. * This defines an action responsible to set the parent property of the target once triggered.
  10128. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10129. */
  10130. export class SetParentAction extends Action {
  10131. private _parent;
  10132. private _target;
  10133. /**
  10134. * Instantiate the action
  10135. * @param triggerOptions defines the trigger options
  10136. * @param target defines the target containing the parent property
  10137. * @param parent defines from where the animation should start (animation frame)
  10138. * @param condition defines the trigger related conditions
  10139. */
  10140. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10141. /** @hidden */
  10142. _prepare(): void;
  10143. /**
  10144. * Execute the action and set the parent property.
  10145. */
  10146. execute(): void;
  10147. /**
  10148. * Serializes the actions and its related information.
  10149. * @param parent defines the object to serialize in
  10150. * @returns the serialized object
  10151. */
  10152. serialize(parent: any): any;
  10153. }
  10154. }
  10155. declare module BABYLON {
  10156. /**
  10157. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10158. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10159. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10160. */
  10161. export class ActionManager extends AbstractActionManager {
  10162. /**
  10163. * Nothing
  10164. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10165. */
  10166. static readonly NothingTrigger: number;
  10167. /**
  10168. * On pick
  10169. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10170. */
  10171. static readonly OnPickTrigger: number;
  10172. /**
  10173. * On left pick
  10174. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10175. */
  10176. static readonly OnLeftPickTrigger: number;
  10177. /**
  10178. * On right pick
  10179. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10180. */
  10181. static readonly OnRightPickTrigger: number;
  10182. /**
  10183. * On center pick
  10184. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10185. */
  10186. static readonly OnCenterPickTrigger: number;
  10187. /**
  10188. * On pick down
  10189. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10190. */
  10191. static readonly OnPickDownTrigger: number;
  10192. /**
  10193. * On double pick
  10194. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10195. */
  10196. static readonly OnDoublePickTrigger: number;
  10197. /**
  10198. * On pick up
  10199. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10200. */
  10201. static readonly OnPickUpTrigger: number;
  10202. /**
  10203. * On pick out.
  10204. * This trigger will only be raised if you also declared a OnPickDown
  10205. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10206. */
  10207. static readonly OnPickOutTrigger: number;
  10208. /**
  10209. * On long press
  10210. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10211. */
  10212. static readonly OnLongPressTrigger: number;
  10213. /**
  10214. * On pointer over
  10215. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10216. */
  10217. static readonly OnPointerOverTrigger: number;
  10218. /**
  10219. * On pointer out
  10220. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10221. */
  10222. static readonly OnPointerOutTrigger: number;
  10223. /**
  10224. * On every frame
  10225. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10226. */
  10227. static readonly OnEveryFrameTrigger: number;
  10228. /**
  10229. * On intersection enter
  10230. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10231. */
  10232. static readonly OnIntersectionEnterTrigger: number;
  10233. /**
  10234. * On intersection exit
  10235. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10236. */
  10237. static readonly OnIntersectionExitTrigger: number;
  10238. /**
  10239. * On key down
  10240. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10241. */
  10242. static readonly OnKeyDownTrigger: number;
  10243. /**
  10244. * On key up
  10245. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10246. */
  10247. static readonly OnKeyUpTrigger: number;
  10248. private _scene;
  10249. /**
  10250. * Creates a new action manager
  10251. * @param scene defines the hosting scene
  10252. */
  10253. constructor(scene: Scene);
  10254. /**
  10255. * Releases all associated resources
  10256. */
  10257. dispose(): void;
  10258. /**
  10259. * Gets hosting scene
  10260. * @returns the hosting scene
  10261. */
  10262. getScene(): Scene;
  10263. /**
  10264. * Does this action manager handles actions of any of the given triggers
  10265. * @param triggers defines the triggers to be tested
  10266. * @return a boolean indicating whether one (or more) of the triggers is handled
  10267. */
  10268. hasSpecificTriggers(triggers: number[]): boolean;
  10269. /**
  10270. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10271. * speed.
  10272. * @param triggerA defines the trigger to be tested
  10273. * @param triggerB defines the trigger to be tested
  10274. * @return a boolean indicating whether one (or more) of the triggers is handled
  10275. */
  10276. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10277. /**
  10278. * Does this action manager handles actions of a given trigger
  10279. * @param trigger defines the trigger to be tested
  10280. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10281. * @return whether the trigger is handled
  10282. */
  10283. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10284. /**
  10285. * Does this action manager has pointer triggers
  10286. */
  10287. get hasPointerTriggers(): boolean;
  10288. /**
  10289. * Does this action manager has pick triggers
  10290. */
  10291. get hasPickTriggers(): boolean;
  10292. /**
  10293. * Registers an action to this action manager
  10294. * @param action defines the action to be registered
  10295. * @return the action amended (prepared) after registration
  10296. */
  10297. registerAction(action: IAction): Nullable<IAction>;
  10298. /**
  10299. * Unregisters an action to this action manager
  10300. * @param action defines the action to be unregistered
  10301. * @return a boolean indicating whether the action has been unregistered
  10302. */
  10303. unregisterAction(action: IAction): Boolean;
  10304. /**
  10305. * Process a specific trigger
  10306. * @param trigger defines the trigger to process
  10307. * @param evt defines the event details to be processed
  10308. */
  10309. processTrigger(trigger: number, evt?: IActionEvent): void;
  10310. /** @hidden */
  10311. _getEffectiveTarget(target: any, propertyPath: string): any;
  10312. /** @hidden */
  10313. _getProperty(propertyPath: string): string;
  10314. /**
  10315. * Serialize this manager to a JSON object
  10316. * @param name defines the property name to store this manager
  10317. * @returns a JSON representation of this manager
  10318. */
  10319. serialize(name: string): any;
  10320. /**
  10321. * Creates a new ActionManager from a JSON data
  10322. * @param parsedActions defines the JSON data to read from
  10323. * @param object defines the hosting mesh
  10324. * @param scene defines the hosting scene
  10325. */
  10326. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10327. /**
  10328. * Get a trigger name by index
  10329. * @param trigger defines the trigger index
  10330. * @returns a trigger name
  10331. */
  10332. static GetTriggerName(trigger: number): string;
  10333. }
  10334. }
  10335. declare module BABYLON {
  10336. /**
  10337. * Class used to represent a sprite
  10338. * @see https://doc.babylonjs.com/babylon101/sprites
  10339. */
  10340. export class Sprite implements IAnimatable {
  10341. /** defines the name */
  10342. name: string;
  10343. /** Gets or sets the current world position */
  10344. position: Vector3;
  10345. /** Gets or sets the main color */
  10346. color: Color4;
  10347. /** Gets or sets the width */
  10348. width: number;
  10349. /** Gets or sets the height */
  10350. height: number;
  10351. /** Gets or sets rotation angle */
  10352. angle: number;
  10353. /** Gets or sets the cell index in the sprite sheet */
  10354. cellIndex: number;
  10355. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10356. cellRef: string;
  10357. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10358. invertU: boolean;
  10359. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10360. invertV: boolean;
  10361. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10362. disposeWhenFinishedAnimating: boolean;
  10363. /** Gets the list of attached animations */
  10364. animations: Nullable<Array<Animation>>;
  10365. /** Gets or sets a boolean indicating if the sprite can be picked */
  10366. isPickable: boolean;
  10367. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10368. useAlphaForPicking: boolean;
  10369. /** @hidden */
  10370. _xOffset: number;
  10371. /** @hidden */
  10372. _yOffset: number;
  10373. /** @hidden */
  10374. _xSize: number;
  10375. /** @hidden */
  10376. _ySize: number;
  10377. /**
  10378. * Gets or sets the associated action manager
  10379. */
  10380. actionManager: Nullable<ActionManager>;
  10381. /**
  10382. * An event triggered when the control has been disposed
  10383. */
  10384. onDisposeObservable: Observable<Sprite>;
  10385. private _animationStarted;
  10386. private _loopAnimation;
  10387. private _fromIndex;
  10388. private _toIndex;
  10389. private _delay;
  10390. private _direction;
  10391. private _manager;
  10392. private _time;
  10393. private _onAnimationEnd;
  10394. /**
  10395. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10396. */
  10397. isVisible: boolean;
  10398. /**
  10399. * Gets or sets the sprite size
  10400. */
  10401. get size(): number;
  10402. set size(value: number);
  10403. /**
  10404. * Returns a boolean indicating if the animation is started
  10405. */
  10406. get animationStarted(): boolean;
  10407. /**
  10408. * Gets or sets the unique id of the sprite
  10409. */
  10410. uniqueId: number;
  10411. /**
  10412. * Gets the manager of this sprite
  10413. */
  10414. get manager(): ISpriteManager;
  10415. /**
  10416. * Creates a new Sprite
  10417. * @param name defines the name
  10418. * @param manager defines the manager
  10419. */
  10420. constructor(
  10421. /** defines the name */
  10422. name: string, manager: ISpriteManager);
  10423. /**
  10424. * Returns the string "Sprite"
  10425. * @returns "Sprite"
  10426. */
  10427. getClassName(): string;
  10428. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10429. get fromIndex(): number;
  10430. set fromIndex(value: number);
  10431. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10432. get toIndex(): number;
  10433. set toIndex(value: number);
  10434. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10435. get loopAnimation(): boolean;
  10436. set loopAnimation(value: boolean);
  10437. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10438. get delay(): number;
  10439. set delay(value: number);
  10440. /**
  10441. * Starts an animation
  10442. * @param from defines the initial key
  10443. * @param to defines the end key
  10444. * @param loop defines if the animation must loop
  10445. * @param delay defines the start delay (in ms)
  10446. * @param onAnimationEnd defines a callback to call when animation ends
  10447. */
  10448. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10449. /** Stops current animation (if any) */
  10450. stopAnimation(): void;
  10451. /** @hidden */
  10452. _animate(deltaTime: number): void;
  10453. /** Release associated resources */
  10454. dispose(): void;
  10455. /**
  10456. * Serializes the sprite to a JSON object
  10457. * @returns the JSON object
  10458. */
  10459. serialize(): any;
  10460. /**
  10461. * Parses a JSON object to create a new sprite
  10462. * @param parsedSprite The JSON object to parse
  10463. * @param manager defines the hosting manager
  10464. * @returns the new sprite
  10465. */
  10466. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10467. }
  10468. }
  10469. declare module BABYLON {
  10470. /**
  10471. * Information about the result of picking within a scene
  10472. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10473. */
  10474. export class PickingInfo {
  10475. /** @hidden */
  10476. _pickingUnavailable: boolean;
  10477. /**
  10478. * If the pick collided with an object
  10479. */
  10480. hit: boolean;
  10481. /**
  10482. * Distance away where the pick collided
  10483. */
  10484. distance: number;
  10485. /**
  10486. * The location of pick collision
  10487. */
  10488. pickedPoint: Nullable<Vector3>;
  10489. /**
  10490. * The mesh corresponding the the pick collision
  10491. */
  10492. pickedMesh: Nullable<AbstractMesh>;
  10493. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10494. bu: number;
  10495. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10496. bv: number;
  10497. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10498. faceId: number;
  10499. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10500. subMeshFaceId: number;
  10501. /** Id of the the submesh that was picked */
  10502. subMeshId: number;
  10503. /** If a sprite was picked, this will be the sprite the pick collided with */
  10504. pickedSprite: Nullable<Sprite>;
  10505. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10506. thinInstanceIndex: number;
  10507. /**
  10508. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10509. */
  10510. originMesh: Nullable<AbstractMesh>;
  10511. /**
  10512. * The ray that was used to perform the picking.
  10513. */
  10514. ray: Nullable<Ray>;
  10515. /**
  10516. * Gets the normal correspodning to the face the pick collided with
  10517. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10518. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10519. * @returns The normal correspodning to the face the pick collided with
  10520. */
  10521. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10522. /**
  10523. * Gets the texture coordinates of where the pick occured
  10524. * @returns the vector containing the coordnates of the texture
  10525. */
  10526. getTextureCoordinates(): Nullable<Vector2>;
  10527. }
  10528. }
  10529. declare module BABYLON {
  10530. /**
  10531. * Class representing a ray with position and direction
  10532. */
  10533. export class Ray {
  10534. /** origin point */
  10535. origin: Vector3;
  10536. /** direction */
  10537. direction: Vector3;
  10538. /** length of the ray */
  10539. length: number;
  10540. private static readonly _TmpVector3;
  10541. private _tmpRay;
  10542. /**
  10543. * Creates a new ray
  10544. * @param origin origin point
  10545. * @param direction direction
  10546. * @param length length of the ray
  10547. */
  10548. constructor(
  10549. /** origin point */
  10550. origin: Vector3,
  10551. /** direction */
  10552. direction: Vector3,
  10553. /** length of the ray */
  10554. length?: number);
  10555. /**
  10556. * Checks if the ray intersects a box
  10557. * This does not account for the ray lenght by design to improve perfs.
  10558. * @param minimum bound of the box
  10559. * @param maximum bound of the box
  10560. * @param intersectionTreshold extra extend to be added to the box in all direction
  10561. * @returns if the box was hit
  10562. */
  10563. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10564. /**
  10565. * Checks if the ray intersects a box
  10566. * This does not account for the ray lenght by design to improve perfs.
  10567. * @param box the bounding box to check
  10568. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10569. * @returns if the box was hit
  10570. */
  10571. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10572. /**
  10573. * If the ray hits a sphere
  10574. * @param sphere the bounding sphere to check
  10575. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10576. * @returns true if it hits the sphere
  10577. */
  10578. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10579. /**
  10580. * If the ray hits a triange
  10581. * @param vertex0 triangle vertex
  10582. * @param vertex1 triangle vertex
  10583. * @param vertex2 triangle vertex
  10584. * @returns intersection information if hit
  10585. */
  10586. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10587. /**
  10588. * Checks if ray intersects a plane
  10589. * @param plane the plane to check
  10590. * @returns the distance away it was hit
  10591. */
  10592. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10593. /**
  10594. * Calculate the intercept of a ray on a given axis
  10595. * @param axis to check 'x' | 'y' | 'z'
  10596. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10597. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10598. */
  10599. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10600. /**
  10601. * Checks if ray intersects a mesh
  10602. * @param mesh the mesh to check
  10603. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10604. * @returns picking info of the intersecton
  10605. */
  10606. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10607. /**
  10608. * Checks if ray intersects a mesh
  10609. * @param meshes the meshes to check
  10610. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10611. * @param results array to store result in
  10612. * @returns Array of picking infos
  10613. */
  10614. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10615. private _comparePickingInfo;
  10616. private static smallnum;
  10617. private static rayl;
  10618. /**
  10619. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10620. * @param sega the first point of the segment to test the intersection against
  10621. * @param segb the second point of the segment to test the intersection against
  10622. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10623. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10624. */
  10625. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10626. /**
  10627. * Update the ray from viewport position
  10628. * @param x position
  10629. * @param y y position
  10630. * @param viewportWidth viewport width
  10631. * @param viewportHeight viewport height
  10632. * @param world world matrix
  10633. * @param view view matrix
  10634. * @param projection projection matrix
  10635. * @returns this ray updated
  10636. */
  10637. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10638. /**
  10639. * Creates a ray with origin and direction of 0,0,0
  10640. * @returns the new ray
  10641. */
  10642. static Zero(): Ray;
  10643. /**
  10644. * Creates a new ray from screen space and viewport
  10645. * @param x position
  10646. * @param y y position
  10647. * @param viewportWidth viewport width
  10648. * @param viewportHeight viewport height
  10649. * @param world world matrix
  10650. * @param view view matrix
  10651. * @param projection projection matrix
  10652. * @returns new ray
  10653. */
  10654. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10655. /**
  10656. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10657. * transformed to the given world matrix.
  10658. * @param origin The origin point
  10659. * @param end The end point
  10660. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10661. * @returns the new ray
  10662. */
  10663. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10664. /**
  10665. * Transforms a ray by a matrix
  10666. * @param ray ray to transform
  10667. * @param matrix matrix to apply
  10668. * @returns the resulting new ray
  10669. */
  10670. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10671. /**
  10672. * Transforms a ray by a matrix
  10673. * @param ray ray to transform
  10674. * @param matrix matrix to apply
  10675. * @param result ray to store result in
  10676. */
  10677. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10678. /**
  10679. * Unproject a ray from screen space to object space
  10680. * @param sourceX defines the screen space x coordinate to use
  10681. * @param sourceY defines the screen space y coordinate to use
  10682. * @param viewportWidth defines the current width of the viewport
  10683. * @param viewportHeight defines the current height of the viewport
  10684. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10685. * @param view defines the view matrix to use
  10686. * @param projection defines the projection matrix to use
  10687. */
  10688. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10689. }
  10690. /**
  10691. * Type used to define predicate used to select faces when a mesh intersection is detected
  10692. */
  10693. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10694. interface Scene {
  10695. /** @hidden */
  10696. _tempPickingRay: Nullable<Ray>;
  10697. /** @hidden */
  10698. _cachedRayForTransform: Ray;
  10699. /** @hidden */
  10700. _pickWithRayInverseMatrix: Matrix;
  10701. /** @hidden */
  10702. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10703. /** @hidden */
  10704. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10705. /** @hidden */
  10706. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10707. }
  10708. }
  10709. declare module BABYLON {
  10710. /**
  10711. * Groups all the scene component constants in one place to ease maintenance.
  10712. * @hidden
  10713. */
  10714. export class SceneComponentConstants {
  10715. static readonly NAME_EFFECTLAYER: string;
  10716. static readonly NAME_LAYER: string;
  10717. static readonly NAME_LENSFLARESYSTEM: string;
  10718. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10719. static readonly NAME_PARTICLESYSTEM: string;
  10720. static readonly NAME_GAMEPAD: string;
  10721. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10722. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10723. static readonly NAME_PREPASSRENDERER: string;
  10724. static readonly NAME_DEPTHRENDERER: string;
  10725. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10726. static readonly NAME_SPRITE: string;
  10727. static readonly NAME_SUBSURFACE: string;
  10728. static readonly NAME_OUTLINERENDERER: string;
  10729. static readonly NAME_PROCEDURALTEXTURE: string;
  10730. static readonly NAME_SHADOWGENERATOR: string;
  10731. static readonly NAME_OCTREE: string;
  10732. static readonly NAME_PHYSICSENGINE: string;
  10733. static readonly NAME_AUDIO: string;
  10734. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10735. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10736. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10737. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10738. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10739. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10740. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10741. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10742. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10743. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10744. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10745. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10746. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10747. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10748. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10749. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10750. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10751. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10752. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10753. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10754. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10755. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10756. static readonly STEP_AFTERRENDER_AUDIO: number;
  10757. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10758. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10759. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10760. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10761. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10762. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10763. static readonly STEP_POINTERMOVE_SPRITE: number;
  10764. static readonly STEP_POINTERDOWN_SPRITE: number;
  10765. static readonly STEP_POINTERUP_SPRITE: number;
  10766. }
  10767. /**
  10768. * This represents a scene component.
  10769. *
  10770. * This is used to decouple the dependency the scene is having on the different workloads like
  10771. * layers, post processes...
  10772. */
  10773. export interface ISceneComponent {
  10774. /**
  10775. * The name of the component. Each component must have a unique name.
  10776. */
  10777. name: string;
  10778. /**
  10779. * The scene the component belongs to.
  10780. */
  10781. scene: Scene;
  10782. /**
  10783. * Register the component to one instance of a scene.
  10784. */
  10785. register(): void;
  10786. /**
  10787. * Rebuilds the elements related to this component in case of
  10788. * context lost for instance.
  10789. */
  10790. rebuild(): void;
  10791. /**
  10792. * Disposes the component and the associated ressources.
  10793. */
  10794. dispose(): void;
  10795. }
  10796. /**
  10797. * This represents a SERIALIZABLE scene component.
  10798. *
  10799. * This extends Scene Component to add Serialization methods on top.
  10800. */
  10801. export interface ISceneSerializableComponent extends ISceneComponent {
  10802. /**
  10803. * Adds all the elements from the container to the scene
  10804. * @param container the container holding the elements
  10805. */
  10806. addFromContainer(container: AbstractScene): void;
  10807. /**
  10808. * Removes all the elements in the container from the scene
  10809. * @param container contains the elements to remove
  10810. * @param dispose if the removed element should be disposed (default: false)
  10811. */
  10812. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10813. /**
  10814. * Serializes the component data to the specified json object
  10815. * @param serializationObject The object to serialize to
  10816. */
  10817. serialize(serializationObject: any): void;
  10818. }
  10819. /**
  10820. * Strong typing of a Mesh related stage step action
  10821. */
  10822. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10823. /**
  10824. * Strong typing of a Evaluate Sub Mesh related stage step action
  10825. */
  10826. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10827. /**
  10828. * Strong typing of a pre active Mesh related stage step action
  10829. */
  10830. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10831. /**
  10832. * Strong typing of a Camera related stage step action
  10833. */
  10834. export type CameraStageAction = (camera: Camera) => void;
  10835. /**
  10836. * Strong typing of a Camera Frame buffer related stage step action
  10837. */
  10838. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10839. /**
  10840. * Strong typing of a Render Target related stage step action
  10841. */
  10842. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10843. /**
  10844. * Strong typing of a RenderingGroup related stage step action
  10845. */
  10846. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10847. /**
  10848. * Strong typing of a Mesh Render related stage step action
  10849. */
  10850. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10851. /**
  10852. * Strong typing of a simple stage step action
  10853. */
  10854. export type SimpleStageAction = () => void;
  10855. /**
  10856. * Strong typing of a render target action.
  10857. */
  10858. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10859. /**
  10860. * Strong typing of a pointer move action.
  10861. */
  10862. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10863. /**
  10864. * Strong typing of a pointer up/down action.
  10865. */
  10866. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10867. /**
  10868. * Representation of a stage in the scene (Basically a list of ordered steps)
  10869. * @hidden
  10870. */
  10871. export class Stage<T extends Function> extends Array<{
  10872. index: number;
  10873. component: ISceneComponent;
  10874. action: T;
  10875. }> {
  10876. /**
  10877. * Hide ctor from the rest of the world.
  10878. * @param items The items to add.
  10879. */
  10880. private constructor();
  10881. /**
  10882. * Creates a new Stage.
  10883. * @returns A new instance of a Stage
  10884. */
  10885. static Create<T extends Function>(): Stage<T>;
  10886. /**
  10887. * Registers a step in an ordered way in the targeted stage.
  10888. * @param index Defines the position to register the step in
  10889. * @param component Defines the component attached to the step
  10890. * @param action Defines the action to launch during the step
  10891. */
  10892. registerStep(index: number, component: ISceneComponent, action: T): void;
  10893. /**
  10894. * Clears all the steps from the stage.
  10895. */
  10896. clear(): void;
  10897. }
  10898. }
  10899. declare module BABYLON {
  10900. interface Scene {
  10901. /** @hidden */
  10902. _pointerOverSprite: Nullable<Sprite>;
  10903. /** @hidden */
  10904. _pickedDownSprite: Nullable<Sprite>;
  10905. /** @hidden */
  10906. _tempSpritePickingRay: Nullable<Ray>;
  10907. /**
  10908. * All of the sprite managers added to this scene
  10909. * @see https://doc.babylonjs.com/babylon101/sprites
  10910. */
  10911. spriteManagers: Array<ISpriteManager>;
  10912. /**
  10913. * An event triggered when sprites rendering is about to start
  10914. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10915. */
  10916. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10917. /**
  10918. * An event triggered when sprites rendering is done
  10919. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10920. */
  10921. onAfterSpritesRenderingObservable: Observable<Scene>;
  10922. /** @hidden */
  10923. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10924. /** Launch a ray to try to pick a sprite in the scene
  10925. * @param x position on screen
  10926. * @param y position on screen
  10927. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10928. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10929. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10930. * @returns a PickingInfo
  10931. */
  10932. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10933. /** Use the given ray to pick a sprite in the scene
  10934. * @param ray The ray (in world space) to use to pick meshes
  10935. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10936. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10937. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10938. * @returns a PickingInfo
  10939. */
  10940. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10941. /** @hidden */
  10942. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10943. /** Launch a ray to try to pick sprites in the scene
  10944. * @param x position on screen
  10945. * @param y position on screen
  10946. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10947. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10948. * @returns a PickingInfo array
  10949. */
  10950. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10951. /** Use the given ray to pick sprites in the scene
  10952. * @param ray The ray (in world space) to use to pick meshes
  10953. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10954. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10955. * @returns a PickingInfo array
  10956. */
  10957. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10958. /**
  10959. * Force the sprite under the pointer
  10960. * @param sprite defines the sprite to use
  10961. */
  10962. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10963. /**
  10964. * Gets the sprite under the pointer
  10965. * @returns a Sprite or null if no sprite is under the pointer
  10966. */
  10967. getPointerOverSprite(): Nullable<Sprite>;
  10968. }
  10969. /**
  10970. * Defines the sprite scene component responsible to manage sprites
  10971. * in a given scene.
  10972. */
  10973. export class SpriteSceneComponent implements ISceneComponent {
  10974. /**
  10975. * The component name helpfull to identify the component in the list of scene components.
  10976. */
  10977. readonly name: string;
  10978. /**
  10979. * The scene the component belongs to.
  10980. */
  10981. scene: Scene;
  10982. /** @hidden */
  10983. private _spritePredicate;
  10984. /**
  10985. * Creates a new instance of the component for the given scene
  10986. * @param scene Defines the scene to register the component in
  10987. */
  10988. constructor(scene: Scene);
  10989. /**
  10990. * Registers the component in a given scene
  10991. */
  10992. register(): void;
  10993. /**
  10994. * Rebuilds the elements related to this component in case of
  10995. * context lost for instance.
  10996. */
  10997. rebuild(): void;
  10998. /**
  10999. * Disposes the component and the associated ressources.
  11000. */
  11001. dispose(): void;
  11002. private _pickSpriteButKeepRay;
  11003. private _pointerMove;
  11004. private _pointerDown;
  11005. private _pointerUp;
  11006. }
  11007. }
  11008. declare module BABYLON {
  11009. /** @hidden */
  11010. export var fogFragmentDeclaration: {
  11011. name: string;
  11012. shader: string;
  11013. };
  11014. }
  11015. declare module BABYLON {
  11016. /** @hidden */
  11017. export var fogFragment: {
  11018. name: string;
  11019. shader: string;
  11020. };
  11021. }
  11022. declare module BABYLON {
  11023. /** @hidden */
  11024. export var imageProcessingCompatibility: {
  11025. name: string;
  11026. shader: string;
  11027. };
  11028. }
  11029. declare module BABYLON {
  11030. /** @hidden */
  11031. export var spritesPixelShader: {
  11032. name: string;
  11033. shader: string;
  11034. };
  11035. }
  11036. declare module BABYLON {
  11037. /** @hidden */
  11038. export var fogVertexDeclaration: {
  11039. name: string;
  11040. shader: string;
  11041. };
  11042. }
  11043. declare module BABYLON {
  11044. /** @hidden */
  11045. export var spritesVertexShader: {
  11046. name: string;
  11047. shader: string;
  11048. };
  11049. }
  11050. declare module BABYLON {
  11051. /**
  11052. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11053. */
  11054. export interface ISpriteManager extends IDisposable {
  11055. /**
  11056. * Gets manager's name
  11057. */
  11058. name: string;
  11059. /**
  11060. * Restricts the camera to viewing objects with the same layerMask.
  11061. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11062. */
  11063. layerMask: number;
  11064. /**
  11065. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11066. */
  11067. isPickable: boolean;
  11068. /**
  11069. * Gets the hosting scene
  11070. */
  11071. scene: Scene;
  11072. /**
  11073. * Specifies the rendering group id for this mesh (0 by default)
  11074. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11075. */
  11076. renderingGroupId: number;
  11077. /**
  11078. * Defines the list of sprites managed by the manager.
  11079. */
  11080. sprites: Array<Sprite>;
  11081. /**
  11082. * Gets or sets the spritesheet texture
  11083. */
  11084. texture: Texture;
  11085. /** Defines the default width of a cell in the spritesheet */
  11086. cellWidth: number;
  11087. /** Defines the default height of a cell in the spritesheet */
  11088. cellHeight: number;
  11089. /**
  11090. * Tests the intersection of a sprite with a specific ray.
  11091. * @param ray The ray we are sending to test the collision
  11092. * @param camera The camera space we are sending rays in
  11093. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11094. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11095. * @returns picking info or null.
  11096. */
  11097. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11098. /**
  11099. * Intersects the sprites with a ray
  11100. * @param ray defines the ray to intersect with
  11101. * @param camera defines the current active camera
  11102. * @param predicate defines a predicate used to select candidate sprites
  11103. * @returns null if no hit or a PickingInfo array
  11104. */
  11105. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11106. /**
  11107. * Renders the list of sprites on screen.
  11108. */
  11109. render(): void;
  11110. }
  11111. /**
  11112. * Class used to manage multiple sprites on the same spritesheet
  11113. * @see https://doc.babylonjs.com/babylon101/sprites
  11114. */
  11115. export class SpriteManager implements ISpriteManager {
  11116. /** defines the manager's name */
  11117. name: string;
  11118. /** Define the Url to load snippets */
  11119. static SnippetUrl: string;
  11120. /** Snippet ID if the manager was created from the snippet server */
  11121. snippetId: string;
  11122. /** Gets the list of sprites */
  11123. sprites: Sprite[];
  11124. /** Gets or sets the rendering group id (0 by default) */
  11125. renderingGroupId: number;
  11126. /** Gets or sets camera layer mask */
  11127. layerMask: number;
  11128. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11129. fogEnabled: boolean;
  11130. /** Gets or sets a boolean indicating if the sprites are pickable */
  11131. isPickable: boolean;
  11132. /** Defines the default width of a cell in the spritesheet */
  11133. cellWidth: number;
  11134. /** Defines the default height of a cell in the spritesheet */
  11135. cellHeight: number;
  11136. /** Associative array from JSON sprite data file */
  11137. private _cellData;
  11138. /** Array of sprite names from JSON sprite data file */
  11139. private _spriteMap;
  11140. /** True when packed cell data from JSON file is ready*/
  11141. private _packedAndReady;
  11142. private _textureContent;
  11143. private _useInstancing;
  11144. /**
  11145. * An event triggered when the manager is disposed.
  11146. */
  11147. onDisposeObservable: Observable<SpriteManager>;
  11148. private _onDisposeObserver;
  11149. /**
  11150. * Callback called when the manager is disposed
  11151. */
  11152. set onDispose(callback: () => void);
  11153. private _capacity;
  11154. private _fromPacked;
  11155. private _spriteTexture;
  11156. private _epsilon;
  11157. private _scene;
  11158. private _vertexData;
  11159. private _buffer;
  11160. private _vertexBuffers;
  11161. private _spriteBuffer;
  11162. private _indexBuffer;
  11163. private _effectBase;
  11164. private _effectFog;
  11165. private _vertexBufferSize;
  11166. /**
  11167. * Gets or sets the unique id of the sprite
  11168. */
  11169. uniqueId: number;
  11170. /**
  11171. * Gets the array of sprites
  11172. */
  11173. get children(): Sprite[];
  11174. /**
  11175. * Gets the hosting scene
  11176. */
  11177. get scene(): Scene;
  11178. /**
  11179. * Gets the capacity of the manager
  11180. */
  11181. get capacity(): number;
  11182. /**
  11183. * Gets or sets the spritesheet texture
  11184. */
  11185. get texture(): Texture;
  11186. set texture(value: Texture);
  11187. private _blendMode;
  11188. /**
  11189. * Blend mode use to render the particle, it can be any of
  11190. * the static Constants.ALPHA_x properties provided in this class.
  11191. * Default value is Constants.ALPHA_COMBINE
  11192. */
  11193. get blendMode(): number;
  11194. set blendMode(blendMode: number);
  11195. /** Disables writing to the depth buffer when rendering the sprites.
  11196. * It can be handy to disable depth writing when using textures without alpha channel
  11197. * and setting some specific blend modes.
  11198. */
  11199. disableDepthWrite: boolean;
  11200. /**
  11201. * Creates a new sprite manager
  11202. * @param name defines the manager's name
  11203. * @param imgUrl defines the sprite sheet url
  11204. * @param capacity defines the maximum allowed number of sprites
  11205. * @param cellSize defines the size of a sprite cell
  11206. * @param scene defines the hosting scene
  11207. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11208. * @param samplingMode defines the smapling mode to use with spritesheet
  11209. * @param fromPacked set to false; do not alter
  11210. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11211. */
  11212. constructor(
  11213. /** defines the manager's name */
  11214. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11215. /**
  11216. * Returns the string "SpriteManager"
  11217. * @returns "SpriteManager"
  11218. */
  11219. getClassName(): string;
  11220. private _makePacked;
  11221. private _appendSpriteVertex;
  11222. private _checkTextureAlpha;
  11223. /**
  11224. * Intersects the sprites with a ray
  11225. * @param ray defines the ray to intersect with
  11226. * @param camera defines the current active camera
  11227. * @param predicate defines a predicate used to select candidate sprites
  11228. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11229. * @returns null if no hit or a PickingInfo
  11230. */
  11231. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11232. /**
  11233. * Intersects the sprites with a ray
  11234. * @param ray defines the ray to intersect with
  11235. * @param camera defines the current active camera
  11236. * @param predicate defines a predicate used to select candidate sprites
  11237. * @returns null if no hit or a PickingInfo array
  11238. */
  11239. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11240. /**
  11241. * Render all child sprites
  11242. */
  11243. render(): void;
  11244. /**
  11245. * Release associated resources
  11246. */
  11247. dispose(): void;
  11248. /**
  11249. * Serializes the sprite manager to a JSON object
  11250. * @param serializeTexture defines if the texture must be serialized as well
  11251. * @returns the JSON object
  11252. */
  11253. serialize(serializeTexture?: boolean): any;
  11254. /**
  11255. * Parses a JSON object to create a new sprite manager.
  11256. * @param parsedManager The JSON object to parse
  11257. * @param scene The scene to create the sprite managerin
  11258. * @param rootUrl The root url to use to load external dependencies like texture
  11259. * @returns the new sprite manager
  11260. */
  11261. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11262. /**
  11263. * Creates a sprite manager from a snippet saved in a remote file
  11264. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11265. * @param url defines the url to load from
  11266. * @param scene defines the hosting scene
  11267. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11268. * @returns a promise that will resolve to the new sprite manager
  11269. */
  11270. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11271. /**
  11272. * Creates a sprite manager from a snippet saved by the sprite editor
  11273. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11274. * @param scene defines the hosting scene
  11275. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11276. * @returns a promise that will resolve to the new sprite manager
  11277. */
  11278. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11279. }
  11280. }
  11281. declare module BABYLON {
  11282. /** Interface used by value gradients (color, factor, ...) */
  11283. export interface IValueGradient {
  11284. /**
  11285. * Gets or sets the gradient value (between 0 and 1)
  11286. */
  11287. gradient: number;
  11288. }
  11289. /** Class used to store color4 gradient */
  11290. export class ColorGradient implements IValueGradient {
  11291. /**
  11292. * Gets or sets the gradient value (between 0 and 1)
  11293. */
  11294. gradient: number;
  11295. /**
  11296. * Gets or sets first associated color
  11297. */
  11298. color1: Color4;
  11299. /**
  11300. * Gets or sets second associated color
  11301. */
  11302. color2?: Color4 | undefined;
  11303. /**
  11304. * Creates a new color4 gradient
  11305. * @param gradient gets or sets the gradient value (between 0 and 1)
  11306. * @param color1 gets or sets first associated color
  11307. * @param color2 gets or sets first second color
  11308. */
  11309. constructor(
  11310. /**
  11311. * Gets or sets the gradient value (between 0 and 1)
  11312. */
  11313. gradient: number,
  11314. /**
  11315. * Gets or sets first associated color
  11316. */
  11317. color1: Color4,
  11318. /**
  11319. * Gets or sets second associated color
  11320. */
  11321. color2?: Color4 | undefined);
  11322. /**
  11323. * Will get a color picked randomly between color1 and color2.
  11324. * If color2 is undefined then color1 will be used
  11325. * @param result defines the target Color4 to store the result in
  11326. */
  11327. getColorToRef(result: Color4): void;
  11328. }
  11329. /** Class used to store color 3 gradient */
  11330. export class Color3Gradient implements IValueGradient {
  11331. /**
  11332. * Gets or sets the gradient value (between 0 and 1)
  11333. */
  11334. gradient: number;
  11335. /**
  11336. * Gets or sets the associated color
  11337. */
  11338. color: Color3;
  11339. /**
  11340. * Creates a new color3 gradient
  11341. * @param gradient gets or sets the gradient value (between 0 and 1)
  11342. * @param color gets or sets associated color
  11343. */
  11344. constructor(
  11345. /**
  11346. * Gets or sets the gradient value (between 0 and 1)
  11347. */
  11348. gradient: number,
  11349. /**
  11350. * Gets or sets the associated color
  11351. */
  11352. color: Color3);
  11353. }
  11354. /** Class used to store factor gradient */
  11355. export class FactorGradient implements IValueGradient {
  11356. /**
  11357. * Gets or sets the gradient value (between 0 and 1)
  11358. */
  11359. gradient: number;
  11360. /**
  11361. * Gets or sets first associated factor
  11362. */
  11363. factor1: number;
  11364. /**
  11365. * Gets or sets second associated factor
  11366. */
  11367. factor2?: number | undefined;
  11368. /**
  11369. * Creates a new factor gradient
  11370. * @param gradient gets or sets the gradient value (between 0 and 1)
  11371. * @param factor1 gets or sets first associated factor
  11372. * @param factor2 gets or sets second associated factor
  11373. */
  11374. constructor(
  11375. /**
  11376. * Gets or sets the gradient value (between 0 and 1)
  11377. */
  11378. gradient: number,
  11379. /**
  11380. * Gets or sets first associated factor
  11381. */
  11382. factor1: number,
  11383. /**
  11384. * Gets or sets second associated factor
  11385. */
  11386. factor2?: number | undefined);
  11387. /**
  11388. * Will get a number picked randomly between factor1 and factor2.
  11389. * If factor2 is undefined then factor1 will be used
  11390. * @returns the picked number
  11391. */
  11392. getFactor(): number;
  11393. }
  11394. /**
  11395. * Helper used to simplify some generic gradient tasks
  11396. */
  11397. export class GradientHelper {
  11398. /**
  11399. * Gets the current gradient from an array of IValueGradient
  11400. * @param ratio defines the current ratio to get
  11401. * @param gradients defines the array of IValueGradient
  11402. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11403. */
  11404. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11405. }
  11406. }
  11407. declare module BABYLON {
  11408. interface ThinEngine {
  11409. /**
  11410. * Creates a raw texture
  11411. * @param data defines the data to store in the texture
  11412. * @param width defines the width of the texture
  11413. * @param height defines the height of the texture
  11414. * @param format defines the format of the data
  11415. * @param generateMipMaps defines if the engine should generate the mip levels
  11416. * @param invertY defines if data must be stored with Y axis inverted
  11417. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11418. * @param compression defines the compression used (null by default)
  11419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11420. * @returns the raw texture inside an InternalTexture
  11421. */
  11422. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11423. /**
  11424. * Update a raw texture
  11425. * @param texture defines the texture to update
  11426. * @param data defines the data to store in the texture
  11427. * @param format defines the format of the data
  11428. * @param invertY defines if data must be stored with Y axis inverted
  11429. */
  11430. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11431. /**
  11432. * Update a raw texture
  11433. * @param texture defines the texture to update
  11434. * @param data defines the data to store in the texture
  11435. * @param format defines the format of the data
  11436. * @param invertY defines if data must be stored with Y axis inverted
  11437. * @param compression defines the compression used (null by default)
  11438. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11439. */
  11440. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11441. /**
  11442. * Creates a new raw cube texture
  11443. * @param data defines the array of data to use to create each face
  11444. * @param size defines the size of the textures
  11445. * @param format defines the format of the data
  11446. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11447. * @param generateMipMaps defines if the engine should generate the mip levels
  11448. * @param invertY defines if data must be stored with Y axis inverted
  11449. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11450. * @param compression defines the compression used (null by default)
  11451. * @returns the cube texture as an InternalTexture
  11452. */
  11453. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11454. /**
  11455. * Update a raw cube texture
  11456. * @param texture defines the texture to udpdate
  11457. * @param data defines the data to store
  11458. * @param format defines the data format
  11459. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11460. * @param invertY defines if data must be stored with Y axis inverted
  11461. */
  11462. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11463. /**
  11464. * Update a raw cube texture
  11465. * @param texture defines the texture to udpdate
  11466. * @param data defines the data to store
  11467. * @param format defines the data format
  11468. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11469. * @param invertY defines if data must be stored with Y axis inverted
  11470. * @param compression defines the compression used (null by default)
  11471. */
  11472. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11473. /**
  11474. * Update a raw cube texture
  11475. * @param texture defines the texture to udpdate
  11476. * @param data defines the data to store
  11477. * @param format defines the data format
  11478. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11479. * @param invertY defines if data must be stored with Y axis inverted
  11480. * @param compression defines the compression used (null by default)
  11481. * @param level defines which level of the texture to update
  11482. */
  11483. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11484. /**
  11485. * Creates a new raw cube texture from a specified url
  11486. * @param url defines the url where the data is located
  11487. * @param scene defines the current scene
  11488. * @param size defines the size of the textures
  11489. * @param format defines the format of the data
  11490. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11491. * @param noMipmap defines if the engine should avoid generating the mip levels
  11492. * @param callback defines a callback used to extract texture data from loaded data
  11493. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11494. * @param onLoad defines a callback called when texture is loaded
  11495. * @param onError defines a callback called if there is an error
  11496. * @returns the cube texture as an InternalTexture
  11497. */
  11498. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11499. /**
  11500. * Creates a new raw cube texture from a specified url
  11501. * @param url defines the url where the data is located
  11502. * @param scene defines the current scene
  11503. * @param size defines the size of the textures
  11504. * @param format defines the format of the data
  11505. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11506. * @param noMipmap defines if the engine should avoid generating the mip levels
  11507. * @param callback defines a callback used to extract texture data from loaded data
  11508. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11509. * @param onLoad defines a callback called when texture is loaded
  11510. * @param onError defines a callback called if there is an error
  11511. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11512. * @param invertY defines if data must be stored with Y axis inverted
  11513. * @returns the cube texture as an InternalTexture
  11514. */
  11515. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11516. /**
  11517. * Creates a new raw 3D texture
  11518. * @param data defines the data used to create the texture
  11519. * @param width defines the width of the texture
  11520. * @param height defines the height of the texture
  11521. * @param depth defines the depth of the texture
  11522. * @param format defines the format of the texture
  11523. * @param generateMipMaps defines if the engine must generate mip levels
  11524. * @param invertY defines if data must be stored with Y axis inverted
  11525. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11526. * @param compression defines the compressed used (can be null)
  11527. * @param textureType defines the compressed used (can be null)
  11528. * @returns a new raw 3D texture (stored in an InternalTexture)
  11529. */
  11530. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11531. /**
  11532. * Update a raw 3D texture
  11533. * @param texture defines the texture to update
  11534. * @param data defines the data to store
  11535. * @param format defines the data format
  11536. * @param invertY defines if data must be stored with Y axis inverted
  11537. */
  11538. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11539. /**
  11540. * Update a raw 3D texture
  11541. * @param texture defines the texture to update
  11542. * @param data defines the data to store
  11543. * @param format defines the data format
  11544. * @param invertY defines if data must be stored with Y axis inverted
  11545. * @param compression defines the used compression (can be null)
  11546. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11547. */
  11548. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11549. /**
  11550. * Creates a new raw 2D array texture
  11551. * @param data defines the data used to create the texture
  11552. * @param width defines the width of the texture
  11553. * @param height defines the height of the texture
  11554. * @param depth defines the number of layers of the texture
  11555. * @param format defines the format of the texture
  11556. * @param generateMipMaps defines if the engine must generate mip levels
  11557. * @param invertY defines if data must be stored with Y axis inverted
  11558. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11559. * @param compression defines the compressed used (can be null)
  11560. * @param textureType defines the compressed used (can be null)
  11561. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11562. */
  11563. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11564. /**
  11565. * Update a raw 2D array texture
  11566. * @param texture defines the texture to update
  11567. * @param data defines the data to store
  11568. * @param format defines the data format
  11569. * @param invertY defines if data must be stored with Y axis inverted
  11570. */
  11571. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11572. /**
  11573. * Update a raw 2D array texture
  11574. * @param texture defines the texture to update
  11575. * @param data defines the data to store
  11576. * @param format defines the data format
  11577. * @param invertY defines if data must be stored with Y axis inverted
  11578. * @param compression defines the used compression (can be null)
  11579. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11580. */
  11581. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11582. }
  11583. }
  11584. declare module BABYLON {
  11585. /**
  11586. * Raw texture can help creating a texture directly from an array of data.
  11587. * This can be super useful if you either get the data from an uncompressed source or
  11588. * if you wish to create your texture pixel by pixel.
  11589. */
  11590. export class RawTexture extends Texture {
  11591. /**
  11592. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11593. */
  11594. format: number;
  11595. /**
  11596. * Instantiates a new RawTexture.
  11597. * Raw texture can help creating a texture directly from an array of data.
  11598. * This can be super useful if you either get the data from an uncompressed source or
  11599. * if you wish to create your texture pixel by pixel.
  11600. * @param data define the array of data to use to create the texture
  11601. * @param width define the width of the texture
  11602. * @param height define the height of the texture
  11603. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11604. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11605. * @param generateMipMaps define whether mip maps should be generated or not
  11606. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11607. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11608. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11609. */
  11610. constructor(data: ArrayBufferView, width: number, height: number,
  11611. /**
  11612. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11613. */
  11614. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11615. /**
  11616. * Updates the texture underlying data.
  11617. * @param data Define the new data of the texture
  11618. */
  11619. update(data: ArrayBufferView): void;
  11620. /**
  11621. * Creates a luminance texture from some data.
  11622. * @param data Define the texture data
  11623. * @param width Define the width of the texture
  11624. * @param height Define the height of the texture
  11625. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11626. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11627. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11628. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11629. * @returns the luminance texture
  11630. */
  11631. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11632. /**
  11633. * Creates a luminance alpha texture from some data.
  11634. * @param data Define the texture data
  11635. * @param width Define the width of the texture
  11636. * @param height Define the height of the texture
  11637. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11638. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11639. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11640. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11641. * @returns the luminance alpha texture
  11642. */
  11643. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11644. /**
  11645. * Creates an alpha texture from some data.
  11646. * @param data Define the texture data
  11647. * @param width Define the width of the texture
  11648. * @param height Define the height of the texture
  11649. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11650. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11651. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11652. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11653. * @returns the alpha texture
  11654. */
  11655. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11656. /**
  11657. * Creates a RGB texture from some data.
  11658. * @param data Define the texture data
  11659. * @param width Define the width of the texture
  11660. * @param height Define the height of the texture
  11661. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11662. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11663. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11664. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11665. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11666. * @returns the RGB alpha texture
  11667. */
  11668. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11669. /**
  11670. * Creates a RGBA texture from some data.
  11671. * @param data Define the texture data
  11672. * @param width Define the width of the texture
  11673. * @param height Define the height of the texture
  11674. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11675. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11676. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11677. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11678. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11679. * @returns the RGBA texture
  11680. */
  11681. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11682. /**
  11683. * Creates a R texture from some data.
  11684. * @param data Define the texture data
  11685. * @param width Define the width of the texture
  11686. * @param height Define the height of the texture
  11687. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11688. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11689. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11690. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11691. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11692. * @returns the R texture
  11693. */
  11694. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11695. }
  11696. }
  11697. declare module BABYLON {
  11698. interface ThinEngine {
  11699. /**
  11700. * Update a dynamic index buffer
  11701. * @param indexBuffer defines the target index buffer
  11702. * @param indices defines the data to update
  11703. * @param offset defines the offset in the target index buffer where update should start
  11704. */
  11705. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11706. /**
  11707. * Updates a dynamic vertex buffer.
  11708. * @param vertexBuffer the vertex buffer to update
  11709. * @param data the data used to update the vertex buffer
  11710. * @param byteOffset the byte offset of the data
  11711. * @param byteLength the byte length of the data
  11712. */
  11713. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11714. }
  11715. }
  11716. declare module BABYLON {
  11717. interface AbstractScene {
  11718. /**
  11719. * The list of procedural textures added to the scene
  11720. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11721. */
  11722. proceduralTextures: Array<ProceduralTexture>;
  11723. }
  11724. /**
  11725. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11726. * in a given scene.
  11727. */
  11728. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11729. /**
  11730. * The component name helpfull to identify the component in the list of scene components.
  11731. */
  11732. readonly name: string;
  11733. /**
  11734. * The scene the component belongs to.
  11735. */
  11736. scene: Scene;
  11737. /**
  11738. * Creates a new instance of the component for the given scene
  11739. * @param scene Defines the scene to register the component in
  11740. */
  11741. constructor(scene: Scene);
  11742. /**
  11743. * Registers the component in a given scene
  11744. */
  11745. register(): void;
  11746. /**
  11747. * Rebuilds the elements related to this component in case of
  11748. * context lost for instance.
  11749. */
  11750. rebuild(): void;
  11751. /**
  11752. * Disposes the component and the associated ressources.
  11753. */
  11754. dispose(): void;
  11755. private _beforeClear;
  11756. }
  11757. }
  11758. declare module BABYLON {
  11759. interface ThinEngine {
  11760. /**
  11761. * Creates a new render target cube texture
  11762. * @param size defines the size of the texture
  11763. * @param options defines the options used to create the texture
  11764. * @returns a new render target cube texture stored in an InternalTexture
  11765. */
  11766. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11767. }
  11768. }
  11769. declare module BABYLON {
  11770. /** @hidden */
  11771. export var proceduralVertexShader: {
  11772. name: string;
  11773. shader: string;
  11774. };
  11775. }
  11776. declare module BABYLON {
  11777. /**
  11778. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11779. * This is the base class of any Procedural texture and contains most of the shareable code.
  11780. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11781. */
  11782. export class ProceduralTexture extends Texture {
  11783. /**
  11784. * Define if the texture is enabled or not (disabled texture will not render)
  11785. */
  11786. isEnabled: boolean;
  11787. /**
  11788. * Define if the texture must be cleared before rendering (default is true)
  11789. */
  11790. autoClear: boolean;
  11791. /**
  11792. * Callback called when the texture is generated
  11793. */
  11794. onGenerated: () => void;
  11795. /**
  11796. * Event raised when the texture is generated
  11797. */
  11798. onGeneratedObservable: Observable<ProceduralTexture>;
  11799. /**
  11800. * Event raised before the texture is generated
  11801. */
  11802. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11803. /**
  11804. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11805. */
  11806. nodeMaterialSource: Nullable<NodeMaterial>;
  11807. /** @hidden */
  11808. _generateMipMaps: boolean;
  11809. /** @hidden **/
  11810. _effect: Effect;
  11811. /** @hidden */
  11812. _textures: {
  11813. [key: string]: Texture;
  11814. };
  11815. /** @hidden */
  11816. protected _fallbackTexture: Nullable<Texture>;
  11817. private _size;
  11818. private _currentRefreshId;
  11819. private _frameId;
  11820. private _refreshRate;
  11821. private _vertexBuffers;
  11822. private _indexBuffer;
  11823. private _uniforms;
  11824. private _samplers;
  11825. private _fragment;
  11826. private _floats;
  11827. private _ints;
  11828. private _floatsArrays;
  11829. private _colors3;
  11830. private _colors4;
  11831. private _vectors2;
  11832. private _vectors3;
  11833. private _matrices;
  11834. private _fallbackTextureUsed;
  11835. private _fullEngine;
  11836. private _cachedDefines;
  11837. private _contentUpdateId;
  11838. private _contentData;
  11839. /**
  11840. * Instantiates a new procedural texture.
  11841. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11842. * This is the base class of any Procedural texture and contains most of the shareable code.
  11843. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11844. * @param name Define the name of the texture
  11845. * @param size Define the size of the texture to create
  11846. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11847. * @param scene Define the scene the texture belongs to
  11848. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11849. * @param generateMipMaps Define if the texture should creates mip maps or not
  11850. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11851. * @param textureType The FBO internal texture type
  11852. */
  11853. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  11854. /**
  11855. * The effect that is created when initializing the post process.
  11856. * @returns The created effect corresponding the the postprocess.
  11857. */
  11858. getEffect(): Effect;
  11859. /**
  11860. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11861. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11862. */
  11863. getContent(): Nullable<ArrayBufferView>;
  11864. private _createIndexBuffer;
  11865. /** @hidden */
  11866. _rebuild(): void;
  11867. /**
  11868. * Resets the texture in order to recreate its associated resources.
  11869. * This can be called in case of context loss
  11870. */
  11871. reset(): void;
  11872. protected _getDefines(): string;
  11873. /**
  11874. * Is the texture ready to be used ? (rendered at least once)
  11875. * @returns true if ready, otherwise, false.
  11876. */
  11877. isReady(): boolean;
  11878. /**
  11879. * Resets the refresh counter of the texture and start bak from scratch.
  11880. * Could be useful to regenerate the texture if it is setup to render only once.
  11881. */
  11882. resetRefreshCounter(): void;
  11883. /**
  11884. * Set the fragment shader to use in order to render the texture.
  11885. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11886. */
  11887. setFragment(fragment: any): void;
  11888. /**
  11889. * Define the refresh rate of the texture or the rendering frequency.
  11890. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11891. */
  11892. get refreshRate(): number;
  11893. set refreshRate(value: number);
  11894. /** @hidden */
  11895. _shouldRender(): boolean;
  11896. /**
  11897. * Get the size the texture is rendering at.
  11898. * @returns the size (on cube texture it is always squared)
  11899. */
  11900. getRenderSize(): RenderTargetTextureSize;
  11901. /**
  11902. * Resize the texture to new value.
  11903. * @param size Define the new size the texture should have
  11904. * @param generateMipMaps Define whether the new texture should create mip maps
  11905. */
  11906. resize(size: number, generateMipMaps: boolean): void;
  11907. private _checkUniform;
  11908. /**
  11909. * Set a texture in the shader program used to render.
  11910. * @param name Define the name of the uniform samplers as defined in the shader
  11911. * @param texture Define the texture to bind to this sampler
  11912. * @return the texture itself allowing "fluent" like uniform updates
  11913. */
  11914. setTexture(name: string, texture: Texture): ProceduralTexture;
  11915. /**
  11916. * Set a float in the shader.
  11917. * @param name Define the name of the uniform as defined in the shader
  11918. * @param value Define the value to give to the uniform
  11919. * @return the texture itself allowing "fluent" like uniform updates
  11920. */
  11921. setFloat(name: string, value: number): ProceduralTexture;
  11922. /**
  11923. * Set a int in the shader.
  11924. * @param name Define the name of the uniform as defined in the shader
  11925. * @param value Define the value to give to the uniform
  11926. * @return the texture itself allowing "fluent" like uniform updates
  11927. */
  11928. setInt(name: string, value: number): ProceduralTexture;
  11929. /**
  11930. * Set an array of floats in the shader.
  11931. * @param name Define the name of the uniform as defined in the shader
  11932. * @param value Define the value to give to the uniform
  11933. * @return the texture itself allowing "fluent" like uniform updates
  11934. */
  11935. setFloats(name: string, value: number[]): ProceduralTexture;
  11936. /**
  11937. * Set a vec3 in the shader from a Color3.
  11938. * @param name Define the name of the uniform as defined in the shader
  11939. * @param value Define the value to give to the uniform
  11940. * @return the texture itself allowing "fluent" like uniform updates
  11941. */
  11942. setColor3(name: string, value: Color3): ProceduralTexture;
  11943. /**
  11944. * Set a vec4 in the shader from a Color4.
  11945. * @param name Define the name of the uniform as defined in the shader
  11946. * @param value Define the value to give to the uniform
  11947. * @return the texture itself allowing "fluent" like uniform updates
  11948. */
  11949. setColor4(name: string, value: Color4): ProceduralTexture;
  11950. /**
  11951. * Set a vec2 in the shader from a Vector2.
  11952. * @param name Define the name of the uniform as defined in the shader
  11953. * @param value Define the value to give to the uniform
  11954. * @return the texture itself allowing "fluent" like uniform updates
  11955. */
  11956. setVector2(name: string, value: Vector2): ProceduralTexture;
  11957. /**
  11958. * Set a vec3 in the shader from a Vector3.
  11959. * @param name Define the name of the uniform as defined in the shader
  11960. * @param value Define the value to give to the uniform
  11961. * @return the texture itself allowing "fluent" like uniform updates
  11962. */
  11963. setVector3(name: string, value: Vector3): ProceduralTexture;
  11964. /**
  11965. * Set a mat4 in the shader from a MAtrix.
  11966. * @param name Define the name of the uniform as defined in the shader
  11967. * @param value Define the value to give to the uniform
  11968. * @return the texture itself allowing "fluent" like uniform updates
  11969. */
  11970. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11971. /**
  11972. * Render the texture to its associated render target.
  11973. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11974. */
  11975. render(useCameraPostProcess?: boolean): void;
  11976. /**
  11977. * Clone the texture.
  11978. * @returns the cloned texture
  11979. */
  11980. clone(): ProceduralTexture;
  11981. /**
  11982. * Dispose the texture and release its asoociated resources.
  11983. */
  11984. dispose(): void;
  11985. }
  11986. }
  11987. declare module BABYLON {
  11988. /**
  11989. * This represents the base class for particle system in Babylon.
  11990. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11991. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11992. * @example https://doc.babylonjs.com/babylon101/particles
  11993. */
  11994. export class BaseParticleSystem {
  11995. /**
  11996. * Source color is added to the destination color without alpha affecting the result
  11997. */
  11998. static BLENDMODE_ONEONE: number;
  11999. /**
  12000. * Blend current color and particle color using particle’s alpha
  12001. */
  12002. static BLENDMODE_STANDARD: number;
  12003. /**
  12004. * Add current color and particle color multiplied by particle’s alpha
  12005. */
  12006. static BLENDMODE_ADD: number;
  12007. /**
  12008. * Multiply current color with particle color
  12009. */
  12010. static BLENDMODE_MULTIPLY: number;
  12011. /**
  12012. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12013. */
  12014. static BLENDMODE_MULTIPLYADD: number;
  12015. /**
  12016. * List of animations used by the particle system.
  12017. */
  12018. animations: Animation[];
  12019. /**
  12020. * Gets or sets the unique id of the particle system
  12021. */
  12022. uniqueId: number;
  12023. /**
  12024. * The id of the Particle system.
  12025. */
  12026. id: string;
  12027. /**
  12028. * The friendly name of the Particle system.
  12029. */
  12030. name: string;
  12031. /**
  12032. * Snippet ID if the particle system was created from the snippet server
  12033. */
  12034. snippetId: string;
  12035. /**
  12036. * The rendering group used by the Particle system to chose when to render.
  12037. */
  12038. renderingGroupId: number;
  12039. /**
  12040. * The emitter represents the Mesh or position we are attaching the particle system to.
  12041. */
  12042. emitter: Nullable<AbstractMesh | Vector3>;
  12043. /**
  12044. * The maximum number of particles to emit per frame
  12045. */
  12046. emitRate: number;
  12047. /**
  12048. * If you want to launch only a few particles at once, that can be done, as well.
  12049. */
  12050. manualEmitCount: number;
  12051. /**
  12052. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12053. */
  12054. updateSpeed: number;
  12055. /**
  12056. * The amount of time the particle system is running (depends of the overall update speed).
  12057. */
  12058. targetStopDuration: number;
  12059. /**
  12060. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12061. */
  12062. disposeOnStop: boolean;
  12063. /**
  12064. * Minimum power of emitting particles.
  12065. */
  12066. minEmitPower: number;
  12067. /**
  12068. * Maximum power of emitting particles.
  12069. */
  12070. maxEmitPower: number;
  12071. /**
  12072. * Minimum life time of emitting particles.
  12073. */
  12074. minLifeTime: number;
  12075. /**
  12076. * Maximum life time of emitting particles.
  12077. */
  12078. maxLifeTime: number;
  12079. /**
  12080. * Minimum Size of emitting particles.
  12081. */
  12082. minSize: number;
  12083. /**
  12084. * Maximum Size of emitting particles.
  12085. */
  12086. maxSize: number;
  12087. /**
  12088. * Minimum scale of emitting particles on X axis.
  12089. */
  12090. minScaleX: number;
  12091. /**
  12092. * Maximum scale of emitting particles on X axis.
  12093. */
  12094. maxScaleX: number;
  12095. /**
  12096. * Minimum scale of emitting particles on Y axis.
  12097. */
  12098. minScaleY: number;
  12099. /**
  12100. * Maximum scale of emitting particles on Y axis.
  12101. */
  12102. maxScaleY: number;
  12103. /**
  12104. * Gets or sets the minimal initial rotation in radians.
  12105. */
  12106. minInitialRotation: number;
  12107. /**
  12108. * Gets or sets the maximal initial rotation in radians.
  12109. */
  12110. maxInitialRotation: number;
  12111. /**
  12112. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12113. */
  12114. minAngularSpeed: number;
  12115. /**
  12116. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12117. */
  12118. maxAngularSpeed: number;
  12119. /**
  12120. * The texture used to render each particle. (this can be a spritesheet)
  12121. */
  12122. particleTexture: Nullable<BaseTexture>;
  12123. /**
  12124. * The layer mask we are rendering the particles through.
  12125. */
  12126. layerMask: number;
  12127. /**
  12128. * This can help using your own shader to render the particle system.
  12129. * The according effect will be created
  12130. */
  12131. customShader: any;
  12132. /**
  12133. * By default particle system starts as soon as they are created. This prevents the
  12134. * automatic start to happen and let you decide when to start emitting particles.
  12135. */
  12136. preventAutoStart: boolean;
  12137. private _noiseTexture;
  12138. /**
  12139. * Gets or sets a texture used to add random noise to particle positions
  12140. */
  12141. get noiseTexture(): Nullable<ProceduralTexture>;
  12142. set noiseTexture(value: Nullable<ProceduralTexture>);
  12143. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12144. noiseStrength: Vector3;
  12145. /**
  12146. * Callback triggered when the particle animation is ending.
  12147. */
  12148. onAnimationEnd: Nullable<() => void>;
  12149. /**
  12150. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12151. */
  12152. blendMode: number;
  12153. /**
  12154. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12155. * to override the particles.
  12156. */
  12157. forceDepthWrite: boolean;
  12158. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  12159. preWarmCycles: number;
  12160. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12161. preWarmStepOffset: number;
  12162. /**
  12163. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  12164. */
  12165. spriteCellChangeSpeed: number;
  12166. /**
  12167. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12168. */
  12169. startSpriteCellID: number;
  12170. /**
  12171. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12172. */
  12173. endSpriteCellID: number;
  12174. /**
  12175. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12176. */
  12177. spriteCellWidth: number;
  12178. /**
  12179. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12180. */
  12181. spriteCellHeight: number;
  12182. /**
  12183. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12184. */
  12185. spriteRandomStartCell: boolean;
  12186. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12187. translationPivot: Vector2;
  12188. /** @hidden */
  12189. protected _isAnimationSheetEnabled: boolean;
  12190. /**
  12191. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12192. */
  12193. beginAnimationOnStart: boolean;
  12194. /**
  12195. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12196. */
  12197. beginAnimationFrom: number;
  12198. /**
  12199. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12200. */
  12201. beginAnimationTo: number;
  12202. /**
  12203. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12204. */
  12205. beginAnimationLoop: boolean;
  12206. /**
  12207. * Gets or sets a world offset applied to all particles
  12208. */
  12209. worldOffset: Vector3;
  12210. /**
  12211. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12212. */
  12213. get isAnimationSheetEnabled(): boolean;
  12214. set isAnimationSheetEnabled(value: boolean);
  12215. /**
  12216. * Get hosting scene
  12217. * @returns the scene
  12218. */
  12219. getScene(): Nullable<Scene>;
  12220. /**
  12221. * You can use gravity if you want to give an orientation to your particles.
  12222. */
  12223. gravity: Vector3;
  12224. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12225. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12226. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12227. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12228. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12229. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12230. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12231. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12232. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12233. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12234. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12235. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12236. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12237. /**
  12238. * Defines the delay in milliseconds before starting the system (0 by default)
  12239. */
  12240. startDelay: number;
  12241. /**
  12242. * Gets the current list of drag gradients.
  12243. * You must use addDragGradient and removeDragGradient to udpate this list
  12244. * @returns the list of drag gradients
  12245. */
  12246. getDragGradients(): Nullable<Array<FactorGradient>>;
  12247. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12248. limitVelocityDamping: number;
  12249. /**
  12250. * Gets the current list of limit velocity gradients.
  12251. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12252. * @returns the list of limit velocity gradients
  12253. */
  12254. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12255. /**
  12256. * Gets the current list of color gradients.
  12257. * You must use addColorGradient and removeColorGradient to udpate this list
  12258. * @returns the list of color gradients
  12259. */
  12260. getColorGradients(): Nullable<Array<ColorGradient>>;
  12261. /**
  12262. * Gets the current list of size gradients.
  12263. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12264. * @returns the list of size gradients
  12265. */
  12266. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12267. /**
  12268. * Gets the current list of color remap gradients.
  12269. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12270. * @returns the list of color remap gradients
  12271. */
  12272. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12273. /**
  12274. * Gets the current list of alpha remap gradients.
  12275. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12276. * @returns the list of alpha remap gradients
  12277. */
  12278. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12279. /**
  12280. * Gets the current list of life time gradients.
  12281. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12282. * @returns the list of life time gradients
  12283. */
  12284. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12285. /**
  12286. * Gets the current list of angular speed gradients.
  12287. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12288. * @returns the list of angular speed gradients
  12289. */
  12290. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12291. /**
  12292. * Gets the current list of velocity gradients.
  12293. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12294. * @returns the list of velocity gradients
  12295. */
  12296. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12297. /**
  12298. * Gets the current list of start size gradients.
  12299. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12300. * @returns the list of start size gradients
  12301. */
  12302. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12303. /**
  12304. * Gets the current list of emit rate gradients.
  12305. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12306. * @returns the list of emit rate gradients
  12307. */
  12308. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12309. /**
  12310. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12311. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12312. */
  12313. get direction1(): Vector3;
  12314. set direction1(value: Vector3);
  12315. /**
  12316. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12317. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12318. */
  12319. get direction2(): Vector3;
  12320. set direction2(value: Vector3);
  12321. /**
  12322. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12323. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12324. */
  12325. get minEmitBox(): Vector3;
  12326. set minEmitBox(value: Vector3);
  12327. /**
  12328. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12329. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12330. */
  12331. get maxEmitBox(): Vector3;
  12332. set maxEmitBox(value: Vector3);
  12333. /**
  12334. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12335. */
  12336. color1: Color4;
  12337. /**
  12338. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12339. */
  12340. color2: Color4;
  12341. /**
  12342. * Color the particle will have at the end of its lifetime
  12343. */
  12344. colorDead: Color4;
  12345. /**
  12346. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12347. */
  12348. textureMask: Color4;
  12349. /**
  12350. * The particle emitter type defines the emitter used by the particle system.
  12351. * It can be for example box, sphere, or cone...
  12352. */
  12353. particleEmitterType: IParticleEmitterType;
  12354. /** @hidden */
  12355. _isSubEmitter: boolean;
  12356. /**
  12357. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12358. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12359. */
  12360. billboardMode: number;
  12361. protected _isBillboardBased: boolean;
  12362. /**
  12363. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12364. */
  12365. get isBillboardBased(): boolean;
  12366. set isBillboardBased(value: boolean);
  12367. /**
  12368. * The scene the particle system belongs to.
  12369. */
  12370. protected _scene: Nullable<Scene>;
  12371. /**
  12372. * The engine the particle system belongs to.
  12373. */
  12374. protected _engine: ThinEngine;
  12375. /**
  12376. * Local cache of defines for image processing.
  12377. */
  12378. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12379. /**
  12380. * Default configuration related to image processing available in the standard Material.
  12381. */
  12382. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12383. /**
  12384. * Gets the image processing configuration used either in this material.
  12385. */
  12386. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12387. /**
  12388. * Sets the Default image processing configuration used either in the this material.
  12389. *
  12390. * If sets to null, the scene one is in use.
  12391. */
  12392. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12393. /**
  12394. * Attaches a new image processing configuration to the Standard Material.
  12395. * @param configuration
  12396. */
  12397. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12398. /** @hidden */
  12399. protected _reset(): void;
  12400. /** @hidden */
  12401. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12402. /**
  12403. * Instantiates a particle system.
  12404. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12405. * @param name The name of the particle system
  12406. */
  12407. constructor(name: string);
  12408. /**
  12409. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12410. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12411. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12412. * @returns the emitter
  12413. */
  12414. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12415. /**
  12416. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12417. * @param radius The radius of the hemisphere to emit from
  12418. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12419. * @returns the emitter
  12420. */
  12421. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12422. /**
  12423. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12424. * @param radius The radius of the sphere to emit from
  12425. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12426. * @returns the emitter
  12427. */
  12428. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12429. /**
  12430. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12431. * @param radius The radius of the sphere to emit from
  12432. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12433. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12434. * @returns the emitter
  12435. */
  12436. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12437. /**
  12438. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12439. * @param radius The radius of the emission cylinder
  12440. * @param height The height of the emission cylinder
  12441. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12442. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12443. * @returns the emitter
  12444. */
  12445. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12446. /**
  12447. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12448. * @param radius The radius of the cylinder to emit from
  12449. * @param height The height of the emission cylinder
  12450. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12451. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12452. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12453. * @returns the emitter
  12454. */
  12455. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12456. /**
  12457. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12458. * @param radius The radius of the cone to emit from
  12459. * @param angle The base angle of the cone
  12460. * @returns the emitter
  12461. */
  12462. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12463. /**
  12464. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12465. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12466. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12467. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12468. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12469. * @returns the emitter
  12470. */
  12471. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12472. }
  12473. }
  12474. declare module BABYLON {
  12475. /**
  12476. * Type of sub emitter
  12477. */
  12478. export enum SubEmitterType {
  12479. /**
  12480. * Attached to the particle over it's lifetime
  12481. */
  12482. ATTACHED = 0,
  12483. /**
  12484. * Created when the particle dies
  12485. */
  12486. END = 1
  12487. }
  12488. /**
  12489. * Sub emitter class used to emit particles from an existing particle
  12490. */
  12491. export class SubEmitter {
  12492. /**
  12493. * the particle system to be used by the sub emitter
  12494. */
  12495. particleSystem: ParticleSystem;
  12496. /**
  12497. * Type of the submitter (Default: END)
  12498. */
  12499. type: SubEmitterType;
  12500. /**
  12501. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  12502. * Note: This only is supported when using an emitter of type Mesh
  12503. */
  12504. inheritDirection: boolean;
  12505. /**
  12506. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12507. */
  12508. inheritedVelocityAmount: number;
  12509. /**
  12510. * Creates a sub emitter
  12511. * @param particleSystem the particle system to be used by the sub emitter
  12512. */
  12513. constructor(
  12514. /**
  12515. * the particle system to be used by the sub emitter
  12516. */
  12517. particleSystem: ParticleSystem);
  12518. /**
  12519. * Clones the sub emitter
  12520. * @returns the cloned sub emitter
  12521. */
  12522. clone(): SubEmitter;
  12523. /**
  12524. * Serialize current object to a JSON object
  12525. * @returns the serialized object
  12526. */
  12527. serialize(): any;
  12528. /** @hidden */
  12529. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12530. /**
  12531. * Creates a new SubEmitter from a serialized JSON version
  12532. * @param serializationObject defines the JSON object to read from
  12533. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12534. * @param rootUrl defines the rootUrl for data loading
  12535. * @returns a new SubEmitter
  12536. */
  12537. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12538. /** Release associated resources */
  12539. dispose(): void;
  12540. }
  12541. }
  12542. declare module BABYLON {
  12543. /** @hidden */
  12544. export var imageProcessingDeclaration: {
  12545. name: string;
  12546. shader: string;
  12547. };
  12548. }
  12549. declare module BABYLON {
  12550. /** @hidden */
  12551. export var imageProcessingFunctions: {
  12552. name: string;
  12553. shader: string;
  12554. };
  12555. }
  12556. declare module BABYLON {
  12557. /** @hidden */
  12558. export var particlesPixelShader: {
  12559. name: string;
  12560. shader: string;
  12561. };
  12562. }
  12563. declare module BABYLON {
  12564. /** @hidden */
  12565. export var particlesVertexShader: {
  12566. name: string;
  12567. shader: string;
  12568. };
  12569. }
  12570. declare module BABYLON {
  12571. /**
  12572. * Interface used to define entities containing multiple clip planes
  12573. */
  12574. export interface IClipPlanesHolder {
  12575. /**
  12576. * Gets or sets the active clipplane 1
  12577. */
  12578. clipPlane: Nullable<Plane>;
  12579. /**
  12580. * Gets or sets the active clipplane 2
  12581. */
  12582. clipPlane2: Nullable<Plane>;
  12583. /**
  12584. * Gets or sets the active clipplane 3
  12585. */
  12586. clipPlane3: Nullable<Plane>;
  12587. /**
  12588. * Gets or sets the active clipplane 4
  12589. */
  12590. clipPlane4: Nullable<Plane>;
  12591. /**
  12592. * Gets or sets the active clipplane 5
  12593. */
  12594. clipPlane5: Nullable<Plane>;
  12595. /**
  12596. * Gets or sets the active clipplane 6
  12597. */
  12598. clipPlane6: Nullable<Plane>;
  12599. }
  12600. }
  12601. declare module BABYLON {
  12602. /**
  12603. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12604. *
  12605. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12606. *
  12607. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12608. */
  12609. export class ThinMaterialHelper {
  12610. /**
  12611. * Binds the clip plane information from the holder to the effect.
  12612. * @param effect The effect we are binding the data to
  12613. * @param holder The entity containing the clip plane information
  12614. */
  12615. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12616. }
  12617. }
  12618. declare module BABYLON {
  12619. interface ThinEngine {
  12620. /**
  12621. * Sets alpha constants used by some alpha blending modes
  12622. * @param r defines the red component
  12623. * @param g defines the green component
  12624. * @param b defines the blue component
  12625. * @param a defines the alpha component
  12626. */
  12627. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12628. /**
  12629. * Sets the current alpha mode
  12630. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12631. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12632. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12633. */
  12634. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12635. /**
  12636. * Gets the current alpha mode
  12637. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12638. * @returns the current alpha mode
  12639. */
  12640. getAlphaMode(): number;
  12641. /**
  12642. * Sets the current alpha equation
  12643. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12644. */
  12645. setAlphaEquation(equation: number): void;
  12646. /**
  12647. * Gets the current alpha equation.
  12648. * @returns the current alpha equation
  12649. */
  12650. getAlphaEquation(): number;
  12651. }
  12652. }
  12653. declare module BABYLON {
  12654. /**
  12655. * This represents a particle system in Babylon.
  12656. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12657. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12658. * @example https://doc.babylonjs.com/babylon101/particles
  12659. */
  12660. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12661. /**
  12662. * Billboard mode will only apply to Y axis
  12663. */
  12664. static readonly BILLBOARDMODE_Y: number;
  12665. /**
  12666. * Billboard mode will apply to all axes
  12667. */
  12668. static readonly BILLBOARDMODE_ALL: number;
  12669. /**
  12670. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12671. */
  12672. static readonly BILLBOARDMODE_STRETCHED: number;
  12673. /**
  12674. * This function can be defined to provide custom update for active particles.
  12675. * This function will be called instead of regular update (age, position, color, etc.).
  12676. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12677. */
  12678. updateFunction: (particles: Particle[]) => void;
  12679. private _emitterWorldMatrix;
  12680. /**
  12681. * This function can be defined to specify initial direction for every new particle.
  12682. * It by default use the emitterType defined function
  12683. */
  12684. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12685. /**
  12686. * This function can be defined to specify initial position for every new particle.
  12687. * It by default use the emitterType defined function
  12688. */
  12689. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12690. /**
  12691. * @hidden
  12692. */
  12693. _inheritedVelocityOffset: Vector3;
  12694. /**
  12695. * An event triggered when the system is disposed
  12696. */
  12697. onDisposeObservable: Observable<IParticleSystem>;
  12698. /**
  12699. * An event triggered when the system is stopped
  12700. */
  12701. onStoppedObservable: Observable<IParticleSystem>;
  12702. private _onDisposeObserver;
  12703. /**
  12704. * Sets a callback that will be triggered when the system is disposed
  12705. */
  12706. set onDispose(callback: () => void);
  12707. private _particles;
  12708. private _epsilon;
  12709. private _capacity;
  12710. private _stockParticles;
  12711. private _newPartsExcess;
  12712. private _vertexData;
  12713. private _vertexBuffer;
  12714. private _vertexBuffers;
  12715. private _spriteBuffer;
  12716. private _indexBuffer;
  12717. private _effect;
  12718. private _customEffect;
  12719. private _cachedDefines;
  12720. private _scaledColorStep;
  12721. private _colorDiff;
  12722. private _scaledDirection;
  12723. private _scaledGravity;
  12724. private _currentRenderId;
  12725. private _alive;
  12726. private _useInstancing;
  12727. private _vertexArrayObject;
  12728. private _started;
  12729. private _stopped;
  12730. private _actualFrame;
  12731. private _scaledUpdateSpeed;
  12732. private _vertexBufferSize;
  12733. /** @hidden */
  12734. _currentEmitRateGradient: Nullable<FactorGradient>;
  12735. /** @hidden */
  12736. _currentEmitRate1: number;
  12737. /** @hidden */
  12738. _currentEmitRate2: number;
  12739. /** @hidden */
  12740. _currentStartSizeGradient: Nullable<FactorGradient>;
  12741. /** @hidden */
  12742. _currentStartSize1: number;
  12743. /** @hidden */
  12744. _currentStartSize2: number;
  12745. private readonly _rawTextureWidth;
  12746. private _rampGradientsTexture;
  12747. private _useRampGradients;
  12748. /** Gets or sets a matrix to use to compute projection */
  12749. defaultProjectionMatrix: Matrix;
  12750. /** Gets or sets a matrix to use to compute view */
  12751. defaultViewMatrix: Matrix;
  12752. /** Gets or sets a boolean indicating that ramp gradients must be used
  12753. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12754. */
  12755. get useRampGradients(): boolean;
  12756. set useRampGradients(value: boolean);
  12757. /**
  12758. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  12759. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  12760. */
  12761. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12762. private _subEmitters;
  12763. /**
  12764. * @hidden
  12765. * If the particle systems emitter should be disposed when the particle system is disposed
  12766. */
  12767. _disposeEmitterOnDispose: boolean;
  12768. /**
  12769. * The current active Sub-systems, this property is used by the root particle system only.
  12770. */
  12771. activeSubSystems: Array<ParticleSystem>;
  12772. /**
  12773. * Specifies if the particles are updated in emitter local space or world space
  12774. */
  12775. isLocal: boolean;
  12776. private _rootParticleSystem;
  12777. /**
  12778. * Gets the current list of active particles
  12779. */
  12780. get particles(): Particle[];
  12781. /**
  12782. * Gets the number of particles active at the same time.
  12783. * @returns The number of active particles.
  12784. */
  12785. getActiveCount(): number;
  12786. /**
  12787. * Returns the string "ParticleSystem"
  12788. * @returns a string containing the class name
  12789. */
  12790. getClassName(): string;
  12791. /**
  12792. * Gets a boolean indicating that the system is stopping
  12793. * @returns true if the system is currently stopping
  12794. */
  12795. isStopping(): boolean;
  12796. /**
  12797. * Gets the custom effect used to render the particles
  12798. * @param blendMode Blend mode for which the effect should be retrieved
  12799. * @returns The effect
  12800. */
  12801. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12802. /**
  12803. * Sets the custom effect used to render the particles
  12804. * @param effect The effect to set
  12805. * @param blendMode Blend mode for which the effect should be set
  12806. */
  12807. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12808. /** @hidden */
  12809. private _onBeforeDrawParticlesObservable;
  12810. /**
  12811. * Observable that will be called just before the particles are drawn
  12812. */
  12813. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12814. /**
  12815. * Gets the name of the particle vertex shader
  12816. */
  12817. get vertexShaderName(): string;
  12818. /**
  12819. * Instantiates a particle system.
  12820. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12821. * @param name The name of the particle system
  12822. * @param capacity The max number of particles alive at the same time
  12823. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12824. * @param customEffect a custom effect used to change the way particles are rendered by default
  12825. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12826. * @param epsilon Offset used to render the particles
  12827. */
  12828. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12829. private _addFactorGradient;
  12830. private _removeFactorGradient;
  12831. /**
  12832. * Adds a new life time gradient
  12833. * @param gradient defines the gradient to use (between 0 and 1)
  12834. * @param factor defines the life time factor to affect to the specified gradient
  12835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12836. * @returns the current particle system
  12837. */
  12838. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12839. /**
  12840. * Remove a specific life time gradient
  12841. * @param gradient defines the gradient to remove
  12842. * @returns the current particle system
  12843. */
  12844. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12845. /**
  12846. * Adds a new size gradient
  12847. * @param gradient defines the gradient to use (between 0 and 1)
  12848. * @param factor defines the size factor to affect to the specified gradient
  12849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12850. * @returns the current particle system
  12851. */
  12852. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12853. /**
  12854. * Remove a specific size gradient
  12855. * @param gradient defines the gradient to remove
  12856. * @returns the current particle system
  12857. */
  12858. removeSizeGradient(gradient: number): IParticleSystem;
  12859. /**
  12860. * Adds a new color remap gradient
  12861. * @param gradient defines the gradient to use (between 0 and 1)
  12862. * @param min defines the color remap minimal range
  12863. * @param max defines the color remap maximal range
  12864. * @returns the current particle system
  12865. */
  12866. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12867. /**
  12868. * Remove a specific color remap gradient
  12869. * @param gradient defines the gradient to remove
  12870. * @returns the current particle system
  12871. */
  12872. removeColorRemapGradient(gradient: number): IParticleSystem;
  12873. /**
  12874. * Adds a new alpha remap gradient
  12875. * @param gradient defines the gradient to use (between 0 and 1)
  12876. * @param min defines the alpha remap minimal range
  12877. * @param max defines the alpha remap maximal range
  12878. * @returns the current particle system
  12879. */
  12880. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12881. /**
  12882. * Remove a specific alpha remap gradient
  12883. * @param gradient defines the gradient to remove
  12884. * @returns the current particle system
  12885. */
  12886. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12887. /**
  12888. * Adds a new angular speed gradient
  12889. * @param gradient defines the gradient to use (between 0 and 1)
  12890. * @param factor defines the angular speed to affect to the specified gradient
  12891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12892. * @returns the current particle system
  12893. */
  12894. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12895. /**
  12896. * Remove a specific angular speed gradient
  12897. * @param gradient defines the gradient to remove
  12898. * @returns the current particle system
  12899. */
  12900. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12901. /**
  12902. * Adds a new velocity gradient
  12903. * @param gradient defines the gradient to use (between 0 and 1)
  12904. * @param factor defines the velocity to affect to the specified gradient
  12905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12906. * @returns the current particle system
  12907. */
  12908. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12909. /**
  12910. * Remove a specific velocity gradient
  12911. * @param gradient defines the gradient to remove
  12912. * @returns the current particle system
  12913. */
  12914. removeVelocityGradient(gradient: number): IParticleSystem;
  12915. /**
  12916. * Adds a new limit velocity gradient
  12917. * @param gradient defines the gradient to use (between 0 and 1)
  12918. * @param factor defines the limit velocity value to affect to the specified gradient
  12919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12920. * @returns the current particle system
  12921. */
  12922. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12923. /**
  12924. * Remove a specific limit velocity gradient
  12925. * @param gradient defines the gradient to remove
  12926. * @returns the current particle system
  12927. */
  12928. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12929. /**
  12930. * Adds a new drag gradient
  12931. * @param gradient defines the gradient to use (between 0 and 1)
  12932. * @param factor defines the drag value to affect to the specified gradient
  12933. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12934. * @returns the current particle system
  12935. */
  12936. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12937. /**
  12938. * Remove a specific drag gradient
  12939. * @param gradient defines the gradient to remove
  12940. * @returns the current particle system
  12941. */
  12942. removeDragGradient(gradient: number): IParticleSystem;
  12943. /**
  12944. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12945. * @param gradient defines the gradient to use (between 0 and 1)
  12946. * @param factor defines the emit rate value to affect to the specified gradient
  12947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12948. * @returns the current particle system
  12949. */
  12950. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12951. /**
  12952. * Remove a specific emit rate gradient
  12953. * @param gradient defines the gradient to remove
  12954. * @returns the current particle system
  12955. */
  12956. removeEmitRateGradient(gradient: number): IParticleSystem;
  12957. /**
  12958. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12959. * @param gradient defines the gradient to use (between 0 and 1)
  12960. * @param factor defines the start size value to affect to the specified gradient
  12961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12962. * @returns the current particle system
  12963. */
  12964. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12965. /**
  12966. * Remove a specific start size gradient
  12967. * @param gradient defines the gradient to remove
  12968. * @returns the current particle system
  12969. */
  12970. removeStartSizeGradient(gradient: number): IParticleSystem;
  12971. private _createRampGradientTexture;
  12972. /**
  12973. * Gets the current list of ramp gradients.
  12974. * You must use addRampGradient and removeRampGradient to udpate this list
  12975. * @returns the list of ramp gradients
  12976. */
  12977. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12978. /** Force the system to rebuild all gradients that need to be resync */
  12979. forceRefreshGradients(): void;
  12980. private _syncRampGradientTexture;
  12981. /**
  12982. * Adds a new ramp gradient used to remap particle colors
  12983. * @param gradient defines the gradient to use (between 0 and 1)
  12984. * @param color defines the color to affect to the specified gradient
  12985. * @returns the current particle system
  12986. */
  12987. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12988. /**
  12989. * Remove a specific ramp gradient
  12990. * @param gradient defines the gradient to remove
  12991. * @returns the current particle system
  12992. */
  12993. removeRampGradient(gradient: number): ParticleSystem;
  12994. /**
  12995. * Adds a new color gradient
  12996. * @param gradient defines the gradient to use (between 0 and 1)
  12997. * @param color1 defines the color to affect to the specified gradient
  12998. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12999. * @returns this particle system
  13000. */
  13001. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13002. /**
  13003. * Remove a specific color gradient
  13004. * @param gradient defines the gradient to remove
  13005. * @returns this particle system
  13006. */
  13007. removeColorGradient(gradient: number): IParticleSystem;
  13008. private _fetchR;
  13009. protected _reset(): void;
  13010. private _resetEffect;
  13011. private _createVertexBuffers;
  13012. private _createIndexBuffer;
  13013. /**
  13014. * Gets the maximum number of particles active at the same time.
  13015. * @returns The max number of active particles.
  13016. */
  13017. getCapacity(): number;
  13018. /**
  13019. * Gets whether there are still active particles in the system.
  13020. * @returns True if it is alive, otherwise false.
  13021. */
  13022. isAlive(): boolean;
  13023. /**
  13024. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13025. * @returns True if it has been started, otherwise false.
  13026. */
  13027. isStarted(): boolean;
  13028. private _prepareSubEmitterInternalArray;
  13029. /**
  13030. * Starts the particle system and begins to emit
  13031. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13032. */
  13033. start(delay?: number): void;
  13034. /**
  13035. * Stops the particle system.
  13036. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  13037. */
  13038. stop(stopSubEmitters?: boolean): void;
  13039. /**
  13040. * Remove all active particles
  13041. */
  13042. reset(): void;
  13043. /**
  13044. * @hidden (for internal use only)
  13045. */
  13046. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13047. /**
  13048. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13049. * Its lifetime will start back at 0.
  13050. */
  13051. recycleParticle: (particle: Particle) => void;
  13052. private _stopSubEmitters;
  13053. private _createParticle;
  13054. private _removeFromRoot;
  13055. private _emitFromParticle;
  13056. private _update;
  13057. /** @hidden */
  13058. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13059. /** @hidden */
  13060. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13061. /**
  13062. * Fill the defines array according to the current settings of the particle system
  13063. * @param defines Array to be updated
  13064. * @param blendMode blend mode to take into account when updating the array
  13065. */
  13066. fillDefines(defines: Array<string>, blendMode: number): void;
  13067. /**
  13068. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13069. * @param uniforms Uniforms array to fill
  13070. * @param attributes Attributes array to fill
  13071. * @param samplers Samplers array to fill
  13072. */
  13073. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13074. /** @hidden */
  13075. private _getEffect;
  13076. /**
  13077. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13078. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13079. */
  13080. animate(preWarmOnly?: boolean): void;
  13081. private _appendParticleVertices;
  13082. /**
  13083. * Rebuilds the particle system.
  13084. */
  13085. rebuild(): void;
  13086. /**
  13087. * Is this system ready to be used/rendered
  13088. * @return true if the system is ready
  13089. */
  13090. isReady(): boolean;
  13091. private _render;
  13092. /**
  13093. * Renders the particle system in its current state.
  13094. * @returns the current number of particles
  13095. */
  13096. render(): number;
  13097. /**
  13098. * Disposes the particle system and free the associated resources
  13099. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13100. */
  13101. dispose(disposeTexture?: boolean): void;
  13102. /**
  13103. * Clones the particle system.
  13104. * @param name The name of the cloned object
  13105. * @param newEmitter The new emitter to use
  13106. * @returns the cloned particle system
  13107. */
  13108. clone(name: string, newEmitter: any): ParticleSystem;
  13109. /**
  13110. * Serializes the particle system to a JSON object
  13111. * @param serializeTexture defines if the texture must be serialized as well
  13112. * @returns the JSON object
  13113. */
  13114. serialize(serializeTexture?: boolean): any;
  13115. /** @hidden */
  13116. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13117. /** @hidden */
  13118. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13119. /**
  13120. * Parses a JSON object to create a particle system.
  13121. * @param parsedParticleSystem The JSON object to parse
  13122. * @param sceneOrEngine The scene or the engine to create the particle system in
  13123. * @param rootUrl The root url to use to load external dependencies like texture
  13124. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13125. * @returns the Parsed particle system
  13126. */
  13127. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13128. }
  13129. }
  13130. declare module BABYLON {
  13131. /**
  13132. * A particle represents one of the element emitted by a particle system.
  13133. * This is mainly define by its coordinates, direction, velocity and age.
  13134. */
  13135. export class Particle {
  13136. /**
  13137. * The particle system the particle belongs to.
  13138. */
  13139. particleSystem: ParticleSystem;
  13140. private static _Count;
  13141. /**
  13142. * Unique ID of the particle
  13143. */
  13144. id: number;
  13145. /**
  13146. * The world position of the particle in the scene.
  13147. */
  13148. position: Vector3;
  13149. /**
  13150. * The world direction of the particle in the scene.
  13151. */
  13152. direction: Vector3;
  13153. /**
  13154. * The color of the particle.
  13155. */
  13156. color: Color4;
  13157. /**
  13158. * The color change of the particle per step.
  13159. */
  13160. colorStep: Color4;
  13161. /**
  13162. * Defines how long will the life of the particle be.
  13163. */
  13164. lifeTime: number;
  13165. /**
  13166. * The current age of the particle.
  13167. */
  13168. age: number;
  13169. /**
  13170. * The current size of the particle.
  13171. */
  13172. size: number;
  13173. /**
  13174. * The current scale of the particle.
  13175. */
  13176. scale: Vector2;
  13177. /**
  13178. * The current angle of the particle.
  13179. */
  13180. angle: number;
  13181. /**
  13182. * Defines how fast is the angle changing.
  13183. */
  13184. angularSpeed: number;
  13185. /**
  13186. * Defines the cell index used by the particle to be rendered from a sprite.
  13187. */
  13188. cellIndex: number;
  13189. /**
  13190. * The information required to support color remapping
  13191. */
  13192. remapData: Vector4;
  13193. /** @hidden */
  13194. _randomCellOffset?: number;
  13195. /** @hidden */
  13196. _initialDirection: Nullable<Vector3>;
  13197. /** @hidden */
  13198. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13199. /** @hidden */
  13200. _initialStartSpriteCellID: number;
  13201. /** @hidden */
  13202. _initialEndSpriteCellID: number;
  13203. /** @hidden */
  13204. _currentColorGradient: Nullable<ColorGradient>;
  13205. /** @hidden */
  13206. _currentColor1: Color4;
  13207. /** @hidden */
  13208. _currentColor2: Color4;
  13209. /** @hidden */
  13210. _currentSizeGradient: Nullable<FactorGradient>;
  13211. /** @hidden */
  13212. _currentSize1: number;
  13213. /** @hidden */
  13214. _currentSize2: number;
  13215. /** @hidden */
  13216. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13217. /** @hidden */
  13218. _currentAngularSpeed1: number;
  13219. /** @hidden */
  13220. _currentAngularSpeed2: number;
  13221. /** @hidden */
  13222. _currentVelocityGradient: Nullable<FactorGradient>;
  13223. /** @hidden */
  13224. _currentVelocity1: number;
  13225. /** @hidden */
  13226. _currentVelocity2: number;
  13227. /** @hidden */
  13228. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13229. /** @hidden */
  13230. _currentLimitVelocity1: number;
  13231. /** @hidden */
  13232. _currentLimitVelocity2: number;
  13233. /** @hidden */
  13234. _currentDragGradient: Nullable<FactorGradient>;
  13235. /** @hidden */
  13236. _currentDrag1: number;
  13237. /** @hidden */
  13238. _currentDrag2: number;
  13239. /** @hidden */
  13240. _randomNoiseCoordinates1: Vector3;
  13241. /** @hidden */
  13242. _randomNoiseCoordinates2: Vector3;
  13243. /** @hidden */
  13244. _localPosition?: Vector3;
  13245. /**
  13246. * Creates a new instance Particle
  13247. * @param particleSystem the particle system the particle belongs to
  13248. */
  13249. constructor(
  13250. /**
  13251. * The particle system the particle belongs to.
  13252. */
  13253. particleSystem: ParticleSystem);
  13254. private updateCellInfoFromSystem;
  13255. /**
  13256. * Defines how the sprite cell index is updated for the particle
  13257. */
  13258. updateCellIndex(): void;
  13259. /** @hidden */
  13260. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13261. /** @hidden */
  13262. _inheritParticleInfoToSubEmitters(): void;
  13263. /** @hidden */
  13264. _reset(): void;
  13265. /**
  13266. * Copy the properties of particle to another one.
  13267. * @param other the particle to copy the information to.
  13268. */
  13269. copyTo(other: Particle): void;
  13270. }
  13271. }
  13272. declare module BABYLON {
  13273. /**
  13274. * Particle emitter represents a volume emitting particles.
  13275. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13276. */
  13277. export interface IParticleEmitterType {
  13278. /**
  13279. * Called by the particle System when the direction is computed for the created particle.
  13280. * @param worldMatrix is the world matrix of the particle system
  13281. * @param directionToUpdate is the direction vector to update with the result
  13282. * @param particle is the particle we are computed the direction for
  13283. * @param isLocal defines if the direction should be set in local space
  13284. */
  13285. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13286. /**
  13287. * Called by the particle System when the position is computed for the created particle.
  13288. * @param worldMatrix is the world matrix of the particle system
  13289. * @param positionToUpdate is the position vector to update with the result
  13290. * @param particle is the particle we are computed the position for
  13291. * @param isLocal defines if the position should be set in local space
  13292. */
  13293. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13294. /**
  13295. * Clones the current emitter and returns a copy of it
  13296. * @returns the new emitter
  13297. */
  13298. clone(): IParticleEmitterType;
  13299. /**
  13300. * Called by the GPUParticleSystem to setup the update shader
  13301. * @param effect defines the update shader
  13302. */
  13303. applyToShader(effect: Effect): void;
  13304. /**
  13305. * Returns a string to use to update the GPU particles update shader
  13306. * @returns the effect defines string
  13307. */
  13308. getEffectDefines(): string;
  13309. /**
  13310. * Returns a string representing the class name
  13311. * @returns a string containing the class name
  13312. */
  13313. getClassName(): string;
  13314. /**
  13315. * Serializes the particle system to a JSON object.
  13316. * @returns the JSON object
  13317. */
  13318. serialize(): any;
  13319. /**
  13320. * Parse properties from a JSON object
  13321. * @param serializationObject defines the JSON object
  13322. * @param scene defines the hosting scene
  13323. */
  13324. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13325. }
  13326. }
  13327. declare module BABYLON {
  13328. /**
  13329. * Particle emitter emitting particles from the inside of a box.
  13330. * It emits the particles randomly between 2 given directions.
  13331. */
  13332. export class BoxParticleEmitter implements IParticleEmitterType {
  13333. /**
  13334. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13335. */
  13336. direction1: Vector3;
  13337. /**
  13338. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13339. */
  13340. direction2: Vector3;
  13341. /**
  13342. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13343. */
  13344. minEmitBox: Vector3;
  13345. /**
  13346. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13347. */
  13348. maxEmitBox: Vector3;
  13349. /**
  13350. * Creates a new instance BoxParticleEmitter
  13351. */
  13352. constructor();
  13353. /**
  13354. * Called by the particle System when the direction is computed for the created particle.
  13355. * @param worldMatrix is the world matrix of the particle system
  13356. * @param directionToUpdate is the direction vector to update with the result
  13357. * @param particle is the particle we are computed the direction for
  13358. * @param isLocal defines if the direction should be set in local space
  13359. */
  13360. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13361. /**
  13362. * Called by the particle System when the position is computed for the created particle.
  13363. * @param worldMatrix is the world matrix of the particle system
  13364. * @param positionToUpdate is the position vector to update with the result
  13365. * @param particle is the particle we are computed the position for
  13366. * @param isLocal defines if the position should be set in local space
  13367. */
  13368. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13369. /**
  13370. * Clones the current emitter and returns a copy of it
  13371. * @returns the new emitter
  13372. */
  13373. clone(): BoxParticleEmitter;
  13374. /**
  13375. * Called by the GPUParticleSystem to setup the update shader
  13376. * @param effect defines the update shader
  13377. */
  13378. applyToShader(effect: Effect): void;
  13379. /**
  13380. * Returns a string to use to update the GPU particles update shader
  13381. * @returns a string containng the defines string
  13382. */
  13383. getEffectDefines(): string;
  13384. /**
  13385. * Returns the string "BoxParticleEmitter"
  13386. * @returns a string containing the class name
  13387. */
  13388. getClassName(): string;
  13389. /**
  13390. * Serializes the particle system to a JSON object.
  13391. * @returns the JSON object
  13392. */
  13393. serialize(): any;
  13394. /**
  13395. * Parse properties from a JSON object
  13396. * @param serializationObject defines the JSON object
  13397. */
  13398. parse(serializationObject: any): void;
  13399. }
  13400. }
  13401. declare module BABYLON {
  13402. /**
  13403. * Particle emitter emitting particles from the inside of a cone.
  13404. * It emits the particles alongside the cone volume from the base to the particle.
  13405. * The emission direction might be randomized.
  13406. */
  13407. export class ConeParticleEmitter implements IParticleEmitterType {
  13408. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13409. directionRandomizer: number;
  13410. private _radius;
  13411. private _angle;
  13412. private _height;
  13413. /**
  13414. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13415. */
  13416. radiusRange: number;
  13417. /**
  13418. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13419. */
  13420. heightRange: number;
  13421. /**
  13422. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13423. */
  13424. emitFromSpawnPointOnly: boolean;
  13425. /**
  13426. * Gets or sets the radius of the emission cone
  13427. */
  13428. get radius(): number;
  13429. set radius(value: number);
  13430. /**
  13431. * Gets or sets the angle of the emission cone
  13432. */
  13433. get angle(): number;
  13434. set angle(value: number);
  13435. private _buildHeight;
  13436. /**
  13437. * Creates a new instance ConeParticleEmitter
  13438. * @param radius the radius of the emission cone (1 by default)
  13439. * @param angle the cone base angle (PI by default)
  13440. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13441. */
  13442. constructor(radius?: number, angle?: number,
  13443. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13444. directionRandomizer?: number);
  13445. /**
  13446. * Called by the particle System when the direction is computed for the created particle.
  13447. * @param worldMatrix is the world matrix of the particle system
  13448. * @param directionToUpdate is the direction vector to update with the result
  13449. * @param particle is the particle we are computed the direction for
  13450. * @param isLocal defines if the direction should be set in local space
  13451. */
  13452. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13453. /**
  13454. * Called by the particle System when the position is computed for the created particle.
  13455. * @param worldMatrix is the world matrix of the particle system
  13456. * @param positionToUpdate is the position vector to update with the result
  13457. * @param particle is the particle we are computed the position for
  13458. * @param isLocal defines if the position should be set in local space
  13459. */
  13460. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13461. /**
  13462. * Clones the current emitter and returns a copy of it
  13463. * @returns the new emitter
  13464. */
  13465. clone(): ConeParticleEmitter;
  13466. /**
  13467. * Called by the GPUParticleSystem to setup the update shader
  13468. * @param effect defines the update shader
  13469. */
  13470. applyToShader(effect: Effect): void;
  13471. /**
  13472. * Returns a string to use to update the GPU particles update shader
  13473. * @returns a string containng the defines string
  13474. */
  13475. getEffectDefines(): string;
  13476. /**
  13477. * Returns the string "ConeParticleEmitter"
  13478. * @returns a string containing the class name
  13479. */
  13480. getClassName(): string;
  13481. /**
  13482. * Serializes the particle system to a JSON object.
  13483. * @returns the JSON object
  13484. */
  13485. serialize(): any;
  13486. /**
  13487. * Parse properties from a JSON object
  13488. * @param serializationObject defines the JSON object
  13489. */
  13490. parse(serializationObject: any): void;
  13491. }
  13492. }
  13493. declare module BABYLON {
  13494. /**
  13495. * Particle emitter emitting particles from the inside of a cylinder.
  13496. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13497. */
  13498. export class CylinderParticleEmitter implements IParticleEmitterType {
  13499. /**
  13500. * The radius of the emission cylinder.
  13501. */
  13502. radius: number;
  13503. /**
  13504. * The height of the emission cylinder.
  13505. */
  13506. height: number;
  13507. /**
  13508. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13509. */
  13510. radiusRange: number;
  13511. /**
  13512. * How much to randomize the particle direction [0-1].
  13513. */
  13514. directionRandomizer: number;
  13515. /**
  13516. * Creates a new instance CylinderParticleEmitter
  13517. * @param radius the radius of the emission cylinder (1 by default)
  13518. * @param height the height of the emission cylinder (1 by default)
  13519. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13520. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13521. */
  13522. constructor(
  13523. /**
  13524. * The radius of the emission cylinder.
  13525. */
  13526. radius?: number,
  13527. /**
  13528. * The height of the emission cylinder.
  13529. */
  13530. height?: number,
  13531. /**
  13532. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13533. */
  13534. radiusRange?: number,
  13535. /**
  13536. * How much to randomize the particle direction [0-1].
  13537. */
  13538. directionRandomizer?: number);
  13539. /**
  13540. * Called by the particle System when the direction is computed for the created particle.
  13541. * @param worldMatrix is the world matrix of the particle system
  13542. * @param directionToUpdate is the direction vector to update with the result
  13543. * @param particle is the particle we are computed the direction for
  13544. * @param isLocal defines if the direction should be set in local space
  13545. */
  13546. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13547. /**
  13548. * Called by the particle System when the position is computed for the created particle.
  13549. * @param worldMatrix is the world matrix of the particle system
  13550. * @param positionToUpdate is the position vector to update with the result
  13551. * @param particle is the particle we are computed the position for
  13552. * @param isLocal defines if the position should be set in local space
  13553. */
  13554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13555. /**
  13556. * Clones the current emitter and returns a copy of it
  13557. * @returns the new emitter
  13558. */
  13559. clone(): CylinderParticleEmitter;
  13560. /**
  13561. * Called by the GPUParticleSystem to setup the update shader
  13562. * @param effect defines the update shader
  13563. */
  13564. applyToShader(effect: Effect): void;
  13565. /**
  13566. * Returns a string to use to update the GPU particles update shader
  13567. * @returns a string containng the defines string
  13568. */
  13569. getEffectDefines(): string;
  13570. /**
  13571. * Returns the string "CylinderParticleEmitter"
  13572. * @returns a string containing the class name
  13573. */
  13574. getClassName(): string;
  13575. /**
  13576. * Serializes the particle system to a JSON object.
  13577. * @returns the JSON object
  13578. */
  13579. serialize(): any;
  13580. /**
  13581. * Parse properties from a JSON object
  13582. * @param serializationObject defines the JSON object
  13583. */
  13584. parse(serializationObject: any): void;
  13585. }
  13586. /**
  13587. * Particle emitter emitting particles from the inside of a cylinder.
  13588. * It emits the particles randomly between two vectors.
  13589. */
  13590. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13591. /**
  13592. * The min limit of the emission direction.
  13593. */
  13594. direction1: Vector3;
  13595. /**
  13596. * The max limit of the emission direction.
  13597. */
  13598. direction2: Vector3;
  13599. /**
  13600. * Creates a new instance CylinderDirectedParticleEmitter
  13601. * @param radius the radius of the emission cylinder (1 by default)
  13602. * @param height the height of the emission cylinder (1 by default)
  13603. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13604. * @param direction1 the min limit of the emission direction (up vector by default)
  13605. * @param direction2 the max limit of the emission direction (up vector by default)
  13606. */
  13607. constructor(radius?: number, height?: number, radiusRange?: number,
  13608. /**
  13609. * The min limit of the emission direction.
  13610. */
  13611. direction1?: Vector3,
  13612. /**
  13613. * The max limit of the emission direction.
  13614. */
  13615. direction2?: Vector3);
  13616. /**
  13617. * Called by the particle System when the direction is computed for the created particle.
  13618. * @param worldMatrix is the world matrix of the particle system
  13619. * @param directionToUpdate is the direction vector to update with the result
  13620. * @param particle is the particle we are computed the direction for
  13621. */
  13622. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13623. /**
  13624. * Clones the current emitter and returns a copy of it
  13625. * @returns the new emitter
  13626. */
  13627. clone(): CylinderDirectedParticleEmitter;
  13628. /**
  13629. * Called by the GPUParticleSystem to setup the update shader
  13630. * @param effect defines the update shader
  13631. */
  13632. applyToShader(effect: Effect): void;
  13633. /**
  13634. * Returns a string to use to update the GPU particles update shader
  13635. * @returns a string containng the defines string
  13636. */
  13637. getEffectDefines(): string;
  13638. /**
  13639. * Returns the string "CylinderDirectedParticleEmitter"
  13640. * @returns a string containing the class name
  13641. */
  13642. getClassName(): string;
  13643. /**
  13644. * Serializes the particle system to a JSON object.
  13645. * @returns the JSON object
  13646. */
  13647. serialize(): any;
  13648. /**
  13649. * Parse properties from a JSON object
  13650. * @param serializationObject defines the JSON object
  13651. */
  13652. parse(serializationObject: any): void;
  13653. }
  13654. }
  13655. declare module BABYLON {
  13656. /**
  13657. * Particle emitter emitting particles from the inside of a hemisphere.
  13658. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13659. */
  13660. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13661. /**
  13662. * The radius of the emission hemisphere.
  13663. */
  13664. radius: number;
  13665. /**
  13666. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13667. */
  13668. radiusRange: number;
  13669. /**
  13670. * How much to randomize the particle direction [0-1].
  13671. */
  13672. directionRandomizer: number;
  13673. /**
  13674. * Creates a new instance HemisphericParticleEmitter
  13675. * @param radius the radius of the emission hemisphere (1 by default)
  13676. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13677. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13678. */
  13679. constructor(
  13680. /**
  13681. * The radius of the emission hemisphere.
  13682. */
  13683. radius?: number,
  13684. /**
  13685. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13686. */
  13687. radiusRange?: number,
  13688. /**
  13689. * How much to randomize the particle direction [0-1].
  13690. */
  13691. directionRandomizer?: number);
  13692. /**
  13693. * Called by the particle System when the direction is computed for the created particle.
  13694. * @param worldMatrix is the world matrix of the particle system
  13695. * @param directionToUpdate is the direction vector to update with the result
  13696. * @param particle is the particle we are computed the direction for
  13697. * @param isLocal defines if the direction should be set in local space
  13698. */
  13699. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13700. /**
  13701. * Called by the particle System when the position is computed for the created particle.
  13702. * @param worldMatrix is the world matrix of the particle system
  13703. * @param positionToUpdate is the position vector to update with the result
  13704. * @param particle is the particle we are computed the position for
  13705. * @param isLocal defines if the position should be set in local space
  13706. */
  13707. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13708. /**
  13709. * Clones the current emitter and returns a copy of it
  13710. * @returns the new emitter
  13711. */
  13712. clone(): HemisphericParticleEmitter;
  13713. /**
  13714. * Called by the GPUParticleSystem to setup the update shader
  13715. * @param effect defines the update shader
  13716. */
  13717. applyToShader(effect: Effect): void;
  13718. /**
  13719. * Returns a string to use to update the GPU particles update shader
  13720. * @returns a string containng the defines string
  13721. */
  13722. getEffectDefines(): string;
  13723. /**
  13724. * Returns the string "HemisphericParticleEmitter"
  13725. * @returns a string containing the class name
  13726. */
  13727. getClassName(): string;
  13728. /**
  13729. * Serializes the particle system to a JSON object.
  13730. * @returns the JSON object
  13731. */
  13732. serialize(): any;
  13733. /**
  13734. * Parse properties from a JSON object
  13735. * @param serializationObject defines the JSON object
  13736. */
  13737. parse(serializationObject: any): void;
  13738. }
  13739. }
  13740. declare module BABYLON {
  13741. /**
  13742. * Particle emitter emitting particles from a point.
  13743. * It emits the particles randomly between 2 given directions.
  13744. */
  13745. export class PointParticleEmitter implements IParticleEmitterType {
  13746. /**
  13747. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13748. */
  13749. direction1: Vector3;
  13750. /**
  13751. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13752. */
  13753. direction2: Vector3;
  13754. /**
  13755. * Creates a new instance PointParticleEmitter
  13756. */
  13757. constructor();
  13758. /**
  13759. * Called by the particle System when the direction is computed for the created particle.
  13760. * @param worldMatrix is the world matrix of the particle system
  13761. * @param directionToUpdate is the direction vector to update with the result
  13762. * @param particle is the particle we are computed the direction for
  13763. * @param isLocal defines if the direction should be set in local space
  13764. */
  13765. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13766. /**
  13767. * Called by the particle System when the position is computed for the created particle.
  13768. * @param worldMatrix is the world matrix of the particle system
  13769. * @param positionToUpdate is the position vector to update with the result
  13770. * @param particle is the particle we are computed the position for
  13771. * @param isLocal defines if the position should be set in local space
  13772. */
  13773. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13774. /**
  13775. * Clones the current emitter and returns a copy of it
  13776. * @returns the new emitter
  13777. */
  13778. clone(): PointParticleEmitter;
  13779. /**
  13780. * Called by the GPUParticleSystem to setup the update shader
  13781. * @param effect defines the update shader
  13782. */
  13783. applyToShader(effect: Effect): void;
  13784. /**
  13785. * Returns a string to use to update the GPU particles update shader
  13786. * @returns a string containng the defines string
  13787. */
  13788. getEffectDefines(): string;
  13789. /**
  13790. * Returns the string "PointParticleEmitter"
  13791. * @returns a string containing the class name
  13792. */
  13793. getClassName(): string;
  13794. /**
  13795. * Serializes the particle system to a JSON object.
  13796. * @returns the JSON object
  13797. */
  13798. serialize(): any;
  13799. /**
  13800. * Parse properties from a JSON object
  13801. * @param serializationObject defines the JSON object
  13802. */
  13803. parse(serializationObject: any): void;
  13804. }
  13805. }
  13806. declare module BABYLON {
  13807. /**
  13808. * Particle emitter emitting particles from the inside of a sphere.
  13809. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13810. */
  13811. export class SphereParticleEmitter implements IParticleEmitterType {
  13812. /**
  13813. * The radius of the emission sphere.
  13814. */
  13815. radius: number;
  13816. /**
  13817. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13818. */
  13819. radiusRange: number;
  13820. /**
  13821. * How much to randomize the particle direction [0-1].
  13822. */
  13823. directionRandomizer: number;
  13824. /**
  13825. * Creates a new instance SphereParticleEmitter
  13826. * @param radius the radius of the emission sphere (1 by default)
  13827. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13828. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13829. */
  13830. constructor(
  13831. /**
  13832. * The radius of the emission sphere.
  13833. */
  13834. radius?: number,
  13835. /**
  13836. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13837. */
  13838. radiusRange?: number,
  13839. /**
  13840. * How much to randomize the particle direction [0-1].
  13841. */
  13842. directionRandomizer?: number);
  13843. /**
  13844. * Called by the particle System when the direction is computed for the created particle.
  13845. * @param worldMatrix is the world matrix of the particle system
  13846. * @param directionToUpdate is the direction vector to update with the result
  13847. * @param particle is the particle we are computed the direction for
  13848. * @param isLocal defines if the direction should be set in local space
  13849. */
  13850. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13851. /**
  13852. * Called by the particle System when the position is computed for the created particle.
  13853. * @param worldMatrix is the world matrix of the particle system
  13854. * @param positionToUpdate is the position vector to update with the result
  13855. * @param particle is the particle we are computed the position for
  13856. * @param isLocal defines if the position should be set in local space
  13857. */
  13858. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13859. /**
  13860. * Clones the current emitter and returns a copy of it
  13861. * @returns the new emitter
  13862. */
  13863. clone(): SphereParticleEmitter;
  13864. /**
  13865. * Called by the GPUParticleSystem to setup the update shader
  13866. * @param effect defines the update shader
  13867. */
  13868. applyToShader(effect: Effect): void;
  13869. /**
  13870. * Returns a string to use to update the GPU particles update shader
  13871. * @returns a string containng the defines string
  13872. */
  13873. getEffectDefines(): string;
  13874. /**
  13875. * Returns the string "SphereParticleEmitter"
  13876. * @returns a string containing the class name
  13877. */
  13878. getClassName(): string;
  13879. /**
  13880. * Serializes the particle system to a JSON object.
  13881. * @returns the JSON object
  13882. */
  13883. serialize(): any;
  13884. /**
  13885. * Parse properties from a JSON object
  13886. * @param serializationObject defines the JSON object
  13887. */
  13888. parse(serializationObject: any): void;
  13889. }
  13890. /**
  13891. * Particle emitter emitting particles from the inside of a sphere.
  13892. * It emits the particles randomly between two vectors.
  13893. */
  13894. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13895. /**
  13896. * The min limit of the emission direction.
  13897. */
  13898. direction1: Vector3;
  13899. /**
  13900. * The max limit of the emission direction.
  13901. */
  13902. direction2: Vector3;
  13903. /**
  13904. * Creates a new instance SphereDirectedParticleEmitter
  13905. * @param radius the radius of the emission sphere (1 by default)
  13906. * @param direction1 the min limit of the emission direction (up vector by default)
  13907. * @param direction2 the max limit of the emission direction (up vector by default)
  13908. */
  13909. constructor(radius?: number,
  13910. /**
  13911. * The min limit of the emission direction.
  13912. */
  13913. direction1?: Vector3,
  13914. /**
  13915. * The max limit of the emission direction.
  13916. */
  13917. direction2?: Vector3);
  13918. /**
  13919. * Called by the particle System when the direction is computed for the created particle.
  13920. * @param worldMatrix is the world matrix of the particle system
  13921. * @param directionToUpdate is the direction vector to update with the result
  13922. * @param particle is the particle we are computed the direction for
  13923. */
  13924. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13925. /**
  13926. * Clones the current emitter and returns a copy of it
  13927. * @returns the new emitter
  13928. */
  13929. clone(): SphereDirectedParticleEmitter;
  13930. /**
  13931. * Called by the GPUParticleSystem to setup the update shader
  13932. * @param effect defines the update shader
  13933. */
  13934. applyToShader(effect: Effect): void;
  13935. /**
  13936. * Returns a string to use to update the GPU particles update shader
  13937. * @returns a string containng the defines string
  13938. */
  13939. getEffectDefines(): string;
  13940. /**
  13941. * Returns the string "SphereDirectedParticleEmitter"
  13942. * @returns a string containing the class name
  13943. */
  13944. getClassName(): string;
  13945. /**
  13946. * Serializes the particle system to a JSON object.
  13947. * @returns the JSON object
  13948. */
  13949. serialize(): any;
  13950. /**
  13951. * Parse properties from a JSON object
  13952. * @param serializationObject defines the JSON object
  13953. */
  13954. parse(serializationObject: any): void;
  13955. }
  13956. }
  13957. declare module BABYLON {
  13958. /**
  13959. * Particle emitter emitting particles from a custom list of positions.
  13960. */
  13961. export class CustomParticleEmitter implements IParticleEmitterType {
  13962. /**
  13963. * Gets or sets the position generator that will create the inital position of each particle.
  13964. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13965. */
  13966. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13967. /**
  13968. * Gets or sets the destination generator that will create the final destination of each particle.
  13969. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13970. */
  13971. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13972. /**
  13973. * Creates a new instance CustomParticleEmitter
  13974. */
  13975. constructor();
  13976. /**
  13977. * Called by the particle System when the direction is computed for the created particle.
  13978. * @param worldMatrix is the world matrix of the particle system
  13979. * @param directionToUpdate is the direction vector to update with the result
  13980. * @param particle is the particle we are computed the direction for
  13981. * @param isLocal defines if the direction should be set in local space
  13982. */
  13983. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13984. /**
  13985. * Called by the particle System when the position is computed for the created particle.
  13986. * @param worldMatrix is the world matrix of the particle system
  13987. * @param positionToUpdate is the position vector to update with the result
  13988. * @param particle is the particle we are computed the position for
  13989. * @param isLocal defines if the position should be set in local space
  13990. */
  13991. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13992. /**
  13993. * Clones the current emitter and returns a copy of it
  13994. * @returns the new emitter
  13995. */
  13996. clone(): CustomParticleEmitter;
  13997. /**
  13998. * Called by the GPUParticleSystem to setup the update shader
  13999. * @param effect defines the update shader
  14000. */
  14001. applyToShader(effect: Effect): void;
  14002. /**
  14003. * Returns a string to use to update the GPU particles update shader
  14004. * @returns a string containng the defines string
  14005. */
  14006. getEffectDefines(): string;
  14007. /**
  14008. * Returns the string "PointParticleEmitter"
  14009. * @returns a string containing the class name
  14010. */
  14011. getClassName(): string;
  14012. /**
  14013. * Serializes the particle system to a JSON object.
  14014. * @returns the JSON object
  14015. */
  14016. serialize(): any;
  14017. /**
  14018. * Parse properties from a JSON object
  14019. * @param serializationObject defines the JSON object
  14020. */
  14021. parse(serializationObject: any): void;
  14022. }
  14023. }
  14024. declare module BABYLON {
  14025. /**
  14026. * Particle emitter emitting particles from the inside of a box.
  14027. * It emits the particles randomly between 2 given directions.
  14028. */
  14029. export class MeshParticleEmitter implements IParticleEmitterType {
  14030. private _indices;
  14031. private _positions;
  14032. private _normals;
  14033. private _storedNormal;
  14034. private _mesh;
  14035. /**
  14036. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14037. */
  14038. direction1: Vector3;
  14039. /**
  14040. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14041. */
  14042. direction2: Vector3;
  14043. /**
  14044. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14045. */
  14046. useMeshNormalsForDirection: boolean;
  14047. /** Defines the mesh to use as source */
  14048. get mesh(): Nullable<AbstractMesh>;
  14049. set mesh(value: Nullable<AbstractMesh>);
  14050. /**
  14051. * Creates a new instance MeshParticleEmitter
  14052. * @param mesh defines the mesh to use as source
  14053. */
  14054. constructor(mesh?: Nullable<AbstractMesh>);
  14055. /**
  14056. * Called by the particle System when the direction is computed for the created particle.
  14057. * @param worldMatrix is the world matrix of the particle system
  14058. * @param directionToUpdate is the direction vector to update with the result
  14059. * @param particle is the particle we are computed the direction for
  14060. * @param isLocal defines if the direction should be set in local space
  14061. */
  14062. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14063. /**
  14064. * Called by the particle System when the position is computed for the created particle.
  14065. * @param worldMatrix is the world matrix of the particle system
  14066. * @param positionToUpdate is the position vector to update with the result
  14067. * @param particle is the particle we are computed the position for
  14068. * @param isLocal defines if the position should be set in local space
  14069. */
  14070. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14071. /**
  14072. * Clones the current emitter and returns a copy of it
  14073. * @returns the new emitter
  14074. */
  14075. clone(): MeshParticleEmitter;
  14076. /**
  14077. * Called by the GPUParticleSystem to setup the update shader
  14078. * @param effect defines the update shader
  14079. */
  14080. applyToShader(effect: Effect): void;
  14081. /**
  14082. * Returns a string to use to update the GPU particles update shader
  14083. * @returns a string containng the defines string
  14084. */
  14085. getEffectDefines(): string;
  14086. /**
  14087. * Returns the string "BoxParticleEmitter"
  14088. * @returns a string containing the class name
  14089. */
  14090. getClassName(): string;
  14091. /**
  14092. * Serializes the particle system to a JSON object.
  14093. * @returns the JSON object
  14094. */
  14095. serialize(): any;
  14096. /**
  14097. * Parse properties from a JSON object
  14098. * @param serializationObject defines the JSON object
  14099. * @param scene defines the hosting scene
  14100. */
  14101. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14102. }
  14103. }
  14104. declare module BABYLON {
  14105. /**
  14106. * Interface representing a particle system in Babylon.js.
  14107. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14108. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14109. */
  14110. export interface IParticleSystem {
  14111. /**
  14112. * List of animations used by the particle system.
  14113. */
  14114. animations: Animation[];
  14115. /**
  14116. * The id of the Particle system.
  14117. */
  14118. id: string;
  14119. /**
  14120. * The name of the Particle system.
  14121. */
  14122. name: string;
  14123. /**
  14124. * The emitter represents the Mesh or position we are attaching the particle system to.
  14125. */
  14126. emitter: Nullable<AbstractMesh | Vector3>;
  14127. /**
  14128. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14129. */
  14130. isBillboardBased: boolean;
  14131. /**
  14132. * The rendering group used by the Particle system to chose when to render.
  14133. */
  14134. renderingGroupId: number;
  14135. /**
  14136. * The layer mask we are rendering the particles through.
  14137. */
  14138. layerMask: number;
  14139. /**
  14140. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14141. */
  14142. updateSpeed: number;
  14143. /**
  14144. * The amount of time the particle system is running (depends of the overall update speed).
  14145. */
  14146. targetStopDuration: number;
  14147. /**
  14148. * The texture used to render each particle. (this can be a spritesheet)
  14149. */
  14150. particleTexture: Nullable<BaseTexture>;
  14151. /**
  14152. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14153. */
  14154. blendMode: number;
  14155. /**
  14156. * Minimum life time of emitting particles.
  14157. */
  14158. minLifeTime: number;
  14159. /**
  14160. * Maximum life time of emitting particles.
  14161. */
  14162. maxLifeTime: number;
  14163. /**
  14164. * Minimum Size of emitting particles.
  14165. */
  14166. minSize: number;
  14167. /**
  14168. * Maximum Size of emitting particles.
  14169. */
  14170. maxSize: number;
  14171. /**
  14172. * Minimum scale of emitting particles on X axis.
  14173. */
  14174. minScaleX: number;
  14175. /**
  14176. * Maximum scale of emitting particles on X axis.
  14177. */
  14178. maxScaleX: number;
  14179. /**
  14180. * Minimum scale of emitting particles on Y axis.
  14181. */
  14182. minScaleY: number;
  14183. /**
  14184. * Maximum scale of emitting particles on Y axis.
  14185. */
  14186. maxScaleY: number;
  14187. /**
  14188. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14189. */
  14190. color1: Color4;
  14191. /**
  14192. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14193. */
  14194. color2: Color4;
  14195. /**
  14196. * Color the particle will have at the end of its lifetime.
  14197. */
  14198. colorDead: Color4;
  14199. /**
  14200. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14201. */
  14202. emitRate: number;
  14203. /**
  14204. * You can use gravity if you want to give an orientation to your particles.
  14205. */
  14206. gravity: Vector3;
  14207. /**
  14208. * Minimum power of emitting particles.
  14209. */
  14210. minEmitPower: number;
  14211. /**
  14212. * Maximum power of emitting particles.
  14213. */
  14214. maxEmitPower: number;
  14215. /**
  14216. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14217. */
  14218. minAngularSpeed: number;
  14219. /**
  14220. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14221. */
  14222. maxAngularSpeed: number;
  14223. /**
  14224. * Gets or sets the minimal initial rotation in radians.
  14225. */
  14226. minInitialRotation: number;
  14227. /**
  14228. * Gets or sets the maximal initial rotation in radians.
  14229. */
  14230. maxInitialRotation: number;
  14231. /**
  14232. * The particle emitter type defines the emitter used by the particle system.
  14233. * It can be for example box, sphere, or cone...
  14234. */
  14235. particleEmitterType: Nullable<IParticleEmitterType>;
  14236. /**
  14237. * Defines the delay in milliseconds before starting the system (0 by default)
  14238. */
  14239. startDelay: number;
  14240. /**
  14241. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  14242. */
  14243. preWarmCycles: number;
  14244. /**
  14245. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14246. */
  14247. preWarmStepOffset: number;
  14248. /**
  14249. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14250. */
  14251. spriteCellChangeSpeed: number;
  14252. /**
  14253. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14254. */
  14255. startSpriteCellID: number;
  14256. /**
  14257. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14258. */
  14259. endSpriteCellID: number;
  14260. /**
  14261. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14262. */
  14263. spriteCellWidth: number;
  14264. /**
  14265. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14266. */
  14267. spriteCellHeight: number;
  14268. /**
  14269. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14270. */
  14271. spriteRandomStartCell: boolean;
  14272. /**
  14273. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14274. */
  14275. isAnimationSheetEnabled: boolean;
  14276. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14277. translationPivot: Vector2;
  14278. /**
  14279. * Gets or sets a texture used to add random noise to particle positions
  14280. */
  14281. noiseTexture: Nullable<BaseTexture>;
  14282. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14283. noiseStrength: Vector3;
  14284. /**
  14285. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14286. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14287. */
  14288. billboardMode: number;
  14289. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14290. limitVelocityDamping: number;
  14291. /**
  14292. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14293. */
  14294. beginAnimationOnStart: boolean;
  14295. /**
  14296. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14297. */
  14298. beginAnimationFrom: number;
  14299. /**
  14300. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14301. */
  14302. beginAnimationTo: number;
  14303. /**
  14304. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14305. */
  14306. beginAnimationLoop: boolean;
  14307. /**
  14308. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14309. */
  14310. disposeOnStop: boolean;
  14311. /**
  14312. * Specifies if the particles are updated in emitter local space or world space
  14313. */
  14314. isLocal: boolean;
  14315. /** Snippet ID if the particle system was created from the snippet server */
  14316. snippetId: string;
  14317. /** Gets or sets a matrix to use to compute projection */
  14318. defaultProjectionMatrix: Matrix;
  14319. /**
  14320. * Gets the maximum number of particles active at the same time.
  14321. * @returns The max number of active particles.
  14322. */
  14323. getCapacity(): number;
  14324. /**
  14325. * Gets the number of particles active at the same time.
  14326. * @returns The number of active particles.
  14327. */
  14328. getActiveCount(): number;
  14329. /**
  14330. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14331. * @returns True if it has been started, otherwise false.
  14332. */
  14333. isStarted(): boolean;
  14334. /**
  14335. * Animates the particle system for this frame.
  14336. */
  14337. animate(): void;
  14338. /**
  14339. * Renders the particle system in its current state.
  14340. * @returns the current number of particles
  14341. */
  14342. render(): number;
  14343. /**
  14344. * Dispose the particle system and frees its associated resources.
  14345. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14346. */
  14347. dispose(disposeTexture?: boolean): void;
  14348. /**
  14349. * An event triggered when the system is disposed
  14350. */
  14351. onDisposeObservable: Observable<IParticleSystem>;
  14352. /**
  14353. * An event triggered when the system is stopped
  14354. */
  14355. onStoppedObservable: Observable<IParticleSystem>;
  14356. /**
  14357. * Clones the particle system.
  14358. * @param name The name of the cloned object
  14359. * @param newEmitter The new emitter to use
  14360. * @returns the cloned particle system
  14361. */
  14362. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14363. /**
  14364. * Serializes the particle system to a JSON object
  14365. * @param serializeTexture defines if the texture must be serialized as well
  14366. * @returns the JSON object
  14367. */
  14368. serialize(serializeTexture: boolean): any;
  14369. /**
  14370. * Rebuild the particle system
  14371. */
  14372. rebuild(): void;
  14373. /** Force the system to rebuild all gradients that need to be resync */
  14374. forceRefreshGradients(): void;
  14375. /**
  14376. * Starts the particle system and begins to emit
  14377. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14378. */
  14379. start(delay?: number): void;
  14380. /**
  14381. * Stops the particle system.
  14382. */
  14383. stop(): void;
  14384. /**
  14385. * Remove all active particles
  14386. */
  14387. reset(): void;
  14388. /**
  14389. * Gets a boolean indicating that the system is stopping
  14390. * @returns true if the system is currently stopping
  14391. */
  14392. isStopping(): boolean;
  14393. /**
  14394. * Is this system ready to be used/rendered
  14395. * @return true if the system is ready
  14396. */
  14397. isReady(): boolean;
  14398. /**
  14399. * Returns the string "ParticleSystem"
  14400. * @returns a string containing the class name
  14401. */
  14402. getClassName(): string;
  14403. /**
  14404. * Gets the custom effect used to render the particles
  14405. * @param blendMode Blend mode for which the effect should be retrieved
  14406. * @returns The effect
  14407. */
  14408. getCustomEffect(blendMode: number): Nullable<Effect>;
  14409. /**
  14410. * Sets the custom effect used to render the particles
  14411. * @param effect The effect to set
  14412. * @param blendMode Blend mode for which the effect should be set
  14413. */
  14414. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14415. /**
  14416. * Fill the defines array according to the current settings of the particle system
  14417. * @param defines Array to be updated
  14418. * @param blendMode blend mode to take into account when updating the array
  14419. */
  14420. fillDefines(defines: Array<string>, blendMode: number): void;
  14421. /**
  14422. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14423. * @param uniforms Uniforms array to fill
  14424. * @param attributes Attributes array to fill
  14425. * @param samplers Samplers array to fill
  14426. */
  14427. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14428. /**
  14429. * Observable that will be called just before the particles are drawn
  14430. */
  14431. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14432. /**
  14433. * Gets the name of the particle vertex shader
  14434. */
  14435. vertexShaderName: string;
  14436. /**
  14437. * Adds a new color gradient
  14438. * @param gradient defines the gradient to use (between 0 and 1)
  14439. * @param color1 defines the color to affect to the specified gradient
  14440. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14441. * @returns the current particle system
  14442. */
  14443. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14444. /**
  14445. * Remove a specific color gradient
  14446. * @param gradient defines the gradient to remove
  14447. * @returns the current particle system
  14448. */
  14449. removeColorGradient(gradient: number): IParticleSystem;
  14450. /**
  14451. * Adds a new size gradient
  14452. * @param gradient defines the gradient to use (between 0 and 1)
  14453. * @param factor defines the size factor to affect to the specified gradient
  14454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14455. * @returns the current particle system
  14456. */
  14457. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14458. /**
  14459. * Remove a specific size gradient
  14460. * @param gradient defines the gradient to remove
  14461. * @returns the current particle system
  14462. */
  14463. removeSizeGradient(gradient: number): IParticleSystem;
  14464. /**
  14465. * Gets the current list of color gradients.
  14466. * You must use addColorGradient and removeColorGradient to udpate this list
  14467. * @returns the list of color gradients
  14468. */
  14469. getColorGradients(): Nullable<Array<ColorGradient>>;
  14470. /**
  14471. * Gets the current list of size gradients.
  14472. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14473. * @returns the list of size gradients
  14474. */
  14475. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14476. /**
  14477. * Gets the current list of angular speed gradients.
  14478. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14479. * @returns the list of angular speed gradients
  14480. */
  14481. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14482. /**
  14483. * Adds a new angular speed gradient
  14484. * @param gradient defines the gradient to use (between 0 and 1)
  14485. * @param factor defines the angular speed to affect to the specified gradient
  14486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14487. * @returns the current particle system
  14488. */
  14489. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14490. /**
  14491. * Remove a specific angular speed gradient
  14492. * @param gradient defines the gradient to remove
  14493. * @returns the current particle system
  14494. */
  14495. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14496. /**
  14497. * Gets the current list of velocity gradients.
  14498. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14499. * @returns the list of velocity gradients
  14500. */
  14501. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14502. /**
  14503. * Adds a new velocity gradient
  14504. * @param gradient defines the gradient to use (between 0 and 1)
  14505. * @param factor defines the velocity to affect to the specified gradient
  14506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14507. * @returns the current particle system
  14508. */
  14509. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14510. /**
  14511. * Remove a specific velocity gradient
  14512. * @param gradient defines the gradient to remove
  14513. * @returns the current particle system
  14514. */
  14515. removeVelocityGradient(gradient: number): IParticleSystem;
  14516. /**
  14517. * Gets the current list of limit velocity gradients.
  14518. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14519. * @returns the list of limit velocity gradients
  14520. */
  14521. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14522. /**
  14523. * Adds a new limit velocity gradient
  14524. * @param gradient defines the gradient to use (between 0 and 1)
  14525. * @param factor defines the limit velocity to affect to the specified gradient
  14526. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14527. * @returns the current particle system
  14528. */
  14529. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14530. /**
  14531. * Remove a specific limit velocity gradient
  14532. * @param gradient defines the gradient to remove
  14533. * @returns the current particle system
  14534. */
  14535. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14536. /**
  14537. * Adds a new drag gradient
  14538. * @param gradient defines the gradient to use (between 0 and 1)
  14539. * @param factor defines the drag to affect to the specified gradient
  14540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14541. * @returns the current particle system
  14542. */
  14543. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14544. /**
  14545. * Remove a specific drag gradient
  14546. * @param gradient defines the gradient to remove
  14547. * @returns the current particle system
  14548. */
  14549. removeDragGradient(gradient: number): IParticleSystem;
  14550. /**
  14551. * Gets the current list of drag gradients.
  14552. * You must use addDragGradient and removeDragGradient to udpate this list
  14553. * @returns the list of drag gradients
  14554. */
  14555. getDragGradients(): Nullable<Array<FactorGradient>>;
  14556. /**
  14557. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14558. * @param gradient defines the gradient to use (between 0 and 1)
  14559. * @param factor defines the emit rate to affect to the specified gradient
  14560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14561. * @returns the current particle system
  14562. */
  14563. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14564. /**
  14565. * Remove a specific emit rate gradient
  14566. * @param gradient defines the gradient to remove
  14567. * @returns the current particle system
  14568. */
  14569. removeEmitRateGradient(gradient: number): IParticleSystem;
  14570. /**
  14571. * Gets the current list of emit rate gradients.
  14572. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14573. * @returns the list of emit rate gradients
  14574. */
  14575. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14576. /**
  14577. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14578. * @param gradient defines the gradient to use (between 0 and 1)
  14579. * @param factor defines the start size to affect to the specified gradient
  14580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14581. * @returns the current particle system
  14582. */
  14583. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14584. /**
  14585. * Remove a specific start size gradient
  14586. * @param gradient defines the gradient to remove
  14587. * @returns the current particle system
  14588. */
  14589. removeStartSizeGradient(gradient: number): IParticleSystem;
  14590. /**
  14591. * Gets the current list of start size gradients.
  14592. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14593. * @returns the list of start size gradients
  14594. */
  14595. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14596. /**
  14597. * Adds a new life time gradient
  14598. * @param gradient defines the gradient to use (between 0 and 1)
  14599. * @param factor defines the life time factor to affect to the specified gradient
  14600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14601. * @returns the current particle system
  14602. */
  14603. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14604. /**
  14605. * Remove a specific life time gradient
  14606. * @param gradient defines the gradient to remove
  14607. * @returns the current particle system
  14608. */
  14609. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14610. /**
  14611. * Gets the current list of life time gradients.
  14612. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14613. * @returns the list of life time gradients
  14614. */
  14615. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14616. /**
  14617. * Gets the current list of color gradients.
  14618. * You must use addColorGradient and removeColorGradient to udpate this list
  14619. * @returns the list of color gradients
  14620. */
  14621. getColorGradients(): Nullable<Array<ColorGradient>>;
  14622. /**
  14623. * Adds a new ramp gradient used to remap particle colors
  14624. * @param gradient defines the gradient to use (between 0 and 1)
  14625. * @param color defines the color to affect to the specified gradient
  14626. * @returns the current particle system
  14627. */
  14628. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14629. /**
  14630. * Gets the current list of ramp gradients.
  14631. * You must use addRampGradient and removeRampGradient to udpate this list
  14632. * @returns the list of ramp gradients
  14633. */
  14634. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14635. /** Gets or sets a boolean indicating that ramp gradients must be used
  14636. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14637. */
  14638. useRampGradients: boolean;
  14639. /**
  14640. * Adds a new color remap gradient
  14641. * @param gradient defines the gradient to use (between 0 and 1)
  14642. * @param min defines the color remap minimal range
  14643. * @param max defines the color remap maximal range
  14644. * @returns the current particle system
  14645. */
  14646. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14647. /**
  14648. * Gets the current list of color remap gradients.
  14649. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14650. * @returns the list of color remap gradients
  14651. */
  14652. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14653. /**
  14654. * Adds a new alpha remap gradient
  14655. * @param gradient defines the gradient to use (between 0 and 1)
  14656. * @param min defines the alpha remap minimal range
  14657. * @param max defines the alpha remap maximal range
  14658. * @returns the current particle system
  14659. */
  14660. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14661. /**
  14662. * Gets the current list of alpha remap gradients.
  14663. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14664. * @returns the list of alpha remap gradients
  14665. */
  14666. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14667. /**
  14668. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14669. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14670. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14671. * @returns the emitter
  14672. */
  14673. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14674. /**
  14675. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14676. * @param radius The radius of the hemisphere to emit from
  14677. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14678. * @returns the emitter
  14679. */
  14680. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14681. /**
  14682. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14683. * @param radius The radius of the sphere to emit from
  14684. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14685. * @returns the emitter
  14686. */
  14687. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14688. /**
  14689. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14690. * @param radius The radius of the sphere to emit from
  14691. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14692. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14693. * @returns the emitter
  14694. */
  14695. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14696. /**
  14697. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14698. * @param radius The radius of the emission cylinder
  14699. * @param height The height of the emission cylinder
  14700. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14701. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14702. * @returns the emitter
  14703. */
  14704. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14705. /**
  14706. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14707. * @param radius The radius of the cylinder to emit from
  14708. * @param height The height of the emission cylinder
  14709. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14710. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14711. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14712. * @returns the emitter
  14713. */
  14714. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14715. /**
  14716. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14717. * @param radius The radius of the cone to emit from
  14718. * @param angle The base angle of the cone
  14719. * @returns the emitter
  14720. */
  14721. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14722. /**
  14723. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14724. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14725. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14726. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14727. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14728. * @returns the emitter
  14729. */
  14730. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14731. /**
  14732. * Get hosting scene
  14733. * @returns the scene
  14734. */
  14735. getScene(): Nullable<Scene>;
  14736. }
  14737. }
  14738. declare module BABYLON {
  14739. /**
  14740. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14741. * @see https://doc.babylonjs.com/how_to/transformnode
  14742. */
  14743. export class TransformNode extends Node {
  14744. /**
  14745. * Object will not rotate to face the camera
  14746. */
  14747. static BILLBOARDMODE_NONE: number;
  14748. /**
  14749. * Object will rotate to face the camera but only on the x axis
  14750. */
  14751. static BILLBOARDMODE_X: number;
  14752. /**
  14753. * Object will rotate to face the camera but only on the y axis
  14754. */
  14755. static BILLBOARDMODE_Y: number;
  14756. /**
  14757. * Object will rotate to face the camera but only on the z axis
  14758. */
  14759. static BILLBOARDMODE_Z: number;
  14760. /**
  14761. * Object will rotate to face the camera
  14762. */
  14763. static BILLBOARDMODE_ALL: number;
  14764. /**
  14765. * Object will rotate to face the camera's position instead of orientation
  14766. */
  14767. static BILLBOARDMODE_USE_POSITION: number;
  14768. private static _TmpRotation;
  14769. private static _TmpScaling;
  14770. private static _TmpTranslation;
  14771. private _forward;
  14772. private _forwardInverted;
  14773. private _up;
  14774. private _right;
  14775. private _rightInverted;
  14776. private _position;
  14777. private _rotation;
  14778. private _rotationQuaternion;
  14779. protected _scaling: Vector3;
  14780. protected _isDirty: boolean;
  14781. private _transformToBoneReferal;
  14782. private _isAbsoluteSynced;
  14783. private _billboardMode;
  14784. /**
  14785. * Gets or sets the billboard mode. Default is 0.
  14786. *
  14787. * | Value | Type | Description |
  14788. * | --- | --- | --- |
  14789. * | 0 | BILLBOARDMODE_NONE | |
  14790. * | 1 | BILLBOARDMODE_X | |
  14791. * | 2 | BILLBOARDMODE_Y | |
  14792. * | 4 | BILLBOARDMODE_Z | |
  14793. * | 7 | BILLBOARDMODE_ALL | |
  14794. *
  14795. */
  14796. get billboardMode(): number;
  14797. set billboardMode(value: number);
  14798. private _preserveParentRotationForBillboard;
  14799. /**
  14800. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14801. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14802. */
  14803. get preserveParentRotationForBillboard(): boolean;
  14804. set preserveParentRotationForBillboard(value: boolean);
  14805. /**
  14806. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14807. */
  14808. scalingDeterminant: number;
  14809. private _infiniteDistance;
  14810. /**
  14811. * Gets or sets the distance of the object to max, often used by skybox
  14812. */
  14813. get infiniteDistance(): boolean;
  14814. set infiniteDistance(value: boolean);
  14815. /**
  14816. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14817. * By default the system will update normals to compensate
  14818. */
  14819. ignoreNonUniformScaling: boolean;
  14820. /**
  14821. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14822. */
  14823. reIntegrateRotationIntoRotationQuaternion: boolean;
  14824. /** @hidden */
  14825. _poseMatrix: Nullable<Matrix>;
  14826. /** @hidden */
  14827. _localMatrix: Matrix;
  14828. private _usePivotMatrix;
  14829. private _absolutePosition;
  14830. private _absoluteScaling;
  14831. private _absoluteRotationQuaternion;
  14832. private _pivotMatrix;
  14833. private _pivotMatrixInverse;
  14834. /** @hidden */
  14835. _postMultiplyPivotMatrix: boolean;
  14836. protected _isWorldMatrixFrozen: boolean;
  14837. /** @hidden */
  14838. _indexInSceneTransformNodesArray: number;
  14839. /**
  14840. * An event triggered after the world matrix is updated
  14841. */
  14842. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14843. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14844. /**
  14845. * Gets a string identifying the name of the class
  14846. * @returns "TransformNode" string
  14847. */
  14848. getClassName(): string;
  14849. /**
  14850. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14851. */
  14852. get position(): Vector3;
  14853. set position(newPosition: Vector3);
  14854. /**
  14855. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14856. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14857. */
  14858. get rotation(): Vector3;
  14859. set rotation(newRotation: Vector3);
  14860. /**
  14861. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14862. */
  14863. get scaling(): Vector3;
  14864. set scaling(newScaling: Vector3);
  14865. /**
  14866. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14867. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14868. */
  14869. get rotationQuaternion(): Nullable<Quaternion>;
  14870. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14871. /**
  14872. * The forward direction of that transform in world space.
  14873. */
  14874. get forward(): Vector3;
  14875. /**
  14876. * The up direction of that transform in world space.
  14877. */
  14878. get up(): Vector3;
  14879. /**
  14880. * The right direction of that transform in world space.
  14881. */
  14882. get right(): Vector3;
  14883. /**
  14884. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14885. * @param matrix the matrix to copy the pose from
  14886. * @returns this TransformNode.
  14887. */
  14888. updatePoseMatrix(matrix: Matrix): TransformNode;
  14889. /**
  14890. * Returns the mesh Pose matrix.
  14891. * @returns the pose matrix
  14892. */
  14893. getPoseMatrix(): Matrix;
  14894. /** @hidden */
  14895. _isSynchronized(): boolean;
  14896. /** @hidden */
  14897. _initCache(): void;
  14898. /**
  14899. * Flag the transform node as dirty (Forcing it to update everything)
  14900. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14901. * @returns this transform node
  14902. */
  14903. markAsDirty(property: string): TransformNode;
  14904. /**
  14905. * Returns the current mesh absolute position.
  14906. * Returns a Vector3.
  14907. */
  14908. get absolutePosition(): Vector3;
  14909. /**
  14910. * Returns the current mesh absolute scaling.
  14911. * Returns a Vector3.
  14912. */
  14913. get absoluteScaling(): Vector3;
  14914. /**
  14915. * Returns the current mesh absolute rotation.
  14916. * Returns a Quaternion.
  14917. */
  14918. get absoluteRotationQuaternion(): Quaternion;
  14919. /**
  14920. * Sets a new matrix to apply before all other transformation
  14921. * @param matrix defines the transform matrix
  14922. * @returns the current TransformNode
  14923. */
  14924. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14925. /**
  14926. * Sets a new pivot matrix to the current node
  14927. * @param matrix defines the new pivot matrix to use
  14928. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14929. * @returns the current TransformNode
  14930. */
  14931. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14932. /**
  14933. * Returns the mesh pivot matrix.
  14934. * Default : Identity.
  14935. * @returns the matrix
  14936. */
  14937. getPivotMatrix(): Matrix;
  14938. /**
  14939. * Instantiate (when possible) or clone that node with its hierarchy
  14940. * @param newParent defines the new parent to use for the instance (or clone)
  14941. * @param options defines options to configure how copy is done
  14942. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14943. * @returns an instance (or a clone) of the current node with its hiearchy
  14944. */
  14945. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14946. doNotInstantiate: boolean;
  14947. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14948. /**
  14949. * Prevents the World matrix to be computed any longer
  14950. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14951. * @returns the TransformNode.
  14952. */
  14953. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14954. /**
  14955. * Allows back the World matrix computation.
  14956. * @returns the TransformNode.
  14957. */
  14958. unfreezeWorldMatrix(): this;
  14959. /**
  14960. * True if the World matrix has been frozen.
  14961. */
  14962. get isWorldMatrixFrozen(): boolean;
  14963. /**
  14964. * Retuns the mesh absolute position in the World.
  14965. * @returns a Vector3.
  14966. */
  14967. getAbsolutePosition(): Vector3;
  14968. /**
  14969. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14970. * @param absolutePosition the absolute position to set
  14971. * @returns the TransformNode.
  14972. */
  14973. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14974. /**
  14975. * Sets the mesh position in its local space.
  14976. * @param vector3 the position to set in localspace
  14977. * @returns the TransformNode.
  14978. */
  14979. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14980. /**
  14981. * Returns the mesh position in the local space from the current World matrix values.
  14982. * @returns a new Vector3.
  14983. */
  14984. getPositionExpressedInLocalSpace(): Vector3;
  14985. /**
  14986. * Translates the mesh along the passed Vector3 in its local space.
  14987. * @param vector3 the distance to translate in localspace
  14988. * @returns the TransformNode.
  14989. */
  14990. locallyTranslate(vector3: Vector3): TransformNode;
  14991. private static _lookAtVectorCache;
  14992. /**
  14993. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14994. * @param targetPoint the position (must be in same space as current mesh) to look at
  14995. * @param yawCor optional yaw (y-axis) correction in radians
  14996. * @param pitchCor optional pitch (x-axis) correction in radians
  14997. * @param rollCor optional roll (z-axis) correction in radians
  14998. * @param space the choosen space of the target
  14999. * @returns the TransformNode.
  15000. */
  15001. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15002. /**
  15003. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15004. * This Vector3 is expressed in the World space.
  15005. * @param localAxis axis to rotate
  15006. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15007. */
  15008. getDirection(localAxis: Vector3): Vector3;
  15009. /**
  15010. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15011. * localAxis is expressed in the mesh local space.
  15012. * result is computed in the Wordl space from the mesh World matrix.
  15013. * @param localAxis axis to rotate
  15014. * @param result the resulting transformnode
  15015. * @returns this TransformNode.
  15016. */
  15017. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15018. /**
  15019. * Sets this transform node rotation to the given local axis.
  15020. * @param localAxis the axis in local space
  15021. * @param yawCor optional yaw (y-axis) correction in radians
  15022. * @param pitchCor optional pitch (x-axis) correction in radians
  15023. * @param rollCor optional roll (z-axis) correction in radians
  15024. * @returns this TransformNode
  15025. */
  15026. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15027. /**
  15028. * Sets a new pivot point to the current node
  15029. * @param point defines the new pivot point to use
  15030. * @param space defines if the point is in world or local space (local by default)
  15031. * @returns the current TransformNode
  15032. */
  15033. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15034. /**
  15035. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15036. * @returns the pivot point
  15037. */
  15038. getPivotPoint(): Vector3;
  15039. /**
  15040. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15041. * @param result the vector3 to store the result
  15042. * @returns this TransformNode.
  15043. */
  15044. getPivotPointToRef(result: Vector3): TransformNode;
  15045. /**
  15046. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15047. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15048. */
  15049. getAbsolutePivotPoint(): Vector3;
  15050. /**
  15051. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15052. * @param result vector3 to store the result
  15053. * @returns this TransformNode.
  15054. */
  15055. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15056. /**
  15057. * Defines the passed node as the parent of the current node.
  15058. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15059. * @see https://doc.babylonjs.com/how_to/parenting
  15060. * @param node the node ot set as the parent
  15061. * @returns this TransformNode.
  15062. */
  15063. setParent(node: Nullable<Node>): TransformNode;
  15064. private _nonUniformScaling;
  15065. /**
  15066. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15067. */
  15068. get nonUniformScaling(): boolean;
  15069. /** @hidden */
  15070. _updateNonUniformScalingState(value: boolean): boolean;
  15071. /**
  15072. * Attach the current TransformNode to another TransformNode associated with a bone
  15073. * @param bone Bone affecting the TransformNode
  15074. * @param affectedTransformNode TransformNode associated with the bone
  15075. * @returns this object
  15076. */
  15077. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15078. /**
  15079. * Detach the transform node if its associated with a bone
  15080. * @returns this object
  15081. */
  15082. detachFromBone(): TransformNode;
  15083. private static _rotationAxisCache;
  15084. /**
  15085. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15086. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15087. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15088. * The passed axis is also normalized.
  15089. * @param axis the axis to rotate around
  15090. * @param amount the amount to rotate in radians
  15091. * @param space Space to rotate in (Default: local)
  15092. * @returns the TransformNode.
  15093. */
  15094. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15095. /**
  15096. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15097. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15098. * The passed axis is also normalized. .
  15099. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15100. * @param point the point to rotate around
  15101. * @param axis the axis to rotate around
  15102. * @param amount the amount to rotate in radians
  15103. * @returns the TransformNode
  15104. */
  15105. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15106. /**
  15107. * Translates the mesh along the axis vector for the passed distance in the given space.
  15108. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15109. * @param axis the axis to translate in
  15110. * @param distance the distance to translate
  15111. * @param space Space to rotate in (Default: local)
  15112. * @returns the TransformNode.
  15113. */
  15114. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15115. /**
  15116. * Adds a rotation step to the mesh current rotation.
  15117. * x, y, z are Euler angles expressed in radians.
  15118. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15119. * This means this rotation is made in the mesh local space only.
  15120. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15121. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15122. * ```javascript
  15123. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15124. * ```
  15125. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15126. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  15127. * @param x Rotation to add
  15128. * @param y Rotation to add
  15129. * @param z Rotation to add
  15130. * @returns the TransformNode.
  15131. */
  15132. addRotation(x: number, y: number, z: number): TransformNode;
  15133. /**
  15134. * @hidden
  15135. */
  15136. protected _getEffectiveParent(): Nullable<Node>;
  15137. /**
  15138. * Computes the world matrix of the node
  15139. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15140. * @returns the world matrix
  15141. */
  15142. computeWorldMatrix(force?: boolean): Matrix;
  15143. /**
  15144. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15145. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15146. */
  15147. resetLocalMatrix(independentOfChildren?: boolean): void;
  15148. protected _afterComputeWorldMatrix(): void;
  15149. /**
  15150. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15151. * @param func callback function to add
  15152. *
  15153. * @returns the TransformNode.
  15154. */
  15155. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15156. /**
  15157. * Removes a registered callback function.
  15158. * @param func callback function to remove
  15159. * @returns the TransformNode.
  15160. */
  15161. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15162. /**
  15163. * Gets the position of the current mesh in camera space
  15164. * @param camera defines the camera to use
  15165. * @returns a position
  15166. */
  15167. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15168. /**
  15169. * Returns the distance from the mesh to the active camera
  15170. * @param camera defines the camera to use
  15171. * @returns the distance
  15172. */
  15173. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15174. /**
  15175. * Clone the current transform node
  15176. * @param name Name of the new clone
  15177. * @param newParent New parent for the clone
  15178. * @param doNotCloneChildren Do not clone children hierarchy
  15179. * @returns the new transform node
  15180. */
  15181. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15182. /**
  15183. * Serializes the objects information.
  15184. * @param currentSerializationObject defines the object to serialize in
  15185. * @returns the serialized object
  15186. */
  15187. serialize(currentSerializationObject?: any): any;
  15188. /**
  15189. * Returns a new TransformNode object parsed from the source provided.
  15190. * @param parsedTransformNode is the source.
  15191. * @param scene the scne the object belongs to
  15192. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15193. * @returns a new TransformNode object parsed from the source provided.
  15194. */
  15195. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15196. /**
  15197. * Get all child-transformNodes of this node
  15198. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  15199. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  15200. * @returns an array of TransformNode
  15201. */
  15202. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15203. /**
  15204. * Releases resources associated with this transform node.
  15205. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15206. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15207. */
  15208. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15209. /**
  15210. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15211. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15212. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15213. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15214. * @returns the current mesh
  15215. */
  15216. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15217. private _syncAbsoluteScalingAndRotation;
  15218. }
  15219. }
  15220. declare module BABYLON {
  15221. /**
  15222. * Class used to override all child animations of a given target
  15223. */
  15224. export class AnimationPropertiesOverride {
  15225. /**
  15226. * Gets or sets a value indicating if animation blending must be used
  15227. */
  15228. enableBlending: boolean;
  15229. /**
  15230. * Gets or sets the blending speed to use when enableBlending is true
  15231. */
  15232. blendingSpeed: number;
  15233. /**
  15234. * Gets or sets the default loop mode to use
  15235. */
  15236. loopMode: number;
  15237. }
  15238. }
  15239. declare module BABYLON {
  15240. /**
  15241. * Class used to store bone information
  15242. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15243. */
  15244. export class Bone extends Node {
  15245. /**
  15246. * defines the bone name
  15247. */
  15248. name: string;
  15249. private static _tmpVecs;
  15250. private static _tmpQuat;
  15251. private static _tmpMats;
  15252. /**
  15253. * Gets the list of child bones
  15254. */
  15255. children: Bone[];
  15256. /** Gets the animations associated with this bone */
  15257. animations: Animation[];
  15258. /**
  15259. * Gets or sets bone length
  15260. */
  15261. length: number;
  15262. /**
  15263. * @hidden Internal only
  15264. * Set this value to map this bone to a different index in the transform matrices
  15265. * Set this value to -1 to exclude the bone from the transform matrices
  15266. */
  15267. _index: Nullable<number>;
  15268. private _skeleton;
  15269. private _localMatrix;
  15270. private _restPose;
  15271. private _bindPose;
  15272. private _baseMatrix;
  15273. private _absoluteTransform;
  15274. private _invertedAbsoluteTransform;
  15275. private _parent;
  15276. private _scalingDeterminant;
  15277. private _worldTransform;
  15278. private _localScaling;
  15279. private _localRotation;
  15280. private _localPosition;
  15281. private _needToDecompose;
  15282. private _needToCompose;
  15283. /** @hidden */
  15284. _linkedTransformNode: Nullable<TransformNode>;
  15285. /** @hidden */
  15286. _waitingTransformNodeId: Nullable<string>;
  15287. /** @hidden */
  15288. get _matrix(): Matrix;
  15289. /** @hidden */
  15290. set _matrix(value: Matrix);
  15291. /**
  15292. * Create a new bone
  15293. * @param name defines the bone name
  15294. * @param skeleton defines the parent skeleton
  15295. * @param parentBone defines the parent (can be null if the bone is the root)
  15296. * @param localMatrix defines the local matrix
  15297. * @param restPose defines the rest pose matrix
  15298. * @param baseMatrix defines the base matrix
  15299. * @param index defines index of the bone in the hiearchy
  15300. */
  15301. constructor(
  15302. /**
  15303. * defines the bone name
  15304. */
  15305. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15306. /**
  15307. * Gets the current object class name.
  15308. * @return the class name
  15309. */
  15310. getClassName(): string;
  15311. /**
  15312. * Gets the parent skeleton
  15313. * @returns a skeleton
  15314. */
  15315. getSkeleton(): Skeleton;
  15316. /**
  15317. * Gets parent bone
  15318. * @returns a bone or null if the bone is the root of the bone hierarchy
  15319. */
  15320. getParent(): Nullable<Bone>;
  15321. /**
  15322. * Returns an array containing the root bones
  15323. * @returns an array containing the root bones
  15324. */
  15325. getChildren(): Array<Bone>;
  15326. /**
  15327. * Gets the node index in matrix array generated for rendering
  15328. * @returns the node index
  15329. */
  15330. getIndex(): number;
  15331. /**
  15332. * Sets the parent bone
  15333. * @param parent defines the parent (can be null if the bone is the root)
  15334. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15335. */
  15336. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15337. /**
  15338. * Gets the local matrix
  15339. * @returns a matrix
  15340. */
  15341. getLocalMatrix(): Matrix;
  15342. /**
  15343. * Gets the base matrix (initial matrix which remains unchanged)
  15344. * @returns a matrix
  15345. */
  15346. getBaseMatrix(): Matrix;
  15347. /**
  15348. * Gets the rest pose matrix
  15349. * @returns a matrix
  15350. */
  15351. getRestPose(): Matrix;
  15352. /**
  15353. * Sets the rest pose matrix
  15354. * @param matrix the local-space rest pose to set for this bone
  15355. */
  15356. setRestPose(matrix: Matrix): void;
  15357. /**
  15358. * Gets the bind pose matrix
  15359. * @returns the bind pose matrix
  15360. */
  15361. getBindPose(): Matrix;
  15362. /**
  15363. * Sets the bind pose matrix
  15364. * @param matrix the local-space bind pose to set for this bone
  15365. */
  15366. setBindPose(matrix: Matrix): void;
  15367. /**
  15368. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15369. */
  15370. getWorldMatrix(): Matrix;
  15371. /**
  15372. * Sets the local matrix to rest pose matrix
  15373. */
  15374. returnToRest(): void;
  15375. /**
  15376. * Gets the inverse of the absolute transform matrix.
  15377. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15378. * @returns a matrix
  15379. */
  15380. getInvertedAbsoluteTransform(): Matrix;
  15381. /**
  15382. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15383. * @returns a matrix
  15384. */
  15385. getAbsoluteTransform(): Matrix;
  15386. /**
  15387. * Links with the given transform node.
  15388. * The local matrix of this bone is copied from the transform node every frame.
  15389. * @param transformNode defines the transform node to link to
  15390. */
  15391. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15392. /**
  15393. * Gets the node used to drive the bone's transformation
  15394. * @returns a transform node or null
  15395. */
  15396. getTransformNode(): Nullable<TransformNode>;
  15397. /** Gets or sets current position (in local space) */
  15398. get position(): Vector3;
  15399. set position(newPosition: Vector3);
  15400. /** Gets or sets current rotation (in local space) */
  15401. get rotation(): Vector3;
  15402. set rotation(newRotation: Vector3);
  15403. /** Gets or sets current rotation quaternion (in local space) */
  15404. get rotationQuaternion(): Quaternion;
  15405. set rotationQuaternion(newRotation: Quaternion);
  15406. /** Gets or sets current scaling (in local space) */
  15407. get scaling(): Vector3;
  15408. set scaling(newScaling: Vector3);
  15409. /**
  15410. * Gets the animation properties override
  15411. */
  15412. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15413. private _decompose;
  15414. private _compose;
  15415. /**
  15416. * Update the base and local matrices
  15417. * @param matrix defines the new base or local matrix
  15418. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15419. * @param updateLocalMatrix defines if the local matrix should be updated
  15420. */
  15421. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15422. /** @hidden */
  15423. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15424. /**
  15425. * Flag the bone as dirty (Forcing it to update everything)
  15426. */
  15427. markAsDirty(): void;
  15428. /** @hidden */
  15429. _markAsDirtyAndCompose(): void;
  15430. private _markAsDirtyAndDecompose;
  15431. /**
  15432. * Translate the bone in local or world space
  15433. * @param vec The amount to translate the bone
  15434. * @param space The space that the translation is in
  15435. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15436. */
  15437. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15438. /**
  15439. * Set the postion of the bone in local or world space
  15440. * @param position The position to set the bone
  15441. * @param space The space that the position is in
  15442. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15443. */
  15444. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15445. /**
  15446. * Set the absolute position of the bone (world space)
  15447. * @param position The position to set the bone
  15448. * @param mesh The mesh that this bone is attached to
  15449. */
  15450. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15451. /**
  15452. * Scale the bone on the x, y and z axes (in local space)
  15453. * @param x The amount to scale the bone on the x axis
  15454. * @param y The amount to scale the bone on the y axis
  15455. * @param z The amount to scale the bone on the z axis
  15456. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15457. */
  15458. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15459. /**
  15460. * Set the bone scaling in local space
  15461. * @param scale defines the scaling vector
  15462. */
  15463. setScale(scale: Vector3): void;
  15464. /**
  15465. * Gets the current scaling in local space
  15466. * @returns the current scaling vector
  15467. */
  15468. getScale(): Vector3;
  15469. /**
  15470. * Gets the current scaling in local space and stores it in a target vector
  15471. * @param result defines the target vector
  15472. */
  15473. getScaleToRef(result: Vector3): void;
  15474. /**
  15475. * Set the yaw, pitch, and roll of the bone in local or world space
  15476. * @param yaw The rotation of the bone on the y axis
  15477. * @param pitch The rotation of the bone on the x axis
  15478. * @param roll The rotation of the bone on the z axis
  15479. * @param space The space that the axes of rotation are in
  15480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15481. */
  15482. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15483. /**
  15484. * Add a rotation to the bone on an axis in local or world space
  15485. * @param axis The axis to rotate the bone on
  15486. * @param amount The amount to rotate the bone
  15487. * @param space The space that the axis is in
  15488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15489. */
  15490. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15491. /**
  15492. * Set the rotation of the bone to a particular axis angle in local or world space
  15493. * @param axis The axis to rotate the bone on
  15494. * @param angle The angle that the bone should be rotated to
  15495. * @param space The space that the axis is in
  15496. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15497. */
  15498. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15499. /**
  15500. * Set the euler rotation of the bone in local or world space
  15501. * @param rotation The euler rotation that the bone should be set to
  15502. * @param space The space that the rotation is in
  15503. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15504. */
  15505. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15506. /**
  15507. * Set the quaternion rotation of the bone in local or world space
  15508. * @param quat The quaternion rotation that the bone should be set to
  15509. * @param space The space that the rotation is in
  15510. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15511. */
  15512. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15513. /**
  15514. * Set the rotation matrix of the bone in local or world space
  15515. * @param rotMat The rotation matrix that the bone should be set to
  15516. * @param space The space that the rotation is in
  15517. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15518. */
  15519. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15520. private _rotateWithMatrix;
  15521. private _getNegativeRotationToRef;
  15522. /**
  15523. * Get the position of the bone in local or world space
  15524. * @param space The space that the returned position is in
  15525. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15526. * @returns The position of the bone
  15527. */
  15528. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15529. /**
  15530. * Copy the position of the bone to a vector3 in local or world space
  15531. * @param space The space that the returned position is in
  15532. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15533. * @param result The vector3 to copy the position to
  15534. */
  15535. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15536. /**
  15537. * Get the absolute position of the bone (world space)
  15538. * @param mesh The mesh that this bone is attached to
  15539. * @returns The absolute position of the bone
  15540. */
  15541. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15542. /**
  15543. * Copy the absolute position of the bone (world space) to the result param
  15544. * @param mesh The mesh that this bone is attached to
  15545. * @param result The vector3 to copy the absolute position to
  15546. */
  15547. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15548. /**
  15549. * Compute the absolute transforms of this bone and its children
  15550. */
  15551. computeAbsoluteTransforms(): void;
  15552. /**
  15553. * Get the world direction from an axis that is in the local space of the bone
  15554. * @param localAxis The local direction that is used to compute the world direction
  15555. * @param mesh The mesh that this bone is attached to
  15556. * @returns The world direction
  15557. */
  15558. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15559. /**
  15560. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15561. * @param localAxis The local direction that is used to compute the world direction
  15562. * @param mesh The mesh that this bone is attached to
  15563. * @param result The vector3 that the world direction will be copied to
  15564. */
  15565. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15566. /**
  15567. * Get the euler rotation of the bone in local or world space
  15568. * @param space The space that the rotation should be in
  15569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15570. * @returns The euler rotation
  15571. */
  15572. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15573. /**
  15574. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15575. * @param space The space that the rotation should be in
  15576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15577. * @param result The vector3 that the rotation should be copied to
  15578. */
  15579. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15580. /**
  15581. * Get the quaternion rotation of the bone in either local or world space
  15582. * @param space The space that the rotation should be in
  15583. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15584. * @returns The quaternion rotation
  15585. */
  15586. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15587. /**
  15588. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15589. * @param space The space that the rotation should be in
  15590. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15591. * @param result The quaternion that the rotation should be copied to
  15592. */
  15593. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15594. /**
  15595. * Get the rotation matrix of the bone in local or world space
  15596. * @param space The space that the rotation should be in
  15597. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15598. * @returns The rotation matrix
  15599. */
  15600. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15601. /**
  15602. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15603. * @param space The space that the rotation should be in
  15604. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15605. * @param result The quaternion that the rotation should be copied to
  15606. */
  15607. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15608. /**
  15609. * Get the world position of a point that is in the local space of the bone
  15610. * @param position The local position
  15611. * @param mesh The mesh that this bone is attached to
  15612. * @returns The world position
  15613. */
  15614. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15615. /**
  15616. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15617. * @param position The local position
  15618. * @param mesh The mesh that this bone is attached to
  15619. * @param result The vector3 that the world position should be copied to
  15620. */
  15621. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15622. /**
  15623. * Get the local position of a point that is in world space
  15624. * @param position The world position
  15625. * @param mesh The mesh that this bone is attached to
  15626. * @returns The local position
  15627. */
  15628. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15629. /**
  15630. * Get the local position of a point that is in world space and copy it to the result param
  15631. * @param position The world position
  15632. * @param mesh The mesh that this bone is attached to
  15633. * @param result The vector3 that the local position should be copied to
  15634. */
  15635. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15636. /**
  15637. * Set the current local matrix as the restPose for this bone.
  15638. */
  15639. setCurrentPoseAsRest(): void;
  15640. }
  15641. }
  15642. declare module BABYLON {
  15643. /**
  15644. * Defines a runtime animation
  15645. */
  15646. export class RuntimeAnimation {
  15647. private _events;
  15648. /**
  15649. * The current frame of the runtime animation
  15650. */
  15651. private _currentFrame;
  15652. /**
  15653. * The animation used by the runtime animation
  15654. */
  15655. private _animation;
  15656. /**
  15657. * The target of the runtime animation
  15658. */
  15659. private _target;
  15660. /**
  15661. * The initiating animatable
  15662. */
  15663. private _host;
  15664. /**
  15665. * The original value of the runtime animation
  15666. */
  15667. private _originalValue;
  15668. /**
  15669. * The original blend value of the runtime animation
  15670. */
  15671. private _originalBlendValue;
  15672. /**
  15673. * The offsets cache of the runtime animation
  15674. */
  15675. private _offsetsCache;
  15676. /**
  15677. * The high limits cache of the runtime animation
  15678. */
  15679. private _highLimitsCache;
  15680. /**
  15681. * Specifies if the runtime animation has been stopped
  15682. */
  15683. private _stopped;
  15684. /**
  15685. * The blending factor of the runtime animation
  15686. */
  15687. private _blendingFactor;
  15688. /**
  15689. * The BabylonJS scene
  15690. */
  15691. private _scene;
  15692. /**
  15693. * The current value of the runtime animation
  15694. */
  15695. private _currentValue;
  15696. /** @hidden */
  15697. _animationState: _IAnimationState;
  15698. /**
  15699. * The active target of the runtime animation
  15700. */
  15701. private _activeTargets;
  15702. private _currentActiveTarget;
  15703. private _directTarget;
  15704. /**
  15705. * The target path of the runtime animation
  15706. */
  15707. private _targetPath;
  15708. /**
  15709. * The weight of the runtime animation
  15710. */
  15711. private _weight;
  15712. /**
  15713. * The ratio offset of the runtime animation
  15714. */
  15715. private _ratioOffset;
  15716. /**
  15717. * The previous delay of the runtime animation
  15718. */
  15719. private _previousDelay;
  15720. /**
  15721. * The previous ratio of the runtime animation
  15722. */
  15723. private _previousRatio;
  15724. private _enableBlending;
  15725. private _keys;
  15726. private _minFrame;
  15727. private _maxFrame;
  15728. private _minValue;
  15729. private _maxValue;
  15730. private _targetIsArray;
  15731. /**
  15732. * Gets the current frame of the runtime animation
  15733. */
  15734. get currentFrame(): number;
  15735. /**
  15736. * Gets the weight of the runtime animation
  15737. */
  15738. get weight(): number;
  15739. /**
  15740. * Gets the current value of the runtime animation
  15741. */
  15742. get currentValue(): any;
  15743. /**
  15744. * Gets the target path of the runtime animation
  15745. */
  15746. get targetPath(): string;
  15747. /**
  15748. * Gets the actual target of the runtime animation
  15749. */
  15750. get target(): any;
  15751. /**
  15752. * Gets the additive state of the runtime animation
  15753. */
  15754. get isAdditive(): boolean;
  15755. /** @hidden */
  15756. _onLoop: () => void;
  15757. /**
  15758. * Create a new RuntimeAnimation object
  15759. * @param target defines the target of the animation
  15760. * @param animation defines the source animation object
  15761. * @param scene defines the hosting scene
  15762. * @param host defines the initiating Animatable
  15763. */
  15764. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15765. private _preparePath;
  15766. /**
  15767. * Gets the animation from the runtime animation
  15768. */
  15769. get animation(): Animation;
  15770. /**
  15771. * Resets the runtime animation to the beginning
  15772. * @param restoreOriginal defines whether to restore the target property to the original value
  15773. */
  15774. reset(restoreOriginal?: boolean): void;
  15775. /**
  15776. * Specifies if the runtime animation is stopped
  15777. * @returns Boolean specifying if the runtime animation is stopped
  15778. */
  15779. isStopped(): boolean;
  15780. /**
  15781. * Disposes of the runtime animation
  15782. */
  15783. dispose(): void;
  15784. /**
  15785. * Apply the interpolated value to the target
  15786. * @param currentValue defines the value computed by the animation
  15787. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15788. */
  15789. setValue(currentValue: any, weight: number): void;
  15790. private _getOriginalValues;
  15791. private _setValue;
  15792. /**
  15793. * Gets the loop pmode of the runtime animation
  15794. * @returns Loop Mode
  15795. */
  15796. private _getCorrectLoopMode;
  15797. /**
  15798. * Move the current animation to a given frame
  15799. * @param frame defines the frame to move to
  15800. */
  15801. goToFrame(frame: number): void;
  15802. /**
  15803. * @hidden Internal use only
  15804. */
  15805. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15806. /**
  15807. * Execute the current animation
  15808. * @param delay defines the delay to add to the current frame
  15809. * @param from defines the lower bound of the animation range
  15810. * @param to defines the upper bound of the animation range
  15811. * @param loop defines if the current animation must loop
  15812. * @param speedRatio defines the current speed ratio
  15813. * @param weight defines the weight of the animation (default is -1 so no weight)
  15814. * @param onLoop optional callback called when animation loops
  15815. * @returns a boolean indicating if the animation is running
  15816. */
  15817. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15818. }
  15819. }
  15820. declare module BABYLON {
  15821. /**
  15822. * Class used to store an actual running animation
  15823. */
  15824. export class Animatable {
  15825. /** defines the target object */
  15826. target: any;
  15827. /** defines the starting frame number (default is 0) */
  15828. fromFrame: number;
  15829. /** defines the ending frame number (default is 100) */
  15830. toFrame: number;
  15831. /** defines if the animation must loop (default is false) */
  15832. loopAnimation: boolean;
  15833. /** defines a callback to call when animation ends if it is not looping */
  15834. onAnimationEnd?: (() => void) | null | undefined;
  15835. /** defines a callback to call when animation loops */
  15836. onAnimationLoop?: (() => void) | null | undefined;
  15837. /** defines whether the animation should be evaluated additively */
  15838. isAdditive: boolean;
  15839. private _localDelayOffset;
  15840. private _pausedDelay;
  15841. private _runtimeAnimations;
  15842. private _paused;
  15843. private _scene;
  15844. private _speedRatio;
  15845. private _weight;
  15846. private _syncRoot;
  15847. /**
  15848. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15849. * This will only apply for non looping animation (default is true)
  15850. */
  15851. disposeOnEnd: boolean;
  15852. /**
  15853. * Gets a boolean indicating if the animation has started
  15854. */
  15855. animationStarted: boolean;
  15856. /**
  15857. * Observer raised when the animation ends
  15858. */
  15859. onAnimationEndObservable: Observable<Animatable>;
  15860. /**
  15861. * Observer raised when the animation loops
  15862. */
  15863. onAnimationLoopObservable: Observable<Animatable>;
  15864. /**
  15865. * Gets the root Animatable used to synchronize and normalize animations
  15866. */
  15867. get syncRoot(): Nullable<Animatable>;
  15868. /**
  15869. * Gets the current frame of the first RuntimeAnimation
  15870. * Used to synchronize Animatables
  15871. */
  15872. get masterFrame(): number;
  15873. /**
  15874. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15875. */
  15876. get weight(): number;
  15877. set weight(value: number);
  15878. /**
  15879. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15880. */
  15881. get speedRatio(): number;
  15882. set speedRatio(value: number);
  15883. /**
  15884. * Creates a new Animatable
  15885. * @param scene defines the hosting scene
  15886. * @param target defines the target object
  15887. * @param fromFrame defines the starting frame number (default is 0)
  15888. * @param toFrame defines the ending frame number (default is 100)
  15889. * @param loopAnimation defines if the animation must loop (default is false)
  15890. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15891. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15892. * @param animations defines a group of animation to add to the new Animatable
  15893. * @param onAnimationLoop defines a callback to call when animation loops
  15894. * @param isAdditive defines whether the animation should be evaluated additively
  15895. */
  15896. constructor(scene: Scene,
  15897. /** defines the target object */
  15898. target: any,
  15899. /** defines the starting frame number (default is 0) */
  15900. fromFrame?: number,
  15901. /** defines the ending frame number (default is 100) */
  15902. toFrame?: number,
  15903. /** defines if the animation must loop (default is false) */
  15904. loopAnimation?: boolean, speedRatio?: number,
  15905. /** defines a callback to call when animation ends if it is not looping */
  15906. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15907. /** defines a callback to call when animation loops */
  15908. onAnimationLoop?: (() => void) | null | undefined,
  15909. /** defines whether the animation should be evaluated additively */
  15910. isAdditive?: boolean);
  15911. /**
  15912. * Synchronize and normalize current Animatable with a source Animatable
  15913. * This is useful when using animation weights and when animations are not of the same length
  15914. * @param root defines the root Animatable to synchronize with
  15915. * @returns the current Animatable
  15916. */
  15917. syncWith(root: Animatable): Animatable;
  15918. /**
  15919. * Gets the list of runtime animations
  15920. * @returns an array of RuntimeAnimation
  15921. */
  15922. getAnimations(): RuntimeAnimation[];
  15923. /**
  15924. * Adds more animations to the current animatable
  15925. * @param target defines the target of the animations
  15926. * @param animations defines the new animations to add
  15927. */
  15928. appendAnimations(target: any, animations: Animation[]): void;
  15929. /**
  15930. * Gets the source animation for a specific property
  15931. * @param property defines the propertyu to look for
  15932. * @returns null or the source animation for the given property
  15933. */
  15934. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15935. /**
  15936. * Gets the runtime animation for a specific property
  15937. * @param property defines the propertyu to look for
  15938. * @returns null or the runtime animation for the given property
  15939. */
  15940. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15941. /**
  15942. * Resets the animatable to its original state
  15943. */
  15944. reset(): void;
  15945. /**
  15946. * Allows the animatable to blend with current running animations
  15947. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15948. * @param blendingSpeed defines the blending speed to use
  15949. */
  15950. enableBlending(blendingSpeed: number): void;
  15951. /**
  15952. * Disable animation blending
  15953. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15954. */
  15955. disableBlending(): void;
  15956. /**
  15957. * Jump directly to a given frame
  15958. * @param frame defines the frame to jump to
  15959. */
  15960. goToFrame(frame: number): void;
  15961. /**
  15962. * Pause the animation
  15963. */
  15964. pause(): void;
  15965. /**
  15966. * Restart the animation
  15967. */
  15968. restart(): void;
  15969. private _raiseOnAnimationEnd;
  15970. /**
  15971. * Stop and delete the current animation
  15972. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15973. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  15974. */
  15975. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15976. /**
  15977. * Wait asynchronously for the animation to end
  15978. * @returns a promise which will be fullfilled when the animation ends
  15979. */
  15980. waitAsync(): Promise<Animatable>;
  15981. /** @hidden */
  15982. _animate(delay: number): boolean;
  15983. }
  15984. interface Scene {
  15985. /** @hidden */
  15986. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15987. /** @hidden */
  15988. _processLateAnimationBindingsForMatrices(holder: {
  15989. totalWeight: number;
  15990. totalAdditiveWeight: number;
  15991. animations: RuntimeAnimation[];
  15992. additiveAnimations: RuntimeAnimation[];
  15993. originalValue: Matrix;
  15994. }): any;
  15995. /** @hidden */
  15996. _processLateAnimationBindingsForQuaternions(holder: {
  15997. totalWeight: number;
  15998. totalAdditiveWeight: number;
  15999. animations: RuntimeAnimation[];
  16000. additiveAnimations: RuntimeAnimation[];
  16001. originalValue: Quaternion;
  16002. }, refQuaternion: Quaternion): Quaternion;
  16003. /** @hidden */
  16004. _processLateAnimationBindings(): void;
  16005. /**
  16006. * Will start the animation sequence of a given target
  16007. * @param target defines the target
  16008. * @param from defines from which frame should animation start
  16009. * @param to defines until which frame should animation run.
  16010. * @param weight defines the weight to apply to the animation (1.0 by default)
  16011. * @param loop defines if the animation loops
  16012. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16013. * @param onAnimationEnd defines the function to be executed when the animation ends
  16014. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16015. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16016. * @param onAnimationLoop defines the callback to call when an animation loops
  16017. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16018. * @returns the animatable object created for this animation
  16019. */
  16020. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16021. /**
  16022. * Will start the animation sequence of a given target
  16023. * @param target defines the target
  16024. * @param from defines from which frame should animation start
  16025. * @param to defines until which frame should animation run.
  16026. * @param loop defines if the animation loops
  16027. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16028. * @param onAnimationEnd defines the function to be executed when the animation ends
  16029. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16030. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16031. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16032. * @param onAnimationLoop defines the callback to call when an animation loops
  16033. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16034. * @returns the animatable object created for this animation
  16035. */
  16036. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16037. /**
  16038. * Will start the animation sequence of a given target and its hierarchy
  16039. * @param target defines the target
  16040. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16041. * @param from defines from which frame should animation start
  16042. * @param to defines until which frame should animation run.
  16043. * @param loop defines if the animation loops
  16044. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16045. * @param onAnimationEnd defines the function to be executed when the animation ends
  16046. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16047. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16048. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16049. * @param onAnimationLoop defines the callback to call when an animation loops
  16050. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16051. * @returns the list of created animatables
  16052. */
  16053. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16054. /**
  16055. * Begin a new animation on a given node
  16056. * @param target defines the target where the animation will take place
  16057. * @param animations defines the list of animations to start
  16058. * @param from defines the initial value
  16059. * @param to defines the final value
  16060. * @param loop defines if you want animation to loop (off by default)
  16061. * @param speedRatio defines the speed ratio to apply to all animations
  16062. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16063. * @param onAnimationLoop defines the callback to call when an animation loops
  16064. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16065. * @returns the list of created animatables
  16066. */
  16067. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16068. /**
  16069. * Begin a new animation on a given node and its hierarchy
  16070. * @param target defines the root node where the animation will take place
  16071. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16072. * @param animations defines the list of animations to start
  16073. * @param from defines the initial value
  16074. * @param to defines the final value
  16075. * @param loop defines if you want animation to loop (off by default)
  16076. * @param speedRatio defines the speed ratio to apply to all animations
  16077. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16078. * @param onAnimationLoop defines the callback to call when an animation loops
  16079. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16080. * @returns the list of animatables created for all nodes
  16081. */
  16082. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16083. /**
  16084. * Gets the animatable associated with a specific target
  16085. * @param target defines the target of the animatable
  16086. * @returns the required animatable if found
  16087. */
  16088. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16089. /**
  16090. * Gets all animatables associated with a given target
  16091. * @param target defines the target to look animatables for
  16092. * @returns an array of Animatables
  16093. */
  16094. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16095. /**
  16096. * Stops and removes all animations that have been applied to the scene
  16097. */
  16098. stopAllAnimations(): void;
  16099. /**
  16100. * Gets the current delta time used by animation engine
  16101. */
  16102. deltaTime: number;
  16103. }
  16104. interface Bone {
  16105. /**
  16106. * Copy an animation range from another bone
  16107. * @param source defines the source bone
  16108. * @param rangeName defines the range name to copy
  16109. * @param frameOffset defines the frame offset
  16110. * @param rescaleAsRequired defines if rescaling must be applied if required
  16111. * @param skelDimensionsRatio defines the scaling ratio
  16112. * @returns true if operation was successful
  16113. */
  16114. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16115. }
  16116. }
  16117. declare module BABYLON {
  16118. /**
  16119. * Class used to handle skinning animations
  16120. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16121. */
  16122. export class Skeleton implements IAnimatable {
  16123. /** defines the skeleton name */
  16124. name: string;
  16125. /** defines the skeleton Id */
  16126. id: string;
  16127. /**
  16128. * Defines the list of child bones
  16129. */
  16130. bones: Bone[];
  16131. /**
  16132. * Defines an estimate of the dimension of the skeleton at rest
  16133. */
  16134. dimensionsAtRest: Vector3;
  16135. /**
  16136. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16137. */
  16138. needInitialSkinMatrix: boolean;
  16139. /**
  16140. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16141. */
  16142. overrideMesh: Nullable<AbstractMesh>;
  16143. /**
  16144. * Gets the list of animations attached to this skeleton
  16145. */
  16146. animations: Array<Animation>;
  16147. private _scene;
  16148. private _isDirty;
  16149. private _transformMatrices;
  16150. private _transformMatrixTexture;
  16151. private _meshesWithPoseMatrix;
  16152. private _animatables;
  16153. private _identity;
  16154. private _synchronizedWithMesh;
  16155. private _ranges;
  16156. private _lastAbsoluteTransformsUpdateId;
  16157. private _canUseTextureForBones;
  16158. private _uniqueId;
  16159. /** @hidden */
  16160. _numBonesWithLinkedTransformNode: number;
  16161. /** @hidden */
  16162. _hasWaitingData: Nullable<boolean>;
  16163. /** @hidden */
  16164. _waitingOverrideMeshId: Nullable<string>;
  16165. /**
  16166. * Specifies if the skeleton should be serialized
  16167. */
  16168. doNotSerialize: boolean;
  16169. private _useTextureToStoreBoneMatrices;
  16170. /**
  16171. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16172. * Please note that this option is not available if the hardware does not support it
  16173. */
  16174. get useTextureToStoreBoneMatrices(): boolean;
  16175. set useTextureToStoreBoneMatrices(value: boolean);
  16176. private _animationPropertiesOverride;
  16177. /**
  16178. * Gets or sets the animation properties override
  16179. */
  16180. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16181. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16182. /**
  16183. * List of inspectable custom properties (used by the Inspector)
  16184. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16185. */
  16186. inspectableCustomProperties: IInspectable[];
  16187. /**
  16188. * An observable triggered before computing the skeleton's matrices
  16189. */
  16190. onBeforeComputeObservable: Observable<Skeleton>;
  16191. /**
  16192. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16193. */
  16194. get isUsingTextureForMatrices(): boolean;
  16195. /**
  16196. * Gets the unique ID of this skeleton
  16197. */
  16198. get uniqueId(): number;
  16199. /**
  16200. * Creates a new skeleton
  16201. * @param name defines the skeleton name
  16202. * @param id defines the skeleton Id
  16203. * @param scene defines the hosting scene
  16204. */
  16205. constructor(
  16206. /** defines the skeleton name */
  16207. name: string,
  16208. /** defines the skeleton Id */
  16209. id: string, scene: Scene);
  16210. /**
  16211. * Gets the current object class name.
  16212. * @return the class name
  16213. */
  16214. getClassName(): string;
  16215. /**
  16216. * Returns an array containing the root bones
  16217. * @returns an array containing the root bones
  16218. */
  16219. getChildren(): Array<Bone>;
  16220. /**
  16221. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16222. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16223. * @returns a Float32Array containing matrices data
  16224. */
  16225. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16226. /**
  16227. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16228. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16229. * @returns a raw texture containing the data
  16230. */
  16231. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16232. /**
  16233. * Gets the current hosting scene
  16234. * @returns a scene object
  16235. */
  16236. getScene(): Scene;
  16237. /**
  16238. * Gets a string representing the current skeleton data
  16239. * @param fullDetails defines a boolean indicating if we want a verbose version
  16240. * @returns a string representing the current skeleton data
  16241. */
  16242. toString(fullDetails?: boolean): string;
  16243. /**
  16244. * Get bone's index searching by name
  16245. * @param name defines bone's name to search for
  16246. * @return the indice of the bone. Returns -1 if not found
  16247. */
  16248. getBoneIndexByName(name: string): number;
  16249. /**
  16250. * Creater a new animation range
  16251. * @param name defines the name of the range
  16252. * @param from defines the start key
  16253. * @param to defines the end key
  16254. */
  16255. createAnimationRange(name: string, from: number, to: number): void;
  16256. /**
  16257. * Delete a specific animation range
  16258. * @param name defines the name of the range
  16259. * @param deleteFrames defines if frames must be removed as well
  16260. */
  16261. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16262. /**
  16263. * Gets a specific animation range
  16264. * @param name defines the name of the range to look for
  16265. * @returns the requested animation range or null if not found
  16266. */
  16267. getAnimationRange(name: string): Nullable<AnimationRange>;
  16268. /**
  16269. * Gets the list of all animation ranges defined on this skeleton
  16270. * @returns an array
  16271. */
  16272. getAnimationRanges(): Nullable<AnimationRange>[];
  16273. /**
  16274. * Copy animation range from a source skeleton.
  16275. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16276. * @param source defines the source skeleton
  16277. * @param name defines the name of the range to copy
  16278. * @param rescaleAsRequired defines if rescaling must be applied if required
  16279. * @returns true if operation was successful
  16280. */
  16281. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16282. /**
  16283. * Forces the skeleton to go to rest pose
  16284. */
  16285. returnToRest(): void;
  16286. private _getHighestAnimationFrame;
  16287. /**
  16288. * Begin a specific animation range
  16289. * @param name defines the name of the range to start
  16290. * @param loop defines if looping must be turned on (false by default)
  16291. * @param speedRatio defines the speed ratio to apply (1 by default)
  16292. * @param onAnimationEnd defines a callback which will be called when animation will end
  16293. * @returns a new animatable
  16294. */
  16295. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16296. /**
  16297. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16298. * @param skeleton defines the Skeleton containing the animation range to convert
  16299. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16300. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16301. * @returns the original skeleton
  16302. */
  16303. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16304. /** @hidden */
  16305. _markAsDirty(): void;
  16306. /** @hidden */
  16307. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16308. /** @hidden */
  16309. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16310. private _computeTransformMatrices;
  16311. /**
  16312. * Build all resources required to render a skeleton
  16313. */
  16314. prepare(): void;
  16315. /**
  16316. * Gets the list of animatables currently running for this skeleton
  16317. * @returns an array of animatables
  16318. */
  16319. getAnimatables(): IAnimatable[];
  16320. /**
  16321. * Clone the current skeleton
  16322. * @param name defines the name of the new skeleton
  16323. * @param id defines the id of the new skeleton
  16324. * @returns the new skeleton
  16325. */
  16326. clone(name: string, id?: string): Skeleton;
  16327. /**
  16328. * Enable animation blending for this skeleton
  16329. * @param blendingSpeed defines the blending speed to apply
  16330. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16331. */
  16332. enableBlending(blendingSpeed?: number): void;
  16333. /**
  16334. * Releases all resources associated with the current skeleton
  16335. */
  16336. dispose(): void;
  16337. /**
  16338. * Serialize the skeleton in a JSON object
  16339. * @returns a JSON object
  16340. */
  16341. serialize(): any;
  16342. /**
  16343. * Creates a new skeleton from serialized data
  16344. * @param parsedSkeleton defines the serialized data
  16345. * @param scene defines the hosting scene
  16346. * @returns a new skeleton
  16347. */
  16348. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16349. /**
  16350. * Compute all node absolute transforms
  16351. * @param forceUpdate defines if computation must be done even if cache is up to date
  16352. */
  16353. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16354. /**
  16355. * Gets the root pose matrix
  16356. * @returns a matrix
  16357. */
  16358. getPoseMatrix(): Nullable<Matrix>;
  16359. /**
  16360. * Sorts bones per internal index
  16361. */
  16362. sortBones(): void;
  16363. private _sortBones;
  16364. /**
  16365. * Set the current local matrix as the restPose for all bones in the skeleton.
  16366. */
  16367. setCurrentPoseAsRest(): void;
  16368. }
  16369. }
  16370. declare module BABYLON {
  16371. /**
  16372. * Creates an instance based on a source mesh.
  16373. */
  16374. export class InstancedMesh extends AbstractMesh {
  16375. private _sourceMesh;
  16376. private _currentLOD;
  16377. /** @hidden */
  16378. _indexInSourceMeshInstanceArray: number;
  16379. constructor(name: string, source: Mesh);
  16380. /**
  16381. * Returns the string "InstancedMesh".
  16382. */
  16383. getClassName(): string;
  16384. /** Gets the list of lights affecting that mesh */
  16385. get lightSources(): Light[];
  16386. _resyncLightSources(): void;
  16387. _resyncLightSource(light: Light): void;
  16388. _removeLightSource(light: Light, dispose: boolean): void;
  16389. /**
  16390. * If the source mesh receives shadows
  16391. */
  16392. get receiveShadows(): boolean;
  16393. /**
  16394. * The material of the source mesh
  16395. */
  16396. get material(): Nullable<Material>;
  16397. /**
  16398. * Visibility of the source mesh
  16399. */
  16400. get visibility(): number;
  16401. /**
  16402. * Skeleton of the source mesh
  16403. */
  16404. get skeleton(): Nullable<Skeleton>;
  16405. /**
  16406. * Rendering ground id of the source mesh
  16407. */
  16408. get renderingGroupId(): number;
  16409. set renderingGroupId(value: number);
  16410. /**
  16411. * Returns the total number of vertices (integer).
  16412. */
  16413. getTotalVertices(): number;
  16414. /**
  16415. * Returns a positive integer : the total number of indices in this mesh geometry.
  16416. * @returns the numner of indices or zero if the mesh has no geometry.
  16417. */
  16418. getTotalIndices(): number;
  16419. /**
  16420. * The source mesh of the instance
  16421. */
  16422. get sourceMesh(): Mesh;
  16423. /**
  16424. * Creates a new InstancedMesh object from the mesh model.
  16425. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16426. * @param name defines the name of the new instance
  16427. * @returns a new InstancedMesh
  16428. */
  16429. createInstance(name: string): InstancedMesh;
  16430. /**
  16431. * Is this node ready to be used/rendered
  16432. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16433. * @return {boolean} is it ready
  16434. */
  16435. isReady(completeCheck?: boolean): boolean;
  16436. /**
  16437. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16438. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16439. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  16440. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16441. */
  16442. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16443. /**
  16444. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16445. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16446. * The `data` are either a numeric array either a Float32Array.
  16447. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16448. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  16449. * Note that a new underlying VertexBuffer object is created each call.
  16450. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16451. *
  16452. * Possible `kind` values :
  16453. * - VertexBuffer.PositionKind
  16454. * - VertexBuffer.UVKind
  16455. * - VertexBuffer.UV2Kind
  16456. * - VertexBuffer.UV3Kind
  16457. * - VertexBuffer.UV4Kind
  16458. * - VertexBuffer.UV5Kind
  16459. * - VertexBuffer.UV6Kind
  16460. * - VertexBuffer.ColorKind
  16461. * - VertexBuffer.MatricesIndicesKind
  16462. * - VertexBuffer.MatricesIndicesExtraKind
  16463. * - VertexBuffer.MatricesWeightsKind
  16464. * - VertexBuffer.MatricesWeightsExtraKind
  16465. *
  16466. * Returns the Mesh.
  16467. */
  16468. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16469. /**
  16470. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16471. * If the mesh has no geometry, it is simply returned as it is.
  16472. * The `data` are either a numeric array either a Float32Array.
  16473. * No new underlying VertexBuffer object is created.
  16474. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16475. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16476. *
  16477. * Possible `kind` values :
  16478. * - VertexBuffer.PositionKind
  16479. * - VertexBuffer.UVKind
  16480. * - VertexBuffer.UV2Kind
  16481. * - VertexBuffer.UV3Kind
  16482. * - VertexBuffer.UV4Kind
  16483. * - VertexBuffer.UV5Kind
  16484. * - VertexBuffer.UV6Kind
  16485. * - VertexBuffer.ColorKind
  16486. * - VertexBuffer.MatricesIndicesKind
  16487. * - VertexBuffer.MatricesIndicesExtraKind
  16488. * - VertexBuffer.MatricesWeightsKind
  16489. * - VertexBuffer.MatricesWeightsExtraKind
  16490. *
  16491. * Returns the Mesh.
  16492. */
  16493. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16494. /**
  16495. * Sets the mesh indices.
  16496. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16497. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16498. * This method creates a new index buffer each call.
  16499. * Returns the Mesh.
  16500. */
  16501. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16502. /**
  16503. * Boolean : True if the mesh owns the requested kind of data.
  16504. */
  16505. isVerticesDataPresent(kind: string): boolean;
  16506. /**
  16507. * Returns an array of indices (IndicesArray).
  16508. */
  16509. getIndices(): Nullable<IndicesArray>;
  16510. get _positions(): Nullable<Vector3[]>;
  16511. /**
  16512. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16513. * This means the mesh underlying bounding box and sphere are recomputed.
  16514. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16515. * @returns the current mesh
  16516. */
  16517. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16518. /** @hidden */
  16519. _preActivate(): InstancedMesh;
  16520. /** @hidden */
  16521. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16522. /** @hidden */
  16523. _postActivate(): void;
  16524. getWorldMatrix(): Matrix;
  16525. get isAnInstance(): boolean;
  16526. /**
  16527. * Returns the current associated LOD AbstractMesh.
  16528. */
  16529. getLOD(camera: Camera): AbstractMesh;
  16530. /** @hidden */
  16531. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16532. /** @hidden */
  16533. _syncSubMeshes(): InstancedMesh;
  16534. /** @hidden */
  16535. _generatePointsArray(): boolean;
  16536. /** @hidden */
  16537. _updateBoundingInfo(): AbstractMesh;
  16538. /**
  16539. * Creates a new InstancedMesh from the current mesh.
  16540. * - name (string) : the cloned mesh name
  16541. * - newParent (optional Node) : the optional Node to parent the clone to.
  16542. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16543. *
  16544. * Returns the clone.
  16545. */
  16546. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16547. /**
  16548. * Disposes the InstancedMesh.
  16549. * Returns nothing.
  16550. */
  16551. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16552. }
  16553. interface Mesh {
  16554. /**
  16555. * Register a custom buffer that will be instanced
  16556. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16557. * @param kind defines the buffer kind
  16558. * @param stride defines the stride in floats
  16559. */
  16560. registerInstancedBuffer(kind: string, stride: number): void;
  16561. /**
  16562. * true to use the edge renderer for all instances of this mesh
  16563. */
  16564. edgesShareWithInstances: boolean;
  16565. /** @hidden */
  16566. _userInstancedBuffersStorage: {
  16567. data: {
  16568. [key: string]: Float32Array;
  16569. };
  16570. sizes: {
  16571. [key: string]: number;
  16572. };
  16573. vertexBuffers: {
  16574. [key: string]: Nullable<VertexBuffer>;
  16575. };
  16576. strides: {
  16577. [key: string]: number;
  16578. };
  16579. };
  16580. }
  16581. interface AbstractMesh {
  16582. /**
  16583. * Object used to store instanced buffers defined by user
  16584. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16585. */
  16586. instancedBuffers: {
  16587. [key: string]: any;
  16588. };
  16589. }
  16590. }
  16591. declare module BABYLON {
  16592. /**
  16593. * Defines the options associated with the creation of a shader material.
  16594. */
  16595. export interface IShaderMaterialOptions {
  16596. /**
  16597. * Does the material work in alpha blend mode
  16598. */
  16599. needAlphaBlending: boolean;
  16600. /**
  16601. * Does the material work in alpha test mode
  16602. */
  16603. needAlphaTesting: boolean;
  16604. /**
  16605. * The list of attribute names used in the shader
  16606. */
  16607. attributes: string[];
  16608. /**
  16609. * The list of unifrom names used in the shader
  16610. */
  16611. uniforms: string[];
  16612. /**
  16613. * The list of UBO names used in the shader
  16614. */
  16615. uniformBuffers: string[];
  16616. /**
  16617. * The list of sampler names used in the shader
  16618. */
  16619. samplers: string[];
  16620. /**
  16621. * The list of defines used in the shader
  16622. */
  16623. defines: string[];
  16624. }
  16625. /**
  16626. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16627. *
  16628. * This returned material effects how the mesh will look based on the code in the shaders.
  16629. *
  16630. * @see https://doc.babylonjs.com/how_to/shader_material
  16631. */
  16632. export class ShaderMaterial extends Material {
  16633. private _shaderPath;
  16634. private _options;
  16635. private _textures;
  16636. private _textureArrays;
  16637. private _floats;
  16638. private _ints;
  16639. private _floatsArrays;
  16640. private _colors3;
  16641. private _colors3Arrays;
  16642. private _colors4;
  16643. private _colors4Arrays;
  16644. private _vectors2;
  16645. private _vectors3;
  16646. private _vectors4;
  16647. private _matrices;
  16648. private _matrixArrays;
  16649. private _matrices3x3;
  16650. private _matrices2x2;
  16651. private _vectors2Arrays;
  16652. private _vectors3Arrays;
  16653. private _vectors4Arrays;
  16654. private _cachedWorldViewMatrix;
  16655. private _cachedWorldViewProjectionMatrix;
  16656. private _renderId;
  16657. private _multiview;
  16658. private _cachedDefines;
  16659. /** Define the Url to load snippets */
  16660. static SnippetUrl: string;
  16661. /** Snippet ID if the material was created from the snippet server */
  16662. snippetId: string;
  16663. /**
  16664. * Instantiate a new shader material.
  16665. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16666. * This returned material effects how the mesh will look based on the code in the shaders.
  16667. * @see https://doc.babylonjs.com/how_to/shader_material
  16668. * @param name Define the name of the material in the scene
  16669. * @param scene Define the scene the material belongs to
  16670. * @param shaderPath Defines the route to the shader code in one of three ways:
  16671. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16672. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16673. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16674. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16675. * @param options Define the options used to create the shader
  16676. */
  16677. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16678. /**
  16679. * Gets the shader path used to define the shader code
  16680. * It can be modified to trigger a new compilation
  16681. */
  16682. get shaderPath(): any;
  16683. /**
  16684. * Sets the shader path used to define the shader code
  16685. * It can be modified to trigger a new compilation
  16686. */
  16687. set shaderPath(shaderPath: any);
  16688. /**
  16689. * Gets the options used to compile the shader.
  16690. * They can be modified to trigger a new compilation
  16691. */
  16692. get options(): IShaderMaterialOptions;
  16693. /**
  16694. * Gets the current class name of the material e.g. "ShaderMaterial"
  16695. * Mainly use in serialization.
  16696. * @returns the class name
  16697. */
  16698. getClassName(): string;
  16699. /**
  16700. * Specifies if the material will require alpha blending
  16701. * @returns a boolean specifying if alpha blending is needed
  16702. */
  16703. needAlphaBlending(): boolean;
  16704. /**
  16705. * Specifies if this material should be rendered in alpha test mode
  16706. * @returns a boolean specifying if an alpha test is needed.
  16707. */
  16708. needAlphaTesting(): boolean;
  16709. private _checkUniform;
  16710. /**
  16711. * Set a texture in the shader.
  16712. * @param name Define the name of the uniform samplers as defined in the shader
  16713. * @param texture Define the texture to bind to this sampler
  16714. * @return the material itself allowing "fluent" like uniform updates
  16715. */
  16716. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16717. /**
  16718. * Set a texture array in the shader.
  16719. * @param name Define the name of the uniform sampler array as defined in the shader
  16720. * @param textures Define the list of textures to bind to this sampler
  16721. * @return the material itself allowing "fluent" like uniform updates
  16722. */
  16723. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16724. /**
  16725. * Set a float in the shader.
  16726. * @param name Define the name of the uniform as defined in the shader
  16727. * @param value Define the value to give to the uniform
  16728. * @return the material itself allowing "fluent" like uniform updates
  16729. */
  16730. setFloat(name: string, value: number): ShaderMaterial;
  16731. /**
  16732. * Set a int in the shader.
  16733. * @param name Define the name of the uniform as defined in the shader
  16734. * @param value Define the value to give to the uniform
  16735. * @return the material itself allowing "fluent" like uniform updates
  16736. */
  16737. setInt(name: string, value: number): ShaderMaterial;
  16738. /**
  16739. * Set an array of floats in the shader.
  16740. * @param name Define the name of the uniform as defined in the shader
  16741. * @param value Define the value to give to the uniform
  16742. * @return the material itself allowing "fluent" like uniform updates
  16743. */
  16744. setFloats(name: string, value: number[]): ShaderMaterial;
  16745. /**
  16746. * Set a vec3 in the shader from a Color3.
  16747. * @param name Define the name of the uniform as defined in the shader
  16748. * @param value Define the value to give to the uniform
  16749. * @return the material itself allowing "fluent" like uniform updates
  16750. */
  16751. setColor3(name: string, value: Color3): ShaderMaterial;
  16752. /**
  16753. * Set a vec3 array in the shader from a Color3 array.
  16754. * @param name Define the name of the uniform as defined in the shader
  16755. * @param value Define the value to give to the uniform
  16756. * @return the material itself allowing "fluent" like uniform updates
  16757. */
  16758. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16759. /**
  16760. * Set a vec4 in the shader from a Color4.
  16761. * @param name Define the name of the uniform as defined in the shader
  16762. * @param value Define the value to give to the uniform
  16763. * @return the material itself allowing "fluent" like uniform updates
  16764. */
  16765. setColor4(name: string, value: Color4): ShaderMaterial;
  16766. /**
  16767. * Set a vec4 array in the shader from a Color4 array.
  16768. * @param name Define the name of the uniform as defined in the shader
  16769. * @param value Define the value to give to the uniform
  16770. * @return the material itself allowing "fluent" like uniform updates
  16771. */
  16772. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16773. /**
  16774. * Set a vec2 in the shader from a Vector2.
  16775. * @param name Define the name of the uniform as defined in the shader
  16776. * @param value Define the value to give to the uniform
  16777. * @return the material itself allowing "fluent" like uniform updates
  16778. */
  16779. setVector2(name: string, value: Vector2): ShaderMaterial;
  16780. /**
  16781. * Set a vec3 in the shader from a Vector3.
  16782. * @param name Define the name of the uniform as defined in the shader
  16783. * @param value Define the value to give to the uniform
  16784. * @return the material itself allowing "fluent" like uniform updates
  16785. */
  16786. setVector3(name: string, value: Vector3): ShaderMaterial;
  16787. /**
  16788. * Set a vec4 in the shader from a Vector4.
  16789. * @param name Define the name of the uniform as defined in the shader
  16790. * @param value Define the value to give to the uniform
  16791. * @return the material itself allowing "fluent" like uniform updates
  16792. */
  16793. setVector4(name: string, value: Vector4): ShaderMaterial;
  16794. /**
  16795. * Set a mat4 in the shader from a Matrix.
  16796. * @param name Define the name of the uniform as defined in the shader
  16797. * @param value Define the value to give to the uniform
  16798. * @return the material itself allowing "fluent" like uniform updates
  16799. */
  16800. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16801. /**
  16802. * Set a float32Array in the shader from a matrix array.
  16803. * @param name Define the name of the uniform as defined in the shader
  16804. * @param value Define the value to give to the uniform
  16805. * @return the material itself allowing "fluent" like uniform updates
  16806. */
  16807. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16808. /**
  16809. * Set a mat3 in the shader from a Float32Array.
  16810. * @param name Define the name of the uniform as defined in the shader
  16811. * @param value Define the value to give to the uniform
  16812. * @return the material itself allowing "fluent" like uniform updates
  16813. */
  16814. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16815. /**
  16816. * Set a mat2 in the shader from a Float32Array.
  16817. * @param name Define the name of the uniform as defined in the shader
  16818. * @param value Define the value to give to the uniform
  16819. * @return the material itself allowing "fluent" like uniform updates
  16820. */
  16821. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16822. /**
  16823. * Set a vec2 array in the shader from a number array.
  16824. * @param name Define the name of the uniform as defined in the shader
  16825. * @param value Define the value to give to the uniform
  16826. * @return the material itself allowing "fluent" like uniform updates
  16827. */
  16828. setArray2(name: string, value: number[]): ShaderMaterial;
  16829. /**
  16830. * Set a vec3 array in the shader from a number array.
  16831. * @param name Define the name of the uniform as defined in the shader
  16832. * @param value Define the value to give to the uniform
  16833. * @return the material itself allowing "fluent" like uniform updates
  16834. */
  16835. setArray3(name: string, value: number[]): ShaderMaterial;
  16836. /**
  16837. * Set a vec4 array in the shader from a number array.
  16838. * @param name Define the name of the uniform as defined in the shader
  16839. * @param value Define the value to give to the uniform
  16840. * @return the material itself allowing "fluent" like uniform updates
  16841. */
  16842. setArray4(name: string, value: number[]): ShaderMaterial;
  16843. private _checkCache;
  16844. /**
  16845. * Specifies that the submesh is ready to be used
  16846. * @param mesh defines the mesh to check
  16847. * @param subMesh defines which submesh to check
  16848. * @param useInstances specifies that instances should be used
  16849. * @returns a boolean indicating that the submesh is ready or not
  16850. */
  16851. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16852. /**
  16853. * Checks if the material is ready to render the requested mesh
  16854. * @param mesh Define the mesh to render
  16855. * @param useInstances Define whether or not the material is used with instances
  16856. * @returns true if ready, otherwise false
  16857. */
  16858. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16859. /**
  16860. * Binds the world matrix to the material
  16861. * @param world defines the world transformation matrix
  16862. * @param effectOverride - If provided, use this effect instead of internal effect
  16863. */
  16864. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16865. /**
  16866. * Binds the submesh to this material by preparing the effect and shader to draw
  16867. * @param world defines the world transformation matrix
  16868. * @param mesh defines the mesh containing the submesh
  16869. * @param subMesh defines the submesh to bind the material to
  16870. */
  16871. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16872. /**
  16873. * Binds the material to the mesh
  16874. * @param world defines the world transformation matrix
  16875. * @param mesh defines the mesh to bind the material to
  16876. * @param effectOverride - If provided, use this effect instead of internal effect
  16877. */
  16878. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16879. protected _afterBind(mesh?: Mesh): void;
  16880. /**
  16881. * Gets the active textures from the material
  16882. * @returns an array of textures
  16883. */
  16884. getActiveTextures(): BaseTexture[];
  16885. /**
  16886. * Specifies if the material uses a texture
  16887. * @param texture defines the texture to check against the material
  16888. * @returns a boolean specifying if the material uses the texture
  16889. */
  16890. hasTexture(texture: BaseTexture): boolean;
  16891. /**
  16892. * Makes a duplicate of the material, and gives it a new name
  16893. * @param name defines the new name for the duplicated material
  16894. * @returns the cloned material
  16895. */
  16896. clone(name: string): ShaderMaterial;
  16897. /**
  16898. * Disposes the material
  16899. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16900. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16901. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16902. */
  16903. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16904. /**
  16905. * Serializes this material in a JSON representation
  16906. * @returns the serialized material object
  16907. */
  16908. serialize(): any;
  16909. /**
  16910. * Creates a shader material from parsed shader material data
  16911. * @param source defines the JSON represnetation of the material
  16912. * @param scene defines the hosting scene
  16913. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16914. * @returns a new material
  16915. */
  16916. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16917. /**
  16918. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16919. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16920. * @param url defines the url to load from
  16921. * @param scene defines the hosting scene
  16922. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16923. * @returns a promise that will resolve to the new ShaderMaterial
  16924. */
  16925. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16926. /**
  16927. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16928. * @param snippetId defines the snippet to load
  16929. * @param scene defines the hosting scene
  16930. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16931. * @returns a promise that will resolve to the new ShaderMaterial
  16932. */
  16933. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16934. }
  16935. }
  16936. declare module BABYLON {
  16937. /** @hidden */
  16938. export var colorPixelShader: {
  16939. name: string;
  16940. shader: string;
  16941. };
  16942. }
  16943. declare module BABYLON {
  16944. /** @hidden */
  16945. export var colorVertexShader: {
  16946. name: string;
  16947. shader: string;
  16948. };
  16949. }
  16950. declare module BABYLON {
  16951. /**
  16952. * Line mesh
  16953. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16954. */
  16955. export class LinesMesh extends Mesh {
  16956. /**
  16957. * If vertex color should be applied to the mesh
  16958. */
  16959. readonly useVertexColor?: boolean | undefined;
  16960. /**
  16961. * If vertex alpha should be applied to the mesh
  16962. */
  16963. readonly useVertexAlpha?: boolean | undefined;
  16964. /**
  16965. * Color of the line (Default: White)
  16966. */
  16967. color: Color3;
  16968. /**
  16969. * Alpha of the line (Default: 1)
  16970. */
  16971. alpha: number;
  16972. /**
  16973. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16974. * This margin is expressed in world space coordinates, so its value may vary.
  16975. * Default value is 0.1
  16976. */
  16977. intersectionThreshold: number;
  16978. private _colorShader;
  16979. private color4;
  16980. /**
  16981. * Creates a new LinesMesh
  16982. * @param name defines the name
  16983. * @param scene defines the hosting scene
  16984. * @param parent defines the parent mesh if any
  16985. * @param source defines the optional source LinesMesh used to clone data from
  16986. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16987. * When false, achieved by calling a clone(), also passing False.
  16988. * This will make creation of children, recursive.
  16989. * @param useVertexColor defines if this LinesMesh supports vertex color
  16990. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16991. */
  16992. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16993. /**
  16994. * If vertex color should be applied to the mesh
  16995. */
  16996. useVertexColor?: boolean | undefined,
  16997. /**
  16998. * If vertex alpha should be applied to the mesh
  16999. */
  17000. useVertexAlpha?: boolean | undefined);
  17001. private _addClipPlaneDefine;
  17002. private _removeClipPlaneDefine;
  17003. isReady(): boolean;
  17004. /**
  17005. * Returns the string "LineMesh"
  17006. */
  17007. getClassName(): string;
  17008. /**
  17009. * @hidden
  17010. */
  17011. get material(): Material;
  17012. /**
  17013. * @hidden
  17014. */
  17015. set material(value: Material);
  17016. /**
  17017. * @hidden
  17018. */
  17019. get checkCollisions(): boolean;
  17020. /** @hidden */
  17021. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17022. /** @hidden */
  17023. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17024. /**
  17025. * Disposes of the line mesh
  17026. * @param doNotRecurse If children should be disposed
  17027. */
  17028. dispose(doNotRecurse?: boolean): void;
  17029. /**
  17030. * Returns a new LineMesh object cloned from the current one.
  17031. */
  17032. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17033. /**
  17034. * Creates a new InstancedLinesMesh object from the mesh model.
  17035. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17036. * @param name defines the name of the new instance
  17037. * @returns a new InstancedLinesMesh
  17038. */
  17039. createInstance(name: string): InstancedLinesMesh;
  17040. }
  17041. /**
  17042. * Creates an instance based on a source LinesMesh
  17043. */
  17044. export class InstancedLinesMesh extends InstancedMesh {
  17045. /**
  17046. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17047. * This margin is expressed in world space coordinates, so its value may vary.
  17048. * Initilized with the intersectionThreshold value of the source LinesMesh
  17049. */
  17050. intersectionThreshold: number;
  17051. constructor(name: string, source: LinesMesh);
  17052. /**
  17053. * Returns the string "InstancedLinesMesh".
  17054. */
  17055. getClassName(): string;
  17056. }
  17057. }
  17058. declare module BABYLON {
  17059. /** @hidden */
  17060. export var linePixelShader: {
  17061. name: string;
  17062. shader: string;
  17063. };
  17064. }
  17065. declare module BABYLON {
  17066. /** @hidden */
  17067. export var lineVertexShader: {
  17068. name: string;
  17069. shader: string;
  17070. };
  17071. }
  17072. declare module BABYLON {
  17073. interface Scene {
  17074. /** @hidden */
  17075. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17076. }
  17077. interface AbstractMesh {
  17078. /**
  17079. * Gets the edgesRenderer associated with the mesh
  17080. */
  17081. edgesRenderer: Nullable<EdgesRenderer>;
  17082. }
  17083. interface LinesMesh {
  17084. /**
  17085. * Enables the edge rendering mode on the mesh.
  17086. * This mode makes the mesh edges visible
  17087. * @param epsilon defines the maximal distance between two angles to detect a face
  17088. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17089. * @returns the currentAbstractMesh
  17090. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17091. */
  17092. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17093. }
  17094. interface InstancedLinesMesh {
  17095. /**
  17096. * Enables the edge rendering mode on the mesh.
  17097. * This mode makes the mesh edges visible
  17098. * @param epsilon defines the maximal distance between two angles to detect a face
  17099. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17100. * @returns the current InstancedLinesMesh
  17101. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17102. */
  17103. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17104. }
  17105. /**
  17106. * Defines the minimum contract an Edges renderer should follow.
  17107. */
  17108. export interface IEdgesRenderer extends IDisposable {
  17109. /**
  17110. * Gets or sets a boolean indicating if the edgesRenderer is active
  17111. */
  17112. isEnabled: boolean;
  17113. /**
  17114. * Renders the edges of the attached mesh,
  17115. */
  17116. render(): void;
  17117. /**
  17118. * Checks wether or not the edges renderer is ready to render.
  17119. * @return true if ready, otherwise false.
  17120. */
  17121. isReady(): boolean;
  17122. /**
  17123. * List of instances to render in case the source mesh has instances
  17124. */
  17125. customInstances: SmartArray<Matrix>;
  17126. }
  17127. /**
  17128. * Defines the additional options of the edges renderer
  17129. */
  17130. export interface IEdgesRendererOptions {
  17131. /**
  17132. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17133. * If not defined, the default value is true
  17134. */
  17135. useAlternateEdgeFinder?: boolean;
  17136. /**
  17137. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17138. * If not defined, the default value is true.
  17139. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  17140. * This option is used only if useAlternateEdgeFinder = true
  17141. */
  17142. useFastVertexMerger?: boolean;
  17143. /**
  17144. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17145. * The default value is 1e-6
  17146. * This option is used only if useAlternateEdgeFinder = true
  17147. */
  17148. epsilonVertexMerge?: number;
  17149. /**
  17150. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  17151. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  17152. * This option is used only if useAlternateEdgeFinder = true
  17153. */
  17154. applyTessellation?: boolean;
  17155. /**
  17156. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  17157. * The default value is 1e-6
  17158. * This option is used only if useAlternateEdgeFinder = true
  17159. */
  17160. epsilonVertexAligned?: number;
  17161. }
  17162. /**
  17163. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17164. */
  17165. export class EdgesRenderer implements IEdgesRenderer {
  17166. /**
  17167. * Define the size of the edges with an orthographic camera
  17168. */
  17169. edgesWidthScalerForOrthographic: number;
  17170. /**
  17171. * Define the size of the edges with a perspective camera
  17172. */
  17173. edgesWidthScalerForPerspective: number;
  17174. protected _source: AbstractMesh;
  17175. protected _linesPositions: number[];
  17176. protected _linesNormals: number[];
  17177. protected _linesIndices: number[];
  17178. protected _epsilon: number;
  17179. protected _indicesCount: number;
  17180. protected _lineShader: ShaderMaterial;
  17181. protected _ib: DataBuffer;
  17182. protected _buffers: {
  17183. [key: string]: Nullable<VertexBuffer>;
  17184. };
  17185. protected _buffersForInstances: {
  17186. [key: string]: Nullable<VertexBuffer>;
  17187. };
  17188. protected _checkVerticesInsteadOfIndices: boolean;
  17189. protected _options: Nullable<IEdgesRendererOptions>;
  17190. private _meshRebuildObserver;
  17191. private _meshDisposeObserver;
  17192. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17193. isEnabled: boolean;
  17194. /**
  17195. * List of instances to render in case the source mesh has instances
  17196. */
  17197. customInstances: SmartArray<Matrix>;
  17198. private static GetShader;
  17199. /**
  17200. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17201. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17202. * @param source Mesh used to create edges
  17203. * @param epsilon sum of angles in adjacency to check for edge
  17204. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17205. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17206. * @param options The options to apply when generating the edges
  17207. */
  17208. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17209. protected _prepareRessources(): void;
  17210. /** @hidden */
  17211. _rebuild(): void;
  17212. /**
  17213. * Releases the required resources for the edges renderer
  17214. */
  17215. dispose(): void;
  17216. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17217. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17218. /**
  17219. * Checks if the pair of p0 and p1 is en edge
  17220. * @param faceIndex
  17221. * @param edge
  17222. * @param faceNormals
  17223. * @param p0
  17224. * @param p1
  17225. * @private
  17226. */
  17227. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17228. /**
  17229. * push line into the position, normal and index buffer
  17230. * @protected
  17231. */
  17232. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17233. /**
  17234. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17235. */
  17236. private _tessellateTriangle;
  17237. private _generateEdgesLinesAlternate;
  17238. /**
  17239. * Generates lines edges from adjacencjes
  17240. * @private
  17241. */
  17242. _generateEdgesLines(): void;
  17243. /**
  17244. * Checks wether or not the edges renderer is ready to render.
  17245. * @return true if ready, otherwise false.
  17246. */
  17247. isReady(): boolean;
  17248. /**
  17249. * Renders the edges of the attached mesh,
  17250. */
  17251. render(): void;
  17252. }
  17253. /**
  17254. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17255. */
  17256. export class LineEdgesRenderer extends EdgesRenderer {
  17257. /**
  17258. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17259. * @param source LineMesh used to generate edges
  17260. * @param epsilon not important (specified angle for edge detection)
  17261. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17262. */
  17263. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17264. /**
  17265. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17266. */
  17267. _generateEdgesLines(): void;
  17268. }
  17269. }
  17270. declare module BABYLON {
  17271. /**
  17272. * This represents the object necessary to create a rendering group.
  17273. * This is exclusively used and created by the rendering manager.
  17274. * To modify the behavior, you use the available helpers in your scene or meshes.
  17275. * @hidden
  17276. */
  17277. export class RenderingGroup {
  17278. index: number;
  17279. private static _zeroVector;
  17280. private _scene;
  17281. private _opaqueSubMeshes;
  17282. private _transparentSubMeshes;
  17283. private _alphaTestSubMeshes;
  17284. private _depthOnlySubMeshes;
  17285. private _particleSystems;
  17286. private _spriteManagers;
  17287. private _opaqueSortCompareFn;
  17288. private _alphaTestSortCompareFn;
  17289. private _transparentSortCompareFn;
  17290. private _renderOpaque;
  17291. private _renderAlphaTest;
  17292. private _renderTransparent;
  17293. /** @hidden */
  17294. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17295. onBeforeTransparentRendering: () => void;
  17296. /**
  17297. * Set the opaque sort comparison function.
  17298. * If null the sub meshes will be render in the order they were created
  17299. */
  17300. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17301. /**
  17302. * Set the alpha test sort comparison function.
  17303. * If null the sub meshes will be render in the order they were created
  17304. */
  17305. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17306. /**
  17307. * Set the transparent sort comparison function.
  17308. * If null the sub meshes will be render in the order they were created
  17309. */
  17310. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17311. /**
  17312. * Creates a new rendering group.
  17313. * @param index The rendering group index
  17314. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17315. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17316. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17317. */
  17318. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17319. /**
  17320. * Render all the sub meshes contained in the group.
  17321. * @param customRenderFunction Used to override the default render behaviour of the group.
  17322. * @returns true if rendered some submeshes.
  17323. */
  17324. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17325. /**
  17326. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17327. * @param subMeshes The submeshes to render
  17328. */
  17329. private renderOpaqueSorted;
  17330. /**
  17331. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17332. * @param subMeshes The submeshes to render
  17333. */
  17334. private renderAlphaTestSorted;
  17335. /**
  17336. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17337. * @param subMeshes The submeshes to render
  17338. */
  17339. private renderTransparentSorted;
  17340. /**
  17341. * Renders the submeshes in a specified order.
  17342. * @param subMeshes The submeshes to sort before render
  17343. * @param sortCompareFn The comparison function use to sort
  17344. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17345. * @param transparent Specifies to activate blending if true
  17346. */
  17347. private static renderSorted;
  17348. /**
  17349. * Renders the submeshes in the order they were dispatched (no sort applied).
  17350. * @param subMeshes The submeshes to render
  17351. */
  17352. private static renderUnsorted;
  17353. /**
  17354. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17355. * are rendered back to front if in the same alpha index.
  17356. *
  17357. * @param a The first submesh
  17358. * @param b The second submesh
  17359. * @returns The result of the comparison
  17360. */
  17361. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17362. /**
  17363. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17364. * are rendered back to front.
  17365. *
  17366. * @param a The first submesh
  17367. * @param b The second submesh
  17368. * @returns The result of the comparison
  17369. */
  17370. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17371. /**
  17372. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17373. * are rendered front to back (prevent overdraw).
  17374. *
  17375. * @param a The first submesh
  17376. * @param b The second submesh
  17377. * @returns The result of the comparison
  17378. */
  17379. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17380. /**
  17381. * Resets the different lists of submeshes to prepare a new frame.
  17382. */
  17383. prepare(): void;
  17384. dispose(): void;
  17385. /**
  17386. * Inserts the submesh in its correct queue depending on its material.
  17387. * @param subMesh The submesh to dispatch
  17388. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17389. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17390. */
  17391. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17392. dispatchSprites(spriteManager: ISpriteManager): void;
  17393. dispatchParticles(particleSystem: IParticleSystem): void;
  17394. private _renderParticles;
  17395. private _renderSprites;
  17396. }
  17397. }
  17398. declare module BABYLON {
  17399. /**
  17400. * Interface describing the different options available in the rendering manager
  17401. * regarding Auto Clear between groups.
  17402. */
  17403. export interface IRenderingManagerAutoClearSetup {
  17404. /**
  17405. * Defines whether or not autoclear is enable.
  17406. */
  17407. autoClear: boolean;
  17408. /**
  17409. * Defines whether or not to autoclear the depth buffer.
  17410. */
  17411. depth: boolean;
  17412. /**
  17413. * Defines whether or not to autoclear the stencil buffer.
  17414. */
  17415. stencil: boolean;
  17416. }
  17417. /**
  17418. * This class is used by the onRenderingGroupObservable
  17419. */
  17420. export class RenderingGroupInfo {
  17421. /**
  17422. * The Scene that being rendered
  17423. */
  17424. scene: Scene;
  17425. /**
  17426. * The camera currently used for the rendering pass
  17427. */
  17428. camera: Nullable<Camera>;
  17429. /**
  17430. * The ID of the renderingGroup being processed
  17431. */
  17432. renderingGroupId: number;
  17433. }
  17434. /**
  17435. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17436. * It is enable to manage the different groups as well as the different necessary sort functions.
  17437. * This should not be used directly aside of the few static configurations
  17438. */
  17439. export class RenderingManager {
  17440. /**
  17441. * The max id used for rendering groups (not included)
  17442. */
  17443. static MAX_RENDERINGGROUPS: number;
  17444. /**
  17445. * The min id used for rendering groups (included)
  17446. */
  17447. static MIN_RENDERINGGROUPS: number;
  17448. /**
  17449. * Used to globally prevent autoclearing scenes.
  17450. */
  17451. static AUTOCLEAR: boolean;
  17452. /**
  17453. * @hidden
  17454. */
  17455. _useSceneAutoClearSetup: boolean;
  17456. private _scene;
  17457. private _renderingGroups;
  17458. private _depthStencilBufferAlreadyCleaned;
  17459. private _autoClearDepthStencil;
  17460. private _customOpaqueSortCompareFn;
  17461. private _customAlphaTestSortCompareFn;
  17462. private _customTransparentSortCompareFn;
  17463. private _renderingGroupInfo;
  17464. /**
  17465. * Instantiates a new rendering group for a particular scene
  17466. * @param scene Defines the scene the groups belongs to
  17467. */
  17468. constructor(scene: Scene);
  17469. private _clearDepthStencilBuffer;
  17470. /**
  17471. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17472. * @hidden
  17473. */
  17474. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17475. /**
  17476. * Resets the different information of the group to prepare a new frame
  17477. * @hidden
  17478. */
  17479. reset(): void;
  17480. /**
  17481. * Dispose and release the group and its associated resources.
  17482. * @hidden
  17483. */
  17484. dispose(): void;
  17485. /**
  17486. * Clear the info related to rendering groups preventing retention points during dispose.
  17487. */
  17488. freeRenderingGroups(): void;
  17489. private _prepareRenderingGroup;
  17490. /**
  17491. * Add a sprite manager to the rendering manager in order to render it this frame.
  17492. * @param spriteManager Define the sprite manager to render
  17493. */
  17494. dispatchSprites(spriteManager: ISpriteManager): void;
  17495. /**
  17496. * Add a particle system to the rendering manager in order to render it this frame.
  17497. * @param particleSystem Define the particle system to render
  17498. */
  17499. dispatchParticles(particleSystem: IParticleSystem): void;
  17500. /**
  17501. * Add a submesh to the manager in order to render it this frame
  17502. * @param subMesh The submesh to dispatch
  17503. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17504. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17505. */
  17506. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17507. /**
  17508. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17509. * This allowed control for front to back rendering or reversly depending of the special needs.
  17510. *
  17511. * @param renderingGroupId The rendering group id corresponding to its index
  17512. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17513. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17514. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17515. */
  17516. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  17517. /**
  17518. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17519. *
  17520. * @param renderingGroupId The rendering group id corresponding to its index
  17521. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17522. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17523. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17524. */
  17525. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17526. /**
  17527. * Gets the current auto clear configuration for one rendering group of the rendering
  17528. * manager.
  17529. * @param index the rendering group index to get the information for
  17530. * @returns The auto clear setup for the requested rendering group
  17531. */
  17532. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17533. }
  17534. }
  17535. declare module BABYLON {
  17536. /**
  17537. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17538. */
  17539. export interface ICustomShaderOptions {
  17540. /**
  17541. * Gets or sets the custom shader name to use
  17542. */
  17543. shaderName: string;
  17544. /**
  17545. * The list of attribute names used in the shader
  17546. */
  17547. attributes?: string[];
  17548. /**
  17549. * The list of unifrom names used in the shader
  17550. */
  17551. uniforms?: string[];
  17552. /**
  17553. * The list of sampler names used in the shader
  17554. */
  17555. samplers?: string[];
  17556. /**
  17557. * The list of defines used in the shader
  17558. */
  17559. defines?: string[];
  17560. }
  17561. /**
  17562. * Interface to implement to create a shadow generator compatible with BJS.
  17563. */
  17564. export interface IShadowGenerator {
  17565. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17566. id: string;
  17567. /**
  17568. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17569. * @returns The render target texture if present otherwise, null
  17570. */
  17571. getShadowMap(): Nullable<RenderTargetTexture>;
  17572. /**
  17573. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17574. * @param subMesh The submesh we want to render in the shadow map
  17575. * @param useInstances Defines wether will draw in the map using instances
  17576. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17577. * @returns true if ready otherwise, false
  17578. */
  17579. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17580. /**
  17581. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17582. * @param defines Defines of the material we want to update
  17583. * @param lightIndex Index of the light in the enabled light list of the material
  17584. */
  17585. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17586. /**
  17587. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17588. * defined in the generator but impacting the effect).
  17589. * It implies the unifroms available on the materials are the standard BJS ones.
  17590. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17591. * @param effect The effect we are binfing the information for
  17592. */
  17593. bindShadowLight(lightIndex: string, effect: Effect): void;
  17594. /**
  17595. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17596. * (eq to shadow prjection matrix * light transform matrix)
  17597. * @returns The transform matrix used to create the shadow map
  17598. */
  17599. getTransformMatrix(): Matrix;
  17600. /**
  17601. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17602. * Cube and 2D textures for instance.
  17603. */
  17604. recreateShadowMap(): void;
  17605. /**
  17606. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17607. * @param onCompiled Callback triggered at the and of the effects compilation
  17608. * @param options Sets of optional options forcing the compilation with different modes
  17609. */
  17610. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17611. useInstances: boolean;
  17612. }>): void;
  17613. /**
  17614. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17615. * @param options Sets of optional options forcing the compilation with different modes
  17616. * @returns A promise that resolves when the compilation completes
  17617. */
  17618. forceCompilationAsync(options?: Partial<{
  17619. useInstances: boolean;
  17620. }>): Promise<void>;
  17621. /**
  17622. * Serializes the shadow generator setup to a json object.
  17623. * @returns The serialized JSON object
  17624. */
  17625. serialize(): any;
  17626. /**
  17627. * Disposes the Shadow map and related Textures and effects.
  17628. */
  17629. dispose(): void;
  17630. }
  17631. /**
  17632. * Default implementation IShadowGenerator.
  17633. * This is the main object responsible of generating shadows in the framework.
  17634. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17635. */
  17636. export class ShadowGenerator implements IShadowGenerator {
  17637. /**
  17638. * Name of the shadow generator class
  17639. */
  17640. static CLASSNAME: string;
  17641. /**
  17642. * Shadow generator mode None: no filtering applied.
  17643. */
  17644. static readonly FILTER_NONE: number;
  17645. /**
  17646. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17647. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17648. */
  17649. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17650. /**
  17651. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17652. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17653. */
  17654. static readonly FILTER_POISSONSAMPLING: number;
  17655. /**
  17656. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17657. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17658. */
  17659. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17660. /**
  17661. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17662. * edge artifacts on steep falloff.
  17663. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17664. */
  17665. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17666. /**
  17667. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17668. * edge artifacts on steep falloff.
  17669. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17670. */
  17671. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17672. /**
  17673. * Shadow generator mode PCF: Percentage Closer Filtering
  17674. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17675. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17676. */
  17677. static readonly FILTER_PCF: number;
  17678. /**
  17679. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17680. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17681. * Contact Hardening
  17682. */
  17683. static readonly FILTER_PCSS: number;
  17684. /**
  17685. * Reserved for PCF and PCSS
  17686. * Highest Quality.
  17687. *
  17688. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17689. *
  17690. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17691. */
  17692. static readonly QUALITY_HIGH: number;
  17693. /**
  17694. * Reserved for PCF and PCSS
  17695. * Good tradeoff for quality/perf cross devices
  17696. *
  17697. * Execute PCF on a 3*3 kernel.
  17698. *
  17699. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17700. */
  17701. static readonly QUALITY_MEDIUM: number;
  17702. /**
  17703. * Reserved for PCF and PCSS
  17704. * The lowest quality but the fastest.
  17705. *
  17706. * Execute PCF on a 1*1 kernel.
  17707. *
  17708. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17709. */
  17710. static readonly QUALITY_LOW: number;
  17711. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17712. id: string;
  17713. /** Gets or sets the custom shader name to use */
  17714. customShaderOptions: ICustomShaderOptions;
  17715. /**
  17716. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17717. */
  17718. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17719. /**
  17720. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17721. */
  17722. onAfterShadowMapRenderObservable: Observable<Effect>;
  17723. /**
  17724. * Observable triggered before a mesh is rendered in the shadow map.
  17725. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17726. */
  17727. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17728. /**
  17729. * Observable triggered after a mesh is rendered in the shadow map.
  17730. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17731. */
  17732. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17733. protected _bias: number;
  17734. /**
  17735. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17736. */
  17737. get bias(): number;
  17738. /**
  17739. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17740. */
  17741. set bias(bias: number);
  17742. protected _normalBias: number;
  17743. /**
  17744. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17745. */
  17746. get normalBias(): number;
  17747. /**
  17748. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17749. */
  17750. set normalBias(normalBias: number);
  17751. protected _blurBoxOffset: number;
  17752. /**
  17753. * Gets the blur box offset: offset applied during the blur pass.
  17754. * Only useful if useKernelBlur = false
  17755. */
  17756. get blurBoxOffset(): number;
  17757. /**
  17758. * Sets the blur box offset: offset applied during the blur pass.
  17759. * Only useful if useKernelBlur = false
  17760. */
  17761. set blurBoxOffset(value: number);
  17762. protected _blurScale: number;
  17763. /**
  17764. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17765. * 2 means half of the size.
  17766. */
  17767. get blurScale(): number;
  17768. /**
  17769. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17770. * 2 means half of the size.
  17771. */
  17772. set blurScale(value: number);
  17773. protected _blurKernel: number;
  17774. /**
  17775. * Gets the blur kernel: kernel size of the blur pass.
  17776. * Only useful if useKernelBlur = true
  17777. */
  17778. get blurKernel(): number;
  17779. /**
  17780. * Sets the blur kernel: kernel size of the blur pass.
  17781. * Only useful if useKernelBlur = true
  17782. */
  17783. set blurKernel(value: number);
  17784. protected _useKernelBlur: boolean;
  17785. /**
  17786. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17787. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17788. */
  17789. get useKernelBlur(): boolean;
  17790. /**
  17791. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17792. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17793. */
  17794. set useKernelBlur(value: boolean);
  17795. protected _depthScale: number;
  17796. /**
  17797. * Gets the depth scale used in ESM mode.
  17798. */
  17799. get depthScale(): number;
  17800. /**
  17801. * Sets the depth scale used in ESM mode.
  17802. * This can override the scale stored on the light.
  17803. */
  17804. set depthScale(value: number);
  17805. protected _validateFilter(filter: number): number;
  17806. protected _filter: number;
  17807. /**
  17808. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17809. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17810. */
  17811. get filter(): number;
  17812. /**
  17813. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17814. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17815. */
  17816. set filter(value: number);
  17817. /**
  17818. * Gets if the current filter is set to Poisson Sampling.
  17819. */
  17820. get usePoissonSampling(): boolean;
  17821. /**
  17822. * Sets the current filter to Poisson Sampling.
  17823. */
  17824. set usePoissonSampling(value: boolean);
  17825. /**
  17826. * Gets if the current filter is set to ESM.
  17827. */
  17828. get useExponentialShadowMap(): boolean;
  17829. /**
  17830. * Sets the current filter is to ESM.
  17831. */
  17832. set useExponentialShadowMap(value: boolean);
  17833. /**
  17834. * Gets if the current filter is set to filtered ESM.
  17835. */
  17836. get useBlurExponentialShadowMap(): boolean;
  17837. /**
  17838. * Gets if the current filter is set to filtered ESM.
  17839. */
  17840. set useBlurExponentialShadowMap(value: boolean);
  17841. /**
  17842. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17843. * exponential to prevent steep falloff artifacts).
  17844. */
  17845. get useCloseExponentialShadowMap(): boolean;
  17846. /**
  17847. * Sets the current filter to "close ESM" (using the inverse of the
  17848. * exponential to prevent steep falloff artifacts).
  17849. */
  17850. set useCloseExponentialShadowMap(value: boolean);
  17851. /**
  17852. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17853. * exponential to prevent steep falloff artifacts).
  17854. */
  17855. get useBlurCloseExponentialShadowMap(): boolean;
  17856. /**
  17857. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17858. * exponential to prevent steep falloff artifacts).
  17859. */
  17860. set useBlurCloseExponentialShadowMap(value: boolean);
  17861. /**
  17862. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17863. */
  17864. get usePercentageCloserFiltering(): boolean;
  17865. /**
  17866. * Sets the current filter to "PCF" (percentage closer filtering).
  17867. */
  17868. set usePercentageCloserFiltering(value: boolean);
  17869. protected _filteringQuality: number;
  17870. /**
  17871. * Gets the PCF or PCSS Quality.
  17872. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17873. */
  17874. get filteringQuality(): number;
  17875. /**
  17876. * Sets the PCF or PCSS Quality.
  17877. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17878. */
  17879. set filteringQuality(filteringQuality: number);
  17880. /**
  17881. * Gets if the current filter is set to "PCSS" (contact hardening).
  17882. */
  17883. get useContactHardeningShadow(): boolean;
  17884. /**
  17885. * Sets the current filter to "PCSS" (contact hardening).
  17886. */
  17887. set useContactHardeningShadow(value: boolean);
  17888. protected _contactHardeningLightSizeUVRatio: number;
  17889. /**
  17890. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17891. * Using a ratio helps keeping shape stability independently of the map size.
  17892. *
  17893. * It does not account for the light projection as it was having too much
  17894. * instability during the light setup or during light position changes.
  17895. *
  17896. * Only valid if useContactHardeningShadow is true.
  17897. */
  17898. get contactHardeningLightSizeUVRatio(): number;
  17899. /**
  17900. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17901. * Using a ratio helps keeping shape stability independently of the map size.
  17902. *
  17903. * It does not account for the light projection as it was having too much
  17904. * instability during the light setup or during light position changes.
  17905. *
  17906. * Only valid if useContactHardeningShadow is true.
  17907. */
  17908. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17909. protected _darkness: number;
  17910. /** Gets or sets the actual darkness of a shadow */
  17911. get darkness(): number;
  17912. set darkness(value: number);
  17913. /**
  17914. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17915. * 0 means strongest and 1 would means no shadow.
  17916. * @returns the darkness.
  17917. */
  17918. getDarkness(): number;
  17919. /**
  17920. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17921. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17922. * @returns the shadow generator allowing fluent coding.
  17923. */
  17924. setDarkness(darkness: number): ShadowGenerator;
  17925. protected _transparencyShadow: boolean;
  17926. /** Gets or sets the ability to have transparent shadow */
  17927. get transparencyShadow(): boolean;
  17928. set transparencyShadow(value: boolean);
  17929. /**
  17930. * Sets the ability to have transparent shadow (boolean).
  17931. * @param transparent True if transparent else False
  17932. * @returns the shadow generator allowing fluent coding
  17933. */
  17934. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17935. /**
  17936. * Enables or disables shadows with varying strength based on the transparency
  17937. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17938. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17939. * mesh.visibility * alphaTexture.a
  17940. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17941. */
  17942. enableSoftTransparentShadow: boolean;
  17943. protected _shadowMap: Nullable<RenderTargetTexture>;
  17944. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17945. /**
  17946. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17947. * @returns The render target texture if present otherwise, null
  17948. */
  17949. getShadowMap(): Nullable<RenderTargetTexture>;
  17950. /**
  17951. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17952. * @returns The render target texture if the shadow map is present otherwise, null
  17953. */
  17954. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17955. /**
  17956. * Gets the class name of that object
  17957. * @returns "ShadowGenerator"
  17958. */
  17959. getClassName(): string;
  17960. /**
  17961. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17962. * @param mesh Mesh to add
  17963. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17964. * @returns the Shadow Generator itself
  17965. */
  17966. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17967. /**
  17968. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17969. * @param mesh Mesh to remove
  17970. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17971. * @returns the Shadow Generator itself
  17972. */
  17973. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17974. /**
  17975. * Controls the extent to which the shadows fade out at the edge of the frustum
  17976. */
  17977. frustumEdgeFalloff: number;
  17978. protected _light: IShadowLight;
  17979. /**
  17980. * Returns the associated light object.
  17981. * @returns the light generating the shadow
  17982. */
  17983. getLight(): IShadowLight;
  17984. /**
  17985. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17986. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17987. * It might on the other hand introduce peter panning.
  17988. */
  17989. forceBackFacesOnly: boolean;
  17990. protected _scene: Scene;
  17991. protected _lightDirection: Vector3;
  17992. protected _effect: Effect;
  17993. protected _viewMatrix: Matrix;
  17994. protected _projectionMatrix: Matrix;
  17995. protected _transformMatrix: Matrix;
  17996. protected _cachedPosition: Vector3;
  17997. protected _cachedDirection: Vector3;
  17998. protected _cachedDefines: string;
  17999. protected _currentRenderID: number;
  18000. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18001. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18002. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18003. protected _blurPostProcesses: PostProcess[];
  18004. protected _mapSize: number;
  18005. protected _currentFaceIndex: number;
  18006. protected _currentFaceIndexCache: number;
  18007. protected _textureType: number;
  18008. protected _defaultTextureMatrix: Matrix;
  18009. protected _storedUniqueId: Nullable<number>;
  18010. /** @hidden */
  18011. static _SceneComponentInitialization: (scene: Scene) => void;
  18012. /**
  18013. * Gets or sets the size of the texture what stores the shadows
  18014. */
  18015. get mapSize(): number;
  18016. set mapSize(size: number);
  18017. /**
  18018. * Creates a ShadowGenerator object.
  18019. * A ShadowGenerator is the required tool to use the shadows.
  18020. * Each light casting shadows needs to use its own ShadowGenerator.
  18021. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18022. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18023. * @param light The light object generating the shadows.
  18024. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  18025. */
  18026. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18027. protected _initializeGenerator(): void;
  18028. protected _createTargetRenderTexture(): void;
  18029. protected _initializeShadowMap(): void;
  18030. protected _initializeBlurRTTAndPostProcesses(): void;
  18031. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18032. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18033. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18034. protected _applyFilterValues(): void;
  18035. /**
  18036. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18037. * @param onCompiled Callback triggered at the and of the effects compilation
  18038. * @param options Sets of optional options forcing the compilation with different modes
  18039. */
  18040. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18041. useInstances: boolean;
  18042. }>): void;
  18043. /**
  18044. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18045. * @param options Sets of optional options forcing the compilation with different modes
  18046. * @returns A promise that resolves when the compilation completes
  18047. */
  18048. forceCompilationAsync(options?: Partial<{
  18049. useInstances: boolean;
  18050. }>): Promise<void>;
  18051. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18052. private _prepareShadowDefines;
  18053. /**
  18054. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18055. * @param subMesh The submesh we want to render in the shadow map
  18056. * @param useInstances Defines wether will draw in the map using instances
  18057. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18058. * @returns true if ready otherwise, false
  18059. */
  18060. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18061. /**
  18062. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18063. * @param defines Defines of the material we want to update
  18064. * @param lightIndex Index of the light in the enabled light list of the material
  18065. */
  18066. prepareDefines(defines: any, lightIndex: number): void;
  18067. /**
  18068. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18069. * defined in the generator but impacting the effect).
  18070. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18071. * @param effect The effect we are binfing the information for
  18072. */
  18073. bindShadowLight(lightIndex: string, effect: Effect): void;
  18074. /**
  18075. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18076. * (eq to shadow prjection matrix * light transform matrix)
  18077. * @returns The transform matrix used to create the shadow map
  18078. */
  18079. getTransformMatrix(): Matrix;
  18080. /**
  18081. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18082. * Cube and 2D textures for instance.
  18083. */
  18084. recreateShadowMap(): void;
  18085. protected _disposeBlurPostProcesses(): void;
  18086. protected _disposeRTTandPostProcesses(): void;
  18087. /**
  18088. * Disposes the ShadowGenerator.
  18089. * Returns nothing.
  18090. */
  18091. dispose(): void;
  18092. /**
  18093. * Serializes the shadow generator setup to a json object.
  18094. * @returns The serialized JSON object
  18095. */
  18096. serialize(): any;
  18097. /**
  18098. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18099. * @param parsedShadowGenerator The JSON object to parse
  18100. * @param scene The scene to create the shadow map for
  18101. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18102. * @returns The parsed shadow generator
  18103. */
  18104. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18105. }
  18106. }
  18107. declare module BABYLON {
  18108. /**
  18109. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18110. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18111. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  18112. */
  18113. export abstract class Light extends Node {
  18114. /**
  18115. * Falloff Default: light is falling off following the material specification:
  18116. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18117. */
  18118. static readonly FALLOFF_DEFAULT: number;
  18119. /**
  18120. * Falloff Physical: light is falling off following the inverse squared distance law.
  18121. */
  18122. static readonly FALLOFF_PHYSICAL: number;
  18123. /**
  18124. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18125. * to enhance interoperability with other engines.
  18126. */
  18127. static readonly FALLOFF_GLTF: number;
  18128. /**
  18129. * Falloff Standard: light is falling off like in the standard material
  18130. * to enhance interoperability with other materials.
  18131. */
  18132. static readonly FALLOFF_STANDARD: number;
  18133. /**
  18134. * If every light affecting the material is in this lightmapMode,
  18135. * material.lightmapTexture adds or multiplies
  18136. * (depends on material.useLightmapAsShadowmap)
  18137. * after every other light calculations.
  18138. */
  18139. static readonly LIGHTMAP_DEFAULT: number;
  18140. /**
  18141. * material.lightmapTexture as only diffuse lighting from this light
  18142. * adds only specular lighting from this light
  18143. * adds dynamic shadows
  18144. */
  18145. static readonly LIGHTMAP_SPECULAR: number;
  18146. /**
  18147. * material.lightmapTexture as only lighting
  18148. * no light calculation from this light
  18149. * only adds dynamic shadows from this light
  18150. */
  18151. static readonly LIGHTMAP_SHADOWSONLY: number;
  18152. /**
  18153. * Each light type uses the default quantity according to its type:
  18154. * point/spot lights use luminous intensity
  18155. * directional lights use illuminance
  18156. */
  18157. static readonly INTENSITYMODE_AUTOMATIC: number;
  18158. /**
  18159. * lumen (lm)
  18160. */
  18161. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18162. /**
  18163. * candela (lm/sr)
  18164. */
  18165. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18166. /**
  18167. * lux (lm/m^2)
  18168. */
  18169. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18170. /**
  18171. * nit (cd/m^2)
  18172. */
  18173. static readonly INTENSITYMODE_LUMINANCE: number;
  18174. /**
  18175. * Light type const id of the point light.
  18176. */
  18177. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18178. /**
  18179. * Light type const id of the directional light.
  18180. */
  18181. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18182. /**
  18183. * Light type const id of the spot light.
  18184. */
  18185. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18186. /**
  18187. * Light type const id of the hemispheric light.
  18188. */
  18189. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18190. /**
  18191. * Diffuse gives the basic color to an object.
  18192. */
  18193. diffuse: Color3;
  18194. /**
  18195. * Specular produces a highlight color on an object.
  18196. * Note: This is note affecting PBR materials.
  18197. */
  18198. specular: Color3;
  18199. /**
  18200. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18201. * falling off base on range or angle.
  18202. * This can be set to any values in Light.FALLOFF_x.
  18203. *
  18204. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18205. * other types of materials.
  18206. */
  18207. falloffType: number;
  18208. /**
  18209. * Strength of the light.
  18210. * Note: By default it is define in the framework own unit.
  18211. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18212. */
  18213. intensity: number;
  18214. private _range;
  18215. protected _inverseSquaredRange: number;
  18216. /**
  18217. * Defines how far from the source the light is impacting in scene units.
  18218. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18219. */
  18220. get range(): number;
  18221. /**
  18222. * Defines how far from the source the light is impacting in scene units.
  18223. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18224. */
  18225. set range(value: number);
  18226. /**
  18227. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18228. * of light.
  18229. */
  18230. private _photometricScale;
  18231. private _intensityMode;
  18232. /**
  18233. * Gets the photometric scale used to interpret the intensity.
  18234. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18235. */
  18236. get intensityMode(): number;
  18237. /**
  18238. * Sets the photometric scale used to interpret the intensity.
  18239. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18240. */
  18241. set intensityMode(value: number);
  18242. private _radius;
  18243. /**
  18244. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18245. */
  18246. get radius(): number;
  18247. /**
  18248. * sets the light radius used by PBR Materials to simulate soft area lights.
  18249. */
  18250. set radius(value: number);
  18251. private _renderPriority;
  18252. /**
  18253. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18254. * exceeding the number allowed of the materials.
  18255. */
  18256. renderPriority: number;
  18257. private _shadowEnabled;
  18258. /**
  18259. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18260. * the current shadow generator.
  18261. */
  18262. get shadowEnabled(): boolean;
  18263. /**
  18264. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18265. * the current shadow generator.
  18266. */
  18267. set shadowEnabled(value: boolean);
  18268. private _includedOnlyMeshes;
  18269. /**
  18270. * Gets the only meshes impacted by this light.
  18271. */
  18272. get includedOnlyMeshes(): AbstractMesh[];
  18273. /**
  18274. * Sets the only meshes impacted by this light.
  18275. */
  18276. set includedOnlyMeshes(value: AbstractMesh[]);
  18277. private _excludedMeshes;
  18278. /**
  18279. * Gets the meshes not impacted by this light.
  18280. */
  18281. get excludedMeshes(): AbstractMesh[];
  18282. /**
  18283. * Sets the meshes not impacted by this light.
  18284. */
  18285. set excludedMeshes(value: AbstractMesh[]);
  18286. private _excludeWithLayerMask;
  18287. /**
  18288. * Gets the layer id use to find what meshes are not impacted by the light.
  18289. * Inactive if 0
  18290. */
  18291. get excludeWithLayerMask(): number;
  18292. /**
  18293. * Sets the layer id use to find what meshes are not impacted by the light.
  18294. * Inactive if 0
  18295. */
  18296. set excludeWithLayerMask(value: number);
  18297. private _includeOnlyWithLayerMask;
  18298. /**
  18299. * Gets the layer id use to find what meshes are impacted by the light.
  18300. * Inactive if 0
  18301. */
  18302. get includeOnlyWithLayerMask(): number;
  18303. /**
  18304. * Sets the layer id use to find what meshes are impacted by the light.
  18305. * Inactive if 0
  18306. */
  18307. set includeOnlyWithLayerMask(value: number);
  18308. private _lightmapMode;
  18309. /**
  18310. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18311. */
  18312. get lightmapMode(): number;
  18313. /**
  18314. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18315. */
  18316. set lightmapMode(value: number);
  18317. /**
  18318. * Shadow generator associted to the light.
  18319. * @hidden Internal use only.
  18320. */
  18321. _shadowGenerator: Nullable<IShadowGenerator>;
  18322. /**
  18323. * @hidden Internal use only.
  18324. */
  18325. _excludedMeshesIds: string[];
  18326. /**
  18327. * @hidden Internal use only.
  18328. */
  18329. _includedOnlyMeshesIds: string[];
  18330. /**
  18331. * The current light unifom buffer.
  18332. * @hidden Internal use only.
  18333. */
  18334. _uniformBuffer: UniformBuffer;
  18335. /** @hidden */
  18336. _renderId: number;
  18337. /**
  18338. * Creates a Light object in the scene.
  18339. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18340. * @param name The firendly name of the light
  18341. * @param scene The scene the light belongs too
  18342. */
  18343. constructor(name: string, scene: Scene);
  18344. protected abstract _buildUniformLayout(): void;
  18345. /**
  18346. * Sets the passed Effect "effect" with the Light information.
  18347. * @param effect The effect to update
  18348. * @param lightIndex The index of the light in the effect to update
  18349. * @returns The light
  18350. */
  18351. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18352. /**
  18353. * Sets the passed Effect "effect" with the Light textures.
  18354. * @param effect The effect to update
  18355. * @param lightIndex The index of the light in the effect to update
  18356. * @returns The light
  18357. */
  18358. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18359. /**
  18360. * Binds the lights information from the scene to the effect for the given mesh.
  18361. * @param lightIndex Light index
  18362. * @param scene The scene where the light belongs to
  18363. * @param effect The effect we are binding the data to
  18364. * @param useSpecular Defines if specular is supported
  18365. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18366. */
  18367. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18368. /**
  18369. * Sets the passed Effect "effect" with the Light information.
  18370. * @param effect The effect to update
  18371. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18372. * @returns The light
  18373. */
  18374. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18375. /**
  18376. * Returns the string "Light".
  18377. * @returns the class name
  18378. */
  18379. getClassName(): string;
  18380. /** @hidden */
  18381. readonly _isLight: boolean;
  18382. /**
  18383. * Converts the light information to a readable string for debug purpose.
  18384. * @param fullDetails Supports for multiple levels of logging within scene loading
  18385. * @returns the human readable light info
  18386. */
  18387. toString(fullDetails?: boolean): string;
  18388. /** @hidden */
  18389. protected _syncParentEnabledState(): void;
  18390. /**
  18391. * Set the enabled state of this node.
  18392. * @param value - the new enabled state
  18393. */
  18394. setEnabled(value: boolean): void;
  18395. /**
  18396. * Returns the Light associated shadow generator if any.
  18397. * @return the associated shadow generator.
  18398. */
  18399. getShadowGenerator(): Nullable<IShadowGenerator>;
  18400. /**
  18401. * Returns a Vector3, the absolute light position in the World.
  18402. * @returns the world space position of the light
  18403. */
  18404. getAbsolutePosition(): Vector3;
  18405. /**
  18406. * Specifies if the light will affect the passed mesh.
  18407. * @param mesh The mesh to test against the light
  18408. * @return true the mesh is affected otherwise, false.
  18409. */
  18410. canAffectMesh(mesh: AbstractMesh): boolean;
  18411. /**
  18412. * Sort function to order lights for rendering.
  18413. * @param a First Light object to compare to second.
  18414. * @param b Second Light object to compare first.
  18415. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18416. */
  18417. static CompareLightsPriority(a: Light, b: Light): number;
  18418. /**
  18419. * Releases resources associated with this node.
  18420. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18421. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18422. */
  18423. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18424. /**
  18425. * Returns the light type ID (integer).
  18426. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18427. */
  18428. getTypeID(): number;
  18429. /**
  18430. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18431. * @returns the scaled intensity in intensity mode unit
  18432. */
  18433. getScaledIntensity(): number;
  18434. /**
  18435. * Returns a new Light object, named "name", from the current one.
  18436. * @param name The name of the cloned light
  18437. * @param newParent The parent of this light, if it has one
  18438. * @returns the new created light
  18439. */
  18440. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18441. /**
  18442. * Serializes the current light into a Serialization object.
  18443. * @returns the serialized object.
  18444. */
  18445. serialize(): any;
  18446. /**
  18447. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18448. * This new light is named "name" and added to the passed scene.
  18449. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18450. * @param name The friendly name of the light
  18451. * @param scene The scene the new light will belong to
  18452. * @returns the constructor function
  18453. */
  18454. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18455. /**
  18456. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18457. * @param parsedLight The JSON representation of the light
  18458. * @param scene The scene to create the parsed light in
  18459. * @returns the created light after parsing
  18460. */
  18461. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18462. private _hookArrayForExcluded;
  18463. private _hookArrayForIncludedOnly;
  18464. private _resyncMeshes;
  18465. /**
  18466. * Forces the meshes to update their light related information in their rendering used effects
  18467. * @hidden Internal Use Only
  18468. */
  18469. _markMeshesAsLightDirty(): void;
  18470. /**
  18471. * Recomputes the cached photometric scale if needed.
  18472. */
  18473. private _computePhotometricScale;
  18474. /**
  18475. * Returns the Photometric Scale according to the light type and intensity mode.
  18476. */
  18477. private _getPhotometricScale;
  18478. /**
  18479. * Reorder the light in the scene according to their defined priority.
  18480. * @hidden Internal Use Only
  18481. */
  18482. _reorderLightsInScene(): void;
  18483. /**
  18484. * Prepares the list of defines specific to the light type.
  18485. * @param defines the list of defines
  18486. * @param lightIndex defines the index of the light for the effect
  18487. */
  18488. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18489. }
  18490. }
  18491. declare module BABYLON {
  18492. /**
  18493. * Configuration needed for prepass-capable materials
  18494. */
  18495. export class PrePassConfiguration {
  18496. /**
  18497. * Previous world matrices of meshes carrying this material
  18498. * Used for computing velocity
  18499. */
  18500. previousWorldMatrices: {
  18501. [index: number]: Matrix;
  18502. };
  18503. /**
  18504. * Previous view project matrix
  18505. * Used for computing velocity
  18506. */
  18507. previousViewProjection: Matrix;
  18508. /**
  18509. * Previous bones of meshes carrying this material
  18510. * Used for computing velocity
  18511. */
  18512. previousBones: {
  18513. [index: number]: Float32Array;
  18514. };
  18515. /**
  18516. * Add the required uniforms to the current list.
  18517. * @param uniforms defines the current uniform list.
  18518. */
  18519. static AddUniforms(uniforms: string[]): void;
  18520. /**
  18521. * Add the required samplers to the current list.
  18522. * @param samplers defines the current sampler list.
  18523. */
  18524. static AddSamplers(samplers: string[]): void;
  18525. /**
  18526. * Binds the material data.
  18527. * @param effect defines the effect to update
  18528. * @param scene defines the scene the material belongs to.
  18529. * @param mesh The mesh
  18530. * @param world World matrix of this mesh
  18531. * @param isFrozen Is the material frozen
  18532. */
  18533. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  18534. }
  18535. }
  18536. declare module BABYLON {
  18537. /**
  18538. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18539. * This is the base of the follow, arc rotate cameras and Free camera
  18540. * @see https://doc.babylonjs.com/features/cameras
  18541. */
  18542. export class TargetCamera extends Camera {
  18543. private static _RigCamTransformMatrix;
  18544. private static _TargetTransformMatrix;
  18545. private static _TargetFocalPoint;
  18546. private _tmpUpVector;
  18547. private _tmpTargetVector;
  18548. /**
  18549. * Define the current direction the camera is moving to
  18550. */
  18551. cameraDirection: Vector3;
  18552. /**
  18553. * Define the current rotation the camera is rotating to
  18554. */
  18555. cameraRotation: Vector2;
  18556. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18557. ignoreParentScaling: boolean;
  18558. /**
  18559. * When set, the up vector of the camera will be updated by the rotation of the camera
  18560. */
  18561. updateUpVectorFromRotation: boolean;
  18562. private _tmpQuaternion;
  18563. /**
  18564. * Define the current rotation of the camera
  18565. */
  18566. rotation: Vector3;
  18567. /**
  18568. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18569. */
  18570. rotationQuaternion: Quaternion;
  18571. /**
  18572. * Define the current speed of the camera
  18573. */
  18574. speed: number;
  18575. /**
  18576. * Add constraint to the camera to prevent it to move freely in all directions and
  18577. * around all axis.
  18578. */
  18579. noRotationConstraint: boolean;
  18580. /**
  18581. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18582. * panning
  18583. */
  18584. invertRotation: boolean;
  18585. /**
  18586. * Speed multiplier for inverse camera panning
  18587. */
  18588. inverseRotationSpeed: number;
  18589. /**
  18590. * Define the current target of the camera as an object or a position.
  18591. */
  18592. lockedTarget: any;
  18593. /** @hidden */
  18594. _currentTarget: Vector3;
  18595. /** @hidden */
  18596. _initialFocalDistance: number;
  18597. /** @hidden */
  18598. _viewMatrix: Matrix;
  18599. /** @hidden */
  18600. _camMatrix: Matrix;
  18601. /** @hidden */
  18602. _cameraTransformMatrix: Matrix;
  18603. /** @hidden */
  18604. _cameraRotationMatrix: Matrix;
  18605. /** @hidden */
  18606. _referencePoint: Vector3;
  18607. /** @hidden */
  18608. _transformedReferencePoint: Vector3;
  18609. /** @hidden */
  18610. _reset: () => void;
  18611. private _defaultUp;
  18612. /**
  18613. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18614. * This is the base of the follow, arc rotate cameras and Free camera
  18615. * @see https://doc.babylonjs.com/features/cameras
  18616. * @param name Defines the name of the camera in the scene
  18617. * @param position Defines the start position of the camera in the scene
  18618. * @param scene Defines the scene the camera belongs to
  18619. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18620. */
  18621. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18622. /**
  18623. * Gets the position in front of the camera at a given distance.
  18624. * @param distance The distance from the camera we want the position to be
  18625. * @returns the position
  18626. */
  18627. getFrontPosition(distance: number): Vector3;
  18628. /** @hidden */
  18629. _getLockedTargetPosition(): Nullable<Vector3>;
  18630. private _storedPosition;
  18631. private _storedRotation;
  18632. private _storedRotationQuaternion;
  18633. /**
  18634. * Store current camera state of the camera (fov, position, rotation, etc..)
  18635. * @returns the camera
  18636. */
  18637. storeState(): Camera;
  18638. /**
  18639. * Restored camera state. You must call storeState() first
  18640. * @returns whether it was successful or not
  18641. * @hidden
  18642. */
  18643. _restoreStateValues(): boolean;
  18644. /** @hidden */
  18645. _initCache(): void;
  18646. /** @hidden */
  18647. _updateCache(ignoreParentClass?: boolean): void;
  18648. /** @hidden */
  18649. _isSynchronizedViewMatrix(): boolean;
  18650. /** @hidden */
  18651. _computeLocalCameraSpeed(): number;
  18652. /**
  18653. * Defines the target the camera should look at.
  18654. * @param target Defines the new target as a Vector or a mesh
  18655. */
  18656. setTarget(target: Vector3): void;
  18657. /**
  18658. * Defines the target point of the camera.
  18659. * The camera looks towards it form the radius distance.
  18660. */
  18661. get target(): Vector3;
  18662. set target(value: Vector3);
  18663. /**
  18664. * Return the current target position of the camera. This value is expressed in local space.
  18665. * @returns the target position
  18666. */
  18667. getTarget(): Vector3;
  18668. /** @hidden */
  18669. _decideIfNeedsToMove(): boolean;
  18670. /** @hidden */
  18671. _updatePosition(): void;
  18672. /** @hidden */
  18673. _checkInputs(): void;
  18674. protected _updateCameraRotationMatrix(): void;
  18675. /**
  18676. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  18677. * @returns the current camera
  18678. */
  18679. private _rotateUpVectorWithCameraRotationMatrix;
  18680. private _cachedRotationZ;
  18681. private _cachedQuaternionRotationZ;
  18682. /** @hidden */
  18683. _getViewMatrix(): Matrix;
  18684. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18685. /**
  18686. * @hidden
  18687. */
  18688. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18689. /**
  18690. * @hidden
  18691. */
  18692. _updateRigCameras(): void;
  18693. private _getRigCamPositionAndTarget;
  18694. /**
  18695. * Gets the current object class name.
  18696. * @return the class name
  18697. */
  18698. getClassName(): string;
  18699. }
  18700. }
  18701. declare module BABYLON {
  18702. /**
  18703. * Gather the list of keyboard event types as constants.
  18704. */
  18705. export class KeyboardEventTypes {
  18706. /**
  18707. * The keydown event is fired when a key becomes active (pressed).
  18708. */
  18709. static readonly KEYDOWN: number;
  18710. /**
  18711. * The keyup event is fired when a key has been released.
  18712. */
  18713. static readonly KEYUP: number;
  18714. }
  18715. /**
  18716. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18717. */
  18718. export class KeyboardInfo {
  18719. /**
  18720. * Defines the type of event (KeyboardEventTypes)
  18721. */
  18722. type: number;
  18723. /**
  18724. * Defines the related dom event
  18725. */
  18726. event: KeyboardEvent;
  18727. /**
  18728. * Instantiates a new keyboard info.
  18729. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18730. * @param type Defines the type of event (KeyboardEventTypes)
  18731. * @param event Defines the related dom event
  18732. */
  18733. constructor(
  18734. /**
  18735. * Defines the type of event (KeyboardEventTypes)
  18736. */
  18737. type: number,
  18738. /**
  18739. * Defines the related dom event
  18740. */
  18741. event: KeyboardEvent);
  18742. }
  18743. /**
  18744. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18745. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18746. */
  18747. export class KeyboardInfoPre extends KeyboardInfo {
  18748. /**
  18749. * Defines the type of event (KeyboardEventTypes)
  18750. */
  18751. type: number;
  18752. /**
  18753. * Defines the related dom event
  18754. */
  18755. event: KeyboardEvent;
  18756. /**
  18757. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18758. */
  18759. skipOnPointerObservable: boolean;
  18760. /**
  18761. * Instantiates a new keyboard pre info.
  18762. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18763. * @param type Defines the type of event (KeyboardEventTypes)
  18764. * @param event Defines the related dom event
  18765. */
  18766. constructor(
  18767. /**
  18768. * Defines the type of event (KeyboardEventTypes)
  18769. */
  18770. type: number,
  18771. /**
  18772. * Defines the related dom event
  18773. */
  18774. event: KeyboardEvent);
  18775. }
  18776. }
  18777. declare module BABYLON {
  18778. /**
  18779. * Manage the keyboard inputs to control the movement of a free camera.
  18780. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18781. */
  18782. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18783. /**
  18784. * Defines the camera the input is attached to.
  18785. */
  18786. camera: FreeCamera;
  18787. /**
  18788. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18789. */
  18790. keysUp: number[];
  18791. /**
  18792. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18793. */
  18794. keysUpward: number[];
  18795. /**
  18796. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18797. */
  18798. keysDown: number[];
  18799. /**
  18800. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18801. */
  18802. keysDownward: number[];
  18803. /**
  18804. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18805. */
  18806. keysLeft: number[];
  18807. /**
  18808. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18809. */
  18810. keysRight: number[];
  18811. private _keys;
  18812. private _onCanvasBlurObserver;
  18813. private _onKeyboardObserver;
  18814. private _engine;
  18815. private _scene;
  18816. /**
  18817. * Attach the input controls to a specific dom element to get the input from.
  18818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18819. */
  18820. attachControl(noPreventDefault?: boolean): void;
  18821. /**
  18822. * Detach the current controls from the specified dom element.
  18823. */
  18824. detachControl(): void;
  18825. /**
  18826. * Update the current camera state depending on the inputs that have been used this frame.
  18827. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18828. */
  18829. checkInputs(): void;
  18830. /**
  18831. * Gets the class name of the current intput.
  18832. * @returns the class name
  18833. */
  18834. getClassName(): string;
  18835. /** @hidden */
  18836. _onLostFocus(): void;
  18837. /**
  18838. * Get the friendly name associated with the input class.
  18839. * @returns the input friendly name
  18840. */
  18841. getSimpleName(): string;
  18842. }
  18843. }
  18844. declare module BABYLON {
  18845. /**
  18846. * Gather the list of pointer event types as constants.
  18847. */
  18848. export class PointerEventTypes {
  18849. /**
  18850. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  18851. */
  18852. static readonly POINTERDOWN: number;
  18853. /**
  18854. * The pointerup event is fired when a pointer is no longer active.
  18855. */
  18856. static readonly POINTERUP: number;
  18857. /**
  18858. * The pointermove event is fired when a pointer changes coordinates.
  18859. */
  18860. static readonly POINTERMOVE: number;
  18861. /**
  18862. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18863. */
  18864. static readonly POINTERWHEEL: number;
  18865. /**
  18866. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18867. */
  18868. static readonly POINTERPICK: number;
  18869. /**
  18870. * The pointertap event is fired when a the object has been touched and released without drag.
  18871. */
  18872. static readonly POINTERTAP: number;
  18873. /**
  18874. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18875. */
  18876. static readonly POINTERDOUBLETAP: number;
  18877. }
  18878. /**
  18879. * Base class of pointer info types.
  18880. */
  18881. export class PointerInfoBase {
  18882. /**
  18883. * Defines the type of event (PointerEventTypes)
  18884. */
  18885. type: number;
  18886. /**
  18887. * Defines the related dom event
  18888. */
  18889. event: PointerEvent | MouseWheelEvent;
  18890. /**
  18891. * Instantiates the base class of pointers info.
  18892. * @param type Defines the type of event (PointerEventTypes)
  18893. * @param event Defines the related dom event
  18894. */
  18895. constructor(
  18896. /**
  18897. * Defines the type of event (PointerEventTypes)
  18898. */
  18899. type: number,
  18900. /**
  18901. * Defines the related dom event
  18902. */
  18903. event: PointerEvent | MouseWheelEvent);
  18904. }
  18905. /**
  18906. * This class is used to store pointer related info for the onPrePointerObservable event.
  18907. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18908. */
  18909. export class PointerInfoPre extends PointerInfoBase {
  18910. /**
  18911. * Ray from a pointer if availible (eg. 6dof controller)
  18912. */
  18913. ray: Nullable<Ray>;
  18914. /**
  18915. * Defines the local position of the pointer on the canvas.
  18916. */
  18917. localPosition: Vector2;
  18918. /**
  18919. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18920. */
  18921. skipOnPointerObservable: boolean;
  18922. /**
  18923. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18924. * @param type Defines the type of event (PointerEventTypes)
  18925. * @param event Defines the related dom event
  18926. * @param localX Defines the local x coordinates of the pointer when the event occured
  18927. * @param localY Defines the local y coordinates of the pointer when the event occured
  18928. */
  18929. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18930. }
  18931. /**
  18932. * This type contains all the data related to a pointer event in Babylon.js.
  18933. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  18934. */
  18935. export class PointerInfo extends PointerInfoBase {
  18936. /**
  18937. * Defines the picking info associated to the info (if any)\
  18938. */
  18939. pickInfo: Nullable<PickingInfo>;
  18940. /**
  18941. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18942. * @param type Defines the type of event (PointerEventTypes)
  18943. * @param event Defines the related dom event
  18944. * @param pickInfo Defines the picking info associated to the info (if any)\
  18945. */
  18946. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18947. /**
  18948. * Defines the picking info associated to the info (if any)\
  18949. */
  18950. pickInfo: Nullable<PickingInfo>);
  18951. }
  18952. /**
  18953. * Data relating to a touch event on the screen.
  18954. */
  18955. export interface PointerTouch {
  18956. /**
  18957. * X coordinate of touch.
  18958. */
  18959. x: number;
  18960. /**
  18961. * Y coordinate of touch.
  18962. */
  18963. y: number;
  18964. /**
  18965. * Id of touch. Unique for each finger.
  18966. */
  18967. pointerId: number;
  18968. /**
  18969. * Event type passed from DOM.
  18970. */
  18971. type: any;
  18972. }
  18973. }
  18974. declare module BABYLON {
  18975. /**
  18976. * Manage the mouse inputs to control the movement of a free camera.
  18977. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18978. */
  18979. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18980. /**
  18981. * Define if touch is enabled in the mouse input
  18982. */
  18983. touchEnabled: boolean;
  18984. /**
  18985. * Defines the camera the input is attached to.
  18986. */
  18987. camera: FreeCamera;
  18988. /**
  18989. * Defines the buttons associated with the input to handle camera move.
  18990. */
  18991. buttons: number[];
  18992. /**
  18993. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18994. */
  18995. angularSensibility: number;
  18996. private _pointerInput;
  18997. private _onMouseMove;
  18998. private _observer;
  18999. private previousPosition;
  19000. /**
  19001. * Observable for when a pointer move event occurs containing the move offset
  19002. */
  19003. onPointerMovedObservable: Observable<{
  19004. offsetX: number;
  19005. offsetY: number;
  19006. }>;
  19007. /**
  19008. * @hidden
  19009. * If the camera should be rotated automatically based on pointer movement
  19010. */
  19011. _allowCameraRotation: boolean;
  19012. /**
  19013. * Manage the mouse inputs to control the movement of a free camera.
  19014. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19015. * @param touchEnabled Defines if touch is enabled or not
  19016. */
  19017. constructor(
  19018. /**
  19019. * Define if touch is enabled in the mouse input
  19020. */
  19021. touchEnabled?: boolean);
  19022. /**
  19023. * Attach the input controls to a specific dom element to get the input from.
  19024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19025. */
  19026. attachControl(noPreventDefault?: boolean): void;
  19027. /**
  19028. * Called on JS contextmenu event.
  19029. * Override this method to provide functionality.
  19030. */
  19031. protected onContextMenu(evt: PointerEvent): void;
  19032. /**
  19033. * Detach the current controls from the specified dom element.
  19034. */
  19035. detachControl(): void;
  19036. /**
  19037. * Gets the class name of the current intput.
  19038. * @returns the class name
  19039. */
  19040. getClassName(): string;
  19041. /**
  19042. * Get the friendly name associated with the input class.
  19043. * @returns the input friendly name
  19044. */
  19045. getSimpleName(): string;
  19046. }
  19047. }
  19048. declare module BABYLON {
  19049. /**
  19050. * Base class for mouse wheel input..
  19051. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  19052. * for example usage.
  19053. */
  19054. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  19055. /**
  19056. * Defines the camera the input is attached to.
  19057. */
  19058. abstract camera: Camera;
  19059. /**
  19060. * How fast is the camera moves in relation to X axis mouseWheel events.
  19061. * Use negative value to reverse direction.
  19062. */
  19063. wheelPrecisionX: number;
  19064. /**
  19065. * How fast is the camera moves in relation to Y axis mouseWheel events.
  19066. * Use negative value to reverse direction.
  19067. */
  19068. wheelPrecisionY: number;
  19069. /**
  19070. * How fast is the camera moves in relation to Z axis mouseWheel events.
  19071. * Use negative value to reverse direction.
  19072. */
  19073. wheelPrecisionZ: number;
  19074. /**
  19075. * Observable for when a mouse wheel move event occurs.
  19076. */
  19077. onChangedObservable: Observable<{
  19078. wheelDeltaX: number;
  19079. wheelDeltaY: number;
  19080. wheelDeltaZ: number;
  19081. }>;
  19082. private _wheel;
  19083. private _observer;
  19084. /**
  19085. * Attach the input controls to a specific dom element to get the input from.
  19086. * @param noPreventDefault Defines whether event caught by the controls
  19087. * should call preventdefault().
  19088. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19089. */
  19090. attachControl(noPreventDefault?: boolean): void;
  19091. /**
  19092. * Detach the current controls from the specified dom element.
  19093. */
  19094. detachControl(): void;
  19095. /**
  19096. * Called for each rendered frame.
  19097. */
  19098. checkInputs(): void;
  19099. /**
  19100. * Gets the class name of the current intput.
  19101. * @returns the class name
  19102. */
  19103. getClassName(): string;
  19104. /**
  19105. * Get the friendly name associated with the input class.
  19106. * @returns the input friendly name
  19107. */
  19108. getSimpleName(): string;
  19109. /**
  19110. * Incremental value of multiple mouse wheel movements of the X axis.
  19111. * Should be zero-ed when read.
  19112. */
  19113. protected _wheelDeltaX: number;
  19114. /**
  19115. * Incremental value of multiple mouse wheel movements of the Y axis.
  19116. * Should be zero-ed when read.
  19117. */
  19118. protected _wheelDeltaY: number;
  19119. /**
  19120. * Incremental value of multiple mouse wheel movements of the Z axis.
  19121. * Should be zero-ed when read.
  19122. */
  19123. protected _wheelDeltaZ: number;
  19124. /**
  19125. * Firefox uses a different scheme to report scroll distances to other
  19126. * browsers. Rather than use complicated methods to calculate the exact
  19127. * multiple we need to apply, let's just cheat and use a constant.
  19128. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  19129. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  19130. */
  19131. private readonly _ffMultiplier;
  19132. /**
  19133. * Different event attributes for wheel data fall into a few set ranges.
  19134. * Some relevant but dated date here:
  19135. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  19136. */
  19137. private readonly _normalize;
  19138. }
  19139. }
  19140. declare module BABYLON {
  19141. /**
  19142. * Manage the mouse wheel inputs to control a free camera.
  19143. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19144. */
  19145. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  19146. /**
  19147. * Defines the camera the input is attached to.
  19148. */
  19149. camera: FreeCamera;
  19150. /**
  19151. * Gets the class name of the current input.
  19152. * @returns the class name
  19153. */
  19154. getClassName(): string;
  19155. /**
  19156. * Set which movement axis (relative to camera's orientation) the mouse
  19157. * wheel's X axis controls.
  19158. * @param axis The axis to be moved. Set null to clear.
  19159. */
  19160. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  19161. /**
  19162. * Get the configured movement axis (relative to camera's orientation) the
  19163. * mouse wheel's X axis controls.
  19164. * @returns The configured axis or null if none.
  19165. */
  19166. get wheelXMoveRelative(): Nullable<Coordinate>;
  19167. /**
  19168. * Set which movement axis (relative to camera's orientation) the mouse
  19169. * wheel's Y axis controls.
  19170. * @param axis The axis to be moved. Set null to clear.
  19171. */
  19172. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  19173. /**
  19174. * Get the configured movement axis (relative to camera's orientation) the
  19175. * mouse wheel's Y axis controls.
  19176. * @returns The configured axis or null if none.
  19177. */
  19178. get wheelYMoveRelative(): Nullable<Coordinate>;
  19179. /**
  19180. * Set which movement axis (relative to camera's orientation) the mouse
  19181. * wheel's Z axis controls.
  19182. * @param axis The axis to be moved. Set null to clear.
  19183. */
  19184. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  19185. /**
  19186. * Get the configured movement axis (relative to camera's orientation) the
  19187. * mouse wheel's Z axis controls.
  19188. * @returns The configured axis or null if none.
  19189. */
  19190. get wheelZMoveRelative(): Nullable<Coordinate>;
  19191. /**
  19192. * Set which rotation axis (relative to camera's orientation) the mouse
  19193. * wheel's X axis controls.
  19194. * @param axis The axis to be moved. Set null to clear.
  19195. */
  19196. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  19197. /**
  19198. * Get the configured rotation axis (relative to camera's orientation) the
  19199. * mouse wheel's X axis controls.
  19200. * @returns The configured axis or null if none.
  19201. */
  19202. get wheelXRotateRelative(): Nullable<Coordinate>;
  19203. /**
  19204. * Set which rotation axis (relative to camera's orientation) the mouse
  19205. * wheel's Y axis controls.
  19206. * @param axis The axis to be moved. Set null to clear.
  19207. */
  19208. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  19209. /**
  19210. * Get the configured rotation axis (relative to camera's orientation) the
  19211. * mouse wheel's Y axis controls.
  19212. * @returns The configured axis or null if none.
  19213. */
  19214. get wheelYRotateRelative(): Nullable<Coordinate>;
  19215. /**
  19216. * Set which rotation axis (relative to camera's orientation) the mouse
  19217. * wheel's Z axis controls.
  19218. * @param axis The axis to be moved. Set null to clear.
  19219. */
  19220. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  19221. /**
  19222. * Get the configured rotation axis (relative to camera's orientation) the
  19223. * mouse wheel's Z axis controls.
  19224. * @returns The configured axis or null if none.
  19225. */
  19226. get wheelZRotateRelative(): Nullable<Coordinate>;
  19227. /**
  19228. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  19229. * controls.
  19230. * @param axis The axis to be moved. Set null to clear.
  19231. */
  19232. set wheelXMoveScene(axis: Nullable<Coordinate>);
  19233. /**
  19234. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19235. * X axis controls.
  19236. * @returns The configured axis or null if none.
  19237. */
  19238. get wheelXMoveScene(): Nullable<Coordinate>;
  19239. /**
  19240. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  19241. * controls.
  19242. * @param axis The axis to be moved. Set null to clear.
  19243. */
  19244. set wheelYMoveScene(axis: Nullable<Coordinate>);
  19245. /**
  19246. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19247. * Y axis controls.
  19248. * @returns The configured axis or null if none.
  19249. */
  19250. get wheelYMoveScene(): Nullable<Coordinate>;
  19251. /**
  19252. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  19253. * controls.
  19254. * @param axis The axis to be moved. Set null to clear.
  19255. */
  19256. set wheelZMoveScene(axis: Nullable<Coordinate>);
  19257. /**
  19258. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19259. * Z axis controls.
  19260. * @returns The configured axis or null if none.
  19261. */
  19262. get wheelZMoveScene(): Nullable<Coordinate>;
  19263. /**
  19264. * Called for each rendered frame.
  19265. */
  19266. checkInputs(): void;
  19267. private _moveRelative;
  19268. private _rotateRelative;
  19269. private _moveScene;
  19270. /**
  19271. * These are set to the desired default behaviour.
  19272. */
  19273. private _wheelXAction;
  19274. private _wheelXActionCoordinate;
  19275. private _wheelYAction;
  19276. private _wheelYActionCoordinate;
  19277. private _wheelZAction;
  19278. private _wheelZActionCoordinate;
  19279. /**
  19280. * Update the camera according to any configured properties for the 3
  19281. * mouse-wheel axis.
  19282. */
  19283. private _updateCamera;
  19284. }
  19285. }
  19286. declare module BABYLON {
  19287. /**
  19288. * Manage the touch inputs to control the movement of a free camera.
  19289. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19290. */
  19291. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19292. /**
  19293. * Define if mouse events can be treated as touch events
  19294. */
  19295. allowMouse: boolean;
  19296. /**
  19297. * Defines the camera the input is attached to.
  19298. */
  19299. camera: FreeCamera;
  19300. /**
  19301. * Defines the touch sensibility for rotation.
  19302. * The higher the faster.
  19303. */
  19304. touchAngularSensibility: number;
  19305. /**
  19306. * Defines the touch sensibility for move.
  19307. * The higher the faster.
  19308. */
  19309. touchMoveSensibility: number;
  19310. private _offsetX;
  19311. private _offsetY;
  19312. private _pointerPressed;
  19313. private _pointerInput?;
  19314. private _observer;
  19315. private _onLostFocus;
  19316. /**
  19317. * Manage the touch inputs to control the movement of a free camera.
  19318. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19319. * @param allowMouse Defines if mouse events can be treated as touch events
  19320. */
  19321. constructor(
  19322. /**
  19323. * Define if mouse events can be treated as touch events
  19324. */
  19325. allowMouse?: boolean);
  19326. /**
  19327. * Attach the input controls to a specific dom element to get the input from.
  19328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19329. */
  19330. attachControl(noPreventDefault?: boolean): void;
  19331. /**
  19332. * Detach the current controls from the specified dom element.
  19333. * @param element Defines the element to stop listening the inputs from
  19334. */
  19335. detachControl(): void;
  19336. /**
  19337. * Update the current camera state depending on the inputs that have been used this frame.
  19338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19339. */
  19340. checkInputs(): void;
  19341. /**
  19342. * Gets the class name of the current intput.
  19343. * @returns the class name
  19344. */
  19345. getClassName(): string;
  19346. /**
  19347. * Get the friendly name associated with the input class.
  19348. * @returns the input friendly name
  19349. */
  19350. getSimpleName(): string;
  19351. }
  19352. }
  19353. declare module BABYLON {
  19354. /**
  19355. * Default Inputs manager for the FreeCamera.
  19356. * It groups all the default supported inputs for ease of use.
  19357. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19358. */
  19359. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19360. /**
  19361. * @hidden
  19362. */
  19363. _mouseInput: Nullable<FreeCameraMouseInput>;
  19364. /**
  19365. * @hidden
  19366. */
  19367. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  19368. /**
  19369. * Instantiates a new FreeCameraInputsManager.
  19370. * @param camera Defines the camera the inputs belong to
  19371. */
  19372. constructor(camera: FreeCamera);
  19373. /**
  19374. * Add keyboard input support to the input manager.
  19375. * @returns the current input manager
  19376. */
  19377. addKeyboard(): FreeCameraInputsManager;
  19378. /**
  19379. * Add mouse input support to the input manager.
  19380. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19381. * @returns the current input manager
  19382. */
  19383. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19384. /**
  19385. * Removes the mouse input support from the manager
  19386. * @returns the current input manager
  19387. */
  19388. removeMouse(): FreeCameraInputsManager;
  19389. /**
  19390. * Add mouse wheel input support to the input manager.
  19391. * @returns the current input manager
  19392. */
  19393. addMouseWheel(): FreeCameraInputsManager;
  19394. /**
  19395. * Removes the mouse wheel input support from the manager
  19396. * @returns the current input manager
  19397. */
  19398. removeMouseWheel(): FreeCameraInputsManager;
  19399. /**
  19400. * Add touch input support to the input manager.
  19401. * @returns the current input manager
  19402. */
  19403. addTouch(): FreeCameraInputsManager;
  19404. /**
  19405. * Remove all attached input methods from a camera
  19406. */
  19407. clear(): void;
  19408. }
  19409. }
  19410. declare module BABYLON {
  19411. /**
  19412. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19413. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19414. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19415. */
  19416. export class FreeCamera extends TargetCamera {
  19417. /**
  19418. * Define the collision ellipsoid of the camera.
  19419. * This is helpful to simulate a camera body like the player body around the camera
  19420. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19421. */
  19422. ellipsoid: Vector3;
  19423. /**
  19424. * Define an offset for the position of the ellipsoid around the camera.
  19425. * This can be helpful to determine the center of the body near the gravity center of the body
  19426. * instead of its head.
  19427. */
  19428. ellipsoidOffset: Vector3;
  19429. /**
  19430. * Enable or disable collisions of the camera with the rest of the scene objects.
  19431. */
  19432. checkCollisions: boolean;
  19433. /**
  19434. * Enable or disable gravity on the camera.
  19435. */
  19436. applyGravity: boolean;
  19437. /**
  19438. * Define the input manager associated to the camera.
  19439. */
  19440. inputs: FreeCameraInputsManager;
  19441. /**
  19442. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19443. * Higher values reduce sensitivity.
  19444. */
  19445. get angularSensibility(): number;
  19446. /**
  19447. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19448. * Higher values reduce sensitivity.
  19449. */
  19450. set angularSensibility(value: number);
  19451. /**
  19452. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19453. */
  19454. get keysUp(): number[];
  19455. set keysUp(value: number[]);
  19456. /**
  19457. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19458. */
  19459. get keysUpward(): number[];
  19460. set keysUpward(value: number[]);
  19461. /**
  19462. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19463. */
  19464. get keysDown(): number[];
  19465. set keysDown(value: number[]);
  19466. /**
  19467. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19468. */
  19469. get keysDownward(): number[];
  19470. set keysDownward(value: number[]);
  19471. /**
  19472. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19473. */
  19474. get keysLeft(): number[];
  19475. set keysLeft(value: number[]);
  19476. /**
  19477. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19478. */
  19479. get keysRight(): number[];
  19480. set keysRight(value: number[]);
  19481. /**
  19482. * Event raised when the camera collide with a mesh in the scene.
  19483. */
  19484. onCollide: (collidedMesh: AbstractMesh) => void;
  19485. private _collider;
  19486. private _needMoveForGravity;
  19487. private _oldPosition;
  19488. private _diffPosition;
  19489. private _newPosition;
  19490. /** @hidden */
  19491. _localDirection: Vector3;
  19492. /** @hidden */
  19493. _transformedDirection: Vector3;
  19494. /**
  19495. * Instantiates a Free Camera.
  19496. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19497. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19498. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19499. * @param name Define the name of the camera in the scene
  19500. * @param position Define the start position of the camera in the scene
  19501. * @param scene Define the scene the camera belongs to
  19502. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19503. */
  19504. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19505. /**
  19506. * Attached controls to the current camera.
  19507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19508. */
  19509. attachControl(noPreventDefault?: boolean): void;
  19510. /**
  19511. * Detach the current controls from the camera.
  19512. * The camera will stop reacting to inputs.
  19513. */
  19514. detachControl(): void;
  19515. private _collisionMask;
  19516. /**
  19517. * Define a collision mask to limit the list of object the camera can collide with
  19518. */
  19519. get collisionMask(): number;
  19520. set collisionMask(mask: number);
  19521. /** @hidden */
  19522. _collideWithWorld(displacement: Vector3): void;
  19523. private _onCollisionPositionChange;
  19524. /** @hidden */
  19525. _checkInputs(): void;
  19526. /** @hidden */
  19527. _decideIfNeedsToMove(): boolean;
  19528. /** @hidden */
  19529. _updatePosition(): void;
  19530. /**
  19531. * Destroy the camera and release the current resources hold by it.
  19532. */
  19533. dispose(): void;
  19534. /**
  19535. * Gets the current object class name.
  19536. * @return the class name
  19537. */
  19538. getClassName(): string;
  19539. }
  19540. }
  19541. declare module BABYLON {
  19542. /**
  19543. * Represents a gamepad control stick position
  19544. */
  19545. export class StickValues {
  19546. /**
  19547. * The x component of the control stick
  19548. */
  19549. x: number;
  19550. /**
  19551. * The y component of the control stick
  19552. */
  19553. y: number;
  19554. /**
  19555. * Initializes the gamepad x and y control stick values
  19556. * @param x The x component of the gamepad control stick value
  19557. * @param y The y component of the gamepad control stick value
  19558. */
  19559. constructor(
  19560. /**
  19561. * The x component of the control stick
  19562. */
  19563. x: number,
  19564. /**
  19565. * The y component of the control stick
  19566. */
  19567. y: number);
  19568. }
  19569. /**
  19570. * An interface which manages callbacks for gamepad button changes
  19571. */
  19572. export interface GamepadButtonChanges {
  19573. /**
  19574. * Called when a gamepad has been changed
  19575. */
  19576. changed: boolean;
  19577. /**
  19578. * Called when a gamepad press event has been triggered
  19579. */
  19580. pressChanged: boolean;
  19581. /**
  19582. * Called when a touch event has been triggered
  19583. */
  19584. touchChanged: boolean;
  19585. /**
  19586. * Called when a value has changed
  19587. */
  19588. valueChanged: boolean;
  19589. }
  19590. /**
  19591. * Represents a gamepad
  19592. */
  19593. export class Gamepad {
  19594. /**
  19595. * The id of the gamepad
  19596. */
  19597. id: string;
  19598. /**
  19599. * The index of the gamepad
  19600. */
  19601. index: number;
  19602. /**
  19603. * The browser gamepad
  19604. */
  19605. browserGamepad: any;
  19606. /**
  19607. * Specifies what type of gamepad this represents
  19608. */
  19609. type: number;
  19610. private _leftStick;
  19611. private _rightStick;
  19612. /** @hidden */
  19613. _isConnected: boolean;
  19614. private _leftStickAxisX;
  19615. private _leftStickAxisY;
  19616. private _rightStickAxisX;
  19617. private _rightStickAxisY;
  19618. /**
  19619. * Triggered when the left control stick has been changed
  19620. */
  19621. private _onleftstickchanged;
  19622. /**
  19623. * Triggered when the right control stick has been changed
  19624. */
  19625. private _onrightstickchanged;
  19626. /**
  19627. * Represents a gamepad controller
  19628. */
  19629. static GAMEPAD: number;
  19630. /**
  19631. * Represents a generic controller
  19632. */
  19633. static GENERIC: number;
  19634. /**
  19635. * Represents an XBox controller
  19636. */
  19637. static XBOX: number;
  19638. /**
  19639. * Represents a pose-enabled controller
  19640. */
  19641. static POSE_ENABLED: number;
  19642. /**
  19643. * Represents an Dual Shock controller
  19644. */
  19645. static DUALSHOCK: number;
  19646. /**
  19647. * Specifies whether the left control stick should be Y-inverted
  19648. */
  19649. protected _invertLeftStickY: boolean;
  19650. /**
  19651. * Specifies if the gamepad has been connected
  19652. */
  19653. get isConnected(): boolean;
  19654. /**
  19655. * Initializes the gamepad
  19656. * @param id The id of the gamepad
  19657. * @param index The index of the gamepad
  19658. * @param browserGamepad The browser gamepad
  19659. * @param leftStickX The x component of the left joystick
  19660. * @param leftStickY The y component of the left joystick
  19661. * @param rightStickX The x component of the right joystick
  19662. * @param rightStickY The y component of the right joystick
  19663. */
  19664. constructor(
  19665. /**
  19666. * The id of the gamepad
  19667. */
  19668. id: string,
  19669. /**
  19670. * The index of the gamepad
  19671. */
  19672. index: number,
  19673. /**
  19674. * The browser gamepad
  19675. */
  19676. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19677. /**
  19678. * Callback triggered when the left joystick has changed
  19679. * @param callback
  19680. */
  19681. onleftstickchanged(callback: (values: StickValues) => void): void;
  19682. /**
  19683. * Callback triggered when the right joystick has changed
  19684. * @param callback
  19685. */
  19686. onrightstickchanged(callback: (values: StickValues) => void): void;
  19687. /**
  19688. * Gets the left joystick
  19689. */
  19690. get leftStick(): StickValues;
  19691. /**
  19692. * Sets the left joystick values
  19693. */
  19694. set leftStick(newValues: StickValues);
  19695. /**
  19696. * Gets the right joystick
  19697. */
  19698. get rightStick(): StickValues;
  19699. /**
  19700. * Sets the right joystick value
  19701. */
  19702. set rightStick(newValues: StickValues);
  19703. /**
  19704. * Updates the gamepad joystick positions
  19705. */
  19706. update(): void;
  19707. /**
  19708. * Disposes the gamepad
  19709. */
  19710. dispose(): void;
  19711. }
  19712. /**
  19713. * Represents a generic gamepad
  19714. */
  19715. export class GenericPad extends Gamepad {
  19716. private _buttons;
  19717. private _onbuttondown;
  19718. private _onbuttonup;
  19719. /**
  19720. * Observable triggered when a button has been pressed
  19721. */
  19722. onButtonDownObservable: Observable<number>;
  19723. /**
  19724. * Observable triggered when a button has been released
  19725. */
  19726. onButtonUpObservable: Observable<number>;
  19727. /**
  19728. * Callback triggered when a button has been pressed
  19729. * @param callback Called when a button has been pressed
  19730. */
  19731. onbuttondown(callback: (buttonPressed: number) => void): void;
  19732. /**
  19733. * Callback triggered when a button has been released
  19734. * @param callback Called when a button has been released
  19735. */
  19736. onbuttonup(callback: (buttonReleased: number) => void): void;
  19737. /**
  19738. * Initializes the generic gamepad
  19739. * @param id The id of the generic gamepad
  19740. * @param index The index of the generic gamepad
  19741. * @param browserGamepad The browser gamepad
  19742. */
  19743. constructor(id: string, index: number, browserGamepad: any);
  19744. private _setButtonValue;
  19745. /**
  19746. * Updates the generic gamepad
  19747. */
  19748. update(): void;
  19749. /**
  19750. * Disposes the generic gamepad
  19751. */
  19752. dispose(): void;
  19753. }
  19754. }
  19755. declare module BABYLON {
  19756. /**
  19757. * Defines the types of pose enabled controllers that are supported
  19758. */
  19759. export enum PoseEnabledControllerType {
  19760. /**
  19761. * HTC Vive
  19762. */
  19763. VIVE = 0,
  19764. /**
  19765. * Oculus Rift
  19766. */
  19767. OCULUS = 1,
  19768. /**
  19769. * Windows mixed reality
  19770. */
  19771. WINDOWS = 2,
  19772. /**
  19773. * Samsung gear VR
  19774. */
  19775. GEAR_VR = 3,
  19776. /**
  19777. * Google Daydream
  19778. */
  19779. DAYDREAM = 4,
  19780. /**
  19781. * Generic
  19782. */
  19783. GENERIC = 5
  19784. }
  19785. /**
  19786. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19787. */
  19788. export interface MutableGamepadButton {
  19789. /**
  19790. * Value of the button/trigger
  19791. */
  19792. value: number;
  19793. /**
  19794. * If the button/trigger is currently touched
  19795. */
  19796. touched: boolean;
  19797. /**
  19798. * If the button/trigger is currently pressed
  19799. */
  19800. pressed: boolean;
  19801. }
  19802. /**
  19803. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19804. * @hidden
  19805. */
  19806. export interface ExtendedGamepadButton extends GamepadButton {
  19807. /**
  19808. * If the button/trigger is currently pressed
  19809. */
  19810. readonly pressed: boolean;
  19811. /**
  19812. * If the button/trigger is currently touched
  19813. */
  19814. readonly touched: boolean;
  19815. /**
  19816. * Value of the button/trigger
  19817. */
  19818. readonly value: number;
  19819. }
  19820. /** @hidden */
  19821. export interface _GamePadFactory {
  19822. /**
  19823. * Returns whether or not the current gamepad can be created for this type of controller.
  19824. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19825. * @returns true if it can be created, otherwise false
  19826. */
  19827. canCreate(gamepadInfo: any): boolean;
  19828. /**
  19829. * Creates a new instance of the Gamepad.
  19830. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19831. * @returns the new gamepad instance
  19832. */
  19833. create(gamepadInfo: any): Gamepad;
  19834. }
  19835. /**
  19836. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19837. */
  19838. export class PoseEnabledControllerHelper {
  19839. /** @hidden */
  19840. static _ControllerFactories: _GamePadFactory[];
  19841. /** @hidden */
  19842. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19843. /**
  19844. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19845. * @param vrGamepad the gamepad to initialized
  19846. * @returns a vr controller of the type the gamepad identified as
  19847. */
  19848. static InitiateController(vrGamepad: any): Gamepad;
  19849. }
  19850. /**
  19851. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19852. */
  19853. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19854. /**
  19855. * If the controller is used in a webXR session
  19856. */
  19857. isXR: boolean;
  19858. private _deviceRoomPosition;
  19859. private _deviceRoomRotationQuaternion;
  19860. /**
  19861. * The device position in babylon space
  19862. */
  19863. devicePosition: Vector3;
  19864. /**
  19865. * The device rotation in babylon space
  19866. */
  19867. deviceRotationQuaternion: Quaternion;
  19868. /**
  19869. * The scale factor of the device in babylon space
  19870. */
  19871. deviceScaleFactor: number;
  19872. /**
  19873. * (Likely devicePosition should be used instead) The device position in its room space
  19874. */
  19875. position: Vector3;
  19876. /**
  19877. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19878. */
  19879. rotationQuaternion: Quaternion;
  19880. /**
  19881. * The type of controller (Eg. Windows mixed reality)
  19882. */
  19883. controllerType: PoseEnabledControllerType;
  19884. protected _calculatedPosition: Vector3;
  19885. private _calculatedRotation;
  19886. /**
  19887. * The raw pose from the device
  19888. */
  19889. rawPose: DevicePose;
  19890. private _trackPosition;
  19891. private _maxRotationDistFromHeadset;
  19892. private _draggedRoomRotation;
  19893. /**
  19894. * @hidden
  19895. */
  19896. _disableTrackPosition(fixedPosition: Vector3): void;
  19897. /**
  19898. * Internal, the mesh attached to the controller
  19899. * @hidden
  19900. */
  19901. _mesh: Nullable<AbstractMesh>;
  19902. private _poseControlledCamera;
  19903. private _leftHandSystemQuaternion;
  19904. /**
  19905. * Internal, matrix used to convert room space to babylon space
  19906. * @hidden
  19907. */
  19908. _deviceToWorld: Matrix;
  19909. /**
  19910. * Node to be used when casting a ray from the controller
  19911. * @hidden
  19912. */
  19913. _pointingPoseNode: Nullable<TransformNode>;
  19914. /**
  19915. * Name of the child mesh that can be used to cast a ray from the controller
  19916. */
  19917. static readonly POINTING_POSE: string;
  19918. /**
  19919. * Creates a new PoseEnabledController from a gamepad
  19920. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19921. */
  19922. constructor(browserGamepad: any);
  19923. private _workingMatrix;
  19924. /**
  19925. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19926. */
  19927. update(): void;
  19928. /**
  19929. * Updates only the pose device and mesh without doing any button event checking
  19930. */
  19931. protected _updatePoseAndMesh(): void;
  19932. /**
  19933. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19934. * @param poseData raw pose fromthe device
  19935. */
  19936. updateFromDevice(poseData: DevicePose): void;
  19937. /**
  19938. * @hidden
  19939. */
  19940. _meshAttachedObservable: Observable<AbstractMesh>;
  19941. /**
  19942. * Attaches a mesh to the controller
  19943. * @param mesh the mesh to be attached
  19944. */
  19945. attachToMesh(mesh: AbstractMesh): void;
  19946. /**
  19947. * Attaches the controllers mesh to a camera
  19948. * @param camera the camera the mesh should be attached to
  19949. */
  19950. attachToPoseControlledCamera(camera: TargetCamera): void;
  19951. /**
  19952. * Disposes of the controller
  19953. */
  19954. dispose(): void;
  19955. /**
  19956. * The mesh that is attached to the controller
  19957. */
  19958. get mesh(): Nullable<AbstractMesh>;
  19959. /**
  19960. * Gets the ray of the controller in the direction the controller is pointing
  19961. * @param length the length the resulting ray should be
  19962. * @returns a ray in the direction the controller is pointing
  19963. */
  19964. getForwardRay(length?: number): Ray;
  19965. }
  19966. }
  19967. declare module BABYLON {
  19968. /**
  19969. * Defines the WebVRController object that represents controllers tracked in 3D space
  19970. */
  19971. export abstract class WebVRController extends PoseEnabledController {
  19972. /**
  19973. * Internal, the default controller model for the controller
  19974. */
  19975. protected _defaultModel: Nullable<AbstractMesh>;
  19976. /**
  19977. * Fired when the trigger state has changed
  19978. */
  19979. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19980. /**
  19981. * Fired when the main button state has changed
  19982. */
  19983. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19984. /**
  19985. * Fired when the secondary button state has changed
  19986. */
  19987. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19988. /**
  19989. * Fired when the pad state has changed
  19990. */
  19991. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19992. /**
  19993. * Fired when controllers stick values have changed
  19994. */
  19995. onPadValuesChangedObservable: Observable<StickValues>;
  19996. /**
  19997. * Array of button availible on the controller
  19998. */
  19999. protected _buttons: Array<MutableGamepadButton>;
  20000. private _onButtonStateChange;
  20001. /**
  20002. * Fired when a controller button's state has changed
  20003. * @param callback the callback containing the button that was modified
  20004. */
  20005. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20006. /**
  20007. * X and Y axis corresponding to the controllers joystick
  20008. */
  20009. pad: StickValues;
  20010. /**
  20011. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20012. */
  20013. hand: string;
  20014. /**
  20015. * The default controller model for the controller
  20016. */
  20017. get defaultModel(): Nullable<AbstractMesh>;
  20018. /**
  20019. * Creates a new WebVRController from a gamepad
  20020. * @param vrGamepad the gamepad that the WebVRController should be created from
  20021. */
  20022. constructor(vrGamepad: any);
  20023. /**
  20024. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20025. */
  20026. update(): void;
  20027. /**
  20028. * Function to be called when a button is modified
  20029. */
  20030. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20031. /**
  20032. * Loads a mesh and attaches it to the controller
  20033. * @param scene the scene the mesh should be added to
  20034. * @param meshLoaded callback for when the mesh has been loaded
  20035. */
  20036. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20037. private _setButtonValue;
  20038. private _changes;
  20039. private _checkChanges;
  20040. /**
  20041. * Disposes of th webVRCOntroller
  20042. */
  20043. dispose(): void;
  20044. }
  20045. }
  20046. declare module BABYLON {
  20047. /**
  20048. * The HemisphericLight simulates the ambient environment light,
  20049. * so the passed direction is the light reflection direction, not the incoming direction.
  20050. */
  20051. export class HemisphericLight extends Light {
  20052. /**
  20053. * The groundColor is the light in the opposite direction to the one specified during creation.
  20054. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  20055. */
  20056. groundColor: Color3;
  20057. /**
  20058. * The light reflection direction, not the incoming direction.
  20059. */
  20060. direction: Vector3;
  20061. /**
  20062. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20063. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20064. * The HemisphericLight can't cast shadows.
  20065. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20066. * @param name The friendly name of the light
  20067. * @param direction The direction of the light reflection
  20068. * @param scene The scene the light belongs to
  20069. */
  20070. constructor(name: string, direction: Vector3, scene: Scene);
  20071. protected _buildUniformLayout(): void;
  20072. /**
  20073. * Returns the string "HemisphericLight".
  20074. * @return The class name
  20075. */
  20076. getClassName(): string;
  20077. /**
  20078. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20079. * Returns the updated direction.
  20080. * @param target The target the direction should point to
  20081. * @return The computed direction
  20082. */
  20083. setDirectionToTarget(target: Vector3): Vector3;
  20084. /**
  20085. * Returns the shadow generator associated to the light.
  20086. * @returns Always null for hemispheric lights because it does not support shadows.
  20087. */
  20088. getShadowGenerator(): Nullable<IShadowGenerator>;
  20089. /**
  20090. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20091. * @param effect The effect to update
  20092. * @param lightIndex The index of the light in the effect to update
  20093. * @returns The hemispheric light
  20094. */
  20095. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20096. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20097. /**
  20098. * Computes the world matrix of the node
  20099. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20100. * @param useWasUpdatedFlag defines a reserved property
  20101. * @returns the world matrix
  20102. */
  20103. computeWorldMatrix(): Matrix;
  20104. /**
  20105. * Returns the integer 3.
  20106. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20107. */
  20108. getTypeID(): number;
  20109. /**
  20110. * Prepares the list of defines specific to the light type.
  20111. * @param defines the list of defines
  20112. * @param lightIndex defines the index of the light for the effect
  20113. */
  20114. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20115. }
  20116. }
  20117. declare module BABYLON {
  20118. /** @hidden */
  20119. export var vrMultiviewToSingleviewPixelShader: {
  20120. name: string;
  20121. shader: string;
  20122. };
  20123. }
  20124. declare module BABYLON {
  20125. /**
  20126. * Renders to multiple views with a single draw call
  20127. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20128. */
  20129. export class MultiviewRenderTarget extends RenderTargetTexture {
  20130. /**
  20131. * Creates a multiview render target
  20132. * @param scene scene used with the render target
  20133. * @param size the size of the render target (used for each view)
  20134. */
  20135. constructor(scene: Scene, size?: number | {
  20136. width: number;
  20137. height: number;
  20138. } | {
  20139. ratio: number;
  20140. });
  20141. /**
  20142. * @hidden
  20143. * @param faceIndex the face index, if its a cube texture
  20144. */
  20145. _bindFrameBuffer(faceIndex?: number): void;
  20146. /**
  20147. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20148. * @returns the view count
  20149. */
  20150. getViewCount(): number;
  20151. }
  20152. }
  20153. declare module BABYLON {
  20154. interface Engine {
  20155. /**
  20156. * Creates a new multiview render target
  20157. * @param width defines the width of the texture
  20158. * @param height defines the height of the texture
  20159. * @returns the created multiview texture
  20160. */
  20161. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20162. /**
  20163. * Binds a multiview framebuffer to be drawn to
  20164. * @param multiviewTexture texture to bind
  20165. */
  20166. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20167. }
  20168. interface Camera {
  20169. /**
  20170. * @hidden
  20171. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  20172. */
  20173. _useMultiviewToSingleView: boolean;
  20174. /**
  20175. * @hidden
  20176. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  20177. */
  20178. _multiviewTexture: Nullable<RenderTargetTexture>;
  20179. /**
  20180. * @hidden
  20181. * ensures the multiview texture of the camera exists and has the specified width/height
  20182. * @param width height to set on the multiview texture
  20183. * @param height width to set on the multiview texture
  20184. */
  20185. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20186. }
  20187. interface Scene {
  20188. /** @hidden */
  20189. _transformMatrixR: Matrix;
  20190. /** @hidden */
  20191. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20192. /** @hidden */
  20193. _createMultiviewUbo(): void;
  20194. /** @hidden */
  20195. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20196. /** @hidden */
  20197. _renderMultiviewToSingleView(camera: Camera): void;
  20198. }
  20199. }
  20200. declare module BABYLON {
  20201. /**
  20202. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20203. * This will not be used for webXR as it supports displaying texture arrays directly
  20204. */
  20205. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20206. /**
  20207. * Gets a string identifying the name of the class
  20208. * @returns "VRMultiviewToSingleviewPostProcess" string
  20209. */
  20210. getClassName(): string;
  20211. /**
  20212. * Initializes a VRMultiviewToSingleview
  20213. * @param name name of the post process
  20214. * @param camera camera to be applied to
  20215. * @param scaleFactor scaling factor to the size of the output texture
  20216. */
  20217. constructor(name: string, camera: Camera, scaleFactor: number);
  20218. }
  20219. }
  20220. declare module BABYLON {
  20221. /**
  20222. * Interface used to define additional presentation attributes
  20223. */
  20224. export interface IVRPresentationAttributes {
  20225. /**
  20226. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20227. */
  20228. highRefreshRate: boolean;
  20229. /**
  20230. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20231. */
  20232. foveationLevel: number;
  20233. }
  20234. interface Engine {
  20235. /** @hidden */
  20236. _vrDisplay: any;
  20237. /** @hidden */
  20238. _vrSupported: boolean;
  20239. /** @hidden */
  20240. _oldSize: Size;
  20241. /** @hidden */
  20242. _oldHardwareScaleFactor: number;
  20243. /** @hidden */
  20244. _vrExclusivePointerMode: boolean;
  20245. /** @hidden */
  20246. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20247. /** @hidden */
  20248. _onVRDisplayPointerRestricted: () => void;
  20249. /** @hidden */
  20250. _onVRDisplayPointerUnrestricted: () => void;
  20251. /** @hidden */
  20252. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20253. /** @hidden */
  20254. _onVrDisplayDisconnect: Nullable<() => void>;
  20255. /** @hidden */
  20256. _onVrDisplayPresentChange: Nullable<() => void>;
  20257. /**
  20258. * Observable signaled when VR display mode changes
  20259. */
  20260. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20261. /**
  20262. * Observable signaled when VR request present is complete
  20263. */
  20264. onVRRequestPresentComplete: Observable<boolean>;
  20265. /**
  20266. * Observable signaled when VR request present starts
  20267. */
  20268. onVRRequestPresentStart: Observable<Engine>;
  20269. /**
  20270. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20271. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20272. */
  20273. isInVRExclusivePointerMode: boolean;
  20274. /**
  20275. * Gets a boolean indicating if a webVR device was detected
  20276. * @returns true if a webVR device was detected
  20277. */
  20278. isVRDevicePresent(): boolean;
  20279. /**
  20280. * Gets the current webVR device
  20281. * @returns the current webVR device (or null)
  20282. */
  20283. getVRDevice(): any;
  20284. /**
  20285. * Initializes a webVR display and starts listening to display change events
  20286. * The onVRDisplayChangedObservable will be notified upon these changes
  20287. * @returns A promise containing a VRDisplay and if vr is supported
  20288. */
  20289. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20290. /** @hidden */
  20291. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20292. /**
  20293. * Gets or sets the presentation attributes used to configure VR rendering
  20294. */
  20295. vrPresentationAttributes?: IVRPresentationAttributes;
  20296. /**
  20297. * Call this function to switch to webVR mode
  20298. * Will do nothing if webVR is not supported or if there is no webVR device
  20299. * @param options the webvr options provided to the camera. mainly used for multiview
  20300. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20301. */
  20302. enableVR(options: WebVROptions): void;
  20303. /** @hidden */
  20304. _onVRFullScreenTriggered(): void;
  20305. }
  20306. }
  20307. declare module BABYLON {
  20308. /**
  20309. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20310. * IMPORTANT!! The data is right-hand data.
  20311. * @export
  20312. * @interface DevicePose
  20313. */
  20314. export interface DevicePose {
  20315. /**
  20316. * The position of the device, values in array are [x,y,z].
  20317. */
  20318. readonly position: Nullable<Float32Array>;
  20319. /**
  20320. * The linearVelocity of the device, values in array are [x,y,z].
  20321. */
  20322. readonly linearVelocity: Nullable<Float32Array>;
  20323. /**
  20324. * The linearAcceleration of the device, values in array are [x,y,z].
  20325. */
  20326. readonly linearAcceleration: Nullable<Float32Array>;
  20327. /**
  20328. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20329. */
  20330. readonly orientation: Nullable<Float32Array>;
  20331. /**
  20332. * The angularVelocity of the device, values in array are [x,y,z].
  20333. */
  20334. readonly angularVelocity: Nullable<Float32Array>;
  20335. /**
  20336. * The angularAcceleration of the device, values in array are [x,y,z].
  20337. */
  20338. readonly angularAcceleration: Nullable<Float32Array>;
  20339. }
  20340. /**
  20341. * Interface representing a pose controlled object in Babylon.
  20342. * A pose controlled object has both regular pose values as well as pose values
  20343. * from an external device such as a VR head mounted display
  20344. */
  20345. export interface PoseControlled {
  20346. /**
  20347. * The position of the object in babylon space.
  20348. */
  20349. position: Vector3;
  20350. /**
  20351. * The rotation quaternion of the object in babylon space.
  20352. */
  20353. rotationQuaternion: Quaternion;
  20354. /**
  20355. * The position of the device in babylon space.
  20356. */
  20357. devicePosition?: Vector3;
  20358. /**
  20359. * The rotation quaternion of the device in babylon space.
  20360. */
  20361. deviceRotationQuaternion: Quaternion;
  20362. /**
  20363. * The raw pose coming from the device.
  20364. */
  20365. rawPose: Nullable<DevicePose>;
  20366. /**
  20367. * The scale of the device to be used when translating from device space to babylon space.
  20368. */
  20369. deviceScaleFactor: number;
  20370. /**
  20371. * Updates the poseControlled values based on the input device pose.
  20372. * @param poseData the pose data to update the object with
  20373. */
  20374. updateFromDevice(poseData: DevicePose): void;
  20375. }
  20376. /**
  20377. * Set of options to customize the webVRCamera
  20378. */
  20379. export interface WebVROptions {
  20380. /**
  20381. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20382. */
  20383. trackPosition?: boolean;
  20384. /**
  20385. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20386. */
  20387. positionScale?: number;
  20388. /**
  20389. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20390. */
  20391. displayName?: string;
  20392. /**
  20393. * Should the native controller meshes be initialized. (default: true)
  20394. */
  20395. controllerMeshes?: boolean;
  20396. /**
  20397. * Creating a default HemiLight only on controllers. (default: true)
  20398. */
  20399. defaultLightingOnControllers?: boolean;
  20400. /**
  20401. * If you don't want to use the default VR button of the helper. (default: false)
  20402. */
  20403. useCustomVRButton?: boolean;
  20404. /**
  20405. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20406. */
  20407. customVRButton?: HTMLButtonElement;
  20408. /**
  20409. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20410. */
  20411. rayLength?: number;
  20412. /**
  20413. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20414. */
  20415. defaultHeight?: number;
  20416. /**
  20417. * If multiview should be used if availible (default: false)
  20418. */
  20419. useMultiview?: boolean;
  20420. }
  20421. /**
  20422. * This represents a WebVR camera.
  20423. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20424. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20425. */
  20426. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20427. private webVROptions;
  20428. /**
  20429. * @hidden
  20430. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20431. */
  20432. _vrDevice: any;
  20433. /**
  20434. * The rawPose of the vrDevice.
  20435. */
  20436. rawPose: Nullable<DevicePose>;
  20437. private _onVREnabled;
  20438. private _specsVersion;
  20439. private _attached;
  20440. private _frameData;
  20441. protected _descendants: Array<Node>;
  20442. private _deviceRoomPosition;
  20443. /** @hidden */
  20444. _deviceRoomRotationQuaternion: Quaternion;
  20445. private _standingMatrix;
  20446. /**
  20447. * Represents device position in babylon space.
  20448. */
  20449. devicePosition: Vector3;
  20450. /**
  20451. * Represents device rotation in babylon space.
  20452. */
  20453. deviceRotationQuaternion: Quaternion;
  20454. /**
  20455. * The scale of the device to be used when translating from device space to babylon space.
  20456. */
  20457. deviceScaleFactor: number;
  20458. private _deviceToWorld;
  20459. private _worldToDevice;
  20460. /**
  20461. * References to the webVR controllers for the vrDevice.
  20462. */
  20463. controllers: Array<WebVRController>;
  20464. /**
  20465. * Emits an event when a controller is attached.
  20466. */
  20467. onControllersAttachedObservable: Observable<WebVRController[]>;
  20468. /**
  20469. * Emits an event when a controller's mesh has been loaded;
  20470. */
  20471. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20472. /**
  20473. * Emits an event when the HMD's pose has been updated.
  20474. */
  20475. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20476. private _poseSet;
  20477. /**
  20478. * If the rig cameras be used as parent instead of this camera.
  20479. */
  20480. rigParenting: boolean;
  20481. private _lightOnControllers;
  20482. private _defaultHeight?;
  20483. /**
  20484. * Instantiates a WebVRFreeCamera.
  20485. * @param name The name of the WebVRFreeCamera
  20486. * @param position The starting anchor position for the camera
  20487. * @param scene The scene the camera belongs to
  20488. * @param webVROptions a set of customizable options for the webVRCamera
  20489. */
  20490. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20491. /**
  20492. * Gets the device distance from the ground in meters.
  20493. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  20494. */
  20495. deviceDistanceToRoomGround(): number;
  20496. /**
  20497. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20498. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20499. */
  20500. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20501. /**
  20502. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20503. * @returns A promise with a boolean set to if the standing matrix is supported.
  20504. */
  20505. useStandingMatrixAsync(): Promise<boolean>;
  20506. /**
  20507. * Disposes the camera
  20508. */
  20509. dispose(): void;
  20510. /**
  20511. * Gets a vrController by name.
  20512. * @param name The name of the controller to retreive
  20513. * @returns the controller matching the name specified or null if not found
  20514. */
  20515. getControllerByName(name: string): Nullable<WebVRController>;
  20516. private _leftController;
  20517. /**
  20518. * The controller corresponding to the users left hand.
  20519. */
  20520. get leftController(): Nullable<WebVRController>;
  20521. private _rightController;
  20522. /**
  20523. * The controller corresponding to the users right hand.
  20524. */
  20525. get rightController(): Nullable<WebVRController>;
  20526. /**
  20527. * Casts a ray forward from the vrCamera's gaze.
  20528. * @param length Length of the ray (default: 100)
  20529. * @returns the ray corresponding to the gaze
  20530. */
  20531. getForwardRay(length?: number): Ray;
  20532. /**
  20533. * @hidden
  20534. * Updates the camera based on device's frame data
  20535. */
  20536. _checkInputs(): void;
  20537. /**
  20538. * Updates the poseControlled values based on the input device pose.
  20539. * @param poseData Pose coming from the device
  20540. */
  20541. updateFromDevice(poseData: DevicePose): void;
  20542. private _detachIfAttached;
  20543. /**
  20544. * WebVR's attach control will start broadcasting frames to the device.
  20545. * Note that in certain browsers (chrome for example) this function must be called
  20546. * within a user-interaction callback. Example:
  20547. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20548. *
  20549. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20550. */
  20551. attachControl(noPreventDefault?: boolean): void;
  20552. /**
  20553. * Detaches the camera from the html element and disables VR
  20554. */
  20555. detachControl(): void;
  20556. /**
  20557. * @returns the name of this class
  20558. */
  20559. getClassName(): string;
  20560. /**
  20561. * Calls resetPose on the vrDisplay
  20562. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20563. */
  20564. resetToCurrentRotation(): void;
  20565. /**
  20566. * @hidden
  20567. * Updates the rig cameras (left and right eye)
  20568. */
  20569. _updateRigCameras(): void;
  20570. private _workingVector;
  20571. private _oneVector;
  20572. private _workingMatrix;
  20573. private updateCacheCalled;
  20574. private _correctPositionIfNotTrackPosition;
  20575. /**
  20576. * @hidden
  20577. * Updates the cached values of the camera
  20578. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20579. */
  20580. _updateCache(ignoreParentClass?: boolean): void;
  20581. /**
  20582. * @hidden
  20583. * Get current device position in babylon world
  20584. */
  20585. _computeDevicePosition(): void;
  20586. /**
  20587. * Updates the current device position and rotation in the babylon world
  20588. */
  20589. update(): void;
  20590. /**
  20591. * @hidden
  20592. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20593. * @returns an identity matrix
  20594. */
  20595. _getViewMatrix(): Matrix;
  20596. private _tmpMatrix;
  20597. /**
  20598. * This function is called by the two RIG cameras.
  20599. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20600. * @hidden
  20601. */
  20602. _getWebVRViewMatrix(): Matrix;
  20603. /** @hidden */
  20604. _getWebVRProjectionMatrix(): Matrix;
  20605. private _onGamepadConnectedObserver;
  20606. private _onGamepadDisconnectedObserver;
  20607. private _updateCacheWhenTrackingDisabledObserver;
  20608. /**
  20609. * Initializes the controllers and their meshes
  20610. */
  20611. initControllers(): void;
  20612. }
  20613. }
  20614. declare module BABYLON {
  20615. /**
  20616. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20617. *
  20618. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20619. *
  20620. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20621. */
  20622. export class MaterialHelper {
  20623. /**
  20624. * Bind the current view position to an effect.
  20625. * @param effect The effect to be bound
  20626. * @param scene The scene the eyes position is used from
  20627. * @param variableName name of the shader variable that will hold the eye position
  20628. */
  20629. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20630. /**
  20631. * Helps preparing the defines values about the UVs in used in the effect.
  20632. * UVs are shared as much as we can accross channels in the shaders.
  20633. * @param texture The texture we are preparing the UVs for
  20634. * @param defines The defines to update
  20635. * @param key The channel key "diffuse", "specular"... used in the shader
  20636. */
  20637. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20638. /**
  20639. * Binds a texture matrix value to its corrsponding uniform
  20640. * @param texture The texture to bind the matrix for
  20641. * @param uniformBuffer The uniform buffer receivin the data
  20642. * @param key The channel key "diffuse", "specular"... used in the shader
  20643. */
  20644. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20645. /**
  20646. * Gets the current status of the fog (should it be enabled?)
  20647. * @param mesh defines the mesh to evaluate for fog support
  20648. * @param scene defines the hosting scene
  20649. * @returns true if fog must be enabled
  20650. */
  20651. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20652. /**
  20653. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20654. * @param mesh defines the current mesh
  20655. * @param scene defines the current scene
  20656. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20657. * @param pointsCloud defines if point cloud rendering has to be turned on
  20658. * @param fogEnabled defines if fog has to be turned on
  20659. * @param alphaTest defines if alpha testing has to be turned on
  20660. * @param defines defines the current list of defines
  20661. */
  20662. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20663. /**
  20664. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20665. * @param scene defines the current scene
  20666. * @param engine defines the current engine
  20667. * @param defines specifies the list of active defines
  20668. * @param useInstances defines if instances have to be turned on
  20669. * @param useClipPlane defines if clip plane have to be turned on
  20670. * @param useInstances defines if instances have to be turned on
  20671. * @param useThinInstances defines if thin instances have to be turned on
  20672. */
  20673. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20674. /**
  20675. * Prepares the defines for bones
  20676. * @param mesh The mesh containing the geometry data we will draw
  20677. * @param defines The defines to update
  20678. */
  20679. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20680. /**
  20681. * Prepares the defines for morph targets
  20682. * @param mesh The mesh containing the geometry data we will draw
  20683. * @param defines The defines to update
  20684. */
  20685. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20686. /**
  20687. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20688. * @param mesh The mesh containing the geometry data we will draw
  20689. * @param defines The defines to update
  20690. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20691. * @param useBones Precise whether bones should be used or not (override mesh info)
  20692. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20693. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20694. * @returns false if defines are considered not dirty and have not been checked
  20695. */
  20696. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20697. /**
  20698. * Prepares the defines related to multiview
  20699. * @param scene The scene we are intending to draw
  20700. * @param defines The defines to update
  20701. */
  20702. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20703. /**
  20704. * Prepares the defines related to the prepass
  20705. * @param scene The scene we are intending to draw
  20706. * @param defines The defines to update
  20707. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20708. */
  20709. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20710. /**
  20711. * Prepares the defines related to the light information passed in parameter
  20712. * @param scene The scene we are intending to draw
  20713. * @param mesh The mesh the effect is compiling for
  20714. * @param light The light the effect is compiling for
  20715. * @param lightIndex The index of the light
  20716. * @param defines The defines to update
  20717. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20718. * @param state Defines the current state regarding what is needed (normals, etc...)
  20719. */
  20720. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20721. needNormals: boolean;
  20722. needRebuild: boolean;
  20723. shadowEnabled: boolean;
  20724. specularEnabled: boolean;
  20725. lightmapMode: boolean;
  20726. }): void;
  20727. /**
  20728. * Prepares the defines related to the light information passed in parameter
  20729. * @param scene The scene we are intending to draw
  20730. * @param mesh The mesh the effect is compiling for
  20731. * @param defines The defines to update
  20732. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20733. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20734. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20735. * @returns true if normals will be required for the rest of the effect
  20736. */
  20737. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20738. /**
  20739. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20740. * @param lightIndex defines the light index
  20741. * @param uniformsList The uniform list
  20742. * @param samplersList The sampler list
  20743. * @param projectedLightTexture defines if projected texture must be used
  20744. * @param uniformBuffersList defines an optional list of uniform buffers
  20745. */
  20746. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20747. /**
  20748. * Prepares the uniforms and samplers list to be used in the effect
  20749. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20750. * @param samplersList The sampler list
  20751. * @param defines The defines helping in the list generation
  20752. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20753. */
  20754. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20755. /**
  20756. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20757. * @param defines The defines to update while falling back
  20758. * @param fallbacks The authorized effect fallbacks
  20759. * @param maxSimultaneousLights The maximum number of lights allowed
  20760. * @param rank the current rank of the Effect
  20761. * @returns The newly affected rank
  20762. */
  20763. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20764. private static _TmpMorphInfluencers;
  20765. /**
  20766. * Prepares the list of attributes required for morph targets according to the effect defines.
  20767. * @param attribs The current list of supported attribs
  20768. * @param mesh The mesh to prepare the morph targets attributes for
  20769. * @param influencers The number of influencers
  20770. */
  20771. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20772. /**
  20773. * Prepares the list of attributes required for morph targets according to the effect defines.
  20774. * @param attribs The current list of supported attribs
  20775. * @param mesh The mesh to prepare the morph targets attributes for
  20776. * @param defines The current Defines of the effect
  20777. */
  20778. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20779. /**
  20780. * Prepares the list of attributes required for bones according to the effect defines.
  20781. * @param attribs The current list of supported attribs
  20782. * @param mesh The mesh to prepare the bones attributes for
  20783. * @param defines The current Defines of the effect
  20784. * @param fallbacks The current efffect fallback strategy
  20785. */
  20786. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20787. /**
  20788. * Check and prepare the list of attributes required for instances according to the effect defines.
  20789. * @param attribs The current list of supported attribs
  20790. * @param defines The current MaterialDefines of the effect
  20791. */
  20792. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20793. /**
  20794. * Add the list of attributes required for instances to the attribs array.
  20795. * @param attribs The current list of supported attribs
  20796. */
  20797. static PushAttributesForInstances(attribs: string[]): void;
  20798. /**
  20799. * Binds the light information to the effect.
  20800. * @param light The light containing the generator
  20801. * @param effect The effect we are binding the data to
  20802. * @param lightIndex The light index in the effect used to render
  20803. */
  20804. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20805. /**
  20806. * Binds the lights information from the scene to the effect for the given mesh.
  20807. * @param light Light to bind
  20808. * @param lightIndex Light index
  20809. * @param scene The scene where the light belongs to
  20810. * @param effect The effect we are binding the data to
  20811. * @param useSpecular Defines if specular is supported
  20812. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20813. */
  20814. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20815. /**
  20816. * Binds the lights information from the scene to the effect for the given mesh.
  20817. * @param scene The scene the lights belongs to
  20818. * @param mesh The mesh we are binding the information to render
  20819. * @param effect The effect we are binding the data to
  20820. * @param defines The generated defines for the effect
  20821. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20822. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20823. */
  20824. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20825. private static _tempFogColor;
  20826. /**
  20827. * Binds the fog information from the scene to the effect for the given mesh.
  20828. * @param scene The scene the lights belongs to
  20829. * @param mesh The mesh we are binding the information to render
  20830. * @param effect The effect we are binding the data to
  20831. * @param linearSpace Defines if the fog effect is applied in linear space
  20832. */
  20833. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20834. /**
  20835. * Binds the bones information from the mesh to the effect.
  20836. * @param mesh The mesh we are binding the information to render
  20837. * @param effect The effect we are binding the data to
  20838. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  20839. */
  20840. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  20841. private static _CopyBonesTransformationMatrices;
  20842. /**
  20843. * Binds the morph targets information from the mesh to the effect.
  20844. * @param abstractMesh The mesh we are binding the information to render
  20845. * @param effect The effect we are binding the data to
  20846. */
  20847. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20848. /**
  20849. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20850. * @param defines The generated defines used in the effect
  20851. * @param effect The effect we are binding the data to
  20852. * @param scene The scene we are willing to render with logarithmic scale for
  20853. */
  20854. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20855. /**
  20856. * Binds the clip plane information from the scene to the effect.
  20857. * @param scene The scene the clip plane information are extracted from
  20858. * @param effect The effect we are binding the data to
  20859. */
  20860. static BindClipPlane(effect: Effect, scene: Scene): void;
  20861. }
  20862. }
  20863. declare module BABYLON {
  20864. /**
  20865. * Block used to expose an input value
  20866. */
  20867. export class InputBlock extends NodeMaterialBlock {
  20868. private _mode;
  20869. private _associatedVariableName;
  20870. private _storedValue;
  20871. private _valueCallback;
  20872. private _type;
  20873. private _animationType;
  20874. /** Gets or set a value used to limit the range of float values */
  20875. min: number;
  20876. /** Gets or set a value used to limit the range of float values */
  20877. max: number;
  20878. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20879. isBoolean: boolean;
  20880. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20881. matrixMode: number;
  20882. /** @hidden */
  20883. _systemValue: Nullable<NodeMaterialSystemValues>;
  20884. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20885. isConstant: boolean;
  20886. /** Gets or sets the group to use to display this block in the Inspector */
  20887. groupInInspector: string;
  20888. /** Gets an observable raised when the value is changed */
  20889. onValueChangedObservable: Observable<InputBlock>;
  20890. /**
  20891. * Gets or sets the connection point type (default is float)
  20892. */
  20893. get type(): NodeMaterialBlockConnectionPointTypes;
  20894. /**
  20895. * Creates a new InputBlock
  20896. * @param name defines the block name
  20897. * @param target defines the target of that block (Vertex by default)
  20898. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20899. */
  20900. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20901. /**
  20902. * Validates if a name is a reserve word.
  20903. * @param newName the new name to be given to the node.
  20904. * @returns false if the name is a reserve word, else true.
  20905. */
  20906. validateBlockName(newName: string): boolean;
  20907. /**
  20908. * Gets the output component
  20909. */
  20910. get output(): NodeMaterialConnectionPoint;
  20911. /**
  20912. * Set the source of this connection point to a vertex attribute
  20913. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20914. * @returns the current connection point
  20915. */
  20916. setAsAttribute(attributeName?: string): InputBlock;
  20917. /**
  20918. * Set the source of this connection point to a system value
  20919. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20920. * @returns the current connection point
  20921. */
  20922. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20923. /**
  20924. * Gets or sets the value of that point.
  20925. * Please note that this value will be ignored if valueCallback is defined
  20926. */
  20927. get value(): any;
  20928. set value(value: any);
  20929. /**
  20930. * Gets or sets a callback used to get the value of that point.
  20931. * Please note that setting this value will force the connection point to ignore the value property
  20932. */
  20933. get valueCallback(): () => any;
  20934. set valueCallback(value: () => any);
  20935. /**
  20936. * Gets or sets the associated variable name in the shader
  20937. */
  20938. get associatedVariableName(): string;
  20939. set associatedVariableName(value: string);
  20940. /** Gets or sets the type of animation applied to the input */
  20941. get animationType(): AnimatedInputBlockTypes;
  20942. set animationType(value: AnimatedInputBlockTypes);
  20943. /**
  20944. * Gets a boolean indicating that this connection point not defined yet
  20945. */
  20946. get isUndefined(): boolean;
  20947. /**
  20948. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20949. * In this case the connection point name must be the name of the uniform to use.
  20950. * Can only be set on inputs
  20951. */
  20952. get isUniform(): boolean;
  20953. set isUniform(value: boolean);
  20954. /**
  20955. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20956. * In this case the connection point name must be the name of the attribute to use
  20957. * Can only be set on inputs
  20958. */
  20959. get isAttribute(): boolean;
  20960. set isAttribute(value: boolean);
  20961. /**
  20962. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20963. * Can only be set on exit points
  20964. */
  20965. get isVarying(): boolean;
  20966. set isVarying(value: boolean);
  20967. /**
  20968. * Gets a boolean indicating that the current connection point is a system value
  20969. */
  20970. get isSystemValue(): boolean;
  20971. /**
  20972. * Gets or sets the current well known value or null if not defined as a system value
  20973. */
  20974. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20975. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20976. /**
  20977. * Gets the current class name
  20978. * @returns the class name
  20979. */
  20980. getClassName(): string;
  20981. /**
  20982. * Animate the input if animationType !== None
  20983. * @param scene defines the rendering scene
  20984. */
  20985. animate(scene: Scene): void;
  20986. private _emitDefine;
  20987. initialize(state: NodeMaterialBuildState): void;
  20988. /**
  20989. * Set the input block to its default value (based on its type)
  20990. */
  20991. setDefaultValue(): void;
  20992. private _emitConstant;
  20993. /** @hidden */
  20994. get _noContextSwitch(): boolean;
  20995. private _emit;
  20996. /** @hidden */
  20997. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20998. /** @hidden */
  20999. _transmit(effect: Effect, scene: Scene): void;
  21000. protected _buildBlock(state: NodeMaterialBuildState): void;
  21001. protected _dumpPropertiesCode(): string;
  21002. dispose(): void;
  21003. serialize(): any;
  21004. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21005. }
  21006. }
  21007. declare module BABYLON {
  21008. /**
  21009. * Enum used to define the compatibility state between two connection points
  21010. */
  21011. export enum NodeMaterialConnectionPointCompatibilityStates {
  21012. /** Points are compatibles */
  21013. Compatible = 0,
  21014. /** Points are incompatible because of their types */
  21015. TypeIncompatible = 1,
  21016. /** Points are incompatible because of their targets (vertex vs fragment) */
  21017. TargetIncompatible = 2
  21018. }
  21019. /**
  21020. * Defines the direction of a connection point
  21021. */
  21022. export enum NodeMaterialConnectionPointDirection {
  21023. /** Input */
  21024. Input = 0,
  21025. /** Output */
  21026. Output = 1
  21027. }
  21028. /**
  21029. * Defines a connection point for a block
  21030. */
  21031. export class NodeMaterialConnectionPoint {
  21032. /**
  21033. * Checks if two types are equivalent
  21034. * @param type1 type 1 to check
  21035. * @param type2 type 2 to check
  21036. * @returns true if both types are equivalent, else false
  21037. */
  21038. static AreEquivalentTypes(type1: number, type2: number): boolean;
  21039. /** @hidden */
  21040. _ownerBlock: NodeMaterialBlock;
  21041. /** @hidden */
  21042. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21043. private _endpoints;
  21044. private _associatedVariableName;
  21045. private _direction;
  21046. /** @hidden */
  21047. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21048. /** @hidden */
  21049. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21050. /** @hidden */
  21051. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  21052. private _type;
  21053. /** @hidden */
  21054. _enforceAssociatedVariableName: boolean;
  21055. /** Gets the direction of the point */
  21056. get direction(): NodeMaterialConnectionPointDirection;
  21057. /** Indicates that this connection point needs dual validation before being connected to another point */
  21058. needDualDirectionValidation: boolean;
  21059. /**
  21060. * Gets or sets the additional types supported by this connection point
  21061. */
  21062. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21063. /**
  21064. * Gets or sets the additional types excluded by this connection point
  21065. */
  21066. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21067. /**
  21068. * Observable triggered when this point is connected
  21069. */
  21070. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21071. /**
  21072. * Gets or sets the associated variable name in the shader
  21073. */
  21074. get associatedVariableName(): string;
  21075. set associatedVariableName(value: string);
  21076. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21077. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21078. /**
  21079. * Gets or sets the connection point type (default is float)
  21080. */
  21081. get type(): NodeMaterialBlockConnectionPointTypes;
  21082. set type(value: NodeMaterialBlockConnectionPointTypes);
  21083. /**
  21084. * Gets or sets the connection point name
  21085. */
  21086. name: string;
  21087. /**
  21088. * Gets or sets the connection point name
  21089. */
  21090. displayName: string;
  21091. /**
  21092. * Gets or sets a boolean indicating that this connection point can be omitted
  21093. */
  21094. isOptional: boolean;
  21095. /**
  21096. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21097. */
  21098. isExposedOnFrame: boolean;
  21099. /**
  21100. * Gets or sets number indicating the position that the port is exposed to on a frame
  21101. */
  21102. exposedPortPosition: number;
  21103. /**
  21104. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21105. */
  21106. define: string;
  21107. /** @hidden */
  21108. _prioritizeVertex: boolean;
  21109. private _target;
  21110. /** Gets or sets the target of that connection point */
  21111. get target(): NodeMaterialBlockTargets;
  21112. set target(value: NodeMaterialBlockTargets);
  21113. /**
  21114. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21115. */
  21116. get isConnected(): boolean;
  21117. /**
  21118. * Gets a boolean indicating that the current point is connected to an input block
  21119. */
  21120. get isConnectedToInputBlock(): boolean;
  21121. /**
  21122. * Gets a the connected input block (if any)
  21123. */
  21124. get connectInputBlock(): Nullable<InputBlock>;
  21125. /** Get the other side of the connection (if any) */
  21126. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21127. /** Get the block that owns this connection point */
  21128. get ownerBlock(): NodeMaterialBlock;
  21129. /** Get the block connected on the other side of this connection (if any) */
  21130. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21131. /** Get the block connected on the endpoints of this connection (if any) */
  21132. get connectedBlocks(): Array<NodeMaterialBlock>;
  21133. /** Gets the list of connected endpoints */
  21134. get endpoints(): NodeMaterialConnectionPoint[];
  21135. /** Gets a boolean indicating if that output point is connected to at least one input */
  21136. get hasEndpoints(): boolean;
  21137. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21138. get isConnectedInVertexShader(): boolean;
  21139. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21140. get isConnectedInFragmentShader(): boolean;
  21141. /**
  21142. * Creates a block suitable to be used as an input for this input point.
  21143. * If null is returned, a block based on the point type will be created.
  21144. * @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
  21145. */
  21146. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21147. /**
  21148. * Creates a new connection point
  21149. * @param name defines the connection point name
  21150. * @param ownerBlock defines the block hosting this connection point
  21151. * @param direction defines the direction of the connection point
  21152. */
  21153. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21154. /**
  21155. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21156. * @returns the class name
  21157. */
  21158. getClassName(): string;
  21159. /**
  21160. * Gets a boolean indicating if the current point can be connected to another point
  21161. * @param connectionPoint defines the other connection point
  21162. * @returns a boolean
  21163. */
  21164. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21165. /**
  21166. * Gets a number indicating if the current point can be connected to another point
  21167. * @param connectionPoint defines the other connection point
  21168. * @returns a number defining the compatibility state
  21169. */
  21170. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21171. /**
  21172. * Connect this point to another connection point
  21173. * @param connectionPoint defines the other connection point
  21174. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21175. * @returns the current connection point
  21176. */
  21177. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21178. /**
  21179. * Disconnect this point from one of his endpoint
  21180. * @param endpoint defines the other connection point
  21181. * @returns the current connection point
  21182. */
  21183. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21184. /**
  21185. * Serializes this point in a JSON representation
  21186. * @param isInput defines if the connection point is an input (default is true)
  21187. * @returns the serialized point object
  21188. */
  21189. serialize(isInput?: boolean): any;
  21190. /**
  21191. * Release resources
  21192. */
  21193. dispose(): void;
  21194. }
  21195. }
  21196. declare module BABYLON {
  21197. /**
  21198. * Enum used to define the material modes
  21199. */
  21200. export enum NodeMaterialModes {
  21201. /** Regular material */
  21202. Material = 0,
  21203. /** For post process */
  21204. PostProcess = 1,
  21205. /** For particle system */
  21206. Particle = 2,
  21207. /** For procedural texture */
  21208. ProceduralTexture = 3
  21209. }
  21210. }
  21211. declare module BABYLON {
  21212. /**
  21213. * Block used to read a texture from a sampler
  21214. */
  21215. export class TextureBlock extends NodeMaterialBlock {
  21216. private _defineName;
  21217. private _linearDefineName;
  21218. private _gammaDefineName;
  21219. private _tempTextureRead;
  21220. private _samplerName;
  21221. private _transformedUVName;
  21222. private _textureTransformName;
  21223. private _textureInfoName;
  21224. private _mainUVName;
  21225. private _mainUVDefineName;
  21226. private _fragmentOnly;
  21227. /**
  21228. * Gets or sets the texture associated with the node
  21229. */
  21230. texture: Nullable<Texture>;
  21231. /**
  21232. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21233. */
  21234. convertToGammaSpace: boolean;
  21235. /**
  21236. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21237. */
  21238. convertToLinearSpace: boolean;
  21239. /**
  21240. * Create a new TextureBlock
  21241. * @param name defines the block name
  21242. */
  21243. constructor(name: string, fragmentOnly?: boolean);
  21244. /**
  21245. * Gets the current class name
  21246. * @returns the class name
  21247. */
  21248. getClassName(): string;
  21249. /**
  21250. * Gets the uv input component
  21251. */
  21252. get uv(): NodeMaterialConnectionPoint;
  21253. /**
  21254. * Gets the rgba output component
  21255. */
  21256. get rgba(): NodeMaterialConnectionPoint;
  21257. /**
  21258. * Gets the rgb output component
  21259. */
  21260. get rgb(): NodeMaterialConnectionPoint;
  21261. /**
  21262. * Gets the r output component
  21263. */
  21264. get r(): NodeMaterialConnectionPoint;
  21265. /**
  21266. * Gets the g output component
  21267. */
  21268. get g(): NodeMaterialConnectionPoint;
  21269. /**
  21270. * Gets the b output component
  21271. */
  21272. get b(): NodeMaterialConnectionPoint;
  21273. /**
  21274. * Gets the a output component
  21275. */
  21276. get a(): NodeMaterialConnectionPoint;
  21277. get target(): NodeMaterialBlockTargets;
  21278. autoConfigure(material: NodeMaterial): void;
  21279. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21280. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21281. isReady(): boolean;
  21282. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21283. private get _isMixed();
  21284. private _injectVertexCode;
  21285. private _writeTextureRead;
  21286. private _writeOutput;
  21287. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21288. protected _dumpPropertiesCode(): string;
  21289. serialize(): any;
  21290. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21291. }
  21292. }
  21293. declare module BABYLON {
  21294. /** @hidden */
  21295. export var reflectionFunction: {
  21296. name: string;
  21297. shader: string;
  21298. };
  21299. }
  21300. declare module BABYLON {
  21301. /**
  21302. * Base block used to read a reflection texture from a sampler
  21303. */
  21304. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21305. /** @hidden */
  21306. _define3DName: string;
  21307. /** @hidden */
  21308. _defineCubicName: string;
  21309. /** @hidden */
  21310. _defineExplicitName: string;
  21311. /** @hidden */
  21312. _defineProjectionName: string;
  21313. /** @hidden */
  21314. _defineLocalCubicName: string;
  21315. /** @hidden */
  21316. _defineSphericalName: string;
  21317. /** @hidden */
  21318. _definePlanarName: string;
  21319. /** @hidden */
  21320. _defineEquirectangularName: string;
  21321. /** @hidden */
  21322. _defineMirroredEquirectangularFixedName: string;
  21323. /** @hidden */
  21324. _defineEquirectangularFixedName: string;
  21325. /** @hidden */
  21326. _defineSkyboxName: string;
  21327. /** @hidden */
  21328. _defineOppositeZ: string;
  21329. /** @hidden */
  21330. _cubeSamplerName: string;
  21331. /** @hidden */
  21332. _2DSamplerName: string;
  21333. protected _positionUVWName: string;
  21334. protected _directionWName: string;
  21335. protected _reflectionVectorName: string;
  21336. /** @hidden */
  21337. _reflectionCoordsName: string;
  21338. /** @hidden */
  21339. _reflectionMatrixName: string;
  21340. protected _reflectionColorName: string;
  21341. /**
  21342. * Gets or sets the texture associated with the node
  21343. */
  21344. texture: Nullable<BaseTexture>;
  21345. /**
  21346. * Create a new ReflectionTextureBaseBlock
  21347. * @param name defines the block name
  21348. */
  21349. constructor(name: string);
  21350. /**
  21351. * Gets the current class name
  21352. * @returns the class name
  21353. */
  21354. getClassName(): string;
  21355. /**
  21356. * Gets the world position input component
  21357. */
  21358. abstract get position(): NodeMaterialConnectionPoint;
  21359. /**
  21360. * Gets the world position input component
  21361. */
  21362. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21363. /**
  21364. * Gets the world normal input component
  21365. */
  21366. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21367. /**
  21368. * Gets the world input component
  21369. */
  21370. abstract get world(): NodeMaterialConnectionPoint;
  21371. /**
  21372. * Gets the camera (or eye) position component
  21373. */
  21374. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21375. /**
  21376. * Gets the view input component
  21377. */
  21378. abstract get view(): NodeMaterialConnectionPoint;
  21379. protected _getTexture(): Nullable<BaseTexture>;
  21380. autoConfigure(material: NodeMaterial): void;
  21381. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21382. isReady(): boolean;
  21383. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21384. /**
  21385. * Gets the code to inject in the vertex shader
  21386. * @param state current state of the node material building
  21387. * @returns the shader code
  21388. */
  21389. handleVertexSide(state: NodeMaterialBuildState): string;
  21390. /**
  21391. * Handles the inits for the fragment code path
  21392. * @param state node material build state
  21393. */
  21394. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21395. /**
  21396. * Generates the reflection coords code for the fragment code path
  21397. * @param worldNormalVarName name of the world normal variable
  21398. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21399. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21400. * @returns the shader code
  21401. */
  21402. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21403. /**
  21404. * Generates the reflection color code for the fragment code path
  21405. * @param lodVarName name of the lod variable
  21406. * @param swizzleLookupTexture swizzle to use for the final color variable
  21407. * @returns the shader code
  21408. */
  21409. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21410. /**
  21411. * Generates the code corresponding to the connected output points
  21412. * @param state node material build state
  21413. * @param varName name of the variable to output
  21414. * @returns the shader code
  21415. */
  21416. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21417. protected _buildBlock(state: NodeMaterialBuildState): this;
  21418. protected _dumpPropertiesCode(): string;
  21419. serialize(): any;
  21420. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21421. }
  21422. }
  21423. declare module BABYLON {
  21424. /**
  21425. * Defines a connection point to be used for points with a custom object type
  21426. */
  21427. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21428. private _blockType;
  21429. private _blockName;
  21430. private _nameForCheking?;
  21431. /**
  21432. * Creates a new connection point
  21433. * @param name defines the connection point name
  21434. * @param ownerBlock defines the block hosting this connection point
  21435. * @param direction defines the direction of the connection point
  21436. */
  21437. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21438. /**
  21439. * Gets a number indicating if the current point can be connected to another point
  21440. * @param connectionPoint defines the other connection point
  21441. * @returns a number defining the compatibility state
  21442. */
  21443. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21444. /**
  21445. * Creates a block suitable to be used as an input for this input point.
  21446. * If null is returned, a block based on the point type will be created.
  21447. * @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
  21448. */
  21449. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21450. }
  21451. }
  21452. declare module BABYLON {
  21453. /**
  21454. * Enum defining the type of properties that can be edited in the property pages in the NME
  21455. */
  21456. export enum PropertyTypeForEdition {
  21457. /** property is a boolean */
  21458. Boolean = 0,
  21459. /** property is a float */
  21460. Float = 1,
  21461. /** property is a Vector2 */
  21462. Vector2 = 2,
  21463. /** property is a list of values */
  21464. List = 3
  21465. }
  21466. /**
  21467. * Interface that defines an option in a variable of type list
  21468. */
  21469. export interface IEditablePropertyListOption {
  21470. /** label of the option */
  21471. "label": string;
  21472. /** value of the option */
  21473. "value": number;
  21474. }
  21475. /**
  21476. * Interface that defines the options available for an editable property
  21477. */
  21478. export interface IEditablePropertyOption {
  21479. /** min value */
  21480. "min"?: number;
  21481. /** max value */
  21482. "max"?: number;
  21483. /** notifiers: indicates which actions to take when the property is changed */
  21484. "notifiers"?: {
  21485. /** the material should be rebuilt */
  21486. "rebuild"?: boolean;
  21487. /** the preview should be updated */
  21488. "update"?: boolean;
  21489. };
  21490. /** list of the options for a variable of type list */
  21491. "options"?: IEditablePropertyListOption[];
  21492. }
  21493. /**
  21494. * Interface that describes an editable property
  21495. */
  21496. export interface IPropertyDescriptionForEdition {
  21497. /** name of the property */
  21498. "propertyName": string;
  21499. /** display name of the property */
  21500. "displayName": string;
  21501. /** type of the property */
  21502. "type": PropertyTypeForEdition;
  21503. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21504. "groupName": string;
  21505. /** options for the property */
  21506. "options": IEditablePropertyOption;
  21507. }
  21508. /**
  21509. * Decorator that flags a property in a node material block as being editable
  21510. */
  21511. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21512. }
  21513. declare module BABYLON {
  21514. /**
  21515. * Block used to implement the refraction part of the sub surface module of the PBR material
  21516. */
  21517. export class RefractionBlock extends NodeMaterialBlock {
  21518. /** @hidden */
  21519. _define3DName: string;
  21520. /** @hidden */
  21521. _refractionMatrixName: string;
  21522. /** @hidden */
  21523. _defineLODRefractionAlpha: string;
  21524. /** @hidden */
  21525. _defineLinearSpecularRefraction: string;
  21526. /** @hidden */
  21527. _defineOppositeZ: string;
  21528. /** @hidden */
  21529. _cubeSamplerName: string;
  21530. /** @hidden */
  21531. _2DSamplerName: string;
  21532. /** @hidden */
  21533. _vRefractionMicrosurfaceInfosName: string;
  21534. /** @hidden */
  21535. _vRefractionInfosName: string;
  21536. private _scene;
  21537. /**
  21538. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21539. * Materials half opaque for instance using refraction could benefit from this control.
  21540. */
  21541. linkRefractionWithTransparency: boolean;
  21542. /**
  21543. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21544. */
  21545. invertRefractionY: boolean;
  21546. /**
  21547. * Gets or sets the texture associated with the node
  21548. */
  21549. texture: Nullable<BaseTexture>;
  21550. /**
  21551. * Create a new RefractionBlock
  21552. * @param name defines the block name
  21553. */
  21554. constructor(name: string);
  21555. /**
  21556. * Gets the current class name
  21557. * @returns the class name
  21558. */
  21559. getClassName(): string;
  21560. /**
  21561. * Gets the intensity input component
  21562. */
  21563. get intensity(): NodeMaterialConnectionPoint;
  21564. /**
  21565. * Gets the index of refraction input component
  21566. */
  21567. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21568. /**
  21569. * Gets the tint at distance input component
  21570. */
  21571. get tintAtDistance(): NodeMaterialConnectionPoint;
  21572. /**
  21573. * Gets the view input component
  21574. */
  21575. get view(): NodeMaterialConnectionPoint;
  21576. /**
  21577. * Gets the refraction object output component
  21578. */
  21579. get refraction(): NodeMaterialConnectionPoint;
  21580. /**
  21581. * Returns true if the block has a texture
  21582. */
  21583. get hasTexture(): boolean;
  21584. protected _getTexture(): Nullable<BaseTexture>;
  21585. autoConfigure(material: NodeMaterial): void;
  21586. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21587. isReady(): boolean;
  21588. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21589. /**
  21590. * Gets the main code of the block (fragment side)
  21591. * @param state current state of the node material building
  21592. * @returns the shader code
  21593. */
  21594. getCode(state: NodeMaterialBuildState): string;
  21595. protected _buildBlock(state: NodeMaterialBuildState): this;
  21596. protected _dumpPropertiesCode(): string;
  21597. serialize(): any;
  21598. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21599. }
  21600. }
  21601. declare module BABYLON {
  21602. /**
  21603. * Base block used as input for post process
  21604. */
  21605. export class CurrentScreenBlock extends NodeMaterialBlock {
  21606. private _samplerName;
  21607. private _linearDefineName;
  21608. private _gammaDefineName;
  21609. private _mainUVName;
  21610. private _tempTextureRead;
  21611. /**
  21612. * Gets or sets the texture associated with the node
  21613. */
  21614. texture: Nullable<BaseTexture>;
  21615. /**
  21616. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21617. */
  21618. convertToGammaSpace: boolean;
  21619. /**
  21620. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21621. */
  21622. convertToLinearSpace: boolean;
  21623. /**
  21624. * Create a new CurrentScreenBlock
  21625. * @param name defines the block name
  21626. */
  21627. constructor(name: string);
  21628. /**
  21629. * Gets the current class name
  21630. * @returns the class name
  21631. */
  21632. getClassName(): string;
  21633. /**
  21634. * Gets the uv input component
  21635. */
  21636. get uv(): NodeMaterialConnectionPoint;
  21637. /**
  21638. * Gets the rgba output component
  21639. */
  21640. get rgba(): NodeMaterialConnectionPoint;
  21641. /**
  21642. * Gets the rgb output component
  21643. */
  21644. get rgb(): NodeMaterialConnectionPoint;
  21645. /**
  21646. * Gets the r output component
  21647. */
  21648. get r(): NodeMaterialConnectionPoint;
  21649. /**
  21650. * Gets the g output component
  21651. */
  21652. get g(): NodeMaterialConnectionPoint;
  21653. /**
  21654. * Gets the b output component
  21655. */
  21656. get b(): NodeMaterialConnectionPoint;
  21657. /**
  21658. * Gets the a output component
  21659. */
  21660. get a(): NodeMaterialConnectionPoint;
  21661. /**
  21662. * Initialize the block and prepare the context for build
  21663. * @param state defines the state that will be used for the build
  21664. */
  21665. initialize(state: NodeMaterialBuildState): void;
  21666. get target(): NodeMaterialBlockTargets;
  21667. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21668. isReady(): boolean;
  21669. private _injectVertexCode;
  21670. private _writeTextureRead;
  21671. private _writeOutput;
  21672. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21673. serialize(): any;
  21674. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21675. }
  21676. }
  21677. declare module BABYLON {
  21678. /**
  21679. * Base block used for the particle texture
  21680. */
  21681. export class ParticleTextureBlock extends NodeMaterialBlock {
  21682. private _samplerName;
  21683. private _linearDefineName;
  21684. private _gammaDefineName;
  21685. private _tempTextureRead;
  21686. /**
  21687. * Gets or sets the texture associated with the node
  21688. */
  21689. texture: Nullable<BaseTexture>;
  21690. /**
  21691. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21692. */
  21693. convertToGammaSpace: boolean;
  21694. /**
  21695. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21696. */
  21697. convertToLinearSpace: boolean;
  21698. /**
  21699. * Create a new ParticleTextureBlock
  21700. * @param name defines the block name
  21701. */
  21702. constructor(name: string);
  21703. /**
  21704. * Gets the current class name
  21705. * @returns the class name
  21706. */
  21707. getClassName(): string;
  21708. /**
  21709. * Gets the uv input component
  21710. */
  21711. get uv(): NodeMaterialConnectionPoint;
  21712. /**
  21713. * Gets the rgba output component
  21714. */
  21715. get rgba(): NodeMaterialConnectionPoint;
  21716. /**
  21717. * Gets the rgb output component
  21718. */
  21719. get rgb(): NodeMaterialConnectionPoint;
  21720. /**
  21721. * Gets the r output component
  21722. */
  21723. get r(): NodeMaterialConnectionPoint;
  21724. /**
  21725. * Gets the g output component
  21726. */
  21727. get g(): NodeMaterialConnectionPoint;
  21728. /**
  21729. * Gets the b output component
  21730. */
  21731. get b(): NodeMaterialConnectionPoint;
  21732. /**
  21733. * Gets the a output component
  21734. */
  21735. get a(): NodeMaterialConnectionPoint;
  21736. /**
  21737. * Initialize the block and prepare the context for build
  21738. * @param state defines the state that will be used for the build
  21739. */
  21740. initialize(state: NodeMaterialBuildState): void;
  21741. autoConfigure(material: NodeMaterial): void;
  21742. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21743. isReady(): boolean;
  21744. private _writeOutput;
  21745. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21746. serialize(): any;
  21747. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21748. }
  21749. }
  21750. declare module BABYLON {
  21751. /**
  21752. * Class used to store shared data between 2 NodeMaterialBuildState
  21753. */
  21754. export class NodeMaterialBuildStateSharedData {
  21755. /**
  21756. * Gets the list of emitted varyings
  21757. */
  21758. temps: string[];
  21759. /**
  21760. * Gets the list of emitted varyings
  21761. */
  21762. varyings: string[];
  21763. /**
  21764. * Gets the varying declaration string
  21765. */
  21766. varyingDeclaration: string;
  21767. /**
  21768. * Input blocks
  21769. */
  21770. inputBlocks: InputBlock[];
  21771. /**
  21772. * Input blocks
  21773. */
  21774. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21775. /**
  21776. * Bindable blocks (Blocks that need to set data to the effect)
  21777. */
  21778. bindableBlocks: NodeMaterialBlock[];
  21779. /**
  21780. * List of blocks that can provide a compilation fallback
  21781. */
  21782. blocksWithFallbacks: NodeMaterialBlock[];
  21783. /**
  21784. * List of blocks that can provide a define update
  21785. */
  21786. blocksWithDefines: NodeMaterialBlock[];
  21787. /**
  21788. * List of blocks that can provide a repeatable content
  21789. */
  21790. repeatableContentBlocks: NodeMaterialBlock[];
  21791. /**
  21792. * List of blocks that can provide a dynamic list of uniforms
  21793. */
  21794. dynamicUniformBlocks: NodeMaterialBlock[];
  21795. /**
  21796. * List of blocks that can block the isReady function for the material
  21797. */
  21798. blockingBlocks: NodeMaterialBlock[];
  21799. /**
  21800. * Gets the list of animated inputs
  21801. */
  21802. animatedInputs: InputBlock[];
  21803. /**
  21804. * Build Id used to avoid multiple recompilations
  21805. */
  21806. buildId: number;
  21807. /** List of emitted variables */
  21808. variableNames: {
  21809. [key: string]: number;
  21810. };
  21811. /** List of emitted defines */
  21812. defineNames: {
  21813. [key: string]: number;
  21814. };
  21815. /** Should emit comments? */
  21816. emitComments: boolean;
  21817. /** Emit build activity */
  21818. verbose: boolean;
  21819. /** Gets or sets the hosting scene */
  21820. scene: Scene;
  21821. /**
  21822. * Gets the compilation hints emitted at compilation time
  21823. */
  21824. hints: {
  21825. needWorldViewMatrix: boolean;
  21826. needWorldViewProjectionMatrix: boolean;
  21827. needAlphaBlending: boolean;
  21828. needAlphaTesting: boolean;
  21829. };
  21830. /**
  21831. * List of compilation checks
  21832. */
  21833. checks: {
  21834. emitVertex: boolean;
  21835. emitFragment: boolean;
  21836. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21837. };
  21838. /**
  21839. * Is vertex program allowed to be empty?
  21840. */
  21841. allowEmptyVertexProgram: boolean;
  21842. /** Creates a new shared data */
  21843. constructor();
  21844. /**
  21845. * Emits console errors and exceptions if there is a failing check
  21846. */
  21847. emitErrors(): void;
  21848. }
  21849. }
  21850. declare module BABYLON {
  21851. /**
  21852. * Class used to store node based material build state
  21853. */
  21854. export class NodeMaterialBuildState {
  21855. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21856. supportUniformBuffers: boolean;
  21857. /**
  21858. * Gets the list of emitted attributes
  21859. */
  21860. attributes: string[];
  21861. /**
  21862. * Gets the list of emitted uniforms
  21863. */
  21864. uniforms: string[];
  21865. /**
  21866. * Gets the list of emitted constants
  21867. */
  21868. constants: string[];
  21869. /**
  21870. * Gets the list of emitted samplers
  21871. */
  21872. samplers: string[];
  21873. /**
  21874. * Gets the list of emitted functions
  21875. */
  21876. functions: {
  21877. [key: string]: string;
  21878. };
  21879. /**
  21880. * Gets the list of emitted extensions
  21881. */
  21882. extensions: {
  21883. [key: string]: string;
  21884. };
  21885. /**
  21886. * Gets the target of the compilation state
  21887. */
  21888. target: NodeMaterialBlockTargets;
  21889. /**
  21890. * Gets the list of emitted counters
  21891. */
  21892. counters: {
  21893. [key: string]: number;
  21894. };
  21895. /**
  21896. * Shared data between multiple NodeMaterialBuildState instances
  21897. */
  21898. sharedData: NodeMaterialBuildStateSharedData;
  21899. /** @hidden */
  21900. _vertexState: NodeMaterialBuildState;
  21901. /** @hidden */
  21902. _attributeDeclaration: string;
  21903. /** @hidden */
  21904. _uniformDeclaration: string;
  21905. /** @hidden */
  21906. _constantDeclaration: string;
  21907. /** @hidden */
  21908. _samplerDeclaration: string;
  21909. /** @hidden */
  21910. _varyingTransfer: string;
  21911. /** @hidden */
  21912. _injectAtEnd: string;
  21913. private _repeatableContentAnchorIndex;
  21914. /** @hidden */
  21915. _builtCompilationString: string;
  21916. /**
  21917. * Gets the emitted compilation strings
  21918. */
  21919. compilationString: string;
  21920. /**
  21921. * Finalize the compilation strings
  21922. * @param state defines the current compilation state
  21923. */
  21924. finalize(state: NodeMaterialBuildState): void;
  21925. /** @hidden */
  21926. get _repeatableContentAnchor(): string;
  21927. /** @hidden */
  21928. _getFreeVariableName(prefix: string): string;
  21929. /** @hidden */
  21930. _getFreeDefineName(prefix: string): string;
  21931. /** @hidden */
  21932. _excludeVariableName(name: string): void;
  21933. /** @hidden */
  21934. _emit2DSampler(name: string): void;
  21935. /** @hidden */
  21936. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21937. /** @hidden */
  21938. _emitExtension(name: string, extension: string, define?: string): void;
  21939. /** @hidden */
  21940. _emitFunction(name: string, code: string, comments: string): void;
  21941. /** @hidden */
  21942. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21943. replaceStrings?: {
  21944. search: RegExp;
  21945. replace: string;
  21946. }[];
  21947. repeatKey?: string;
  21948. }): string;
  21949. /** @hidden */
  21950. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21951. repeatKey?: string;
  21952. removeAttributes?: boolean;
  21953. removeUniforms?: boolean;
  21954. removeVaryings?: boolean;
  21955. removeIfDef?: boolean;
  21956. replaceStrings?: {
  21957. search: RegExp;
  21958. replace: string;
  21959. }[];
  21960. }, storeKey?: string): void;
  21961. /** @hidden */
  21962. _registerTempVariable(name: string): boolean;
  21963. /** @hidden */
  21964. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21965. /** @hidden */
  21966. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21967. /** @hidden */
  21968. _emitFloat(value: number): string;
  21969. }
  21970. }
  21971. declare module BABYLON {
  21972. /**
  21973. * Helper class used to generate session unique ID
  21974. */
  21975. export class UniqueIdGenerator {
  21976. private static _UniqueIdCounter;
  21977. /**
  21978. * Gets an unique (relatively to the current scene) Id
  21979. */
  21980. static get UniqueId(): number;
  21981. }
  21982. }
  21983. declare module BABYLON {
  21984. /**
  21985. * Defines a block that can be used inside a node based material
  21986. */
  21987. export class NodeMaterialBlock {
  21988. private _buildId;
  21989. private _buildTarget;
  21990. private _target;
  21991. private _isFinalMerger;
  21992. private _isInput;
  21993. private _name;
  21994. protected _isUnique: boolean;
  21995. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21996. inputsAreExclusive: boolean;
  21997. /** @hidden */
  21998. _codeVariableName: string;
  21999. /** @hidden */
  22000. _inputs: NodeMaterialConnectionPoint[];
  22001. /** @hidden */
  22002. _outputs: NodeMaterialConnectionPoint[];
  22003. /** @hidden */
  22004. _preparationId: number;
  22005. /**
  22006. * Gets the name of the block
  22007. */
  22008. get name(): string;
  22009. /**
  22010. * Sets the name of the block. Will check if the name is valid.
  22011. */
  22012. set name(newName: string);
  22013. /**
  22014. * Gets or sets the unique id of the node
  22015. */
  22016. uniqueId: number;
  22017. /**
  22018. * Gets or sets the comments associated with this block
  22019. */
  22020. comments: string;
  22021. /**
  22022. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22023. */
  22024. get isUnique(): boolean;
  22025. /**
  22026. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22027. */
  22028. get isFinalMerger(): boolean;
  22029. /**
  22030. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22031. */
  22032. get isInput(): boolean;
  22033. /**
  22034. * Gets or sets the build Id
  22035. */
  22036. get buildId(): number;
  22037. set buildId(value: number);
  22038. /**
  22039. * Gets or sets the target of the block
  22040. */
  22041. get target(): NodeMaterialBlockTargets;
  22042. set target(value: NodeMaterialBlockTargets);
  22043. /**
  22044. * Gets the list of input points
  22045. */
  22046. get inputs(): NodeMaterialConnectionPoint[];
  22047. /** Gets the list of output points */
  22048. get outputs(): NodeMaterialConnectionPoint[];
  22049. /**
  22050. * Find an input by its name
  22051. * @param name defines the name of the input to look for
  22052. * @returns the input or null if not found
  22053. */
  22054. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22055. /**
  22056. * Find an output by its name
  22057. * @param name defines the name of the outputto look for
  22058. * @returns the output or null if not found
  22059. */
  22060. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22061. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22062. visibleInInspector: boolean;
  22063. /**
  22064. * Creates a new NodeMaterialBlock
  22065. * @param name defines the block name
  22066. * @param target defines the target of that block (Vertex by default)
  22067. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22068. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22069. */
  22070. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22071. /**
  22072. * Initialize the block and prepare the context for build
  22073. * @param state defines the state that will be used for the build
  22074. */
  22075. initialize(state: NodeMaterialBuildState): void;
  22076. /**
  22077. * Bind data to effect. Will only be called for blocks with isBindable === true
  22078. * @param effect defines the effect to bind data to
  22079. * @param nodeMaterial defines the hosting NodeMaterial
  22080. * @param mesh defines the mesh that will be rendered
  22081. * @param subMesh defines the submesh that will be rendered
  22082. */
  22083. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22084. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22085. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22086. protected _writeFloat(value: number): string;
  22087. /**
  22088. * Gets the current class name e.g. "NodeMaterialBlock"
  22089. * @returns the class name
  22090. */
  22091. getClassName(): string;
  22092. /**
  22093. * Register a new input. Must be called inside a block constructor
  22094. * @param name defines the connection point name
  22095. * @param type defines the connection point type
  22096. * @param isOptional defines a boolean indicating that this input can be omitted
  22097. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22098. * @param point an already created connection point. If not provided, create a new one
  22099. * @returns the current block
  22100. */
  22101. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22102. /**
  22103. * Register a new output. Must be called inside a block constructor
  22104. * @param name defines the connection point name
  22105. * @param type defines the connection point type
  22106. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22107. * @param point an already created connection point. If not provided, create a new one
  22108. * @returns the current block
  22109. */
  22110. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22111. /**
  22112. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22113. * @param forOutput defines an optional connection point to check compatibility with
  22114. * @returns the first available input or null
  22115. */
  22116. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22117. /**
  22118. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22119. * @param forBlock defines an optional block to check compatibility with
  22120. * @returns the first available input or null
  22121. */
  22122. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22123. /**
  22124. * Gets the sibling of the given output
  22125. * @param current defines the current output
  22126. * @returns the next output in the list or null
  22127. */
  22128. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22129. /**
  22130. * Connect current block with another block
  22131. * @param other defines the block to connect with
  22132. * @param options define the various options to help pick the right connections
  22133. * @returns the current block
  22134. */
  22135. connectTo(other: NodeMaterialBlock, options?: {
  22136. input?: string;
  22137. output?: string;
  22138. outputSwizzle?: string;
  22139. }): this | undefined;
  22140. protected _buildBlock(state: NodeMaterialBuildState): void;
  22141. /**
  22142. * Add uniforms, samplers and uniform buffers at compilation time
  22143. * @param state defines the state to update
  22144. * @param nodeMaterial defines the node material requesting the update
  22145. * @param defines defines the material defines to update
  22146. * @param uniformBuffers defines the list of uniform buffer names
  22147. */
  22148. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22149. /**
  22150. * Add potential fallbacks if shader compilation fails
  22151. * @param mesh defines the mesh to be rendered
  22152. * @param fallbacks defines the current prioritized list of fallbacks
  22153. */
  22154. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22155. /**
  22156. * Initialize defines for shader compilation
  22157. * @param mesh defines the mesh to be rendered
  22158. * @param nodeMaterial defines the node material requesting the update
  22159. * @param defines defines the material defines to update
  22160. * @param useInstances specifies that instances should be used
  22161. */
  22162. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22163. /**
  22164. * Update defines for shader compilation
  22165. * @param mesh defines the mesh to be rendered
  22166. * @param nodeMaterial defines the node material requesting the update
  22167. * @param defines defines the material defines to update
  22168. * @param useInstances specifies that instances should be used
  22169. * @param subMesh defines which submesh to render
  22170. */
  22171. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22172. /**
  22173. * Lets the block try to connect some inputs automatically
  22174. * @param material defines the hosting NodeMaterial
  22175. */
  22176. autoConfigure(material: NodeMaterial): void;
  22177. /**
  22178. * Function called when a block is declared as repeatable content generator
  22179. * @param vertexShaderState defines the current compilation state for the vertex shader
  22180. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22181. * @param mesh defines the mesh to be rendered
  22182. * @param defines defines the material defines to update
  22183. */
  22184. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22185. /**
  22186. * Checks if the block is ready
  22187. * @param mesh defines the mesh to be rendered
  22188. * @param nodeMaterial defines the node material requesting the update
  22189. * @param defines defines the material defines to update
  22190. * @param useInstances specifies that instances should be used
  22191. * @returns true if the block is ready
  22192. */
  22193. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22194. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  22195. private _processBuild;
  22196. /**
  22197. * Validates the new name for the block node.
  22198. * @param newName the new name to be given to the node.
  22199. * @returns false if the name is a reserve word, else true.
  22200. */
  22201. validateBlockName(newName: string): boolean;
  22202. /**
  22203. * Compile the current node and generate the shader code
  22204. * @param state defines the current compilation state (uniforms, samplers, current string)
  22205. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22206. * @returns true if already built
  22207. */
  22208. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22209. protected _inputRename(name: string): string;
  22210. protected _outputRename(name: string): string;
  22211. protected _dumpPropertiesCode(): string;
  22212. /** @hidden */
  22213. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22214. /** @hidden */
  22215. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22216. /**
  22217. * Clone the current block to a new identical block
  22218. * @param scene defines the hosting scene
  22219. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22220. * @returns a copy of the current block
  22221. */
  22222. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22223. /**
  22224. * Serializes this block in a JSON representation
  22225. * @returns the serialized block object
  22226. */
  22227. serialize(): any;
  22228. /** @hidden */
  22229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22230. private _deserializePortDisplayNamesAndExposedOnFrame;
  22231. /**
  22232. * Release resources
  22233. */
  22234. dispose(): void;
  22235. }
  22236. }
  22237. declare module BABYLON {
  22238. /**
  22239. * Base class of materials working in push mode in babylon JS
  22240. * @hidden
  22241. */
  22242. export class PushMaterial extends Material {
  22243. protected _activeEffect: Effect;
  22244. protected _normalMatrix: Matrix;
  22245. constructor(name: string, scene: Scene);
  22246. getEffect(): Effect;
  22247. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22248. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22249. /**
  22250. * Binds the given world matrix to the active effect
  22251. *
  22252. * @param world the matrix to bind
  22253. */
  22254. bindOnlyWorldMatrix(world: Matrix): void;
  22255. /**
  22256. * Binds the given normal matrix to the active effect
  22257. *
  22258. * @param normalMatrix the matrix to bind
  22259. */
  22260. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22261. bind(world: Matrix, mesh?: Mesh): void;
  22262. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22263. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22264. }
  22265. }
  22266. declare module BABYLON {
  22267. /**
  22268. * Root class for all node material optimizers
  22269. */
  22270. export class NodeMaterialOptimizer {
  22271. /**
  22272. * Function used to optimize a NodeMaterial graph
  22273. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22274. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22275. */
  22276. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22277. }
  22278. }
  22279. declare module BABYLON {
  22280. /**
  22281. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22282. */
  22283. export class TransformBlock extends NodeMaterialBlock {
  22284. /**
  22285. * Defines the value to use to complement W value to transform it to a Vector4
  22286. */
  22287. complementW: number;
  22288. /**
  22289. * Defines the value to use to complement z value to transform it to a Vector4
  22290. */
  22291. complementZ: number;
  22292. /**
  22293. * Creates a new TransformBlock
  22294. * @param name defines the block name
  22295. */
  22296. constructor(name: string);
  22297. /**
  22298. * Gets the current class name
  22299. * @returns the class name
  22300. */
  22301. getClassName(): string;
  22302. /**
  22303. * Gets the vector input
  22304. */
  22305. get vector(): NodeMaterialConnectionPoint;
  22306. /**
  22307. * Gets the output component
  22308. */
  22309. get output(): NodeMaterialConnectionPoint;
  22310. /**
  22311. * Gets the xyz output component
  22312. */
  22313. get xyz(): NodeMaterialConnectionPoint;
  22314. /**
  22315. * Gets the matrix transform input
  22316. */
  22317. get transform(): NodeMaterialConnectionPoint;
  22318. protected _buildBlock(state: NodeMaterialBuildState): this;
  22319. /**
  22320. * Update defines for shader compilation
  22321. * @param mesh defines the mesh to be rendered
  22322. * @param nodeMaterial defines the node material requesting the update
  22323. * @param defines defines the material defines to update
  22324. * @param useInstances specifies that instances should be used
  22325. * @param subMesh defines which submesh to render
  22326. */
  22327. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22328. serialize(): any;
  22329. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22330. protected _dumpPropertiesCode(): string;
  22331. }
  22332. }
  22333. declare module BABYLON {
  22334. /**
  22335. * Block used to output the vertex position
  22336. */
  22337. export class VertexOutputBlock extends NodeMaterialBlock {
  22338. /**
  22339. * Creates a new VertexOutputBlock
  22340. * @param name defines the block name
  22341. */
  22342. constructor(name: string);
  22343. /**
  22344. * Gets the current class name
  22345. * @returns the class name
  22346. */
  22347. getClassName(): string;
  22348. /**
  22349. * Gets the vector input component
  22350. */
  22351. get vector(): NodeMaterialConnectionPoint;
  22352. protected _buildBlock(state: NodeMaterialBuildState): this;
  22353. }
  22354. }
  22355. declare module BABYLON {
  22356. /**
  22357. * Block used to output the final color
  22358. */
  22359. export class FragmentOutputBlock extends NodeMaterialBlock {
  22360. /**
  22361. * Create a new FragmentOutputBlock
  22362. * @param name defines the block name
  22363. */
  22364. constructor(name: string);
  22365. /**
  22366. * Gets the current class name
  22367. * @returns the class name
  22368. */
  22369. getClassName(): string;
  22370. /**
  22371. * Gets the rgba input component
  22372. */
  22373. get rgba(): NodeMaterialConnectionPoint;
  22374. /**
  22375. * Gets the rgb input component
  22376. */
  22377. get rgb(): NodeMaterialConnectionPoint;
  22378. /**
  22379. * Gets the a input component
  22380. */
  22381. get a(): NodeMaterialConnectionPoint;
  22382. protected _buildBlock(state: NodeMaterialBuildState): this;
  22383. }
  22384. }
  22385. declare module BABYLON {
  22386. /**
  22387. * Block used for the particle ramp gradient section
  22388. */
  22389. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22390. /**
  22391. * Create a new ParticleRampGradientBlock
  22392. * @param name defines the block name
  22393. */
  22394. constructor(name: string);
  22395. /**
  22396. * Gets the current class name
  22397. * @returns the class name
  22398. */
  22399. getClassName(): string;
  22400. /**
  22401. * Gets the color input component
  22402. */
  22403. get color(): NodeMaterialConnectionPoint;
  22404. /**
  22405. * Gets the rampColor output component
  22406. */
  22407. get rampColor(): NodeMaterialConnectionPoint;
  22408. /**
  22409. * Initialize the block and prepare the context for build
  22410. * @param state defines the state that will be used for the build
  22411. */
  22412. initialize(state: NodeMaterialBuildState): void;
  22413. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22414. }
  22415. }
  22416. declare module BABYLON {
  22417. /**
  22418. * Block used for the particle blend multiply section
  22419. */
  22420. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22421. /**
  22422. * Create a new ParticleBlendMultiplyBlock
  22423. * @param name defines the block name
  22424. */
  22425. constructor(name: string);
  22426. /**
  22427. * Gets the current class name
  22428. * @returns the class name
  22429. */
  22430. getClassName(): string;
  22431. /**
  22432. * Gets the color input component
  22433. */
  22434. get color(): NodeMaterialConnectionPoint;
  22435. /**
  22436. * Gets the alphaTexture input component
  22437. */
  22438. get alphaTexture(): NodeMaterialConnectionPoint;
  22439. /**
  22440. * Gets the alphaColor input component
  22441. */
  22442. get alphaColor(): NodeMaterialConnectionPoint;
  22443. /**
  22444. * Gets the blendColor output component
  22445. */
  22446. get blendColor(): NodeMaterialConnectionPoint;
  22447. /**
  22448. * Initialize the block and prepare the context for build
  22449. * @param state defines the state that will be used for the build
  22450. */
  22451. initialize(state: NodeMaterialBuildState): void;
  22452. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22453. }
  22454. }
  22455. declare module BABYLON {
  22456. /**
  22457. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22458. */
  22459. export class VectorMergerBlock extends NodeMaterialBlock {
  22460. /**
  22461. * Create a new VectorMergerBlock
  22462. * @param name defines the block name
  22463. */
  22464. constructor(name: string);
  22465. /**
  22466. * Gets the current class name
  22467. * @returns the class name
  22468. */
  22469. getClassName(): string;
  22470. /**
  22471. * Gets the xyz component (input)
  22472. */
  22473. get xyzIn(): NodeMaterialConnectionPoint;
  22474. /**
  22475. * Gets the xy component (input)
  22476. */
  22477. get xyIn(): NodeMaterialConnectionPoint;
  22478. /**
  22479. * Gets the x component (input)
  22480. */
  22481. get x(): NodeMaterialConnectionPoint;
  22482. /**
  22483. * Gets the y component (input)
  22484. */
  22485. get y(): NodeMaterialConnectionPoint;
  22486. /**
  22487. * Gets the z component (input)
  22488. */
  22489. get z(): NodeMaterialConnectionPoint;
  22490. /**
  22491. * Gets the w component (input)
  22492. */
  22493. get w(): NodeMaterialConnectionPoint;
  22494. /**
  22495. * Gets the xyzw component (output)
  22496. */
  22497. get xyzw(): NodeMaterialConnectionPoint;
  22498. /**
  22499. * Gets the xyz component (output)
  22500. */
  22501. get xyzOut(): NodeMaterialConnectionPoint;
  22502. /**
  22503. * Gets the xy component (output)
  22504. */
  22505. get xyOut(): NodeMaterialConnectionPoint;
  22506. /**
  22507. * Gets the xy component (output)
  22508. * @deprecated Please use xyOut instead.
  22509. */
  22510. get xy(): NodeMaterialConnectionPoint;
  22511. /**
  22512. * Gets the xyz component (output)
  22513. * @deprecated Please use xyzOut instead.
  22514. */
  22515. get xyz(): NodeMaterialConnectionPoint;
  22516. protected _buildBlock(state: NodeMaterialBuildState): this;
  22517. }
  22518. }
  22519. declare module BABYLON {
  22520. /**
  22521. * Block used to remap a float from a range to a new one
  22522. */
  22523. export class RemapBlock extends NodeMaterialBlock {
  22524. /**
  22525. * Gets or sets the source range
  22526. */
  22527. sourceRange: Vector2;
  22528. /**
  22529. * Gets or sets the target range
  22530. */
  22531. targetRange: Vector2;
  22532. /**
  22533. * Creates a new RemapBlock
  22534. * @param name defines the block name
  22535. */
  22536. constructor(name: string);
  22537. /**
  22538. * Gets the current class name
  22539. * @returns the class name
  22540. */
  22541. getClassName(): string;
  22542. /**
  22543. * Gets the input component
  22544. */
  22545. get input(): NodeMaterialConnectionPoint;
  22546. /**
  22547. * Gets the source min input component
  22548. */
  22549. get sourceMin(): NodeMaterialConnectionPoint;
  22550. /**
  22551. * Gets the source max input component
  22552. */
  22553. get sourceMax(): NodeMaterialConnectionPoint;
  22554. /**
  22555. * Gets the target min input component
  22556. */
  22557. get targetMin(): NodeMaterialConnectionPoint;
  22558. /**
  22559. * Gets the target max input component
  22560. */
  22561. get targetMax(): NodeMaterialConnectionPoint;
  22562. /**
  22563. * Gets the output component
  22564. */
  22565. get output(): NodeMaterialConnectionPoint;
  22566. protected _buildBlock(state: NodeMaterialBuildState): this;
  22567. protected _dumpPropertiesCode(): string;
  22568. serialize(): any;
  22569. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22570. }
  22571. }
  22572. declare module BABYLON {
  22573. /**
  22574. * Block used to multiply 2 values
  22575. */
  22576. export class MultiplyBlock extends NodeMaterialBlock {
  22577. /**
  22578. * Creates a new MultiplyBlock
  22579. * @param name defines the block name
  22580. */
  22581. constructor(name: string);
  22582. /**
  22583. * Gets the current class name
  22584. * @returns the class name
  22585. */
  22586. getClassName(): string;
  22587. /**
  22588. * Gets the left operand input component
  22589. */
  22590. get left(): NodeMaterialConnectionPoint;
  22591. /**
  22592. * Gets the right operand input component
  22593. */
  22594. get right(): NodeMaterialConnectionPoint;
  22595. /**
  22596. * Gets the output component
  22597. */
  22598. get output(): NodeMaterialConnectionPoint;
  22599. protected _buildBlock(state: NodeMaterialBuildState): this;
  22600. }
  22601. }
  22602. declare module BABYLON {
  22603. /**
  22604. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22605. */
  22606. export class ColorSplitterBlock extends NodeMaterialBlock {
  22607. /**
  22608. * Create a new ColorSplitterBlock
  22609. * @param name defines the block name
  22610. */
  22611. constructor(name: string);
  22612. /**
  22613. * Gets the current class name
  22614. * @returns the class name
  22615. */
  22616. getClassName(): string;
  22617. /**
  22618. * Gets the rgba component (input)
  22619. */
  22620. get rgba(): NodeMaterialConnectionPoint;
  22621. /**
  22622. * Gets the rgb component (input)
  22623. */
  22624. get rgbIn(): NodeMaterialConnectionPoint;
  22625. /**
  22626. * Gets the rgb component (output)
  22627. */
  22628. get rgbOut(): NodeMaterialConnectionPoint;
  22629. /**
  22630. * Gets the r component (output)
  22631. */
  22632. get r(): NodeMaterialConnectionPoint;
  22633. /**
  22634. * Gets the g component (output)
  22635. */
  22636. get g(): NodeMaterialConnectionPoint;
  22637. /**
  22638. * Gets the b component (output)
  22639. */
  22640. get b(): NodeMaterialConnectionPoint;
  22641. /**
  22642. * Gets the a component (output)
  22643. */
  22644. get a(): NodeMaterialConnectionPoint;
  22645. protected _inputRename(name: string): string;
  22646. protected _outputRename(name: string): string;
  22647. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22648. }
  22649. }
  22650. declare module BABYLON {
  22651. /**
  22652. * Operations supported by the Trigonometry block
  22653. */
  22654. export enum TrigonometryBlockOperations {
  22655. /** Cos */
  22656. Cos = 0,
  22657. /** Sin */
  22658. Sin = 1,
  22659. /** Abs */
  22660. Abs = 2,
  22661. /** Exp */
  22662. Exp = 3,
  22663. /** Exp2 */
  22664. Exp2 = 4,
  22665. /** Round */
  22666. Round = 5,
  22667. /** Floor */
  22668. Floor = 6,
  22669. /** Ceiling */
  22670. Ceiling = 7,
  22671. /** Square root */
  22672. Sqrt = 8,
  22673. /** Log */
  22674. Log = 9,
  22675. /** Tangent */
  22676. Tan = 10,
  22677. /** Arc tangent */
  22678. ArcTan = 11,
  22679. /** Arc cosinus */
  22680. ArcCos = 12,
  22681. /** Arc sinus */
  22682. ArcSin = 13,
  22683. /** Fraction */
  22684. Fract = 14,
  22685. /** Sign */
  22686. Sign = 15,
  22687. /** To radians (from degrees) */
  22688. Radians = 16,
  22689. /** To degrees (from radians) */
  22690. Degrees = 17
  22691. }
  22692. /**
  22693. * Block used to apply trigonometry operation to floats
  22694. */
  22695. export class TrigonometryBlock extends NodeMaterialBlock {
  22696. /**
  22697. * Gets or sets the operation applied by the block
  22698. */
  22699. operation: TrigonometryBlockOperations;
  22700. /**
  22701. * Creates a new TrigonometryBlock
  22702. * @param name defines the block name
  22703. */
  22704. constructor(name: string);
  22705. /**
  22706. * Gets the current class name
  22707. * @returns the class name
  22708. */
  22709. getClassName(): string;
  22710. /**
  22711. * Gets the input component
  22712. */
  22713. get input(): NodeMaterialConnectionPoint;
  22714. /**
  22715. * Gets the output component
  22716. */
  22717. get output(): NodeMaterialConnectionPoint;
  22718. protected _buildBlock(state: NodeMaterialBuildState): this;
  22719. serialize(): any;
  22720. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22721. protected _dumpPropertiesCode(): string;
  22722. }
  22723. }
  22724. declare module BABYLON {
  22725. /**
  22726. * Interface used to configure the node material editor
  22727. */
  22728. export interface INodeMaterialEditorOptions {
  22729. /** Define the URl to load node editor script */
  22730. editorURL?: string;
  22731. }
  22732. /** @hidden */
  22733. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22734. NORMAL: boolean;
  22735. TANGENT: boolean;
  22736. UV1: boolean;
  22737. /** BONES */
  22738. NUM_BONE_INFLUENCERS: number;
  22739. BonesPerMesh: number;
  22740. BONETEXTURE: boolean;
  22741. /** MORPH TARGETS */
  22742. MORPHTARGETS: boolean;
  22743. MORPHTARGETS_NORMAL: boolean;
  22744. MORPHTARGETS_TANGENT: boolean;
  22745. MORPHTARGETS_UV: boolean;
  22746. NUM_MORPH_INFLUENCERS: number;
  22747. /** IMAGE PROCESSING */
  22748. IMAGEPROCESSING: boolean;
  22749. VIGNETTE: boolean;
  22750. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22751. VIGNETTEBLENDMODEOPAQUE: boolean;
  22752. TONEMAPPING: boolean;
  22753. TONEMAPPING_ACES: boolean;
  22754. CONTRAST: boolean;
  22755. EXPOSURE: boolean;
  22756. COLORCURVES: boolean;
  22757. COLORGRADING: boolean;
  22758. COLORGRADING3D: boolean;
  22759. SAMPLER3DGREENDEPTH: boolean;
  22760. SAMPLER3DBGRMAP: boolean;
  22761. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22762. /** MISC. */
  22763. BUMPDIRECTUV: number;
  22764. constructor();
  22765. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22766. }
  22767. /**
  22768. * Class used to configure NodeMaterial
  22769. */
  22770. export interface INodeMaterialOptions {
  22771. /**
  22772. * Defines if blocks should emit comments
  22773. */
  22774. emitComments: boolean;
  22775. }
  22776. /**
  22777. * Class used to create a node based material built by assembling shader blocks
  22778. */
  22779. export class NodeMaterial extends PushMaterial {
  22780. private static _BuildIdGenerator;
  22781. private _options;
  22782. private _vertexCompilationState;
  22783. private _fragmentCompilationState;
  22784. private _sharedData;
  22785. private _buildId;
  22786. private _buildWasSuccessful;
  22787. private _cachedWorldViewMatrix;
  22788. private _cachedWorldViewProjectionMatrix;
  22789. private _optimizers;
  22790. private _animationFrame;
  22791. /** Define the Url to load node editor script */
  22792. static EditorURL: string;
  22793. /** Define the Url to load snippets */
  22794. static SnippetUrl: string;
  22795. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22796. static IgnoreTexturesAtLoadTime: boolean;
  22797. private BJSNODEMATERIALEDITOR;
  22798. /** Get the inspector from bundle or global */
  22799. private _getGlobalNodeMaterialEditor;
  22800. /**
  22801. * Snippet ID if the material was created from the snippet server
  22802. */
  22803. snippetId: string;
  22804. /**
  22805. * Gets or sets data used by visual editor
  22806. * @see https://nme.babylonjs.com
  22807. */
  22808. editorData: any;
  22809. /**
  22810. * 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)
  22811. */
  22812. ignoreAlpha: boolean;
  22813. /**
  22814. * Defines the maximum number of lights that can be used in the material
  22815. */
  22816. maxSimultaneousLights: number;
  22817. /**
  22818. * Observable raised when the material is built
  22819. */
  22820. onBuildObservable: Observable<NodeMaterial>;
  22821. /**
  22822. * Gets or sets the root nodes of the material vertex shader
  22823. */
  22824. _vertexOutputNodes: NodeMaterialBlock[];
  22825. /**
  22826. * Gets or sets the root nodes of the material fragment (pixel) shader
  22827. */
  22828. _fragmentOutputNodes: NodeMaterialBlock[];
  22829. /** Gets or sets options to control the node material overall behavior */
  22830. get options(): INodeMaterialOptions;
  22831. set options(options: INodeMaterialOptions);
  22832. /**
  22833. * Default configuration related to image processing available in the standard Material.
  22834. */
  22835. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22836. /**
  22837. * Gets the image processing configuration used either in this material.
  22838. */
  22839. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22840. /**
  22841. * Sets the Default image processing configuration used either in the this material.
  22842. *
  22843. * If sets to null, the scene one is in use.
  22844. */
  22845. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22846. /**
  22847. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22848. */
  22849. attachedBlocks: NodeMaterialBlock[];
  22850. /**
  22851. * Specifies the mode of the node material
  22852. * @hidden
  22853. */
  22854. _mode: NodeMaterialModes;
  22855. /**
  22856. * Gets the mode property
  22857. */
  22858. get mode(): NodeMaterialModes;
  22859. /**
  22860. * A free comment about the material
  22861. */
  22862. comment: string;
  22863. /**
  22864. * Create a new node based material
  22865. * @param name defines the material name
  22866. * @param scene defines the hosting scene
  22867. * @param options defines creation option
  22868. */
  22869. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22870. /**
  22871. * Gets the current class name of the material e.g. "NodeMaterial"
  22872. * @returns the class name
  22873. */
  22874. getClassName(): string;
  22875. /**
  22876. * Keep track of the image processing observer to allow dispose and replace.
  22877. */
  22878. private _imageProcessingObserver;
  22879. /**
  22880. * Attaches a new image processing configuration to the Standard Material.
  22881. * @param configuration
  22882. */
  22883. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22884. /**
  22885. * Get a block by its name
  22886. * @param name defines the name of the block to retrieve
  22887. * @returns the required block or null if not found
  22888. */
  22889. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22890. /**
  22891. * Get a block by its name
  22892. * @param predicate defines the predicate used to find the good candidate
  22893. * @returns the required block or null if not found
  22894. */
  22895. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22896. /**
  22897. * Get an input block by its name
  22898. * @param predicate defines the predicate used to find the good candidate
  22899. * @returns the required input block or null if not found
  22900. */
  22901. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22902. /**
  22903. * Gets the list of input blocks attached to this material
  22904. * @returns an array of InputBlocks
  22905. */
  22906. getInputBlocks(): InputBlock[];
  22907. /**
  22908. * Adds a new optimizer to the list of optimizers
  22909. * @param optimizer defines the optimizers to add
  22910. * @returns the current material
  22911. */
  22912. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22913. /**
  22914. * Remove an optimizer from the list of optimizers
  22915. * @param optimizer defines the optimizers to remove
  22916. * @returns the current material
  22917. */
  22918. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22919. /**
  22920. * Add a new block to the list of output nodes
  22921. * @param node defines the node to add
  22922. * @returns the current material
  22923. */
  22924. addOutputNode(node: NodeMaterialBlock): this;
  22925. /**
  22926. * Remove a block from the list of root nodes
  22927. * @param node defines the node to remove
  22928. * @returns the current material
  22929. */
  22930. removeOutputNode(node: NodeMaterialBlock): this;
  22931. private _addVertexOutputNode;
  22932. private _removeVertexOutputNode;
  22933. private _addFragmentOutputNode;
  22934. private _removeFragmentOutputNode;
  22935. /**
  22936. * Specifies if the material will require alpha blending
  22937. * @returns a boolean specifying if alpha blending is needed
  22938. */
  22939. needAlphaBlending(): boolean;
  22940. /**
  22941. * Specifies if this material should be rendered in alpha test mode
  22942. * @returns a boolean specifying if an alpha test is needed.
  22943. */
  22944. needAlphaTesting(): boolean;
  22945. private _initializeBlock;
  22946. private _resetDualBlocks;
  22947. /**
  22948. * Remove a block from the current node material
  22949. * @param block defines the block to remove
  22950. */
  22951. removeBlock(block: NodeMaterialBlock): void;
  22952. /**
  22953. * Build the material and generates the inner effect
  22954. * @param verbose defines if the build should log activity
  22955. */
  22956. build(verbose?: boolean): void;
  22957. /**
  22958. * Runs an otpimization phase to try to improve the shader code
  22959. */
  22960. optimize(): void;
  22961. private _prepareDefinesForAttributes;
  22962. /**
  22963. * Create a post process from the material
  22964. * @param camera The camera to apply the render pass to.
  22965. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22967. * @param engine The engine which the post process will be applied. (default: current engine)
  22968. * @param reusable If the post process can be reused on the same frame. (default: false)
  22969. * @param textureType Type of textures used when performing the post process. (default: 0)
  22970. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22971. * @returns the post process created
  22972. */
  22973. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22974. /**
  22975. * Create the post process effect from the material
  22976. * @param postProcess The post process to create the effect for
  22977. */
  22978. createEffectForPostProcess(postProcess: PostProcess): void;
  22979. private _createEffectForPostProcess;
  22980. /**
  22981. * Create a new procedural texture based on this node material
  22982. * @param size defines the size of the texture
  22983. * @param scene defines the hosting scene
  22984. * @returns the new procedural texture attached to this node material
  22985. */
  22986. createProceduralTexture(size: number | {
  22987. width: number;
  22988. height: number;
  22989. layers?: number;
  22990. }, scene: Scene): Nullable<ProceduralTexture>;
  22991. private _createEffectForParticles;
  22992. private _checkInternals;
  22993. /**
  22994. * Create the effect to be used as the custom effect for a particle system
  22995. * @param particleSystem Particle system to create the effect for
  22996. * @param onCompiled defines a function to call when the effect creation is successful
  22997. * @param onError defines a function to call when the effect creation has failed
  22998. */
  22999. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23000. private _processDefines;
  23001. /**
  23002. * Get if the submesh is ready to be used and all its information available.
  23003. * Child classes can use it to update shaders
  23004. * @param mesh defines the mesh to check
  23005. * @param subMesh defines which submesh to check
  23006. * @param useInstances specifies that instances should be used
  23007. * @returns a boolean indicating that the submesh is ready or not
  23008. */
  23009. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23010. /**
  23011. * Get a string representing the shaders built by the current node graph
  23012. */
  23013. get compiledShaders(): string;
  23014. /**
  23015. * Binds the world matrix to the material
  23016. * @param world defines the world transformation matrix
  23017. */
  23018. bindOnlyWorldMatrix(world: Matrix): void;
  23019. /**
  23020. * Binds the submesh to this material by preparing the effect and shader to draw
  23021. * @param world defines the world transformation matrix
  23022. * @param mesh defines the mesh containing the submesh
  23023. * @param subMesh defines the submesh to bind the material to
  23024. */
  23025. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23026. /**
  23027. * Gets the active textures from the material
  23028. * @returns an array of textures
  23029. */
  23030. getActiveTextures(): BaseTexture[];
  23031. /**
  23032. * Gets the list of texture blocks
  23033. * @returns an array of texture blocks
  23034. */
  23035. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23036. /**
  23037. * Specifies if the material uses a texture
  23038. * @param texture defines the texture to check against the material
  23039. * @returns a boolean specifying if the material uses the texture
  23040. */
  23041. hasTexture(texture: BaseTexture): boolean;
  23042. /**
  23043. * Disposes the material
  23044. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23045. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23046. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23047. */
  23048. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23049. /** Creates the node editor window. */
  23050. private _createNodeEditor;
  23051. /**
  23052. * Launch the node material editor
  23053. * @param config Define the configuration of the editor
  23054. * @return a promise fulfilled when the node editor is visible
  23055. */
  23056. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23057. /**
  23058. * Clear the current material
  23059. */
  23060. clear(): void;
  23061. /**
  23062. * Clear the current material and set it to a default state
  23063. */
  23064. setToDefault(): void;
  23065. /**
  23066. * Clear the current material and set it to a default state for post process
  23067. */
  23068. setToDefaultPostProcess(): void;
  23069. /**
  23070. * Clear the current material and set it to a default state for procedural texture
  23071. */
  23072. setToDefaultProceduralTexture(): void;
  23073. /**
  23074. * Clear the current material and set it to a default state for particle
  23075. */
  23076. setToDefaultParticle(): void;
  23077. /**
  23078. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23079. * @param url defines the url to load from
  23080. * @returns a promise that will fullfil when the material is fully loaded
  23081. */
  23082. loadAsync(url: string): Promise<void>;
  23083. private _gatherBlocks;
  23084. /**
  23085. * Generate a string containing the code declaration required to create an equivalent of this material
  23086. * @returns a string
  23087. */
  23088. generateCode(): string;
  23089. /**
  23090. * Serializes this material in a JSON representation
  23091. * @returns the serialized material object
  23092. */
  23093. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23094. private _restoreConnections;
  23095. /**
  23096. * Clear the current graph and load a new one from a serialization object
  23097. * @param source defines the JSON representation of the material
  23098. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23099. * @param merge defines whether or not the source must be merged or replace the current content
  23100. */
  23101. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23102. /**
  23103. * Makes a duplicate of the current material.
  23104. * @param name - name to use for the new material.
  23105. */
  23106. clone(name: string): NodeMaterial;
  23107. /**
  23108. * Creates a node material from parsed material data
  23109. * @param source defines the JSON representation of the material
  23110. * @param scene defines the hosting scene
  23111. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23112. * @returns a new node material
  23113. */
  23114. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23115. /**
  23116. * Creates a node material from a snippet saved in a remote file
  23117. * @param name defines the name of the material to create
  23118. * @param url defines the url to load from
  23119. * @param scene defines the hosting scene
  23120. * @returns a promise that will resolve to the new node material
  23121. */
  23122. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23123. /**
  23124. * Creates a node material from a snippet saved by the node material editor
  23125. * @param snippetId defines the snippet to load
  23126. * @param scene defines the hosting scene
  23127. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23128. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23129. * @returns a promise that will resolve to the new node material
  23130. */
  23131. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23132. /**
  23133. * Creates a new node material set to default basic configuration
  23134. * @param name defines the name of the material
  23135. * @param scene defines the hosting scene
  23136. * @returns a new NodeMaterial
  23137. */
  23138. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23139. }
  23140. }
  23141. declare module BABYLON {
  23142. interface ThinEngine {
  23143. /**
  23144. * Unbind a list of render target textures from the webGL context
  23145. * This is used only when drawBuffer extension or webGL2 are active
  23146. * @param textures defines the render target textures to unbind
  23147. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23148. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23149. */
  23150. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23151. /**
  23152. * Create a multi render target texture
  23153. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23154. * @param size defines the size of the texture
  23155. * @param options defines the creation options
  23156. * @returns the cube texture as an InternalTexture
  23157. */
  23158. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23159. /**
  23160. * Update the sample count for a given multiple render target texture
  23161. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23162. * @param textures defines the textures to update
  23163. * @param samples defines the sample count to set
  23164. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23165. */
  23166. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23167. /**
  23168. * Select a subsets of attachments to draw to.
  23169. * @param attachments gl attachments
  23170. */
  23171. bindAttachments(attachments: number[]): void;
  23172. /**
  23173. * Creates a layout object to draw/clear on specific textures in a MRT
  23174. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23175. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23176. */
  23177. buildTextureLayout(textureStatus: boolean[]): number[];
  23178. /**
  23179. * Restores the webgl state to only draw on the main color attachment
  23180. */
  23181. restoreSingleAttachment(): void;
  23182. }
  23183. }
  23184. declare module BABYLON {
  23185. /**
  23186. * Creation options of the multi render target texture.
  23187. */
  23188. export interface IMultiRenderTargetOptions {
  23189. /**
  23190. * Define if the texture needs to create mip maps after render.
  23191. */
  23192. generateMipMaps?: boolean;
  23193. /**
  23194. * Define the types of all the draw buffers we want to create
  23195. */
  23196. types?: number[];
  23197. /**
  23198. * Define the sampling modes of all the draw buffers we want to create
  23199. */
  23200. samplingModes?: number[];
  23201. /**
  23202. * Define if a depth buffer is required
  23203. */
  23204. generateDepthBuffer?: boolean;
  23205. /**
  23206. * Define if a stencil buffer is required
  23207. */
  23208. generateStencilBuffer?: boolean;
  23209. /**
  23210. * Define if a depth texture is required instead of a depth buffer
  23211. */
  23212. generateDepthTexture?: boolean;
  23213. /**
  23214. * Define the number of desired draw buffers
  23215. */
  23216. textureCount?: number;
  23217. /**
  23218. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23219. */
  23220. doNotChangeAspectRatio?: boolean;
  23221. /**
  23222. * Define the default type of the buffers we are creating
  23223. */
  23224. defaultType?: number;
  23225. }
  23226. /**
  23227. * A multi render target, like a render target provides the ability to render to a texture.
  23228. * Unlike the render target, it can render to several draw buffers in one draw.
  23229. * This is specially interesting in deferred rendering or for any effects requiring more than
  23230. * just one color from a single pass.
  23231. */
  23232. export class MultiRenderTarget extends RenderTargetTexture {
  23233. private _internalTextures;
  23234. private _textures;
  23235. private _multiRenderTargetOptions;
  23236. private _count;
  23237. /**
  23238. * Get if draw buffers are currently supported by the used hardware and browser.
  23239. */
  23240. get isSupported(): boolean;
  23241. /**
  23242. * Get the list of textures generated by the multi render target.
  23243. */
  23244. get textures(): Texture[];
  23245. /**
  23246. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23247. */
  23248. get count(): number;
  23249. /**
  23250. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23251. */
  23252. get depthTexture(): Texture;
  23253. /**
  23254. * Set the wrapping mode on U of all the textures we are rendering to.
  23255. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23256. */
  23257. set wrapU(wrap: number);
  23258. /**
  23259. * Set the wrapping mode on V of all the textures we are rendering to.
  23260. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23261. */
  23262. set wrapV(wrap: number);
  23263. /**
  23264. * Instantiate a new multi render target texture.
  23265. * A multi render target, like a render target provides the ability to render to a texture.
  23266. * Unlike the render target, it can render to several draw buffers in one draw.
  23267. * This is specially interesting in deferred rendering or for any effects requiring more than
  23268. * just one color from a single pass.
  23269. * @param name Define the name of the texture
  23270. * @param size Define the size of the buffers to render to
  23271. * @param count Define the number of target we are rendering into
  23272. * @param scene Define the scene the texture belongs to
  23273. * @param options Define the options used to create the multi render target
  23274. */
  23275. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23276. private _initTypes;
  23277. /** @hidden */
  23278. _rebuild(forceFullRebuild?: boolean): void;
  23279. private _createInternalTextures;
  23280. private _createTextures;
  23281. /**
  23282. * Replaces a texture within the MRT.
  23283. * @param texture The new texture to insert in the MRT
  23284. * @param index The index of the texture to replace
  23285. */
  23286. replaceTexture(texture: Texture, index: number): void;
  23287. /**
  23288. * Define the number of samples used if MSAA is enabled.
  23289. */
  23290. get samples(): number;
  23291. set samples(value: number);
  23292. /**
  23293. * Resize all the textures in the multi render target.
  23294. * Be careful as it will recreate all the data in the new texture.
  23295. * @param size Define the new size
  23296. */
  23297. resize(size: any): void;
  23298. /**
  23299. * Changes the number of render targets in this MRT
  23300. * Be careful as it will recreate all the data in the new texture.
  23301. * @param count new texture count
  23302. * @param options Specifies texture types and sampling modes for new textures
  23303. */
  23304. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23305. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23306. /**
  23307. * Dispose the render targets and their associated resources
  23308. */
  23309. dispose(): void;
  23310. /**
  23311. * Release all the underlying texture used as draw buffers.
  23312. */
  23313. releaseInternalTextures(): void;
  23314. }
  23315. }
  23316. declare module BABYLON {
  23317. /** @hidden */
  23318. export var imageProcessingPixelShader: {
  23319. name: string;
  23320. shader: string;
  23321. };
  23322. }
  23323. declare module BABYLON {
  23324. /**
  23325. * ImageProcessingPostProcess
  23326. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23327. */
  23328. export class ImageProcessingPostProcess extends PostProcess {
  23329. /**
  23330. * Default configuration related to image processing available in the PBR Material.
  23331. */
  23332. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23333. /**
  23334. * Gets the image processing configuration used either in this material.
  23335. */
  23336. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23337. /**
  23338. * Sets the Default image processing configuration used either in the this material.
  23339. *
  23340. * If sets to null, the scene one is in use.
  23341. */
  23342. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23343. /**
  23344. * Keep track of the image processing observer to allow dispose and replace.
  23345. */
  23346. private _imageProcessingObserver;
  23347. /**
  23348. * Attaches a new image processing configuration to the PBR Material.
  23349. * @param configuration
  23350. */
  23351. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23352. /**
  23353. * If the post process is supported.
  23354. */
  23355. get isSupported(): boolean;
  23356. /**
  23357. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23358. */
  23359. get colorCurves(): Nullable<ColorCurves>;
  23360. /**
  23361. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23362. */
  23363. set colorCurves(value: Nullable<ColorCurves>);
  23364. /**
  23365. * Gets wether the color curves effect is enabled.
  23366. */
  23367. get colorCurvesEnabled(): boolean;
  23368. /**
  23369. * Sets wether the color curves effect is enabled.
  23370. */
  23371. set colorCurvesEnabled(value: boolean);
  23372. /**
  23373. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23374. */
  23375. get colorGradingTexture(): Nullable<BaseTexture>;
  23376. /**
  23377. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23378. */
  23379. set colorGradingTexture(value: Nullable<BaseTexture>);
  23380. /**
  23381. * Gets wether the color grading effect is enabled.
  23382. */
  23383. get colorGradingEnabled(): boolean;
  23384. /**
  23385. * Gets wether the color grading effect is enabled.
  23386. */
  23387. set colorGradingEnabled(value: boolean);
  23388. /**
  23389. * Gets exposure used in the effect.
  23390. */
  23391. get exposure(): number;
  23392. /**
  23393. * Sets exposure used in the effect.
  23394. */
  23395. set exposure(value: number);
  23396. /**
  23397. * Gets wether tonemapping is enabled or not.
  23398. */
  23399. get toneMappingEnabled(): boolean;
  23400. /**
  23401. * Sets wether tonemapping is enabled or not
  23402. */
  23403. set toneMappingEnabled(value: boolean);
  23404. /**
  23405. * Gets the type of tone mapping effect.
  23406. */
  23407. get toneMappingType(): number;
  23408. /**
  23409. * Sets the type of tone mapping effect.
  23410. */
  23411. set toneMappingType(value: number);
  23412. /**
  23413. * Gets contrast used in the effect.
  23414. */
  23415. get contrast(): number;
  23416. /**
  23417. * Sets contrast used in the effect.
  23418. */
  23419. set contrast(value: number);
  23420. /**
  23421. * Gets Vignette stretch size.
  23422. */
  23423. get vignetteStretch(): number;
  23424. /**
  23425. * Sets Vignette stretch size.
  23426. */
  23427. set vignetteStretch(value: number);
  23428. /**
  23429. * Gets Vignette centre X Offset.
  23430. */
  23431. get vignetteCentreX(): number;
  23432. /**
  23433. * Sets Vignette centre X Offset.
  23434. */
  23435. set vignetteCentreX(value: number);
  23436. /**
  23437. * Gets Vignette centre Y Offset.
  23438. */
  23439. get vignetteCentreY(): number;
  23440. /**
  23441. * Sets Vignette centre Y Offset.
  23442. */
  23443. set vignetteCentreY(value: number);
  23444. /**
  23445. * Gets Vignette weight or intensity of the vignette effect.
  23446. */
  23447. get vignetteWeight(): number;
  23448. /**
  23449. * Sets Vignette weight or intensity of the vignette effect.
  23450. */
  23451. set vignetteWeight(value: number);
  23452. /**
  23453. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23454. * if vignetteEnabled is set to true.
  23455. */
  23456. get vignetteColor(): Color4;
  23457. /**
  23458. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23459. * if vignetteEnabled is set to true.
  23460. */
  23461. set vignetteColor(value: Color4);
  23462. /**
  23463. * Gets Camera field of view used by the Vignette effect.
  23464. */
  23465. get vignetteCameraFov(): number;
  23466. /**
  23467. * Sets Camera field of view used by the Vignette effect.
  23468. */
  23469. set vignetteCameraFov(value: number);
  23470. /**
  23471. * Gets the vignette blend mode allowing different kind of effect.
  23472. */
  23473. get vignetteBlendMode(): number;
  23474. /**
  23475. * Sets the vignette blend mode allowing different kind of effect.
  23476. */
  23477. set vignetteBlendMode(value: number);
  23478. /**
  23479. * Gets wether the vignette effect is enabled.
  23480. */
  23481. get vignetteEnabled(): boolean;
  23482. /**
  23483. * Sets wether the vignette effect is enabled.
  23484. */
  23485. set vignetteEnabled(value: boolean);
  23486. private _fromLinearSpace;
  23487. /**
  23488. * Gets wether the input of the processing is in Gamma or Linear Space.
  23489. */
  23490. get fromLinearSpace(): boolean;
  23491. /**
  23492. * Sets wether the input of the processing is in Gamma or Linear Space.
  23493. */
  23494. set fromLinearSpace(value: boolean);
  23495. /**
  23496. * Defines cache preventing GC.
  23497. */
  23498. private _defines;
  23499. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23500. /**
  23501. * "ImageProcessingPostProcess"
  23502. * @returns "ImageProcessingPostProcess"
  23503. */
  23504. getClassName(): string;
  23505. /**
  23506. * @hidden
  23507. */
  23508. _updateParameters(): void;
  23509. dispose(camera?: Camera): void;
  23510. }
  23511. }
  23512. declare module BABYLON {
  23513. /**
  23514. * Interface for defining prepass effects in the prepass post-process pipeline
  23515. */
  23516. export interface PrePassEffectConfiguration {
  23517. /**
  23518. * Name of the effect
  23519. */
  23520. name: string;
  23521. /**
  23522. * Post process to attach for this effect
  23523. */
  23524. postProcess?: PostProcess;
  23525. /**
  23526. * Textures required in the MRT
  23527. */
  23528. texturesRequired: number[];
  23529. /**
  23530. * Is the effect enabled
  23531. */
  23532. enabled: boolean;
  23533. /**
  23534. * Disposes the effect configuration
  23535. */
  23536. dispose?: () => void;
  23537. /**
  23538. * Creates the associated post process
  23539. */
  23540. createPostProcess?: () => PostProcess;
  23541. }
  23542. }
  23543. declare module BABYLON {
  23544. /**
  23545. * Options to be used when creating a FresnelParameters.
  23546. */
  23547. export type IFresnelParametersCreationOptions = {
  23548. /**
  23549. * Define the color used on edges (grazing angle)
  23550. */
  23551. leftColor?: Color3;
  23552. /**
  23553. * Define the color used on center
  23554. */
  23555. rightColor?: Color3;
  23556. /**
  23557. * Define bias applied to computed fresnel term
  23558. */
  23559. bias?: number;
  23560. /**
  23561. * Defined the power exponent applied to fresnel term
  23562. */
  23563. power?: number;
  23564. /**
  23565. * Define if the fresnel effect is enable or not.
  23566. */
  23567. isEnabled?: boolean;
  23568. };
  23569. /**
  23570. * Serialized format for FresnelParameters.
  23571. */
  23572. export type IFresnelParametersSerialized = {
  23573. /**
  23574. * Define the color used on edges (grazing angle) [as an array]
  23575. */
  23576. leftColor: number[];
  23577. /**
  23578. * Define the color used on center [as an array]
  23579. */
  23580. rightColor: number[];
  23581. /**
  23582. * Define bias applied to computed fresnel term
  23583. */
  23584. bias: number;
  23585. /**
  23586. * Defined the power exponent applied to fresnel term
  23587. */
  23588. power?: number;
  23589. /**
  23590. * Define if the fresnel effect is enable or not.
  23591. */
  23592. isEnabled: boolean;
  23593. };
  23594. /**
  23595. * This represents all the required information to add a fresnel effect on a material:
  23596. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23597. */
  23598. export class FresnelParameters {
  23599. private _isEnabled;
  23600. /**
  23601. * Define if the fresnel effect is enable or not.
  23602. */
  23603. get isEnabled(): boolean;
  23604. set isEnabled(value: boolean);
  23605. /**
  23606. * Define the color used on edges (grazing angle)
  23607. */
  23608. leftColor: Color3;
  23609. /**
  23610. * Define the color used on center
  23611. */
  23612. rightColor: Color3;
  23613. /**
  23614. * Define bias applied to computed fresnel term
  23615. */
  23616. bias: number;
  23617. /**
  23618. * Defined the power exponent applied to fresnel term
  23619. */
  23620. power: number;
  23621. /**
  23622. * Creates a new FresnelParameters object.
  23623. *
  23624. * @param options provide your own settings to optionally to override defaults
  23625. */
  23626. constructor(options?: IFresnelParametersCreationOptions);
  23627. /**
  23628. * Clones the current fresnel and its valuues
  23629. * @returns a clone fresnel configuration
  23630. */
  23631. clone(): FresnelParameters;
  23632. /**
  23633. * Determines equality between FresnelParameters objects
  23634. * @param otherFresnelParameters defines the second operand
  23635. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  23636. */
  23637. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  23638. /**
  23639. * Serializes the current fresnel parameters to a JSON representation.
  23640. * @return the JSON serialization
  23641. */
  23642. serialize(): IFresnelParametersSerialized;
  23643. /**
  23644. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  23645. * @param parsedFresnelParameters Define the JSON representation
  23646. * @returns the parsed parameters
  23647. */
  23648. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  23649. }
  23650. }
  23651. declare module BABYLON {
  23652. /**
  23653. * This groups all the flags used to control the materials channel.
  23654. */
  23655. export class MaterialFlags {
  23656. private static _DiffuseTextureEnabled;
  23657. /**
  23658. * Are diffuse textures enabled in the application.
  23659. */
  23660. static get DiffuseTextureEnabled(): boolean;
  23661. static set DiffuseTextureEnabled(value: boolean);
  23662. private static _DetailTextureEnabled;
  23663. /**
  23664. * Are detail textures enabled in the application.
  23665. */
  23666. static get DetailTextureEnabled(): boolean;
  23667. static set DetailTextureEnabled(value: boolean);
  23668. private static _AmbientTextureEnabled;
  23669. /**
  23670. * Are ambient textures enabled in the application.
  23671. */
  23672. static get AmbientTextureEnabled(): boolean;
  23673. static set AmbientTextureEnabled(value: boolean);
  23674. private static _OpacityTextureEnabled;
  23675. /**
  23676. * Are opacity textures enabled in the application.
  23677. */
  23678. static get OpacityTextureEnabled(): boolean;
  23679. static set OpacityTextureEnabled(value: boolean);
  23680. private static _ReflectionTextureEnabled;
  23681. /**
  23682. * Are reflection textures enabled in the application.
  23683. */
  23684. static get ReflectionTextureEnabled(): boolean;
  23685. static set ReflectionTextureEnabled(value: boolean);
  23686. private static _EmissiveTextureEnabled;
  23687. /**
  23688. * Are emissive textures enabled in the application.
  23689. */
  23690. static get EmissiveTextureEnabled(): boolean;
  23691. static set EmissiveTextureEnabled(value: boolean);
  23692. private static _SpecularTextureEnabled;
  23693. /**
  23694. * Are specular textures enabled in the application.
  23695. */
  23696. static get SpecularTextureEnabled(): boolean;
  23697. static set SpecularTextureEnabled(value: boolean);
  23698. private static _BumpTextureEnabled;
  23699. /**
  23700. * Are bump textures enabled in the application.
  23701. */
  23702. static get BumpTextureEnabled(): boolean;
  23703. static set BumpTextureEnabled(value: boolean);
  23704. private static _LightmapTextureEnabled;
  23705. /**
  23706. * Are lightmap textures enabled in the application.
  23707. */
  23708. static get LightmapTextureEnabled(): boolean;
  23709. static set LightmapTextureEnabled(value: boolean);
  23710. private static _RefractionTextureEnabled;
  23711. /**
  23712. * Are refraction textures enabled in the application.
  23713. */
  23714. static get RefractionTextureEnabled(): boolean;
  23715. static set RefractionTextureEnabled(value: boolean);
  23716. private static _ColorGradingTextureEnabled;
  23717. /**
  23718. * Are color grading textures enabled in the application.
  23719. */
  23720. static get ColorGradingTextureEnabled(): boolean;
  23721. static set ColorGradingTextureEnabled(value: boolean);
  23722. private static _FresnelEnabled;
  23723. /**
  23724. * Are fresnels enabled in the application.
  23725. */
  23726. static get FresnelEnabled(): boolean;
  23727. static set FresnelEnabled(value: boolean);
  23728. private static _ClearCoatTextureEnabled;
  23729. /**
  23730. * Are clear coat textures enabled in the application.
  23731. */
  23732. static get ClearCoatTextureEnabled(): boolean;
  23733. static set ClearCoatTextureEnabled(value: boolean);
  23734. private static _ClearCoatBumpTextureEnabled;
  23735. /**
  23736. * Are clear coat bump textures enabled in the application.
  23737. */
  23738. static get ClearCoatBumpTextureEnabled(): boolean;
  23739. static set ClearCoatBumpTextureEnabled(value: boolean);
  23740. private static _ClearCoatTintTextureEnabled;
  23741. /**
  23742. * Are clear coat tint textures enabled in the application.
  23743. */
  23744. static get ClearCoatTintTextureEnabled(): boolean;
  23745. static set ClearCoatTintTextureEnabled(value: boolean);
  23746. private static _SheenTextureEnabled;
  23747. /**
  23748. * Are sheen textures enabled in the application.
  23749. */
  23750. static get SheenTextureEnabled(): boolean;
  23751. static set SheenTextureEnabled(value: boolean);
  23752. private static _AnisotropicTextureEnabled;
  23753. /**
  23754. * Are anisotropic textures enabled in the application.
  23755. */
  23756. static get AnisotropicTextureEnabled(): boolean;
  23757. static set AnisotropicTextureEnabled(value: boolean);
  23758. private static _ThicknessTextureEnabled;
  23759. /**
  23760. * Are thickness textures enabled in the application.
  23761. */
  23762. static get ThicknessTextureEnabled(): boolean;
  23763. static set ThicknessTextureEnabled(value: boolean);
  23764. }
  23765. }
  23766. declare module BABYLON {
  23767. /** @hidden */
  23768. export var defaultFragmentDeclaration: {
  23769. name: string;
  23770. shader: string;
  23771. };
  23772. }
  23773. declare module BABYLON {
  23774. /** @hidden */
  23775. export var defaultUboDeclaration: {
  23776. name: string;
  23777. shader: string;
  23778. };
  23779. }
  23780. declare module BABYLON {
  23781. /** @hidden */
  23782. export var prePassDeclaration: {
  23783. name: string;
  23784. shader: string;
  23785. };
  23786. }
  23787. declare module BABYLON {
  23788. /** @hidden */
  23789. export var lightFragmentDeclaration: {
  23790. name: string;
  23791. shader: string;
  23792. };
  23793. }
  23794. declare module BABYLON {
  23795. /** @hidden */
  23796. export var lightUboDeclaration: {
  23797. name: string;
  23798. shader: string;
  23799. };
  23800. }
  23801. declare module BABYLON {
  23802. /** @hidden */
  23803. export var lightsFragmentFunctions: {
  23804. name: string;
  23805. shader: string;
  23806. };
  23807. }
  23808. declare module BABYLON {
  23809. /** @hidden */
  23810. export var shadowsFragmentFunctions: {
  23811. name: string;
  23812. shader: string;
  23813. };
  23814. }
  23815. declare module BABYLON {
  23816. /** @hidden */
  23817. export var fresnelFunction: {
  23818. name: string;
  23819. shader: string;
  23820. };
  23821. }
  23822. declare module BABYLON {
  23823. /** @hidden */
  23824. export var bumpFragmentMainFunctions: {
  23825. name: string;
  23826. shader: string;
  23827. };
  23828. }
  23829. declare module BABYLON {
  23830. /** @hidden */
  23831. export var bumpFragmentFunctions: {
  23832. name: string;
  23833. shader: string;
  23834. };
  23835. }
  23836. declare module BABYLON {
  23837. /** @hidden */
  23838. export var logDepthDeclaration: {
  23839. name: string;
  23840. shader: string;
  23841. };
  23842. }
  23843. declare module BABYLON {
  23844. /** @hidden */
  23845. export var bumpFragment: {
  23846. name: string;
  23847. shader: string;
  23848. };
  23849. }
  23850. declare module BABYLON {
  23851. /** @hidden */
  23852. export var depthPrePass: {
  23853. name: string;
  23854. shader: string;
  23855. };
  23856. }
  23857. declare module BABYLON {
  23858. /** @hidden */
  23859. export var lightFragment: {
  23860. name: string;
  23861. shader: string;
  23862. };
  23863. }
  23864. declare module BABYLON {
  23865. /** @hidden */
  23866. export var logDepthFragment: {
  23867. name: string;
  23868. shader: string;
  23869. };
  23870. }
  23871. declare module BABYLON {
  23872. /** @hidden */
  23873. export var defaultPixelShader: {
  23874. name: string;
  23875. shader: string;
  23876. };
  23877. }
  23878. declare module BABYLON {
  23879. /** @hidden */
  23880. export var defaultVertexDeclaration: {
  23881. name: string;
  23882. shader: string;
  23883. };
  23884. }
  23885. declare module BABYLON {
  23886. /** @hidden */
  23887. export var prePassVertexDeclaration: {
  23888. name: string;
  23889. shader: string;
  23890. };
  23891. }
  23892. declare module BABYLON {
  23893. /** @hidden */
  23894. export var bumpVertexDeclaration: {
  23895. name: string;
  23896. shader: string;
  23897. };
  23898. }
  23899. declare module BABYLON {
  23900. /** @hidden */
  23901. export var prePassVertex: {
  23902. name: string;
  23903. shader: string;
  23904. };
  23905. }
  23906. declare module BABYLON {
  23907. /** @hidden */
  23908. export var bumpVertex: {
  23909. name: string;
  23910. shader: string;
  23911. };
  23912. }
  23913. declare module BABYLON {
  23914. /** @hidden */
  23915. export var fogVertex: {
  23916. name: string;
  23917. shader: string;
  23918. };
  23919. }
  23920. declare module BABYLON {
  23921. /** @hidden */
  23922. export var shadowsVertex: {
  23923. name: string;
  23924. shader: string;
  23925. };
  23926. }
  23927. declare module BABYLON {
  23928. /** @hidden */
  23929. export var pointCloudVertex: {
  23930. name: string;
  23931. shader: string;
  23932. };
  23933. }
  23934. declare module BABYLON {
  23935. /** @hidden */
  23936. export var logDepthVertex: {
  23937. name: string;
  23938. shader: string;
  23939. };
  23940. }
  23941. declare module BABYLON {
  23942. /** @hidden */
  23943. export var defaultVertexShader: {
  23944. name: string;
  23945. shader: string;
  23946. };
  23947. }
  23948. declare module BABYLON {
  23949. /**
  23950. * @hidden
  23951. */
  23952. export interface IMaterialDetailMapDefines {
  23953. DETAIL: boolean;
  23954. DETAILDIRECTUV: number;
  23955. DETAIL_NORMALBLENDMETHOD: number;
  23956. /** @hidden */
  23957. _areTexturesDirty: boolean;
  23958. }
  23959. /**
  23960. * Define the code related to the detail map parameters of a material
  23961. *
  23962. * Inspired from:
  23963. * 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
  23964. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  23965. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  23966. */
  23967. export class DetailMapConfiguration {
  23968. private _texture;
  23969. /**
  23970. * The detail texture of the material.
  23971. */
  23972. texture: Nullable<BaseTexture>;
  23973. /**
  23974. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  23975. * Bigger values mean stronger blending
  23976. */
  23977. diffuseBlendLevel: number;
  23978. /**
  23979. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  23980. * Bigger values mean stronger blending. Only used with PBR materials
  23981. */
  23982. roughnessBlendLevel: number;
  23983. /**
  23984. * Defines how strong the bump effect from the detail map is
  23985. * Bigger values mean stronger effect
  23986. */
  23987. bumpLevel: number;
  23988. private _normalBlendMethod;
  23989. /**
  23990. * The method used to blend the bump and detail normals together
  23991. */
  23992. normalBlendMethod: number;
  23993. private _isEnabled;
  23994. /**
  23995. * Enable or disable the detail map on this material
  23996. */
  23997. isEnabled: boolean;
  23998. /** @hidden */
  23999. private _internalMarkAllSubMeshesAsTexturesDirty;
  24000. /** @hidden */
  24001. _markAllSubMeshesAsTexturesDirty(): void;
  24002. /**
  24003. * Instantiate a new detail map
  24004. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24005. */
  24006. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24007. /**
  24008. * Gets whether the submesh is ready to be used or not.
  24009. * @param defines the list of "defines" to update.
  24010. * @param scene defines the scene the material belongs to.
  24011. * @returns - boolean indicating that the submesh is ready or not.
  24012. */
  24013. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24014. /**
  24015. * Update the defines for detail map usage
  24016. * @param defines the list of "defines" to update.
  24017. * @param scene defines the scene the material belongs to.
  24018. */
  24019. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24020. /**
  24021. * Binds the material data.
  24022. * @param uniformBuffer defines the Uniform buffer to fill in.
  24023. * @param scene defines the scene the material belongs to.
  24024. * @param isFrozen defines whether the material is frozen or not.
  24025. */
  24026. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24027. /**
  24028. * Checks to see if a texture is used in the material.
  24029. * @param texture - Base texture to use.
  24030. * @returns - Boolean specifying if a texture is used in the material.
  24031. */
  24032. hasTexture(texture: BaseTexture): boolean;
  24033. /**
  24034. * Returns an array of the actively used textures.
  24035. * @param activeTextures Array of BaseTextures
  24036. */
  24037. getActiveTextures(activeTextures: BaseTexture[]): void;
  24038. /**
  24039. * Returns the animatable textures.
  24040. * @param animatables Array of animatable textures.
  24041. */
  24042. getAnimatables(animatables: IAnimatable[]): void;
  24043. /**
  24044. * Disposes the resources of the material.
  24045. * @param forceDisposeTextures - Forces the disposal of all textures.
  24046. */
  24047. dispose(forceDisposeTextures?: boolean): void;
  24048. /**
  24049. * Get the current class name useful for serialization or dynamic coding.
  24050. * @returns "DetailMap"
  24051. */
  24052. getClassName(): string;
  24053. /**
  24054. * Add the required uniforms to the current list.
  24055. * @param uniforms defines the current uniform list.
  24056. */
  24057. static AddUniforms(uniforms: string[]): void;
  24058. /**
  24059. * Add the required samplers to the current list.
  24060. * @param samplers defines the current sampler list.
  24061. */
  24062. static AddSamplers(samplers: string[]): void;
  24063. /**
  24064. * Add the required uniforms to the current buffer.
  24065. * @param uniformBuffer defines the current uniform buffer.
  24066. */
  24067. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24068. /**
  24069. * Makes a duplicate of the current instance into another one.
  24070. * @param detailMap define the instance where to copy the info
  24071. */
  24072. copyTo(detailMap: DetailMapConfiguration): void;
  24073. /**
  24074. * Serializes this detail map instance
  24075. * @returns - An object with the serialized instance.
  24076. */
  24077. serialize(): any;
  24078. /**
  24079. * Parses a detail map setting from a serialized object.
  24080. * @param source - Serialized object.
  24081. * @param scene Defines the scene we are parsing for
  24082. * @param rootUrl Defines the rootUrl to load from
  24083. */
  24084. parse(source: any, scene: Scene, rootUrl: string): void;
  24085. }
  24086. }
  24087. declare module BABYLON {
  24088. /** @hidden */
  24089. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24090. MAINUV1: boolean;
  24091. MAINUV2: boolean;
  24092. DIFFUSE: boolean;
  24093. DIFFUSEDIRECTUV: number;
  24094. DETAIL: boolean;
  24095. DETAILDIRECTUV: number;
  24096. DETAIL_NORMALBLENDMETHOD: number;
  24097. AMBIENT: boolean;
  24098. AMBIENTDIRECTUV: number;
  24099. OPACITY: boolean;
  24100. OPACITYDIRECTUV: number;
  24101. OPACITYRGB: boolean;
  24102. REFLECTION: boolean;
  24103. EMISSIVE: boolean;
  24104. EMISSIVEDIRECTUV: number;
  24105. SPECULAR: boolean;
  24106. SPECULARDIRECTUV: number;
  24107. BUMP: boolean;
  24108. BUMPDIRECTUV: number;
  24109. PARALLAX: boolean;
  24110. PARALLAXOCCLUSION: boolean;
  24111. SPECULAROVERALPHA: boolean;
  24112. CLIPPLANE: boolean;
  24113. CLIPPLANE2: boolean;
  24114. CLIPPLANE3: boolean;
  24115. CLIPPLANE4: boolean;
  24116. CLIPPLANE5: boolean;
  24117. CLIPPLANE6: boolean;
  24118. ALPHATEST: boolean;
  24119. DEPTHPREPASS: boolean;
  24120. ALPHAFROMDIFFUSE: boolean;
  24121. POINTSIZE: boolean;
  24122. FOG: boolean;
  24123. SPECULARTERM: boolean;
  24124. DIFFUSEFRESNEL: boolean;
  24125. OPACITYFRESNEL: boolean;
  24126. REFLECTIONFRESNEL: boolean;
  24127. REFRACTIONFRESNEL: boolean;
  24128. EMISSIVEFRESNEL: boolean;
  24129. FRESNEL: boolean;
  24130. NORMAL: boolean;
  24131. UV1: boolean;
  24132. UV2: boolean;
  24133. VERTEXCOLOR: boolean;
  24134. VERTEXALPHA: boolean;
  24135. NUM_BONE_INFLUENCERS: number;
  24136. BonesPerMesh: number;
  24137. BONETEXTURE: boolean;
  24138. BONES_VELOCITY_ENABLED: boolean;
  24139. INSTANCES: boolean;
  24140. THIN_INSTANCES: boolean;
  24141. GLOSSINESS: boolean;
  24142. ROUGHNESS: boolean;
  24143. EMISSIVEASILLUMINATION: boolean;
  24144. LINKEMISSIVEWITHDIFFUSE: boolean;
  24145. REFLECTIONFRESNELFROMSPECULAR: boolean;
  24146. LIGHTMAP: boolean;
  24147. LIGHTMAPDIRECTUV: number;
  24148. OBJECTSPACE_NORMALMAP: boolean;
  24149. USELIGHTMAPASSHADOWMAP: boolean;
  24150. REFLECTIONMAP_3D: boolean;
  24151. REFLECTIONMAP_SPHERICAL: boolean;
  24152. REFLECTIONMAP_PLANAR: boolean;
  24153. REFLECTIONMAP_CUBIC: boolean;
  24154. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  24155. REFLECTIONMAP_PROJECTION: boolean;
  24156. REFLECTIONMAP_SKYBOX: boolean;
  24157. REFLECTIONMAP_EXPLICIT: boolean;
  24158. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  24159. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  24160. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  24161. INVERTCUBICMAP: boolean;
  24162. LOGARITHMICDEPTH: boolean;
  24163. REFRACTION: boolean;
  24164. REFRACTIONMAP_3D: boolean;
  24165. REFLECTIONOVERALPHA: boolean;
  24166. TWOSIDEDLIGHTING: boolean;
  24167. SHADOWFLOAT: boolean;
  24168. MORPHTARGETS: boolean;
  24169. MORPHTARGETS_NORMAL: boolean;
  24170. MORPHTARGETS_TANGENT: boolean;
  24171. MORPHTARGETS_UV: boolean;
  24172. NUM_MORPH_INFLUENCERS: number;
  24173. NONUNIFORMSCALING: boolean;
  24174. PREMULTIPLYALPHA: boolean;
  24175. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  24176. ALPHABLEND: boolean;
  24177. PREPASS: boolean;
  24178. PREPASS_IRRADIANCE: boolean;
  24179. PREPASS_IRRADIANCE_INDEX: number;
  24180. PREPASS_ALBEDO: boolean;
  24181. PREPASS_ALBEDO_INDEX: number;
  24182. PREPASS_DEPTHNORMAL: boolean;
  24183. PREPASS_DEPTHNORMAL_INDEX: number;
  24184. PREPASS_POSITION: boolean;
  24185. PREPASS_POSITION_INDEX: number;
  24186. PREPASS_VELOCITY: boolean;
  24187. PREPASS_VELOCITY_INDEX: number;
  24188. PREPASS_REFLECTIVITY: boolean;
  24189. PREPASS_REFLECTIVITY_INDEX: number;
  24190. SCENE_MRT_COUNT: number;
  24191. RGBDLIGHTMAP: boolean;
  24192. RGBDREFLECTION: boolean;
  24193. RGBDREFRACTION: boolean;
  24194. IMAGEPROCESSING: boolean;
  24195. VIGNETTE: boolean;
  24196. VIGNETTEBLENDMODEMULTIPLY: boolean;
  24197. VIGNETTEBLENDMODEOPAQUE: boolean;
  24198. TONEMAPPING: boolean;
  24199. TONEMAPPING_ACES: boolean;
  24200. CONTRAST: boolean;
  24201. COLORCURVES: boolean;
  24202. COLORGRADING: boolean;
  24203. COLORGRADING3D: boolean;
  24204. SAMPLER3DGREENDEPTH: boolean;
  24205. SAMPLER3DBGRMAP: boolean;
  24206. IMAGEPROCESSINGPOSTPROCESS: boolean;
  24207. MULTIVIEW: boolean;
  24208. /**
  24209. * If the reflection texture on this material is in linear color space
  24210. * @hidden
  24211. */
  24212. IS_REFLECTION_LINEAR: boolean;
  24213. /**
  24214. * If the refraction texture on this material is in linear color space
  24215. * @hidden
  24216. */
  24217. IS_REFRACTION_LINEAR: boolean;
  24218. EXPOSURE: boolean;
  24219. constructor();
  24220. setReflectionMode(modeToEnable: string): void;
  24221. }
  24222. /**
  24223. * This is the default material used in Babylon. It is the best trade off between quality
  24224. * and performances.
  24225. * @see https://doc.babylonjs.com/babylon101/materials
  24226. */
  24227. export class StandardMaterial extends PushMaterial {
  24228. private _diffuseTexture;
  24229. /**
  24230. * The basic texture of the material as viewed under a light.
  24231. */
  24232. diffuseTexture: Nullable<BaseTexture>;
  24233. private _ambientTexture;
  24234. /**
  24235. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  24236. */
  24237. ambientTexture: Nullable<BaseTexture>;
  24238. private _opacityTexture;
  24239. /**
  24240. * Define the transparency of the material from a texture.
  24241. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  24242. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  24243. */
  24244. opacityTexture: Nullable<BaseTexture>;
  24245. private _reflectionTexture;
  24246. /**
  24247. * Define the texture used to display the reflection.
  24248. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24249. */
  24250. reflectionTexture: Nullable<BaseTexture>;
  24251. private _emissiveTexture;
  24252. /**
  24253. * Define texture of the material as if self lit.
  24254. * This will be mixed in the final result even in the absence of light.
  24255. */
  24256. emissiveTexture: Nullable<BaseTexture>;
  24257. private _specularTexture;
  24258. /**
  24259. * Define how the color and intensity of the highlight given by the light in the material.
  24260. */
  24261. specularTexture: Nullable<BaseTexture>;
  24262. private _bumpTexture;
  24263. /**
  24264. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  24265. * 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.
  24266. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  24267. */
  24268. bumpTexture: Nullable<BaseTexture>;
  24269. private _lightmapTexture;
  24270. /**
  24271. * Complex lighting can be computationally expensive to compute at runtime.
  24272. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  24273. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  24274. */
  24275. lightmapTexture: Nullable<BaseTexture>;
  24276. private _refractionTexture;
  24277. /**
  24278. * Define the texture used to display the refraction.
  24279. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24280. */
  24281. refractionTexture: Nullable<BaseTexture>;
  24282. /**
  24283. * The color of the material lit by the environmental background lighting.
  24284. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24285. */
  24286. ambientColor: Color3;
  24287. /**
  24288. * The basic color of the material as viewed under a light.
  24289. */
  24290. diffuseColor: Color3;
  24291. /**
  24292. * Define how the color and intensity of the highlight given by the light in the material.
  24293. */
  24294. specularColor: Color3;
  24295. /**
  24296. * Define the color of the material as if self lit.
  24297. * This will be mixed in the final result even in the absence of light.
  24298. */
  24299. emissiveColor: Color3;
  24300. /**
  24301. * Defines how sharp are the highlights in the material.
  24302. * The bigger the value the sharper giving a more glossy feeling to the result.
  24303. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24304. */
  24305. specularPower: number;
  24306. private _useAlphaFromDiffuseTexture;
  24307. /**
  24308. * Does the transparency come from the diffuse texture alpha channel.
  24309. */
  24310. useAlphaFromDiffuseTexture: boolean;
  24311. private _useEmissiveAsIllumination;
  24312. /**
  24313. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24314. */
  24315. useEmissiveAsIllumination: boolean;
  24316. private _linkEmissiveWithDiffuse;
  24317. /**
  24318. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24319. * the emissive level when the final color is close to one.
  24320. */
  24321. linkEmissiveWithDiffuse: boolean;
  24322. private _useSpecularOverAlpha;
  24323. /**
  24324. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24325. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24326. */
  24327. useSpecularOverAlpha: boolean;
  24328. private _useReflectionOverAlpha;
  24329. /**
  24330. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24331. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24332. */
  24333. useReflectionOverAlpha: boolean;
  24334. private _disableLighting;
  24335. /**
  24336. * Does lights from the scene impacts this material.
  24337. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24338. */
  24339. disableLighting: boolean;
  24340. private _useObjectSpaceNormalMap;
  24341. /**
  24342. * Allows using an object space normal map (instead of tangent space).
  24343. */
  24344. useObjectSpaceNormalMap: boolean;
  24345. private _useParallax;
  24346. /**
  24347. * Is parallax enabled or not.
  24348. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24349. */
  24350. useParallax: boolean;
  24351. private _useParallaxOcclusion;
  24352. /**
  24353. * Is parallax occlusion enabled or not.
  24354. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24355. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24356. */
  24357. useParallaxOcclusion: boolean;
  24358. /**
  24359. * 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.
  24360. */
  24361. parallaxScaleBias: number;
  24362. private _roughness;
  24363. /**
  24364. * Helps to define how blurry the reflections should appears in the material.
  24365. */
  24366. roughness: number;
  24367. /**
  24368. * In case of refraction, define the value of the index of refraction.
  24369. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24370. */
  24371. indexOfRefraction: number;
  24372. /**
  24373. * Invert the refraction texture alongside the y axis.
  24374. * It can be useful with procedural textures or probe for instance.
  24375. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24376. */
  24377. invertRefractionY: boolean;
  24378. /**
  24379. * Defines the alpha limits in alpha test mode.
  24380. */
  24381. alphaCutOff: number;
  24382. private _useLightmapAsShadowmap;
  24383. /**
  24384. * In case of light mapping, define whether the map contains light or shadow informations.
  24385. */
  24386. useLightmapAsShadowmap: boolean;
  24387. private _diffuseFresnelParameters;
  24388. /**
  24389. * Define the diffuse fresnel parameters of the material.
  24390. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24391. */
  24392. diffuseFresnelParameters: FresnelParameters;
  24393. private _opacityFresnelParameters;
  24394. /**
  24395. * Define the opacity fresnel parameters of the material.
  24396. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24397. */
  24398. opacityFresnelParameters: FresnelParameters;
  24399. private _reflectionFresnelParameters;
  24400. /**
  24401. * Define the reflection fresnel parameters of the material.
  24402. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24403. */
  24404. reflectionFresnelParameters: FresnelParameters;
  24405. private _refractionFresnelParameters;
  24406. /**
  24407. * Define the refraction fresnel parameters of the material.
  24408. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24409. */
  24410. refractionFresnelParameters: FresnelParameters;
  24411. private _emissiveFresnelParameters;
  24412. /**
  24413. * Define the emissive fresnel parameters of the material.
  24414. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24415. */
  24416. emissiveFresnelParameters: FresnelParameters;
  24417. private _useReflectionFresnelFromSpecular;
  24418. /**
  24419. * If true automatically deducts the fresnels values from the material specularity.
  24420. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24421. */
  24422. useReflectionFresnelFromSpecular: boolean;
  24423. private _useGlossinessFromSpecularMapAlpha;
  24424. /**
  24425. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  24426. */
  24427. useGlossinessFromSpecularMapAlpha: boolean;
  24428. private _maxSimultaneousLights;
  24429. /**
  24430. * Defines the maximum number of lights that can be used in the material
  24431. */
  24432. maxSimultaneousLights: number;
  24433. private _invertNormalMapX;
  24434. /**
  24435. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  24436. */
  24437. invertNormalMapX: boolean;
  24438. private _invertNormalMapY;
  24439. /**
  24440. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  24441. */
  24442. invertNormalMapY: boolean;
  24443. private _twoSidedLighting;
  24444. /**
  24445. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  24446. */
  24447. twoSidedLighting: boolean;
  24448. /**
  24449. * Default configuration related to image processing available in the standard Material.
  24450. */
  24451. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24452. /**
  24453. * Gets the image processing configuration used either in this material.
  24454. */
  24455. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24456. /**
  24457. * Sets the Default image processing configuration used either in the this material.
  24458. *
  24459. * If sets to null, the scene one is in use.
  24460. */
  24461. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24462. /**
  24463. * Keep track of the image processing observer to allow dispose and replace.
  24464. */
  24465. private _imageProcessingObserver;
  24466. /**
  24467. * Attaches a new image processing configuration to the Standard Material.
  24468. * @param configuration
  24469. */
  24470. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24471. /**
  24472. * Defines additionnal PrePass parameters for the material.
  24473. */
  24474. readonly prePassConfiguration: PrePassConfiguration;
  24475. /**
  24476. * Gets wether the color curves effect is enabled.
  24477. */
  24478. get cameraColorCurvesEnabled(): boolean;
  24479. /**
  24480. * Sets wether the color curves effect is enabled.
  24481. */
  24482. set cameraColorCurvesEnabled(value: boolean);
  24483. /**
  24484. * Gets wether the color grading effect is enabled.
  24485. */
  24486. get cameraColorGradingEnabled(): boolean;
  24487. /**
  24488. * Gets wether the color grading effect is enabled.
  24489. */
  24490. set cameraColorGradingEnabled(value: boolean);
  24491. /**
  24492. * Gets wether tonemapping is enabled or not.
  24493. */
  24494. get cameraToneMappingEnabled(): boolean;
  24495. /**
  24496. * Sets wether tonemapping is enabled or not
  24497. */
  24498. set cameraToneMappingEnabled(value: boolean);
  24499. /**
  24500. * The camera exposure used on this material.
  24501. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24502. * This corresponds to a photographic exposure.
  24503. */
  24504. get cameraExposure(): number;
  24505. /**
  24506. * The camera exposure used on this material.
  24507. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24508. * This corresponds to a photographic exposure.
  24509. */
  24510. set cameraExposure(value: number);
  24511. /**
  24512. * Gets The camera contrast used on this material.
  24513. */
  24514. get cameraContrast(): number;
  24515. /**
  24516. * Sets The camera contrast used on this material.
  24517. */
  24518. set cameraContrast(value: number);
  24519. /**
  24520. * Gets the Color Grading 2D Lookup Texture.
  24521. */
  24522. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  24523. /**
  24524. * Sets the Color Grading 2D Lookup Texture.
  24525. */
  24526. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  24527. /**
  24528. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24529. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24530. * 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;
  24531. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24532. */
  24533. get cameraColorCurves(): Nullable<ColorCurves>;
  24534. /**
  24535. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24536. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24537. * 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;
  24538. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24539. */
  24540. set cameraColorCurves(value: Nullable<ColorCurves>);
  24541. /**
  24542. * Can this material render to several textures at once
  24543. */
  24544. get canRenderToMRT(): boolean;
  24545. /**
  24546. * Defines the detail map parameters for the material.
  24547. */
  24548. readonly detailMap: DetailMapConfiguration;
  24549. protected _renderTargets: SmartArray<RenderTargetTexture>;
  24550. protected _worldViewProjectionMatrix: Matrix;
  24551. protected _globalAmbientColor: Color3;
  24552. protected _useLogarithmicDepth: boolean;
  24553. protected _rebuildInParallel: boolean;
  24554. /**
  24555. * Instantiates a new standard material.
  24556. * This is the default material used in Babylon. It is the best trade off between quality
  24557. * and performances.
  24558. * @see https://doc.babylonjs.com/babylon101/materials
  24559. * @param name Define the name of the material in the scene
  24560. * @param scene Define the scene the material belong to
  24561. */
  24562. constructor(name: string, scene: Scene);
  24563. /**
  24564. * Gets a boolean indicating that current material needs to register RTT
  24565. */
  24566. get hasRenderTargetTextures(): boolean;
  24567. /**
  24568. * Gets the current class name of the material e.g. "StandardMaterial"
  24569. * Mainly use in serialization.
  24570. * @returns the class name
  24571. */
  24572. getClassName(): string;
  24573. /**
  24574. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  24575. * You can try switching to logarithmic depth.
  24576. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  24577. */
  24578. get useLogarithmicDepth(): boolean;
  24579. set useLogarithmicDepth(value: boolean);
  24580. /**
  24581. * Specifies if the material will require alpha blending
  24582. * @returns a boolean specifying if alpha blending is needed
  24583. */
  24584. needAlphaBlending(): boolean;
  24585. /**
  24586. * Specifies if this material should be rendered in alpha test mode
  24587. * @returns a boolean specifying if an alpha test is needed.
  24588. */
  24589. needAlphaTesting(): boolean;
  24590. /**
  24591. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  24592. */
  24593. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  24594. /**
  24595. * Specifies whether or not there is a usable alpha channel for transparency.
  24596. */
  24597. protected _hasAlphaChannel(): boolean;
  24598. /**
  24599. * Get the texture used for alpha test purpose.
  24600. * @returns the diffuse texture in case of the standard material.
  24601. */
  24602. getAlphaTestTexture(): Nullable<BaseTexture>;
  24603. /**
  24604. * Get if the submesh is ready to be used and all its information available.
  24605. * Child classes can use it to update shaders
  24606. * @param mesh defines the mesh to check
  24607. * @param subMesh defines which submesh to check
  24608. * @param useInstances specifies that instances should be used
  24609. * @returns a boolean indicating that the submesh is ready or not
  24610. */
  24611. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24612. /**
  24613. * Builds the material UBO layouts.
  24614. * Used internally during the effect preparation.
  24615. */
  24616. buildUniformLayout(): void;
  24617. /**
  24618. * Unbinds the material from the mesh
  24619. */
  24620. unbind(): void;
  24621. /**
  24622. * Binds the submesh to this material by preparing the effect and shader to draw
  24623. * @param world defines the world transformation matrix
  24624. * @param mesh defines the mesh containing the submesh
  24625. * @param subMesh defines the submesh to bind the material to
  24626. */
  24627. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24628. /**
  24629. * Get the list of animatables in the material.
  24630. * @returns the list of animatables object used in the material
  24631. */
  24632. getAnimatables(): IAnimatable[];
  24633. /**
  24634. * Gets the active textures from the material
  24635. * @returns an array of textures
  24636. */
  24637. getActiveTextures(): BaseTexture[];
  24638. /**
  24639. * Specifies if the material uses a texture
  24640. * @param texture defines the texture to check against the material
  24641. * @returns a boolean specifying if the material uses the texture
  24642. */
  24643. hasTexture(texture: BaseTexture): boolean;
  24644. /**
  24645. * Disposes the material
  24646. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24647. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24648. */
  24649. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  24650. /**
  24651. * Makes a duplicate of the material, and gives it a new name
  24652. * @param name defines the new name for the duplicated material
  24653. * @returns the cloned material
  24654. */
  24655. clone(name: string): StandardMaterial;
  24656. /**
  24657. * Serializes this material in a JSON representation
  24658. * @returns the serialized material object
  24659. */
  24660. serialize(): any;
  24661. /**
  24662. * Creates a standard material from parsed material data
  24663. * @param source defines the JSON representation of the material
  24664. * @param scene defines the hosting scene
  24665. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24666. * @returns a new standard material
  24667. */
  24668. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  24669. /**
  24670. * Are diffuse textures enabled in the application.
  24671. */
  24672. static get DiffuseTextureEnabled(): boolean;
  24673. static set DiffuseTextureEnabled(value: boolean);
  24674. /**
  24675. * Are detail textures enabled in the application.
  24676. */
  24677. static get DetailTextureEnabled(): boolean;
  24678. static set DetailTextureEnabled(value: boolean);
  24679. /**
  24680. * Are ambient textures enabled in the application.
  24681. */
  24682. static get AmbientTextureEnabled(): boolean;
  24683. static set AmbientTextureEnabled(value: boolean);
  24684. /**
  24685. * Are opacity textures enabled in the application.
  24686. */
  24687. static get OpacityTextureEnabled(): boolean;
  24688. static set OpacityTextureEnabled(value: boolean);
  24689. /**
  24690. * Are reflection textures enabled in the application.
  24691. */
  24692. static get ReflectionTextureEnabled(): boolean;
  24693. static set ReflectionTextureEnabled(value: boolean);
  24694. /**
  24695. * Are emissive textures enabled in the application.
  24696. */
  24697. static get EmissiveTextureEnabled(): boolean;
  24698. static set EmissiveTextureEnabled(value: boolean);
  24699. /**
  24700. * Are specular textures enabled in the application.
  24701. */
  24702. static get SpecularTextureEnabled(): boolean;
  24703. static set SpecularTextureEnabled(value: boolean);
  24704. /**
  24705. * Are bump textures enabled in the application.
  24706. */
  24707. static get BumpTextureEnabled(): boolean;
  24708. static set BumpTextureEnabled(value: boolean);
  24709. /**
  24710. * Are lightmap textures enabled in the application.
  24711. */
  24712. static get LightmapTextureEnabled(): boolean;
  24713. static set LightmapTextureEnabled(value: boolean);
  24714. /**
  24715. * Are refraction textures enabled in the application.
  24716. */
  24717. static get RefractionTextureEnabled(): boolean;
  24718. static set RefractionTextureEnabled(value: boolean);
  24719. /**
  24720. * Are color grading textures enabled in the application.
  24721. */
  24722. static get ColorGradingTextureEnabled(): boolean;
  24723. static set ColorGradingTextureEnabled(value: boolean);
  24724. /**
  24725. * Are fresnels enabled in the application.
  24726. */
  24727. static get FresnelEnabled(): boolean;
  24728. static set FresnelEnabled(value: boolean);
  24729. }
  24730. }
  24731. declare module BABYLON {
  24732. /** @hidden */
  24733. export var rgbdDecodePixelShader: {
  24734. name: string;
  24735. shader: string;
  24736. };
  24737. }
  24738. declare module BABYLON {
  24739. /**
  24740. * Class used to host RGBD texture specific utilities
  24741. */
  24742. export class RGBDTextureTools {
  24743. /**
  24744. * Expand the RGBD Texture from RGBD to Half Float if possible.
  24745. * @param texture the texture to expand.
  24746. */
  24747. static ExpandRGBDTexture(texture: Texture): void;
  24748. }
  24749. }
  24750. declare module BABYLON {
  24751. /**
  24752. * Class used to host texture specific utilities
  24753. */
  24754. export class BRDFTextureTools {
  24755. /**
  24756. * Prevents texture cache collision
  24757. */
  24758. private static _instanceNumber;
  24759. /**
  24760. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  24761. * @param scene defines the hosting scene
  24762. * @returns the environment BRDF texture
  24763. */
  24764. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  24765. private static _environmentBRDFBase64Texture;
  24766. }
  24767. }
  24768. declare module BABYLON {
  24769. /**
  24770. * @hidden
  24771. */
  24772. export interface IMaterialClearCoatDefines {
  24773. CLEARCOAT: boolean;
  24774. CLEARCOAT_DEFAULTIOR: boolean;
  24775. CLEARCOAT_TEXTURE: boolean;
  24776. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  24777. CLEARCOAT_TEXTUREDIRECTUV: number;
  24778. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  24779. CLEARCOAT_BUMP: boolean;
  24780. CLEARCOAT_BUMPDIRECTUV: number;
  24781. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  24782. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  24783. CLEARCOAT_REMAP_F0: boolean;
  24784. CLEARCOAT_TINT: boolean;
  24785. CLEARCOAT_TINT_TEXTURE: boolean;
  24786. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  24787. /** @hidden */
  24788. _areTexturesDirty: boolean;
  24789. }
  24790. /**
  24791. * Define the code related to the clear coat parameters of the pbr material.
  24792. */
  24793. export class PBRClearCoatConfiguration {
  24794. /**
  24795. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24796. * The default fits with a polyurethane material.
  24797. */
  24798. private static readonly _DefaultIndexOfRefraction;
  24799. private _isEnabled;
  24800. /**
  24801. * Defines if the clear coat is enabled in the material.
  24802. */
  24803. isEnabled: boolean;
  24804. /**
  24805. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  24806. */
  24807. intensity: number;
  24808. /**
  24809. * Defines the clear coat layer roughness.
  24810. */
  24811. roughness: number;
  24812. private _indexOfRefraction;
  24813. /**
  24814. * Defines the index of refraction of the clear coat.
  24815. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24816. * The default fits with a polyurethane material.
  24817. * Changing the default value is more performance intensive.
  24818. */
  24819. indexOfRefraction: number;
  24820. private _texture;
  24821. /**
  24822. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  24823. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  24824. * if textureRoughness is not empty, else no texture roughness is used
  24825. */
  24826. texture: Nullable<BaseTexture>;
  24827. private _useRoughnessFromMainTexture;
  24828. /**
  24829. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  24830. * If false, the green channel from textureRoughness is used for roughness
  24831. */
  24832. useRoughnessFromMainTexture: boolean;
  24833. private _textureRoughness;
  24834. /**
  24835. * Stores the clear coat roughness in a texture (green channel)
  24836. * Not used if useRoughnessFromMainTexture is true
  24837. */
  24838. textureRoughness: Nullable<BaseTexture>;
  24839. private _remapF0OnInterfaceChange;
  24840. /**
  24841. * Defines if the F0 value should be remapped to account for the interface change in the material.
  24842. */
  24843. remapF0OnInterfaceChange: boolean;
  24844. private _bumpTexture;
  24845. /**
  24846. * Define the clear coat specific bump texture.
  24847. */
  24848. bumpTexture: Nullable<BaseTexture>;
  24849. private _isTintEnabled;
  24850. /**
  24851. * Defines if the clear coat tint is enabled in the material.
  24852. */
  24853. isTintEnabled: boolean;
  24854. /**
  24855. * Defines the clear coat tint of the material.
  24856. * This is only use if tint is enabled
  24857. */
  24858. tintColor: Color3;
  24859. /**
  24860. * Defines the distance at which the tint color should be found in the
  24861. * clear coat media.
  24862. * This is only use if tint is enabled
  24863. */
  24864. tintColorAtDistance: number;
  24865. /**
  24866. * Defines the clear coat layer thickness.
  24867. * This is only use if tint is enabled
  24868. */
  24869. tintThickness: number;
  24870. private _tintTexture;
  24871. /**
  24872. * Stores the clear tint values in a texture.
  24873. * rgb is tint
  24874. * a is a thickness factor
  24875. */
  24876. tintTexture: Nullable<BaseTexture>;
  24877. /** @hidden */
  24878. private _internalMarkAllSubMeshesAsTexturesDirty;
  24879. /** @hidden */
  24880. _markAllSubMeshesAsTexturesDirty(): void;
  24881. /**
  24882. * Instantiate a new istance of clear coat configuration.
  24883. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24884. */
  24885. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24886. /**
  24887. * Gets wehter the submesh is ready to be used or not.
  24888. * @param defines the list of "defines" to update.
  24889. * @param scene defines the scene the material belongs to.
  24890. * @param engine defines the engine the material belongs to.
  24891. * @param disableBumpMap defines wether the material disables bump or not.
  24892. * @returns - boolean indicating that the submesh is ready or not.
  24893. */
  24894. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  24895. /**
  24896. * Checks to see if a texture is used in the material.
  24897. * @param defines the list of "defines" to update.
  24898. * @param scene defines the scene to the material belongs to.
  24899. */
  24900. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  24901. /**
  24902. * Binds the material data.
  24903. * @param uniformBuffer defines the Uniform buffer to fill in.
  24904. * @param scene defines the scene the material belongs to.
  24905. * @param engine defines the engine the material belongs to.
  24906. * @param disableBumpMap defines wether the material disables bump or not.
  24907. * @param isFrozen defines wether the material is frozen or not.
  24908. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  24909. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  24910. * @param subMesh the submesh to bind data for
  24911. */
  24912. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  24913. /**
  24914. * Checks to see if a texture is used in the material.
  24915. * @param texture - Base texture to use.
  24916. * @returns - Boolean specifying if a texture is used in the material.
  24917. */
  24918. hasTexture(texture: BaseTexture): boolean;
  24919. /**
  24920. * Returns an array of the actively used textures.
  24921. * @param activeTextures Array of BaseTextures
  24922. */
  24923. getActiveTextures(activeTextures: BaseTexture[]): void;
  24924. /**
  24925. * Returns the animatable textures.
  24926. * @param animatables Array of animatable textures.
  24927. */
  24928. getAnimatables(animatables: IAnimatable[]): void;
  24929. /**
  24930. * Disposes the resources of the material.
  24931. * @param forceDisposeTextures - Forces the disposal of all textures.
  24932. */
  24933. dispose(forceDisposeTextures?: boolean): void;
  24934. /**
  24935. * Get the current class name of the texture useful for serialization or dynamic coding.
  24936. * @returns "PBRClearCoatConfiguration"
  24937. */
  24938. getClassName(): string;
  24939. /**
  24940. * Add fallbacks to the effect fallbacks list.
  24941. * @param defines defines the Base texture to use.
  24942. * @param fallbacks defines the current fallback list.
  24943. * @param currentRank defines the current fallback rank.
  24944. * @returns the new fallback rank.
  24945. */
  24946. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24947. /**
  24948. * Add the required uniforms to the current list.
  24949. * @param uniforms defines the current uniform list.
  24950. */
  24951. static AddUniforms(uniforms: string[]): void;
  24952. /**
  24953. * Add the required samplers to the current list.
  24954. * @param samplers defines the current sampler list.
  24955. */
  24956. static AddSamplers(samplers: string[]): void;
  24957. /**
  24958. * Add the required uniforms to the current buffer.
  24959. * @param uniformBuffer defines the current uniform buffer.
  24960. */
  24961. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24962. /**
  24963. * Makes a duplicate of the current configuration into another one.
  24964. * @param clearCoatConfiguration define the config where to copy the info
  24965. */
  24966. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  24967. /**
  24968. * Serializes this clear coat configuration.
  24969. * @returns - An object with the serialized config.
  24970. */
  24971. serialize(): any;
  24972. /**
  24973. * Parses a anisotropy Configuration from a serialized object.
  24974. * @param source - Serialized object.
  24975. * @param scene Defines the scene we are parsing for
  24976. * @param rootUrl Defines the rootUrl to load from
  24977. */
  24978. parse(source: any, scene: Scene, rootUrl: string): void;
  24979. }
  24980. }
  24981. declare module BABYLON {
  24982. /**
  24983. * @hidden
  24984. */
  24985. export interface IMaterialAnisotropicDefines {
  24986. ANISOTROPIC: boolean;
  24987. ANISOTROPIC_TEXTURE: boolean;
  24988. ANISOTROPIC_TEXTUREDIRECTUV: number;
  24989. MAINUV1: boolean;
  24990. _areTexturesDirty: boolean;
  24991. _needUVs: boolean;
  24992. }
  24993. /**
  24994. * Define the code related to the anisotropic parameters of the pbr material.
  24995. */
  24996. export class PBRAnisotropicConfiguration {
  24997. private _isEnabled;
  24998. /**
  24999. * Defines if the anisotropy is enabled in the material.
  25000. */
  25001. isEnabled: boolean;
  25002. /**
  25003. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  25004. */
  25005. intensity: number;
  25006. /**
  25007. * Defines if the effect is along the tangents, bitangents or in between.
  25008. * By default, the effect is "strectching" the highlights along the tangents.
  25009. */
  25010. direction: Vector2;
  25011. private _texture;
  25012. /**
  25013. * Stores the anisotropy values in a texture.
  25014. * rg is direction (like normal from -1 to 1)
  25015. * b is a intensity
  25016. */
  25017. texture: Nullable<BaseTexture>;
  25018. /** @hidden */
  25019. private _internalMarkAllSubMeshesAsTexturesDirty;
  25020. /** @hidden */
  25021. _markAllSubMeshesAsTexturesDirty(): void;
  25022. /**
  25023. * Instantiate a new istance of anisotropy configuration.
  25024. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25025. */
  25026. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25027. /**
  25028. * Specifies that the submesh is ready to be used.
  25029. * @param defines the list of "defines" to update.
  25030. * @param scene defines the scene the material belongs to.
  25031. * @returns - boolean indicating that the submesh is ready or not.
  25032. */
  25033. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25034. /**
  25035. * Checks to see if a texture is used in the material.
  25036. * @param defines the list of "defines" to update.
  25037. * @param mesh the mesh we are preparing the defines for.
  25038. * @param scene defines the scene the material belongs to.
  25039. */
  25040. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25041. /**
  25042. * Binds the material data.
  25043. * @param uniformBuffer defines the Uniform buffer to fill in.
  25044. * @param scene defines the scene the material belongs to.
  25045. * @param isFrozen defines wether the material is frozen or not.
  25046. */
  25047. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25048. /**
  25049. * Checks to see if a texture is used in the material.
  25050. * @param texture - Base texture to use.
  25051. * @returns - Boolean specifying if a texture is used in the material.
  25052. */
  25053. hasTexture(texture: BaseTexture): boolean;
  25054. /**
  25055. * Returns an array of the actively used textures.
  25056. * @param activeTextures Array of BaseTextures
  25057. */
  25058. getActiveTextures(activeTextures: BaseTexture[]): void;
  25059. /**
  25060. * Returns the animatable textures.
  25061. * @param animatables Array of animatable textures.
  25062. */
  25063. getAnimatables(animatables: IAnimatable[]): void;
  25064. /**
  25065. * Disposes the resources of the material.
  25066. * @param forceDisposeTextures - Forces the disposal of all textures.
  25067. */
  25068. dispose(forceDisposeTextures?: boolean): void;
  25069. /**
  25070. * Get the current class name of the texture useful for serialization or dynamic coding.
  25071. * @returns "PBRAnisotropicConfiguration"
  25072. */
  25073. getClassName(): string;
  25074. /**
  25075. * Add fallbacks to the effect fallbacks list.
  25076. * @param defines defines the Base texture to use.
  25077. * @param fallbacks defines the current fallback list.
  25078. * @param currentRank defines the current fallback rank.
  25079. * @returns the new fallback rank.
  25080. */
  25081. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25082. /**
  25083. * Add the required uniforms to the current list.
  25084. * @param uniforms defines the current uniform list.
  25085. */
  25086. static AddUniforms(uniforms: string[]): void;
  25087. /**
  25088. * Add the required uniforms to the current buffer.
  25089. * @param uniformBuffer defines the current uniform buffer.
  25090. */
  25091. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25092. /**
  25093. * Add the required samplers to the current list.
  25094. * @param samplers defines the current sampler list.
  25095. */
  25096. static AddSamplers(samplers: string[]): void;
  25097. /**
  25098. * Makes a duplicate of the current configuration into another one.
  25099. * @param anisotropicConfiguration define the config where to copy the info
  25100. */
  25101. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  25102. /**
  25103. * Serializes this anisotropy configuration.
  25104. * @returns - An object with the serialized config.
  25105. */
  25106. serialize(): any;
  25107. /**
  25108. * Parses a anisotropy Configuration from a serialized object.
  25109. * @param source - Serialized object.
  25110. * @param scene Defines the scene we are parsing for
  25111. * @param rootUrl Defines the rootUrl to load from
  25112. */
  25113. parse(source: any, scene: Scene, rootUrl: string): void;
  25114. }
  25115. }
  25116. declare module BABYLON {
  25117. /**
  25118. * @hidden
  25119. */
  25120. export interface IMaterialBRDFDefines {
  25121. BRDF_V_HEIGHT_CORRELATED: boolean;
  25122. MS_BRDF_ENERGY_CONSERVATION: boolean;
  25123. SPHERICAL_HARMONICS: boolean;
  25124. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  25125. /** @hidden */
  25126. _areMiscDirty: boolean;
  25127. }
  25128. /**
  25129. * Define the code related to the BRDF parameters of the pbr material.
  25130. */
  25131. export class PBRBRDFConfiguration {
  25132. /**
  25133. * Default value used for the energy conservation.
  25134. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25135. */
  25136. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  25137. /**
  25138. * Default value used for the Smith Visibility Height Correlated mode.
  25139. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25140. */
  25141. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  25142. /**
  25143. * Default value used for the IBL diffuse part.
  25144. * This can help switching back to the polynomials mode globally which is a tiny bit
  25145. * less GPU intensive at the drawback of a lower quality.
  25146. */
  25147. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  25148. /**
  25149. * Default value used for activating energy conservation for the specular workflow.
  25150. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25151. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25152. */
  25153. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  25154. private _useEnergyConservation;
  25155. /**
  25156. * Defines if the material uses energy conservation.
  25157. */
  25158. useEnergyConservation: boolean;
  25159. private _useSmithVisibilityHeightCorrelated;
  25160. /**
  25161. * LEGACY Mode set to false
  25162. * Defines if the material uses height smith correlated visibility term.
  25163. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  25164. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  25165. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  25166. * Not relying on height correlated will also disable energy conservation.
  25167. */
  25168. useSmithVisibilityHeightCorrelated: boolean;
  25169. private _useSphericalHarmonics;
  25170. /**
  25171. * LEGACY Mode set to false
  25172. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  25173. * diffuse part of the IBL.
  25174. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  25175. * to the ground truth.
  25176. */
  25177. useSphericalHarmonics: boolean;
  25178. private _useSpecularGlossinessInputEnergyConservation;
  25179. /**
  25180. * Defines if the material uses energy conservation, when the specular workflow is active.
  25181. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25182. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25183. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  25184. */
  25185. useSpecularGlossinessInputEnergyConservation: boolean;
  25186. /** @hidden */
  25187. private _internalMarkAllSubMeshesAsMiscDirty;
  25188. /** @hidden */
  25189. _markAllSubMeshesAsMiscDirty(): void;
  25190. /**
  25191. * Instantiate a new istance of clear coat configuration.
  25192. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  25193. */
  25194. constructor(markAllSubMeshesAsMiscDirty: () => void);
  25195. /**
  25196. * Checks to see if a texture is used in the material.
  25197. * @param defines the list of "defines" to update.
  25198. */
  25199. prepareDefines(defines: IMaterialBRDFDefines): void;
  25200. /**
  25201. * Get the current class name of the texture useful for serialization or dynamic coding.
  25202. * @returns "PBRClearCoatConfiguration"
  25203. */
  25204. getClassName(): string;
  25205. /**
  25206. * Makes a duplicate of the current configuration into another one.
  25207. * @param brdfConfiguration define the config where to copy the info
  25208. */
  25209. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  25210. /**
  25211. * Serializes this BRDF configuration.
  25212. * @returns - An object with the serialized config.
  25213. */
  25214. serialize(): any;
  25215. /**
  25216. * Parses a anisotropy Configuration from a serialized object.
  25217. * @param source - Serialized object.
  25218. * @param scene Defines the scene we are parsing for
  25219. * @param rootUrl Defines the rootUrl to load from
  25220. */
  25221. parse(source: any, scene: Scene, rootUrl: string): void;
  25222. }
  25223. }
  25224. declare module BABYLON {
  25225. /**
  25226. * @hidden
  25227. */
  25228. export interface IMaterialSheenDefines {
  25229. SHEEN: boolean;
  25230. SHEEN_TEXTURE: boolean;
  25231. SHEEN_TEXTURE_ROUGHNESS: boolean;
  25232. SHEEN_TEXTUREDIRECTUV: number;
  25233. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  25234. SHEEN_LINKWITHALBEDO: boolean;
  25235. SHEEN_ROUGHNESS: boolean;
  25236. SHEEN_ALBEDOSCALING: boolean;
  25237. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25238. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25239. /** @hidden */
  25240. _areTexturesDirty: boolean;
  25241. }
  25242. /**
  25243. * Define the code related to the Sheen parameters of the pbr material.
  25244. */
  25245. export class PBRSheenConfiguration {
  25246. private _isEnabled;
  25247. /**
  25248. * Defines if the material uses sheen.
  25249. */
  25250. isEnabled: boolean;
  25251. private _linkSheenWithAlbedo;
  25252. /**
  25253. * Defines if the sheen is linked to the sheen color.
  25254. */
  25255. linkSheenWithAlbedo: boolean;
  25256. /**
  25257. * Defines the sheen intensity.
  25258. */
  25259. intensity: number;
  25260. /**
  25261. * Defines the sheen color.
  25262. */
  25263. color: Color3;
  25264. private _texture;
  25265. /**
  25266. * Stores the sheen tint values in a texture.
  25267. * rgb is tint
  25268. * 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)
  25269. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  25270. */
  25271. texture: Nullable<BaseTexture>;
  25272. private _useRoughnessFromMainTexture;
  25273. /**
  25274. * Indicates that the alpha channel of the texture property will be used for roughness.
  25275. * Has no effect if the roughness (and texture!) property is not defined
  25276. */
  25277. useRoughnessFromMainTexture: boolean;
  25278. private _roughness;
  25279. /**
  25280. * Defines the sheen roughness.
  25281. * It is not taken into account if linkSheenWithAlbedo is true.
  25282. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25283. */
  25284. roughness: Nullable<number>;
  25285. private _textureRoughness;
  25286. /**
  25287. * Stores the sheen roughness in a texture.
  25288. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  25289. */
  25290. textureRoughness: Nullable<BaseTexture>;
  25291. private _albedoScaling;
  25292. /**
  25293. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25294. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25295. * making it easier to setup and tweak the effect
  25296. */
  25297. albedoScaling: boolean;
  25298. /** @hidden */
  25299. private _internalMarkAllSubMeshesAsTexturesDirty;
  25300. /** @hidden */
  25301. _markAllSubMeshesAsTexturesDirty(): void;
  25302. /**
  25303. * Instantiate a new istance of clear coat configuration.
  25304. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25305. */
  25306. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25307. /**
  25308. * Specifies that the submesh is ready to be used.
  25309. * @param defines the list of "defines" to update.
  25310. * @param scene defines the scene the material belongs to.
  25311. * @returns - boolean indicating that the submesh is ready or not.
  25312. */
  25313. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25314. /**
  25315. * Checks to see if a texture is used in the material.
  25316. * @param defines the list of "defines" to update.
  25317. * @param scene defines the scene the material belongs to.
  25318. */
  25319. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25320. /**
  25321. * Binds the material data.
  25322. * @param uniformBuffer defines the Uniform buffer to fill in.
  25323. * @param scene defines the scene the material belongs to.
  25324. * @param isFrozen defines wether the material is frozen or not.
  25325. * @param subMesh the submesh to bind data for
  25326. */
  25327. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25328. /**
  25329. * Checks to see if a texture is used in the material.
  25330. * @param texture - Base texture to use.
  25331. * @returns - Boolean specifying if a texture is used in the material.
  25332. */
  25333. hasTexture(texture: BaseTexture): boolean;
  25334. /**
  25335. * Returns an array of the actively used textures.
  25336. * @param activeTextures Array of BaseTextures
  25337. */
  25338. getActiveTextures(activeTextures: BaseTexture[]): void;
  25339. /**
  25340. * Returns the animatable textures.
  25341. * @param animatables Array of animatable textures.
  25342. */
  25343. getAnimatables(animatables: IAnimatable[]): void;
  25344. /**
  25345. * Disposes the resources of the material.
  25346. * @param forceDisposeTextures - Forces the disposal of all textures.
  25347. */
  25348. dispose(forceDisposeTextures?: boolean): void;
  25349. /**
  25350. * Get the current class name of the texture useful for serialization or dynamic coding.
  25351. * @returns "PBRSheenConfiguration"
  25352. */
  25353. getClassName(): string;
  25354. /**
  25355. * Add fallbacks to the effect fallbacks list.
  25356. * @param defines defines the Base texture to use.
  25357. * @param fallbacks defines the current fallback list.
  25358. * @param currentRank defines the current fallback rank.
  25359. * @returns the new fallback rank.
  25360. */
  25361. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25362. /**
  25363. * Add the required uniforms to the current list.
  25364. * @param uniforms defines the current uniform list.
  25365. */
  25366. static AddUniforms(uniforms: string[]): void;
  25367. /**
  25368. * Add the required uniforms to the current buffer.
  25369. * @param uniformBuffer defines the current uniform buffer.
  25370. */
  25371. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25372. /**
  25373. * Add the required samplers to the current list.
  25374. * @param samplers defines the current sampler list.
  25375. */
  25376. static AddSamplers(samplers: string[]): void;
  25377. /**
  25378. * Makes a duplicate of the current configuration into another one.
  25379. * @param sheenConfiguration define the config where to copy the info
  25380. */
  25381. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  25382. /**
  25383. * Serializes this BRDF configuration.
  25384. * @returns - An object with the serialized config.
  25385. */
  25386. serialize(): any;
  25387. /**
  25388. * Parses a anisotropy Configuration from a serialized object.
  25389. * @param source - Serialized object.
  25390. * @param scene Defines the scene we are parsing for
  25391. * @param rootUrl Defines the rootUrl to load from
  25392. */
  25393. parse(source: any, scene: Scene, rootUrl: string): void;
  25394. }
  25395. }
  25396. declare module BABYLON {
  25397. /**
  25398. * @hidden
  25399. */
  25400. export interface IMaterialSubSurfaceDefines {
  25401. SUBSURFACE: boolean;
  25402. SS_REFRACTION: boolean;
  25403. SS_TRANSLUCENCY: boolean;
  25404. SS_SCATTERING: boolean;
  25405. SS_THICKNESSANDMASK_TEXTURE: boolean;
  25406. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  25407. SS_REFRACTIONMAP_3D: boolean;
  25408. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  25409. SS_LODINREFRACTIONALPHA: boolean;
  25410. SS_GAMMAREFRACTION: boolean;
  25411. SS_RGBDREFRACTION: boolean;
  25412. SS_LINEARSPECULARREFRACTION: boolean;
  25413. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  25414. SS_ALBEDOFORREFRACTIONTINT: boolean;
  25415. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  25416. /** @hidden */
  25417. _areTexturesDirty: boolean;
  25418. }
  25419. /**
  25420. * Define the code related to the sub surface parameters of the pbr material.
  25421. */
  25422. export class PBRSubSurfaceConfiguration {
  25423. private _isRefractionEnabled;
  25424. /**
  25425. * Defines if the refraction is enabled in the material.
  25426. */
  25427. isRefractionEnabled: boolean;
  25428. private _isTranslucencyEnabled;
  25429. /**
  25430. * Defines if the translucency is enabled in the material.
  25431. */
  25432. isTranslucencyEnabled: boolean;
  25433. private _isScatteringEnabled;
  25434. /**
  25435. * Defines if the sub surface scattering is enabled in the material.
  25436. */
  25437. isScatteringEnabled: boolean;
  25438. private _scatteringDiffusionProfileIndex;
  25439. /**
  25440. * Diffusion profile for subsurface scattering.
  25441. * Useful for better scattering in the skins or foliages.
  25442. */
  25443. get scatteringDiffusionProfile(): Nullable<Color3>;
  25444. set scatteringDiffusionProfile(c: Nullable<Color3>);
  25445. /**
  25446. * Defines the refraction intensity of the material.
  25447. * The refraction when enabled replaces the Diffuse part of the material.
  25448. * The intensity helps transitionning between diffuse and refraction.
  25449. */
  25450. refractionIntensity: number;
  25451. /**
  25452. * Defines the translucency intensity of the material.
  25453. * When translucency has been enabled, this defines how much of the "translucency"
  25454. * is addded to the diffuse part of the material.
  25455. */
  25456. translucencyIntensity: number;
  25457. /**
  25458. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  25459. */
  25460. useAlbedoToTintRefraction: boolean;
  25461. private _thicknessTexture;
  25462. /**
  25463. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  25464. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  25465. * 0 would mean minimumThickness
  25466. * 1 would mean maximumThickness
  25467. * The other channels might be use as a mask to vary the different effects intensity.
  25468. */
  25469. thicknessTexture: Nullable<BaseTexture>;
  25470. private _refractionTexture;
  25471. /**
  25472. * Defines the texture to use for refraction.
  25473. */
  25474. refractionTexture: Nullable<BaseTexture>;
  25475. private _indexOfRefraction;
  25476. /**
  25477. * Index of refraction of the material base layer.
  25478. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25479. *
  25480. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  25481. *
  25482. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  25483. */
  25484. indexOfRefraction: number;
  25485. private _volumeIndexOfRefraction;
  25486. /**
  25487. * Index of refraction of the material's volume.
  25488. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25489. *
  25490. * This ONLY impacts refraction. If not provided or given a non-valid value,
  25491. * the volume will use the same IOR as the surface.
  25492. */
  25493. get volumeIndexOfRefraction(): number;
  25494. set volumeIndexOfRefraction(value: number);
  25495. private _invertRefractionY;
  25496. /**
  25497. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  25498. */
  25499. invertRefractionY: boolean;
  25500. private _linkRefractionWithTransparency;
  25501. /**
  25502. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25503. * Materials half opaque for instance using refraction could benefit from this control.
  25504. */
  25505. linkRefractionWithTransparency: boolean;
  25506. /**
  25507. * Defines the minimum thickness stored in the thickness map.
  25508. * If no thickness map is defined, this value will be used to simulate thickness.
  25509. */
  25510. minimumThickness: number;
  25511. /**
  25512. * Defines the maximum thickness stored in the thickness map.
  25513. */
  25514. maximumThickness: number;
  25515. /**
  25516. * Defines the volume tint of the material.
  25517. * This is used for both translucency and scattering.
  25518. */
  25519. tintColor: Color3;
  25520. /**
  25521. * Defines the distance at which the tint color should be found in the media.
  25522. * This is used for refraction only.
  25523. */
  25524. tintColorAtDistance: number;
  25525. /**
  25526. * Defines how far each channel transmit through the media.
  25527. * It is defined as a color to simplify it selection.
  25528. */
  25529. diffusionDistance: Color3;
  25530. private _useMaskFromThicknessTexture;
  25531. /**
  25532. * Stores the intensity of the different subsurface effects in the thickness texture.
  25533. * * the green channel is the translucency intensity.
  25534. * * the blue channel is the scattering intensity.
  25535. * * the alpha channel is the refraction intensity.
  25536. */
  25537. useMaskFromThicknessTexture: boolean;
  25538. private _scene;
  25539. /** @hidden */
  25540. private _internalMarkAllSubMeshesAsTexturesDirty;
  25541. private _internalMarkScenePrePassDirty;
  25542. /** @hidden */
  25543. _markAllSubMeshesAsTexturesDirty(): void;
  25544. /** @hidden */
  25545. _markScenePrePassDirty(): void;
  25546. /**
  25547. * Instantiate a new istance of sub surface configuration.
  25548. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25549. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  25550. * @param scene The scene
  25551. */
  25552. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  25553. /**
  25554. * Gets wehter the submesh is ready to be used or not.
  25555. * @param defines the list of "defines" to update.
  25556. * @param scene defines the scene the material belongs to.
  25557. * @returns - boolean indicating that the submesh is ready or not.
  25558. */
  25559. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  25560. /**
  25561. * Checks to see if a texture is used in the material.
  25562. * @param defines the list of "defines" to update.
  25563. * @param scene defines the scene to the material belongs to.
  25564. */
  25565. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  25566. /**
  25567. * Binds the material data.
  25568. * @param uniformBuffer defines the Uniform buffer to fill in.
  25569. * @param scene defines the scene the material belongs to.
  25570. * @param engine defines the engine the material belongs to.
  25571. * @param isFrozen defines whether the material is frozen or not.
  25572. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  25573. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  25574. */
  25575. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  25576. /**
  25577. * Unbinds the material from the mesh.
  25578. * @param activeEffect defines the effect that should be unbound from.
  25579. * @returns true if unbound, otherwise false
  25580. */
  25581. unbind(activeEffect: Effect): boolean;
  25582. /**
  25583. * Returns the texture used for refraction or null if none is used.
  25584. * @param scene defines the scene the material belongs to.
  25585. * @returns - Refraction texture if present. If no refraction texture and refraction
  25586. * is linked with transparency, returns environment texture. Otherwise, returns null.
  25587. */
  25588. private _getRefractionTexture;
  25589. /**
  25590. * Returns true if alpha blending should be disabled.
  25591. */
  25592. get disableAlphaBlending(): boolean;
  25593. /**
  25594. * Fills the list of render target textures.
  25595. * @param renderTargets the list of render targets to update
  25596. */
  25597. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  25598. /**
  25599. * Checks to see if a texture is used in the material.
  25600. * @param texture - Base texture to use.
  25601. * @returns - Boolean specifying if a texture is used in the material.
  25602. */
  25603. hasTexture(texture: BaseTexture): boolean;
  25604. /**
  25605. * Gets a boolean indicating that current material needs to register RTT
  25606. * @returns true if this uses a render target otherwise false.
  25607. */
  25608. hasRenderTargetTextures(): boolean;
  25609. /**
  25610. * Returns an array of the actively used textures.
  25611. * @param activeTextures Array of BaseTextures
  25612. */
  25613. getActiveTextures(activeTextures: BaseTexture[]): void;
  25614. /**
  25615. * Returns the animatable textures.
  25616. * @param animatables Array of animatable textures.
  25617. */
  25618. getAnimatables(animatables: IAnimatable[]): void;
  25619. /**
  25620. * Disposes the resources of the material.
  25621. * @param forceDisposeTextures - Forces the disposal of all textures.
  25622. */
  25623. dispose(forceDisposeTextures?: boolean): void;
  25624. /**
  25625. * Get the current class name of the texture useful for serialization or dynamic coding.
  25626. * @returns "PBRSubSurfaceConfiguration"
  25627. */
  25628. getClassName(): string;
  25629. /**
  25630. * Add fallbacks to the effect fallbacks list.
  25631. * @param defines defines the Base texture to use.
  25632. * @param fallbacks defines the current fallback list.
  25633. * @param currentRank defines the current fallback rank.
  25634. * @returns the new fallback rank.
  25635. */
  25636. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25637. /**
  25638. * Add the required uniforms to the current list.
  25639. * @param uniforms defines the current uniform list.
  25640. */
  25641. static AddUniforms(uniforms: string[]): void;
  25642. /**
  25643. * Add the required samplers to the current list.
  25644. * @param samplers defines the current sampler list.
  25645. */
  25646. static AddSamplers(samplers: string[]): void;
  25647. /**
  25648. * Add the required uniforms to the current buffer.
  25649. * @param uniformBuffer defines the current uniform buffer.
  25650. */
  25651. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25652. /**
  25653. * Makes a duplicate of the current configuration into another one.
  25654. * @param configuration define the config where to copy the info
  25655. */
  25656. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  25657. /**
  25658. * Serializes this Sub Surface configuration.
  25659. * @returns - An object with the serialized config.
  25660. */
  25661. serialize(): any;
  25662. /**
  25663. * Parses a anisotropy Configuration from a serialized object.
  25664. * @param source - Serialized object.
  25665. * @param scene Defines the scene we are parsing for
  25666. * @param rootUrl Defines the rootUrl to load from
  25667. */
  25668. parse(source: any, scene: Scene, rootUrl: string): void;
  25669. }
  25670. }
  25671. declare module BABYLON {
  25672. /**
  25673. * Class representing spherical harmonics coefficients to the 3rd degree
  25674. */
  25675. export class SphericalHarmonics {
  25676. /**
  25677. * Defines whether or not the harmonics have been prescaled for rendering.
  25678. */
  25679. preScaled: boolean;
  25680. /**
  25681. * The l0,0 coefficients of the spherical harmonics
  25682. */
  25683. l00: Vector3;
  25684. /**
  25685. * The l1,-1 coefficients of the spherical harmonics
  25686. */
  25687. l1_1: Vector3;
  25688. /**
  25689. * The l1,0 coefficients of the spherical harmonics
  25690. */
  25691. l10: Vector3;
  25692. /**
  25693. * The l1,1 coefficients of the spherical harmonics
  25694. */
  25695. l11: Vector3;
  25696. /**
  25697. * The l2,-2 coefficients of the spherical harmonics
  25698. */
  25699. l2_2: Vector3;
  25700. /**
  25701. * The l2,-1 coefficients of the spherical harmonics
  25702. */
  25703. l2_1: Vector3;
  25704. /**
  25705. * The l2,0 coefficients of the spherical harmonics
  25706. */
  25707. l20: Vector3;
  25708. /**
  25709. * The l2,1 coefficients of the spherical harmonics
  25710. */
  25711. l21: Vector3;
  25712. /**
  25713. * The l2,2 coefficients of the spherical harmonics
  25714. */
  25715. l22: Vector3;
  25716. /**
  25717. * Adds a light to the spherical harmonics
  25718. * @param direction the direction of the light
  25719. * @param color the color of the light
  25720. * @param deltaSolidAngle the delta solid angle of the light
  25721. */
  25722. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  25723. /**
  25724. * Scales the spherical harmonics by the given amount
  25725. * @param scale the amount to scale
  25726. */
  25727. scaleInPlace(scale: number): void;
  25728. /**
  25729. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  25730. *
  25731. * ```
  25732. * E_lm = A_l * L_lm
  25733. * ```
  25734. *
  25735. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  25736. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  25737. * the scaling factors are given in equation 9.
  25738. */
  25739. convertIncidentRadianceToIrradiance(): void;
  25740. /**
  25741. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  25742. *
  25743. * ```
  25744. * L = (1/pi) * E * rho
  25745. * ```
  25746. *
  25747. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  25748. */
  25749. convertIrradianceToLambertianRadiance(): void;
  25750. /**
  25751. * Integrates the reconstruction coefficients directly in to the SH preventing further
  25752. * required operations at run time.
  25753. *
  25754. * This is simply done by scaling back the SH with Ylm constants parameter.
  25755. * The trigonometric part being applied by the shader at run time.
  25756. */
  25757. preScaleForRendering(): void;
  25758. /**
  25759. * Constructs a spherical harmonics from an array.
  25760. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  25761. * @returns the spherical harmonics
  25762. */
  25763. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  25764. /**
  25765. * Gets the spherical harmonics from polynomial
  25766. * @param polynomial the spherical polynomial
  25767. * @returns the spherical harmonics
  25768. */
  25769. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  25770. }
  25771. /**
  25772. * Class representing spherical polynomial coefficients to the 3rd degree
  25773. */
  25774. export class SphericalPolynomial {
  25775. private _harmonics;
  25776. /**
  25777. * The spherical harmonics used to create the polynomials.
  25778. */
  25779. get preScaledHarmonics(): SphericalHarmonics;
  25780. /**
  25781. * The x coefficients of the spherical polynomial
  25782. */
  25783. x: Vector3;
  25784. /**
  25785. * The y coefficients of the spherical polynomial
  25786. */
  25787. y: Vector3;
  25788. /**
  25789. * The z coefficients of the spherical polynomial
  25790. */
  25791. z: Vector3;
  25792. /**
  25793. * The xx coefficients of the spherical polynomial
  25794. */
  25795. xx: Vector3;
  25796. /**
  25797. * The yy coefficients of the spherical polynomial
  25798. */
  25799. yy: Vector3;
  25800. /**
  25801. * The zz coefficients of the spherical polynomial
  25802. */
  25803. zz: Vector3;
  25804. /**
  25805. * The xy coefficients of the spherical polynomial
  25806. */
  25807. xy: Vector3;
  25808. /**
  25809. * The yz coefficients of the spherical polynomial
  25810. */
  25811. yz: Vector3;
  25812. /**
  25813. * The zx coefficients of the spherical polynomial
  25814. */
  25815. zx: Vector3;
  25816. /**
  25817. * Adds an ambient color to the spherical polynomial
  25818. * @param color the color to add
  25819. */
  25820. addAmbient(color: Color3): void;
  25821. /**
  25822. * Scales the spherical polynomial by the given amount
  25823. * @param scale the amount to scale
  25824. */
  25825. scaleInPlace(scale: number): void;
  25826. /**
  25827. * Gets the spherical polynomial from harmonics
  25828. * @param harmonics the spherical harmonics
  25829. * @returns the spherical polynomial
  25830. */
  25831. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  25832. /**
  25833. * Constructs a spherical polynomial from an array.
  25834. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  25835. * @returns the spherical polynomial
  25836. */
  25837. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  25838. }
  25839. }
  25840. declare module BABYLON {
  25841. /**
  25842. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  25843. */
  25844. export interface CubeMapInfo {
  25845. /**
  25846. * The pixel array for the front face.
  25847. * This is stored in format, left to right, up to down format.
  25848. */
  25849. front: Nullable<ArrayBufferView>;
  25850. /**
  25851. * The pixel array for the back face.
  25852. * This is stored in format, left to right, up to down format.
  25853. */
  25854. back: Nullable<ArrayBufferView>;
  25855. /**
  25856. * The pixel array for the left face.
  25857. * This is stored in format, left to right, up to down format.
  25858. */
  25859. left: Nullable<ArrayBufferView>;
  25860. /**
  25861. * The pixel array for the right face.
  25862. * This is stored in format, left to right, up to down format.
  25863. */
  25864. right: Nullable<ArrayBufferView>;
  25865. /**
  25866. * The pixel array for the up face.
  25867. * This is stored in format, left to right, up to down format.
  25868. */
  25869. up: Nullable<ArrayBufferView>;
  25870. /**
  25871. * The pixel array for the down face.
  25872. * This is stored in format, left to right, up to down format.
  25873. */
  25874. down: Nullable<ArrayBufferView>;
  25875. /**
  25876. * The size of the cubemap stored.
  25877. *
  25878. * Each faces will be size * size pixels.
  25879. */
  25880. size: number;
  25881. /**
  25882. * The format of the texture.
  25883. *
  25884. * RGBA, RGB.
  25885. */
  25886. format: number;
  25887. /**
  25888. * The type of the texture data.
  25889. *
  25890. * UNSIGNED_INT, FLOAT.
  25891. */
  25892. type: number;
  25893. /**
  25894. * Specifies whether the texture is in gamma space.
  25895. */
  25896. gammaSpace: boolean;
  25897. }
  25898. /**
  25899. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  25900. */
  25901. export class PanoramaToCubeMapTools {
  25902. private static FACE_LEFT;
  25903. private static FACE_RIGHT;
  25904. private static FACE_FRONT;
  25905. private static FACE_BACK;
  25906. private static FACE_DOWN;
  25907. private static FACE_UP;
  25908. /**
  25909. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  25910. *
  25911. * @param float32Array The source data.
  25912. * @param inputWidth The width of the input panorama.
  25913. * @param inputHeight The height of the input panorama.
  25914. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  25915. * @return The cubemap data
  25916. */
  25917. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  25918. private static CreateCubemapTexture;
  25919. private static CalcProjectionSpherical;
  25920. }
  25921. }
  25922. declare module BABYLON {
  25923. /**
  25924. * Helper class dealing with the extraction of spherical polynomial dataArray
  25925. * from a cube map.
  25926. */
  25927. export class CubeMapToSphericalPolynomialTools {
  25928. private static FileFaces;
  25929. /**
  25930. * Converts a texture to the according Spherical Polynomial data.
  25931. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25932. *
  25933. * @param texture The texture to extract the information from.
  25934. * @return The Spherical Polynomial data.
  25935. */
  25936. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  25937. /**
  25938. * Converts a cubemap to the according Spherical Polynomial data.
  25939. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25940. *
  25941. * @param cubeInfo The Cube map to extract the information from.
  25942. * @return The Spherical Polynomial data.
  25943. */
  25944. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  25945. }
  25946. }
  25947. declare module BABYLON {
  25948. interface BaseTexture {
  25949. /**
  25950. * Get the polynomial representation of the texture data.
  25951. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25952. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25953. */
  25954. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25955. }
  25956. }
  25957. declare module BABYLON {
  25958. /** @hidden */
  25959. export var pbrFragmentDeclaration: {
  25960. name: string;
  25961. shader: string;
  25962. };
  25963. }
  25964. declare module BABYLON {
  25965. /** @hidden */
  25966. export var pbrUboDeclaration: {
  25967. name: string;
  25968. shader: string;
  25969. };
  25970. }
  25971. declare module BABYLON {
  25972. /** @hidden */
  25973. export var pbrFragmentExtraDeclaration: {
  25974. name: string;
  25975. shader: string;
  25976. };
  25977. }
  25978. declare module BABYLON {
  25979. /** @hidden */
  25980. export var pbrFragmentSamplersDeclaration: {
  25981. name: string;
  25982. shader: string;
  25983. };
  25984. }
  25985. declare module BABYLON {
  25986. /** @hidden */
  25987. export var subSurfaceScatteringFunctions: {
  25988. name: string;
  25989. shader: string;
  25990. };
  25991. }
  25992. declare module BABYLON {
  25993. /** @hidden */
  25994. export var importanceSampling: {
  25995. name: string;
  25996. shader: string;
  25997. };
  25998. }
  25999. declare module BABYLON {
  26000. /** @hidden */
  26001. export var pbrHelperFunctions: {
  26002. name: string;
  26003. shader: string;
  26004. };
  26005. }
  26006. declare module BABYLON {
  26007. /** @hidden */
  26008. export var harmonicsFunctions: {
  26009. name: string;
  26010. shader: string;
  26011. };
  26012. }
  26013. declare module BABYLON {
  26014. /** @hidden */
  26015. export var pbrDirectLightingSetupFunctions: {
  26016. name: string;
  26017. shader: string;
  26018. };
  26019. }
  26020. declare module BABYLON {
  26021. /** @hidden */
  26022. export var pbrDirectLightingFalloffFunctions: {
  26023. name: string;
  26024. shader: string;
  26025. };
  26026. }
  26027. declare module BABYLON {
  26028. /** @hidden */
  26029. export var pbrBRDFFunctions: {
  26030. name: string;
  26031. shader: string;
  26032. };
  26033. }
  26034. declare module BABYLON {
  26035. /** @hidden */
  26036. export var hdrFilteringFunctions: {
  26037. name: string;
  26038. shader: string;
  26039. };
  26040. }
  26041. declare module BABYLON {
  26042. /** @hidden */
  26043. export var pbrDirectLightingFunctions: {
  26044. name: string;
  26045. shader: string;
  26046. };
  26047. }
  26048. declare module BABYLON {
  26049. /** @hidden */
  26050. export var pbrIBLFunctions: {
  26051. name: string;
  26052. shader: string;
  26053. };
  26054. }
  26055. declare module BABYLON {
  26056. /** @hidden */
  26057. export var pbrBlockAlbedoOpacity: {
  26058. name: string;
  26059. shader: string;
  26060. };
  26061. }
  26062. declare module BABYLON {
  26063. /** @hidden */
  26064. export var pbrBlockReflectivity: {
  26065. name: string;
  26066. shader: string;
  26067. };
  26068. }
  26069. declare module BABYLON {
  26070. /** @hidden */
  26071. export var pbrBlockAmbientOcclusion: {
  26072. name: string;
  26073. shader: string;
  26074. };
  26075. }
  26076. declare module BABYLON {
  26077. /** @hidden */
  26078. export var pbrBlockAlphaFresnel: {
  26079. name: string;
  26080. shader: string;
  26081. };
  26082. }
  26083. declare module BABYLON {
  26084. /** @hidden */
  26085. export var pbrBlockAnisotropic: {
  26086. name: string;
  26087. shader: string;
  26088. };
  26089. }
  26090. declare module BABYLON {
  26091. /** @hidden */
  26092. export var pbrBlockReflection: {
  26093. name: string;
  26094. shader: string;
  26095. };
  26096. }
  26097. declare module BABYLON {
  26098. /** @hidden */
  26099. export var pbrBlockSheen: {
  26100. name: string;
  26101. shader: string;
  26102. };
  26103. }
  26104. declare module BABYLON {
  26105. /** @hidden */
  26106. export var pbrBlockClearcoat: {
  26107. name: string;
  26108. shader: string;
  26109. };
  26110. }
  26111. declare module BABYLON {
  26112. /** @hidden */
  26113. export var pbrBlockSubSurface: {
  26114. name: string;
  26115. shader: string;
  26116. };
  26117. }
  26118. declare module BABYLON {
  26119. /** @hidden */
  26120. export var pbrBlockNormalGeometric: {
  26121. name: string;
  26122. shader: string;
  26123. };
  26124. }
  26125. declare module BABYLON {
  26126. /** @hidden */
  26127. export var pbrBlockNormalFinal: {
  26128. name: string;
  26129. shader: string;
  26130. };
  26131. }
  26132. declare module BABYLON {
  26133. /** @hidden */
  26134. export var pbrBlockLightmapInit: {
  26135. name: string;
  26136. shader: string;
  26137. };
  26138. }
  26139. declare module BABYLON {
  26140. /** @hidden */
  26141. export var pbrBlockGeometryInfo: {
  26142. name: string;
  26143. shader: string;
  26144. };
  26145. }
  26146. declare module BABYLON {
  26147. /** @hidden */
  26148. export var pbrBlockReflectance0: {
  26149. name: string;
  26150. shader: string;
  26151. };
  26152. }
  26153. declare module BABYLON {
  26154. /** @hidden */
  26155. export var pbrBlockReflectance: {
  26156. name: string;
  26157. shader: string;
  26158. };
  26159. }
  26160. declare module BABYLON {
  26161. /** @hidden */
  26162. export var pbrBlockDirectLighting: {
  26163. name: string;
  26164. shader: string;
  26165. };
  26166. }
  26167. declare module BABYLON {
  26168. /** @hidden */
  26169. export var pbrBlockFinalLitComponents: {
  26170. name: string;
  26171. shader: string;
  26172. };
  26173. }
  26174. declare module BABYLON {
  26175. /** @hidden */
  26176. export var pbrBlockFinalUnlitComponents: {
  26177. name: string;
  26178. shader: string;
  26179. };
  26180. }
  26181. declare module BABYLON {
  26182. /** @hidden */
  26183. export var pbrBlockFinalColorComposition: {
  26184. name: string;
  26185. shader: string;
  26186. };
  26187. }
  26188. declare module BABYLON {
  26189. /** @hidden */
  26190. export var pbrBlockImageProcessing: {
  26191. name: string;
  26192. shader: string;
  26193. };
  26194. }
  26195. declare module BABYLON {
  26196. /** @hidden */
  26197. export var pbrDebug: {
  26198. name: string;
  26199. shader: string;
  26200. };
  26201. }
  26202. declare module BABYLON {
  26203. /** @hidden */
  26204. export var pbrPixelShader: {
  26205. name: string;
  26206. shader: string;
  26207. };
  26208. }
  26209. declare module BABYLON {
  26210. /** @hidden */
  26211. export var pbrVertexDeclaration: {
  26212. name: string;
  26213. shader: string;
  26214. };
  26215. }
  26216. declare module BABYLON {
  26217. /** @hidden */
  26218. export var pbrVertexShader: {
  26219. name: string;
  26220. shader: string;
  26221. };
  26222. }
  26223. declare module BABYLON {
  26224. /**
  26225. * Manages the defines for the PBR Material.
  26226. * @hidden
  26227. */
  26228. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  26229. PBR: boolean;
  26230. NUM_SAMPLES: string;
  26231. REALTIME_FILTERING: boolean;
  26232. MAINUV1: boolean;
  26233. MAINUV2: boolean;
  26234. UV1: boolean;
  26235. UV2: boolean;
  26236. ALBEDO: boolean;
  26237. GAMMAALBEDO: boolean;
  26238. ALBEDODIRECTUV: number;
  26239. VERTEXCOLOR: boolean;
  26240. DETAIL: boolean;
  26241. DETAILDIRECTUV: number;
  26242. DETAIL_NORMALBLENDMETHOD: number;
  26243. AMBIENT: boolean;
  26244. AMBIENTDIRECTUV: number;
  26245. AMBIENTINGRAYSCALE: boolean;
  26246. OPACITY: boolean;
  26247. VERTEXALPHA: boolean;
  26248. OPACITYDIRECTUV: number;
  26249. OPACITYRGB: boolean;
  26250. ALPHATEST: boolean;
  26251. DEPTHPREPASS: boolean;
  26252. ALPHABLEND: boolean;
  26253. ALPHAFROMALBEDO: boolean;
  26254. ALPHATESTVALUE: string;
  26255. SPECULAROVERALPHA: boolean;
  26256. RADIANCEOVERALPHA: boolean;
  26257. ALPHAFRESNEL: boolean;
  26258. LINEARALPHAFRESNEL: boolean;
  26259. PREMULTIPLYALPHA: boolean;
  26260. EMISSIVE: boolean;
  26261. EMISSIVEDIRECTUV: number;
  26262. REFLECTIVITY: boolean;
  26263. REFLECTIVITYDIRECTUV: number;
  26264. SPECULARTERM: boolean;
  26265. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  26266. MICROSURFACEAUTOMATIC: boolean;
  26267. LODBASEDMICROSFURACE: boolean;
  26268. MICROSURFACEMAP: boolean;
  26269. MICROSURFACEMAPDIRECTUV: number;
  26270. METALLICWORKFLOW: boolean;
  26271. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  26272. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  26273. METALLNESSSTOREINMETALMAPBLUE: boolean;
  26274. AOSTOREINMETALMAPRED: boolean;
  26275. METALLIC_REFLECTANCE: boolean;
  26276. METALLIC_REFLECTANCEDIRECTUV: number;
  26277. ENVIRONMENTBRDF: boolean;
  26278. ENVIRONMENTBRDF_RGBD: boolean;
  26279. NORMAL: boolean;
  26280. TANGENT: boolean;
  26281. BUMP: boolean;
  26282. BUMPDIRECTUV: number;
  26283. OBJECTSPACE_NORMALMAP: boolean;
  26284. PARALLAX: boolean;
  26285. PARALLAXOCCLUSION: boolean;
  26286. NORMALXYSCALE: boolean;
  26287. LIGHTMAP: boolean;
  26288. LIGHTMAPDIRECTUV: number;
  26289. USELIGHTMAPASSHADOWMAP: boolean;
  26290. GAMMALIGHTMAP: boolean;
  26291. RGBDLIGHTMAP: boolean;
  26292. REFLECTION: boolean;
  26293. REFLECTIONMAP_3D: boolean;
  26294. REFLECTIONMAP_SPHERICAL: boolean;
  26295. REFLECTIONMAP_PLANAR: boolean;
  26296. REFLECTIONMAP_CUBIC: boolean;
  26297. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26298. REFLECTIONMAP_PROJECTION: boolean;
  26299. REFLECTIONMAP_SKYBOX: boolean;
  26300. REFLECTIONMAP_EXPLICIT: boolean;
  26301. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26302. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26303. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26304. INVERTCUBICMAP: boolean;
  26305. USESPHERICALFROMREFLECTIONMAP: boolean;
  26306. USEIRRADIANCEMAP: boolean;
  26307. SPHERICAL_HARMONICS: boolean;
  26308. USESPHERICALINVERTEX: boolean;
  26309. REFLECTIONMAP_OPPOSITEZ: boolean;
  26310. LODINREFLECTIONALPHA: boolean;
  26311. GAMMAREFLECTION: boolean;
  26312. RGBDREFLECTION: boolean;
  26313. LINEARSPECULARREFLECTION: boolean;
  26314. RADIANCEOCCLUSION: boolean;
  26315. HORIZONOCCLUSION: boolean;
  26316. INSTANCES: boolean;
  26317. THIN_INSTANCES: boolean;
  26318. PREPASS: boolean;
  26319. PREPASS_IRRADIANCE: boolean;
  26320. PREPASS_IRRADIANCE_INDEX: number;
  26321. PREPASS_ALBEDO: boolean;
  26322. PREPASS_ALBEDO_INDEX: number;
  26323. PREPASS_DEPTHNORMAL: boolean;
  26324. PREPASS_DEPTHNORMAL_INDEX: number;
  26325. PREPASS_POSITION: boolean;
  26326. PREPASS_POSITION_INDEX: number;
  26327. PREPASS_VELOCITY: boolean;
  26328. PREPASS_VELOCITY_INDEX: number;
  26329. PREPASS_REFLECTIVITY: boolean;
  26330. PREPASS_REFLECTIVITY_INDEX: number;
  26331. SCENE_MRT_COUNT: number;
  26332. NUM_BONE_INFLUENCERS: number;
  26333. BonesPerMesh: number;
  26334. BONETEXTURE: boolean;
  26335. BONES_VELOCITY_ENABLED: boolean;
  26336. NONUNIFORMSCALING: boolean;
  26337. MORPHTARGETS: boolean;
  26338. MORPHTARGETS_NORMAL: boolean;
  26339. MORPHTARGETS_TANGENT: boolean;
  26340. MORPHTARGETS_UV: boolean;
  26341. NUM_MORPH_INFLUENCERS: number;
  26342. IMAGEPROCESSING: boolean;
  26343. VIGNETTE: boolean;
  26344. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26345. VIGNETTEBLENDMODEOPAQUE: boolean;
  26346. TONEMAPPING: boolean;
  26347. TONEMAPPING_ACES: boolean;
  26348. CONTRAST: boolean;
  26349. COLORCURVES: boolean;
  26350. COLORGRADING: boolean;
  26351. COLORGRADING3D: boolean;
  26352. SAMPLER3DGREENDEPTH: boolean;
  26353. SAMPLER3DBGRMAP: boolean;
  26354. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26355. EXPOSURE: boolean;
  26356. MULTIVIEW: boolean;
  26357. USEPHYSICALLIGHTFALLOFF: boolean;
  26358. USEGLTFLIGHTFALLOFF: boolean;
  26359. TWOSIDEDLIGHTING: boolean;
  26360. SHADOWFLOAT: boolean;
  26361. CLIPPLANE: boolean;
  26362. CLIPPLANE2: boolean;
  26363. CLIPPLANE3: boolean;
  26364. CLIPPLANE4: boolean;
  26365. CLIPPLANE5: boolean;
  26366. CLIPPLANE6: boolean;
  26367. POINTSIZE: boolean;
  26368. FOG: boolean;
  26369. LOGARITHMICDEPTH: boolean;
  26370. FORCENORMALFORWARD: boolean;
  26371. SPECULARAA: boolean;
  26372. CLEARCOAT: boolean;
  26373. CLEARCOAT_DEFAULTIOR: boolean;
  26374. CLEARCOAT_TEXTURE: boolean;
  26375. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  26376. CLEARCOAT_TEXTUREDIRECTUV: number;
  26377. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  26378. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26379. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26380. CLEARCOAT_BUMP: boolean;
  26381. CLEARCOAT_BUMPDIRECTUV: number;
  26382. CLEARCOAT_REMAP_F0: boolean;
  26383. CLEARCOAT_TINT: boolean;
  26384. CLEARCOAT_TINT_TEXTURE: boolean;
  26385. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  26386. ANISOTROPIC: boolean;
  26387. ANISOTROPIC_TEXTURE: boolean;
  26388. ANISOTROPIC_TEXTUREDIRECTUV: number;
  26389. BRDF_V_HEIGHT_CORRELATED: boolean;
  26390. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26391. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26392. SHEEN: boolean;
  26393. SHEEN_TEXTURE: boolean;
  26394. SHEEN_TEXTURE_ROUGHNESS: boolean;
  26395. SHEEN_TEXTUREDIRECTUV: number;
  26396. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  26397. SHEEN_LINKWITHALBEDO: boolean;
  26398. SHEEN_ROUGHNESS: boolean;
  26399. SHEEN_ALBEDOSCALING: boolean;
  26400. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26401. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26402. SUBSURFACE: boolean;
  26403. SS_REFRACTION: boolean;
  26404. SS_TRANSLUCENCY: boolean;
  26405. SS_SCATTERING: boolean;
  26406. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26407. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26408. SS_REFRACTIONMAP_3D: boolean;
  26409. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26410. SS_LODINREFRACTIONALPHA: boolean;
  26411. SS_GAMMAREFRACTION: boolean;
  26412. SS_RGBDREFRACTION: boolean;
  26413. SS_LINEARSPECULARREFRACTION: boolean;
  26414. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26415. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26416. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26417. UNLIT: boolean;
  26418. DEBUGMODE: number;
  26419. /**
  26420. * Initializes the PBR Material defines.
  26421. */
  26422. constructor();
  26423. /**
  26424. * Resets the PBR Material defines.
  26425. */
  26426. reset(): void;
  26427. }
  26428. /**
  26429. * The Physically based material base class of BJS.
  26430. *
  26431. * This offers the main features of a standard PBR material.
  26432. * For more information, please refer to the documentation :
  26433. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26434. */
  26435. export abstract class PBRBaseMaterial extends PushMaterial {
  26436. /**
  26437. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26438. */
  26439. static readonly PBRMATERIAL_OPAQUE: number;
  26440. /**
  26441. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26442. */
  26443. static readonly PBRMATERIAL_ALPHATEST: number;
  26444. /**
  26445. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26446. */
  26447. static readonly PBRMATERIAL_ALPHABLEND: number;
  26448. /**
  26449. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26450. * They are also discarded below the alpha cutoff threshold to improve performances.
  26451. */
  26452. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26453. /**
  26454. * Defines the default value of how much AO map is occluding the analytical lights
  26455. * (point spot...).
  26456. */
  26457. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26458. /**
  26459. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  26460. */
  26461. static readonly LIGHTFALLOFF_PHYSICAL: number;
  26462. /**
  26463. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  26464. * to enhance interoperability with other engines.
  26465. */
  26466. static readonly LIGHTFALLOFF_GLTF: number;
  26467. /**
  26468. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  26469. * to enhance interoperability with other materials.
  26470. */
  26471. static readonly LIGHTFALLOFF_STANDARD: number;
  26472. /**
  26473. * Intensity of the direct lights e.g. the four lights available in your scene.
  26474. * This impacts both the direct diffuse and specular highlights.
  26475. */
  26476. protected _directIntensity: number;
  26477. /**
  26478. * Intensity of the emissive part of the material.
  26479. * This helps controlling the emissive effect without modifying the emissive color.
  26480. */
  26481. protected _emissiveIntensity: number;
  26482. /**
  26483. * Intensity of the environment e.g. how much the environment will light the object
  26484. * either through harmonics for rough material or through the refelction for shiny ones.
  26485. */
  26486. protected _environmentIntensity: number;
  26487. /**
  26488. * This is a special control allowing the reduction of the specular highlights coming from the
  26489. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26490. */
  26491. protected _specularIntensity: number;
  26492. /**
  26493. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  26494. */
  26495. private _lightingInfos;
  26496. /**
  26497. * Debug Control allowing disabling the bump map on this material.
  26498. */
  26499. protected _disableBumpMap: boolean;
  26500. /**
  26501. * AKA Diffuse Texture in standard nomenclature.
  26502. */
  26503. protected _albedoTexture: Nullable<BaseTexture>;
  26504. /**
  26505. * AKA Occlusion Texture in other nomenclature.
  26506. */
  26507. protected _ambientTexture: Nullable<BaseTexture>;
  26508. /**
  26509. * AKA Occlusion Texture Intensity in other nomenclature.
  26510. */
  26511. protected _ambientTextureStrength: number;
  26512. /**
  26513. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26514. * 1 means it completely occludes it
  26515. * 0 mean it has no impact
  26516. */
  26517. protected _ambientTextureImpactOnAnalyticalLights: number;
  26518. /**
  26519. * Stores the alpha values in a texture.
  26520. */
  26521. protected _opacityTexture: Nullable<BaseTexture>;
  26522. /**
  26523. * Stores the reflection values in a texture.
  26524. */
  26525. protected _reflectionTexture: Nullable<BaseTexture>;
  26526. /**
  26527. * Stores the emissive values in a texture.
  26528. */
  26529. protected _emissiveTexture: Nullable<BaseTexture>;
  26530. /**
  26531. * AKA Specular texture in other nomenclature.
  26532. */
  26533. protected _reflectivityTexture: Nullable<BaseTexture>;
  26534. /**
  26535. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26536. */
  26537. protected _metallicTexture: Nullable<BaseTexture>;
  26538. /**
  26539. * Specifies the metallic scalar of the metallic/roughness workflow.
  26540. * Can also be used to scale the metalness values of the metallic texture.
  26541. */
  26542. protected _metallic: Nullable<number>;
  26543. /**
  26544. * Specifies the roughness scalar of the metallic/roughness workflow.
  26545. * Can also be used to scale the roughness values of the metallic texture.
  26546. */
  26547. protected _roughness: Nullable<number>;
  26548. /**
  26549. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26550. * By default the indexOfrefraction is used to compute F0;
  26551. *
  26552. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26553. *
  26554. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26555. * F90 = metallicReflectanceColor;
  26556. */
  26557. protected _metallicF0Factor: number;
  26558. /**
  26559. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26560. * By default the F90 is always 1;
  26561. *
  26562. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26563. *
  26564. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26565. * F90 = metallicReflectanceColor;
  26566. */
  26567. protected _metallicReflectanceColor: Color3;
  26568. /**
  26569. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26570. * This is multiply against the scalar values defined in the material.
  26571. */
  26572. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  26573. /**
  26574. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26575. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26576. */
  26577. protected _microSurfaceTexture: Nullable<BaseTexture>;
  26578. /**
  26579. * Stores surface normal data used to displace a mesh in a texture.
  26580. */
  26581. protected _bumpTexture: Nullable<BaseTexture>;
  26582. /**
  26583. * Stores the pre-calculated light information of a mesh in a texture.
  26584. */
  26585. protected _lightmapTexture: Nullable<BaseTexture>;
  26586. /**
  26587. * The color of a material in ambient lighting.
  26588. */
  26589. protected _ambientColor: Color3;
  26590. /**
  26591. * AKA Diffuse Color in other nomenclature.
  26592. */
  26593. protected _albedoColor: Color3;
  26594. /**
  26595. * AKA Specular Color in other nomenclature.
  26596. */
  26597. protected _reflectivityColor: Color3;
  26598. /**
  26599. * The color applied when light is reflected from a material.
  26600. */
  26601. protected _reflectionColor: Color3;
  26602. /**
  26603. * The color applied when light is emitted from a material.
  26604. */
  26605. protected _emissiveColor: Color3;
  26606. /**
  26607. * AKA Glossiness in other nomenclature.
  26608. */
  26609. protected _microSurface: number;
  26610. /**
  26611. * Specifies that the material will use the light map as a show map.
  26612. */
  26613. protected _useLightmapAsShadowmap: boolean;
  26614. /**
  26615. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26616. * makes the reflect vector face the model (under horizon).
  26617. */
  26618. protected _useHorizonOcclusion: boolean;
  26619. /**
  26620. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26621. * too much the area relying on ambient texture to define their ambient occlusion.
  26622. */
  26623. protected _useRadianceOcclusion: boolean;
  26624. /**
  26625. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26626. */
  26627. protected _useAlphaFromAlbedoTexture: boolean;
  26628. /**
  26629. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  26630. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26631. */
  26632. protected _useSpecularOverAlpha: boolean;
  26633. /**
  26634. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26635. */
  26636. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26637. /**
  26638. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26639. */
  26640. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  26641. /**
  26642. * Specifies if the metallic texture contains the roughness information in its green channel.
  26643. */
  26644. protected _useRoughnessFromMetallicTextureGreen: boolean;
  26645. /**
  26646. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26647. */
  26648. protected _useMetallnessFromMetallicTextureBlue: boolean;
  26649. /**
  26650. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26651. */
  26652. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  26653. /**
  26654. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26655. */
  26656. protected _useAmbientInGrayScale: boolean;
  26657. /**
  26658. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26659. * The material will try to infer what glossiness each pixel should be.
  26660. */
  26661. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  26662. /**
  26663. * Defines the falloff type used in this material.
  26664. * It by default is Physical.
  26665. */
  26666. protected _lightFalloff: number;
  26667. /**
  26668. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26669. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26670. */
  26671. protected _useRadianceOverAlpha: boolean;
  26672. /**
  26673. * Allows using an object space normal map (instead of tangent space).
  26674. */
  26675. protected _useObjectSpaceNormalMap: boolean;
  26676. /**
  26677. * Allows using the bump map in parallax mode.
  26678. */
  26679. protected _useParallax: boolean;
  26680. /**
  26681. * Allows using the bump map in parallax occlusion mode.
  26682. */
  26683. protected _useParallaxOcclusion: boolean;
  26684. /**
  26685. * Controls the scale bias of the parallax mode.
  26686. */
  26687. protected _parallaxScaleBias: number;
  26688. /**
  26689. * If sets to true, disables all the lights affecting the material.
  26690. */
  26691. protected _disableLighting: boolean;
  26692. /**
  26693. * Number of Simultaneous lights allowed on the material.
  26694. */
  26695. protected _maxSimultaneousLights: number;
  26696. /**
  26697. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  26698. */
  26699. protected _invertNormalMapX: boolean;
  26700. /**
  26701. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  26702. */
  26703. protected _invertNormalMapY: boolean;
  26704. /**
  26705. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26706. */
  26707. protected _twoSidedLighting: boolean;
  26708. /**
  26709. * Defines the alpha limits in alpha test mode.
  26710. */
  26711. protected _alphaCutOff: number;
  26712. /**
  26713. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26714. */
  26715. protected _forceAlphaTest: boolean;
  26716. /**
  26717. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26718. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26719. */
  26720. protected _useAlphaFresnel: boolean;
  26721. /**
  26722. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26723. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26724. */
  26725. protected _useLinearAlphaFresnel: boolean;
  26726. /**
  26727. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  26728. * from cos thetav and roughness:
  26729. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  26730. */
  26731. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  26732. /**
  26733. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26734. */
  26735. protected _forceIrradianceInFragment: boolean;
  26736. private _realTimeFiltering;
  26737. /**
  26738. * Enables realtime filtering on the texture.
  26739. */
  26740. get realTimeFiltering(): boolean;
  26741. set realTimeFiltering(b: boolean);
  26742. private _realTimeFilteringQuality;
  26743. /**
  26744. * Quality switch for realtime filtering
  26745. */
  26746. get realTimeFilteringQuality(): number;
  26747. set realTimeFilteringQuality(n: number);
  26748. /**
  26749. * Can this material render to several textures at once
  26750. */
  26751. get canRenderToMRT(): boolean;
  26752. /**
  26753. * Force normal to face away from face.
  26754. */
  26755. protected _forceNormalForward: boolean;
  26756. /**
  26757. * Enables specular anti aliasing in the PBR shader.
  26758. * It will both interacts on the Geometry for analytical and IBL lighting.
  26759. * It also prefilter the roughness map based on the bump values.
  26760. */
  26761. protected _enableSpecularAntiAliasing: boolean;
  26762. /**
  26763. * Default configuration related to image processing available in the PBR Material.
  26764. */
  26765. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26766. /**
  26767. * Keep track of the image processing observer to allow dispose and replace.
  26768. */
  26769. private _imageProcessingObserver;
  26770. /**
  26771. * Attaches a new image processing configuration to the PBR Material.
  26772. * @param configuration
  26773. */
  26774. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26775. /**
  26776. * Stores the available render targets.
  26777. */
  26778. private _renderTargets;
  26779. /**
  26780. * Sets the global ambient color for the material used in lighting calculations.
  26781. */
  26782. private _globalAmbientColor;
  26783. /**
  26784. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  26785. */
  26786. private _useLogarithmicDepth;
  26787. /**
  26788. * If set to true, no lighting calculations will be applied.
  26789. */
  26790. private _unlit;
  26791. private _debugMode;
  26792. /**
  26793. * @hidden
  26794. * This is reserved for the inspector.
  26795. * Defines the material debug mode.
  26796. * It helps seeing only some components of the material while troubleshooting.
  26797. */
  26798. debugMode: number;
  26799. /**
  26800. * @hidden
  26801. * This is reserved for the inspector.
  26802. * Specify from where on screen the debug mode should start.
  26803. * The value goes from -1 (full screen) to 1 (not visible)
  26804. * It helps with side by side comparison against the final render
  26805. * This defaults to -1
  26806. */
  26807. private debugLimit;
  26808. /**
  26809. * @hidden
  26810. * This is reserved for the inspector.
  26811. * As the default viewing range might not be enough (if the ambient is really small for instance)
  26812. * You can use the factor to better multiply the final value.
  26813. */
  26814. private debugFactor;
  26815. /**
  26816. * Defines the clear coat layer parameters for the material.
  26817. */
  26818. readonly clearCoat: PBRClearCoatConfiguration;
  26819. /**
  26820. * Defines the anisotropic parameters for the material.
  26821. */
  26822. readonly anisotropy: PBRAnisotropicConfiguration;
  26823. /**
  26824. * Defines the BRDF parameters for the material.
  26825. */
  26826. readonly brdf: PBRBRDFConfiguration;
  26827. /**
  26828. * Defines the Sheen parameters for the material.
  26829. */
  26830. readonly sheen: PBRSheenConfiguration;
  26831. /**
  26832. * Defines the SubSurface parameters for the material.
  26833. */
  26834. readonly subSurface: PBRSubSurfaceConfiguration;
  26835. /**
  26836. * Defines additionnal PrePass parameters for the material.
  26837. */
  26838. readonly prePassConfiguration: PrePassConfiguration;
  26839. /**
  26840. * Defines the detail map parameters for the material.
  26841. */
  26842. readonly detailMap: DetailMapConfiguration;
  26843. protected _rebuildInParallel: boolean;
  26844. /**
  26845. * Instantiates a new PBRMaterial instance.
  26846. *
  26847. * @param name The material name
  26848. * @param scene The scene the material will be use in.
  26849. */
  26850. constructor(name: string, scene: Scene);
  26851. /**
  26852. * Gets a boolean indicating that current material needs to register RTT
  26853. */
  26854. get hasRenderTargetTextures(): boolean;
  26855. /**
  26856. * Gets the name of the material class.
  26857. */
  26858. getClassName(): string;
  26859. /**
  26860. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26861. */
  26862. get useLogarithmicDepth(): boolean;
  26863. /**
  26864. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26865. */
  26866. set useLogarithmicDepth(value: boolean);
  26867. /**
  26868. * Returns true if alpha blending should be disabled.
  26869. */
  26870. protected get _disableAlphaBlending(): boolean;
  26871. /**
  26872. * Specifies whether or not this material should be rendered in alpha blend mode.
  26873. */
  26874. needAlphaBlending(): boolean;
  26875. /**
  26876. * Specifies whether or not this material should be rendered in alpha test mode.
  26877. */
  26878. needAlphaTesting(): boolean;
  26879. /**
  26880. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  26881. */
  26882. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  26883. /**
  26884. * Specifies whether or not there is a usable alpha channel for transparency.
  26885. */
  26886. protected _hasAlphaChannel(): boolean;
  26887. /**
  26888. * Gets the texture used for the alpha test.
  26889. */
  26890. getAlphaTestTexture(): Nullable<BaseTexture>;
  26891. /**
  26892. * Specifies that the submesh is ready to be used.
  26893. * @param mesh - BJS mesh.
  26894. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  26895. * @param useInstances - Specifies that instances should be used.
  26896. * @returns - boolean indicating that the submesh is ready or not.
  26897. */
  26898. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26899. /**
  26900. * Specifies if the material uses metallic roughness workflow.
  26901. * @returns boolean specifiying if the material uses metallic roughness workflow.
  26902. */
  26903. isMetallicWorkflow(): boolean;
  26904. private _prepareEffect;
  26905. private _prepareDefines;
  26906. /**
  26907. * Force shader compilation
  26908. */
  26909. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  26910. /**
  26911. * Initializes the uniform buffer layout for the shader.
  26912. */
  26913. buildUniformLayout(): void;
  26914. /**
  26915. * Unbinds the material from the mesh
  26916. */
  26917. unbind(): void;
  26918. /**
  26919. * Binds the submesh data.
  26920. * @param world - The world matrix.
  26921. * @param mesh - The BJS mesh.
  26922. * @param subMesh - A submesh of the BJS mesh.
  26923. */
  26924. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26925. /**
  26926. * Returns the animatable textures.
  26927. * @returns - Array of animatable textures.
  26928. */
  26929. getAnimatables(): IAnimatable[];
  26930. /**
  26931. * Returns the texture used for reflections.
  26932. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  26933. */
  26934. private _getReflectionTexture;
  26935. /**
  26936. * Returns an array of the actively used textures.
  26937. * @returns - Array of BaseTextures
  26938. */
  26939. getActiveTextures(): BaseTexture[];
  26940. /**
  26941. * Checks to see if a texture is used in the material.
  26942. * @param texture - Base texture to use.
  26943. * @returns - Boolean specifying if a texture is used in the material.
  26944. */
  26945. hasTexture(texture: BaseTexture): boolean;
  26946. /**
  26947. * Sets the required values to the prepass renderer.
  26948. * @param prePassRenderer defines the prepass renderer to setup
  26949. */
  26950. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26951. /**
  26952. * Disposes the resources of the material.
  26953. * @param forceDisposeEffect - Forces the disposal of effects.
  26954. * @param forceDisposeTextures - Forces the disposal of all textures.
  26955. */
  26956. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26957. }
  26958. }
  26959. declare module BABYLON {
  26960. /**
  26961. * The Physically based material of BJS.
  26962. *
  26963. * This offers the main features of a standard PBR material.
  26964. * For more information, please refer to the documentation :
  26965. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26966. */
  26967. export class PBRMaterial extends PBRBaseMaterial {
  26968. /**
  26969. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26970. */
  26971. static readonly PBRMATERIAL_OPAQUE: number;
  26972. /**
  26973. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26974. */
  26975. static readonly PBRMATERIAL_ALPHATEST: number;
  26976. /**
  26977. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26978. */
  26979. static readonly PBRMATERIAL_ALPHABLEND: number;
  26980. /**
  26981. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26982. * They are also discarded below the alpha cutoff threshold to improve performances.
  26983. */
  26984. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26985. /**
  26986. * Defines the default value of how much AO map is occluding the analytical lights
  26987. * (point spot...).
  26988. */
  26989. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26990. /**
  26991. * Intensity of the direct lights e.g. the four lights available in your scene.
  26992. * This impacts both the direct diffuse and specular highlights.
  26993. */
  26994. directIntensity: number;
  26995. /**
  26996. * Intensity of the emissive part of the material.
  26997. * This helps controlling the emissive effect without modifying the emissive color.
  26998. */
  26999. emissiveIntensity: number;
  27000. /**
  27001. * Intensity of the environment e.g. how much the environment will light the object
  27002. * either through harmonics for rough material or through the refelction for shiny ones.
  27003. */
  27004. environmentIntensity: number;
  27005. /**
  27006. * This is a special control allowing the reduction of the specular highlights coming from the
  27007. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27008. */
  27009. specularIntensity: number;
  27010. /**
  27011. * Debug Control allowing disabling the bump map on this material.
  27012. */
  27013. disableBumpMap: boolean;
  27014. /**
  27015. * AKA Diffuse Texture in standard nomenclature.
  27016. */
  27017. albedoTexture: BaseTexture;
  27018. /**
  27019. * AKA Occlusion Texture in other nomenclature.
  27020. */
  27021. ambientTexture: BaseTexture;
  27022. /**
  27023. * AKA Occlusion Texture Intensity in other nomenclature.
  27024. */
  27025. ambientTextureStrength: number;
  27026. /**
  27027. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27028. * 1 means it completely occludes it
  27029. * 0 mean it has no impact
  27030. */
  27031. ambientTextureImpactOnAnalyticalLights: number;
  27032. /**
  27033. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  27034. */
  27035. opacityTexture: BaseTexture;
  27036. /**
  27037. * Stores the reflection values in a texture.
  27038. */
  27039. reflectionTexture: Nullable<BaseTexture>;
  27040. /**
  27041. * Stores the emissive values in a texture.
  27042. */
  27043. emissiveTexture: BaseTexture;
  27044. /**
  27045. * AKA Specular texture in other nomenclature.
  27046. */
  27047. reflectivityTexture: BaseTexture;
  27048. /**
  27049. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27050. */
  27051. metallicTexture: BaseTexture;
  27052. /**
  27053. * Specifies the metallic scalar of the metallic/roughness workflow.
  27054. * Can also be used to scale the metalness values of the metallic texture.
  27055. */
  27056. metallic: Nullable<number>;
  27057. /**
  27058. * Specifies the roughness scalar of the metallic/roughness workflow.
  27059. * Can also be used to scale the roughness values of the metallic texture.
  27060. */
  27061. roughness: Nullable<number>;
  27062. /**
  27063. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27064. * By default the indexOfrefraction is used to compute F0;
  27065. *
  27066. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27067. *
  27068. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27069. * F90 = metallicReflectanceColor;
  27070. */
  27071. metallicF0Factor: number;
  27072. /**
  27073. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27074. * By default the F90 is always 1;
  27075. *
  27076. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27077. *
  27078. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27079. * F90 = metallicReflectanceColor;
  27080. */
  27081. metallicReflectanceColor: Color3;
  27082. /**
  27083. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27084. * This is multiply against the scalar values defined in the material.
  27085. */
  27086. metallicReflectanceTexture: Nullable<BaseTexture>;
  27087. /**
  27088. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27089. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27090. */
  27091. microSurfaceTexture: BaseTexture;
  27092. /**
  27093. * Stores surface normal data used to displace a mesh in a texture.
  27094. */
  27095. bumpTexture: BaseTexture;
  27096. /**
  27097. * Stores the pre-calculated light information of a mesh in a texture.
  27098. */
  27099. lightmapTexture: BaseTexture;
  27100. /**
  27101. * Stores the refracted light information in a texture.
  27102. */
  27103. get refractionTexture(): Nullable<BaseTexture>;
  27104. set refractionTexture(value: Nullable<BaseTexture>);
  27105. /**
  27106. * The color of a material in ambient lighting.
  27107. */
  27108. ambientColor: Color3;
  27109. /**
  27110. * AKA Diffuse Color in other nomenclature.
  27111. */
  27112. albedoColor: Color3;
  27113. /**
  27114. * AKA Specular Color in other nomenclature.
  27115. */
  27116. reflectivityColor: Color3;
  27117. /**
  27118. * The color reflected from the material.
  27119. */
  27120. reflectionColor: Color3;
  27121. /**
  27122. * The color emitted from the material.
  27123. */
  27124. emissiveColor: Color3;
  27125. /**
  27126. * AKA Glossiness in other nomenclature.
  27127. */
  27128. microSurface: number;
  27129. /**
  27130. * Index of refraction of the material base layer.
  27131. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  27132. *
  27133. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  27134. *
  27135. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  27136. */
  27137. get indexOfRefraction(): number;
  27138. set indexOfRefraction(value: number);
  27139. /**
  27140. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  27141. */
  27142. get invertRefractionY(): boolean;
  27143. set invertRefractionY(value: boolean);
  27144. /**
  27145. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27146. * Materials half opaque for instance using refraction could benefit from this control.
  27147. */
  27148. get linkRefractionWithTransparency(): boolean;
  27149. set linkRefractionWithTransparency(value: boolean);
  27150. /**
  27151. * If true, the light map contains occlusion information instead of lighting info.
  27152. */
  27153. useLightmapAsShadowmap: boolean;
  27154. /**
  27155. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27156. */
  27157. useAlphaFromAlbedoTexture: boolean;
  27158. /**
  27159. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27160. */
  27161. forceAlphaTest: boolean;
  27162. /**
  27163. * Defines the alpha limits in alpha test mode.
  27164. */
  27165. alphaCutOff: number;
  27166. /**
  27167. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27168. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27169. */
  27170. useSpecularOverAlpha: boolean;
  27171. /**
  27172. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27173. */
  27174. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27175. /**
  27176. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27177. */
  27178. useRoughnessFromMetallicTextureAlpha: boolean;
  27179. /**
  27180. * Specifies if the metallic texture contains the roughness information in its green channel.
  27181. */
  27182. useRoughnessFromMetallicTextureGreen: boolean;
  27183. /**
  27184. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27185. */
  27186. useMetallnessFromMetallicTextureBlue: boolean;
  27187. /**
  27188. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27189. */
  27190. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27191. /**
  27192. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27193. */
  27194. useAmbientInGrayScale: boolean;
  27195. /**
  27196. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27197. * The material will try to infer what glossiness each pixel should be.
  27198. */
  27199. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27200. /**
  27201. * BJS is using an harcoded light falloff based on a manually sets up range.
  27202. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27203. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27204. */
  27205. get usePhysicalLightFalloff(): boolean;
  27206. /**
  27207. * BJS is using an harcoded light falloff based on a manually sets up range.
  27208. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27209. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27210. */
  27211. set usePhysicalLightFalloff(value: boolean);
  27212. /**
  27213. * In order to support the falloff compatibility with gltf, a special mode has been added
  27214. * to reproduce the gltf light falloff.
  27215. */
  27216. get useGLTFLightFalloff(): boolean;
  27217. /**
  27218. * In order to support the falloff compatibility with gltf, a special mode has been added
  27219. * to reproduce the gltf light falloff.
  27220. */
  27221. set useGLTFLightFalloff(value: boolean);
  27222. /**
  27223. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27224. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27225. */
  27226. useRadianceOverAlpha: boolean;
  27227. /**
  27228. * Allows using an object space normal map (instead of tangent space).
  27229. */
  27230. useObjectSpaceNormalMap: boolean;
  27231. /**
  27232. * Allows using the bump map in parallax mode.
  27233. */
  27234. useParallax: boolean;
  27235. /**
  27236. * Allows using the bump map in parallax occlusion mode.
  27237. */
  27238. useParallaxOcclusion: boolean;
  27239. /**
  27240. * Controls the scale bias of the parallax mode.
  27241. */
  27242. parallaxScaleBias: number;
  27243. /**
  27244. * If sets to true, disables all the lights affecting the material.
  27245. */
  27246. disableLighting: boolean;
  27247. /**
  27248. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27249. */
  27250. forceIrradianceInFragment: boolean;
  27251. /**
  27252. * Number of Simultaneous lights allowed on the material.
  27253. */
  27254. maxSimultaneousLights: number;
  27255. /**
  27256. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27257. */
  27258. invertNormalMapX: boolean;
  27259. /**
  27260. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27261. */
  27262. invertNormalMapY: boolean;
  27263. /**
  27264. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27265. */
  27266. twoSidedLighting: boolean;
  27267. /**
  27268. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27269. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27270. */
  27271. useAlphaFresnel: boolean;
  27272. /**
  27273. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27274. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27275. */
  27276. useLinearAlphaFresnel: boolean;
  27277. /**
  27278. * Let user defines the brdf lookup texture used for IBL.
  27279. * A default 8bit version is embedded but you could point at :
  27280. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  27281. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  27282. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  27283. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  27284. */
  27285. environmentBRDFTexture: Nullable<BaseTexture>;
  27286. /**
  27287. * Force normal to face away from face.
  27288. */
  27289. forceNormalForward: boolean;
  27290. /**
  27291. * Enables specular anti aliasing in the PBR shader.
  27292. * It will both interacts on the Geometry for analytical and IBL lighting.
  27293. * It also prefilter the roughness map based on the bump values.
  27294. */
  27295. enableSpecularAntiAliasing: boolean;
  27296. /**
  27297. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27298. * makes the reflect vector face the model (under horizon).
  27299. */
  27300. useHorizonOcclusion: boolean;
  27301. /**
  27302. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27303. * too much the area relying on ambient texture to define their ambient occlusion.
  27304. */
  27305. useRadianceOcclusion: boolean;
  27306. /**
  27307. * If set to true, no lighting calculations will be applied.
  27308. */
  27309. unlit: boolean;
  27310. /**
  27311. * Gets the image processing configuration used either in this material.
  27312. */
  27313. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27314. /**
  27315. * Sets the Default image processing configuration used either in the this material.
  27316. *
  27317. * If sets to null, the scene one is in use.
  27318. */
  27319. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27320. /**
  27321. * Gets wether the color curves effect is enabled.
  27322. */
  27323. get cameraColorCurvesEnabled(): boolean;
  27324. /**
  27325. * Sets wether the color curves effect is enabled.
  27326. */
  27327. set cameraColorCurvesEnabled(value: boolean);
  27328. /**
  27329. * Gets wether the color grading effect is enabled.
  27330. */
  27331. get cameraColorGradingEnabled(): boolean;
  27332. /**
  27333. * Gets wether the color grading effect is enabled.
  27334. */
  27335. set cameraColorGradingEnabled(value: boolean);
  27336. /**
  27337. * Gets wether tonemapping is enabled or not.
  27338. */
  27339. get cameraToneMappingEnabled(): boolean;
  27340. /**
  27341. * Sets wether tonemapping is enabled or not
  27342. */
  27343. set cameraToneMappingEnabled(value: boolean);
  27344. /**
  27345. * The camera exposure used on this material.
  27346. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27347. * This corresponds to a photographic exposure.
  27348. */
  27349. get cameraExposure(): number;
  27350. /**
  27351. * The camera exposure used on this material.
  27352. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27353. * This corresponds to a photographic exposure.
  27354. */
  27355. set cameraExposure(value: number);
  27356. /**
  27357. * Gets The camera contrast used on this material.
  27358. */
  27359. get cameraContrast(): number;
  27360. /**
  27361. * Sets The camera contrast used on this material.
  27362. */
  27363. set cameraContrast(value: number);
  27364. /**
  27365. * Gets the Color Grading 2D Lookup Texture.
  27366. */
  27367. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27368. /**
  27369. * Sets the Color Grading 2D Lookup Texture.
  27370. */
  27371. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27372. /**
  27373. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27374. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27375. * 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;
  27376. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27377. */
  27378. get cameraColorCurves(): Nullable<ColorCurves>;
  27379. /**
  27380. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27381. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27382. * 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;
  27383. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27384. */
  27385. set cameraColorCurves(value: Nullable<ColorCurves>);
  27386. /**
  27387. * Instantiates a new PBRMaterial instance.
  27388. *
  27389. * @param name The material name
  27390. * @param scene The scene the material will be use in.
  27391. */
  27392. constructor(name: string, scene: Scene);
  27393. /**
  27394. * Returns the name of this material class.
  27395. */
  27396. getClassName(): string;
  27397. /**
  27398. * Makes a duplicate of the current material.
  27399. * @param name - name to use for the new material.
  27400. */
  27401. clone(name: string): PBRMaterial;
  27402. /**
  27403. * Serializes this PBR Material.
  27404. * @returns - An object with the serialized material.
  27405. */
  27406. serialize(): any;
  27407. /**
  27408. * Parses a PBR Material from a serialized object.
  27409. * @param source - Serialized object.
  27410. * @param scene - BJS scene instance.
  27411. * @param rootUrl - url for the scene object
  27412. * @returns - PBRMaterial
  27413. */
  27414. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  27415. }
  27416. }
  27417. declare module BABYLON {
  27418. /** @hidden */
  27419. export var mrtFragmentDeclaration: {
  27420. name: string;
  27421. shader: string;
  27422. };
  27423. }
  27424. declare module BABYLON {
  27425. /** @hidden */
  27426. export var geometryPixelShader: {
  27427. name: string;
  27428. shader: string;
  27429. };
  27430. }
  27431. declare module BABYLON {
  27432. /** @hidden */
  27433. export var geometryVertexShader: {
  27434. name: string;
  27435. shader: string;
  27436. };
  27437. }
  27438. declare module BABYLON {
  27439. /** @hidden */
  27440. interface ISavedTransformationMatrix {
  27441. world: Matrix;
  27442. viewProjection: Matrix;
  27443. }
  27444. /**
  27445. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  27446. */
  27447. export class GeometryBufferRenderer {
  27448. /**
  27449. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  27450. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  27451. */
  27452. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  27453. /**
  27454. * Constant used to retrieve the position texture index in the G-Buffer textures array
  27455. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  27456. */
  27457. static readonly POSITION_TEXTURE_TYPE: number;
  27458. /**
  27459. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  27460. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  27461. */
  27462. static readonly VELOCITY_TEXTURE_TYPE: number;
  27463. /**
  27464. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  27465. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  27466. */
  27467. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  27468. /**
  27469. * Dictionary used to store the previous transformation matrices of each rendered mesh
  27470. * in order to compute objects velocities when enableVelocity is set to "true"
  27471. * @hidden
  27472. */
  27473. _previousTransformationMatrices: {
  27474. [index: number]: ISavedTransformationMatrix;
  27475. };
  27476. /**
  27477. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  27478. * in order to compute objects velocities when enableVelocity is set to "true"
  27479. * @hidden
  27480. */
  27481. _previousBonesTransformationMatrices: {
  27482. [index: number]: Float32Array;
  27483. };
  27484. /**
  27485. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  27486. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  27487. */
  27488. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  27489. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  27490. renderTransparentMeshes: boolean;
  27491. private _scene;
  27492. private _resizeObserver;
  27493. private _multiRenderTarget;
  27494. private _ratio;
  27495. private _enablePosition;
  27496. private _enableVelocity;
  27497. private _enableReflectivity;
  27498. private _positionIndex;
  27499. private _velocityIndex;
  27500. private _reflectivityIndex;
  27501. private _depthNormalIndex;
  27502. private _linkedWithPrePass;
  27503. private _prePassRenderer;
  27504. private _attachments;
  27505. protected _effect: Effect;
  27506. protected _cachedDefines: string;
  27507. /**
  27508. * @hidden
  27509. * Sets up internal structures to share outputs with PrePassRenderer
  27510. * This method should only be called by the PrePassRenderer itself
  27511. */
  27512. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  27513. /**
  27514. * @hidden
  27515. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  27516. * This method should only be called by the PrePassRenderer itself
  27517. */
  27518. _unlinkPrePassRenderer(): void;
  27519. /**
  27520. * @hidden
  27521. * Resets the geometry buffer layout
  27522. */
  27523. _resetLayout(): void;
  27524. /**
  27525. * @hidden
  27526. * Replaces a texture in the geometry buffer renderer
  27527. * Useful when linking textures of the prepass renderer
  27528. */
  27529. _forceTextureType(geometryBufferType: number, index: number): void;
  27530. /**
  27531. * @hidden
  27532. * Sets texture attachments
  27533. * Useful when linking textures of the prepass renderer
  27534. */
  27535. _setAttachments(attachments: number[]): void;
  27536. /**
  27537. * @hidden
  27538. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  27539. * Useful when linking textures of the prepass renderer
  27540. */
  27541. _linkInternalTexture(internalTexture: InternalTexture): void;
  27542. /**
  27543. * Gets the render list (meshes to be rendered) used in the G buffer.
  27544. */
  27545. get renderList(): Nullable<AbstractMesh[]>;
  27546. /**
  27547. * Set the render list (meshes to be rendered) used in the G buffer.
  27548. */
  27549. set renderList(meshes: Nullable<AbstractMesh[]>);
  27550. /**
  27551. * Gets wether or not G buffer are supported by the running hardware.
  27552. * This requires draw buffer supports
  27553. */
  27554. get isSupported(): boolean;
  27555. /**
  27556. * Returns the index of the given texture type in the G-Buffer textures array
  27557. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  27558. * @returns the index of the given texture type in the G-Buffer textures array
  27559. */
  27560. getTextureIndex(textureType: number): number;
  27561. /**
  27562. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  27563. */
  27564. get enablePosition(): boolean;
  27565. /**
  27566. * Sets whether or not objects positions are enabled for the G buffer.
  27567. */
  27568. set enablePosition(enable: boolean);
  27569. /**
  27570. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  27571. */
  27572. get enableVelocity(): boolean;
  27573. /**
  27574. * Sets wether or not objects velocities are enabled for the G buffer.
  27575. */
  27576. set enableVelocity(enable: boolean);
  27577. /**
  27578. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  27579. */
  27580. get enableReflectivity(): boolean;
  27581. /**
  27582. * Sets wether or not objects roughness are enabled for the G buffer.
  27583. */
  27584. set enableReflectivity(enable: boolean);
  27585. /**
  27586. * Gets the scene associated with the buffer.
  27587. */
  27588. get scene(): Scene;
  27589. /**
  27590. * Gets the ratio used by the buffer during its creation.
  27591. * How big is the buffer related to the main canvas.
  27592. */
  27593. get ratio(): number;
  27594. /** @hidden */
  27595. static _SceneComponentInitialization: (scene: Scene) => void;
  27596. /**
  27597. * Creates a new G Buffer for the scene
  27598. * @param scene The scene the buffer belongs to
  27599. * @param ratio How big is the buffer related to the main canvas.
  27600. */
  27601. constructor(scene: Scene, ratio?: number);
  27602. /**
  27603. * Checks wether everything is ready to render a submesh to the G buffer.
  27604. * @param subMesh the submesh to check readiness for
  27605. * @param useInstances is the mesh drawn using instance or not
  27606. * @returns true if ready otherwise false
  27607. */
  27608. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  27609. /**
  27610. * Gets the current underlying G Buffer.
  27611. * @returns the buffer
  27612. */
  27613. getGBuffer(): MultiRenderTarget;
  27614. /**
  27615. * Gets the number of samples used to render the buffer (anti aliasing).
  27616. */
  27617. get samples(): number;
  27618. /**
  27619. * Sets the number of samples used to render the buffer (anti aliasing).
  27620. */
  27621. set samples(value: number);
  27622. /**
  27623. * Disposes the renderer and frees up associated resources.
  27624. */
  27625. dispose(): void;
  27626. private _assignRenderTargetIndices;
  27627. protected _createRenderTargets(): void;
  27628. private _copyBonesTransformationMatrices;
  27629. }
  27630. }
  27631. declare module BABYLON {
  27632. /**
  27633. * Renders a pre pass of the scene
  27634. * This means every mesh in the scene will be rendered to a render target texture
  27635. * And then this texture will be composited to the rendering canvas with post processes
  27636. * It is necessary for effects like subsurface scattering or deferred shading
  27637. */
  27638. export class PrePassRenderer {
  27639. /** @hidden */
  27640. static _SceneComponentInitialization: (scene: Scene) => void;
  27641. private _textureFormats;
  27642. /**
  27643. * To save performance, we can excluded skinned meshes from the prepass
  27644. */
  27645. excludedSkinnedMesh: AbstractMesh[];
  27646. /**
  27647. * Force material to be excluded from the prepass
  27648. * Can be useful when `useGeometryBufferFallback` is set to `true`
  27649. * and you don't want a material to show in the effect.
  27650. */
  27651. excludedMaterials: Material[];
  27652. private _textureIndices;
  27653. private _scene;
  27654. private _engine;
  27655. private _isDirty;
  27656. /**
  27657. * Number of textures in the multi render target texture where the scene is directly rendered
  27658. */
  27659. mrtCount: number;
  27660. /**
  27661. * The render target where the scene is directly rendered
  27662. */
  27663. prePassRT: MultiRenderTarget;
  27664. private _multiRenderAttachments;
  27665. private _defaultAttachments;
  27666. private _clearAttachments;
  27667. private _postProcesses;
  27668. private readonly _clearColor;
  27669. /**
  27670. * Image processing post process for composition
  27671. */
  27672. imageProcessingPostProcess: ImageProcessingPostProcess;
  27673. /**
  27674. * Configuration for prepass effects
  27675. */
  27676. private _effectConfigurations;
  27677. private _mrtFormats;
  27678. private _mrtLayout;
  27679. private _enabled;
  27680. /**
  27681. * Indicates if the prepass is enabled
  27682. */
  27683. get enabled(): boolean;
  27684. /**
  27685. * How many samples are used for MSAA of the scene render target
  27686. */
  27687. get samples(): number;
  27688. set samples(n: number);
  27689. private _geometryBuffer;
  27690. private _useGeometryBufferFallback;
  27691. /**
  27692. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  27693. */
  27694. get useGeometryBufferFallback(): boolean;
  27695. set useGeometryBufferFallback(value: boolean);
  27696. /**
  27697. * Instanciates a prepass renderer
  27698. * @param scene The scene
  27699. */
  27700. constructor(scene: Scene);
  27701. private _initializeAttachments;
  27702. private _createCompositionEffect;
  27703. /**
  27704. * Indicates if rendering a prepass is supported
  27705. */
  27706. get isSupported(): boolean;
  27707. /**
  27708. * Sets the proper output textures to draw in the engine.
  27709. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  27710. * @param subMesh Submesh on which the effect is applied
  27711. */
  27712. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  27713. /**
  27714. * @hidden
  27715. */
  27716. _beforeCameraDraw(): void;
  27717. /**
  27718. * @hidden
  27719. */
  27720. _afterCameraDraw(): void;
  27721. private _checkRTSize;
  27722. private _bindFrameBuffer;
  27723. /**
  27724. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  27725. */
  27726. clear(): void;
  27727. private _setState;
  27728. private _updateGeometryBufferLayout;
  27729. /**
  27730. * Adds an effect configuration to the prepass.
  27731. * If an effect has already been added, it won't add it twice and will return the configuration
  27732. * already present.
  27733. * @param cfg the effect configuration
  27734. * @return the effect configuration now used by the prepass
  27735. */
  27736. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  27737. /**
  27738. * Returns the index of a texture in the multi render target texture array.
  27739. * @param type Texture type
  27740. * @return The index
  27741. */
  27742. getIndex(type: number): number;
  27743. private _enable;
  27744. private _disable;
  27745. private _resetLayout;
  27746. private _resetPostProcessChain;
  27747. private _bindPostProcessChain;
  27748. /**
  27749. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  27750. */
  27751. markAsDirty(): void;
  27752. /**
  27753. * Enables a texture on the MultiRenderTarget for prepass
  27754. */
  27755. private _enableTextures;
  27756. private _update;
  27757. private _markAllMaterialsAsPrePassDirty;
  27758. /**
  27759. * Disposes the prepass renderer.
  27760. */
  27761. dispose(): void;
  27762. }
  27763. }
  27764. declare module BABYLON {
  27765. /**
  27766. * Size options for a post process
  27767. */
  27768. export type PostProcessOptions = {
  27769. width: number;
  27770. height: number;
  27771. };
  27772. /**
  27773. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27774. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27775. */
  27776. export class PostProcess {
  27777. /**
  27778. * Gets or sets the unique id of the post process
  27779. */
  27780. uniqueId: number;
  27781. /** Name of the PostProcess. */
  27782. name: string;
  27783. /**
  27784. * Width of the texture to apply the post process on
  27785. */
  27786. width: number;
  27787. /**
  27788. * Height of the texture to apply the post process on
  27789. */
  27790. height: number;
  27791. /**
  27792. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  27793. */
  27794. nodeMaterialSource: Nullable<NodeMaterial>;
  27795. /**
  27796. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27797. * @hidden
  27798. */
  27799. _outputTexture: Nullable<InternalTexture>;
  27800. /**
  27801. * Sampling mode used by the shader
  27802. * See https://doc.babylonjs.com/classes/3.1/texture
  27803. */
  27804. renderTargetSamplingMode: number;
  27805. /**
  27806. * Clear color to use when screen clearing
  27807. */
  27808. clearColor: Color4;
  27809. /**
  27810. * If the buffer needs to be cleared before applying the post process. (default: true)
  27811. * Should be set to false if shader will overwrite all previous pixels.
  27812. */
  27813. autoClear: boolean;
  27814. /**
  27815. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27816. */
  27817. alphaMode: number;
  27818. /**
  27819. * Sets the setAlphaBlendConstants of the babylon engine
  27820. */
  27821. alphaConstants: Color4;
  27822. /**
  27823. * Animations to be used for the post processing
  27824. */
  27825. animations: Animation[];
  27826. /**
  27827. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27828. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27829. */
  27830. enablePixelPerfectMode: boolean;
  27831. /**
  27832. * Force the postprocess to be applied without taking in account viewport
  27833. */
  27834. forceFullscreenViewport: boolean;
  27835. /**
  27836. * List of inspectable custom properties (used by the Inspector)
  27837. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27838. */
  27839. inspectableCustomProperties: IInspectable[];
  27840. /**
  27841. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27842. *
  27843. * | Value | Type | Description |
  27844. * | ----- | ----------------------------------- | ----------- |
  27845. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27846. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27847. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27848. *
  27849. */
  27850. scaleMode: number;
  27851. /**
  27852. * Force textures to be a power of two (default: false)
  27853. */
  27854. alwaysForcePOT: boolean;
  27855. private _samples;
  27856. /**
  27857. * Number of sample textures (default: 1)
  27858. */
  27859. get samples(): number;
  27860. set samples(n: number);
  27861. /**
  27862. * Modify the scale of the post process to be the same as the viewport (default: false)
  27863. */
  27864. adaptScaleToCurrentViewport: boolean;
  27865. private _camera;
  27866. protected _scene: Scene;
  27867. private _engine;
  27868. private _options;
  27869. private _reusable;
  27870. private _textureType;
  27871. private _textureFormat;
  27872. /**
  27873. * Smart array of input and output textures for the post process.
  27874. * @hidden
  27875. */
  27876. _textures: SmartArray<InternalTexture>;
  27877. /**
  27878. * The index in _textures that corresponds to the output texture.
  27879. * @hidden
  27880. */
  27881. _currentRenderTextureInd: number;
  27882. private _effect;
  27883. private _samplers;
  27884. private _fragmentUrl;
  27885. private _vertexUrl;
  27886. private _parameters;
  27887. private _scaleRatio;
  27888. protected _indexParameters: any;
  27889. private _shareOutputWithPostProcess;
  27890. private _texelSize;
  27891. private _forcedOutputTexture;
  27892. /**
  27893. * Prepass configuration in case this post process needs a texture from prepass
  27894. * @hidden
  27895. */
  27896. _prePassEffectConfiguration: PrePassEffectConfiguration;
  27897. /**
  27898. * Returns the fragment url or shader name used in the post process.
  27899. * @returns the fragment url or name in the shader store.
  27900. */
  27901. getEffectName(): string;
  27902. /**
  27903. * An event triggered when the postprocess is activated.
  27904. */
  27905. onActivateObservable: Observable<Camera>;
  27906. private _onActivateObserver;
  27907. /**
  27908. * A function that is added to the onActivateObservable
  27909. */
  27910. set onActivate(callback: Nullable<(camera: Camera) => void>);
  27911. /**
  27912. * An event triggered when the postprocess changes its size.
  27913. */
  27914. onSizeChangedObservable: Observable<PostProcess>;
  27915. private _onSizeChangedObserver;
  27916. /**
  27917. * A function that is added to the onSizeChangedObservable
  27918. */
  27919. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  27920. /**
  27921. * An event triggered when the postprocess applies its effect.
  27922. */
  27923. onApplyObservable: Observable<Effect>;
  27924. private _onApplyObserver;
  27925. /**
  27926. * A function that is added to the onApplyObservable
  27927. */
  27928. set onApply(callback: (effect: Effect) => void);
  27929. /**
  27930. * An event triggered before rendering the postprocess
  27931. */
  27932. onBeforeRenderObservable: Observable<Effect>;
  27933. private _onBeforeRenderObserver;
  27934. /**
  27935. * A function that is added to the onBeforeRenderObservable
  27936. */
  27937. set onBeforeRender(callback: (effect: Effect) => void);
  27938. /**
  27939. * An event triggered after rendering the postprocess
  27940. */
  27941. onAfterRenderObservable: Observable<Effect>;
  27942. private _onAfterRenderObserver;
  27943. /**
  27944. * A function that is added to the onAfterRenderObservable
  27945. */
  27946. set onAfterRender(callback: (efect: Effect) => void);
  27947. /**
  27948. * 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
  27949. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27950. */
  27951. get inputTexture(): InternalTexture;
  27952. set inputTexture(value: InternalTexture);
  27953. /**
  27954. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  27955. * the only way to unset it is to use this function to restore its internal state
  27956. */
  27957. restoreDefaultInputTexture(): void;
  27958. /**
  27959. * Gets the camera which post process is applied to.
  27960. * @returns The camera the post process is applied to.
  27961. */
  27962. getCamera(): Camera;
  27963. /**
  27964. * Gets the texel size of the postprocess.
  27965. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27966. */
  27967. get texelSize(): Vector2;
  27968. /**
  27969. * Creates a new instance PostProcess
  27970. * @param name The name of the PostProcess.
  27971. * @param fragmentUrl The url of the fragment shader to be used.
  27972. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27973. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27974. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27975. * @param camera The camera to apply the render pass to.
  27976. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27977. * @param engine The engine which the post process will be applied. (default: current engine)
  27978. * @param reusable If the post process can be reused on the same frame. (default: false)
  27979. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27980. * @param textureType Type of textures used when performing the post process. (default: 0)
  27981. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27982. * @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
  27983. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  27984. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  27985. */
  27986. 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);
  27987. /**
  27988. * Gets a string identifying the name of the class
  27989. * @returns "PostProcess" string
  27990. */
  27991. getClassName(): string;
  27992. /**
  27993. * Gets the engine which this post process belongs to.
  27994. * @returns The engine the post process was enabled with.
  27995. */
  27996. getEngine(): Engine;
  27997. /**
  27998. * The effect that is created when initializing the post process.
  27999. * @returns The created effect corresponding the the postprocess.
  28000. */
  28001. getEffect(): Effect;
  28002. /**
  28003. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28004. * @param postProcess The post process to share the output with.
  28005. * @returns This post process.
  28006. */
  28007. shareOutputWith(postProcess: PostProcess): PostProcess;
  28008. /**
  28009. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28010. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28011. */
  28012. useOwnOutput(): void;
  28013. /**
  28014. * Updates the effect with the current post process compile time values and recompiles the shader.
  28015. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28016. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28017. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28018. * @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
  28019. * @param onCompiled Called when the shader has been compiled.
  28020. * @param onError Called if there is an error when compiling a shader.
  28021. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  28022. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  28023. */
  28024. 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;
  28025. /**
  28026. * The post process is reusable if it can be used multiple times within one frame.
  28027. * @returns If the post process is reusable
  28028. */
  28029. isReusable(): boolean;
  28030. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28031. markTextureDirty(): void;
  28032. /**
  28033. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28034. * 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.
  28035. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28036. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28037. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28038. * @returns The target texture that was bound to be written to.
  28039. */
  28040. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28041. /**
  28042. * If the post process is supported.
  28043. */
  28044. get isSupported(): boolean;
  28045. /**
  28046. * The aspect ratio of the output texture.
  28047. */
  28048. get aspectRatio(): number;
  28049. /**
  28050. * Get a value indicating if the post-process is ready to be used
  28051. * @returns true if the post-process is ready (shader is compiled)
  28052. */
  28053. isReady(): boolean;
  28054. /**
  28055. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28056. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  28057. */
  28058. apply(): Nullable<Effect>;
  28059. private _disposeTextures;
  28060. /**
  28061. * Sets the required values to the prepass renderer.
  28062. * @param prePassRenderer defines the prepass renderer to setup.
  28063. * @returns true if the pre pass is needed.
  28064. */
  28065. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28066. /**
  28067. * Disposes the post process.
  28068. * @param camera The camera to dispose the post process on.
  28069. */
  28070. dispose(camera?: Camera): void;
  28071. /**
  28072. * Serializes the particle system to a JSON object
  28073. * @returns the JSON object
  28074. */
  28075. serialize(): any;
  28076. /**
  28077. * Creates a material from parsed material data
  28078. * @param parsedPostProcess defines parsed post process data
  28079. * @param scene defines the hosting scene
  28080. * @param rootUrl defines the root URL to use to load textures
  28081. * @returns a new post process
  28082. */
  28083. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  28084. }
  28085. }
  28086. declare module BABYLON {
  28087. /** @hidden */
  28088. export var kernelBlurVaryingDeclaration: {
  28089. name: string;
  28090. shader: string;
  28091. };
  28092. }
  28093. declare module BABYLON {
  28094. /** @hidden */
  28095. export var kernelBlurFragment: {
  28096. name: string;
  28097. shader: string;
  28098. };
  28099. }
  28100. declare module BABYLON {
  28101. /** @hidden */
  28102. export var kernelBlurFragment2: {
  28103. name: string;
  28104. shader: string;
  28105. };
  28106. }
  28107. declare module BABYLON {
  28108. /** @hidden */
  28109. export var kernelBlurPixelShader: {
  28110. name: string;
  28111. shader: string;
  28112. };
  28113. }
  28114. declare module BABYLON {
  28115. /** @hidden */
  28116. export var kernelBlurVertex: {
  28117. name: string;
  28118. shader: string;
  28119. };
  28120. }
  28121. declare module BABYLON {
  28122. /** @hidden */
  28123. export var kernelBlurVertexShader: {
  28124. name: string;
  28125. shader: string;
  28126. };
  28127. }
  28128. declare module BABYLON {
  28129. /**
  28130. * The Blur Post Process which blurs an image based on a kernel and direction.
  28131. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  28132. */
  28133. export class BlurPostProcess extends PostProcess {
  28134. private blockCompilation;
  28135. protected _kernel: number;
  28136. protected _idealKernel: number;
  28137. protected _packedFloat: boolean;
  28138. private _staticDefines;
  28139. /** The direction in which to blur the image. */
  28140. direction: Vector2;
  28141. /**
  28142. * Sets the length in pixels of the blur sample region
  28143. */
  28144. set kernel(v: number);
  28145. /**
  28146. * Gets the length in pixels of the blur sample region
  28147. */
  28148. get kernel(): number;
  28149. /**
  28150. * Sets wether or not the blur needs to unpack/repack floats
  28151. */
  28152. set packedFloat(v: boolean);
  28153. /**
  28154. * Gets wether or not the blur is unpacking/repacking floats
  28155. */
  28156. get packedFloat(): boolean;
  28157. /**
  28158. * Gets a string identifying the name of the class
  28159. * @returns "BlurPostProcess" string
  28160. */
  28161. getClassName(): string;
  28162. /**
  28163. * Creates a new instance BlurPostProcess
  28164. * @param name The name of the effect.
  28165. * @param direction The direction in which to blur the image.
  28166. * @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.
  28167. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28168. * @param camera The camera to apply the render pass to.
  28169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28170. * @param engine The engine which the post process will be applied. (default: current engine)
  28171. * @param reusable If the post process can be reused on the same frame. (default: false)
  28172. * @param textureType Type of textures used when performing the post process. (default: 0)
  28173. * @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)
  28174. */
  28175. 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);
  28176. /**
  28177. * Updates the effect with the current post process compile time values and recompiles the shader.
  28178. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28179. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28180. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28181. * @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
  28182. * @param onCompiled Called when the shader has been compiled.
  28183. * @param onError Called if there is an error when compiling a shader.
  28184. */
  28185. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28186. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28187. /**
  28188. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  28189. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  28190. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  28191. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  28192. * The gaps between physical kernels are compensated for in the weighting of the samples
  28193. * @param idealKernel Ideal blur kernel.
  28194. * @return Nearest best kernel.
  28195. */
  28196. protected _nearestBestKernel(idealKernel: number): number;
  28197. /**
  28198. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  28199. * @param x The point on the Gaussian distribution to sample.
  28200. * @return the value of the Gaussian function at x.
  28201. */
  28202. protected _gaussianWeight(x: number): number;
  28203. /**
  28204. * Generates a string that can be used as a floating point number in GLSL.
  28205. * @param x Value to print.
  28206. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  28207. * @return GLSL float string.
  28208. */
  28209. protected _glslFloat(x: number, decimalFigures?: number): string;
  28210. /** @hidden */
  28211. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  28212. }
  28213. }
  28214. declare module BABYLON {
  28215. /**
  28216. * Mirror texture can be used to simulate the view from a mirror in a scene.
  28217. * It will dynamically be rendered every frame to adapt to the camera point of view.
  28218. * You can then easily use it as a reflectionTexture on a flat surface.
  28219. * In case the surface is not a plane, please consider relying on reflection probes.
  28220. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28221. */
  28222. export class MirrorTexture extends RenderTargetTexture {
  28223. private scene;
  28224. /**
  28225. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  28226. * 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.
  28227. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28228. */
  28229. mirrorPlane: Plane;
  28230. /**
  28231. * Define the blur ratio used to blur the reflection if needed.
  28232. */
  28233. set blurRatio(value: number);
  28234. get blurRatio(): number;
  28235. /**
  28236. * Define the adaptive blur kernel used to blur the reflection if needed.
  28237. * This will autocompute the closest best match for the `blurKernel`
  28238. */
  28239. set adaptiveBlurKernel(value: number);
  28240. /**
  28241. * Define the blur kernel used to blur the reflection if needed.
  28242. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28243. */
  28244. set blurKernel(value: number);
  28245. /**
  28246. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  28247. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28248. */
  28249. set blurKernelX(value: number);
  28250. get blurKernelX(): number;
  28251. /**
  28252. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  28253. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28254. */
  28255. set blurKernelY(value: number);
  28256. get blurKernelY(): number;
  28257. private _autoComputeBlurKernel;
  28258. protected _onRatioRescale(): void;
  28259. private _updateGammaSpace;
  28260. private _imageProcessingConfigChangeObserver;
  28261. private _transformMatrix;
  28262. private _mirrorMatrix;
  28263. private _savedViewMatrix;
  28264. private _blurX;
  28265. private _blurY;
  28266. private _adaptiveBlurKernel;
  28267. private _blurKernelX;
  28268. private _blurKernelY;
  28269. private _blurRatio;
  28270. /**
  28271. * Instantiates a Mirror Texture.
  28272. * Mirror texture can be used to simulate the view from a mirror in a scene.
  28273. * It will dynamically be rendered every frame to adapt to the camera point of view.
  28274. * You can then easily use it as a reflectionTexture on a flat surface.
  28275. * In case the surface is not a plane, please consider relying on reflection probes.
  28276. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28277. * @param name
  28278. * @param size
  28279. * @param scene
  28280. * @param generateMipMaps
  28281. * @param type
  28282. * @param samplingMode
  28283. * @param generateDepthBuffer
  28284. */
  28285. constructor(name: string, size: number | {
  28286. width: number;
  28287. height: number;
  28288. } | {
  28289. ratio: number;
  28290. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  28291. private _preparePostProcesses;
  28292. /**
  28293. * Clone the mirror texture.
  28294. * @returns the cloned texture
  28295. */
  28296. clone(): MirrorTexture;
  28297. /**
  28298. * Serialize the texture to a JSON representation you could use in Parse later on
  28299. * @returns the serialized JSON representation
  28300. */
  28301. serialize(): any;
  28302. /**
  28303. * Dispose the texture and release its associated resources.
  28304. */
  28305. dispose(): void;
  28306. }
  28307. }
  28308. declare module BABYLON {
  28309. /**
  28310. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28311. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28312. */
  28313. export class Texture extends BaseTexture {
  28314. /**
  28315. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  28316. */
  28317. static SerializeBuffers: boolean;
  28318. /**
  28319. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  28320. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  28321. */
  28322. static ForceSerializeBuffers: boolean;
  28323. /** @hidden */
  28324. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  28325. /** @hidden */
  28326. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  28327. /** @hidden */
  28328. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  28329. /** nearest is mag = nearest and min = nearest and mip = linear */
  28330. static readonly NEAREST_SAMPLINGMODE: number;
  28331. /** nearest is mag = nearest and min = nearest and mip = linear */
  28332. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  28333. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28334. static readonly BILINEAR_SAMPLINGMODE: number;
  28335. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28336. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  28337. /** Trilinear is mag = linear and min = linear and mip = linear */
  28338. static readonly TRILINEAR_SAMPLINGMODE: number;
  28339. /** Trilinear is mag = linear and min = linear and mip = linear */
  28340. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  28341. /** mag = nearest and min = nearest and mip = nearest */
  28342. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  28343. /** mag = nearest and min = linear and mip = nearest */
  28344. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  28345. /** mag = nearest and min = linear and mip = linear */
  28346. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  28347. /** mag = nearest and min = linear and mip = none */
  28348. static readonly NEAREST_LINEAR: number;
  28349. /** mag = nearest and min = nearest and mip = none */
  28350. static readonly NEAREST_NEAREST: number;
  28351. /** mag = linear and min = nearest and mip = nearest */
  28352. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  28353. /** mag = linear and min = nearest and mip = linear */
  28354. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  28355. /** mag = linear and min = linear and mip = none */
  28356. static readonly LINEAR_LINEAR: number;
  28357. /** mag = linear and min = nearest and mip = none */
  28358. static readonly LINEAR_NEAREST: number;
  28359. /** Explicit coordinates mode */
  28360. static readonly EXPLICIT_MODE: number;
  28361. /** Spherical coordinates mode */
  28362. static readonly SPHERICAL_MODE: number;
  28363. /** Planar coordinates mode */
  28364. static readonly PLANAR_MODE: number;
  28365. /** Cubic coordinates mode */
  28366. static readonly CUBIC_MODE: number;
  28367. /** Projection coordinates mode */
  28368. static readonly PROJECTION_MODE: number;
  28369. /** Inverse Cubic coordinates mode */
  28370. static readonly SKYBOX_MODE: number;
  28371. /** Inverse Cubic coordinates mode */
  28372. static readonly INVCUBIC_MODE: number;
  28373. /** Equirectangular coordinates mode */
  28374. static readonly EQUIRECTANGULAR_MODE: number;
  28375. /** Equirectangular Fixed coordinates mode */
  28376. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  28377. /** Equirectangular Fixed Mirrored coordinates mode */
  28378. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28379. /** Texture is not repeating outside of 0..1 UVs */
  28380. static readonly CLAMP_ADDRESSMODE: number;
  28381. /** Texture is repeating outside of 0..1 UVs */
  28382. static readonly WRAP_ADDRESSMODE: number;
  28383. /** Texture is repeating and mirrored */
  28384. static readonly MIRROR_ADDRESSMODE: number;
  28385. /**
  28386. * 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
  28387. */
  28388. static UseSerializedUrlIfAny: boolean;
  28389. /**
  28390. * Define the url of the texture.
  28391. */
  28392. url: Nullable<string>;
  28393. /**
  28394. * Define an offset on the texture to offset the u coordinates of the UVs
  28395. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28396. */
  28397. uOffset: number;
  28398. /**
  28399. * Define an offset on the texture to offset the v coordinates of the UVs
  28400. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28401. */
  28402. vOffset: number;
  28403. /**
  28404. * Define an offset on the texture to scale the u coordinates of the UVs
  28405. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28406. */
  28407. uScale: number;
  28408. /**
  28409. * Define an offset on the texture to scale the v coordinates of the UVs
  28410. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28411. */
  28412. vScale: number;
  28413. /**
  28414. * Define an offset on the texture to rotate around the u coordinates of the UVs
  28415. * @see https://doc.babylonjs.com/how_to/more_materials
  28416. */
  28417. uAng: number;
  28418. /**
  28419. * Define an offset on the texture to rotate around the v coordinates of the UVs
  28420. * @see https://doc.babylonjs.com/how_to/more_materials
  28421. */
  28422. vAng: number;
  28423. /**
  28424. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  28425. * @see https://doc.babylonjs.com/how_to/more_materials
  28426. */
  28427. wAng: number;
  28428. /**
  28429. * Defines the center of rotation (U)
  28430. */
  28431. uRotationCenter: number;
  28432. /**
  28433. * Defines the center of rotation (V)
  28434. */
  28435. vRotationCenter: number;
  28436. /**
  28437. * Defines the center of rotation (W)
  28438. */
  28439. wRotationCenter: number;
  28440. /**
  28441. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  28442. */
  28443. homogeneousRotationInUVTransform: boolean;
  28444. /**
  28445. * Are mip maps generated for this texture or not.
  28446. */
  28447. get noMipmap(): boolean;
  28448. /**
  28449. * List of inspectable custom properties (used by the Inspector)
  28450. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28451. */
  28452. inspectableCustomProperties: Nullable<IInspectable[]>;
  28453. private _noMipmap;
  28454. /** @hidden */
  28455. _invertY: boolean;
  28456. private _rowGenerationMatrix;
  28457. private _cachedTextureMatrix;
  28458. private _projectionModeMatrix;
  28459. private _t0;
  28460. private _t1;
  28461. private _t2;
  28462. private _cachedUOffset;
  28463. private _cachedVOffset;
  28464. private _cachedUScale;
  28465. private _cachedVScale;
  28466. private _cachedUAng;
  28467. private _cachedVAng;
  28468. private _cachedWAng;
  28469. private _cachedProjectionMatrixId;
  28470. private _cachedURotationCenter;
  28471. private _cachedVRotationCenter;
  28472. private _cachedWRotationCenter;
  28473. private _cachedHomogeneousRotationInUVTransform;
  28474. private _cachedCoordinatesMode;
  28475. /** @hidden */
  28476. protected _initialSamplingMode: number;
  28477. /** @hidden */
  28478. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  28479. private _deleteBuffer;
  28480. protected _format: Nullable<number>;
  28481. private _delayedOnLoad;
  28482. private _delayedOnError;
  28483. private _mimeType?;
  28484. private _loaderOptions?;
  28485. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  28486. get mimeType(): string | undefined;
  28487. /**
  28488. * Observable triggered once the texture has been loaded.
  28489. */
  28490. onLoadObservable: Observable<Texture>;
  28491. protected _isBlocking: boolean;
  28492. /**
  28493. * Is the texture preventing material to render while loading.
  28494. * If false, a default texture will be used instead of the loading one during the preparation step.
  28495. */
  28496. set isBlocking(value: boolean);
  28497. get isBlocking(): boolean;
  28498. /**
  28499. * Get the current sampling mode associated with the texture.
  28500. */
  28501. get samplingMode(): number;
  28502. /**
  28503. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  28504. */
  28505. get invertY(): boolean;
  28506. /**
  28507. * Instantiates a new texture.
  28508. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28509. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28510. * @param url defines the url of the picture to load as a texture
  28511. * @param sceneOrEngine defines the scene or engine the texture will belong to
  28512. * @param noMipmap defines if the texture will require mip maps or not
  28513. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  28514. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28515. * @param onLoad defines a callback triggered when the texture has been loaded
  28516. * @param onError defines a callback triggered when an error occurred during the loading session
  28517. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  28518. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  28519. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28520. * @param mimeType defines an optional mime type information
  28521. * @param loaderOptions options to be passed to the loader
  28522. */
  28523. 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);
  28524. /**
  28525. * Update the url (and optional buffer) of this texture if url was null during construction.
  28526. * @param url the url of the texture
  28527. * @param buffer the buffer of the texture (defaults to null)
  28528. * @param onLoad callback called when the texture is loaded (defaults to null)
  28529. */
  28530. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  28531. /**
  28532. * Finish the loading sequence of a texture flagged as delayed load.
  28533. * @hidden
  28534. */
  28535. delayLoad(): void;
  28536. private _prepareRowForTextureGeneration;
  28537. /**
  28538. * Checks if the texture has the same transform matrix than another texture
  28539. * @param texture texture to check against
  28540. * @returns true if the transforms are the same, else false
  28541. */
  28542. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  28543. /**
  28544. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  28545. * @returns the transform matrix of the texture.
  28546. */
  28547. getTextureMatrix(uBase?: number): Matrix;
  28548. /**
  28549. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  28550. * @returns The reflection texture transform
  28551. */
  28552. getReflectionTextureMatrix(): Matrix;
  28553. /**
  28554. * Clones the texture.
  28555. * @returns the cloned texture
  28556. */
  28557. clone(): Texture;
  28558. /**
  28559. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28560. * @returns The JSON representation of the texture
  28561. */
  28562. serialize(): any;
  28563. /**
  28564. * Get the current class name of the texture useful for serialization or dynamic coding.
  28565. * @returns "Texture"
  28566. */
  28567. getClassName(): string;
  28568. /**
  28569. * Dispose the texture and release its associated resources.
  28570. */
  28571. dispose(): void;
  28572. /**
  28573. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  28574. * @param parsedTexture Define the JSON representation of the texture
  28575. * @param scene Define the scene the parsed texture should be instantiated in
  28576. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  28577. * @returns The parsed texture if successful
  28578. */
  28579. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  28580. /**
  28581. * Creates a texture from its base 64 representation.
  28582. * @param data Define the base64 payload without the data: prefix
  28583. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28584. * @param scene Define the scene the texture should belong to
  28585. * @param noMipmap Forces the texture to not create mip map information if true
  28586. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28587. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28588. * @param onLoad define a callback triggered when the texture has been loaded
  28589. * @param onError define a callback triggered when an error occurred during the loading session
  28590. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28591. * @returns the created texture
  28592. */
  28593. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  28594. /**
  28595. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  28596. * @param data Define the base64 payload without the data: prefix
  28597. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28598. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  28599. * @param scene Define the scene the texture should belong to
  28600. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  28601. * @param noMipmap Forces the texture to not create mip map information if true
  28602. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28603. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28604. * @param onLoad define a callback triggered when the texture has been loaded
  28605. * @param onError define a callback triggered when an error occurred during the loading session
  28606. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28607. * @returns the created texture
  28608. */
  28609. 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;
  28610. }
  28611. }
  28612. declare module BABYLON {
  28613. /**
  28614. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28615. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28616. */
  28617. export class PostProcessManager {
  28618. private _scene;
  28619. private _indexBuffer;
  28620. private _vertexBuffers;
  28621. /**
  28622. * Creates a new instance PostProcess
  28623. * @param scene The scene that the post process is associated with.
  28624. */
  28625. constructor(scene: Scene);
  28626. private _prepareBuffers;
  28627. private _buildIndexBuffer;
  28628. /**
  28629. * Rebuilds the vertex buffers of the manager.
  28630. * @hidden
  28631. */
  28632. _rebuild(): void;
  28633. /**
  28634. * Prepares a frame to be run through a post process.
  28635. * @param sourceTexture The input texture to the post procesess. (default: null)
  28636. * @param postProcesses An array of post processes to be run. (default: null)
  28637. * @returns True if the post processes were able to be run.
  28638. * @hidden
  28639. */
  28640. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28641. /**
  28642. * Manually render a set of post processes to a texture.
  28643. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  28644. * @param postProcesses An array of post processes to be run.
  28645. * @param targetTexture The target texture to render to.
  28646. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28647. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28648. * @param lodLevel defines which lod of the texture to render to
  28649. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  28650. */
  28651. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  28652. /**
  28653. * Finalize the result of the output of the postprocesses.
  28654. * @param doNotPresent If true the result will not be displayed to the screen.
  28655. * @param targetTexture The target texture to render to.
  28656. * @param faceIndex The index of the face to bind the target texture to.
  28657. * @param postProcesses The array of post processes to render.
  28658. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28659. * @hidden
  28660. */
  28661. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28662. /**
  28663. * Disposes of the post process manager.
  28664. */
  28665. dispose(): void;
  28666. }
  28667. }
  28668. declare module BABYLON {
  28669. /**
  28670. * This Helps creating a texture that will be created from a camera in your scene.
  28671. * It is basically a dynamic texture that could be used to create special effects for instance.
  28672. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  28673. */
  28674. export class RenderTargetTexture extends Texture {
  28675. /**
  28676. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  28677. */
  28678. static readonly REFRESHRATE_RENDER_ONCE: number;
  28679. /**
  28680. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  28681. */
  28682. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  28683. /**
  28684. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  28685. * the central point of your effect and can save a lot of performances.
  28686. */
  28687. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  28688. /**
  28689. * Use this predicate to dynamically define the list of mesh you want to render.
  28690. * If set, the renderList property will be overwritten.
  28691. */
  28692. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  28693. private _renderList;
  28694. /**
  28695. * Use this list to define the list of mesh you want to render.
  28696. */
  28697. get renderList(): Nullable<Array<AbstractMesh>>;
  28698. set renderList(value: Nullable<Array<AbstractMesh>>);
  28699. /**
  28700. * Use this function to overload the renderList array at rendering time.
  28701. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  28702. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  28703. * the cube (if the RTT is a cube, else layerOrFace=0).
  28704. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  28705. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  28706. * hold dummy elements!
  28707. */
  28708. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  28709. private _hookArray;
  28710. /**
  28711. * Define if particles should be rendered in your texture.
  28712. */
  28713. renderParticles: boolean;
  28714. /**
  28715. * Define if sprites should be rendered in your texture.
  28716. */
  28717. renderSprites: boolean;
  28718. /**
  28719. * Define the camera used to render the texture.
  28720. */
  28721. activeCamera: Nullable<Camera>;
  28722. /**
  28723. * Override the mesh isReady function with your own one.
  28724. */
  28725. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  28726. /**
  28727. * Override the render function of the texture with your own one.
  28728. */
  28729. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  28730. /**
  28731. * Define if camera post processes should be use while rendering the texture.
  28732. */
  28733. useCameraPostProcesses: boolean;
  28734. /**
  28735. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  28736. */
  28737. ignoreCameraViewport: boolean;
  28738. private _postProcessManager;
  28739. private _postProcesses;
  28740. private _resizeObserver;
  28741. /**
  28742. * An event triggered when the texture is unbind.
  28743. */
  28744. onBeforeBindObservable: Observable<RenderTargetTexture>;
  28745. /**
  28746. * An event triggered when the texture is unbind.
  28747. */
  28748. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  28749. private _onAfterUnbindObserver;
  28750. /**
  28751. * Set a after unbind callback in the texture.
  28752. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  28753. */
  28754. set onAfterUnbind(callback: () => void);
  28755. /**
  28756. * An event triggered before rendering the texture
  28757. */
  28758. onBeforeRenderObservable: Observable<number>;
  28759. private _onBeforeRenderObserver;
  28760. /**
  28761. * Set a before render callback in the texture.
  28762. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  28763. */
  28764. set onBeforeRender(callback: (faceIndex: number) => void);
  28765. /**
  28766. * An event triggered after rendering the texture
  28767. */
  28768. onAfterRenderObservable: Observable<number>;
  28769. private _onAfterRenderObserver;
  28770. /**
  28771. * Set a after render callback in the texture.
  28772. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  28773. */
  28774. set onAfterRender(callback: (faceIndex: number) => void);
  28775. /**
  28776. * An event triggered after the texture clear
  28777. */
  28778. onClearObservable: Observable<Engine>;
  28779. private _onClearObserver;
  28780. /**
  28781. * Set a clear callback in the texture.
  28782. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  28783. */
  28784. set onClear(callback: (Engine: Engine) => void);
  28785. /**
  28786. * An event triggered when the texture is resized.
  28787. */
  28788. onResizeObservable: Observable<RenderTargetTexture>;
  28789. /**
  28790. * Define the clear color of the Render Target if it should be different from the scene.
  28791. */
  28792. clearColor: Color4;
  28793. protected _size: number | {
  28794. width: number;
  28795. height: number;
  28796. layers?: number;
  28797. };
  28798. protected _initialSizeParameter: number | {
  28799. width: number;
  28800. height: number;
  28801. } | {
  28802. ratio: number;
  28803. };
  28804. protected _sizeRatio: Nullable<number>;
  28805. /** @hidden */
  28806. _generateMipMaps: boolean;
  28807. protected _renderingManager: RenderingManager;
  28808. /** @hidden */
  28809. _waitingRenderList?: string[];
  28810. protected _doNotChangeAspectRatio: boolean;
  28811. protected _currentRefreshId: number;
  28812. protected _refreshRate: number;
  28813. protected _textureMatrix: Matrix;
  28814. protected _samples: number;
  28815. protected _renderTargetOptions: RenderTargetCreationOptions;
  28816. /**
  28817. * Gets render target creation options that were used.
  28818. */
  28819. get renderTargetOptions(): RenderTargetCreationOptions;
  28820. protected _onRatioRescale(): void;
  28821. /**
  28822. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  28823. * It must define where the camera used to render the texture is set
  28824. */
  28825. boundingBoxPosition: Vector3;
  28826. private _boundingBoxSize;
  28827. /**
  28828. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  28829. * When defined, the cubemap will switch to local mode
  28830. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  28831. * @example https://www.babylonjs-playground.com/#RNASML
  28832. */
  28833. set boundingBoxSize(value: Vector3);
  28834. get boundingBoxSize(): Vector3;
  28835. /**
  28836. * In case the RTT has been created with a depth texture, get the associated
  28837. * depth texture.
  28838. * Otherwise, return null.
  28839. */
  28840. get depthStencilTexture(): Nullable<InternalTexture>;
  28841. /**
  28842. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  28843. * or used a shadow, depth texture...
  28844. * @param name The friendly name of the texture
  28845. * @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)
  28846. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  28847. * @param generateMipMaps True if mip maps need to be generated after render.
  28848. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  28849. * @param type The type of the buffer in the RTT (int, half float, float...)
  28850. * @param isCube True if a cube texture needs to be created
  28851. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  28852. * @param generateDepthBuffer True to generate a depth buffer
  28853. * @param generateStencilBuffer True to generate a stencil buffer
  28854. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  28855. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  28856. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28857. */
  28858. constructor(name: string, size: number | {
  28859. width: number;
  28860. height: number;
  28861. layers?: number;
  28862. } | {
  28863. ratio: number;
  28864. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  28865. /**
  28866. * Creates a depth stencil texture.
  28867. * This is only available in WebGL 2 or with the depth texture extension available.
  28868. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  28869. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  28870. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  28871. */
  28872. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  28873. private _processSizeParameter;
  28874. /**
  28875. * Define the number of samples to use in case of MSAA.
  28876. * It defaults to one meaning no MSAA has been enabled.
  28877. */
  28878. get samples(): number;
  28879. set samples(value: number);
  28880. /**
  28881. * Resets the refresh counter of the texture and start bak from scratch.
  28882. * Could be useful to regenerate the texture if it is setup to render only once.
  28883. */
  28884. resetRefreshCounter(): void;
  28885. /**
  28886. * Define the refresh rate of the texture or the rendering frequency.
  28887. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  28888. */
  28889. get refreshRate(): number;
  28890. set refreshRate(value: number);
  28891. /**
  28892. * Adds a post process to the render target rendering passes.
  28893. * @param postProcess define the post process to add
  28894. */
  28895. addPostProcess(postProcess: PostProcess): void;
  28896. /**
  28897. * Clear all the post processes attached to the render target
  28898. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  28899. */
  28900. clearPostProcesses(dispose?: boolean): void;
  28901. /**
  28902. * Remove one of the post process from the list of attached post processes to the texture
  28903. * @param postProcess define the post process to remove from the list
  28904. */
  28905. removePostProcess(postProcess: PostProcess): void;
  28906. /** @hidden */
  28907. _shouldRender(): boolean;
  28908. /**
  28909. * Gets the actual render size of the texture.
  28910. * @returns the width of the render size
  28911. */
  28912. getRenderSize(): number;
  28913. /**
  28914. * Gets the actual render width of the texture.
  28915. * @returns the width of the render size
  28916. */
  28917. getRenderWidth(): number;
  28918. /**
  28919. * Gets the actual render height of the texture.
  28920. * @returns the height of the render size
  28921. */
  28922. getRenderHeight(): number;
  28923. /**
  28924. * Gets the actual number of layers of the texture.
  28925. * @returns the number of layers
  28926. */
  28927. getRenderLayers(): number;
  28928. /**
  28929. * Get if the texture can be rescaled or not.
  28930. */
  28931. get canRescale(): boolean;
  28932. /**
  28933. * Resize the texture using a ratio.
  28934. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  28935. */
  28936. scale(ratio: number): void;
  28937. /**
  28938. * Get the texture reflection matrix used to rotate/transform the reflection.
  28939. * @returns the reflection matrix
  28940. */
  28941. getReflectionTextureMatrix(): Matrix;
  28942. /**
  28943. * Resize the texture to a new desired size.
  28944. * Be carrefull as it will recreate all the data in the new texture.
  28945. * @param size Define the new size. It can be:
  28946. * - a number for squared texture,
  28947. * - an object containing { width: number, height: number }
  28948. * - or an object containing a ratio { ratio: number }
  28949. */
  28950. resize(size: number | {
  28951. width: number;
  28952. height: number;
  28953. } | {
  28954. ratio: number;
  28955. }): void;
  28956. private _defaultRenderListPrepared;
  28957. /**
  28958. * Renders all the objects from the render list into the texture.
  28959. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  28960. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  28961. */
  28962. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  28963. private _bestReflectionRenderTargetDimension;
  28964. private _prepareRenderingManager;
  28965. /**
  28966. * @hidden
  28967. * @param faceIndex face index to bind to if this is a cubetexture
  28968. * @param layer defines the index of the texture to bind in the array
  28969. */
  28970. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  28971. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  28972. private renderToTarget;
  28973. /**
  28974. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28975. * This allowed control for front to back rendering or reversly depending of the special needs.
  28976. *
  28977. * @param renderingGroupId The rendering group id corresponding to its index
  28978. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28979. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28980. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28981. */
  28982. 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;
  28983. /**
  28984. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28985. *
  28986. * @param renderingGroupId The rendering group id corresponding to its index
  28987. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28988. */
  28989. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28990. /**
  28991. * Clones the texture.
  28992. * @returns the cloned texture
  28993. */
  28994. clone(): RenderTargetTexture;
  28995. /**
  28996. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28997. * @returns The JSON representation of the texture
  28998. */
  28999. serialize(): any;
  29000. /**
  29001. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  29002. */
  29003. disposeFramebufferObjects(): void;
  29004. /**
  29005. * Dispose the texture and release its associated resources.
  29006. */
  29007. dispose(): void;
  29008. /** @hidden */
  29009. _rebuild(): void;
  29010. /**
  29011. * Clear the info related to rendering groups preventing retention point in material dispose.
  29012. */
  29013. freeRenderingGroups(): void;
  29014. /**
  29015. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  29016. * @returns the view count
  29017. */
  29018. getViewCount(): number;
  29019. }
  29020. }
  29021. declare module BABYLON {
  29022. /**
  29023. * Class used to manipulate GUIDs
  29024. */
  29025. export class GUID {
  29026. /**
  29027. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29028. * Be aware Math.random() could cause collisions, but:
  29029. * "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"
  29030. * @returns a pseudo random id
  29031. */
  29032. static RandomId(): string;
  29033. }
  29034. }
  29035. declare module BABYLON {
  29036. /**
  29037. * Options to be used when creating a shadow depth material
  29038. */
  29039. export interface IIOptionShadowDepthMaterial {
  29040. /** Variables in the vertex shader code that need to have their names remapped.
  29041. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29042. * "var_name" should be either: worldPos or vNormalW
  29043. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29044. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29045. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29046. */
  29047. remappedVariables?: string[];
  29048. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29049. standalone?: boolean;
  29050. }
  29051. /**
  29052. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29053. */
  29054. export class ShadowDepthWrapper {
  29055. private _scene;
  29056. private _options?;
  29057. private _baseMaterial;
  29058. private _onEffectCreatedObserver;
  29059. private _subMeshToEffect;
  29060. private _subMeshToDepthEffect;
  29061. private _meshes;
  29062. /** @hidden */
  29063. _matriceNames: any;
  29064. /** Gets the standalone status of the wrapper */
  29065. get standalone(): boolean;
  29066. /** Gets the base material the wrapper is built upon */
  29067. get baseMaterial(): Material;
  29068. /**
  29069. * Instantiate a new shadow depth wrapper.
  29070. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29071. * generate the shadow depth map. For more information, please refer to the documentation:
  29072. * https://doc.babylonjs.com/babylon101/shadows
  29073. * @param baseMaterial Material to wrap
  29074. * @param scene Define the scene the material belongs to
  29075. * @param options Options used to create the wrapper
  29076. */
  29077. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29078. /**
  29079. * Gets the effect to use to generate the depth map
  29080. * @param subMesh subMesh to get the effect for
  29081. * @param shadowGenerator shadow generator to get the effect for
  29082. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29083. */
  29084. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29085. /**
  29086. * Specifies that the submesh is ready to be used for depth rendering
  29087. * @param subMesh submesh to check
  29088. * @param defines the list of defines to take into account when checking the effect
  29089. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29090. * @param useInstances specifies that instances should be used
  29091. * @returns a boolean indicating that the submesh is ready or not
  29092. */
  29093. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29094. /**
  29095. * Disposes the resources
  29096. */
  29097. dispose(): void;
  29098. private _makeEffect;
  29099. }
  29100. }
  29101. declare module BABYLON {
  29102. /**
  29103. * Options for compiling materials.
  29104. */
  29105. export interface IMaterialCompilationOptions {
  29106. /**
  29107. * Defines whether clip planes are enabled.
  29108. */
  29109. clipPlane: boolean;
  29110. /**
  29111. * Defines whether instances are enabled.
  29112. */
  29113. useInstances: boolean;
  29114. }
  29115. /**
  29116. * Options passed when calling customShaderNameResolve
  29117. */
  29118. export interface ICustomShaderNameResolveOptions {
  29119. /**
  29120. * 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
  29121. */
  29122. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29123. }
  29124. /**
  29125. * Base class for the main features of a material in Babylon.js
  29126. */
  29127. export class Material implements IAnimatable {
  29128. /**
  29129. * Returns the triangle fill mode
  29130. */
  29131. static readonly TriangleFillMode: number;
  29132. /**
  29133. * Returns the wireframe mode
  29134. */
  29135. static readonly WireFrameFillMode: number;
  29136. /**
  29137. * Returns the point fill mode
  29138. */
  29139. static readonly PointFillMode: number;
  29140. /**
  29141. * Returns the point list draw mode
  29142. */
  29143. static readonly PointListDrawMode: number;
  29144. /**
  29145. * Returns the line list draw mode
  29146. */
  29147. static readonly LineListDrawMode: number;
  29148. /**
  29149. * Returns the line loop draw mode
  29150. */
  29151. static readonly LineLoopDrawMode: number;
  29152. /**
  29153. * Returns the line strip draw mode
  29154. */
  29155. static readonly LineStripDrawMode: number;
  29156. /**
  29157. * Returns the triangle strip draw mode
  29158. */
  29159. static readonly TriangleStripDrawMode: number;
  29160. /**
  29161. * Returns the triangle fan draw mode
  29162. */
  29163. static readonly TriangleFanDrawMode: number;
  29164. /**
  29165. * Stores the clock-wise side orientation
  29166. */
  29167. static readonly ClockWiseSideOrientation: number;
  29168. /**
  29169. * Stores the counter clock-wise side orientation
  29170. */
  29171. static readonly CounterClockWiseSideOrientation: number;
  29172. /**
  29173. * The dirty texture flag value
  29174. */
  29175. static readonly TextureDirtyFlag: number;
  29176. /**
  29177. * The dirty light flag value
  29178. */
  29179. static readonly LightDirtyFlag: number;
  29180. /**
  29181. * The dirty fresnel flag value
  29182. */
  29183. static readonly FresnelDirtyFlag: number;
  29184. /**
  29185. * The dirty attribute flag value
  29186. */
  29187. static readonly AttributesDirtyFlag: number;
  29188. /**
  29189. * The dirty misc flag value
  29190. */
  29191. static readonly MiscDirtyFlag: number;
  29192. /**
  29193. * The dirty prepass flag value
  29194. */
  29195. static readonly PrePassDirtyFlag: number;
  29196. /**
  29197. * The all dirty flag value
  29198. */
  29199. static readonly AllDirtyFlag: number;
  29200. /**
  29201. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29202. */
  29203. static readonly MATERIAL_OPAQUE: number;
  29204. /**
  29205. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29206. */
  29207. static readonly MATERIAL_ALPHATEST: number;
  29208. /**
  29209. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29210. */
  29211. static readonly MATERIAL_ALPHABLEND: number;
  29212. /**
  29213. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29214. * They are also discarded below the alpha cutoff threshold to improve performances.
  29215. */
  29216. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29217. /**
  29218. * The Whiteout method is used to blend normals.
  29219. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29220. */
  29221. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29222. /**
  29223. * The Reoriented Normal Mapping method is used to blend normals.
  29224. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29225. */
  29226. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29227. /**
  29228. * Custom callback helping to override the default shader used in the material.
  29229. */
  29230. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29231. /**
  29232. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29233. */
  29234. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29235. /**
  29236. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29237. * This means that the material can keep using a previous shader while a new one is being compiled.
  29238. * This is mostly used when shader parallel compilation is supported (true by default)
  29239. */
  29240. allowShaderHotSwapping: boolean;
  29241. /**
  29242. * The ID of the material
  29243. */
  29244. id: string;
  29245. /**
  29246. * Gets or sets the unique id of the material
  29247. */
  29248. uniqueId: number;
  29249. /**
  29250. * The name of the material
  29251. */
  29252. name: string;
  29253. /**
  29254. * Gets or sets user defined metadata
  29255. */
  29256. metadata: any;
  29257. /**
  29258. * For internal use only. Please do not use.
  29259. */
  29260. reservedDataStore: any;
  29261. /**
  29262. * Specifies if the ready state should be checked on each call
  29263. */
  29264. checkReadyOnEveryCall: boolean;
  29265. /**
  29266. * Specifies if the ready state should be checked once
  29267. */
  29268. checkReadyOnlyOnce: boolean;
  29269. /**
  29270. * The state of the material
  29271. */
  29272. state: string;
  29273. /**
  29274. * If the material can be rendered to several textures with MRT extension
  29275. */
  29276. get canRenderToMRT(): boolean;
  29277. /**
  29278. * The alpha value of the material
  29279. */
  29280. protected _alpha: number;
  29281. /**
  29282. * List of inspectable custom properties (used by the Inspector)
  29283. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29284. */
  29285. inspectableCustomProperties: IInspectable[];
  29286. /**
  29287. * Sets the alpha value of the material
  29288. */
  29289. set alpha(value: number);
  29290. /**
  29291. * Gets the alpha value of the material
  29292. */
  29293. get alpha(): number;
  29294. /**
  29295. * Specifies if back face culling is enabled
  29296. */
  29297. protected _backFaceCulling: boolean;
  29298. /**
  29299. * Sets the back-face culling state
  29300. */
  29301. set backFaceCulling(value: boolean);
  29302. /**
  29303. * Gets the back-face culling state
  29304. */
  29305. get backFaceCulling(): boolean;
  29306. /**
  29307. * Stores the value for side orientation
  29308. */
  29309. sideOrientation: number;
  29310. /**
  29311. * Callback triggered when the material is compiled
  29312. */
  29313. onCompiled: Nullable<(effect: Effect) => void>;
  29314. /**
  29315. * Callback triggered when an error occurs
  29316. */
  29317. onError: Nullable<(effect: Effect, errors: string) => void>;
  29318. /**
  29319. * Callback triggered to get the render target textures
  29320. */
  29321. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29322. /**
  29323. * Gets a boolean indicating that current material needs to register RTT
  29324. */
  29325. get hasRenderTargetTextures(): boolean;
  29326. /**
  29327. * Specifies if the material should be serialized
  29328. */
  29329. doNotSerialize: boolean;
  29330. /**
  29331. * @hidden
  29332. */
  29333. _storeEffectOnSubMeshes: boolean;
  29334. /**
  29335. * Stores the animations for the material
  29336. */
  29337. animations: Nullable<Array<Animation>>;
  29338. /**
  29339. * An event triggered when the material is disposed
  29340. */
  29341. onDisposeObservable: Observable<Material>;
  29342. /**
  29343. * An observer which watches for dispose events
  29344. */
  29345. private _onDisposeObserver;
  29346. private _onUnBindObservable;
  29347. /**
  29348. * Called during a dispose event
  29349. */
  29350. set onDispose(callback: () => void);
  29351. private _onBindObservable;
  29352. /**
  29353. * An event triggered when the material is bound
  29354. */
  29355. get onBindObservable(): Observable<AbstractMesh>;
  29356. /**
  29357. * An observer which watches for bind events
  29358. */
  29359. private _onBindObserver;
  29360. /**
  29361. * Called during a bind event
  29362. */
  29363. set onBind(callback: (Mesh: AbstractMesh) => void);
  29364. /**
  29365. * An event triggered when the material is unbound
  29366. */
  29367. get onUnBindObservable(): Observable<Material>;
  29368. protected _onEffectCreatedObservable: Nullable<Observable<{
  29369. effect: Effect;
  29370. subMesh: Nullable<SubMesh>;
  29371. }>>;
  29372. /**
  29373. * An event triggered when the effect is (re)created
  29374. */
  29375. get onEffectCreatedObservable(): Observable<{
  29376. effect: Effect;
  29377. subMesh: Nullable<SubMesh>;
  29378. }>;
  29379. /**
  29380. * Stores the value of the alpha mode
  29381. */
  29382. private _alphaMode;
  29383. /**
  29384. * Sets the value of the alpha mode.
  29385. *
  29386. * | Value | Type | Description |
  29387. * | --- | --- | --- |
  29388. * | 0 | ALPHA_DISABLE | |
  29389. * | 1 | ALPHA_ADD | |
  29390. * | 2 | ALPHA_COMBINE | |
  29391. * | 3 | ALPHA_SUBTRACT | |
  29392. * | 4 | ALPHA_MULTIPLY | |
  29393. * | 5 | ALPHA_MAXIMIZED | |
  29394. * | 6 | ALPHA_ONEONE | |
  29395. * | 7 | ALPHA_PREMULTIPLIED | |
  29396. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29397. * | 9 | ALPHA_INTERPOLATE | |
  29398. * | 10 | ALPHA_SCREENMODE | |
  29399. *
  29400. */
  29401. set alphaMode(value: number);
  29402. /**
  29403. * Gets the value of the alpha mode
  29404. */
  29405. get alphaMode(): number;
  29406. /**
  29407. * Stores the state of the need depth pre-pass value
  29408. */
  29409. private _needDepthPrePass;
  29410. /**
  29411. * Sets the need depth pre-pass value
  29412. */
  29413. set needDepthPrePass(value: boolean);
  29414. /**
  29415. * Gets the depth pre-pass value
  29416. */
  29417. get needDepthPrePass(): boolean;
  29418. /**
  29419. * Specifies if depth writing should be disabled
  29420. */
  29421. disableDepthWrite: boolean;
  29422. /**
  29423. * Specifies if color writing should be disabled
  29424. */
  29425. disableColorWrite: boolean;
  29426. /**
  29427. * Specifies if depth writing should be forced
  29428. */
  29429. forceDepthWrite: boolean;
  29430. /**
  29431. * Specifies the depth function that should be used. 0 means the default engine function
  29432. */
  29433. depthFunction: number;
  29434. /**
  29435. * Specifies if there should be a separate pass for culling
  29436. */
  29437. separateCullingPass: boolean;
  29438. /**
  29439. * Stores the state specifing if fog should be enabled
  29440. */
  29441. private _fogEnabled;
  29442. /**
  29443. * Sets the state for enabling fog
  29444. */
  29445. set fogEnabled(value: boolean);
  29446. /**
  29447. * Gets the value of the fog enabled state
  29448. */
  29449. get fogEnabled(): boolean;
  29450. /**
  29451. * Stores the size of points
  29452. */
  29453. pointSize: number;
  29454. /**
  29455. * Stores the z offset value
  29456. */
  29457. zOffset: number;
  29458. get wireframe(): boolean;
  29459. /**
  29460. * Sets the state of wireframe mode
  29461. */
  29462. set wireframe(value: boolean);
  29463. /**
  29464. * Gets the value specifying if point clouds are enabled
  29465. */
  29466. get pointsCloud(): boolean;
  29467. /**
  29468. * Sets the state of point cloud mode
  29469. */
  29470. set pointsCloud(value: boolean);
  29471. /**
  29472. * Gets the material fill mode
  29473. */
  29474. get fillMode(): number;
  29475. /**
  29476. * Sets the material fill mode
  29477. */
  29478. set fillMode(value: number);
  29479. /**
  29480. * @hidden
  29481. * Stores the effects for the material
  29482. */
  29483. _effect: Nullable<Effect>;
  29484. /**
  29485. * Specifies if uniform buffers should be used
  29486. */
  29487. private _useUBO;
  29488. /**
  29489. * Stores a reference to the scene
  29490. */
  29491. private _scene;
  29492. /**
  29493. * Stores the fill mode state
  29494. */
  29495. private _fillMode;
  29496. /**
  29497. * Specifies if the depth write state should be cached
  29498. */
  29499. private _cachedDepthWriteState;
  29500. /**
  29501. * Specifies if the color write state should be cached
  29502. */
  29503. private _cachedColorWriteState;
  29504. /**
  29505. * Specifies if the depth function state should be cached
  29506. */
  29507. private _cachedDepthFunctionState;
  29508. /**
  29509. * Stores the uniform buffer
  29510. */
  29511. protected _uniformBuffer: UniformBuffer;
  29512. /** @hidden */
  29513. _indexInSceneMaterialArray: number;
  29514. /** @hidden */
  29515. meshMap: Nullable<{
  29516. [id: string]: AbstractMesh | undefined;
  29517. }>;
  29518. /**
  29519. * Creates a material instance
  29520. * @param name defines the name of the material
  29521. * @param scene defines the scene to reference
  29522. * @param doNotAdd specifies if the material should be added to the scene
  29523. */
  29524. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29525. /**
  29526. * Returns a string representation of the current material
  29527. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29528. * @returns a string with material information
  29529. */
  29530. toString(fullDetails?: boolean): string;
  29531. /**
  29532. * Gets the class name of the material
  29533. * @returns a string with the class name of the material
  29534. */
  29535. getClassName(): string;
  29536. /**
  29537. * Specifies if updates for the material been locked
  29538. */
  29539. get isFrozen(): boolean;
  29540. /**
  29541. * Locks updates for the material
  29542. */
  29543. freeze(): void;
  29544. /**
  29545. * Unlocks updates for the material
  29546. */
  29547. unfreeze(): void;
  29548. /**
  29549. * Specifies if the material is ready to be used
  29550. * @param mesh defines the mesh to check
  29551. * @param useInstances specifies if instances should be used
  29552. * @returns a boolean indicating if the material is ready to be used
  29553. */
  29554. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29555. /**
  29556. * Specifies that the submesh is ready to be used
  29557. * @param mesh defines the mesh to check
  29558. * @param subMesh defines which submesh to check
  29559. * @param useInstances specifies that instances should be used
  29560. * @returns a boolean indicating that the submesh is ready or not
  29561. */
  29562. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29563. /**
  29564. * Returns the material effect
  29565. * @returns the effect associated with the material
  29566. */
  29567. getEffect(): Nullable<Effect>;
  29568. /**
  29569. * Returns the current scene
  29570. * @returns a Scene
  29571. */
  29572. getScene(): Scene;
  29573. /**
  29574. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29575. */
  29576. protected _forceAlphaTest: boolean;
  29577. /**
  29578. * The transparency mode of the material.
  29579. */
  29580. protected _transparencyMode: Nullable<number>;
  29581. /**
  29582. * Gets the current transparency mode.
  29583. */
  29584. get transparencyMode(): Nullable<number>;
  29585. /**
  29586. * Sets the transparency mode of the material.
  29587. *
  29588. * | Value | Type | Description |
  29589. * | ----- | ----------------------------------- | ----------- |
  29590. * | 0 | OPAQUE | |
  29591. * | 1 | ALPHATEST | |
  29592. * | 2 | ALPHABLEND | |
  29593. * | 3 | ALPHATESTANDBLEND | |
  29594. *
  29595. */
  29596. set transparencyMode(value: Nullable<number>);
  29597. /**
  29598. * Returns true if alpha blending should be disabled.
  29599. */
  29600. protected get _disableAlphaBlending(): boolean;
  29601. /**
  29602. * Specifies whether or not this material should be rendered in alpha blend mode.
  29603. * @returns a boolean specifying if alpha blending is needed
  29604. */
  29605. needAlphaBlending(): boolean;
  29606. /**
  29607. * Specifies if the mesh will require alpha blending
  29608. * @param mesh defines the mesh to check
  29609. * @returns a boolean specifying if alpha blending is needed for the mesh
  29610. */
  29611. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29612. /**
  29613. * Specifies whether or not this material should be rendered in alpha test mode.
  29614. * @returns a boolean specifying if an alpha test is needed.
  29615. */
  29616. needAlphaTesting(): boolean;
  29617. /**
  29618. * Specifies if material alpha testing should be turned on for the mesh
  29619. * @param mesh defines the mesh to check
  29620. */
  29621. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29622. /**
  29623. * Gets the texture used for the alpha test
  29624. * @returns the texture to use for alpha testing
  29625. */
  29626. getAlphaTestTexture(): Nullable<BaseTexture>;
  29627. /**
  29628. * Marks the material to indicate that it needs to be re-calculated
  29629. */
  29630. markDirty(): void;
  29631. /** @hidden */
  29632. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29633. /**
  29634. * Binds the material to the mesh
  29635. * @param world defines the world transformation matrix
  29636. * @param mesh defines the mesh to bind the material to
  29637. */
  29638. bind(world: Matrix, mesh?: Mesh): void;
  29639. /**
  29640. * Binds the submesh to the material
  29641. * @param world defines the world transformation matrix
  29642. * @param mesh defines the mesh containing the submesh
  29643. * @param subMesh defines the submesh to bind the material to
  29644. */
  29645. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29646. /**
  29647. * Binds the world matrix to the material
  29648. * @param world defines the world transformation matrix
  29649. */
  29650. bindOnlyWorldMatrix(world: Matrix): void;
  29651. /**
  29652. * Binds the scene's uniform buffer to the effect.
  29653. * @param effect defines the effect to bind to the scene uniform buffer
  29654. * @param sceneUbo defines the uniform buffer storing scene data
  29655. */
  29656. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29657. /**
  29658. * Binds the view matrix to the effect
  29659. * @param effect defines the effect to bind the view matrix to
  29660. */
  29661. bindView(effect: Effect): void;
  29662. /**
  29663. * Binds the view projection matrix to the effect
  29664. * @param effect defines the effect to bind the view projection matrix to
  29665. */
  29666. bindViewProjection(effect: Effect): void;
  29667. /**
  29668. * Processes to execute after binding the material to a mesh
  29669. * @param mesh defines the rendered mesh
  29670. */
  29671. protected _afterBind(mesh?: Mesh): void;
  29672. /**
  29673. * Unbinds the material from the mesh
  29674. */
  29675. unbind(): void;
  29676. /**
  29677. * Gets the active textures from the material
  29678. * @returns an array of textures
  29679. */
  29680. getActiveTextures(): BaseTexture[];
  29681. /**
  29682. * Specifies if the material uses a texture
  29683. * @param texture defines the texture to check against the material
  29684. * @returns a boolean specifying if the material uses the texture
  29685. */
  29686. hasTexture(texture: BaseTexture): boolean;
  29687. /**
  29688. * Makes a duplicate of the material, and gives it a new name
  29689. * @param name defines the new name for the duplicated material
  29690. * @returns the cloned material
  29691. */
  29692. clone(name: string): Nullable<Material>;
  29693. /**
  29694. * Gets the meshes bound to the material
  29695. * @returns an array of meshes bound to the material
  29696. */
  29697. getBindedMeshes(): AbstractMesh[];
  29698. /**
  29699. * Force shader compilation
  29700. * @param mesh defines the mesh associated with this material
  29701. * @param onCompiled defines a function to execute once the material is compiled
  29702. * @param options defines the options to configure the compilation
  29703. * @param onError defines a function to execute if the material fails compiling
  29704. */
  29705. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29706. /**
  29707. * Force shader compilation
  29708. * @param mesh defines the mesh that will use this material
  29709. * @param options defines additional options for compiling the shaders
  29710. * @returns a promise that resolves when the compilation completes
  29711. */
  29712. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29713. private static readonly _AllDirtyCallBack;
  29714. private static readonly _ImageProcessingDirtyCallBack;
  29715. private static readonly _TextureDirtyCallBack;
  29716. private static readonly _FresnelDirtyCallBack;
  29717. private static readonly _MiscDirtyCallBack;
  29718. private static readonly _PrePassDirtyCallBack;
  29719. private static readonly _LightsDirtyCallBack;
  29720. private static readonly _AttributeDirtyCallBack;
  29721. private static _FresnelAndMiscDirtyCallBack;
  29722. private static _TextureAndMiscDirtyCallBack;
  29723. private static readonly _DirtyCallbackArray;
  29724. private static readonly _RunDirtyCallBacks;
  29725. /**
  29726. * Marks a define in the material to indicate that it needs to be re-computed
  29727. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29728. */
  29729. markAsDirty(flag: number): void;
  29730. /**
  29731. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29732. * @param func defines a function which checks material defines against the submeshes
  29733. */
  29734. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29735. /**
  29736. * Indicates that the scene should check if the rendering now needs a prepass
  29737. */
  29738. protected _markScenePrePassDirty(): void;
  29739. /**
  29740. * Indicates that we need to re-calculated for all submeshes
  29741. */
  29742. protected _markAllSubMeshesAsAllDirty(): void;
  29743. /**
  29744. * Indicates that image processing needs to be re-calculated for all submeshes
  29745. */
  29746. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29747. /**
  29748. * Indicates that textures need to be re-calculated for all submeshes
  29749. */
  29750. protected _markAllSubMeshesAsTexturesDirty(): void;
  29751. /**
  29752. * Indicates that fresnel needs to be re-calculated for all submeshes
  29753. */
  29754. protected _markAllSubMeshesAsFresnelDirty(): void;
  29755. /**
  29756. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29757. */
  29758. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29759. /**
  29760. * Indicates that lights need to be re-calculated for all submeshes
  29761. */
  29762. protected _markAllSubMeshesAsLightsDirty(): void;
  29763. /**
  29764. * Indicates that attributes need to be re-calculated for all submeshes
  29765. */
  29766. protected _markAllSubMeshesAsAttributesDirty(): void;
  29767. /**
  29768. * Indicates that misc needs to be re-calculated for all submeshes
  29769. */
  29770. protected _markAllSubMeshesAsMiscDirty(): void;
  29771. /**
  29772. * Indicates that prepass needs to be re-calculated for all submeshes
  29773. */
  29774. protected _markAllSubMeshesAsPrePassDirty(): void;
  29775. /**
  29776. * Indicates that textures and misc need to be re-calculated for all submeshes
  29777. */
  29778. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29779. /**
  29780. * Sets the required values to the prepass renderer.
  29781. * @param prePassRenderer defines the prepass renderer to setup.
  29782. * @returns true if the pre pass is needed.
  29783. */
  29784. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29785. /**
  29786. * Disposes the material
  29787. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29788. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29789. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29790. */
  29791. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29792. /** @hidden */
  29793. private releaseVertexArrayObject;
  29794. /**
  29795. * Serializes this material
  29796. * @returns the serialized material object
  29797. */
  29798. serialize(): any;
  29799. /**
  29800. * Creates a material from parsed material data
  29801. * @param parsedMaterial defines parsed material data
  29802. * @param scene defines the hosting scene
  29803. * @param rootUrl defines the root URL to use to load textures
  29804. * @returns a new material
  29805. */
  29806. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29807. }
  29808. }
  29809. declare module BABYLON {
  29810. /**
  29811. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29812. * separate meshes. This can be use to improve performances.
  29813. * @see https://doc.babylonjs.com/how_to/multi_materials
  29814. */
  29815. export class MultiMaterial extends Material {
  29816. private _subMaterials;
  29817. /**
  29818. * Gets or Sets the list of Materials used within the multi material.
  29819. * They need to be ordered according to the submeshes order in the associated mesh
  29820. */
  29821. get subMaterials(): Nullable<Material>[];
  29822. set subMaterials(value: Nullable<Material>[]);
  29823. /**
  29824. * Function used to align with Node.getChildren()
  29825. * @returns the list of Materials used within the multi material
  29826. */
  29827. getChildren(): Nullable<Material>[];
  29828. /**
  29829. * Instantiates a new Multi Material
  29830. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29831. * separate meshes. This can be use to improve performances.
  29832. * @see https://doc.babylonjs.com/how_to/multi_materials
  29833. * @param name Define the name in the scene
  29834. * @param scene Define the scene the material belongs to
  29835. */
  29836. constructor(name: string, scene: Scene);
  29837. private _hookArray;
  29838. /**
  29839. * Get one of the submaterial by its index in the submaterials array
  29840. * @param index The index to look the sub material at
  29841. * @returns The Material if the index has been defined
  29842. */
  29843. getSubMaterial(index: number): Nullable<Material>;
  29844. /**
  29845. * Get the list of active textures for the whole sub materials list.
  29846. * @returns All the textures that will be used during the rendering
  29847. */
  29848. getActiveTextures(): BaseTexture[];
  29849. /**
  29850. * Gets the current class name of the material e.g. "MultiMaterial"
  29851. * Mainly use in serialization.
  29852. * @returns the class name
  29853. */
  29854. getClassName(): string;
  29855. /**
  29856. * Checks if the material is ready to render the requested sub mesh
  29857. * @param mesh Define the mesh the submesh belongs to
  29858. * @param subMesh Define the sub mesh to look readyness for
  29859. * @param useInstances Define whether or not the material is used with instances
  29860. * @returns true if ready, otherwise false
  29861. */
  29862. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29863. /**
  29864. * Clones the current material and its related sub materials
  29865. * @param name Define the name of the newly cloned material
  29866. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  29867. * @returns the cloned material
  29868. */
  29869. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  29870. /**
  29871. * Serializes the materials into a JSON representation.
  29872. * @returns the JSON representation
  29873. */
  29874. serialize(): any;
  29875. /**
  29876. * Dispose the material and release its associated resources
  29877. * @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)
  29878. * @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)
  29879. * @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)
  29880. */
  29881. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  29882. /**
  29883. * Creates a MultiMaterial from parsed MultiMaterial data.
  29884. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  29885. * @param scene defines the hosting scene
  29886. * @returns a new MultiMaterial
  29887. */
  29888. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  29889. }
  29890. }
  29891. declare module BABYLON {
  29892. /**
  29893. * Defines a subdivision inside a mesh
  29894. */
  29895. export class SubMesh implements ICullable {
  29896. /** the material index to use */
  29897. materialIndex: number;
  29898. /** vertex index start */
  29899. verticesStart: number;
  29900. /** vertices count */
  29901. verticesCount: number;
  29902. /** index start */
  29903. indexStart: number;
  29904. /** indices count */
  29905. indexCount: number;
  29906. /** @hidden */
  29907. _materialDefines: Nullable<MaterialDefines>;
  29908. /** @hidden */
  29909. _materialEffect: Nullable<Effect>;
  29910. /** @hidden */
  29911. _effectOverride: Nullable<Effect>;
  29912. /**
  29913. * Gets material defines used by the effect associated to the sub mesh
  29914. */
  29915. get materialDefines(): Nullable<MaterialDefines>;
  29916. /**
  29917. * Sets material defines used by the effect associated to the sub mesh
  29918. */
  29919. set materialDefines(defines: Nullable<MaterialDefines>);
  29920. /**
  29921. * Gets associated effect
  29922. */
  29923. get effect(): Nullable<Effect>;
  29924. /**
  29925. * Sets associated effect (effect used to render this submesh)
  29926. * @param effect defines the effect to associate with
  29927. * @param defines defines the set of defines used to compile this effect
  29928. */
  29929. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29930. /** @hidden */
  29931. _linesIndexCount: number;
  29932. private _mesh;
  29933. private _renderingMesh;
  29934. private _boundingInfo;
  29935. private _linesIndexBuffer;
  29936. /** @hidden */
  29937. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29938. /** @hidden */
  29939. _trianglePlanes: Plane[];
  29940. /** @hidden */
  29941. _lastColliderTransformMatrix: Nullable<Matrix>;
  29942. /** @hidden */
  29943. _renderId: number;
  29944. /** @hidden */
  29945. _alphaIndex: number;
  29946. /** @hidden */
  29947. _distanceToCamera: number;
  29948. /** @hidden */
  29949. _id: number;
  29950. private _currentMaterial;
  29951. /**
  29952. * Add a new submesh to a mesh
  29953. * @param materialIndex defines the material index to use
  29954. * @param verticesStart defines vertex index start
  29955. * @param verticesCount defines vertices count
  29956. * @param indexStart defines index start
  29957. * @param indexCount defines indices count
  29958. * @param mesh defines the parent mesh
  29959. * @param renderingMesh defines an optional rendering mesh
  29960. * @param createBoundingBox defines if bounding box should be created for this submesh
  29961. * @returns the new submesh
  29962. */
  29963. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29964. /**
  29965. * Creates a new submesh
  29966. * @param materialIndex defines the material index to use
  29967. * @param verticesStart defines vertex index start
  29968. * @param verticesCount defines vertices count
  29969. * @param indexStart defines index start
  29970. * @param indexCount defines indices count
  29971. * @param mesh defines the parent mesh
  29972. * @param renderingMesh defines an optional rendering mesh
  29973. * @param createBoundingBox defines if bounding box should be created for this submesh
  29974. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  29975. */
  29976. constructor(
  29977. /** the material index to use */
  29978. materialIndex: number,
  29979. /** vertex index start */
  29980. verticesStart: number,
  29981. /** vertices count */
  29982. verticesCount: number,
  29983. /** index start */
  29984. indexStart: number,
  29985. /** indices count */
  29986. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  29987. /**
  29988. * Returns true if this submesh covers the entire parent mesh
  29989. * @ignorenaming
  29990. */
  29991. get IsGlobal(): boolean;
  29992. /**
  29993. * Returns the submesh BoudingInfo object
  29994. * @returns current bounding info (or mesh's one if the submesh is global)
  29995. */
  29996. getBoundingInfo(): BoundingInfo;
  29997. /**
  29998. * Sets the submesh BoundingInfo
  29999. * @param boundingInfo defines the new bounding info to use
  30000. * @returns the SubMesh
  30001. */
  30002. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30003. /**
  30004. * Returns the mesh of the current submesh
  30005. * @return the parent mesh
  30006. */
  30007. getMesh(): AbstractMesh;
  30008. /**
  30009. * Returns the rendering mesh of the submesh
  30010. * @returns the rendering mesh (could be different from parent mesh)
  30011. */
  30012. getRenderingMesh(): Mesh;
  30013. /**
  30014. * Returns the replacement mesh of the submesh
  30015. * @returns the replacement mesh (could be different from parent mesh)
  30016. */
  30017. getReplacementMesh(): Nullable<AbstractMesh>;
  30018. /**
  30019. * Returns the effective mesh of the submesh
  30020. * @returns the effective mesh (could be different from parent mesh)
  30021. */
  30022. getEffectiveMesh(): AbstractMesh;
  30023. /**
  30024. * Returns the submesh material
  30025. * @returns null or the current material
  30026. */
  30027. getMaterial(): Nullable<Material>;
  30028. private _IsMultiMaterial;
  30029. /**
  30030. * Sets a new updated BoundingInfo object to the submesh
  30031. * @param data defines an optional position array to use to determine the bounding info
  30032. * @returns the SubMesh
  30033. */
  30034. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30035. /** @hidden */
  30036. _checkCollision(collider: Collider): boolean;
  30037. /**
  30038. * Updates the submesh BoundingInfo
  30039. * @param world defines the world matrix to use to update the bounding info
  30040. * @returns the submesh
  30041. */
  30042. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30043. /**
  30044. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30045. * @param frustumPlanes defines the frustum planes
  30046. * @returns true if the submesh is intersecting with the frustum
  30047. */
  30048. isInFrustum(frustumPlanes: Plane[]): boolean;
  30049. /**
  30050. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30051. * @param frustumPlanes defines the frustum planes
  30052. * @returns true if the submesh is inside the frustum
  30053. */
  30054. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30055. /**
  30056. * Renders the submesh
  30057. * @param enableAlphaMode defines if alpha needs to be used
  30058. * @returns the submesh
  30059. */
  30060. render(enableAlphaMode: boolean): SubMesh;
  30061. /**
  30062. * @hidden
  30063. */
  30064. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30065. /**
  30066. * Checks if the submesh intersects with a ray
  30067. * @param ray defines the ray to test
  30068. * @returns true is the passed ray intersects the submesh bounding box
  30069. */
  30070. canIntersects(ray: Ray): boolean;
  30071. /**
  30072. * Intersects current submesh with a ray
  30073. * @param ray defines the ray to test
  30074. * @param positions defines mesh's positions array
  30075. * @param indices defines mesh's indices array
  30076. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30077. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30078. * @returns intersection info or null if no intersection
  30079. */
  30080. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30081. /** @hidden */
  30082. private _intersectLines;
  30083. /** @hidden */
  30084. private _intersectUnIndexedLines;
  30085. /** @hidden */
  30086. private _intersectTriangles;
  30087. /** @hidden */
  30088. private _intersectUnIndexedTriangles;
  30089. /** @hidden */
  30090. _rebuild(): void;
  30091. /**
  30092. * Creates a new submesh from the passed mesh
  30093. * @param newMesh defines the new hosting mesh
  30094. * @param newRenderingMesh defines an optional rendering mesh
  30095. * @returns the new submesh
  30096. */
  30097. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30098. /**
  30099. * Release associated resources
  30100. */
  30101. dispose(): void;
  30102. /**
  30103. * Gets the class name
  30104. * @returns the string "SubMesh".
  30105. */
  30106. getClassName(): string;
  30107. /**
  30108. * Creates a new submesh from indices data
  30109. * @param materialIndex the index of the main mesh material
  30110. * @param startIndex the index where to start the copy in the mesh indices array
  30111. * @param indexCount the number of indices to copy then from the startIndex
  30112. * @param mesh the main mesh to create the submesh from
  30113. * @param renderingMesh the optional rendering mesh
  30114. * @returns a new submesh
  30115. */
  30116. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30117. }
  30118. }
  30119. declare module BABYLON {
  30120. /**
  30121. * Class used to represent data loading progression
  30122. */
  30123. export class SceneLoaderFlags {
  30124. private static _ForceFullSceneLoadingForIncremental;
  30125. private static _ShowLoadingScreen;
  30126. private static _CleanBoneMatrixWeights;
  30127. private static _loggingLevel;
  30128. /**
  30129. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30130. */
  30131. static get ForceFullSceneLoadingForIncremental(): boolean;
  30132. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30133. /**
  30134. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30135. */
  30136. static get ShowLoadingScreen(): boolean;
  30137. static set ShowLoadingScreen(value: boolean);
  30138. /**
  30139. * Defines the current logging level (while loading the scene)
  30140. * @ignorenaming
  30141. */
  30142. static get loggingLevel(): number;
  30143. static set loggingLevel(value: number);
  30144. /**
  30145. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30146. */
  30147. static get CleanBoneMatrixWeights(): boolean;
  30148. static set CleanBoneMatrixWeights(value: boolean);
  30149. }
  30150. }
  30151. declare module BABYLON {
  30152. /**
  30153. * Class used to store geometry data (vertex buffers + index buffer)
  30154. */
  30155. export class Geometry implements IGetSetVerticesData {
  30156. /**
  30157. * Gets or sets the ID of the geometry
  30158. */
  30159. id: string;
  30160. /**
  30161. * Gets or sets the unique ID of the geometry
  30162. */
  30163. uniqueId: number;
  30164. /**
  30165. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30166. */
  30167. delayLoadState: number;
  30168. /**
  30169. * Gets the file containing the data to load when running in delay load state
  30170. */
  30171. delayLoadingFile: Nullable<string>;
  30172. /**
  30173. * Callback called when the geometry is updated
  30174. */
  30175. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30176. private _scene;
  30177. private _engine;
  30178. private _meshes;
  30179. private _totalVertices;
  30180. /** @hidden */
  30181. _indices: IndicesArray;
  30182. /** @hidden */
  30183. _vertexBuffers: {
  30184. [key: string]: VertexBuffer;
  30185. };
  30186. private _isDisposed;
  30187. private _extend;
  30188. private _boundingBias;
  30189. /** @hidden */
  30190. _delayInfo: Array<string>;
  30191. private _indexBuffer;
  30192. private _indexBufferIsUpdatable;
  30193. /** @hidden */
  30194. _boundingInfo: Nullable<BoundingInfo>;
  30195. /** @hidden */
  30196. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30197. /** @hidden */
  30198. _softwareSkinningFrameId: number;
  30199. private _vertexArrayObjects;
  30200. private _updatable;
  30201. /** @hidden */
  30202. _positions: Nullable<Vector3[]>;
  30203. private _positionsCache;
  30204. /**
  30205. * 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
  30206. */
  30207. get boundingBias(): Vector2;
  30208. /**
  30209. * 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
  30210. */
  30211. set boundingBias(value: Vector2);
  30212. /**
  30213. * Static function used to attach a new empty geometry to a mesh
  30214. * @param mesh defines the mesh to attach the geometry to
  30215. * @returns the new Geometry
  30216. */
  30217. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30218. /** Get the list of meshes using this geometry */
  30219. get meshes(): Mesh[];
  30220. /**
  30221. * 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
  30222. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30223. */
  30224. useBoundingInfoFromGeometry: boolean;
  30225. /**
  30226. * Creates a new geometry
  30227. * @param id defines the unique ID
  30228. * @param scene defines the hosting scene
  30229. * @param vertexData defines the VertexData used to get geometry data
  30230. * @param updatable defines if geometry must be updatable (false by default)
  30231. * @param mesh defines the mesh that will be associated with the geometry
  30232. */
  30233. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30234. /**
  30235. * Gets the current extend of the geometry
  30236. */
  30237. get extend(): {
  30238. minimum: Vector3;
  30239. maximum: Vector3;
  30240. };
  30241. /**
  30242. * Gets the hosting scene
  30243. * @returns the hosting Scene
  30244. */
  30245. getScene(): Scene;
  30246. /**
  30247. * Gets the hosting engine
  30248. * @returns the hosting Engine
  30249. */
  30250. getEngine(): Engine;
  30251. /**
  30252. * Defines if the geometry is ready to use
  30253. * @returns true if the geometry is ready to be used
  30254. */
  30255. isReady(): boolean;
  30256. /**
  30257. * Gets a value indicating that the geometry should not be serialized
  30258. */
  30259. get doNotSerialize(): boolean;
  30260. /** @hidden */
  30261. _rebuild(): void;
  30262. /**
  30263. * Affects all geometry data in one call
  30264. * @param vertexData defines the geometry data
  30265. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30266. */
  30267. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30268. /**
  30269. * Set specific vertex data
  30270. * @param kind defines the data kind (Position, normal, etc...)
  30271. * @param data defines the vertex data to use
  30272. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30273. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30274. */
  30275. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30276. /**
  30277. * Removes a specific vertex data
  30278. * @param kind defines the data kind (Position, normal, etc...)
  30279. */
  30280. removeVerticesData(kind: string): void;
  30281. /**
  30282. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30283. * @param buffer defines the vertex buffer to use
  30284. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30285. */
  30286. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30287. /**
  30288. * Update a specific vertex buffer
  30289. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30290. * It will do nothing if the buffer is not updatable
  30291. * @param kind defines the data kind (Position, normal, etc...)
  30292. * @param data defines the data to use
  30293. * @param offset defines the offset in the target buffer where to store the data
  30294. * @param useBytes set to true if the offset is in bytes
  30295. */
  30296. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30297. /**
  30298. * Update a specific vertex buffer
  30299. * This function will create a new buffer if the current one is not updatable
  30300. * @param kind defines the data kind (Position, normal, etc...)
  30301. * @param data defines the data to use
  30302. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30303. */
  30304. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30305. private _updateBoundingInfo;
  30306. /** @hidden */
  30307. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30308. /**
  30309. * Gets total number of vertices
  30310. * @returns the total number of vertices
  30311. */
  30312. getTotalVertices(): number;
  30313. /**
  30314. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30315. * @param kind defines the data kind (Position, normal, etc...)
  30316. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30317. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30318. * @returns a float array containing vertex data
  30319. */
  30320. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30321. /**
  30322. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30323. * @param kind defines the data kind (Position, normal, etc...)
  30324. * @returns true if the vertex buffer with the specified kind is updatable
  30325. */
  30326. isVertexBufferUpdatable(kind: string): boolean;
  30327. /**
  30328. * Gets a specific vertex buffer
  30329. * @param kind defines the data kind (Position, normal, etc...)
  30330. * @returns a VertexBuffer
  30331. */
  30332. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30333. /**
  30334. * Returns all vertex buffers
  30335. * @return an object holding all vertex buffers indexed by kind
  30336. */
  30337. getVertexBuffers(): Nullable<{
  30338. [key: string]: VertexBuffer;
  30339. }>;
  30340. /**
  30341. * Gets a boolean indicating if specific vertex buffer is present
  30342. * @param kind defines the data kind (Position, normal, etc...)
  30343. * @returns true if data is present
  30344. */
  30345. isVerticesDataPresent(kind: string): boolean;
  30346. /**
  30347. * Gets a list of all attached data kinds (Position, normal, etc...)
  30348. * @returns a list of string containing all kinds
  30349. */
  30350. getVerticesDataKinds(): string[];
  30351. /**
  30352. * Update index buffer
  30353. * @param indices defines the indices to store in the index buffer
  30354. * @param offset defines the offset in the target buffer where to store the data
  30355. * @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)
  30356. */
  30357. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30358. /**
  30359. * Creates a new index buffer
  30360. * @param indices defines the indices to store in the index buffer
  30361. * @param totalVertices defines the total number of vertices (could be null)
  30362. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30363. */
  30364. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30365. /**
  30366. * Return the total number of indices
  30367. * @returns the total number of indices
  30368. */
  30369. getTotalIndices(): number;
  30370. /**
  30371. * Gets the index buffer array
  30372. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30373. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30374. * @returns the index buffer array
  30375. */
  30376. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30377. /**
  30378. * Gets the index buffer
  30379. * @return the index buffer
  30380. */
  30381. getIndexBuffer(): Nullable<DataBuffer>;
  30382. /** @hidden */
  30383. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30384. /**
  30385. * Release the associated resources for a specific mesh
  30386. * @param mesh defines the source mesh
  30387. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30388. */
  30389. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30390. /**
  30391. * Apply current geometry to a given mesh
  30392. * @param mesh defines the mesh to apply geometry to
  30393. */
  30394. applyToMesh(mesh: Mesh): void;
  30395. private _updateExtend;
  30396. private _applyToMesh;
  30397. private notifyUpdate;
  30398. /**
  30399. * Load the geometry if it was flagged as delay loaded
  30400. * @param scene defines the hosting scene
  30401. * @param onLoaded defines a callback called when the geometry is loaded
  30402. */
  30403. load(scene: Scene, onLoaded?: () => void): void;
  30404. private _queueLoad;
  30405. /**
  30406. * Invert the geometry to move from a right handed system to a left handed one.
  30407. */
  30408. toLeftHanded(): void;
  30409. /** @hidden */
  30410. _resetPointsArrayCache(): void;
  30411. /** @hidden */
  30412. _generatePointsArray(): boolean;
  30413. /**
  30414. * Gets a value indicating if the geometry is disposed
  30415. * @returns true if the geometry was disposed
  30416. */
  30417. isDisposed(): boolean;
  30418. private _disposeVertexArrayObjects;
  30419. /**
  30420. * Free all associated resources
  30421. */
  30422. dispose(): void;
  30423. /**
  30424. * Clone the current geometry into a new geometry
  30425. * @param id defines the unique ID of the new geometry
  30426. * @returns a new geometry object
  30427. */
  30428. copy(id: string): Geometry;
  30429. /**
  30430. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30431. * @return a JSON representation of the current geometry data (without the vertices data)
  30432. */
  30433. serialize(): any;
  30434. private toNumberArray;
  30435. /**
  30436. * Serialize all vertices data into a JSON oject
  30437. * @returns a JSON representation of the current geometry data
  30438. */
  30439. serializeVerticeData(): any;
  30440. /**
  30441. * Extracts a clone of a mesh geometry
  30442. * @param mesh defines the source mesh
  30443. * @param id defines the unique ID of the new geometry object
  30444. * @returns the new geometry object
  30445. */
  30446. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30447. /**
  30448. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30449. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30450. * Be aware Math.random() could cause collisions, but:
  30451. * "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"
  30452. * @returns a string containing a new GUID
  30453. */
  30454. static RandomId(): string;
  30455. /** @hidden */
  30456. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30457. private static _CleanMatricesWeights;
  30458. /**
  30459. * Create a new geometry from persisted data (Using .babylon file format)
  30460. * @param parsedVertexData defines the persisted data
  30461. * @param scene defines the hosting scene
  30462. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30463. * @returns the new geometry object
  30464. */
  30465. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30466. }
  30467. }
  30468. declare module BABYLON {
  30469. /**
  30470. * Define an interface for all classes that will get and set the data on vertices
  30471. */
  30472. export interface IGetSetVerticesData {
  30473. /**
  30474. * Gets a boolean indicating if specific vertex data is present
  30475. * @param kind defines the vertex data kind to use
  30476. * @returns true is data kind is present
  30477. */
  30478. isVerticesDataPresent(kind: string): boolean;
  30479. /**
  30480. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30481. * @param kind defines the data kind (Position, normal, etc...)
  30482. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30483. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30484. * @returns a float array containing vertex data
  30485. */
  30486. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30487. /**
  30488. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  30489. * @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.
  30490. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30491. * @returns the indices array or an empty array if the mesh has no geometry
  30492. */
  30493. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30494. /**
  30495. * Set specific vertex data
  30496. * @param kind defines the data kind (Position, normal, etc...)
  30497. * @param data defines the vertex data to use
  30498. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30499. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30500. */
  30501. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  30502. /**
  30503. * Update a specific associated vertex buffer
  30504. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  30505. * - VertexBuffer.PositionKind
  30506. * - VertexBuffer.UVKind
  30507. * - VertexBuffer.UV2Kind
  30508. * - VertexBuffer.UV3Kind
  30509. * - VertexBuffer.UV4Kind
  30510. * - VertexBuffer.UV5Kind
  30511. * - VertexBuffer.UV6Kind
  30512. * - VertexBuffer.ColorKind
  30513. * - VertexBuffer.MatricesIndicesKind
  30514. * - VertexBuffer.MatricesIndicesExtraKind
  30515. * - VertexBuffer.MatricesWeightsKind
  30516. * - VertexBuffer.MatricesWeightsExtraKind
  30517. * @param data defines the data source
  30518. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  30519. * @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)
  30520. */
  30521. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  30522. /**
  30523. * Creates a new index buffer
  30524. * @param indices defines the indices to store in the index buffer
  30525. * @param totalVertices defines the total number of vertices (could be null)
  30526. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30527. */
  30528. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  30529. }
  30530. /**
  30531. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  30532. */
  30533. export class VertexData {
  30534. /**
  30535. * Mesh side orientation : usually the external or front surface
  30536. */
  30537. static readonly FRONTSIDE: number;
  30538. /**
  30539. * Mesh side orientation : usually the internal or back surface
  30540. */
  30541. static readonly BACKSIDE: number;
  30542. /**
  30543. * Mesh side orientation : both internal and external or front and back surfaces
  30544. */
  30545. static readonly DOUBLESIDE: number;
  30546. /**
  30547. * Mesh side orientation : by default, `FRONTSIDE`
  30548. */
  30549. static readonly DEFAULTSIDE: number;
  30550. /**
  30551. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  30552. */
  30553. positions: Nullable<FloatArray>;
  30554. /**
  30555. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  30556. */
  30557. normals: Nullable<FloatArray>;
  30558. /**
  30559. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  30560. */
  30561. tangents: Nullable<FloatArray>;
  30562. /**
  30563. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30564. */
  30565. uvs: Nullable<FloatArray>;
  30566. /**
  30567. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30568. */
  30569. uvs2: Nullable<FloatArray>;
  30570. /**
  30571. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30572. */
  30573. uvs3: Nullable<FloatArray>;
  30574. /**
  30575. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30576. */
  30577. uvs4: Nullable<FloatArray>;
  30578. /**
  30579. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30580. */
  30581. uvs5: Nullable<FloatArray>;
  30582. /**
  30583. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30584. */
  30585. uvs6: Nullable<FloatArray>;
  30586. /**
  30587. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  30588. */
  30589. colors: Nullable<FloatArray>;
  30590. /**
  30591. * 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).
  30592. */
  30593. matricesIndices: Nullable<FloatArray>;
  30594. /**
  30595. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  30596. */
  30597. matricesWeights: Nullable<FloatArray>;
  30598. /**
  30599. * An array extending the number of possible indices
  30600. */
  30601. matricesIndicesExtra: Nullable<FloatArray>;
  30602. /**
  30603. * An array extending the number of possible weights when the number of indices is extended
  30604. */
  30605. matricesWeightsExtra: Nullable<FloatArray>;
  30606. /**
  30607. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  30608. */
  30609. indices: Nullable<IndicesArray>;
  30610. /**
  30611. * Uses the passed data array to set the set the values for the specified kind of data
  30612. * @param data a linear array of floating numbers
  30613. * @param kind the type of data that is being set, eg positions, colors etc
  30614. */
  30615. set(data: FloatArray, kind: string): void;
  30616. /**
  30617. * Associates the vertexData to the passed Mesh.
  30618. * Sets it as updatable or not (default `false`)
  30619. * @param mesh the mesh the vertexData is applied to
  30620. * @param updatable when used and having the value true allows new data to update the vertexData
  30621. * @returns the VertexData
  30622. */
  30623. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  30624. /**
  30625. * Associates the vertexData to the passed Geometry.
  30626. * Sets it as updatable or not (default `false`)
  30627. * @param geometry the geometry the vertexData is applied to
  30628. * @param updatable when used and having the value true allows new data to update the vertexData
  30629. * @returns VertexData
  30630. */
  30631. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  30632. /**
  30633. * Updates the associated mesh
  30634. * @param mesh the mesh to be updated
  30635. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30636. * @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
  30637. * @returns VertexData
  30638. */
  30639. updateMesh(mesh: Mesh): VertexData;
  30640. /**
  30641. * Updates the associated geometry
  30642. * @param geometry the geometry to be updated
  30643. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30644. * @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
  30645. * @returns VertexData.
  30646. */
  30647. updateGeometry(geometry: Geometry): VertexData;
  30648. private _applyTo;
  30649. private _update;
  30650. /**
  30651. * Transforms each position and each normal of the vertexData according to the passed Matrix
  30652. * @param matrix the transforming matrix
  30653. * @returns the VertexData
  30654. */
  30655. transform(matrix: Matrix): VertexData;
  30656. /**
  30657. * Merges the passed VertexData into the current one
  30658. * @param other the VertexData to be merged into the current one
  30659. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  30660. * @returns the modified VertexData
  30661. */
  30662. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  30663. private _mergeElement;
  30664. private _validate;
  30665. /**
  30666. * Serializes the VertexData
  30667. * @returns a serialized object
  30668. */
  30669. serialize(): any;
  30670. /**
  30671. * Extracts the vertexData from a mesh
  30672. * @param mesh the mesh from which to extract the VertexData
  30673. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  30674. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30675. * @returns the object VertexData associated to the passed mesh
  30676. */
  30677. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30678. /**
  30679. * Extracts the vertexData from the geometry
  30680. * @param geometry the geometry from which to extract the VertexData
  30681. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  30682. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30683. * @returns the object VertexData associated to the passed mesh
  30684. */
  30685. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30686. private static _ExtractFrom;
  30687. /**
  30688. * Creates the VertexData for a Ribbon
  30689. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  30690. * * pathArray array of paths, each of which an array of successive Vector3
  30691. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  30692. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  30693. * * 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
  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. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  30698. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  30699. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  30700. * @returns the VertexData of the ribbon
  30701. */
  30702. static CreateRibbon(options: {
  30703. pathArray: Vector3[][];
  30704. closeArray?: boolean;
  30705. closePath?: boolean;
  30706. offset?: number;
  30707. sideOrientation?: number;
  30708. frontUVs?: Vector4;
  30709. backUVs?: Vector4;
  30710. invertUV?: boolean;
  30711. uvs?: Vector2[];
  30712. colors?: Color4[];
  30713. }): VertexData;
  30714. /**
  30715. * Creates the VertexData for a box
  30716. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30717. * * size sets the width, height and depth of the box to the value of size, optional default 1
  30718. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  30719. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  30720. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  30721. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30722. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30723. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30724. * * 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)
  30725. * * 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)
  30726. * @returns the VertexData of the box
  30727. */
  30728. static CreateBox(options: {
  30729. size?: number;
  30730. width?: number;
  30731. height?: number;
  30732. depth?: number;
  30733. faceUV?: Vector4[];
  30734. faceColors?: Color4[];
  30735. sideOrientation?: number;
  30736. frontUVs?: Vector4;
  30737. backUVs?: Vector4;
  30738. }): VertexData;
  30739. /**
  30740. * Creates the VertexData for a tiled box
  30741. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30742. * * faceTiles sets the pattern, tile size and number of tiles for a face
  30743. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30744. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30745. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30746. * @returns the VertexData of the box
  30747. */
  30748. static CreateTiledBox(options: {
  30749. pattern?: number;
  30750. width?: number;
  30751. height?: number;
  30752. depth?: number;
  30753. tileSize?: number;
  30754. tileWidth?: number;
  30755. tileHeight?: number;
  30756. alignHorizontal?: number;
  30757. alignVertical?: number;
  30758. faceUV?: Vector4[];
  30759. faceColors?: Color4[];
  30760. sideOrientation?: number;
  30761. }): VertexData;
  30762. /**
  30763. * Creates the VertexData for a tiled plane
  30764. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30765. * * pattern a limited pattern arrangement depending on the number
  30766. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  30767. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  30768. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  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 tiled plane
  30773. */
  30774. static CreateTiledPlane(options: {
  30775. pattern?: number;
  30776. tileSize?: number;
  30777. tileWidth?: number;
  30778. tileHeight?: number;
  30779. size?: number;
  30780. width?: number;
  30781. height?: number;
  30782. alignHorizontal?: number;
  30783. alignVertical?: number;
  30784. sideOrientation?: number;
  30785. frontUVs?: Vector4;
  30786. backUVs?: Vector4;
  30787. }): VertexData;
  30788. /**
  30789. * Creates the VertexData for an ellipsoid, defaults to a sphere
  30790. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30791. * * segments sets the number of horizontal strips optional, default 32
  30792. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  30793. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  30794. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  30795. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  30796. * * 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
  30797. * * 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
  30798. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30799. * * 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)
  30800. * * 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)
  30801. * @returns the VertexData of the ellipsoid
  30802. */
  30803. static CreateSphere(options: {
  30804. segments?: number;
  30805. diameter?: number;
  30806. diameterX?: number;
  30807. diameterY?: number;
  30808. diameterZ?: number;
  30809. arc?: number;
  30810. slice?: number;
  30811. sideOrientation?: number;
  30812. frontUVs?: Vector4;
  30813. backUVs?: Vector4;
  30814. }): VertexData;
  30815. /**
  30816. * Creates the VertexData for a cylinder, cone or prism
  30817. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30818. * * height sets the height (y direction) of the cylinder, optional, default 2
  30819. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  30820. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  30821. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  30822. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30823. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  30824. * * 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
  30825. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30826. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30827. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  30828. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  30829. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30830. * * 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)
  30831. * * 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)
  30832. * @returns the VertexData of the cylinder, cone or prism
  30833. */
  30834. static CreateCylinder(options: {
  30835. height?: number;
  30836. diameterTop?: number;
  30837. diameterBottom?: number;
  30838. diameter?: number;
  30839. tessellation?: number;
  30840. subdivisions?: number;
  30841. arc?: number;
  30842. faceColors?: Color4[];
  30843. faceUV?: Vector4[];
  30844. hasRings?: boolean;
  30845. enclose?: boolean;
  30846. sideOrientation?: number;
  30847. frontUVs?: Vector4;
  30848. backUVs?: Vector4;
  30849. }): VertexData;
  30850. /**
  30851. * Creates the VertexData for a torus
  30852. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30853. * * diameter the diameter of the torus, optional default 1
  30854. * * thickness the diameter of the tube forming the torus, optional default 0.5
  30855. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30856. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30857. * * 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)
  30858. * * 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)
  30859. * @returns the VertexData of the torus
  30860. */
  30861. static CreateTorus(options: {
  30862. diameter?: number;
  30863. thickness?: number;
  30864. tessellation?: number;
  30865. sideOrientation?: number;
  30866. frontUVs?: Vector4;
  30867. backUVs?: Vector4;
  30868. }): VertexData;
  30869. /**
  30870. * Creates the VertexData of the LineSystem
  30871. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  30872. * - lines an array of lines, each line being an array of successive Vector3
  30873. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  30874. * @returns the VertexData of the LineSystem
  30875. */
  30876. static CreateLineSystem(options: {
  30877. lines: Vector3[][];
  30878. colors?: Nullable<Color4[][]>;
  30879. }): VertexData;
  30880. /**
  30881. * Create the VertexData for a DashedLines
  30882. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  30883. * - points an array successive Vector3
  30884. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  30885. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  30886. * - dashNb the intended total number of dashes, optional, default 200
  30887. * @returns the VertexData for the DashedLines
  30888. */
  30889. static CreateDashedLines(options: {
  30890. points: Vector3[];
  30891. dashSize?: number;
  30892. gapSize?: number;
  30893. dashNb?: number;
  30894. }): VertexData;
  30895. /**
  30896. * Creates the VertexData for a Ground
  30897. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30898. * - width the width (x direction) of the ground, optional, default 1
  30899. * - height the height (z direction) of the ground, optional, default 1
  30900. * - subdivisions the number of subdivisions per side, optional, default 1
  30901. * @returns the VertexData of the Ground
  30902. */
  30903. static CreateGround(options: {
  30904. width?: number;
  30905. height?: number;
  30906. subdivisions?: number;
  30907. subdivisionsX?: number;
  30908. subdivisionsY?: number;
  30909. }): VertexData;
  30910. /**
  30911. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  30912. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30913. * * xmin the ground minimum X coordinate, optional, default -1
  30914. * * zmin the ground minimum Z coordinate, optional, default -1
  30915. * * xmax the ground maximum X coordinate, optional, default 1
  30916. * * zmax the ground maximum Z coordinate, optional, default 1
  30917. * * 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}
  30918. * * 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}
  30919. * @returns the VertexData of the TiledGround
  30920. */
  30921. static CreateTiledGround(options: {
  30922. xmin: number;
  30923. zmin: number;
  30924. xmax: number;
  30925. zmax: number;
  30926. subdivisions?: {
  30927. w: number;
  30928. h: number;
  30929. };
  30930. precision?: {
  30931. w: number;
  30932. h: number;
  30933. };
  30934. }): VertexData;
  30935. /**
  30936. * Creates the VertexData of the Ground designed from a heightmap
  30937. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  30938. * * width the width (x direction) of the ground
  30939. * * height the height (z direction) of the ground
  30940. * * subdivisions the number of subdivisions per side
  30941. * * minHeight the minimum altitude on the ground, optional, default 0
  30942. * * maxHeight the maximum altitude on the ground, optional default 1
  30943. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  30944. * * buffer the array holding the image color data
  30945. * * bufferWidth the width of image
  30946. * * bufferHeight the height of image
  30947. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  30948. * @returns the VertexData of the Ground designed from a heightmap
  30949. */
  30950. static CreateGroundFromHeightMap(options: {
  30951. width: number;
  30952. height: number;
  30953. subdivisions: number;
  30954. minHeight: number;
  30955. maxHeight: number;
  30956. colorFilter: Color3;
  30957. buffer: Uint8Array;
  30958. bufferWidth: number;
  30959. bufferHeight: number;
  30960. alphaFilter: number;
  30961. }): VertexData;
  30962. /**
  30963. * Creates the VertexData for a Plane
  30964. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  30965. * * size sets the width and height of the plane to the value of size, optional default 1
  30966. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  30967. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  30968. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30969. * * 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)
  30970. * * 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)
  30971. * @returns the VertexData of the box
  30972. */
  30973. static CreatePlane(options: {
  30974. size?: number;
  30975. width?: number;
  30976. height?: number;
  30977. sideOrientation?: number;
  30978. frontUVs?: Vector4;
  30979. backUVs?: Vector4;
  30980. }): VertexData;
  30981. /**
  30982. * Creates the VertexData of the Disc or regular Polygon
  30983. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  30984. * * radius the radius of the disc, optional default 0.5
  30985. * * tessellation the number of polygon sides, optional, default 64
  30986. * * 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
  30987. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30988. * * 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)
  30989. * * 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)
  30990. * @returns the VertexData of the box
  30991. */
  30992. static CreateDisc(options: {
  30993. radius?: number;
  30994. tessellation?: number;
  30995. arc?: number;
  30996. sideOrientation?: number;
  30997. frontUVs?: Vector4;
  30998. backUVs?: Vector4;
  30999. }): VertexData;
  31000. /**
  31001. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  31002. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  31003. * @param polygon a mesh built from polygonTriangulation.build()
  31004. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31005. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31006. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31007. * @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)
  31008. * @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)
  31009. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  31010. * @returns the VertexData of the Polygon
  31011. */
  31012. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  31013. /**
  31014. * Creates the VertexData of the IcoSphere
  31015. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  31016. * * radius the radius of the IcoSphere, optional default 1
  31017. * * radiusX allows stretching in the x direction, optional, default radius
  31018. * * radiusY allows stretching in the y direction, optional, default radius
  31019. * * radiusZ allows stretching in the z direction, optional, default radius
  31020. * * flat when true creates a flat shaded mesh, optional, default true
  31021. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31022. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31023. * * 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)
  31024. * * 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)
  31025. * @returns the VertexData of the IcoSphere
  31026. */
  31027. static CreateIcoSphere(options: {
  31028. radius?: number;
  31029. radiusX?: number;
  31030. radiusY?: number;
  31031. radiusZ?: number;
  31032. flat?: boolean;
  31033. subdivisions?: number;
  31034. sideOrientation?: number;
  31035. frontUVs?: Vector4;
  31036. backUVs?: Vector4;
  31037. }): VertexData;
  31038. /**
  31039. * Creates the VertexData for a Polyhedron
  31040. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  31041. * * type provided types are:
  31042. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  31043. * * 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)
  31044. * * size the size of the IcoSphere, optional default 1
  31045. * * sizeX allows stretching in the x direction, optional, default size
  31046. * * sizeY allows stretching in the y direction, optional, default size
  31047. * * sizeZ allows stretching in the z direction, optional, default size
  31048. * * 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
  31049. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31050. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31051. * * flat when true creates a flat shaded mesh, optional, default true
  31052. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31053. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31054. * * 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)
  31055. * * 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)
  31056. * @returns the VertexData of the Polyhedron
  31057. */
  31058. static CreatePolyhedron(options: {
  31059. type?: number;
  31060. size?: number;
  31061. sizeX?: number;
  31062. sizeY?: number;
  31063. sizeZ?: number;
  31064. custom?: any;
  31065. faceUV?: Vector4[];
  31066. faceColors?: Color4[];
  31067. flat?: boolean;
  31068. sideOrientation?: number;
  31069. frontUVs?: Vector4;
  31070. backUVs?: Vector4;
  31071. }): VertexData;
  31072. /**
  31073. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  31074. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  31075. * @returns the VertexData of the Capsule
  31076. */
  31077. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  31078. /**
  31079. * Creates the VertexData for a TorusKnot
  31080. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  31081. * * radius the radius of the torus knot, optional, default 2
  31082. * * tube the thickness of the tube, optional, default 0.5
  31083. * * radialSegments the number of sides on each tube segments, optional, default 32
  31084. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  31085. * * p the number of windings around the z axis, optional, default 2
  31086. * * q the number of windings around the x axis, optional, default 3
  31087. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31088. * * 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)
  31089. * * 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)
  31090. * @returns the VertexData of the Torus Knot
  31091. */
  31092. static CreateTorusKnot(options: {
  31093. radius?: number;
  31094. tube?: number;
  31095. radialSegments?: number;
  31096. tubularSegments?: number;
  31097. p?: number;
  31098. q?: number;
  31099. sideOrientation?: number;
  31100. frontUVs?: Vector4;
  31101. backUVs?: Vector4;
  31102. }): VertexData;
  31103. /**
  31104. * Compute normals for given positions and indices
  31105. * @param positions an array of vertex positions, [...., x, y, z, ......]
  31106. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  31107. * @param normals an array of vertex normals, [...., x, y, z, ......]
  31108. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  31109. * * facetNormals : optional array of facet normals (vector3)
  31110. * * facetPositions : optional array of facet positions (vector3)
  31111. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  31112. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  31113. * * bInfo : optional bounding info, required for facetPartitioning computation
  31114. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  31115. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  31116. * * useRightHandedSystem: optional boolean to for right handed system computation
  31117. * * depthSort : optional boolean to enable the facet depth sort computation
  31118. * * distanceTo : optional Vector3 to compute the facet depth from this location
  31119. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  31120. */
  31121. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  31122. facetNormals?: any;
  31123. facetPositions?: any;
  31124. facetPartitioning?: any;
  31125. ratio?: number;
  31126. bInfo?: any;
  31127. bbSize?: Vector3;
  31128. subDiv?: any;
  31129. useRightHandedSystem?: boolean;
  31130. depthSort?: boolean;
  31131. distanceTo?: Vector3;
  31132. depthSortedFacets?: any;
  31133. }): void;
  31134. /** @hidden */
  31135. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  31136. /**
  31137. * Applies VertexData created from the imported parameters to the geometry
  31138. * @param parsedVertexData the parsed data from an imported file
  31139. * @param geometry the geometry to apply the VertexData to
  31140. */
  31141. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  31142. }
  31143. }
  31144. declare module BABYLON {
  31145. /**
  31146. * Defines a target to use with MorphTargetManager
  31147. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31148. */
  31149. export class MorphTarget implements IAnimatable {
  31150. /** defines the name of the target */
  31151. name: string;
  31152. /**
  31153. * Gets or sets the list of animations
  31154. */
  31155. animations: Animation[];
  31156. private _scene;
  31157. private _positions;
  31158. private _normals;
  31159. private _tangents;
  31160. private _uvs;
  31161. private _influence;
  31162. private _uniqueId;
  31163. /**
  31164. * Observable raised when the influence changes
  31165. */
  31166. onInfluenceChanged: Observable<boolean>;
  31167. /** @hidden */
  31168. _onDataLayoutChanged: Observable<void>;
  31169. /**
  31170. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31171. */
  31172. get influence(): number;
  31173. set influence(influence: number);
  31174. /**
  31175. * Gets or sets the id of the morph Target
  31176. */
  31177. id: string;
  31178. private _animationPropertiesOverride;
  31179. /**
  31180. * Gets or sets the animation properties override
  31181. */
  31182. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31183. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31184. /**
  31185. * Creates a new MorphTarget
  31186. * @param name defines the name of the target
  31187. * @param influence defines the influence to use
  31188. * @param scene defines the scene the morphtarget belongs to
  31189. */
  31190. constructor(
  31191. /** defines the name of the target */
  31192. name: string, influence?: number, scene?: Nullable<Scene>);
  31193. /**
  31194. * Gets the unique ID of this manager
  31195. */
  31196. get uniqueId(): number;
  31197. /**
  31198. * Gets a boolean defining if the target contains position data
  31199. */
  31200. get hasPositions(): boolean;
  31201. /**
  31202. * Gets a boolean defining if the target contains normal data
  31203. */
  31204. get hasNormals(): boolean;
  31205. /**
  31206. * Gets a boolean defining if the target contains tangent data
  31207. */
  31208. get hasTangents(): boolean;
  31209. /**
  31210. * Gets a boolean defining if the target contains texture coordinates data
  31211. */
  31212. get hasUVs(): boolean;
  31213. /**
  31214. * Affects position data to this target
  31215. * @param data defines the position data to use
  31216. */
  31217. setPositions(data: Nullable<FloatArray>): void;
  31218. /**
  31219. * Gets the position data stored in this target
  31220. * @returns a FloatArray containing the position data (or null if not present)
  31221. */
  31222. getPositions(): Nullable<FloatArray>;
  31223. /**
  31224. * Affects normal data to this target
  31225. * @param data defines the normal data to use
  31226. */
  31227. setNormals(data: Nullable<FloatArray>): void;
  31228. /**
  31229. * Gets the normal data stored in this target
  31230. * @returns a FloatArray containing the normal data (or null if not present)
  31231. */
  31232. getNormals(): Nullable<FloatArray>;
  31233. /**
  31234. * Affects tangent data to this target
  31235. * @param data defines the tangent data to use
  31236. */
  31237. setTangents(data: Nullable<FloatArray>): void;
  31238. /**
  31239. * Gets the tangent data stored in this target
  31240. * @returns a FloatArray containing the tangent data (or null if not present)
  31241. */
  31242. getTangents(): Nullable<FloatArray>;
  31243. /**
  31244. * Affects texture coordinates data to this target
  31245. * @param data defines the texture coordinates data to use
  31246. */
  31247. setUVs(data: Nullable<FloatArray>): void;
  31248. /**
  31249. * Gets the texture coordinates data stored in this target
  31250. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31251. */
  31252. getUVs(): Nullable<FloatArray>;
  31253. /**
  31254. * Clone the current target
  31255. * @returns a new MorphTarget
  31256. */
  31257. clone(): MorphTarget;
  31258. /**
  31259. * Serializes the current target into a Serialization object
  31260. * @returns the serialized object
  31261. */
  31262. serialize(): any;
  31263. /**
  31264. * Returns the string "MorphTarget"
  31265. * @returns "MorphTarget"
  31266. */
  31267. getClassName(): string;
  31268. /**
  31269. * Creates a new target from serialized data
  31270. * @param serializationObject defines the serialized data to use
  31271. * @returns a new MorphTarget
  31272. */
  31273. static Parse(serializationObject: any): MorphTarget;
  31274. /**
  31275. * Creates a MorphTarget from mesh data
  31276. * @param mesh defines the source mesh
  31277. * @param name defines the name to use for the new target
  31278. * @param influence defines the influence to attach to the target
  31279. * @returns a new MorphTarget
  31280. */
  31281. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31282. }
  31283. }
  31284. declare module BABYLON {
  31285. /**
  31286. * This class is used to deform meshes using morphing between different targets
  31287. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31288. */
  31289. export class MorphTargetManager {
  31290. private _targets;
  31291. private _targetInfluenceChangedObservers;
  31292. private _targetDataLayoutChangedObservers;
  31293. private _activeTargets;
  31294. private _scene;
  31295. private _influences;
  31296. private _supportsNormals;
  31297. private _supportsTangents;
  31298. private _supportsUVs;
  31299. private _vertexCount;
  31300. private _uniqueId;
  31301. private _tempInfluences;
  31302. /**
  31303. * Gets or sets a boolean indicating if normals must be morphed
  31304. */
  31305. enableNormalMorphing: boolean;
  31306. /**
  31307. * Gets or sets a boolean indicating if tangents must be morphed
  31308. */
  31309. enableTangentMorphing: boolean;
  31310. /**
  31311. * Gets or sets a boolean indicating if UV must be morphed
  31312. */
  31313. enableUVMorphing: boolean;
  31314. /**
  31315. * Creates a new MorphTargetManager
  31316. * @param scene defines the current scene
  31317. */
  31318. constructor(scene?: Nullable<Scene>);
  31319. /**
  31320. * Gets the unique ID of this manager
  31321. */
  31322. get uniqueId(): number;
  31323. /**
  31324. * Gets the number of vertices handled by this manager
  31325. */
  31326. get vertexCount(): number;
  31327. /**
  31328. * Gets a boolean indicating if this manager supports morphing of normals
  31329. */
  31330. get supportsNormals(): boolean;
  31331. /**
  31332. * Gets a boolean indicating if this manager supports morphing of tangents
  31333. */
  31334. get supportsTangents(): boolean;
  31335. /**
  31336. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31337. */
  31338. get supportsUVs(): boolean;
  31339. /**
  31340. * Gets the number of targets stored in this manager
  31341. */
  31342. get numTargets(): number;
  31343. /**
  31344. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31345. */
  31346. get numInfluencers(): number;
  31347. /**
  31348. * Gets the list of influences (one per target)
  31349. */
  31350. get influences(): Float32Array;
  31351. /**
  31352. * Gets the active target at specified index. An active target is a target with an influence > 0
  31353. * @param index defines the index to check
  31354. * @returns the requested target
  31355. */
  31356. getActiveTarget(index: number): MorphTarget;
  31357. /**
  31358. * Gets the target at specified index
  31359. * @param index defines the index to check
  31360. * @returns the requested target
  31361. */
  31362. getTarget(index: number): MorphTarget;
  31363. /**
  31364. * Add a new target to this manager
  31365. * @param target defines the target to add
  31366. */
  31367. addTarget(target: MorphTarget): void;
  31368. /**
  31369. * Removes a target from the manager
  31370. * @param target defines the target to remove
  31371. */
  31372. removeTarget(target: MorphTarget): void;
  31373. /**
  31374. * Clone the current manager
  31375. * @returns a new MorphTargetManager
  31376. */
  31377. clone(): MorphTargetManager;
  31378. /**
  31379. * Serializes the current manager into a Serialization object
  31380. * @returns the serialized object
  31381. */
  31382. serialize(): any;
  31383. private _syncActiveTargets;
  31384. /**
  31385. * Syncrhonize the targets with all the meshes using this morph target manager
  31386. */
  31387. synchronize(): void;
  31388. /**
  31389. * Creates a new MorphTargetManager from serialized data
  31390. * @param serializationObject defines the serialized data
  31391. * @param scene defines the hosting scene
  31392. * @returns the new MorphTargetManager
  31393. */
  31394. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31395. }
  31396. }
  31397. declare module BABYLON {
  31398. /**
  31399. * Class used to represent a specific level of detail of a mesh
  31400. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31401. */
  31402. export class MeshLODLevel {
  31403. /** Defines the distance where this level should start being displayed */
  31404. distance: number;
  31405. /** Defines the mesh to use to render this level */
  31406. mesh: Nullable<Mesh>;
  31407. /**
  31408. * Creates a new LOD level
  31409. * @param distance defines the distance where this level should star being displayed
  31410. * @param mesh defines the mesh to use to render this level
  31411. */
  31412. constructor(
  31413. /** Defines the distance where this level should start being displayed */
  31414. distance: number,
  31415. /** Defines the mesh to use to render this level */
  31416. mesh: Nullable<Mesh>);
  31417. }
  31418. }
  31419. declare module BABYLON {
  31420. /**
  31421. * Helper class used to generate a canvas to manipulate images
  31422. */
  31423. export class CanvasGenerator {
  31424. /**
  31425. * Create a new canvas (or offscreen canvas depending on the context)
  31426. * @param width defines the expected width
  31427. * @param height defines the expected height
  31428. * @return a new canvas or offscreen canvas
  31429. */
  31430. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31431. }
  31432. }
  31433. declare module BABYLON {
  31434. /**
  31435. * Mesh representing the gorund
  31436. */
  31437. export class GroundMesh extends Mesh {
  31438. /** If octree should be generated */
  31439. generateOctree: boolean;
  31440. private _heightQuads;
  31441. /** @hidden */
  31442. _subdivisionsX: number;
  31443. /** @hidden */
  31444. _subdivisionsY: number;
  31445. /** @hidden */
  31446. _width: number;
  31447. /** @hidden */
  31448. _height: number;
  31449. /** @hidden */
  31450. _minX: number;
  31451. /** @hidden */
  31452. _maxX: number;
  31453. /** @hidden */
  31454. _minZ: number;
  31455. /** @hidden */
  31456. _maxZ: number;
  31457. constructor(name: string, scene: Scene);
  31458. /**
  31459. * "GroundMesh"
  31460. * @returns "GroundMesh"
  31461. */
  31462. getClassName(): string;
  31463. /**
  31464. * The minimum of x and y subdivisions
  31465. */
  31466. get subdivisions(): number;
  31467. /**
  31468. * X subdivisions
  31469. */
  31470. get subdivisionsX(): number;
  31471. /**
  31472. * Y subdivisions
  31473. */
  31474. get subdivisionsY(): number;
  31475. /**
  31476. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31477. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31478. * @param chunksCount the number of subdivisions for x and y
  31479. * @param octreeBlocksSize (Default: 32)
  31480. */
  31481. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31482. /**
  31483. * Returns a height (y) value in the Worl system :
  31484. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31485. * @param x x coordinate
  31486. * @param z z coordinate
  31487. * @returns the ground y position if (x, z) are outside the ground surface.
  31488. */
  31489. getHeightAtCoordinates(x: number, z: number): number;
  31490. /**
  31491. * Returns a normalized vector (Vector3) orthogonal to the ground
  31492. * at the ground coordinates (x, z) expressed in the World system.
  31493. * @param x x coordinate
  31494. * @param z z coordinate
  31495. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31496. */
  31497. getNormalAtCoordinates(x: number, z: number): Vector3;
  31498. /**
  31499. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31500. * at the ground coordinates (x, z) expressed in the World system.
  31501. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31502. * @param x x coordinate
  31503. * @param z z coordinate
  31504. * @param ref vector to store the result
  31505. * @returns the GroundMesh.
  31506. */
  31507. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31508. /**
  31509. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31510. * if the ground has been updated.
  31511. * This can be used in the render loop.
  31512. * @returns the GroundMesh.
  31513. */
  31514. updateCoordinateHeights(): GroundMesh;
  31515. private _getFacetAt;
  31516. private _initHeightQuads;
  31517. private _computeHeightQuads;
  31518. /**
  31519. * Serializes this ground mesh
  31520. * @param serializationObject object to write serialization to
  31521. */
  31522. serialize(serializationObject: any): void;
  31523. /**
  31524. * Parses a serialized ground mesh
  31525. * @param parsedMesh the serialized mesh
  31526. * @param scene the scene to create the ground mesh in
  31527. * @returns the created ground mesh
  31528. */
  31529. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31530. }
  31531. }
  31532. declare module BABYLON {
  31533. /**
  31534. * Interface for Physics-Joint data
  31535. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31536. */
  31537. export interface PhysicsJointData {
  31538. /**
  31539. * The main pivot of the joint
  31540. */
  31541. mainPivot?: Vector3;
  31542. /**
  31543. * The connected pivot of the joint
  31544. */
  31545. connectedPivot?: Vector3;
  31546. /**
  31547. * The main axis of the joint
  31548. */
  31549. mainAxis?: Vector3;
  31550. /**
  31551. * The connected axis of the joint
  31552. */
  31553. connectedAxis?: Vector3;
  31554. /**
  31555. * The collision of the joint
  31556. */
  31557. collision?: boolean;
  31558. /**
  31559. * Native Oimo/Cannon/Energy data
  31560. */
  31561. nativeParams?: any;
  31562. }
  31563. /**
  31564. * This is a holder class for the physics joint created by the physics plugin
  31565. * It holds a set of functions to control the underlying joint
  31566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31567. */
  31568. export class PhysicsJoint {
  31569. /**
  31570. * The type of the physics joint
  31571. */
  31572. type: number;
  31573. /**
  31574. * The data for the physics joint
  31575. */
  31576. jointData: PhysicsJointData;
  31577. private _physicsJoint;
  31578. protected _physicsPlugin: IPhysicsEnginePlugin;
  31579. /**
  31580. * Initializes the physics joint
  31581. * @param type The type of the physics joint
  31582. * @param jointData The data for the physics joint
  31583. */
  31584. constructor(
  31585. /**
  31586. * The type of the physics joint
  31587. */
  31588. type: number,
  31589. /**
  31590. * The data for the physics joint
  31591. */
  31592. jointData: PhysicsJointData);
  31593. /**
  31594. * Gets the physics joint
  31595. */
  31596. get physicsJoint(): any;
  31597. /**
  31598. * Sets the physics joint
  31599. */
  31600. set physicsJoint(newJoint: any);
  31601. /**
  31602. * Sets the physics plugin
  31603. */
  31604. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31605. /**
  31606. * Execute a function that is physics-plugin specific.
  31607. * @param {Function} func the function that will be executed.
  31608. * It accepts two parameters: the physics world and the physics joint
  31609. */
  31610. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31611. /**
  31612. * Distance-Joint type
  31613. */
  31614. static DistanceJoint: number;
  31615. /**
  31616. * Hinge-Joint type
  31617. */
  31618. static HingeJoint: number;
  31619. /**
  31620. * Ball-and-Socket joint type
  31621. */
  31622. static BallAndSocketJoint: number;
  31623. /**
  31624. * Wheel-Joint type
  31625. */
  31626. static WheelJoint: number;
  31627. /**
  31628. * Slider-Joint type
  31629. */
  31630. static SliderJoint: number;
  31631. /**
  31632. * Prismatic-Joint type
  31633. */
  31634. static PrismaticJoint: number;
  31635. /**
  31636. * Universal-Joint type
  31637. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31638. */
  31639. static UniversalJoint: number;
  31640. /**
  31641. * Hinge-Joint 2 type
  31642. */
  31643. static Hinge2Joint: number;
  31644. /**
  31645. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31646. */
  31647. static PointToPointJoint: number;
  31648. /**
  31649. * Spring-Joint type
  31650. */
  31651. static SpringJoint: number;
  31652. /**
  31653. * Lock-Joint type
  31654. */
  31655. static LockJoint: number;
  31656. }
  31657. /**
  31658. * A class representing a physics distance joint
  31659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31660. */
  31661. export class DistanceJoint extends PhysicsJoint {
  31662. /**
  31663. *
  31664. * @param jointData The data for the Distance-Joint
  31665. */
  31666. constructor(jointData: DistanceJointData);
  31667. /**
  31668. * Update the predefined distance.
  31669. * @param maxDistance The maximum preferred distance
  31670. * @param minDistance The minimum preferred distance
  31671. */
  31672. updateDistance(maxDistance: number, minDistance?: number): void;
  31673. }
  31674. /**
  31675. * Represents a Motor-Enabled Joint
  31676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31677. */
  31678. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31679. /**
  31680. * Initializes the Motor-Enabled Joint
  31681. * @param type The type of the joint
  31682. * @param jointData The physica joint data for the joint
  31683. */
  31684. constructor(type: number, jointData: PhysicsJointData);
  31685. /**
  31686. * Set the motor values.
  31687. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31688. * @param force the force to apply
  31689. * @param maxForce max force for this motor.
  31690. */
  31691. setMotor(force?: number, maxForce?: number): void;
  31692. /**
  31693. * Set the motor's limits.
  31694. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31695. * @param upperLimit The upper limit of the motor
  31696. * @param lowerLimit The lower limit of the motor
  31697. */
  31698. setLimit(upperLimit: number, lowerLimit?: number): void;
  31699. }
  31700. /**
  31701. * This class represents a single physics Hinge-Joint
  31702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31703. */
  31704. export class HingeJoint extends MotorEnabledJoint {
  31705. /**
  31706. * Initializes the Hinge-Joint
  31707. * @param jointData The joint data for the Hinge-Joint
  31708. */
  31709. constructor(jointData: PhysicsJointData);
  31710. /**
  31711. * Set the motor values.
  31712. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31713. * @param {number} force the force to apply
  31714. * @param {number} maxForce max force for this motor.
  31715. */
  31716. setMotor(force?: number, maxForce?: number): void;
  31717. /**
  31718. * Set the motor's limits.
  31719. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31720. * @param upperLimit The upper limit of the motor
  31721. * @param lowerLimit The lower limit of the motor
  31722. */
  31723. setLimit(upperLimit: number, lowerLimit?: number): void;
  31724. }
  31725. /**
  31726. * This class represents a dual hinge physics joint (same as wheel joint)
  31727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31728. */
  31729. export class Hinge2Joint extends MotorEnabledJoint {
  31730. /**
  31731. * Initializes the Hinge2-Joint
  31732. * @param jointData The joint data for the Hinge2-Joint
  31733. */
  31734. constructor(jointData: PhysicsJointData);
  31735. /**
  31736. * Set the motor values.
  31737. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31738. * @param {number} targetSpeed the speed the motor is to reach
  31739. * @param {number} maxForce max force for this motor.
  31740. * @param {motorIndex} the motor's index, 0 or 1.
  31741. */
  31742. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31743. /**
  31744. * Set the motor limits.
  31745. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31746. * @param {number} upperLimit the upper limit
  31747. * @param {number} lowerLimit lower limit
  31748. * @param {motorIndex} the motor's index, 0 or 1.
  31749. */
  31750. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31751. }
  31752. /**
  31753. * Interface for a motor enabled joint
  31754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31755. */
  31756. export interface IMotorEnabledJoint {
  31757. /**
  31758. * Physics joint
  31759. */
  31760. physicsJoint: any;
  31761. /**
  31762. * Sets the motor of the motor-enabled joint
  31763. * @param force The force of the motor
  31764. * @param maxForce The maximum force of the motor
  31765. * @param motorIndex The index of the motor
  31766. */
  31767. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31768. /**
  31769. * Sets the limit of the motor
  31770. * @param upperLimit The upper limit of the motor
  31771. * @param lowerLimit The lower limit of the motor
  31772. * @param motorIndex The index of the motor
  31773. */
  31774. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31775. }
  31776. /**
  31777. * Joint data for a Distance-Joint
  31778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31779. */
  31780. export interface DistanceJointData extends PhysicsJointData {
  31781. /**
  31782. * Max distance the 2 joint objects can be apart
  31783. */
  31784. maxDistance: number;
  31785. }
  31786. /**
  31787. * Joint data from a spring joint
  31788. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31789. */
  31790. export interface SpringJointData extends PhysicsJointData {
  31791. /**
  31792. * Length of the spring
  31793. */
  31794. length: number;
  31795. /**
  31796. * Stiffness of the spring
  31797. */
  31798. stiffness: number;
  31799. /**
  31800. * Damping of the spring
  31801. */
  31802. damping: number;
  31803. /** this callback will be called when applying the force to the impostors. */
  31804. forceApplicationCallback: () => void;
  31805. }
  31806. }
  31807. declare module BABYLON {
  31808. /**
  31809. * Holds the data for the raycast result
  31810. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31811. */
  31812. export class PhysicsRaycastResult {
  31813. private _hasHit;
  31814. private _hitDistance;
  31815. private _hitNormalWorld;
  31816. private _hitPointWorld;
  31817. private _rayFromWorld;
  31818. private _rayToWorld;
  31819. /**
  31820. * Gets if there was a hit
  31821. */
  31822. get hasHit(): boolean;
  31823. /**
  31824. * Gets the distance from the hit
  31825. */
  31826. get hitDistance(): number;
  31827. /**
  31828. * Gets the hit normal/direction in the world
  31829. */
  31830. get hitNormalWorld(): Vector3;
  31831. /**
  31832. * Gets the hit point in the world
  31833. */
  31834. get hitPointWorld(): Vector3;
  31835. /**
  31836. * Gets the ray "start point" of the ray in the world
  31837. */
  31838. get rayFromWorld(): Vector3;
  31839. /**
  31840. * Gets the ray "end point" of the ray in the world
  31841. */
  31842. get rayToWorld(): Vector3;
  31843. /**
  31844. * Sets the hit data (normal & point in world space)
  31845. * @param hitNormalWorld defines the normal in world space
  31846. * @param hitPointWorld defines the point in world space
  31847. */
  31848. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31849. /**
  31850. * Sets the distance from the start point to the hit point
  31851. * @param distance
  31852. */
  31853. setHitDistance(distance: number): void;
  31854. /**
  31855. * Calculates the distance manually
  31856. */
  31857. calculateHitDistance(): void;
  31858. /**
  31859. * Resets all the values to default
  31860. * @param from The from point on world space
  31861. * @param to The to point on world space
  31862. */
  31863. reset(from?: Vector3, to?: Vector3): void;
  31864. }
  31865. /**
  31866. * Interface for the size containing width and height
  31867. */
  31868. interface IXYZ {
  31869. /**
  31870. * X
  31871. */
  31872. x: number;
  31873. /**
  31874. * Y
  31875. */
  31876. y: number;
  31877. /**
  31878. * Z
  31879. */
  31880. z: number;
  31881. }
  31882. }
  31883. declare module BABYLON {
  31884. /**
  31885. * Interface used to describe a physics joint
  31886. */
  31887. export interface PhysicsImpostorJoint {
  31888. /** Defines the main impostor to which the joint is linked */
  31889. mainImpostor: PhysicsImpostor;
  31890. /** Defines the impostor that is connected to the main impostor using this joint */
  31891. connectedImpostor: PhysicsImpostor;
  31892. /** Defines the joint itself */
  31893. joint: PhysicsJoint;
  31894. }
  31895. /** @hidden */
  31896. export interface IPhysicsEnginePlugin {
  31897. world: any;
  31898. name: string;
  31899. setGravity(gravity: Vector3): void;
  31900. setTimeStep(timeStep: number): void;
  31901. getTimeStep(): number;
  31902. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31903. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31904. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31905. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31906. removePhysicsBody(impostor: PhysicsImpostor): void;
  31907. generateJoint(joint: PhysicsImpostorJoint): void;
  31908. removeJoint(joint: PhysicsImpostorJoint): void;
  31909. isSupported(): boolean;
  31910. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31911. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31912. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31913. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31914. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31915. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31916. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31917. getBodyMass(impostor: PhysicsImpostor): number;
  31918. getBodyFriction(impostor: PhysicsImpostor): number;
  31919. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31920. getBodyRestitution(impostor: PhysicsImpostor): number;
  31921. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31922. getBodyPressure?(impostor: PhysicsImpostor): number;
  31923. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31924. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31925. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31926. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31927. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31928. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31929. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31930. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31931. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31932. sleepBody(impostor: PhysicsImpostor): void;
  31933. wakeUpBody(impostor: PhysicsImpostor): void;
  31934. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31935. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31936. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31937. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31938. getRadius(impostor: PhysicsImpostor): number;
  31939. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31940. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31941. dispose(): void;
  31942. }
  31943. /**
  31944. * Interface used to define a physics engine
  31945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31946. */
  31947. export interface IPhysicsEngine {
  31948. /**
  31949. * Gets the gravity vector used by the simulation
  31950. */
  31951. gravity: Vector3;
  31952. /**
  31953. * Sets the gravity vector used by the simulation
  31954. * @param gravity defines the gravity vector to use
  31955. */
  31956. setGravity(gravity: Vector3): void;
  31957. /**
  31958. * Set the time step of the physics engine.
  31959. * Default is 1/60.
  31960. * To slow it down, enter 1/600 for example.
  31961. * To speed it up, 1/30
  31962. * @param newTimeStep the new timestep to apply to this world.
  31963. */
  31964. setTimeStep(newTimeStep: number): void;
  31965. /**
  31966. * Get the time step of the physics engine.
  31967. * @returns the current time step
  31968. */
  31969. getTimeStep(): number;
  31970. /**
  31971. * Set the sub time step of the physics engine.
  31972. * Default is 0 meaning there is no sub steps
  31973. * To increase physics resolution precision, set a small value (like 1 ms)
  31974. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31975. */
  31976. setSubTimeStep(subTimeStep: number): void;
  31977. /**
  31978. * Get the sub time step of the physics engine.
  31979. * @returns the current sub time step
  31980. */
  31981. getSubTimeStep(): number;
  31982. /**
  31983. * Release all resources
  31984. */
  31985. dispose(): void;
  31986. /**
  31987. * Gets the name of the current physics plugin
  31988. * @returns the name of the plugin
  31989. */
  31990. getPhysicsPluginName(): string;
  31991. /**
  31992. * Adding a new impostor for the impostor tracking.
  31993. * This will be done by the impostor itself.
  31994. * @param impostor the impostor to add
  31995. */
  31996. addImpostor(impostor: PhysicsImpostor): void;
  31997. /**
  31998. * Remove an impostor from the engine.
  31999. * This impostor and its mesh will not longer be updated by the physics engine.
  32000. * @param impostor the impostor to remove
  32001. */
  32002. removeImpostor(impostor: PhysicsImpostor): void;
  32003. /**
  32004. * Add a joint to the physics engine
  32005. * @param mainImpostor defines the main impostor to which the joint is added.
  32006. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32007. * @param joint defines the joint that will connect both impostors.
  32008. */
  32009. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32010. /**
  32011. * Removes a joint from the simulation
  32012. * @param mainImpostor defines the impostor used with the joint
  32013. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32014. * @param joint defines the joint to remove
  32015. */
  32016. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32017. /**
  32018. * Gets the current plugin used to run the simulation
  32019. * @returns current plugin
  32020. */
  32021. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32022. /**
  32023. * Gets the list of physic impostors
  32024. * @returns an array of PhysicsImpostor
  32025. */
  32026. getImpostors(): Array<PhysicsImpostor>;
  32027. /**
  32028. * Gets the impostor for a physics enabled object
  32029. * @param object defines the object impersonated by the impostor
  32030. * @returns the PhysicsImpostor or null if not found
  32031. */
  32032. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32033. /**
  32034. * Gets the impostor for a physics body object
  32035. * @param body defines physics body used by the impostor
  32036. * @returns the PhysicsImpostor or null if not found
  32037. */
  32038. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32039. /**
  32040. * Does a raycast in the physics world
  32041. * @param from when should the ray start?
  32042. * @param to when should the ray end?
  32043. * @returns PhysicsRaycastResult
  32044. */
  32045. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32046. /**
  32047. * Called by the scene. No need to call it.
  32048. * @param delta defines the timespam between frames
  32049. */
  32050. _step(delta: number): void;
  32051. }
  32052. }
  32053. declare module BABYLON {
  32054. /**
  32055. * The interface for the physics imposter parameters
  32056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32057. */
  32058. export interface PhysicsImpostorParameters {
  32059. /**
  32060. * The mass of the physics imposter
  32061. */
  32062. mass: number;
  32063. /**
  32064. * The friction of the physics imposter
  32065. */
  32066. friction?: number;
  32067. /**
  32068. * The coefficient of restitution of the physics imposter
  32069. */
  32070. restitution?: number;
  32071. /**
  32072. * The native options of the physics imposter
  32073. */
  32074. nativeOptions?: any;
  32075. /**
  32076. * Specifies if the parent should be ignored
  32077. */
  32078. ignoreParent?: boolean;
  32079. /**
  32080. * Specifies if bi-directional transformations should be disabled
  32081. */
  32082. disableBidirectionalTransformation?: boolean;
  32083. /**
  32084. * The pressure inside the physics imposter, soft object only
  32085. */
  32086. pressure?: number;
  32087. /**
  32088. * The stiffness the physics imposter, soft object only
  32089. */
  32090. stiffness?: number;
  32091. /**
  32092. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32093. */
  32094. velocityIterations?: number;
  32095. /**
  32096. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32097. */
  32098. positionIterations?: number;
  32099. /**
  32100. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32101. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32102. * Add to fix multiple points
  32103. */
  32104. fixedPoints?: number;
  32105. /**
  32106. * The collision margin around a soft object
  32107. */
  32108. margin?: number;
  32109. /**
  32110. * The collision margin around a soft object
  32111. */
  32112. damping?: number;
  32113. /**
  32114. * The path for a rope based on an extrusion
  32115. */
  32116. path?: any;
  32117. /**
  32118. * The shape of an extrusion used for a rope based on an extrusion
  32119. */
  32120. shape?: any;
  32121. }
  32122. /**
  32123. * Interface for a physics-enabled object
  32124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32125. */
  32126. export interface IPhysicsEnabledObject {
  32127. /**
  32128. * The position of the physics-enabled object
  32129. */
  32130. position: Vector3;
  32131. /**
  32132. * The rotation of the physics-enabled object
  32133. */
  32134. rotationQuaternion: Nullable<Quaternion>;
  32135. /**
  32136. * The scale of the physics-enabled object
  32137. */
  32138. scaling: Vector3;
  32139. /**
  32140. * The rotation of the physics-enabled object
  32141. */
  32142. rotation?: Vector3;
  32143. /**
  32144. * The parent of the physics-enabled object
  32145. */
  32146. parent?: any;
  32147. /**
  32148. * The bounding info of the physics-enabled object
  32149. * @returns The bounding info of the physics-enabled object
  32150. */
  32151. getBoundingInfo(): BoundingInfo;
  32152. /**
  32153. * Computes the world matrix
  32154. * @param force Specifies if the world matrix should be computed by force
  32155. * @returns A world matrix
  32156. */
  32157. computeWorldMatrix(force: boolean): Matrix;
  32158. /**
  32159. * Gets the world matrix
  32160. * @returns A world matrix
  32161. */
  32162. getWorldMatrix?(): Matrix;
  32163. /**
  32164. * Gets the child meshes
  32165. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32166. * @returns An array of abstract meshes
  32167. */
  32168. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32169. /**
  32170. * Gets the vertex data
  32171. * @param kind The type of vertex data
  32172. * @returns A nullable array of numbers, or a float32 array
  32173. */
  32174. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32175. /**
  32176. * Gets the indices from the mesh
  32177. * @returns A nullable array of index arrays
  32178. */
  32179. getIndices?(): Nullable<IndicesArray>;
  32180. /**
  32181. * Gets the scene from the mesh
  32182. * @returns the indices array or null
  32183. */
  32184. getScene?(): Scene;
  32185. /**
  32186. * Gets the absolute position from the mesh
  32187. * @returns the absolute position
  32188. */
  32189. getAbsolutePosition(): Vector3;
  32190. /**
  32191. * Gets the absolute pivot point from the mesh
  32192. * @returns the absolute pivot point
  32193. */
  32194. getAbsolutePivotPoint(): Vector3;
  32195. /**
  32196. * Rotates the mesh
  32197. * @param axis The axis of rotation
  32198. * @param amount The amount of rotation
  32199. * @param space The space of the rotation
  32200. * @returns The rotation transform node
  32201. */
  32202. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32203. /**
  32204. * Translates the mesh
  32205. * @param axis The axis of translation
  32206. * @param distance The distance of translation
  32207. * @param space The space of the translation
  32208. * @returns The transform node
  32209. */
  32210. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32211. /**
  32212. * Sets the absolute position of the mesh
  32213. * @param absolutePosition The absolute position of the mesh
  32214. * @returns The transform node
  32215. */
  32216. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32217. /**
  32218. * Gets the class name of the mesh
  32219. * @returns The class name
  32220. */
  32221. getClassName(): string;
  32222. }
  32223. /**
  32224. * Represents a physics imposter
  32225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32226. */
  32227. export class PhysicsImpostor {
  32228. /**
  32229. * The physics-enabled object used as the physics imposter
  32230. */
  32231. object: IPhysicsEnabledObject;
  32232. /**
  32233. * The type of the physics imposter
  32234. */
  32235. type: number;
  32236. private _options;
  32237. private _scene?;
  32238. /**
  32239. * The default object size of the imposter
  32240. */
  32241. static DEFAULT_OBJECT_SIZE: Vector3;
  32242. /**
  32243. * The identity quaternion of the imposter
  32244. */
  32245. static IDENTITY_QUATERNION: Quaternion;
  32246. /** @hidden */
  32247. _pluginData: any;
  32248. private _physicsEngine;
  32249. private _physicsBody;
  32250. private _bodyUpdateRequired;
  32251. private _onBeforePhysicsStepCallbacks;
  32252. private _onAfterPhysicsStepCallbacks;
  32253. /** @hidden */
  32254. _onPhysicsCollideCallbacks: Array<{
  32255. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32256. otherImpostors: Array<PhysicsImpostor>;
  32257. }>;
  32258. private _deltaPosition;
  32259. private _deltaRotation;
  32260. private _deltaRotationConjugated;
  32261. /** @hidden */
  32262. _isFromLine: boolean;
  32263. private _parent;
  32264. private _isDisposed;
  32265. private static _tmpVecs;
  32266. private static _tmpQuat;
  32267. /**
  32268. * Specifies if the physics imposter is disposed
  32269. */
  32270. get isDisposed(): boolean;
  32271. /**
  32272. * Gets the mass of the physics imposter
  32273. */
  32274. get mass(): number;
  32275. set mass(value: number);
  32276. /**
  32277. * Gets the coefficient of friction
  32278. */
  32279. get friction(): number;
  32280. /**
  32281. * Sets the coefficient of friction
  32282. */
  32283. set friction(value: number);
  32284. /**
  32285. * Gets the coefficient of restitution
  32286. */
  32287. get restitution(): number;
  32288. /**
  32289. * Sets the coefficient of restitution
  32290. */
  32291. set restitution(value: number);
  32292. /**
  32293. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32294. */
  32295. get pressure(): number;
  32296. /**
  32297. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32298. */
  32299. set pressure(value: number);
  32300. /**
  32301. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32302. */
  32303. get stiffness(): number;
  32304. /**
  32305. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32306. */
  32307. set stiffness(value: number);
  32308. /**
  32309. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32310. */
  32311. get velocityIterations(): number;
  32312. /**
  32313. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32314. */
  32315. set velocityIterations(value: number);
  32316. /**
  32317. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32318. */
  32319. get positionIterations(): number;
  32320. /**
  32321. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32322. */
  32323. set positionIterations(value: number);
  32324. /**
  32325. * The unique id of the physics imposter
  32326. * set by the physics engine when adding this impostor to the array
  32327. */
  32328. uniqueId: number;
  32329. /**
  32330. * @hidden
  32331. */
  32332. soft: boolean;
  32333. /**
  32334. * @hidden
  32335. */
  32336. segments: number;
  32337. private _joints;
  32338. /**
  32339. * Initializes the physics imposter
  32340. * @param object The physics-enabled object used as the physics imposter
  32341. * @param type The type of the physics imposter
  32342. * @param _options The options for the physics imposter
  32343. * @param _scene The Babylon scene
  32344. */
  32345. constructor(
  32346. /**
  32347. * The physics-enabled object used as the physics imposter
  32348. */
  32349. object: IPhysicsEnabledObject,
  32350. /**
  32351. * The type of the physics imposter
  32352. */
  32353. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32354. /**
  32355. * This function will completly initialize this impostor.
  32356. * It will create a new body - but only if this mesh has no parent.
  32357. * If it has, this impostor will not be used other than to define the impostor
  32358. * of the child mesh.
  32359. * @hidden
  32360. */
  32361. _init(): void;
  32362. private _getPhysicsParent;
  32363. /**
  32364. * Should a new body be generated.
  32365. * @returns boolean specifying if body initialization is required
  32366. */
  32367. isBodyInitRequired(): boolean;
  32368. /**
  32369. * Sets the updated scaling
  32370. * @param updated Specifies if the scaling is updated
  32371. */
  32372. setScalingUpdated(): void;
  32373. /**
  32374. * Force a regeneration of this or the parent's impostor's body.
  32375. * Use under cautious - This will remove all joints already implemented.
  32376. */
  32377. forceUpdate(): void;
  32378. /**
  32379. * Gets the body that holds this impostor. Either its own, or its parent.
  32380. */
  32381. get physicsBody(): any;
  32382. /**
  32383. * Get the parent of the physics imposter
  32384. * @returns Physics imposter or null
  32385. */
  32386. get parent(): Nullable<PhysicsImpostor>;
  32387. /**
  32388. * Sets the parent of the physics imposter
  32389. */
  32390. set parent(value: Nullable<PhysicsImpostor>);
  32391. /**
  32392. * Set the physics body. Used mainly by the physics engine/plugin
  32393. */
  32394. set physicsBody(physicsBody: any);
  32395. /**
  32396. * Resets the update flags
  32397. */
  32398. resetUpdateFlags(): void;
  32399. /**
  32400. * Gets the object extend size
  32401. * @returns the object extend size
  32402. */
  32403. getObjectExtendSize(): Vector3;
  32404. /**
  32405. * Gets the object center
  32406. * @returns The object center
  32407. */
  32408. getObjectCenter(): Vector3;
  32409. /**
  32410. * Get a specific parameter from the options parameters
  32411. * @param paramName The object parameter name
  32412. * @returns The object parameter
  32413. */
  32414. getParam(paramName: string): any;
  32415. /**
  32416. * Sets a specific parameter in the options given to the physics plugin
  32417. * @param paramName The parameter name
  32418. * @param value The value of the parameter
  32419. */
  32420. setParam(paramName: string, value: number): void;
  32421. /**
  32422. * Specifically change the body's mass option. Won't recreate the physics body object
  32423. * @param mass The mass of the physics imposter
  32424. */
  32425. setMass(mass: number): void;
  32426. /**
  32427. * Gets the linear velocity
  32428. * @returns linear velocity or null
  32429. */
  32430. getLinearVelocity(): Nullable<Vector3>;
  32431. /**
  32432. * Sets the linear velocity
  32433. * @param velocity linear velocity or null
  32434. */
  32435. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32436. /**
  32437. * Gets the angular velocity
  32438. * @returns angular velocity or null
  32439. */
  32440. getAngularVelocity(): Nullable<Vector3>;
  32441. /**
  32442. * Sets the angular velocity
  32443. * @param velocity The velocity or null
  32444. */
  32445. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32446. /**
  32447. * Execute a function with the physics plugin native code
  32448. * Provide a function the will have two variables - the world object and the physics body object
  32449. * @param func The function to execute with the physics plugin native code
  32450. */
  32451. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32452. /**
  32453. * Register a function that will be executed before the physics world is stepping forward
  32454. * @param func The function to execute before the physics world is stepped forward
  32455. */
  32456. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32457. /**
  32458. * Unregister a function that will be executed before the physics world is stepping forward
  32459. * @param func The function to execute before the physics world is stepped forward
  32460. */
  32461. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32462. /**
  32463. * Register a function that will be executed after the physics step
  32464. * @param func The function to execute after physics step
  32465. */
  32466. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32467. /**
  32468. * Unregisters a function that will be executed after the physics step
  32469. * @param func The function to execute after physics step
  32470. */
  32471. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32472. /**
  32473. * register a function that will be executed when this impostor collides against a different body
  32474. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32475. * @param func Callback that is executed on collision
  32476. */
  32477. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32478. /**
  32479. * Unregisters the physics imposter on contact
  32480. * @param collideAgainst The physics object to collide against
  32481. * @param func Callback to execute on collision
  32482. */
  32483. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32484. private _tmpQuat;
  32485. private _tmpQuat2;
  32486. /**
  32487. * Get the parent rotation
  32488. * @returns The parent rotation
  32489. */
  32490. getParentsRotation(): Quaternion;
  32491. /**
  32492. * this function is executed by the physics engine.
  32493. */
  32494. beforeStep: () => void;
  32495. /**
  32496. * this function is executed by the physics engine
  32497. */
  32498. afterStep: () => void;
  32499. /**
  32500. * Legacy collision detection event support
  32501. */
  32502. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32503. /**
  32504. * event and body object due to cannon's event-based architecture.
  32505. */
  32506. onCollide: (e: {
  32507. body: any;
  32508. point: Nullable<Vector3>;
  32509. }) => void;
  32510. /**
  32511. * Apply a force
  32512. * @param force The force to apply
  32513. * @param contactPoint The contact point for the force
  32514. * @returns The physics imposter
  32515. */
  32516. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32517. /**
  32518. * Apply an impulse
  32519. * @param force The impulse force
  32520. * @param contactPoint The contact point for the impulse force
  32521. * @returns The physics imposter
  32522. */
  32523. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32524. /**
  32525. * A help function to create a joint
  32526. * @param otherImpostor A physics imposter used to create a joint
  32527. * @param jointType The type of joint
  32528. * @param jointData The data for the joint
  32529. * @returns The physics imposter
  32530. */
  32531. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32532. /**
  32533. * Add a joint to this impostor with a different impostor
  32534. * @param otherImpostor A physics imposter used to add a joint
  32535. * @param joint The joint to add
  32536. * @returns The physics imposter
  32537. */
  32538. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32539. /**
  32540. * Add an anchor to a cloth impostor
  32541. * @param otherImpostor rigid impostor to anchor to
  32542. * @param width ratio across width from 0 to 1
  32543. * @param height ratio up height from 0 to 1
  32544. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32545. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32546. * @returns impostor the soft imposter
  32547. */
  32548. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32549. /**
  32550. * Add a hook to a rope impostor
  32551. * @param otherImpostor rigid impostor to anchor to
  32552. * @param length ratio across rope from 0 to 1
  32553. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32554. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32555. * @returns impostor the rope imposter
  32556. */
  32557. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32558. /**
  32559. * Will keep this body still, in a sleep mode.
  32560. * @returns the physics imposter
  32561. */
  32562. sleep(): PhysicsImpostor;
  32563. /**
  32564. * Wake the body up.
  32565. * @returns The physics imposter
  32566. */
  32567. wakeUp(): PhysicsImpostor;
  32568. /**
  32569. * Clones the physics imposter
  32570. * @param newObject The physics imposter clones to this physics-enabled object
  32571. * @returns A nullable physics imposter
  32572. */
  32573. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32574. /**
  32575. * Disposes the physics imposter
  32576. */
  32577. dispose(): void;
  32578. /**
  32579. * Sets the delta position
  32580. * @param position The delta position amount
  32581. */
  32582. setDeltaPosition(position: Vector3): void;
  32583. /**
  32584. * Sets the delta rotation
  32585. * @param rotation The delta rotation amount
  32586. */
  32587. setDeltaRotation(rotation: Quaternion): void;
  32588. /**
  32589. * Gets the box size of the physics imposter and stores the result in the input parameter
  32590. * @param result Stores the box size
  32591. * @returns The physics imposter
  32592. */
  32593. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32594. /**
  32595. * Gets the radius of the physics imposter
  32596. * @returns Radius of the physics imposter
  32597. */
  32598. getRadius(): number;
  32599. /**
  32600. * Sync a bone with this impostor
  32601. * @param bone The bone to sync to the impostor.
  32602. * @param boneMesh The mesh that the bone is influencing.
  32603. * @param jointPivot The pivot of the joint / bone in local space.
  32604. * @param distToJoint Optional distance from the impostor to the joint.
  32605. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32606. */
  32607. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32608. /**
  32609. * Sync impostor to a bone
  32610. * @param bone The bone that the impostor will be synced to.
  32611. * @param boneMesh The mesh that the bone is influencing.
  32612. * @param jointPivot The pivot of the joint / bone in local space.
  32613. * @param distToJoint Optional distance from the impostor to the joint.
  32614. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32615. * @param boneAxis Optional vector3 axis the bone is aligned with
  32616. */
  32617. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32618. /**
  32619. * No-Imposter type
  32620. */
  32621. static NoImpostor: number;
  32622. /**
  32623. * Sphere-Imposter type
  32624. */
  32625. static SphereImpostor: number;
  32626. /**
  32627. * Box-Imposter type
  32628. */
  32629. static BoxImpostor: number;
  32630. /**
  32631. * Plane-Imposter type
  32632. */
  32633. static PlaneImpostor: number;
  32634. /**
  32635. * Mesh-imposter type
  32636. */
  32637. static MeshImpostor: number;
  32638. /**
  32639. * Capsule-Impostor type (Ammo.js plugin only)
  32640. */
  32641. static CapsuleImpostor: number;
  32642. /**
  32643. * Cylinder-Imposter type
  32644. */
  32645. static CylinderImpostor: number;
  32646. /**
  32647. * Particle-Imposter type
  32648. */
  32649. static ParticleImpostor: number;
  32650. /**
  32651. * Heightmap-Imposter type
  32652. */
  32653. static HeightmapImpostor: number;
  32654. /**
  32655. * ConvexHull-Impostor type (Ammo.js plugin only)
  32656. */
  32657. static ConvexHullImpostor: number;
  32658. /**
  32659. * Custom-Imposter type (Ammo.js plugin only)
  32660. */
  32661. static CustomImpostor: number;
  32662. /**
  32663. * Rope-Imposter type
  32664. */
  32665. static RopeImpostor: number;
  32666. /**
  32667. * Cloth-Imposter type
  32668. */
  32669. static ClothImpostor: number;
  32670. /**
  32671. * Softbody-Imposter type
  32672. */
  32673. static SoftbodyImpostor: number;
  32674. }
  32675. }
  32676. declare module BABYLON {
  32677. /**
  32678. * @hidden
  32679. **/
  32680. export class _CreationDataStorage {
  32681. closePath?: boolean;
  32682. closeArray?: boolean;
  32683. idx: number[];
  32684. dashSize: number;
  32685. gapSize: number;
  32686. path3D: Path3D;
  32687. pathArray: Vector3[][];
  32688. arc: number;
  32689. radius: number;
  32690. cap: number;
  32691. tessellation: number;
  32692. }
  32693. /**
  32694. * @hidden
  32695. **/
  32696. class _InstanceDataStorage {
  32697. visibleInstances: any;
  32698. batchCache: _InstancesBatch;
  32699. instancesBufferSize: number;
  32700. instancesBuffer: Nullable<Buffer>;
  32701. instancesData: Float32Array;
  32702. overridenInstanceCount: number;
  32703. isFrozen: boolean;
  32704. previousBatch: Nullable<_InstancesBatch>;
  32705. hardwareInstancedRendering: boolean;
  32706. sideOrientation: number;
  32707. manualUpdate: boolean;
  32708. previousRenderId: number;
  32709. }
  32710. /**
  32711. * @hidden
  32712. **/
  32713. export class _InstancesBatch {
  32714. mustReturn: boolean;
  32715. visibleInstances: Nullable<InstancedMesh[]>[];
  32716. renderSelf: boolean[];
  32717. hardwareInstancedRendering: boolean[];
  32718. }
  32719. /**
  32720. * @hidden
  32721. **/
  32722. class _ThinInstanceDataStorage {
  32723. instancesCount: number;
  32724. matrixBuffer: Nullable<Buffer>;
  32725. matrixBufferSize: number;
  32726. matrixData: Nullable<Float32Array>;
  32727. boundingVectors: Array<Vector3>;
  32728. worldMatrices: Nullable<Matrix[]>;
  32729. }
  32730. /**
  32731. * Class used to represent renderable models
  32732. */
  32733. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32734. /**
  32735. * Mesh side orientation : usually the external or front surface
  32736. */
  32737. static readonly FRONTSIDE: number;
  32738. /**
  32739. * Mesh side orientation : usually the internal or back surface
  32740. */
  32741. static readonly BACKSIDE: number;
  32742. /**
  32743. * Mesh side orientation : both internal and external or front and back surfaces
  32744. */
  32745. static readonly DOUBLESIDE: number;
  32746. /**
  32747. * Mesh side orientation : by default, `FRONTSIDE`
  32748. */
  32749. static readonly DEFAULTSIDE: number;
  32750. /**
  32751. * Mesh cap setting : no cap
  32752. */
  32753. static readonly NO_CAP: number;
  32754. /**
  32755. * Mesh cap setting : one cap at the beginning of the mesh
  32756. */
  32757. static readonly CAP_START: number;
  32758. /**
  32759. * Mesh cap setting : one cap at the end of the mesh
  32760. */
  32761. static readonly CAP_END: number;
  32762. /**
  32763. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32764. */
  32765. static readonly CAP_ALL: number;
  32766. /**
  32767. * Mesh pattern setting : no flip or rotate
  32768. */
  32769. static readonly NO_FLIP: number;
  32770. /**
  32771. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32772. */
  32773. static readonly FLIP_TILE: number;
  32774. /**
  32775. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32776. */
  32777. static readonly ROTATE_TILE: number;
  32778. /**
  32779. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32780. */
  32781. static readonly FLIP_ROW: number;
  32782. /**
  32783. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32784. */
  32785. static readonly ROTATE_ROW: number;
  32786. /**
  32787. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32788. */
  32789. static readonly FLIP_N_ROTATE_TILE: number;
  32790. /**
  32791. * Mesh pattern setting : rotate pattern and rotate
  32792. */
  32793. static readonly FLIP_N_ROTATE_ROW: number;
  32794. /**
  32795. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32796. */
  32797. static readonly CENTER: number;
  32798. /**
  32799. * Mesh tile positioning : part tiles on left
  32800. */
  32801. static readonly LEFT: number;
  32802. /**
  32803. * Mesh tile positioning : part tiles on right
  32804. */
  32805. static readonly RIGHT: number;
  32806. /**
  32807. * Mesh tile positioning : part tiles on top
  32808. */
  32809. static readonly TOP: number;
  32810. /**
  32811. * Mesh tile positioning : part tiles on bottom
  32812. */
  32813. static readonly BOTTOM: number;
  32814. /**
  32815. * Gets the default side orientation.
  32816. * @param orientation the orientation to value to attempt to get
  32817. * @returns the default orientation
  32818. * @hidden
  32819. */
  32820. static _GetDefaultSideOrientation(orientation?: number): number;
  32821. private _internalMeshDataInfo;
  32822. get computeBonesUsingShaders(): boolean;
  32823. set computeBonesUsingShaders(value: boolean);
  32824. /**
  32825. * An event triggered before rendering the mesh
  32826. */
  32827. get onBeforeRenderObservable(): Observable<Mesh>;
  32828. /**
  32829. * An event triggered before binding the mesh
  32830. */
  32831. get onBeforeBindObservable(): Observable<Mesh>;
  32832. /**
  32833. * An event triggered after rendering the mesh
  32834. */
  32835. get onAfterRenderObservable(): Observable<Mesh>;
  32836. /**
  32837. * An event triggered before drawing the mesh
  32838. */
  32839. get onBeforeDrawObservable(): Observable<Mesh>;
  32840. private _onBeforeDrawObserver;
  32841. /**
  32842. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32843. */
  32844. set onBeforeDraw(callback: () => void);
  32845. get hasInstances(): boolean;
  32846. get hasThinInstances(): boolean;
  32847. /**
  32848. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32849. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32850. */
  32851. delayLoadState: number;
  32852. /**
  32853. * Gets the list of instances created from this mesh
  32854. * it is not supposed to be modified manually.
  32855. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32856. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32857. */
  32858. instances: InstancedMesh[];
  32859. /**
  32860. * Gets the file containing delay loading data for this mesh
  32861. */
  32862. delayLoadingFile: string;
  32863. /** @hidden */
  32864. _binaryInfo: any;
  32865. /**
  32866. * User defined function used to change how LOD level selection is done
  32867. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32868. */
  32869. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32870. /**
  32871. * Gets or sets the morph target manager
  32872. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32873. */
  32874. get morphTargetManager(): Nullable<MorphTargetManager>;
  32875. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32876. /** @hidden */
  32877. _creationDataStorage: Nullable<_CreationDataStorage>;
  32878. /** @hidden */
  32879. _geometry: Nullable<Geometry>;
  32880. /** @hidden */
  32881. _delayInfo: Array<string>;
  32882. /** @hidden */
  32883. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32884. /** @hidden */
  32885. _instanceDataStorage: _InstanceDataStorage;
  32886. /** @hidden */
  32887. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32888. private _effectiveMaterial;
  32889. /** @hidden */
  32890. _shouldGenerateFlatShading: boolean;
  32891. /** @hidden */
  32892. _originalBuilderSideOrientation: number;
  32893. /**
  32894. * Use this property to change the original side orientation defined at construction time
  32895. */
  32896. overrideMaterialSideOrientation: Nullable<number>;
  32897. /**
  32898. * Gets the source mesh (the one used to clone this one from)
  32899. */
  32900. get source(): Nullable<Mesh>;
  32901. /**
  32902. * Gets the list of clones of this mesh
  32903. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32904. * Note that useClonedMeshMap=true is the default setting
  32905. */
  32906. get cloneMeshMap(): Nullable<{
  32907. [id: string]: Mesh | undefined;
  32908. }>;
  32909. /**
  32910. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32911. */
  32912. get isUnIndexed(): boolean;
  32913. set isUnIndexed(value: boolean);
  32914. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32915. get worldMatrixInstancedBuffer(): Float32Array;
  32916. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32917. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32918. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32919. /**
  32920. * @constructor
  32921. * @param name The value used by scene.getMeshByName() to do a lookup.
  32922. * @param scene The scene to add this mesh to.
  32923. * @param parent The parent of this mesh, if it has one
  32924. * @param source An optional Mesh from which geometry is shared, cloned.
  32925. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32926. * When false, achieved by calling a clone(), also passing False.
  32927. * This will make creation of children, recursive.
  32928. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32929. */
  32930. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32931. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32932. doNotInstantiate: boolean;
  32933. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32934. /**
  32935. * Gets the class name
  32936. * @returns the string "Mesh".
  32937. */
  32938. getClassName(): string;
  32939. /** @hidden */
  32940. get _isMesh(): boolean;
  32941. /**
  32942. * Returns a description of this mesh
  32943. * @param fullDetails define if full details about this mesh must be used
  32944. * @returns a descriptive string representing this mesh
  32945. */
  32946. toString(fullDetails?: boolean): string;
  32947. /** @hidden */
  32948. _unBindEffect(): void;
  32949. /**
  32950. * Gets a boolean indicating if this mesh has LOD
  32951. */
  32952. get hasLODLevels(): boolean;
  32953. /**
  32954. * Gets the list of MeshLODLevel associated with the current mesh
  32955. * @returns an array of MeshLODLevel
  32956. */
  32957. getLODLevels(): MeshLODLevel[];
  32958. private _sortLODLevels;
  32959. /**
  32960. * Add a mesh as LOD level triggered at the given distance.
  32961. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32962. * @param distance The distance from the center of the object to show this level
  32963. * @param mesh The mesh to be added as LOD level (can be null)
  32964. * @return This mesh (for chaining)
  32965. */
  32966. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32967. /**
  32968. * Returns the LOD level mesh at the passed distance or null if not found.
  32969. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32970. * @param distance The distance from the center of the object to show this level
  32971. * @returns a Mesh or `null`
  32972. */
  32973. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32974. /**
  32975. * Remove a mesh from the LOD array
  32976. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32977. * @param mesh defines the mesh to be removed
  32978. * @return This mesh (for chaining)
  32979. */
  32980. removeLODLevel(mesh: Mesh): Mesh;
  32981. /**
  32982. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32983. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32984. * @param camera defines the camera to use to compute distance
  32985. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32986. * @return This mesh (for chaining)
  32987. */
  32988. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32989. /**
  32990. * Gets the mesh internal Geometry object
  32991. */
  32992. get geometry(): Nullable<Geometry>;
  32993. /**
  32994. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32995. * @returns the total number of vertices
  32996. */
  32997. getTotalVertices(): number;
  32998. /**
  32999. * Returns the content of an associated vertex buffer
  33000. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33001. * - VertexBuffer.PositionKind
  33002. * - VertexBuffer.UVKind
  33003. * - VertexBuffer.UV2Kind
  33004. * - VertexBuffer.UV3Kind
  33005. * - VertexBuffer.UV4Kind
  33006. * - VertexBuffer.UV5Kind
  33007. * - VertexBuffer.UV6Kind
  33008. * - VertexBuffer.ColorKind
  33009. * - VertexBuffer.MatricesIndicesKind
  33010. * - VertexBuffer.MatricesIndicesExtraKind
  33011. * - VertexBuffer.MatricesWeightsKind
  33012. * - VertexBuffer.MatricesWeightsExtraKind
  33013. * @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
  33014. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33015. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33016. */
  33017. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33018. /**
  33019. * Returns the mesh VertexBuffer object from the requested `kind`
  33020. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33021. * - VertexBuffer.PositionKind
  33022. * - VertexBuffer.NormalKind
  33023. * - VertexBuffer.UVKind
  33024. * - VertexBuffer.UV2Kind
  33025. * - VertexBuffer.UV3Kind
  33026. * - VertexBuffer.UV4Kind
  33027. * - VertexBuffer.UV5Kind
  33028. * - VertexBuffer.UV6Kind
  33029. * - VertexBuffer.ColorKind
  33030. * - VertexBuffer.MatricesIndicesKind
  33031. * - VertexBuffer.MatricesIndicesExtraKind
  33032. * - VertexBuffer.MatricesWeightsKind
  33033. * - VertexBuffer.MatricesWeightsExtraKind
  33034. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33035. */
  33036. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33037. /**
  33038. * Tests if a specific vertex buffer is associated with this mesh
  33039. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33040. * - VertexBuffer.PositionKind
  33041. * - VertexBuffer.NormalKind
  33042. * - VertexBuffer.UVKind
  33043. * - VertexBuffer.UV2Kind
  33044. * - VertexBuffer.UV3Kind
  33045. * - VertexBuffer.UV4Kind
  33046. * - VertexBuffer.UV5Kind
  33047. * - VertexBuffer.UV6Kind
  33048. * - VertexBuffer.ColorKind
  33049. * - VertexBuffer.MatricesIndicesKind
  33050. * - VertexBuffer.MatricesIndicesExtraKind
  33051. * - VertexBuffer.MatricesWeightsKind
  33052. * - VertexBuffer.MatricesWeightsExtraKind
  33053. * @returns a boolean
  33054. */
  33055. isVerticesDataPresent(kind: string): boolean;
  33056. /**
  33057. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33058. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33059. * - VertexBuffer.PositionKind
  33060. * - VertexBuffer.UVKind
  33061. * - VertexBuffer.UV2Kind
  33062. * - VertexBuffer.UV3Kind
  33063. * - VertexBuffer.UV4Kind
  33064. * - VertexBuffer.UV5Kind
  33065. * - VertexBuffer.UV6Kind
  33066. * - VertexBuffer.ColorKind
  33067. * - VertexBuffer.MatricesIndicesKind
  33068. * - VertexBuffer.MatricesIndicesExtraKind
  33069. * - VertexBuffer.MatricesWeightsKind
  33070. * - VertexBuffer.MatricesWeightsExtraKind
  33071. * @returns a boolean
  33072. */
  33073. isVertexBufferUpdatable(kind: string): boolean;
  33074. /**
  33075. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33076. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33077. * - VertexBuffer.PositionKind
  33078. * - VertexBuffer.NormalKind
  33079. * - VertexBuffer.UVKind
  33080. * - VertexBuffer.UV2Kind
  33081. * - VertexBuffer.UV3Kind
  33082. * - VertexBuffer.UV4Kind
  33083. * - VertexBuffer.UV5Kind
  33084. * - VertexBuffer.UV6Kind
  33085. * - VertexBuffer.ColorKind
  33086. * - VertexBuffer.MatricesIndicesKind
  33087. * - VertexBuffer.MatricesIndicesExtraKind
  33088. * - VertexBuffer.MatricesWeightsKind
  33089. * - VertexBuffer.MatricesWeightsExtraKind
  33090. * @returns an array of strings
  33091. */
  33092. getVerticesDataKinds(): string[];
  33093. /**
  33094. * Returns a positive integer : the total number of indices in this mesh geometry.
  33095. * @returns the numner of indices or zero if the mesh has no geometry.
  33096. */
  33097. getTotalIndices(): number;
  33098. /**
  33099. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33100. * @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.
  33101. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33102. * @returns the indices array or an empty array if the mesh has no geometry
  33103. */
  33104. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33105. get isBlocked(): boolean;
  33106. /**
  33107. * Determine if the current mesh is ready to be rendered
  33108. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33109. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33110. * @returns true if all associated assets are ready (material, textures, shaders)
  33111. */
  33112. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33113. /**
  33114. * 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.
  33115. */
  33116. get areNormalsFrozen(): boolean;
  33117. /**
  33118. * 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.
  33119. * @returns the current mesh
  33120. */
  33121. freezeNormals(): Mesh;
  33122. /**
  33123. * 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
  33124. * @returns the current mesh
  33125. */
  33126. unfreezeNormals(): Mesh;
  33127. /**
  33128. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33129. */
  33130. set overridenInstanceCount(count: number);
  33131. /** @hidden */
  33132. _preActivate(): Mesh;
  33133. /** @hidden */
  33134. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33135. /** @hidden */
  33136. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33137. protected _afterComputeWorldMatrix(): void;
  33138. /** @hidden */
  33139. _postActivate(): void;
  33140. /**
  33141. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33142. * This means the mesh underlying bounding box and sphere are recomputed.
  33143. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33144. * @returns the current mesh
  33145. */
  33146. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33147. /** @hidden */
  33148. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33149. /**
  33150. * This function will subdivide the mesh into multiple submeshes
  33151. * @param count defines the expected number of submeshes
  33152. */
  33153. subdivide(count: number): void;
  33154. /**
  33155. * Copy a FloatArray into a specific associated vertex buffer
  33156. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33157. * - VertexBuffer.PositionKind
  33158. * - VertexBuffer.UVKind
  33159. * - VertexBuffer.UV2Kind
  33160. * - VertexBuffer.UV3Kind
  33161. * - VertexBuffer.UV4Kind
  33162. * - VertexBuffer.UV5Kind
  33163. * - VertexBuffer.UV6Kind
  33164. * - VertexBuffer.ColorKind
  33165. * - VertexBuffer.MatricesIndicesKind
  33166. * - VertexBuffer.MatricesIndicesExtraKind
  33167. * - VertexBuffer.MatricesWeightsKind
  33168. * - VertexBuffer.MatricesWeightsExtraKind
  33169. * @param data defines the data source
  33170. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33171. * @param stride defines the data stride size (can be null)
  33172. * @returns the current mesh
  33173. */
  33174. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33175. /**
  33176. * Delete a vertex buffer associated with this mesh
  33177. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33178. * - VertexBuffer.PositionKind
  33179. * - VertexBuffer.UVKind
  33180. * - VertexBuffer.UV2Kind
  33181. * - VertexBuffer.UV3Kind
  33182. * - VertexBuffer.UV4Kind
  33183. * - VertexBuffer.UV5Kind
  33184. * - VertexBuffer.UV6Kind
  33185. * - VertexBuffer.ColorKind
  33186. * - VertexBuffer.MatricesIndicesKind
  33187. * - VertexBuffer.MatricesIndicesExtraKind
  33188. * - VertexBuffer.MatricesWeightsKind
  33189. * - VertexBuffer.MatricesWeightsExtraKind
  33190. */
  33191. removeVerticesData(kind: string): void;
  33192. /**
  33193. * Flags an associated vertex buffer as updatable
  33194. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33195. * - VertexBuffer.PositionKind
  33196. * - VertexBuffer.UVKind
  33197. * - VertexBuffer.UV2Kind
  33198. * - VertexBuffer.UV3Kind
  33199. * - VertexBuffer.UV4Kind
  33200. * - VertexBuffer.UV5Kind
  33201. * - VertexBuffer.UV6Kind
  33202. * - VertexBuffer.ColorKind
  33203. * - VertexBuffer.MatricesIndicesKind
  33204. * - VertexBuffer.MatricesIndicesExtraKind
  33205. * - VertexBuffer.MatricesWeightsKind
  33206. * - VertexBuffer.MatricesWeightsExtraKind
  33207. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33208. */
  33209. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33210. /**
  33211. * Sets the mesh global Vertex Buffer
  33212. * @param buffer defines the buffer to use
  33213. * @returns the current mesh
  33214. */
  33215. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33216. /**
  33217. * Update a specific associated vertex buffer
  33218. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33219. * - VertexBuffer.PositionKind
  33220. * - VertexBuffer.UVKind
  33221. * - VertexBuffer.UV2Kind
  33222. * - VertexBuffer.UV3Kind
  33223. * - VertexBuffer.UV4Kind
  33224. * - VertexBuffer.UV5Kind
  33225. * - VertexBuffer.UV6Kind
  33226. * - VertexBuffer.ColorKind
  33227. * - VertexBuffer.MatricesIndicesKind
  33228. * - VertexBuffer.MatricesIndicesExtraKind
  33229. * - VertexBuffer.MatricesWeightsKind
  33230. * - VertexBuffer.MatricesWeightsExtraKind
  33231. * @param data defines the data source
  33232. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33233. * @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)
  33234. * @returns the current mesh
  33235. */
  33236. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33237. /**
  33238. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33239. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33240. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33241. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33242. * @returns the current mesh
  33243. */
  33244. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33245. /**
  33246. * Creates a un-shared specific occurence of the geometry for the mesh.
  33247. * @returns the current mesh
  33248. */
  33249. makeGeometryUnique(): Mesh;
  33250. /**
  33251. * Set the index buffer of this mesh
  33252. * @param indices defines the source data
  33253. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33254. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33255. * @returns the current mesh
  33256. */
  33257. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33258. /**
  33259. * Update the current index buffer
  33260. * @param indices defines the source data
  33261. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33262. * @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)
  33263. * @returns the current mesh
  33264. */
  33265. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33266. /**
  33267. * Invert the geometry to move from a right handed system to a left handed one.
  33268. * @returns the current mesh
  33269. */
  33270. toLeftHanded(): Mesh;
  33271. /** @hidden */
  33272. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33273. /** @hidden */
  33274. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33275. /**
  33276. * Registers for this mesh a javascript function called just before the rendering process
  33277. * @param func defines the function to call before rendering this mesh
  33278. * @returns the current mesh
  33279. */
  33280. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33281. /**
  33282. * Disposes a previously registered javascript function called before the rendering
  33283. * @param func defines the function to remove
  33284. * @returns the current mesh
  33285. */
  33286. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33287. /**
  33288. * Registers for this mesh a javascript function called just after the rendering is complete
  33289. * @param func defines the function to call after rendering this mesh
  33290. * @returns the current mesh
  33291. */
  33292. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33293. /**
  33294. * Disposes a previously registered javascript function called after the rendering.
  33295. * @param func defines the function to remove
  33296. * @returns the current mesh
  33297. */
  33298. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33299. /** @hidden */
  33300. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33301. /** @hidden */
  33302. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33303. /** @hidden */
  33304. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33305. /** @hidden */
  33306. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33307. /** @hidden */
  33308. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33309. /** @hidden */
  33310. _rebuild(): void;
  33311. /** @hidden */
  33312. _freeze(): void;
  33313. /** @hidden */
  33314. _unFreeze(): void;
  33315. /**
  33316. * 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
  33317. * @param subMesh defines the subMesh to render
  33318. * @param enableAlphaMode defines if alpha mode can be changed
  33319. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33320. * @returns the current mesh
  33321. */
  33322. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33323. private _onBeforeDraw;
  33324. /**
  33325. * Renormalize the mesh and patch it up if there are no weights
  33326. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33327. * However in the case of zero weights then we set just a single influence to 1.
  33328. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33329. */
  33330. cleanMatrixWeights(): void;
  33331. private normalizeSkinFourWeights;
  33332. private normalizeSkinWeightsAndExtra;
  33333. /**
  33334. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33335. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33336. * the user know there was an issue with importing the mesh
  33337. * @returns a validation object with skinned, valid and report string
  33338. */
  33339. validateSkinning(): {
  33340. skinned: boolean;
  33341. valid: boolean;
  33342. report: string;
  33343. };
  33344. /** @hidden */
  33345. _checkDelayState(): Mesh;
  33346. private _queueLoad;
  33347. /**
  33348. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33349. * A mesh is in the frustum if its bounding box intersects the frustum
  33350. * @param frustumPlanes defines the frustum to test
  33351. * @returns true if the mesh is in the frustum planes
  33352. */
  33353. isInFrustum(frustumPlanes: Plane[]): boolean;
  33354. /**
  33355. * Sets the mesh material by the material or multiMaterial `id` property
  33356. * @param id is a string identifying the material or the multiMaterial
  33357. * @returns the current mesh
  33358. */
  33359. setMaterialByID(id: string): Mesh;
  33360. /**
  33361. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33362. * @returns an array of IAnimatable
  33363. */
  33364. getAnimatables(): IAnimatable[];
  33365. /**
  33366. * Modifies the mesh geometry according to the passed transformation matrix.
  33367. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33368. * The mesh normals are modified using the same transformation.
  33369. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33370. * @param transform defines the transform matrix to use
  33371. * @see https://doc.babylonjs.com/resources/baking_transformations
  33372. * @returns the current mesh
  33373. */
  33374. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33375. /**
  33376. * Modifies the mesh geometry according to its own current World Matrix.
  33377. * The mesh World Matrix is then reset.
  33378. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33379. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33380. * @see https://doc.babylonjs.com/resources/baking_transformations
  33381. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33382. * @returns the current mesh
  33383. */
  33384. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33385. /** @hidden */
  33386. get _positions(): Nullable<Vector3[]>;
  33387. /** @hidden */
  33388. _resetPointsArrayCache(): Mesh;
  33389. /** @hidden */
  33390. _generatePointsArray(): boolean;
  33391. /**
  33392. * Returns a new Mesh object generated from the current mesh properties.
  33393. * This method must not get confused with createInstance()
  33394. * @param name is a string, the name given to the new mesh
  33395. * @param newParent can be any Node object (default `null`)
  33396. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33397. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33398. * @returns a new mesh
  33399. */
  33400. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33401. /**
  33402. * Releases resources associated with this mesh.
  33403. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33404. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33405. */
  33406. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33407. /** @hidden */
  33408. _disposeInstanceSpecificData(): void;
  33409. /** @hidden */
  33410. _disposeThinInstanceSpecificData(): void;
  33411. /**
  33412. * Modifies the mesh geometry according to a displacement map.
  33413. * 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.
  33414. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33415. * @param url is a string, the URL from the image file is to be downloaded.
  33416. * @param minHeight is the lower limit of the displacement.
  33417. * @param maxHeight is the upper limit of the displacement.
  33418. * @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.
  33419. * @param uvOffset is an optional vector2 used to offset UV.
  33420. * @param uvScale is an optional vector2 used to scale UV.
  33421. * @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.
  33422. * @returns the Mesh.
  33423. */
  33424. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33425. /**
  33426. * Modifies the mesh geometry according to a displacementMap buffer.
  33427. * 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.
  33428. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33429. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33430. * @param heightMapWidth is the width of the buffer image.
  33431. * @param heightMapHeight is the height of the buffer image.
  33432. * @param minHeight is the lower limit of the displacement.
  33433. * @param maxHeight is the upper limit of the displacement.
  33434. * @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.
  33435. * @param uvOffset is an optional vector2 used to offset UV.
  33436. * @param uvScale is an optional vector2 used to scale UV.
  33437. * @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.
  33438. * @returns the Mesh.
  33439. */
  33440. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33441. /**
  33442. * Modify the mesh to get a flat shading rendering.
  33443. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33444. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33445. * @returns current mesh
  33446. */
  33447. convertToFlatShadedMesh(): Mesh;
  33448. /**
  33449. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33450. * In other words, more vertices, no more indices and a single bigger VBO.
  33451. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33452. * @returns current mesh
  33453. */
  33454. convertToUnIndexedMesh(): Mesh;
  33455. /**
  33456. * Inverses facet orientations.
  33457. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33458. * @param flipNormals will also inverts the normals
  33459. * @returns current mesh
  33460. */
  33461. flipFaces(flipNormals?: boolean): Mesh;
  33462. /**
  33463. * Increase the number of facets and hence vertices in a mesh
  33464. * Vertex normals are interpolated from existing vertex normals
  33465. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33466. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33467. */
  33468. increaseVertices(numberPerEdge: number): void;
  33469. /**
  33470. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33471. * This will undo any application of covertToFlatShadedMesh
  33472. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33473. */
  33474. forceSharedVertices(): void;
  33475. /** @hidden */
  33476. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33477. /** @hidden */
  33478. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33479. /**
  33480. * Creates a new InstancedMesh object from the mesh model.
  33481. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33482. * @param name defines the name of the new instance
  33483. * @returns a new InstancedMesh
  33484. */
  33485. createInstance(name: string): InstancedMesh;
  33486. /**
  33487. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33488. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33489. * @returns the current mesh
  33490. */
  33491. synchronizeInstances(): Mesh;
  33492. /**
  33493. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33494. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33495. * This should be used together with the simplification to avoid disappearing triangles.
  33496. * @param successCallback an optional success callback to be called after the optimization finished.
  33497. * @returns the current mesh
  33498. */
  33499. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33500. /**
  33501. * Serialize current mesh
  33502. * @param serializationObject defines the object which will receive the serialization data
  33503. */
  33504. serialize(serializationObject: any): void;
  33505. /** @hidden */
  33506. _syncGeometryWithMorphTargetManager(): void;
  33507. /** @hidden */
  33508. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33509. /**
  33510. * Returns a new Mesh object parsed from the source provided.
  33511. * @param parsedMesh is the source
  33512. * @param scene defines the hosting scene
  33513. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33514. * @returns a new Mesh
  33515. */
  33516. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33517. /**
  33518. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33519. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33520. * @param name defines the name of the mesh to create
  33521. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33522. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33523. * @param closePath creates a seam between the first and the last points of each path of the path array
  33524. * @param offset is taken in account only if the `pathArray` is containing a single path
  33525. * @param scene defines the hosting scene
  33526. * @param updatable defines if the mesh must be flagged as updatable
  33527. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33528. * @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)
  33529. * @returns a new Mesh
  33530. */
  33531. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33532. /**
  33533. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33534. * @param name defines the name of the mesh to create
  33535. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33536. * @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
  33537. * @param scene defines the hosting scene
  33538. * @param updatable defines if the mesh must be flagged as updatable
  33539. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33540. * @returns a new Mesh
  33541. */
  33542. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33543. /**
  33544. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33545. * @param name defines the name of the mesh to create
  33546. * @param size sets the size (float) of each box side (default 1)
  33547. * @param scene defines the hosting scene
  33548. * @param updatable defines if the mesh must be flagged as updatable
  33549. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33550. * @returns a new Mesh
  33551. */
  33552. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33553. /**
  33554. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33555. * @param name defines the name of the mesh to create
  33556. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33557. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33558. * @param scene defines the hosting scene
  33559. * @param updatable defines if the mesh must be flagged as updatable
  33560. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33561. * @returns a new Mesh
  33562. */
  33563. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33564. /**
  33565. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33566. * @param name defines the name of the mesh to create
  33567. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33568. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33569. * @param scene defines the hosting scene
  33570. * @returns a new Mesh
  33571. */
  33572. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33573. /**
  33574. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33575. * @param name defines the name of the mesh to create
  33576. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33577. * @param diameterTop set the top cap diameter (floats, default 1)
  33578. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33579. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33580. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33581. * @param scene defines the hosting scene
  33582. * @param updatable defines if the mesh must be flagged as updatable
  33583. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33584. * @returns a new Mesh
  33585. */
  33586. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33587. /**
  33588. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33589. * @param name defines the name of the mesh to create
  33590. * @param diameter sets the diameter size (float) of the torus (default 1)
  33591. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33592. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33593. * @param scene defines the hosting scene
  33594. * @param updatable defines if the mesh must be flagged as updatable
  33595. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33596. * @returns a new Mesh
  33597. */
  33598. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33599. /**
  33600. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33601. * @param name defines the name of the mesh to create
  33602. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33603. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33604. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33605. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33606. * @param p the number of windings on X axis (positive integers, default 2)
  33607. * @param q the number of windings on Y axis (positive integers, default 3)
  33608. * @param scene defines the hosting scene
  33609. * @param updatable defines if the mesh must be flagged as updatable
  33610. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33611. * @returns a new Mesh
  33612. */
  33613. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33614. /**
  33615. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33616. * @param name defines the name of the mesh to create
  33617. * @param points is an array successive Vector3
  33618. * @param scene defines the hosting scene
  33619. * @param updatable defines if the mesh must be flagged as updatable
  33620. * @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).
  33621. * @returns a new Mesh
  33622. */
  33623. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33624. /**
  33625. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33626. * @param name defines the name of the mesh to create
  33627. * @param points is an array successive Vector3
  33628. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33629. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33630. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33631. * @param scene defines the hosting scene
  33632. * @param updatable defines if the mesh must be flagged as updatable
  33633. * @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)
  33634. * @returns a new Mesh
  33635. */
  33636. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33637. /**
  33638. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33639. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33640. * 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.
  33641. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33642. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33643. * Remember you can only change the shape positions, not their number when updating a polygon.
  33644. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33645. * @param name defines the name of the mesh to create
  33646. * @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
  33647. * @param scene defines the hosting scene
  33648. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33649. * @param updatable defines if the mesh must be flagged as updatable
  33650. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33651. * @param earcutInjection can be used to inject your own earcut reference
  33652. * @returns a new Mesh
  33653. */
  33654. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33655. /**
  33656. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33657. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33658. * @param name defines the name of the mesh to create
  33659. * @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
  33660. * @param depth defines the height of extrusion
  33661. * @param scene defines the hosting scene
  33662. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33663. * @param updatable defines if the mesh must be flagged as updatable
  33664. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33665. * @param earcutInjection can be used to inject your own earcut reference
  33666. * @returns a new Mesh
  33667. */
  33668. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33669. /**
  33670. * Creates an extruded shape mesh.
  33671. * 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
  33672. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33673. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33674. * @param name defines the name of the mesh to create
  33675. * @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
  33676. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33677. * @param scale is the value to scale the shape
  33678. * @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
  33679. * @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
  33680. * @param scene defines the hosting scene
  33681. * @param updatable defines if the mesh must be flagged as updatable
  33682. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33683. * @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)
  33684. * @returns a new Mesh
  33685. */
  33686. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33687. /**
  33688. * Creates an custom extruded shape mesh.
  33689. * The custom extrusion is a parametric shape.
  33690. * It has no predefined shape. Its final shape will depend on the input parameters.
  33691. * Please consider using the same method from the MeshBuilder class instead
  33692. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33693. * @param name defines the name of the mesh to create
  33694. * @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
  33695. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33696. * @param scaleFunction is a custom Javascript function called on each path point
  33697. * @param rotationFunction is a custom Javascript function called on each path point
  33698. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33699. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33700. * @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
  33701. * @param scene defines the hosting scene
  33702. * @param updatable defines if the mesh must be flagged as updatable
  33703. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33704. * @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)
  33705. * @returns a new Mesh
  33706. */
  33707. 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;
  33708. /**
  33709. * Creates lathe mesh.
  33710. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33711. * Please consider using the same method from the MeshBuilder class instead
  33712. * @param name defines the name of the mesh to create
  33713. * @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
  33714. * @param radius is the radius value of the lathe
  33715. * @param tessellation is the side number of the lathe.
  33716. * @param scene defines the hosting scene
  33717. * @param updatable defines if the mesh must be flagged as updatable
  33718. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33719. * @returns a new Mesh
  33720. */
  33721. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33722. /**
  33723. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33724. * @param name defines the name of the mesh to create
  33725. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33726. * @param scene defines the hosting scene
  33727. * @param updatable defines if the mesh must be flagged as updatable
  33728. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33729. * @returns a new Mesh
  33730. */
  33731. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33732. /**
  33733. * Creates a ground mesh.
  33734. * Please consider using the same method from the MeshBuilder class instead
  33735. * @param name defines the name of the mesh to create
  33736. * @param width set the width of the ground
  33737. * @param height set the height of the ground
  33738. * @param subdivisions sets the number of subdivisions per side
  33739. * @param scene defines the hosting scene
  33740. * @param updatable defines if the mesh must be flagged as updatable
  33741. * @returns a new Mesh
  33742. */
  33743. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33744. /**
  33745. * Creates a tiled ground mesh.
  33746. * Please consider using the same method from the MeshBuilder class instead
  33747. * @param name defines the name of the mesh to create
  33748. * @param xmin set the ground minimum X coordinate
  33749. * @param zmin set the ground minimum Y coordinate
  33750. * @param xmax set the ground maximum X coordinate
  33751. * @param zmax set the ground maximum Z coordinate
  33752. * @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
  33753. * @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
  33754. * @param scene defines the hosting scene
  33755. * @param updatable defines if the mesh must be flagged as updatable
  33756. * @returns a new Mesh
  33757. */
  33758. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33759. w: number;
  33760. h: number;
  33761. }, precision: {
  33762. w: number;
  33763. h: number;
  33764. }, scene: Scene, updatable?: boolean): Mesh;
  33765. /**
  33766. * Creates a ground mesh from a height map.
  33767. * Please consider using the same method from the MeshBuilder class instead
  33768. * @see https://doc.babylonjs.com/babylon101/height_map
  33769. * @param name defines the name of the mesh to create
  33770. * @param url sets the URL of the height map image resource
  33771. * @param width set the ground width size
  33772. * @param height set the ground height size
  33773. * @param subdivisions sets the number of subdivision per side
  33774. * @param minHeight is the minimum altitude on the ground
  33775. * @param maxHeight is the maximum altitude on the ground
  33776. * @param scene defines the hosting scene
  33777. * @param updatable defines if the mesh must be flagged as updatable
  33778. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33779. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33780. * @returns a new Mesh
  33781. */
  33782. 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;
  33783. /**
  33784. * Creates a tube mesh.
  33785. * The tube is a parametric shape.
  33786. * It has no predefined shape. Its final shape will depend on the input parameters.
  33787. * Please consider using the same method from the MeshBuilder class instead
  33788. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33789. * @param name defines the name of the mesh to create
  33790. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33791. * @param radius sets the tube radius size
  33792. * @param tessellation is the number of sides on the tubular surface
  33793. * @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
  33794. * @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
  33795. * @param scene defines the hosting scene
  33796. * @param updatable defines if the mesh must be flagged as updatable
  33797. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33798. * @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)
  33799. * @returns a new Mesh
  33800. */
  33801. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33802. (i: number, distance: number): number;
  33803. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33804. /**
  33805. * Creates a polyhedron mesh.
  33806. * Please consider using the same method from the MeshBuilder class instead.
  33807. * * 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
  33808. * * The parameter `size` (positive float, default 1) sets the polygon size
  33809. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33810. * * 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`
  33811. * * 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
  33812. * * 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)`)
  33813. * * 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
  33814. * * 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
  33815. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33816. * * 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
  33817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33818. * @param name defines the name of the mesh to create
  33819. * @param options defines the options used to create the mesh
  33820. * @param scene defines the hosting scene
  33821. * @returns a new Mesh
  33822. */
  33823. static CreatePolyhedron(name: string, options: {
  33824. type?: number;
  33825. size?: number;
  33826. sizeX?: number;
  33827. sizeY?: number;
  33828. sizeZ?: number;
  33829. custom?: any;
  33830. faceUV?: Vector4[];
  33831. faceColors?: Color4[];
  33832. updatable?: boolean;
  33833. sideOrientation?: number;
  33834. }, scene: Scene): Mesh;
  33835. /**
  33836. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33837. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33838. * * 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`)
  33839. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33840. * * 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
  33841. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33842. * * 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
  33843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33844. * @param name defines the name of the mesh
  33845. * @param options defines the options used to create the mesh
  33846. * @param scene defines the hosting scene
  33847. * @returns a new Mesh
  33848. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33849. */
  33850. static CreateIcoSphere(name: string, options: {
  33851. radius?: number;
  33852. flat?: boolean;
  33853. subdivisions?: number;
  33854. sideOrientation?: number;
  33855. updatable?: boolean;
  33856. }, scene: Scene): Mesh;
  33857. /**
  33858. * Creates a decal mesh.
  33859. * Please consider using the same method from the MeshBuilder class instead.
  33860. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33861. * @param name defines the name of the mesh
  33862. * @param sourceMesh defines the mesh receiving the decal
  33863. * @param position sets the position of the decal in world coordinates
  33864. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33865. * @param size sets the decal scaling
  33866. * @param angle sets the angle to rotate the decal
  33867. * @returns a new Mesh
  33868. */
  33869. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33870. /** Creates a Capsule Mesh
  33871. * @param name defines the name of the mesh.
  33872. * @param options the constructors options used to shape the mesh.
  33873. * @param scene defines the scene the mesh is scoped to.
  33874. * @returns the capsule mesh
  33875. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33876. */
  33877. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33878. /**
  33879. * Prepare internal position array for software CPU skinning
  33880. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33881. */
  33882. setPositionsForCPUSkinning(): Float32Array;
  33883. /**
  33884. * Prepare internal normal array for software CPU skinning
  33885. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33886. */
  33887. setNormalsForCPUSkinning(): Float32Array;
  33888. /**
  33889. * Updates the vertex buffer by applying transformation from the bones
  33890. * @param skeleton defines the skeleton to apply to current mesh
  33891. * @returns the current mesh
  33892. */
  33893. applySkeleton(skeleton: Skeleton): Mesh;
  33894. /**
  33895. * 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
  33896. * @param meshes defines the list of meshes to scan
  33897. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33898. */
  33899. static MinMax(meshes: AbstractMesh[]): {
  33900. min: Vector3;
  33901. max: Vector3;
  33902. };
  33903. /**
  33904. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33905. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33906. * @returns a vector3
  33907. */
  33908. static Center(meshesOrMinMaxVector: {
  33909. min: Vector3;
  33910. max: Vector3;
  33911. } | AbstractMesh[]): Vector3;
  33912. /**
  33913. * Merge the array of meshes into a single mesh for performance reasons.
  33914. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33915. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33916. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33917. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33918. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33919. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33920. * @returns a new mesh
  33921. */
  33922. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33923. /** @hidden */
  33924. addInstance(instance: InstancedMesh): void;
  33925. /** @hidden */
  33926. removeInstance(instance: InstancedMesh): void;
  33927. }
  33928. }
  33929. declare module BABYLON {
  33930. /**
  33931. * This is the base class of all the camera used in the application.
  33932. * @see https://doc.babylonjs.com/features/cameras
  33933. */
  33934. export class Camera extends Node {
  33935. /** @hidden */
  33936. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  33937. /**
  33938. * This is the default projection mode used by the cameras.
  33939. * It helps recreating a feeling of perspective and better appreciate depth.
  33940. * This is the best way to simulate real life cameras.
  33941. */
  33942. static readonly PERSPECTIVE_CAMERA: number;
  33943. /**
  33944. * This helps creating camera with an orthographic mode.
  33945. * 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.
  33946. */
  33947. static readonly ORTHOGRAPHIC_CAMERA: number;
  33948. /**
  33949. * This is the default FOV mode for perspective cameras.
  33950. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  33951. */
  33952. static readonly FOVMODE_VERTICAL_FIXED: number;
  33953. /**
  33954. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  33955. */
  33956. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  33957. /**
  33958. * This specifies ther is no need for a camera rig.
  33959. * Basically only one eye is rendered corresponding to the camera.
  33960. */
  33961. static readonly RIG_MODE_NONE: number;
  33962. /**
  33963. * Simulates a camera Rig with one blue eye and one red eye.
  33964. * This can be use with 3d blue and red glasses.
  33965. */
  33966. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  33967. /**
  33968. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  33969. */
  33970. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  33971. /**
  33972. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  33973. */
  33974. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  33975. /**
  33976. * Defines that both eyes of the camera will be rendered over under each other.
  33977. */
  33978. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  33979. /**
  33980. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  33981. */
  33982. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  33983. /**
  33984. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  33985. */
  33986. static readonly RIG_MODE_VR: number;
  33987. /**
  33988. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  33989. */
  33990. static readonly RIG_MODE_WEBVR: number;
  33991. /**
  33992. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  33993. */
  33994. static readonly RIG_MODE_CUSTOM: number;
  33995. /**
  33996. * Defines if by default attaching controls should prevent the default javascript event to continue.
  33997. */
  33998. static ForceAttachControlToAlwaysPreventDefault: boolean;
  33999. /**
  34000. * Define the input manager associated with the camera.
  34001. */
  34002. inputs: CameraInputsManager<Camera>;
  34003. /** @hidden */
  34004. _position: Vector3;
  34005. /**
  34006. * Define the current local position of the camera in the scene
  34007. */
  34008. get position(): Vector3;
  34009. set position(newPosition: Vector3);
  34010. protected _upVector: Vector3;
  34011. /**
  34012. * The vector the camera should consider as up.
  34013. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  34014. */
  34015. set upVector(vec: Vector3);
  34016. get upVector(): Vector3;
  34017. /**
  34018. * Define the current limit on the left side for an orthographic camera
  34019. * In scene unit
  34020. */
  34021. orthoLeft: Nullable<number>;
  34022. /**
  34023. * Define the current limit on the right side for an orthographic camera
  34024. * In scene unit
  34025. */
  34026. orthoRight: Nullable<number>;
  34027. /**
  34028. * Define the current limit on the bottom side for an orthographic camera
  34029. * In scene unit
  34030. */
  34031. orthoBottom: Nullable<number>;
  34032. /**
  34033. * Define the current limit on the top side for an orthographic camera
  34034. * In scene unit
  34035. */
  34036. orthoTop: Nullable<number>;
  34037. /**
  34038. * Field Of View is set in Radians. (default is 0.8)
  34039. */
  34040. fov: number;
  34041. /**
  34042. * Define the minimum distance the camera can see from.
  34043. * This is important to note that the depth buffer are not infinite and the closer it starts
  34044. * the more your scene might encounter depth fighting issue.
  34045. */
  34046. minZ: number;
  34047. /**
  34048. * Define the maximum distance the camera can see to.
  34049. * This is important to note that the depth buffer are not infinite and the further it end
  34050. * the more your scene might encounter depth fighting issue.
  34051. */
  34052. maxZ: number;
  34053. /**
  34054. * Define the default inertia of the camera.
  34055. * This helps giving a smooth feeling to the camera movement.
  34056. */
  34057. inertia: number;
  34058. /**
  34059. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  34060. */
  34061. mode: number;
  34062. /**
  34063. * Define whether the camera is intermediate.
  34064. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  34065. */
  34066. isIntermediate: boolean;
  34067. /**
  34068. * Define the viewport of the camera.
  34069. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  34070. */
  34071. viewport: Viewport;
  34072. /**
  34073. * Restricts the camera to viewing objects with the same layerMask.
  34074. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  34075. */
  34076. layerMask: number;
  34077. /**
  34078. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  34079. */
  34080. fovMode: number;
  34081. /**
  34082. * Rig mode of the camera.
  34083. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  34084. * This is normally controlled byt the camera themselves as internal use.
  34085. */
  34086. cameraRigMode: number;
  34087. /**
  34088. * Defines the distance between both "eyes" in case of a RIG
  34089. */
  34090. interaxialDistance: number;
  34091. /**
  34092. * Defines if stereoscopic rendering is done side by side or over under.
  34093. */
  34094. isStereoscopicSideBySide: boolean;
  34095. /**
  34096. * 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
  34097. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  34098. * else in the scene. (Eg. security camera)
  34099. *
  34100. * 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)
  34101. */
  34102. customRenderTargets: RenderTargetTexture[];
  34103. /**
  34104. * When set, the camera will render to this render target instead of the default canvas
  34105. *
  34106. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  34107. */
  34108. outputRenderTarget: Nullable<RenderTargetTexture>;
  34109. /**
  34110. * Observable triggered when the camera view matrix has changed.
  34111. */
  34112. onViewMatrixChangedObservable: Observable<Camera>;
  34113. /**
  34114. * Observable triggered when the camera Projection matrix has changed.
  34115. */
  34116. onProjectionMatrixChangedObservable: Observable<Camera>;
  34117. /**
  34118. * Observable triggered when the inputs have been processed.
  34119. */
  34120. onAfterCheckInputsObservable: Observable<Camera>;
  34121. /**
  34122. * Observable triggered when reset has been called and applied to the camera.
  34123. */
  34124. onRestoreStateObservable: Observable<Camera>;
  34125. /**
  34126. * Is this camera a part of a rig system?
  34127. */
  34128. isRigCamera: boolean;
  34129. /**
  34130. * If isRigCamera set to true this will be set with the parent camera.
  34131. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  34132. */
  34133. rigParent?: Camera;
  34134. /** @hidden */
  34135. _cameraRigParams: any;
  34136. /** @hidden */
  34137. _rigCameras: Camera[];
  34138. /** @hidden */
  34139. _rigPostProcess: Nullable<PostProcess>;
  34140. protected _webvrViewMatrix: Matrix;
  34141. /** @hidden */
  34142. _skipRendering: boolean;
  34143. /** @hidden */
  34144. _projectionMatrix: Matrix;
  34145. /** @hidden */
  34146. _postProcesses: Nullable<PostProcess>[];
  34147. /** @hidden */
  34148. _activeMeshes: SmartArray<AbstractMesh>;
  34149. protected _globalPosition: Vector3;
  34150. /** @hidden */
  34151. _computedViewMatrix: Matrix;
  34152. private _doNotComputeProjectionMatrix;
  34153. private _transformMatrix;
  34154. private _frustumPlanes;
  34155. private _refreshFrustumPlanes;
  34156. private _storedFov;
  34157. private _stateStored;
  34158. /**
  34159. * Instantiates a new camera object.
  34160. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  34161. * @see https://doc.babylonjs.com/features/cameras
  34162. * @param name Defines the name of the camera in the scene
  34163. * @param position Defines the position of the camera
  34164. * @param scene Defines the scene the camera belongs too
  34165. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  34166. */
  34167. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34168. /**
  34169. * Store current camera state (fov, position, etc..)
  34170. * @returns the camera
  34171. */
  34172. storeState(): Camera;
  34173. /**
  34174. * Restores the camera state values if it has been stored. You must call storeState() first
  34175. */
  34176. protected _restoreStateValues(): boolean;
  34177. /**
  34178. * Restored camera state. You must call storeState() first.
  34179. * @returns true if restored and false otherwise
  34180. */
  34181. restoreState(): boolean;
  34182. /**
  34183. * Gets the class name of the camera.
  34184. * @returns the class name
  34185. */
  34186. getClassName(): string;
  34187. /** @hidden */
  34188. readonly _isCamera: boolean;
  34189. /**
  34190. * Gets a string representation of the camera useful for debug purpose.
  34191. * @param fullDetails Defines that a more verboe level of logging is required
  34192. * @returns the string representation
  34193. */
  34194. toString(fullDetails?: boolean): string;
  34195. /**
  34196. * Gets the current world space position of the camera.
  34197. */
  34198. get globalPosition(): Vector3;
  34199. /**
  34200. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  34201. * @returns the active meshe list
  34202. */
  34203. getActiveMeshes(): SmartArray<AbstractMesh>;
  34204. /**
  34205. * Check whether a mesh is part of the current active mesh list of the camera
  34206. * @param mesh Defines the mesh to check
  34207. * @returns true if active, false otherwise
  34208. */
  34209. isActiveMesh(mesh: Mesh): boolean;
  34210. /**
  34211. * Is this camera ready to be used/rendered
  34212. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  34213. * @return true if the camera is ready
  34214. */
  34215. isReady(completeCheck?: boolean): boolean;
  34216. /** @hidden */
  34217. _initCache(): void;
  34218. /** @hidden */
  34219. _updateCache(ignoreParentClass?: boolean): void;
  34220. /** @hidden */
  34221. _isSynchronized(): boolean;
  34222. /** @hidden */
  34223. _isSynchronizedViewMatrix(): boolean;
  34224. /** @hidden */
  34225. _isSynchronizedProjectionMatrix(): boolean;
  34226. /**
  34227. * Attach the input controls to a specific dom element to get the input from.
  34228. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34229. */
  34230. attachControl(noPreventDefault?: boolean): void;
  34231. /**
  34232. * Detach the current controls from the specified dom element.
  34233. */
  34234. detachControl(): void;
  34235. /**
  34236. * Update the camera state according to the different inputs gathered during the frame.
  34237. */
  34238. update(): void;
  34239. /** @hidden */
  34240. _checkInputs(): void;
  34241. /** @hidden */
  34242. get rigCameras(): Camera[];
  34243. /**
  34244. * Gets the post process used by the rig cameras
  34245. */
  34246. get rigPostProcess(): Nullable<PostProcess>;
  34247. /**
  34248. * Internal, gets the first post proces.
  34249. * @returns the first post process to be run on this camera.
  34250. */
  34251. _getFirstPostProcess(): Nullable<PostProcess>;
  34252. private _cascadePostProcessesToRigCams;
  34253. /**
  34254. * Attach a post process to the camera.
  34255. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  34256. * @param postProcess The post process to attach to the camera
  34257. * @param insertAt The position of the post process in case several of them are in use in the scene
  34258. * @returns the position the post process has been inserted at
  34259. */
  34260. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  34261. /**
  34262. * Detach a post process to the camera.
  34263. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  34264. * @param postProcess The post process to detach from the camera
  34265. */
  34266. detachPostProcess(postProcess: PostProcess): void;
  34267. /**
  34268. * Gets the current world matrix of the camera
  34269. */
  34270. getWorldMatrix(): Matrix;
  34271. /** @hidden */
  34272. _getViewMatrix(): Matrix;
  34273. /**
  34274. * Gets the current view matrix of the camera.
  34275. * @param force forces the camera to recompute the matrix without looking at the cached state
  34276. * @returns the view matrix
  34277. */
  34278. getViewMatrix(force?: boolean): Matrix;
  34279. /**
  34280. * Freeze the projection matrix.
  34281. * It will prevent the cache check of the camera projection compute and can speed up perf
  34282. * if no parameter of the camera are meant to change
  34283. * @param projection Defines manually a projection if necessary
  34284. */
  34285. freezeProjectionMatrix(projection?: Matrix): void;
  34286. /**
  34287. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  34288. */
  34289. unfreezeProjectionMatrix(): void;
  34290. /**
  34291. * Gets the current projection matrix of the camera.
  34292. * @param force forces the camera to recompute the matrix without looking at the cached state
  34293. * @returns the projection matrix
  34294. */
  34295. getProjectionMatrix(force?: boolean): Matrix;
  34296. /**
  34297. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  34298. * @returns a Matrix
  34299. */
  34300. getTransformationMatrix(): Matrix;
  34301. private _updateFrustumPlanes;
  34302. /**
  34303. * Checks if a cullable object (mesh...) is in the camera frustum
  34304. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  34305. * @param target The object to check
  34306. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  34307. * @returns true if the object is in frustum otherwise false
  34308. */
  34309. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  34310. /**
  34311. * Checks if a cullable object (mesh...) is in the camera frustum
  34312. * Unlike isInFrustum this cheks the full bounding box
  34313. * @param target The object to check
  34314. * @returns true if the object is in frustum otherwise false
  34315. */
  34316. isCompletelyInFrustum(target: ICullable): boolean;
  34317. /**
  34318. * Gets a ray in the forward direction from the camera.
  34319. * @param length Defines the length of the ray to create
  34320. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34321. * @param origin Defines the start point of the ray which defaults to the camera position
  34322. * @returns the forward ray
  34323. */
  34324. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34325. /**
  34326. * Gets a ray in the forward direction from the camera.
  34327. * @param refRay the ray to (re)use when setting the values
  34328. * @param length Defines the length of the ray to create
  34329. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34330. * @param origin Defines the start point of the ray which defaults to the camera position
  34331. * @returns the forward ray
  34332. */
  34333. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34334. /**
  34335. * Releases resources associated with this node.
  34336. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34337. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34338. */
  34339. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34340. /** @hidden */
  34341. _isLeftCamera: boolean;
  34342. /**
  34343. * Gets the left camera of a rig setup in case of Rigged Camera
  34344. */
  34345. get isLeftCamera(): boolean;
  34346. /** @hidden */
  34347. _isRightCamera: boolean;
  34348. /**
  34349. * Gets the right camera of a rig setup in case of Rigged Camera
  34350. */
  34351. get isRightCamera(): boolean;
  34352. /**
  34353. * Gets the left camera of a rig setup in case of Rigged Camera
  34354. */
  34355. get leftCamera(): Nullable<FreeCamera>;
  34356. /**
  34357. * Gets the right camera of a rig setup in case of Rigged Camera
  34358. */
  34359. get rightCamera(): Nullable<FreeCamera>;
  34360. /**
  34361. * Gets the left camera target of a rig setup in case of Rigged Camera
  34362. * @returns the target position
  34363. */
  34364. getLeftTarget(): Nullable<Vector3>;
  34365. /**
  34366. * Gets the right camera target of a rig setup in case of Rigged Camera
  34367. * @returns the target position
  34368. */
  34369. getRightTarget(): Nullable<Vector3>;
  34370. /**
  34371. * @hidden
  34372. */
  34373. setCameraRigMode(mode: number, rigParams: any): void;
  34374. /** @hidden */
  34375. static _setStereoscopicRigMode(camera: Camera): void;
  34376. /** @hidden */
  34377. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  34378. /** @hidden */
  34379. static _setVRRigMode(camera: Camera, rigParams: any): void;
  34380. /** @hidden */
  34381. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  34382. /** @hidden */
  34383. _getVRProjectionMatrix(): Matrix;
  34384. protected _updateCameraRotationMatrix(): void;
  34385. protected _updateWebVRCameraRotationMatrix(): void;
  34386. /**
  34387. * This function MUST be overwritten by the different WebVR cameras available.
  34388. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34389. * @hidden
  34390. */
  34391. _getWebVRProjectionMatrix(): Matrix;
  34392. /**
  34393. * This function MUST be overwritten by the different WebVR cameras available.
  34394. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34395. * @hidden
  34396. */
  34397. _getWebVRViewMatrix(): Matrix;
  34398. /** @hidden */
  34399. setCameraRigParameter(name: string, value: any): void;
  34400. /**
  34401. * needs to be overridden by children so sub has required properties to be copied
  34402. * @hidden
  34403. */
  34404. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  34405. /**
  34406. * May need to be overridden by children
  34407. * @hidden
  34408. */
  34409. _updateRigCameras(): void;
  34410. /** @hidden */
  34411. _setupInputs(): void;
  34412. /**
  34413. * Serialiaze the camera setup to a json represention
  34414. * @returns the JSON representation
  34415. */
  34416. serialize(): any;
  34417. /**
  34418. * Clones the current camera.
  34419. * @param name The cloned camera name
  34420. * @returns the cloned camera
  34421. */
  34422. clone(name: string): Camera;
  34423. /**
  34424. * Gets the direction of the camera relative to a given local axis.
  34425. * @param localAxis Defines the reference axis to provide a relative direction.
  34426. * @return the direction
  34427. */
  34428. getDirection(localAxis: Vector3): Vector3;
  34429. /**
  34430. * Returns the current camera absolute rotation
  34431. */
  34432. get absoluteRotation(): Quaternion;
  34433. /**
  34434. * Gets the direction of the camera relative to a given local axis into a passed vector.
  34435. * @param localAxis Defines the reference axis to provide a relative direction.
  34436. * @param result Defines the vector to store the result in
  34437. */
  34438. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  34439. /**
  34440. * Gets a camera constructor for a given camera type
  34441. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  34442. * @param name The name of the camera the result will be able to instantiate
  34443. * @param scene The scene the result will construct the camera in
  34444. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  34445. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  34446. * @returns a factory method to construc the camera
  34447. */
  34448. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  34449. /**
  34450. * Compute the world matrix of the camera.
  34451. * @returns the camera world matrix
  34452. */
  34453. computeWorldMatrix(): Matrix;
  34454. /**
  34455. * Parse a JSON and creates the camera from the parsed information
  34456. * @param parsedCamera The JSON to parse
  34457. * @param scene The scene to instantiate the camera in
  34458. * @returns the newly constructed camera
  34459. */
  34460. static Parse(parsedCamera: any, scene: Scene): Camera;
  34461. }
  34462. }
  34463. declare module BABYLON {
  34464. /**
  34465. * Class containing static functions to help procedurally build meshes
  34466. */
  34467. export class DiscBuilder {
  34468. /**
  34469. * Creates a plane polygonal mesh. By default, this is a disc
  34470. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34471. * * 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
  34472. * * 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
  34473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34474. * * 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
  34475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34476. * @param name defines the name of the mesh
  34477. * @param options defines the options used to create the mesh
  34478. * @param scene defines the hosting scene
  34479. * @returns the plane polygonal mesh
  34480. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34481. */
  34482. static CreateDisc(name: string, options: {
  34483. radius?: number;
  34484. tessellation?: number;
  34485. arc?: number;
  34486. updatable?: boolean;
  34487. sideOrientation?: number;
  34488. frontUVs?: Vector4;
  34489. backUVs?: Vector4;
  34490. }, scene?: Nullable<Scene>): Mesh;
  34491. }
  34492. }
  34493. declare module BABYLON {
  34494. /**
  34495. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34496. *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.
  34497. * The SPS is also a particle system. It provides some methods to manage the particles.
  34498. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34499. *
  34500. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34501. */
  34502. export class SolidParticleSystem implements IDisposable {
  34503. /**
  34504. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34505. * Example : var p = SPS.particles[i];
  34506. */
  34507. particles: SolidParticle[];
  34508. /**
  34509. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34510. */
  34511. nbParticles: number;
  34512. /**
  34513. * If the particles must ever face the camera (default false). Useful for planar particles.
  34514. */
  34515. billboard: boolean;
  34516. /**
  34517. * Recompute normals when adding a shape
  34518. */
  34519. recomputeNormals: boolean;
  34520. /**
  34521. * This a counter ofr your own usage. It's not set by any SPS functions.
  34522. */
  34523. counter: number;
  34524. /**
  34525. * The SPS name. This name is also given to the underlying mesh.
  34526. */
  34527. name: string;
  34528. /**
  34529. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34530. */
  34531. mesh: Mesh;
  34532. /**
  34533. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34534. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34535. */
  34536. vars: any;
  34537. /**
  34538. * This array is populated when the SPS is set as 'pickable'.
  34539. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34540. * Each element of this array is an object `{idx: int, faceId: int}`.
  34541. * `idx` is the picked particle index in the `SPS.particles` array
  34542. * `faceId` is the picked face index counted within this particle.
  34543. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34544. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34545. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34546. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34547. */
  34548. pickedParticles: {
  34549. idx: number;
  34550. faceId: number;
  34551. }[];
  34552. /**
  34553. * This array is populated when the SPS is set as 'pickable'
  34554. * Each key of this array is a submesh index.
  34555. * Each element of this array is a second array defined like this :
  34556. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34557. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34558. * `idx` is the picked particle index in the `SPS.particles` array
  34559. * `faceId` is the picked face index counted within this particle.
  34560. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34561. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34562. */
  34563. pickedBySubMesh: {
  34564. idx: number;
  34565. faceId: number;
  34566. }[][];
  34567. /**
  34568. * This array is populated when `enableDepthSort` is set to true.
  34569. * Each element of this array is an instance of the class DepthSortedParticle.
  34570. */
  34571. depthSortedParticles: DepthSortedParticle[];
  34572. /**
  34573. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34574. * @hidden
  34575. */
  34576. _bSphereOnly: boolean;
  34577. /**
  34578. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34579. * @hidden
  34580. */
  34581. _bSphereRadiusFactor: number;
  34582. private _scene;
  34583. private _positions;
  34584. private _indices;
  34585. private _normals;
  34586. private _colors;
  34587. private _uvs;
  34588. private _indices32;
  34589. private _positions32;
  34590. private _normals32;
  34591. private _fixedNormal32;
  34592. private _colors32;
  34593. private _uvs32;
  34594. private _index;
  34595. private _updatable;
  34596. private _pickable;
  34597. private _isVisibilityBoxLocked;
  34598. private _alwaysVisible;
  34599. private _depthSort;
  34600. private _expandable;
  34601. private _shapeCounter;
  34602. private _copy;
  34603. private _color;
  34604. private _computeParticleColor;
  34605. private _computeParticleTexture;
  34606. private _computeParticleRotation;
  34607. private _computeParticleVertex;
  34608. private _computeBoundingBox;
  34609. private _depthSortParticles;
  34610. private _camera;
  34611. private _mustUnrotateFixedNormals;
  34612. private _particlesIntersect;
  34613. private _needs32Bits;
  34614. private _isNotBuilt;
  34615. private _lastParticleId;
  34616. private _idxOfId;
  34617. private _multimaterialEnabled;
  34618. private _useModelMaterial;
  34619. private _indicesByMaterial;
  34620. private _materialIndexes;
  34621. private _depthSortFunction;
  34622. private _materialSortFunction;
  34623. private _materials;
  34624. private _multimaterial;
  34625. private _materialIndexesById;
  34626. private _defaultMaterial;
  34627. private _autoUpdateSubMeshes;
  34628. private _tmpVertex;
  34629. /**
  34630. * Creates a SPS (Solid Particle System) object.
  34631. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34632. * @param scene (Scene) is the scene in which the SPS is added.
  34633. * @param options defines the options of the sps e.g.
  34634. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34635. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34636. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34637. * * 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.
  34638. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34639. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34640. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34641. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34642. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34643. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34644. */
  34645. constructor(name: string, scene: Scene, options?: {
  34646. updatable?: boolean;
  34647. isPickable?: boolean;
  34648. enableDepthSort?: boolean;
  34649. particleIntersection?: boolean;
  34650. boundingSphereOnly?: boolean;
  34651. bSphereRadiusFactor?: number;
  34652. expandable?: boolean;
  34653. useModelMaterial?: boolean;
  34654. enableMultiMaterial?: boolean;
  34655. });
  34656. /**
  34657. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34658. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34659. * @returns the created mesh
  34660. */
  34661. buildMesh(): Mesh;
  34662. /**
  34663. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34664. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34665. * Thus the particles generated from `digest()` have their property `position` set yet.
  34666. * @param mesh ( Mesh ) is the mesh to be digested
  34667. * @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
  34668. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34669. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34670. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34671. * @returns the current SPS
  34672. */
  34673. digest(mesh: Mesh, options?: {
  34674. facetNb?: number;
  34675. number?: number;
  34676. delta?: number;
  34677. storage?: [];
  34678. }): SolidParticleSystem;
  34679. /**
  34680. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34681. * @hidden
  34682. */
  34683. private _unrotateFixedNormals;
  34684. /**
  34685. * Resets the temporary working copy particle
  34686. * @hidden
  34687. */
  34688. private _resetCopy;
  34689. /**
  34690. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34691. * @param p the current index in the positions array to be updated
  34692. * @param ind the current index in the indices array
  34693. * @param shape a Vector3 array, the shape geometry
  34694. * @param positions the positions array to be updated
  34695. * @param meshInd the shape indices array
  34696. * @param indices the indices array to be updated
  34697. * @param meshUV the shape uv array
  34698. * @param uvs the uv array to be updated
  34699. * @param meshCol the shape color array
  34700. * @param colors the color array to be updated
  34701. * @param meshNor the shape normals array
  34702. * @param normals the normals array to be updated
  34703. * @param idx the particle index
  34704. * @param idxInShape the particle index in its shape
  34705. * @param options the addShape() method passed options
  34706. * @model the particle model
  34707. * @hidden
  34708. */
  34709. private _meshBuilder;
  34710. /**
  34711. * Returns a shape Vector3 array from positions float array
  34712. * @param positions float array
  34713. * @returns a vector3 array
  34714. * @hidden
  34715. */
  34716. private _posToShape;
  34717. /**
  34718. * Returns a shapeUV array from a float uvs (array deep copy)
  34719. * @param uvs as a float array
  34720. * @returns a shapeUV array
  34721. * @hidden
  34722. */
  34723. private _uvsToShapeUV;
  34724. /**
  34725. * Adds a new particle object in the particles array
  34726. * @param idx particle index in particles array
  34727. * @param id particle id
  34728. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34729. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34730. * @param model particle ModelShape object
  34731. * @param shapeId model shape identifier
  34732. * @param idxInShape index of the particle in the current model
  34733. * @param bInfo model bounding info object
  34734. * @param storage target storage array, if any
  34735. * @hidden
  34736. */
  34737. private _addParticle;
  34738. /**
  34739. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34740. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34741. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34742. * @param nb (positive integer) the number of particles to be created from this model
  34743. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34744. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34745. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34746. * @returns the number of shapes in the system
  34747. */
  34748. addShape(mesh: Mesh, nb: number, options?: {
  34749. positionFunction?: any;
  34750. vertexFunction?: any;
  34751. storage?: [];
  34752. }): number;
  34753. /**
  34754. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34755. * @hidden
  34756. */
  34757. private _rebuildParticle;
  34758. /**
  34759. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34760. * @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.
  34761. * @returns the SPS.
  34762. */
  34763. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34764. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34765. * Returns an array with the removed particles.
  34766. * 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.
  34767. * The SPS can't be empty so at least one particle needs to remain in place.
  34768. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34769. * @param start index of the first particle to remove
  34770. * @param end index of the last particle to remove (included)
  34771. * @returns an array populated with the removed particles
  34772. */
  34773. removeParticles(start: number, end: number): SolidParticle[];
  34774. /**
  34775. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34776. * @param solidParticleArray an array populated with Solid Particles objects
  34777. * @returns the SPS
  34778. */
  34779. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34780. /**
  34781. * Creates a new particle and modifies the SPS mesh geometry :
  34782. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34783. * - calls _addParticle() to populate the particle array
  34784. * factorized code from addShape() and insertParticlesFromArray()
  34785. * @param idx particle index in the particles array
  34786. * @param i particle index in its shape
  34787. * @param modelShape particle ModelShape object
  34788. * @param shape shape vertex array
  34789. * @param meshInd shape indices array
  34790. * @param meshUV shape uv array
  34791. * @param meshCol shape color array
  34792. * @param meshNor shape normals array
  34793. * @param bbInfo shape bounding info
  34794. * @param storage target particle storage
  34795. * @options addShape() passed options
  34796. * @hidden
  34797. */
  34798. private _insertNewParticle;
  34799. /**
  34800. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34801. * This method calls `updateParticle()` for each particle of the SPS.
  34802. * For an animated SPS, it is usually called within the render loop.
  34803. * 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.
  34804. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34805. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34806. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34807. * @returns the SPS.
  34808. */
  34809. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34810. /**
  34811. * Disposes the SPS.
  34812. */
  34813. dispose(): void;
  34814. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34815. * idx is the particle index in the SPS
  34816. * faceId is the picked face index counted within this particle.
  34817. * Returns null if the pickInfo can't identify a picked particle.
  34818. * @param pickingInfo (PickingInfo object)
  34819. * @returns {idx: number, faceId: number} or null
  34820. */
  34821. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34822. idx: number;
  34823. faceId: number;
  34824. }>;
  34825. /**
  34826. * Returns a SolidParticle object from its identifier : particle.id
  34827. * @param id (integer) the particle Id
  34828. * @returns the searched particle or null if not found in the SPS.
  34829. */
  34830. getParticleById(id: number): Nullable<SolidParticle>;
  34831. /**
  34832. * Returns a new array populated with the particles having the passed shapeId.
  34833. * @param shapeId (integer) the shape identifier
  34834. * @returns a new solid particle array
  34835. */
  34836. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34837. /**
  34838. * Populates the passed array "ref" with the particles having the passed shapeId.
  34839. * @param shapeId the shape identifier
  34840. * @returns the SPS
  34841. * @param ref
  34842. */
  34843. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34844. /**
  34845. * Computes the required SubMeshes according the materials assigned to the particles.
  34846. * @returns the solid particle system.
  34847. * Does nothing if called before the SPS mesh is built.
  34848. */
  34849. computeSubMeshes(): SolidParticleSystem;
  34850. /**
  34851. * Sorts the solid particles by material when MultiMaterial is enabled.
  34852. * Updates the indices32 array.
  34853. * Updates the indicesByMaterial array.
  34854. * Updates the mesh indices array.
  34855. * @returns the SPS
  34856. * @hidden
  34857. */
  34858. private _sortParticlesByMaterial;
  34859. /**
  34860. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34861. * @hidden
  34862. */
  34863. private _setMaterialIndexesById;
  34864. /**
  34865. * Returns an array with unique values of Materials from the passed array
  34866. * @param array the material array to be checked and filtered
  34867. * @hidden
  34868. */
  34869. private _filterUniqueMaterialId;
  34870. /**
  34871. * Sets a new Standard Material as _defaultMaterial if not already set.
  34872. * @hidden
  34873. */
  34874. private _setDefaultMaterial;
  34875. /**
  34876. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34877. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34878. * @returns the SPS.
  34879. */
  34880. refreshVisibleSize(): SolidParticleSystem;
  34881. /**
  34882. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34883. * @param size the size (float) of the visibility box
  34884. * note : this doesn't lock the SPS mesh bounding box.
  34885. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34886. */
  34887. setVisibilityBox(size: number): void;
  34888. /**
  34889. * Gets whether the SPS as always visible or not
  34890. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34891. */
  34892. get isAlwaysVisible(): boolean;
  34893. /**
  34894. * Sets the SPS as always visible or not
  34895. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34896. */
  34897. set isAlwaysVisible(val: boolean);
  34898. /**
  34899. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34900. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34901. */
  34902. set isVisibilityBoxLocked(val: boolean);
  34903. /**
  34904. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34905. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34906. */
  34907. get isVisibilityBoxLocked(): boolean;
  34908. /**
  34909. * Tells to `setParticles()` to compute 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. set computeParticleRotation(val: boolean);
  34914. /**
  34915. * Tells to `setParticles()` to compute 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. set computeParticleColor(val: boolean);
  34920. set computeParticleTexture(val: boolean);
  34921. /**
  34922. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34923. * Default value : false. The SPS is faster when it's set to false.
  34924. * Note : the particle custom vertex positions aren't stored values.
  34925. */
  34926. set computeParticleVertex(val: boolean);
  34927. /**
  34928. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34929. */
  34930. set computeBoundingBox(val: boolean);
  34931. /**
  34932. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34933. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34934. * Default : `true`
  34935. */
  34936. set depthSortParticles(val: boolean);
  34937. /**
  34938. * Gets if `setParticles()` computes the particle rotations or not.
  34939. * Default value : true. The SPS is faster when it's set to false.
  34940. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34941. */
  34942. get computeParticleRotation(): boolean;
  34943. /**
  34944. * Gets if `setParticles()` computes the particle colors or not.
  34945. * Default value : true. The SPS is faster when it's set to false.
  34946. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34947. */
  34948. get computeParticleColor(): boolean;
  34949. /**
  34950. * Gets if `setParticles()` computes the particle textures or not.
  34951. * Default value : true. The SPS is faster when it's set to false.
  34952. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34953. */
  34954. get computeParticleTexture(): boolean;
  34955. /**
  34956. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34957. * Default value : false. The SPS is faster when it's set to false.
  34958. * Note : the particle custom vertex positions aren't stored values.
  34959. */
  34960. get computeParticleVertex(): boolean;
  34961. /**
  34962. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34963. */
  34964. get computeBoundingBox(): boolean;
  34965. /**
  34966. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34967. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34968. * Default : `true`
  34969. */
  34970. get depthSortParticles(): boolean;
  34971. /**
  34972. * Gets if the SPS is created as expandable at construction time.
  34973. * Default : `false`
  34974. */
  34975. get expandable(): boolean;
  34976. /**
  34977. * Gets if the SPS supports the Multi Materials
  34978. */
  34979. get multimaterialEnabled(): boolean;
  34980. /**
  34981. * Gets if the SPS uses the model materials for its own multimaterial.
  34982. */
  34983. get useModelMaterial(): boolean;
  34984. /**
  34985. * The SPS used material array.
  34986. */
  34987. get materials(): Material[];
  34988. /**
  34989. * Sets the SPS MultiMaterial from the passed materials.
  34990. * Note : the passed array is internally copied and not used then by reference.
  34991. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34992. */
  34993. setMultiMaterial(materials: Material[]): void;
  34994. /**
  34995. * The SPS computed multimaterial object
  34996. */
  34997. get multimaterial(): MultiMaterial;
  34998. set multimaterial(mm: MultiMaterial);
  34999. /**
  35000. * If the subMeshes must be updated on the next call to setParticles()
  35001. */
  35002. get autoUpdateSubMeshes(): boolean;
  35003. set autoUpdateSubMeshes(val: boolean);
  35004. /**
  35005. * This function does nothing. It may be overwritten to set all the particle first values.
  35006. * The SPS doesn't call this function, you may have to call it by your own.
  35007. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35008. */
  35009. initParticles(): void;
  35010. /**
  35011. * This function does nothing. It may be overwritten to recycle a particle.
  35012. * The SPS doesn't call this function, you may have to call it by your own.
  35013. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35014. * @param particle The particle to recycle
  35015. * @returns the recycled particle
  35016. */
  35017. recycleParticle(particle: SolidParticle): SolidParticle;
  35018. /**
  35019. * Updates a particle : this function should be overwritten by the user.
  35020. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35021. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35022. * @example : just set a particle position or velocity and recycle conditions
  35023. * @param particle The particle to update
  35024. * @returns the updated particle
  35025. */
  35026. updateParticle(particle: SolidParticle): SolidParticle;
  35027. /**
  35028. * Updates a vertex of a particle : it can be overwritten by the user.
  35029. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35030. * @param particle the current particle
  35031. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35032. * @param pt the index of the current vertex in the particle shape
  35033. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35034. * @example : just set a vertex particle position or color
  35035. * @returns the sps
  35036. */
  35037. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35038. /**
  35039. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35040. * This does nothing and may be overwritten by the user.
  35041. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35042. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35043. * @param update the boolean update value actually passed to setParticles()
  35044. */
  35045. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35046. /**
  35047. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35048. * This will be passed three parameters.
  35049. * This does nothing and may be overwritten by the user.
  35050. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35051. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35052. * @param update the boolean update value actually passed to setParticles()
  35053. */
  35054. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35055. }
  35056. }
  35057. declare module BABYLON {
  35058. /**
  35059. * Represents one particle of a solid particle system.
  35060. */
  35061. export class SolidParticle {
  35062. /**
  35063. * particle global index
  35064. */
  35065. idx: number;
  35066. /**
  35067. * particle identifier
  35068. */
  35069. id: number;
  35070. /**
  35071. * The color of the particle
  35072. */
  35073. color: Nullable<Color4>;
  35074. /**
  35075. * The world space position of the particle.
  35076. */
  35077. position: Vector3;
  35078. /**
  35079. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35080. */
  35081. rotation: Vector3;
  35082. /**
  35083. * The world space rotation quaternion of the particle.
  35084. */
  35085. rotationQuaternion: Nullable<Quaternion>;
  35086. /**
  35087. * The scaling of the particle.
  35088. */
  35089. scaling: Vector3;
  35090. /**
  35091. * The uvs of the particle.
  35092. */
  35093. uvs: Vector4;
  35094. /**
  35095. * The current speed of the particle.
  35096. */
  35097. velocity: Vector3;
  35098. /**
  35099. * The pivot point in the particle local space.
  35100. */
  35101. pivot: Vector3;
  35102. /**
  35103. * Must the particle be translated from its pivot point in its local space ?
  35104. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35105. * Default : false
  35106. */
  35107. translateFromPivot: boolean;
  35108. /**
  35109. * Is the particle active or not ?
  35110. */
  35111. alive: boolean;
  35112. /**
  35113. * Is the particle visible or not ?
  35114. */
  35115. isVisible: boolean;
  35116. /**
  35117. * Index of this particle in the global "positions" array (Internal use)
  35118. * @hidden
  35119. */
  35120. _pos: number;
  35121. /**
  35122. * @hidden Index of this particle in the global "indices" array (Internal use)
  35123. */
  35124. _ind: number;
  35125. /**
  35126. * @hidden ModelShape of this particle (Internal use)
  35127. */
  35128. _model: ModelShape;
  35129. /**
  35130. * ModelShape id of this particle
  35131. */
  35132. shapeId: number;
  35133. /**
  35134. * Index of the particle in its shape id
  35135. */
  35136. idxInShape: number;
  35137. /**
  35138. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35139. */
  35140. _modelBoundingInfo: BoundingInfo;
  35141. /**
  35142. * @hidden Particle BoundingInfo object (Internal use)
  35143. */
  35144. _boundingInfo: BoundingInfo;
  35145. /**
  35146. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35147. */
  35148. _sps: SolidParticleSystem;
  35149. /**
  35150. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35151. */
  35152. _stillInvisible: boolean;
  35153. /**
  35154. * @hidden Last computed particle rotation matrix
  35155. */
  35156. _rotationMatrix: number[];
  35157. /**
  35158. * Parent particle Id, if any.
  35159. * Default null.
  35160. */
  35161. parentId: Nullable<number>;
  35162. /**
  35163. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35164. */
  35165. materialIndex: Nullable<number>;
  35166. /**
  35167. * Custom object or properties.
  35168. */
  35169. props: Nullable<any>;
  35170. /**
  35171. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35172. * The possible values are :
  35173. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35174. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35175. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35176. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35177. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35178. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35179. * */
  35180. cullingStrategy: number;
  35181. /**
  35182. * @hidden Internal global position in the SPS.
  35183. */
  35184. _globalPosition: Vector3;
  35185. /**
  35186. * Creates a Solid Particle object.
  35187. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35188. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35189. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35190. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35191. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35192. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35193. * @param shapeId (integer) is the model shape identifier in the SPS.
  35194. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35195. * @param sps defines the sps it is associated to
  35196. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35197. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35198. */
  35199. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35200. /**
  35201. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35202. * @param target the particle target
  35203. * @returns the current particle
  35204. */
  35205. copyToRef(target: SolidParticle): SolidParticle;
  35206. /**
  35207. * Legacy support, changed scale to scaling
  35208. */
  35209. get scale(): Vector3;
  35210. /**
  35211. * Legacy support, changed scale to scaling
  35212. */
  35213. set scale(scale: Vector3);
  35214. /**
  35215. * Legacy support, changed quaternion to rotationQuaternion
  35216. */
  35217. get quaternion(): Nullable<Quaternion>;
  35218. /**
  35219. * Legacy support, changed quaternion to rotationQuaternion
  35220. */
  35221. set quaternion(q: Nullable<Quaternion>);
  35222. /**
  35223. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35224. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35225. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35226. * @returns true if it intersects
  35227. */
  35228. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35229. /**
  35230. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35231. * A particle is in the frustum if its bounding box intersects the frustum
  35232. * @param frustumPlanes defines the frustum to test
  35233. * @returns true if the particle is in the frustum planes
  35234. */
  35235. isInFrustum(frustumPlanes: Plane[]): boolean;
  35236. /**
  35237. * get the rotation matrix of the particle
  35238. * @hidden
  35239. */
  35240. getRotationMatrix(m: Matrix): void;
  35241. }
  35242. /**
  35243. * Represents the shape of the model used by one particle of a solid particle system.
  35244. * SPS internal tool, don't use it manually.
  35245. */
  35246. export class ModelShape {
  35247. /**
  35248. * The shape id
  35249. * @hidden
  35250. */
  35251. shapeID: number;
  35252. /**
  35253. * flat array of model positions (internal use)
  35254. * @hidden
  35255. */
  35256. _shape: Vector3[];
  35257. /**
  35258. * flat array of model UVs (internal use)
  35259. * @hidden
  35260. */
  35261. _shapeUV: number[];
  35262. /**
  35263. * color array of the model
  35264. * @hidden
  35265. */
  35266. _shapeColors: number[];
  35267. /**
  35268. * indices array of the model
  35269. * @hidden
  35270. */
  35271. _indices: number[];
  35272. /**
  35273. * normals array of the model
  35274. * @hidden
  35275. */
  35276. _normals: number[];
  35277. /**
  35278. * length of the shape in the model indices array (internal use)
  35279. * @hidden
  35280. */
  35281. _indicesLength: number;
  35282. /**
  35283. * Custom position function (internal use)
  35284. * @hidden
  35285. */
  35286. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35287. /**
  35288. * Custom vertex function (internal use)
  35289. * @hidden
  35290. */
  35291. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35292. /**
  35293. * Model material (internal use)
  35294. * @hidden
  35295. */
  35296. _material: Nullable<Material>;
  35297. /**
  35298. * 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.
  35299. * SPS internal tool, don't use it manually.
  35300. * @hidden
  35301. */
  35302. 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>);
  35303. }
  35304. /**
  35305. * Represents a Depth Sorted Particle in the solid particle system.
  35306. * @hidden
  35307. */
  35308. export class DepthSortedParticle {
  35309. /**
  35310. * Particle index
  35311. */
  35312. idx: number;
  35313. /**
  35314. * Index of the particle in the "indices" array
  35315. */
  35316. ind: number;
  35317. /**
  35318. * Length of the particle shape in the "indices" array
  35319. */
  35320. indicesLength: number;
  35321. /**
  35322. * Squared distance from the particle to the camera
  35323. */
  35324. sqDistance: number;
  35325. /**
  35326. * Material index when used with MultiMaterials
  35327. */
  35328. materialIndex: number;
  35329. /**
  35330. * Creates a new sorted particle
  35331. * @param materialIndex
  35332. */
  35333. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35334. }
  35335. /**
  35336. * Represents a solid particle vertex
  35337. */
  35338. export class SolidParticleVertex {
  35339. /**
  35340. * Vertex position
  35341. */
  35342. position: Vector3;
  35343. /**
  35344. * Vertex color
  35345. */
  35346. color: Color4;
  35347. /**
  35348. * Vertex UV
  35349. */
  35350. uv: Vector2;
  35351. /**
  35352. * Creates a new solid particle vertex
  35353. */
  35354. constructor();
  35355. /** Vertex x coordinate */
  35356. get x(): number;
  35357. set x(val: number);
  35358. /** Vertex y coordinate */
  35359. get y(): number;
  35360. set y(val: number);
  35361. /** Vertex z coordinate */
  35362. get z(): number;
  35363. set z(val: number);
  35364. }
  35365. }
  35366. declare module BABYLON {
  35367. /**
  35368. * @hidden
  35369. */
  35370. export class _MeshCollisionData {
  35371. _checkCollisions: boolean;
  35372. _collisionMask: number;
  35373. _collisionGroup: number;
  35374. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35375. _collider: Nullable<Collider>;
  35376. _oldPositionForCollisions: Vector3;
  35377. _diffPositionForCollisions: Vector3;
  35378. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35379. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35380. _collisionResponse: boolean;
  35381. }
  35382. }
  35383. declare module BABYLON {
  35384. /** @hidden */
  35385. class _FacetDataStorage {
  35386. facetPositions: Vector3[];
  35387. facetNormals: Vector3[];
  35388. facetPartitioning: number[][];
  35389. facetNb: number;
  35390. partitioningSubdivisions: number;
  35391. partitioningBBoxRatio: number;
  35392. facetDataEnabled: boolean;
  35393. facetParameters: any;
  35394. bbSize: Vector3;
  35395. subDiv: {
  35396. max: number;
  35397. X: number;
  35398. Y: number;
  35399. Z: number;
  35400. };
  35401. facetDepthSort: boolean;
  35402. facetDepthSortEnabled: boolean;
  35403. depthSortedIndices: IndicesArray;
  35404. depthSortedFacets: {
  35405. ind: number;
  35406. sqDistance: number;
  35407. }[];
  35408. facetDepthSortFunction: (f1: {
  35409. ind: number;
  35410. sqDistance: number;
  35411. }, f2: {
  35412. ind: number;
  35413. sqDistance: number;
  35414. }) => number;
  35415. facetDepthSortFrom: Vector3;
  35416. facetDepthSortOrigin: Vector3;
  35417. invertedMatrix: Matrix;
  35418. }
  35419. /**
  35420. * @hidden
  35421. **/
  35422. class _InternalAbstractMeshDataInfo {
  35423. _hasVertexAlpha: boolean;
  35424. _useVertexColors: boolean;
  35425. _numBoneInfluencers: number;
  35426. _applyFog: boolean;
  35427. _receiveShadows: boolean;
  35428. _facetData: _FacetDataStorage;
  35429. _visibility: number;
  35430. _skeleton: Nullable<Skeleton>;
  35431. _layerMask: number;
  35432. _computeBonesUsingShaders: boolean;
  35433. _isActive: boolean;
  35434. _onlyForInstances: boolean;
  35435. _isActiveIntermediate: boolean;
  35436. _onlyForInstancesIntermediate: boolean;
  35437. _actAsRegularMesh: boolean;
  35438. _currentLOD: Nullable<AbstractMesh>;
  35439. }
  35440. /**
  35441. * Class used to store all common mesh properties
  35442. */
  35443. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35444. /** No occlusion */
  35445. static OCCLUSION_TYPE_NONE: number;
  35446. /** Occlusion set to optimisitic */
  35447. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35448. /** Occlusion set to strict */
  35449. static OCCLUSION_TYPE_STRICT: number;
  35450. /** Use an accurante occlusion algorithm */
  35451. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35452. /** Use a conservative occlusion algorithm */
  35453. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35454. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35455. * Test order :
  35456. * Is the bounding sphere outside the frustum ?
  35457. * If not, are the bounding box vertices outside the frustum ?
  35458. * It not, then the cullable object is in the frustum.
  35459. */
  35460. static readonly CULLINGSTRATEGY_STANDARD: number;
  35461. /** Culling strategy : Bounding Sphere Only.
  35462. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35463. * It's also less accurate than the standard because some not visible objects can still be selected.
  35464. * Test : is the bounding sphere outside the frustum ?
  35465. * If not, then the cullable object is in the frustum.
  35466. */
  35467. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35468. /** Culling strategy : Optimistic Inclusion.
  35469. * This in an inclusion test first, then the standard exclusion test.
  35470. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35471. * 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.
  35472. * Anyway, it's as accurate as the standard strategy.
  35473. * Test :
  35474. * Is the cullable object bounding sphere center in the frustum ?
  35475. * If not, apply the default culling strategy.
  35476. */
  35477. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35478. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35479. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35480. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35481. * 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.
  35482. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35483. * Test :
  35484. * Is the cullable object bounding sphere center in the frustum ?
  35485. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35486. */
  35487. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35488. /**
  35489. * No billboard
  35490. */
  35491. static get BILLBOARDMODE_NONE(): number;
  35492. /** Billboard on X axis */
  35493. static get BILLBOARDMODE_X(): number;
  35494. /** Billboard on Y axis */
  35495. static get BILLBOARDMODE_Y(): number;
  35496. /** Billboard on Z axis */
  35497. static get BILLBOARDMODE_Z(): number;
  35498. /** Billboard on all axes */
  35499. static get BILLBOARDMODE_ALL(): number;
  35500. /** Billboard on using position instead of orientation */
  35501. static get BILLBOARDMODE_USE_POSITION(): number;
  35502. /** @hidden */
  35503. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35504. /**
  35505. * The culling strategy to use to check whether the mesh must be rendered or not.
  35506. * This value can be changed at any time and will be used on the next render mesh selection.
  35507. * The possible values are :
  35508. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35509. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35510. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35511. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35512. * Please read each static variable documentation to get details about the culling process.
  35513. * */
  35514. cullingStrategy: number;
  35515. /**
  35516. * Gets the number of facets in the mesh
  35517. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35518. */
  35519. get facetNb(): number;
  35520. /**
  35521. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35522. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35523. */
  35524. get partitioningSubdivisions(): number;
  35525. set partitioningSubdivisions(nb: number);
  35526. /**
  35527. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35528. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35529. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35530. */
  35531. get partitioningBBoxRatio(): number;
  35532. set partitioningBBoxRatio(ratio: number);
  35533. /**
  35534. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35535. * Works only for updatable meshes.
  35536. * Doesn't work with multi-materials
  35537. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35538. */
  35539. get mustDepthSortFacets(): boolean;
  35540. set mustDepthSortFacets(sort: boolean);
  35541. /**
  35542. * The location (Vector3) where the facet depth sort must be computed from.
  35543. * By default, the active camera position.
  35544. * Used only when facet depth sort is enabled
  35545. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35546. */
  35547. get facetDepthSortFrom(): Vector3;
  35548. set facetDepthSortFrom(location: Vector3);
  35549. /**
  35550. * gets a boolean indicating if facetData is enabled
  35551. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35552. */
  35553. get isFacetDataEnabled(): boolean;
  35554. /** @hidden */
  35555. _updateNonUniformScalingState(value: boolean): boolean;
  35556. /**
  35557. * An event triggered when this mesh collides with another one
  35558. */
  35559. onCollideObservable: Observable<AbstractMesh>;
  35560. /** Set a function to call when this mesh collides with another one */
  35561. set onCollide(callback: () => void);
  35562. /**
  35563. * An event triggered when the collision's position changes
  35564. */
  35565. onCollisionPositionChangeObservable: Observable<Vector3>;
  35566. /** Set a function to call when the collision's position changes */
  35567. set onCollisionPositionChange(callback: () => void);
  35568. /**
  35569. * An event triggered when material is changed
  35570. */
  35571. onMaterialChangedObservable: Observable<AbstractMesh>;
  35572. /**
  35573. * Gets or sets the orientation for POV movement & rotation
  35574. */
  35575. definedFacingForward: boolean;
  35576. /** @hidden */
  35577. _occlusionQuery: Nullable<WebGLQuery>;
  35578. /** @hidden */
  35579. _renderingGroup: Nullable<RenderingGroup>;
  35580. /**
  35581. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35582. */
  35583. get visibility(): number;
  35584. /**
  35585. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35586. */
  35587. set visibility(value: number);
  35588. /** Gets or sets the alpha index used to sort transparent meshes
  35589. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35590. */
  35591. alphaIndex: number;
  35592. /**
  35593. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35594. */
  35595. isVisible: boolean;
  35596. /**
  35597. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35598. */
  35599. isPickable: boolean;
  35600. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35601. showSubMeshesBoundingBox: boolean;
  35602. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35603. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35604. */
  35605. isBlocker: boolean;
  35606. /**
  35607. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35608. */
  35609. enablePointerMoveEvents: boolean;
  35610. private _renderingGroupId;
  35611. /**
  35612. * Specifies the rendering group id for this mesh (0 by default)
  35613. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35614. */
  35615. get renderingGroupId(): number;
  35616. set renderingGroupId(value: number);
  35617. private _material;
  35618. /** Gets or sets current material */
  35619. get material(): Nullable<Material>;
  35620. set material(value: Nullable<Material>);
  35621. /**
  35622. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35623. * @see https://doc.babylonjs.com/babylon101/shadows
  35624. */
  35625. get receiveShadows(): boolean;
  35626. set receiveShadows(value: boolean);
  35627. /** Defines color to use when rendering outline */
  35628. outlineColor: Color3;
  35629. /** Define width to use when rendering outline */
  35630. outlineWidth: number;
  35631. /** Defines color to use when rendering overlay */
  35632. overlayColor: Color3;
  35633. /** Defines alpha to use when rendering overlay */
  35634. overlayAlpha: number;
  35635. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35636. get hasVertexAlpha(): boolean;
  35637. set hasVertexAlpha(value: boolean);
  35638. /** 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) */
  35639. get useVertexColors(): boolean;
  35640. set useVertexColors(value: boolean);
  35641. /**
  35642. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35643. */
  35644. get computeBonesUsingShaders(): boolean;
  35645. set computeBonesUsingShaders(value: boolean);
  35646. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35647. get numBoneInfluencers(): number;
  35648. set numBoneInfluencers(value: number);
  35649. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35650. get applyFog(): boolean;
  35651. set applyFog(value: boolean);
  35652. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35653. useOctreeForRenderingSelection: boolean;
  35654. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35655. useOctreeForPicking: boolean;
  35656. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35657. useOctreeForCollisions: boolean;
  35658. /**
  35659. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35660. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35661. */
  35662. get layerMask(): number;
  35663. set layerMask(value: number);
  35664. /**
  35665. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35666. */
  35667. alwaysSelectAsActiveMesh: boolean;
  35668. /**
  35669. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35670. */
  35671. doNotSyncBoundingInfo: boolean;
  35672. /**
  35673. * Gets or sets the current action manager
  35674. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35675. */
  35676. actionManager: Nullable<AbstractActionManager>;
  35677. private _meshCollisionData;
  35678. /**
  35679. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35680. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35681. */
  35682. ellipsoid: Vector3;
  35683. /**
  35684. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35685. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35686. */
  35687. ellipsoidOffset: Vector3;
  35688. /**
  35689. * Gets or sets a collision mask used to mask collisions (default is -1).
  35690. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35691. */
  35692. get collisionMask(): number;
  35693. set collisionMask(mask: number);
  35694. /**
  35695. * Gets or sets a collision response flag (default is true).
  35696. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35697. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35698. * to respond to the collision.
  35699. */
  35700. get collisionResponse(): boolean;
  35701. set collisionResponse(response: boolean);
  35702. /**
  35703. * Gets or sets the current collision group mask (-1 by default).
  35704. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35705. */
  35706. get collisionGroup(): number;
  35707. set collisionGroup(mask: number);
  35708. /**
  35709. * Gets or sets current surrounding meshes (null by default).
  35710. *
  35711. * By default collision detection is tested against every mesh in the scene.
  35712. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35713. * meshes will be tested for the collision.
  35714. *
  35715. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35716. */
  35717. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35718. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35719. /**
  35720. * Defines edge width used when edgesRenderer is enabled
  35721. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35722. */
  35723. edgesWidth: number;
  35724. /**
  35725. * Defines edge color used when edgesRenderer is enabled
  35726. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35727. */
  35728. edgesColor: Color4;
  35729. /** @hidden */
  35730. _edgesRenderer: Nullable<IEdgesRenderer>;
  35731. /** @hidden */
  35732. _masterMesh: Nullable<AbstractMesh>;
  35733. /** @hidden */
  35734. _boundingInfo: Nullable<BoundingInfo>;
  35735. /** @hidden */
  35736. _renderId: number;
  35737. /**
  35738. * Gets or sets the list of subMeshes
  35739. * @see https://doc.babylonjs.com/how_to/multi_materials
  35740. */
  35741. subMeshes: SubMesh[];
  35742. /** @hidden */
  35743. _intersectionsInProgress: AbstractMesh[];
  35744. /** @hidden */
  35745. _unIndexed: boolean;
  35746. /** @hidden */
  35747. _lightSources: Light[];
  35748. /** Gets the list of lights affecting that mesh */
  35749. get lightSources(): Light[];
  35750. /** @hidden */
  35751. get _positions(): Nullable<Vector3[]>;
  35752. /** @hidden */
  35753. _waitingData: {
  35754. lods: Nullable<any>;
  35755. actions: Nullable<any>;
  35756. freezeWorldMatrix: Nullable<boolean>;
  35757. };
  35758. /** @hidden */
  35759. _bonesTransformMatrices: Nullable<Float32Array>;
  35760. /** @hidden */
  35761. _transformMatrixTexture: Nullable<RawTexture>;
  35762. /**
  35763. * Gets or sets a skeleton to apply skining transformations
  35764. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35765. */
  35766. set skeleton(value: Nullable<Skeleton>);
  35767. get skeleton(): Nullable<Skeleton>;
  35768. /**
  35769. * An event triggered when the mesh is rebuilt.
  35770. */
  35771. onRebuildObservable: Observable<AbstractMesh>;
  35772. /**
  35773. * Creates a new AbstractMesh
  35774. * @param name defines the name of the mesh
  35775. * @param scene defines the hosting scene
  35776. */
  35777. constructor(name: string, scene?: Nullable<Scene>);
  35778. /**
  35779. * Returns the string "AbstractMesh"
  35780. * @returns "AbstractMesh"
  35781. */
  35782. getClassName(): string;
  35783. /**
  35784. * Gets a string representation of the current mesh
  35785. * @param fullDetails defines a boolean indicating if full details must be included
  35786. * @returns a string representation of the current mesh
  35787. */
  35788. toString(fullDetails?: boolean): string;
  35789. /**
  35790. * @hidden
  35791. */
  35792. protected _getEffectiveParent(): Nullable<Node>;
  35793. /** @hidden */
  35794. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35795. /** @hidden */
  35796. _rebuild(): void;
  35797. /** @hidden */
  35798. _resyncLightSources(): void;
  35799. /** @hidden */
  35800. _resyncLightSource(light: Light): void;
  35801. /** @hidden */
  35802. _unBindEffect(): void;
  35803. /** @hidden */
  35804. _removeLightSource(light: Light, dispose: boolean): void;
  35805. private _markSubMeshesAsDirty;
  35806. /** @hidden */
  35807. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35808. /** @hidden */
  35809. _markSubMeshesAsAttributesDirty(): void;
  35810. /** @hidden */
  35811. _markSubMeshesAsMiscDirty(): void;
  35812. /**
  35813. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35814. */
  35815. get scaling(): Vector3;
  35816. set scaling(newScaling: Vector3);
  35817. /**
  35818. * Returns true if the mesh is blocked. Implemented by child classes
  35819. */
  35820. get isBlocked(): boolean;
  35821. /**
  35822. * Returns the mesh itself by default. Implemented by child classes
  35823. * @param camera defines the camera to use to pick the right LOD level
  35824. * @returns the currentAbstractMesh
  35825. */
  35826. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35827. /**
  35828. * Returns 0 by default. Implemented by child classes
  35829. * @returns an integer
  35830. */
  35831. getTotalVertices(): number;
  35832. /**
  35833. * Returns a positive integer : the total number of indices in this mesh geometry.
  35834. * @returns the numner of indices or zero if the mesh has no geometry.
  35835. */
  35836. getTotalIndices(): number;
  35837. /**
  35838. * Returns null by default. Implemented by child classes
  35839. * @returns null
  35840. */
  35841. getIndices(): Nullable<IndicesArray>;
  35842. /**
  35843. * Returns the array of the requested vertex data kind. Implemented by child classes
  35844. * @param kind defines the vertex data kind to use
  35845. * @returns null
  35846. */
  35847. getVerticesData(kind: string): Nullable<FloatArray>;
  35848. /**
  35849. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35850. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35851. * Note that a new underlying VertexBuffer object is created each call.
  35852. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35853. * @param kind defines vertex data kind:
  35854. * * VertexBuffer.PositionKind
  35855. * * VertexBuffer.UVKind
  35856. * * VertexBuffer.UV2Kind
  35857. * * VertexBuffer.UV3Kind
  35858. * * VertexBuffer.UV4Kind
  35859. * * VertexBuffer.UV5Kind
  35860. * * VertexBuffer.UV6Kind
  35861. * * VertexBuffer.ColorKind
  35862. * * VertexBuffer.MatricesIndicesKind
  35863. * * VertexBuffer.MatricesIndicesExtraKind
  35864. * * VertexBuffer.MatricesWeightsKind
  35865. * * VertexBuffer.MatricesWeightsExtraKind
  35866. * @param data defines the data source
  35867. * @param updatable defines if the data must be flagged as updatable (or static)
  35868. * @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
  35869. * @returns the current mesh
  35870. */
  35871. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35872. /**
  35873. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35874. * If the mesh has no geometry, it is simply returned as it is.
  35875. * @param kind defines vertex data kind:
  35876. * * VertexBuffer.PositionKind
  35877. * * VertexBuffer.UVKind
  35878. * * VertexBuffer.UV2Kind
  35879. * * VertexBuffer.UV3Kind
  35880. * * VertexBuffer.UV4Kind
  35881. * * VertexBuffer.UV5Kind
  35882. * * VertexBuffer.UV6Kind
  35883. * * VertexBuffer.ColorKind
  35884. * * VertexBuffer.MatricesIndicesKind
  35885. * * VertexBuffer.MatricesIndicesExtraKind
  35886. * * VertexBuffer.MatricesWeightsKind
  35887. * * VertexBuffer.MatricesWeightsExtraKind
  35888. * @param data defines the data source
  35889. * @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
  35890. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35891. * @returns the current mesh
  35892. */
  35893. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35894. /**
  35895. * Sets the mesh indices,
  35896. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35897. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35898. * @param totalVertices Defines the total number of vertices
  35899. * @returns the current mesh
  35900. */
  35901. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35902. /**
  35903. * Gets a boolean indicating if specific vertex data is present
  35904. * @param kind defines the vertex data kind to use
  35905. * @returns true is data kind is present
  35906. */
  35907. isVerticesDataPresent(kind: string): boolean;
  35908. /**
  35909. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35910. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35911. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35912. * @returns a BoundingInfo
  35913. */
  35914. getBoundingInfo(): BoundingInfo;
  35915. /**
  35916. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35917. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35918. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35919. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35920. * @returns the current mesh
  35921. */
  35922. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35923. /**
  35924. * Overwrite the current bounding info
  35925. * @param boundingInfo defines the new bounding info
  35926. * @returns the current mesh
  35927. */
  35928. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35929. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35930. get useBones(): boolean;
  35931. /** @hidden */
  35932. _preActivate(): void;
  35933. /** @hidden */
  35934. _preActivateForIntermediateRendering(renderId: number): void;
  35935. /** @hidden */
  35936. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35937. /** @hidden */
  35938. _postActivate(): void;
  35939. /** @hidden */
  35940. _freeze(): void;
  35941. /** @hidden */
  35942. _unFreeze(): void;
  35943. /**
  35944. * Gets the current world matrix
  35945. * @returns a Matrix
  35946. */
  35947. getWorldMatrix(): Matrix;
  35948. /** @hidden */
  35949. _getWorldMatrixDeterminant(): number;
  35950. /**
  35951. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35952. */
  35953. get isAnInstance(): boolean;
  35954. /**
  35955. * Gets a boolean indicating if this mesh has instances
  35956. */
  35957. get hasInstances(): boolean;
  35958. /**
  35959. * Gets a boolean indicating if this mesh has thin instances
  35960. */
  35961. get hasThinInstances(): boolean;
  35962. /**
  35963. * Perform relative position change from the point of view of behind the front of the mesh.
  35964. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35965. * Supports definition of mesh facing forward or backward
  35966. * @param amountRight defines the distance on the right axis
  35967. * @param amountUp defines the distance on the up axis
  35968. * @param amountForward defines the distance on the forward axis
  35969. * @returns the current mesh
  35970. */
  35971. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35972. /**
  35973. * Calculate relative position change from the point of view of behind the front of the mesh.
  35974. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35975. * Supports definition of mesh facing forward or backward
  35976. * @param amountRight defines the distance on the right axis
  35977. * @param amountUp defines the distance on the up axis
  35978. * @param amountForward defines the distance on the forward axis
  35979. * @returns the new displacement vector
  35980. */
  35981. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35982. /**
  35983. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35984. * Supports definition of mesh facing forward or backward
  35985. * @param flipBack defines the flip
  35986. * @param twirlClockwise defines the twirl
  35987. * @param tiltRight defines the tilt
  35988. * @returns the current mesh
  35989. */
  35990. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35991. /**
  35992. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35993. * Supports definition of mesh facing forward or backward.
  35994. * @param flipBack defines the flip
  35995. * @param twirlClockwise defines the twirl
  35996. * @param tiltRight defines the tilt
  35997. * @returns the new rotation vector
  35998. */
  35999. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36000. /**
  36001. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36002. * This means the mesh underlying bounding box and sphere are recomputed.
  36003. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36004. * @returns the current mesh
  36005. */
  36006. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36007. /** @hidden */
  36008. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36009. /** @hidden */
  36010. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36011. /** @hidden */
  36012. _updateBoundingInfo(): AbstractMesh;
  36013. /** @hidden */
  36014. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36015. /** @hidden */
  36016. protected _afterComputeWorldMatrix(): void;
  36017. /** @hidden */
  36018. get _effectiveMesh(): AbstractMesh;
  36019. /**
  36020. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36021. * A mesh is in the frustum if its bounding box intersects the frustum
  36022. * @param frustumPlanes defines the frustum to test
  36023. * @returns true if the mesh is in the frustum planes
  36024. */
  36025. isInFrustum(frustumPlanes: Plane[]): boolean;
  36026. /**
  36027. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36028. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36029. * @param frustumPlanes defines the frustum to test
  36030. * @returns true if the mesh is completely in the frustum planes
  36031. */
  36032. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36033. /**
  36034. * True if the mesh intersects another mesh or a SolidParticle object
  36035. * @param mesh defines a target mesh or SolidParticle to test
  36036. * @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)
  36037. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36038. * @returns true if there is an intersection
  36039. */
  36040. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36041. /**
  36042. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36043. * @param point defines the point to test
  36044. * @returns true if there is an intersection
  36045. */
  36046. intersectsPoint(point: Vector3): boolean;
  36047. /**
  36048. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36049. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36050. */
  36051. get checkCollisions(): boolean;
  36052. set checkCollisions(collisionEnabled: boolean);
  36053. /**
  36054. * Gets Collider object used to compute collisions (not physics)
  36055. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36056. */
  36057. get collider(): Nullable<Collider>;
  36058. /**
  36059. * Move the mesh using collision engine
  36060. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36061. * @param displacement defines the requested displacement vector
  36062. * @returns the current mesh
  36063. */
  36064. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36065. private _onCollisionPositionChange;
  36066. /** @hidden */
  36067. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36068. /** @hidden */
  36069. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36070. /** @hidden */
  36071. _checkCollision(collider: Collider): AbstractMesh;
  36072. /** @hidden */
  36073. _generatePointsArray(): boolean;
  36074. /**
  36075. * Checks if the passed Ray intersects with the mesh
  36076. * @param ray defines the ray to use
  36077. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36078. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36079. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36080. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36081. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36082. * @returns the picking info
  36083. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36084. */
  36085. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36086. /**
  36087. * Clones the current mesh
  36088. * @param name defines the mesh name
  36089. * @param newParent defines the new mesh parent
  36090. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36091. * @returns the new mesh
  36092. */
  36093. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36094. /**
  36095. * Disposes all the submeshes of the current meshnp
  36096. * @returns the current mesh
  36097. */
  36098. releaseSubMeshes(): AbstractMesh;
  36099. /**
  36100. * Releases resources associated with this abstract mesh.
  36101. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36102. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36103. */
  36104. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36105. /**
  36106. * Adds the passed mesh as a child to the current mesh
  36107. * @param mesh defines the child mesh
  36108. * @returns the current mesh
  36109. */
  36110. addChild(mesh: AbstractMesh): AbstractMesh;
  36111. /**
  36112. * Removes the passed mesh from the current mesh children list
  36113. * @param mesh defines the child mesh
  36114. * @returns the current mesh
  36115. */
  36116. removeChild(mesh: AbstractMesh): AbstractMesh;
  36117. /** @hidden */
  36118. private _initFacetData;
  36119. /**
  36120. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36121. * This method can be called within the render loop.
  36122. * 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
  36123. * @returns the current mesh
  36124. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36125. */
  36126. updateFacetData(): AbstractMesh;
  36127. /**
  36128. * Returns the facetLocalNormals array.
  36129. * The normals are expressed in the mesh local spac
  36130. * @returns an array of Vector3
  36131. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36132. */
  36133. getFacetLocalNormals(): Vector3[];
  36134. /**
  36135. * Returns the facetLocalPositions array.
  36136. * The facet positions are expressed in the mesh local space
  36137. * @returns an array of Vector3
  36138. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36139. */
  36140. getFacetLocalPositions(): Vector3[];
  36141. /**
  36142. * Returns the facetLocalPartioning array
  36143. * @returns an array of array of numbers
  36144. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36145. */
  36146. getFacetLocalPartitioning(): number[][];
  36147. /**
  36148. * Returns the i-th facet position in the world system.
  36149. * This method allocates a new Vector3 per call
  36150. * @param i defines the facet index
  36151. * @returns a new Vector3
  36152. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36153. */
  36154. getFacetPosition(i: number): Vector3;
  36155. /**
  36156. * Sets the reference Vector3 with the i-th facet position in the world system
  36157. * @param i defines the facet index
  36158. * @param ref defines the target vector
  36159. * @returns the current mesh
  36160. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36161. */
  36162. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36163. /**
  36164. * Returns the i-th facet normal in the world system.
  36165. * This method allocates a new Vector3 per call
  36166. * @param i defines the facet index
  36167. * @returns a new Vector3
  36168. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36169. */
  36170. getFacetNormal(i: number): Vector3;
  36171. /**
  36172. * Sets the reference Vector3 with the i-th facet normal in the world system
  36173. * @param i defines the facet index
  36174. * @param ref defines the target vector
  36175. * @returns the current mesh
  36176. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36177. */
  36178. getFacetNormalToRef(i: number, ref: Vector3): this;
  36179. /**
  36180. * 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)
  36181. * @param x defines x coordinate
  36182. * @param y defines y coordinate
  36183. * @param z defines z coordinate
  36184. * @returns the array of facet indexes
  36185. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36186. */
  36187. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36188. /**
  36189. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36190. * @param projected sets as the (x,y,z) world projection on the facet
  36191. * @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
  36192. * @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
  36193. * @param x defines x coordinate
  36194. * @param y defines y coordinate
  36195. * @param z defines z coordinate
  36196. * @returns the face index if found (or null instead)
  36197. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36198. */
  36199. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36200. /**
  36201. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36202. * @param projected sets as the (x,y,z) local projection on the facet
  36203. * @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
  36204. * @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
  36205. * @param x defines x coordinate
  36206. * @param y defines y coordinate
  36207. * @param z defines z coordinate
  36208. * @returns the face index if found (or null instead)
  36209. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36210. */
  36211. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36212. /**
  36213. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36214. * @returns the parameters
  36215. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36216. */
  36217. getFacetDataParameters(): any;
  36218. /**
  36219. * Disables the feature FacetData and frees the related memory
  36220. * @returns the current mesh
  36221. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36222. */
  36223. disableFacetData(): AbstractMesh;
  36224. /**
  36225. * Updates the AbstractMesh indices array
  36226. * @param indices defines the data source
  36227. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36228. * @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)
  36229. * @returns the current mesh
  36230. */
  36231. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36232. /**
  36233. * Creates new normals data for the mesh
  36234. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36235. * @returns the current mesh
  36236. */
  36237. createNormals(updatable: boolean): AbstractMesh;
  36238. /**
  36239. * Align the mesh with a normal
  36240. * @param normal defines the normal to use
  36241. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36242. * @returns the current mesh
  36243. */
  36244. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  36245. /** @hidden */
  36246. _checkOcclusionQuery(): boolean;
  36247. /**
  36248. * Disables the mesh edge rendering mode
  36249. * @returns the currentAbstractMesh
  36250. */
  36251. disableEdgesRendering(): AbstractMesh;
  36252. /**
  36253. * Enables the edge rendering mode on the mesh.
  36254. * This mode makes the mesh edges visible
  36255. * @param epsilon defines the maximal distance between two angles to detect a face
  36256. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36257. * @returns the currentAbstractMesh
  36258. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36259. */
  36260. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36261. /**
  36262. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  36263. * @returns an array of particle systems in the scene that use the mesh as an emitter
  36264. */
  36265. getConnectedParticleSystems(): IParticleSystem[];
  36266. }
  36267. }
  36268. declare module BABYLON {
  36269. /**
  36270. * Interface used to define ActionEvent
  36271. */
  36272. export interface IActionEvent {
  36273. /** The mesh or sprite that triggered the action */
  36274. source: any;
  36275. /** The X mouse cursor position at the time of the event */
  36276. pointerX: number;
  36277. /** The Y mouse cursor position at the time of the event */
  36278. pointerY: number;
  36279. /** The mesh that is currently pointed at (can be null) */
  36280. meshUnderPointer: Nullable<AbstractMesh>;
  36281. /** the original (browser) event that triggered the ActionEvent */
  36282. sourceEvent?: any;
  36283. /** additional data for the event */
  36284. additionalData?: any;
  36285. }
  36286. /**
  36287. * ActionEvent is the event being sent when an action is triggered.
  36288. */
  36289. export class ActionEvent implements IActionEvent {
  36290. /** The mesh or sprite that triggered the action */
  36291. source: any;
  36292. /** The X mouse cursor position at the time of the event */
  36293. pointerX: number;
  36294. /** The Y mouse cursor position at the time of the event */
  36295. pointerY: number;
  36296. /** The mesh that is currently pointed at (can be null) */
  36297. meshUnderPointer: Nullable<AbstractMesh>;
  36298. /** the original (browser) event that triggered the ActionEvent */
  36299. sourceEvent?: any;
  36300. /** additional data for the event */
  36301. additionalData?: any;
  36302. /**
  36303. * Creates a new ActionEvent
  36304. * @param source The mesh or sprite that triggered the action
  36305. * @param pointerX The X mouse cursor position at the time of the event
  36306. * @param pointerY The Y mouse cursor position at the time of the event
  36307. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36308. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36309. * @param additionalData additional data for the event
  36310. */
  36311. constructor(
  36312. /** The mesh or sprite that triggered the action */
  36313. source: any,
  36314. /** The X mouse cursor position at the time of the event */
  36315. pointerX: number,
  36316. /** The Y mouse cursor position at the time of the event */
  36317. pointerY: number,
  36318. /** The mesh that is currently pointed at (can be null) */
  36319. meshUnderPointer: Nullable<AbstractMesh>,
  36320. /** the original (browser) event that triggered the ActionEvent */
  36321. sourceEvent?: any,
  36322. /** additional data for the event */
  36323. additionalData?: any);
  36324. /**
  36325. * Helper function to auto-create an ActionEvent from a source mesh.
  36326. * @param source The source mesh that triggered the event
  36327. * @param evt The original (browser) event
  36328. * @param additionalData additional data for the event
  36329. * @returns the new ActionEvent
  36330. */
  36331. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36332. /**
  36333. * Helper function to auto-create an ActionEvent from a source sprite
  36334. * @param source The source sprite that triggered the event
  36335. * @param scene Scene associated with the sprite
  36336. * @param evt The original (browser) event
  36337. * @param additionalData additional data for the event
  36338. * @returns the new ActionEvent
  36339. */
  36340. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36341. /**
  36342. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36343. * @param scene the scene where the event occurred
  36344. * @param evt The original (browser) event
  36345. * @returns the new ActionEvent
  36346. */
  36347. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36348. /**
  36349. * Helper function to auto-create an ActionEvent from a primitive
  36350. * @param prim defines the target primitive
  36351. * @param pointerPos defines the pointer position
  36352. * @param evt The original (browser) event
  36353. * @param additionalData additional data for the event
  36354. * @returns the new ActionEvent
  36355. */
  36356. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36357. }
  36358. }
  36359. declare module BABYLON {
  36360. /**
  36361. * Abstract class used to decouple action Manager from scene and meshes.
  36362. * Do not instantiate.
  36363. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36364. */
  36365. export abstract class AbstractActionManager implements IDisposable {
  36366. /** Gets the list of active triggers */
  36367. static Triggers: {
  36368. [key: string]: number;
  36369. };
  36370. /** Gets the cursor to use when hovering items */
  36371. hoverCursor: string;
  36372. /** Gets the list of actions */
  36373. actions: IAction[];
  36374. /**
  36375. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36376. */
  36377. isRecursive: boolean;
  36378. /**
  36379. * Releases all associated resources
  36380. */
  36381. abstract dispose(): void;
  36382. /**
  36383. * Does this action manager has pointer triggers
  36384. */
  36385. abstract get hasPointerTriggers(): boolean;
  36386. /**
  36387. * Does this action manager has pick triggers
  36388. */
  36389. abstract get hasPickTriggers(): boolean;
  36390. /**
  36391. * Process a specific trigger
  36392. * @param trigger defines the trigger to process
  36393. * @param evt defines the event details to be processed
  36394. */
  36395. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36396. /**
  36397. * Does this action manager handles actions of any of the given triggers
  36398. * @param triggers defines the triggers to be tested
  36399. * @return a boolean indicating whether one (or more) of the triggers is handled
  36400. */
  36401. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36402. /**
  36403. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36404. * speed.
  36405. * @param triggerA defines the trigger to be tested
  36406. * @param triggerB defines the trigger to be tested
  36407. * @return a boolean indicating whether one (or more) of the triggers is handled
  36408. */
  36409. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36410. /**
  36411. * Does this action manager handles actions of a given trigger
  36412. * @param trigger defines the trigger to be tested
  36413. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36414. * @return whether the trigger is handled
  36415. */
  36416. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36417. /**
  36418. * Serialize this manager to a JSON object
  36419. * @param name defines the property name to store this manager
  36420. * @returns a JSON representation of this manager
  36421. */
  36422. abstract serialize(name: string): any;
  36423. /**
  36424. * Registers an action to this action manager
  36425. * @param action defines the action to be registered
  36426. * @return the action amended (prepared) after registration
  36427. */
  36428. abstract registerAction(action: IAction): Nullable<IAction>;
  36429. /**
  36430. * Unregisters an action to this action manager
  36431. * @param action defines the action to be unregistered
  36432. * @return a boolean indicating whether the action has been unregistered
  36433. */
  36434. abstract unregisterAction(action: IAction): Boolean;
  36435. /**
  36436. * Does exist one action manager with at least one trigger
  36437. **/
  36438. static get HasTriggers(): boolean;
  36439. /**
  36440. * Does exist one action manager with at least one pick trigger
  36441. **/
  36442. static get HasPickTriggers(): boolean;
  36443. /**
  36444. * Does exist one action manager that handles actions of a given trigger
  36445. * @param trigger defines the trigger to be tested
  36446. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36447. **/
  36448. static HasSpecificTrigger(trigger: number): boolean;
  36449. }
  36450. }
  36451. declare module BABYLON {
  36452. /**
  36453. * Defines how a node can be built from a string name.
  36454. */
  36455. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36456. /**
  36457. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36458. */
  36459. export class Node implements IBehaviorAware<Node> {
  36460. /** @hidden */
  36461. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36462. private static _NodeConstructors;
  36463. /**
  36464. * Add a new node constructor
  36465. * @param type defines the type name of the node to construct
  36466. * @param constructorFunc defines the constructor function
  36467. */
  36468. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36469. /**
  36470. * Returns a node constructor based on type name
  36471. * @param type defines the type name
  36472. * @param name defines the new node name
  36473. * @param scene defines the hosting scene
  36474. * @param options defines optional options to transmit to constructors
  36475. * @returns the new constructor or null
  36476. */
  36477. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36478. /**
  36479. * Gets or sets the name of the node
  36480. */
  36481. name: string;
  36482. /**
  36483. * Gets or sets the id of the node
  36484. */
  36485. id: string;
  36486. /**
  36487. * Gets or sets the unique id of the node
  36488. */
  36489. uniqueId: number;
  36490. /**
  36491. * Gets or sets a string used to store user defined state for the node
  36492. */
  36493. state: string;
  36494. /**
  36495. * Gets or sets an object used to store user defined information for the node
  36496. */
  36497. metadata: any;
  36498. /**
  36499. * For internal use only. Please do not use.
  36500. */
  36501. reservedDataStore: any;
  36502. /**
  36503. * List of inspectable custom properties (used by the Inspector)
  36504. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36505. */
  36506. inspectableCustomProperties: IInspectable[];
  36507. private _doNotSerialize;
  36508. /**
  36509. * Gets or sets a boolean used to define if the node must be serialized
  36510. */
  36511. get doNotSerialize(): boolean;
  36512. set doNotSerialize(value: boolean);
  36513. /** @hidden */
  36514. _isDisposed: boolean;
  36515. /**
  36516. * Gets a list of Animations associated with the node
  36517. */
  36518. animations: Animation[];
  36519. protected _ranges: {
  36520. [name: string]: Nullable<AnimationRange>;
  36521. };
  36522. /**
  36523. * Callback raised when the node is ready to be used
  36524. */
  36525. onReady: Nullable<(node: Node) => void>;
  36526. private _isEnabled;
  36527. private _isParentEnabled;
  36528. private _isReady;
  36529. /** @hidden */
  36530. _currentRenderId: number;
  36531. private _parentUpdateId;
  36532. /** @hidden */
  36533. _childUpdateId: number;
  36534. /** @hidden */
  36535. _waitingParentId: Nullable<string>;
  36536. /** @hidden */
  36537. _scene: Scene;
  36538. /** @hidden */
  36539. _cache: any;
  36540. private _parentNode;
  36541. private _children;
  36542. /** @hidden */
  36543. _worldMatrix: Matrix;
  36544. /** @hidden */
  36545. _worldMatrixDeterminant: number;
  36546. /** @hidden */
  36547. _worldMatrixDeterminantIsDirty: boolean;
  36548. /** @hidden */
  36549. private _sceneRootNodesIndex;
  36550. /**
  36551. * Gets a boolean indicating if the node has been disposed
  36552. * @returns true if the node was disposed
  36553. */
  36554. isDisposed(): boolean;
  36555. /**
  36556. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36557. * @see https://doc.babylonjs.com/how_to/parenting
  36558. */
  36559. set parent(parent: Nullable<Node>);
  36560. get parent(): Nullable<Node>;
  36561. /** @hidden */
  36562. _addToSceneRootNodes(): void;
  36563. /** @hidden */
  36564. _removeFromSceneRootNodes(): void;
  36565. private _animationPropertiesOverride;
  36566. /**
  36567. * Gets or sets the animation properties override
  36568. */
  36569. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36570. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36571. /**
  36572. * Gets a string identifying the name of the class
  36573. * @returns "Node" string
  36574. */
  36575. getClassName(): string;
  36576. /** @hidden */
  36577. readonly _isNode: boolean;
  36578. /**
  36579. * An event triggered when the mesh is disposed
  36580. */
  36581. onDisposeObservable: Observable<Node>;
  36582. private _onDisposeObserver;
  36583. /**
  36584. * Sets a callback that will be raised when the node will be disposed
  36585. */
  36586. set onDispose(callback: () => void);
  36587. /**
  36588. * Creates a new Node
  36589. * @param name the name and id to be given to this node
  36590. * @param scene the scene this node will be added to
  36591. */
  36592. constructor(name: string, scene?: Nullable<Scene>);
  36593. /**
  36594. * Gets the scene of the node
  36595. * @returns a scene
  36596. */
  36597. getScene(): Scene;
  36598. /**
  36599. * Gets the engine of the node
  36600. * @returns a Engine
  36601. */
  36602. getEngine(): Engine;
  36603. private _behaviors;
  36604. /**
  36605. * Attach a behavior to the node
  36606. * @see https://doc.babylonjs.com/features/behaviour
  36607. * @param behavior defines the behavior to attach
  36608. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36609. * @returns the current Node
  36610. */
  36611. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36612. /**
  36613. * Remove an attached behavior
  36614. * @see https://doc.babylonjs.com/features/behaviour
  36615. * @param behavior defines the behavior to attach
  36616. * @returns the current Node
  36617. */
  36618. removeBehavior(behavior: Behavior<Node>): Node;
  36619. /**
  36620. * Gets the list of attached behaviors
  36621. * @see https://doc.babylonjs.com/features/behaviour
  36622. */
  36623. get behaviors(): Behavior<Node>[];
  36624. /**
  36625. * Gets an attached behavior by name
  36626. * @param name defines the name of the behavior to look for
  36627. * @see https://doc.babylonjs.com/features/behaviour
  36628. * @returns null if behavior was not found else the requested behavior
  36629. */
  36630. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36631. /**
  36632. * Returns the latest update of the World matrix
  36633. * @returns a Matrix
  36634. */
  36635. getWorldMatrix(): Matrix;
  36636. /** @hidden */
  36637. _getWorldMatrixDeterminant(): number;
  36638. /**
  36639. * Returns directly the latest state of the mesh World matrix.
  36640. * A Matrix is returned.
  36641. */
  36642. get worldMatrixFromCache(): Matrix;
  36643. /** @hidden */
  36644. _initCache(): void;
  36645. /** @hidden */
  36646. updateCache(force?: boolean): void;
  36647. /** @hidden */
  36648. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36649. /** @hidden */
  36650. _updateCache(ignoreParentClass?: boolean): void;
  36651. /** @hidden */
  36652. _isSynchronized(): boolean;
  36653. /** @hidden */
  36654. _markSyncedWithParent(): void;
  36655. /** @hidden */
  36656. isSynchronizedWithParent(): boolean;
  36657. /** @hidden */
  36658. isSynchronized(): boolean;
  36659. /**
  36660. * Is this node ready to be used/rendered
  36661. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36662. * @return true if the node is ready
  36663. */
  36664. isReady(completeCheck?: boolean): boolean;
  36665. /**
  36666. * Is this node enabled?
  36667. * 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
  36668. * @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
  36669. * @return whether this node (and its parent) is enabled
  36670. */
  36671. isEnabled(checkAncestors?: boolean): boolean;
  36672. /** @hidden */
  36673. protected _syncParentEnabledState(): void;
  36674. /**
  36675. * Set the enabled state of this node
  36676. * @param value defines the new enabled state
  36677. */
  36678. setEnabled(value: boolean): void;
  36679. /**
  36680. * Is this node a descendant of the given node?
  36681. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36682. * @param ancestor defines the parent node to inspect
  36683. * @returns a boolean indicating if this node is a descendant of the given node
  36684. */
  36685. isDescendantOf(ancestor: Node): boolean;
  36686. /** @hidden */
  36687. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36688. /**
  36689. * Will return all nodes that have this node as ascendant
  36690. * @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
  36691. * @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
  36692. * @return all children nodes of all types
  36693. */
  36694. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36695. /**
  36696. * Get all child-meshes of this node
  36697. * @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)
  36698. * @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
  36699. * @returns an array of AbstractMesh
  36700. */
  36701. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36702. /**
  36703. * Get all direct children of this node
  36704. * @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
  36705. * @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)
  36706. * @returns an array of Node
  36707. */
  36708. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36709. /** @hidden */
  36710. _setReady(state: boolean): void;
  36711. /**
  36712. * Get an animation by name
  36713. * @param name defines the name of the animation to look for
  36714. * @returns null if not found else the requested animation
  36715. */
  36716. getAnimationByName(name: string): Nullable<Animation>;
  36717. /**
  36718. * Creates an animation range for this node
  36719. * @param name defines the name of the range
  36720. * @param from defines the starting key
  36721. * @param to defines the end key
  36722. */
  36723. createAnimationRange(name: string, from: number, to: number): void;
  36724. /**
  36725. * Delete a specific animation range
  36726. * @param name defines the name of the range to delete
  36727. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36728. */
  36729. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36730. /**
  36731. * Get an animation range by name
  36732. * @param name defines the name of the animation range to look for
  36733. * @returns null if not found else the requested animation range
  36734. */
  36735. getAnimationRange(name: string): Nullable<AnimationRange>;
  36736. /**
  36737. * Gets the list of all animation ranges defined on this node
  36738. * @returns an array
  36739. */
  36740. getAnimationRanges(): Nullable<AnimationRange>[];
  36741. /**
  36742. * Will start the animation sequence
  36743. * @param name defines the range frames for animation sequence
  36744. * @param loop defines if the animation should loop (false by default)
  36745. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36746. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36747. * @returns the object created for this animation. If range does not exist, it will return null
  36748. */
  36749. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36750. /**
  36751. * Serialize animation ranges into a JSON compatible object
  36752. * @returns serialization object
  36753. */
  36754. serializeAnimationRanges(): any;
  36755. /**
  36756. * Computes the world matrix of the node
  36757. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36758. * @returns the world matrix
  36759. */
  36760. computeWorldMatrix(force?: boolean): Matrix;
  36761. /**
  36762. * Releases resources associated with this node.
  36763. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36764. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36765. */
  36766. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36767. /**
  36768. * Parse animation range data from a serialization object and store them into a given node
  36769. * @param node defines where to store the animation ranges
  36770. * @param parsedNode defines the serialization object to read data from
  36771. * @param scene defines the hosting scene
  36772. */
  36773. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36774. /**
  36775. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36776. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36777. * @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
  36778. * @returns the new bounding vectors
  36779. */
  36780. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36781. min: Vector3;
  36782. max: Vector3;
  36783. };
  36784. }
  36785. }
  36786. declare module BABYLON {
  36787. /**
  36788. * @hidden
  36789. */
  36790. export class _IAnimationState {
  36791. key: number;
  36792. repeatCount: number;
  36793. workValue?: any;
  36794. loopMode?: number;
  36795. offsetValue?: any;
  36796. highLimitValue?: any;
  36797. }
  36798. /**
  36799. * Class used to store any kind of animation
  36800. */
  36801. export class Animation {
  36802. /**Name of the animation */
  36803. name: string;
  36804. /**Property to animate */
  36805. targetProperty: string;
  36806. /**The frames per second of the animation */
  36807. framePerSecond: number;
  36808. /**The data type of the animation */
  36809. dataType: number;
  36810. /**The loop mode of the animation */
  36811. loopMode?: number | undefined;
  36812. /**Specifies if blending should be enabled */
  36813. enableBlending?: boolean | undefined;
  36814. /**
  36815. * Use matrix interpolation instead of using direct key value when animating matrices
  36816. */
  36817. static AllowMatricesInterpolation: boolean;
  36818. /**
  36819. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36820. */
  36821. static AllowMatrixDecomposeForInterpolation: boolean;
  36822. /** Define the Url to load snippets */
  36823. static SnippetUrl: string;
  36824. /** Snippet ID if the animation was created from the snippet server */
  36825. snippetId: string;
  36826. /**
  36827. * Stores the key frames of the animation
  36828. */
  36829. private _keys;
  36830. /**
  36831. * Stores the easing function of the animation
  36832. */
  36833. private _easingFunction;
  36834. /**
  36835. * @hidden Internal use only
  36836. */
  36837. _runtimeAnimations: RuntimeAnimation[];
  36838. /**
  36839. * The set of event that will be linked to this animation
  36840. */
  36841. private _events;
  36842. /**
  36843. * Stores an array of target property paths
  36844. */
  36845. targetPropertyPath: string[];
  36846. /**
  36847. * Stores the blending speed of the animation
  36848. */
  36849. blendingSpeed: number;
  36850. /**
  36851. * Stores the animation ranges for the animation
  36852. */
  36853. private _ranges;
  36854. /**
  36855. * @hidden Internal use
  36856. */
  36857. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36858. /**
  36859. * Sets up an animation
  36860. * @param property The property to animate
  36861. * @param animationType The animation type to apply
  36862. * @param framePerSecond The frames per second of the animation
  36863. * @param easingFunction The easing function used in the animation
  36864. * @returns The created animation
  36865. */
  36866. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36867. /**
  36868. * Create and start an animation on a node
  36869. * @param name defines the name of the global animation that will be run on all nodes
  36870. * @param node defines the root node where the animation will take place
  36871. * @param targetProperty defines property to animate
  36872. * @param framePerSecond defines the number of frame per second yo use
  36873. * @param totalFrame defines the number of frames in total
  36874. * @param from defines the initial value
  36875. * @param to defines the final value
  36876. * @param loopMode defines which loop mode you want to use (off by default)
  36877. * @param easingFunction defines the easing function to use (linear by default)
  36878. * @param onAnimationEnd defines the callback to call when animation end
  36879. * @returns the animatable created for this animation
  36880. */
  36881. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36882. /**
  36883. * Create and start an animation on a node and its descendants
  36884. * @param name defines the name of the global animation that will be run on all nodes
  36885. * @param node defines the root node where the animation will take place
  36886. * @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
  36887. * @param targetProperty defines property to animate
  36888. * @param framePerSecond defines the number of frame per second to use
  36889. * @param totalFrame defines the number of frames in total
  36890. * @param from defines the initial value
  36891. * @param to defines the final value
  36892. * @param loopMode defines which loop mode you want to use (off by default)
  36893. * @param easingFunction defines the easing function to use (linear by default)
  36894. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36895. * @returns the list of animatables created for all nodes
  36896. * @example https://www.babylonjs-playground.com/#MH0VLI
  36897. */
  36898. 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[]>;
  36899. /**
  36900. * Creates a new animation, merges it with the existing animations and starts it
  36901. * @param name Name of the animation
  36902. * @param node Node which contains the scene that begins the animations
  36903. * @param targetProperty Specifies which property to animate
  36904. * @param framePerSecond The frames per second of the animation
  36905. * @param totalFrame The total number of frames
  36906. * @param from The frame at the beginning of the animation
  36907. * @param to The frame at the end of the animation
  36908. * @param loopMode Specifies the loop mode of the animation
  36909. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36910. * @param onAnimationEnd Callback to run once the animation is complete
  36911. * @returns Nullable animation
  36912. */
  36913. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36914. /**
  36915. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36916. * @param sourceAnimation defines the Animation containing keyframes to convert
  36917. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36918. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36919. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36920. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36921. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36922. */
  36923. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36924. /**
  36925. * Transition property of an host to the target Value
  36926. * @param property The property to transition
  36927. * @param targetValue The target Value of the property
  36928. * @param host The object where the property to animate belongs
  36929. * @param scene Scene used to run the animation
  36930. * @param frameRate Framerate (in frame/s) to use
  36931. * @param transition The transition type we want to use
  36932. * @param duration The duration of the animation, in milliseconds
  36933. * @param onAnimationEnd Callback trigger at the end of the animation
  36934. * @returns Nullable animation
  36935. */
  36936. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36937. /**
  36938. * Return the array of runtime animations currently using this animation
  36939. */
  36940. get runtimeAnimations(): RuntimeAnimation[];
  36941. /**
  36942. * Specifies if any of the runtime animations are currently running
  36943. */
  36944. get hasRunningRuntimeAnimations(): boolean;
  36945. /**
  36946. * Initializes the animation
  36947. * @param name Name of the animation
  36948. * @param targetProperty Property to animate
  36949. * @param framePerSecond The frames per second of the animation
  36950. * @param dataType The data type of the animation
  36951. * @param loopMode The loop mode of the animation
  36952. * @param enableBlending Specifies if blending should be enabled
  36953. */
  36954. constructor(
  36955. /**Name of the animation */
  36956. name: string,
  36957. /**Property to animate */
  36958. targetProperty: string,
  36959. /**The frames per second of the animation */
  36960. framePerSecond: number,
  36961. /**The data type of the animation */
  36962. dataType: number,
  36963. /**The loop mode of the animation */
  36964. loopMode?: number | undefined,
  36965. /**Specifies if blending should be enabled */
  36966. enableBlending?: boolean | undefined);
  36967. /**
  36968. * Converts the animation to a string
  36969. * @param fullDetails support for multiple levels of logging within scene loading
  36970. * @returns String form of the animation
  36971. */
  36972. toString(fullDetails?: boolean): string;
  36973. /**
  36974. * Add an event to this animation
  36975. * @param event Event to add
  36976. */
  36977. addEvent(event: AnimationEvent): void;
  36978. /**
  36979. * Remove all events found at the given frame
  36980. * @param frame The frame to remove events from
  36981. */
  36982. removeEvents(frame: number): void;
  36983. /**
  36984. * Retrieves all the events from the animation
  36985. * @returns Events from the animation
  36986. */
  36987. getEvents(): AnimationEvent[];
  36988. /**
  36989. * Creates an animation range
  36990. * @param name Name of the animation range
  36991. * @param from Starting frame of the animation range
  36992. * @param to Ending frame of the animation
  36993. */
  36994. createRange(name: string, from: number, to: number): void;
  36995. /**
  36996. * Deletes an animation range by name
  36997. * @param name Name of the animation range to delete
  36998. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36999. */
  37000. deleteRange(name: string, deleteFrames?: boolean): void;
  37001. /**
  37002. * Gets the animation range by name, or null if not defined
  37003. * @param name Name of the animation range
  37004. * @returns Nullable animation range
  37005. */
  37006. getRange(name: string): Nullable<AnimationRange>;
  37007. /**
  37008. * Gets the key frames from the animation
  37009. * @returns The key frames of the animation
  37010. */
  37011. getKeys(): Array<IAnimationKey>;
  37012. /**
  37013. * Gets the highest frame rate of the animation
  37014. * @returns Highest frame rate of the animation
  37015. */
  37016. getHighestFrame(): number;
  37017. /**
  37018. * Gets the easing function of the animation
  37019. * @returns Easing function of the animation
  37020. */
  37021. getEasingFunction(): IEasingFunction;
  37022. /**
  37023. * Sets the easing function of the animation
  37024. * @param easingFunction A custom mathematical formula for animation
  37025. */
  37026. setEasingFunction(easingFunction: EasingFunction): void;
  37027. /**
  37028. * Interpolates a scalar linearly
  37029. * @param startValue Start value of the animation curve
  37030. * @param endValue End value of the animation curve
  37031. * @param gradient Scalar amount to interpolate
  37032. * @returns Interpolated scalar value
  37033. */
  37034. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37035. /**
  37036. * Interpolates a scalar cubically
  37037. * @param startValue Start value of the animation curve
  37038. * @param outTangent End tangent of the animation
  37039. * @param endValue End value of the animation curve
  37040. * @param inTangent Start tangent of the animation curve
  37041. * @param gradient Scalar amount to interpolate
  37042. * @returns Interpolated scalar value
  37043. */
  37044. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37045. /**
  37046. * Interpolates a quaternion using a spherical linear interpolation
  37047. * @param startValue Start value of the animation curve
  37048. * @param endValue End value of the animation curve
  37049. * @param gradient Scalar amount to interpolate
  37050. * @returns Interpolated quaternion value
  37051. */
  37052. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37053. /**
  37054. * Interpolates a quaternion cubically
  37055. * @param startValue Start value of the animation curve
  37056. * @param outTangent End tangent of the animation curve
  37057. * @param endValue End value of the animation curve
  37058. * @param inTangent Start tangent of the animation curve
  37059. * @param gradient Scalar amount to interpolate
  37060. * @returns Interpolated quaternion value
  37061. */
  37062. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37063. /**
  37064. * Interpolates a Vector3 linearl
  37065. * @param startValue Start value of the animation curve
  37066. * @param endValue End value of the animation curve
  37067. * @param gradient Scalar amount to interpolate
  37068. * @returns Interpolated scalar value
  37069. */
  37070. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37071. /**
  37072. * Interpolates a Vector3 cubically
  37073. * @param startValue Start value of the animation curve
  37074. * @param outTangent End tangent of the animation
  37075. * @param endValue End value of the animation curve
  37076. * @param inTangent Start tangent of the animation curve
  37077. * @param gradient Scalar amount to interpolate
  37078. * @returns InterpolatedVector3 value
  37079. */
  37080. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37081. /**
  37082. * Interpolates a Vector2 linearly
  37083. * @param startValue Start value of the animation curve
  37084. * @param endValue End value of the animation curve
  37085. * @param gradient Scalar amount to interpolate
  37086. * @returns Interpolated Vector2 value
  37087. */
  37088. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37089. /**
  37090. * Interpolates a Vector2 cubically
  37091. * @param startValue Start value of the animation curve
  37092. * @param outTangent End tangent of the animation
  37093. * @param endValue End value of the animation curve
  37094. * @param inTangent Start tangent of the animation curve
  37095. * @param gradient Scalar amount to interpolate
  37096. * @returns Interpolated Vector2 value
  37097. */
  37098. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37099. /**
  37100. * Interpolates a size linearly
  37101. * @param startValue Start value of the animation curve
  37102. * @param endValue End value of the animation curve
  37103. * @param gradient Scalar amount to interpolate
  37104. * @returns Interpolated Size value
  37105. */
  37106. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37107. /**
  37108. * Interpolates a Color3 linearly
  37109. * @param startValue Start value of the animation curve
  37110. * @param endValue End value of the animation curve
  37111. * @param gradient Scalar amount to interpolate
  37112. * @returns Interpolated Color3 value
  37113. */
  37114. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37115. /**
  37116. * Interpolates a Color4 linearly
  37117. * @param startValue Start value of the animation curve
  37118. * @param endValue End value of the animation curve
  37119. * @param gradient Scalar amount to interpolate
  37120. * @returns Interpolated Color3 value
  37121. */
  37122. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37123. /**
  37124. * @hidden Internal use only
  37125. */
  37126. _getKeyValue(value: any): any;
  37127. /**
  37128. * @hidden Internal use only
  37129. */
  37130. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37131. /**
  37132. * Defines the function to use to interpolate matrices
  37133. * @param startValue defines the start matrix
  37134. * @param endValue defines the end matrix
  37135. * @param gradient defines the gradient between both matrices
  37136. * @param result defines an optional target matrix where to store the interpolation
  37137. * @returns the interpolated matrix
  37138. */
  37139. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37140. /**
  37141. * Makes a copy of the animation
  37142. * @returns Cloned animation
  37143. */
  37144. clone(): Animation;
  37145. /**
  37146. * Sets the key frames of the animation
  37147. * @param values The animation key frames to set
  37148. */
  37149. setKeys(values: Array<IAnimationKey>): void;
  37150. /**
  37151. * Serializes the animation to an object
  37152. * @returns Serialized object
  37153. */
  37154. serialize(): any;
  37155. /**
  37156. * Float animation type
  37157. */
  37158. static readonly ANIMATIONTYPE_FLOAT: number;
  37159. /**
  37160. * Vector3 animation type
  37161. */
  37162. static readonly ANIMATIONTYPE_VECTOR3: number;
  37163. /**
  37164. * Quaternion animation type
  37165. */
  37166. static readonly ANIMATIONTYPE_QUATERNION: number;
  37167. /**
  37168. * Matrix animation type
  37169. */
  37170. static readonly ANIMATIONTYPE_MATRIX: number;
  37171. /**
  37172. * Color3 animation type
  37173. */
  37174. static readonly ANIMATIONTYPE_COLOR3: number;
  37175. /**
  37176. * Color3 animation type
  37177. */
  37178. static readonly ANIMATIONTYPE_COLOR4: number;
  37179. /**
  37180. * Vector2 animation type
  37181. */
  37182. static readonly ANIMATIONTYPE_VECTOR2: number;
  37183. /**
  37184. * Size animation type
  37185. */
  37186. static readonly ANIMATIONTYPE_SIZE: number;
  37187. /**
  37188. * Relative Loop Mode
  37189. */
  37190. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37191. /**
  37192. * Cycle Loop Mode
  37193. */
  37194. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37195. /**
  37196. * Constant Loop Mode
  37197. */
  37198. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37199. /** @hidden */
  37200. static _UniversalLerp(left: any, right: any, amount: number): any;
  37201. /**
  37202. * Parses an animation object and creates an animation
  37203. * @param parsedAnimation Parsed animation object
  37204. * @returns Animation object
  37205. */
  37206. static Parse(parsedAnimation: any): Animation;
  37207. /**
  37208. * Appends the serialized animations from the source animations
  37209. * @param source Source containing the animations
  37210. * @param destination Target to store the animations
  37211. */
  37212. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37213. /**
  37214. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37215. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37216. * @param url defines the url to load from
  37217. * @returns a promise that will resolve to the new animation or an array of animations
  37218. */
  37219. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37220. /**
  37221. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37222. * @param snippetId defines the snippet to load
  37223. * @returns a promise that will resolve to the new animation or a new array of animations
  37224. */
  37225. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37226. }
  37227. }
  37228. declare module BABYLON {
  37229. /**
  37230. * Interface containing an array of animations
  37231. */
  37232. export interface IAnimatable {
  37233. /**
  37234. * Array of animations
  37235. */
  37236. animations: Nullable<Array<Animation>>;
  37237. }
  37238. }
  37239. declare module BABYLON {
  37240. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37241. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37242. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37243. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37244. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37245. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37246. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37247. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37248. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37249. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37250. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37251. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37252. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37253. /**
  37254. * Decorator used to define property that can be serialized as reference to a camera
  37255. * @param sourceName defines the name of the property to decorate
  37256. */
  37257. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37258. /**
  37259. * Class used to help serialization objects
  37260. */
  37261. export class SerializationHelper {
  37262. /** @hidden */
  37263. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  37264. /** @hidden */
  37265. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  37266. /** @hidden */
  37267. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  37268. /** @hidden */
  37269. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  37270. /**
  37271. * Appends the serialized animations from the source animations
  37272. * @param source Source containing the animations
  37273. * @param destination Target to store the animations
  37274. */
  37275. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37276. /**
  37277. * Static function used to serialized a specific entity
  37278. * @param entity defines the entity to serialize
  37279. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37280. * @returns a JSON compatible object representing the serialization of the entity
  37281. */
  37282. static Serialize<T>(entity: T, serializationObject?: any): any;
  37283. /**
  37284. * Creates a new entity from a serialization data object
  37285. * @param creationFunction defines a function used to instanciated the new entity
  37286. * @param source defines the source serialization data
  37287. * @param scene defines the hosting scene
  37288. * @param rootUrl defines the root url for resources
  37289. * @returns a new entity
  37290. */
  37291. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37292. /**
  37293. * Clones an object
  37294. * @param creationFunction defines the function used to instanciate the new object
  37295. * @param source defines the source object
  37296. * @returns the cloned object
  37297. */
  37298. static Clone<T>(creationFunction: () => T, source: T): T;
  37299. /**
  37300. * Instanciates a new object based on a source one (some data will be shared between both object)
  37301. * @param creationFunction defines the function used to instanciate the new object
  37302. * @param source defines the source object
  37303. * @returns the new object
  37304. */
  37305. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37306. }
  37307. }
  37308. declare module BABYLON {
  37309. /**
  37310. * Base class of all the textures in babylon.
  37311. * It groups all the common properties the materials, post process, lights... might need
  37312. * in order to make a correct use of the texture.
  37313. */
  37314. export class BaseTexture implements IAnimatable {
  37315. /**
  37316. * Default anisotropic filtering level for the application.
  37317. * It is set to 4 as a good tradeoff between perf and quality.
  37318. */
  37319. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  37320. /**
  37321. * Gets or sets the unique id of the texture
  37322. */
  37323. uniqueId: number;
  37324. /**
  37325. * Define the name of the texture.
  37326. */
  37327. name: string;
  37328. /**
  37329. * Gets or sets an object used to store user defined information.
  37330. */
  37331. metadata: any;
  37332. /**
  37333. * For internal use only. Please do not use.
  37334. */
  37335. reservedDataStore: any;
  37336. private _hasAlpha;
  37337. /**
  37338. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  37339. */
  37340. set hasAlpha(value: boolean);
  37341. get hasAlpha(): boolean;
  37342. /**
  37343. * Defines if the alpha value should be determined via the rgb values.
  37344. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  37345. */
  37346. getAlphaFromRGB: boolean;
  37347. /**
  37348. * Intensity or strength of the texture.
  37349. * It is commonly used by materials to fine tune the intensity of the texture
  37350. */
  37351. level: number;
  37352. /**
  37353. * Define the UV chanel to use starting from 0 and defaulting to 0.
  37354. * This is part of the texture as textures usually maps to one uv set.
  37355. */
  37356. coordinatesIndex: number;
  37357. protected _coordinatesMode: number;
  37358. /**
  37359. * How a texture is mapped.
  37360. *
  37361. * | Value | Type | Description |
  37362. * | ----- | ----------------------------------- | ----------- |
  37363. * | 0 | EXPLICIT_MODE | |
  37364. * | 1 | SPHERICAL_MODE | |
  37365. * | 2 | PLANAR_MODE | |
  37366. * | 3 | CUBIC_MODE | |
  37367. * | 4 | PROJECTION_MODE | |
  37368. * | 5 | SKYBOX_MODE | |
  37369. * | 6 | INVCUBIC_MODE | |
  37370. * | 7 | EQUIRECTANGULAR_MODE | |
  37371. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  37372. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  37373. */
  37374. set coordinatesMode(value: number);
  37375. get coordinatesMode(): number;
  37376. private _wrapU;
  37377. /**
  37378. * | Value | Type | Description |
  37379. * | ----- | ------------------ | ----------- |
  37380. * | 0 | CLAMP_ADDRESSMODE | |
  37381. * | 1 | WRAP_ADDRESSMODE | |
  37382. * | 2 | MIRROR_ADDRESSMODE | |
  37383. */
  37384. get wrapU(): number;
  37385. set wrapU(value: number);
  37386. private _wrapV;
  37387. /**
  37388. * | Value | Type | Description |
  37389. * | ----- | ------------------ | ----------- |
  37390. * | 0 | CLAMP_ADDRESSMODE | |
  37391. * | 1 | WRAP_ADDRESSMODE | |
  37392. * | 2 | MIRROR_ADDRESSMODE | |
  37393. */
  37394. get wrapV(): number;
  37395. set wrapV(value: number);
  37396. /**
  37397. * | Value | Type | Description |
  37398. * | ----- | ------------------ | ----------- |
  37399. * | 0 | CLAMP_ADDRESSMODE | |
  37400. * | 1 | WRAP_ADDRESSMODE | |
  37401. * | 2 | MIRROR_ADDRESSMODE | |
  37402. */
  37403. wrapR: number;
  37404. /**
  37405. * With compliant hardware and browser (supporting anisotropic filtering)
  37406. * this defines the level of anisotropic filtering in the texture.
  37407. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  37408. */
  37409. anisotropicFilteringLevel: number;
  37410. /**
  37411. * Define if the texture is a cube texture or if false a 2d texture.
  37412. */
  37413. get isCube(): boolean;
  37414. set isCube(value: boolean);
  37415. /**
  37416. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  37417. */
  37418. get is3D(): boolean;
  37419. set is3D(value: boolean);
  37420. /**
  37421. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  37422. */
  37423. get is2DArray(): boolean;
  37424. set is2DArray(value: boolean);
  37425. private _gammaSpace;
  37426. /**
  37427. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  37428. * HDR texture are usually stored in linear space.
  37429. * This only impacts the PBR and Background materials
  37430. */
  37431. get gammaSpace(): boolean;
  37432. set gammaSpace(gamma: boolean);
  37433. /**
  37434. * Gets or sets whether or not the texture contains RGBD data.
  37435. */
  37436. get isRGBD(): boolean;
  37437. set isRGBD(value: boolean);
  37438. /**
  37439. * Is Z inverted in the texture (useful in a cube texture).
  37440. */
  37441. invertZ: boolean;
  37442. /**
  37443. * Are mip maps generated for this texture or not.
  37444. */
  37445. get noMipmap(): boolean;
  37446. /**
  37447. * @hidden
  37448. */
  37449. lodLevelInAlpha: boolean;
  37450. /**
  37451. * With prefiltered texture, defined the offset used during the prefiltering steps.
  37452. */
  37453. get lodGenerationOffset(): number;
  37454. set lodGenerationOffset(value: number);
  37455. /**
  37456. * With prefiltered texture, defined the scale used during the prefiltering steps.
  37457. */
  37458. get lodGenerationScale(): number;
  37459. set lodGenerationScale(value: number);
  37460. /**
  37461. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  37462. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  37463. * average roughness values.
  37464. */
  37465. get linearSpecularLOD(): boolean;
  37466. set linearSpecularLOD(value: boolean);
  37467. /**
  37468. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  37469. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  37470. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  37471. */
  37472. get irradianceTexture(): Nullable<BaseTexture>;
  37473. set irradianceTexture(value: Nullable<BaseTexture>);
  37474. /**
  37475. * Define if the texture is a render target.
  37476. */
  37477. isRenderTarget: boolean;
  37478. /**
  37479. * Define the unique id of the texture in the scene.
  37480. */
  37481. get uid(): string;
  37482. /** @hidden */
  37483. _prefiltered: boolean;
  37484. /**
  37485. * Return a string representation of the texture.
  37486. * @returns the texture as a string
  37487. */
  37488. toString(): string;
  37489. /**
  37490. * Get the class name of the texture.
  37491. * @returns "BaseTexture"
  37492. */
  37493. getClassName(): string;
  37494. /**
  37495. * Define the list of animation attached to the texture.
  37496. */
  37497. animations: Animation[];
  37498. /**
  37499. * An event triggered when the texture is disposed.
  37500. */
  37501. onDisposeObservable: Observable<BaseTexture>;
  37502. private _onDisposeObserver;
  37503. /**
  37504. * Callback triggered when the texture has been disposed.
  37505. * Kept for back compatibility, you can use the onDisposeObservable instead.
  37506. */
  37507. set onDispose(callback: () => void);
  37508. /**
  37509. * Define the current state of the loading sequence when in delayed load mode.
  37510. */
  37511. delayLoadState: number;
  37512. protected _scene: Nullable<Scene>;
  37513. protected _engine: Nullable<ThinEngine>;
  37514. /** @hidden */
  37515. _texture: Nullable<InternalTexture>;
  37516. private _uid;
  37517. /**
  37518. * Define if the texture is preventinga material to render or not.
  37519. * If not and the texture is not ready, the engine will use a default black texture instead.
  37520. */
  37521. get isBlocking(): boolean;
  37522. /**
  37523. * Instantiates a new BaseTexture.
  37524. * Base class of all the textures in babylon.
  37525. * It groups all the common properties the materials, post process, lights... might need
  37526. * in order to make a correct use of the texture.
  37527. * @param sceneOrEngine Define the scene or engine the texture blongs to
  37528. */
  37529. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  37530. /**
  37531. * Get the scene the texture belongs to.
  37532. * @returns the scene or null if undefined
  37533. */
  37534. getScene(): Nullable<Scene>;
  37535. /** @hidden */
  37536. protected _getEngine(): Nullable<ThinEngine>;
  37537. /**
  37538. * Checks if the texture has the same transform matrix than another texture
  37539. * @param texture texture to check against
  37540. * @returns true if the transforms are the same, else false
  37541. */
  37542. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  37543. /**
  37544. * Get the texture transform matrix used to offset tile the texture for istance.
  37545. * @returns the transformation matrix
  37546. */
  37547. getTextureMatrix(): Matrix;
  37548. /**
  37549. * Get the texture reflection matrix used to rotate/transform the reflection.
  37550. * @returns the reflection matrix
  37551. */
  37552. getReflectionTextureMatrix(): Matrix;
  37553. /**
  37554. * Get the underlying lower level texture from Babylon.
  37555. * @returns the insternal texture
  37556. */
  37557. getInternalTexture(): Nullable<InternalTexture>;
  37558. /**
  37559. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  37560. * @returns true if ready or not blocking
  37561. */
  37562. isReadyOrNotBlocking(): boolean;
  37563. /**
  37564. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  37565. * @returns true if fully ready
  37566. */
  37567. isReady(): boolean;
  37568. private _cachedSize;
  37569. /**
  37570. * Get the size of the texture.
  37571. * @returns the texture size.
  37572. */
  37573. getSize(): ISize;
  37574. /**
  37575. * Get the base size of the texture.
  37576. * It can be different from the size if the texture has been resized for POT for instance
  37577. * @returns the base size
  37578. */
  37579. getBaseSize(): ISize;
  37580. /**
  37581. * Update the sampling mode of the texture.
  37582. * Default is Trilinear mode.
  37583. *
  37584. * | Value | Type | Description |
  37585. * | ----- | ------------------ | ----------- |
  37586. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37587. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37588. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37589. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37590. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37591. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37592. * | 7 | NEAREST_LINEAR | |
  37593. * | 8 | NEAREST_NEAREST | |
  37594. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37595. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37596. * | 11 | LINEAR_LINEAR | |
  37597. * | 12 | LINEAR_NEAREST | |
  37598. *
  37599. * > _mag_: magnification filter (close to the viewer)
  37600. * > _min_: minification filter (far from the viewer)
  37601. * > _mip_: filter used between mip map levels
  37602. *@param samplingMode Define the new sampling mode of the texture
  37603. */
  37604. updateSamplingMode(samplingMode: number): void;
  37605. /**
  37606. * Scales the texture if is `canRescale()`
  37607. * @param ratio the resize factor we want to use to rescale
  37608. */
  37609. scale(ratio: number): void;
  37610. /**
  37611. * Get if the texture can rescale.
  37612. */
  37613. get canRescale(): boolean;
  37614. /** @hidden */
  37615. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  37616. /** @hidden */
  37617. _rebuild(): void;
  37618. /**
  37619. * Triggers the load sequence in delayed load mode.
  37620. */
  37621. delayLoad(): void;
  37622. /**
  37623. * Clones the texture.
  37624. * @returns the cloned texture
  37625. */
  37626. clone(): Nullable<BaseTexture>;
  37627. /**
  37628. * Get the texture underlying type (INT, FLOAT...)
  37629. */
  37630. get textureType(): number;
  37631. /**
  37632. * Get the texture underlying format (RGB, RGBA...)
  37633. */
  37634. get textureFormat(): number;
  37635. /**
  37636. * Indicates that textures need to be re-calculated for all materials
  37637. */
  37638. protected _markAllSubMeshesAsTexturesDirty(): void;
  37639. /**
  37640. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  37641. * This will returns an RGBA array buffer containing either in values (0-255) or
  37642. * float values (0-1) depending of the underlying buffer type.
  37643. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  37644. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  37645. * @param buffer defines a user defined buffer to fill with data (can be null)
  37646. * @returns The Array buffer containing the pixels data.
  37647. */
  37648. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  37649. /**
  37650. * Release and destroy the underlying lower level texture aka internalTexture.
  37651. */
  37652. releaseInternalTexture(): void;
  37653. /** @hidden */
  37654. get _lodTextureHigh(): Nullable<BaseTexture>;
  37655. /** @hidden */
  37656. get _lodTextureMid(): Nullable<BaseTexture>;
  37657. /** @hidden */
  37658. get _lodTextureLow(): Nullable<BaseTexture>;
  37659. /**
  37660. * Dispose the texture and release its associated resources.
  37661. */
  37662. dispose(): void;
  37663. /**
  37664. * Serialize the texture into a JSON representation that can be parsed later on.
  37665. * @returns the JSON representation of the texture
  37666. */
  37667. serialize(): any;
  37668. /**
  37669. * Helper function to be called back once a list of texture contains only ready textures.
  37670. * @param textures Define the list of textures to wait for
  37671. * @param callback Define the callback triggered once the entire list will be ready
  37672. */
  37673. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37674. private static _isScene;
  37675. }
  37676. }
  37677. declare module BABYLON {
  37678. /**
  37679. * Options to be used when creating an effect.
  37680. */
  37681. export interface IEffectCreationOptions {
  37682. /**
  37683. * Atrributes that will be used in the shader.
  37684. */
  37685. attributes: string[];
  37686. /**
  37687. * Uniform varible names that will be set in the shader.
  37688. */
  37689. uniformsNames: string[];
  37690. /**
  37691. * Uniform buffer variable names that will be set in the shader.
  37692. */
  37693. uniformBuffersNames: string[];
  37694. /**
  37695. * Sampler texture variable names that will be set in the shader.
  37696. */
  37697. samplers: string[];
  37698. /**
  37699. * Define statements that will be set in the shader.
  37700. */
  37701. defines: any;
  37702. /**
  37703. * Possible fallbacks for this effect to improve performance when needed.
  37704. */
  37705. fallbacks: Nullable<IEffectFallbacks>;
  37706. /**
  37707. * Callback that will be called when the shader is compiled.
  37708. */
  37709. onCompiled: Nullable<(effect: Effect) => void>;
  37710. /**
  37711. * Callback that will be called if an error occurs during shader compilation.
  37712. */
  37713. onError: Nullable<(effect: Effect, errors: string) => void>;
  37714. /**
  37715. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37716. */
  37717. indexParameters?: any;
  37718. /**
  37719. * Max number of lights that can be used in the shader.
  37720. */
  37721. maxSimultaneousLights?: number;
  37722. /**
  37723. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37724. */
  37725. transformFeedbackVaryings?: Nullable<string[]>;
  37726. /**
  37727. * 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
  37728. */
  37729. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37730. /**
  37731. * Is this effect rendering to several color attachments ?
  37732. */
  37733. multiTarget?: boolean;
  37734. }
  37735. /**
  37736. * Effect containing vertex and fragment shader that can be executed on an object.
  37737. */
  37738. export class Effect implements IDisposable {
  37739. /**
  37740. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37741. */
  37742. static ShadersRepository: string;
  37743. /**
  37744. * Enable logging of the shader code when a compilation error occurs
  37745. */
  37746. static LogShaderCodeOnCompilationError: boolean;
  37747. /**
  37748. * Name of the effect.
  37749. */
  37750. name: any;
  37751. /**
  37752. * String container all the define statements that should be set on the shader.
  37753. */
  37754. defines: string;
  37755. /**
  37756. * Callback that will be called when the shader is compiled.
  37757. */
  37758. onCompiled: Nullable<(effect: Effect) => void>;
  37759. /**
  37760. * Callback that will be called if an error occurs during shader compilation.
  37761. */
  37762. onError: Nullable<(effect: Effect, errors: string) => void>;
  37763. /**
  37764. * Callback that will be called when effect is bound.
  37765. */
  37766. onBind: Nullable<(effect: Effect) => void>;
  37767. /**
  37768. * Unique ID of the effect.
  37769. */
  37770. uniqueId: number;
  37771. /**
  37772. * Observable that will be called when the shader is compiled.
  37773. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  37774. */
  37775. onCompileObservable: Observable<Effect>;
  37776. /**
  37777. * Observable that will be called if an error occurs during shader compilation.
  37778. */
  37779. onErrorObservable: Observable<Effect>;
  37780. /** @hidden */
  37781. _onBindObservable: Nullable<Observable<Effect>>;
  37782. /**
  37783. * @hidden
  37784. * Specifies if the effect was previously ready
  37785. */
  37786. _wasPreviouslyReady: boolean;
  37787. /**
  37788. * Observable that will be called when effect is bound.
  37789. */
  37790. get onBindObservable(): Observable<Effect>;
  37791. /** @hidden */
  37792. _bonesComputationForcedToCPU: boolean;
  37793. /** @hidden */
  37794. _multiTarget: boolean;
  37795. private static _uniqueIdSeed;
  37796. private _engine;
  37797. private _uniformBuffersNames;
  37798. private _uniformBuffersNamesList;
  37799. private _uniformsNames;
  37800. private _samplerList;
  37801. private _samplers;
  37802. private _isReady;
  37803. private _compilationError;
  37804. private _allFallbacksProcessed;
  37805. private _attributesNames;
  37806. private _attributes;
  37807. private _attributeLocationByName;
  37808. private _uniforms;
  37809. /**
  37810. * Key for the effect.
  37811. * @hidden
  37812. */
  37813. _key: string;
  37814. private _indexParameters;
  37815. private _fallbacks;
  37816. private _vertexSourceCode;
  37817. private _fragmentSourceCode;
  37818. private _vertexSourceCodeOverride;
  37819. private _fragmentSourceCodeOverride;
  37820. private _transformFeedbackVaryings;
  37821. private _rawVertexSourceCode;
  37822. private _rawFragmentSourceCode;
  37823. /**
  37824. * Compiled shader to webGL program.
  37825. * @hidden
  37826. */
  37827. _pipelineContext: Nullable<IPipelineContext>;
  37828. private _valueCache;
  37829. private static _baseCache;
  37830. /**
  37831. * Instantiates an effect.
  37832. * An effect can be used to create/manage/execute vertex and fragment shaders.
  37833. * @param baseName Name of the effect.
  37834. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  37835. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  37836. * @param samplers List of sampler variables that will be passed to the shader.
  37837. * @param engine Engine to be used to render the effect
  37838. * @param defines Define statements to be added to the shader.
  37839. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  37840. * @param onCompiled Callback that will be called when the shader is compiled.
  37841. * @param onError Callback that will be called if an error occurs during shader compilation.
  37842. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37843. */
  37844. 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);
  37845. private _useFinalCode;
  37846. /**
  37847. * Unique key for this effect
  37848. */
  37849. get key(): string;
  37850. /**
  37851. * If the effect has been compiled and prepared.
  37852. * @returns if the effect is compiled and prepared.
  37853. */
  37854. isReady(): boolean;
  37855. private _isReadyInternal;
  37856. /**
  37857. * The engine the effect was initialized with.
  37858. * @returns the engine.
  37859. */
  37860. getEngine(): Engine;
  37861. /**
  37862. * The pipeline context for this effect
  37863. * @returns the associated pipeline context
  37864. */
  37865. getPipelineContext(): Nullable<IPipelineContext>;
  37866. /**
  37867. * The set of names of attribute variables for the shader.
  37868. * @returns An array of attribute names.
  37869. */
  37870. getAttributesNames(): string[];
  37871. /**
  37872. * Returns the attribute at the given index.
  37873. * @param index The index of the attribute.
  37874. * @returns The location of the attribute.
  37875. */
  37876. getAttributeLocation(index: number): number;
  37877. /**
  37878. * Returns the attribute based on the name of the variable.
  37879. * @param name of the attribute to look up.
  37880. * @returns the attribute location.
  37881. */
  37882. getAttributeLocationByName(name: string): number;
  37883. /**
  37884. * The number of attributes.
  37885. * @returns the numnber of attributes.
  37886. */
  37887. getAttributesCount(): number;
  37888. /**
  37889. * Gets the index of a uniform variable.
  37890. * @param uniformName of the uniform to look up.
  37891. * @returns the index.
  37892. */
  37893. getUniformIndex(uniformName: string): number;
  37894. /**
  37895. * Returns the attribute based on the name of the variable.
  37896. * @param uniformName of the uniform to look up.
  37897. * @returns the location of the uniform.
  37898. */
  37899. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  37900. /**
  37901. * Returns an array of sampler variable names
  37902. * @returns The array of sampler variable names.
  37903. */
  37904. getSamplers(): string[];
  37905. /**
  37906. * Returns an array of uniform variable names
  37907. * @returns The array of uniform variable names.
  37908. */
  37909. getUniformNames(): string[];
  37910. /**
  37911. * Returns an array of uniform buffer variable names
  37912. * @returns The array of uniform buffer variable names.
  37913. */
  37914. getUniformBuffersNames(): string[];
  37915. /**
  37916. * Returns the index parameters used to create the effect
  37917. * @returns The index parameters object
  37918. */
  37919. getIndexParameters(): any;
  37920. /**
  37921. * The error from the last compilation.
  37922. * @returns the error string.
  37923. */
  37924. getCompilationError(): string;
  37925. /**
  37926. * Gets a boolean indicating that all fallbacks were used during compilation
  37927. * @returns true if all fallbacks were used
  37928. */
  37929. allFallbacksProcessed(): boolean;
  37930. /**
  37931. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  37932. * @param func The callback to be used.
  37933. */
  37934. executeWhenCompiled(func: (effect: Effect) => void): void;
  37935. private _checkIsReady;
  37936. private _loadShader;
  37937. /**
  37938. * Gets the vertex shader source code of this effect
  37939. */
  37940. get vertexSourceCode(): string;
  37941. /**
  37942. * Gets the fragment shader source code of this effect
  37943. */
  37944. get fragmentSourceCode(): string;
  37945. /**
  37946. * Gets the vertex shader source code before it has been processed by the preprocessor
  37947. */
  37948. get rawVertexSourceCode(): string;
  37949. /**
  37950. * Gets the fragment shader source code before it has been processed by the preprocessor
  37951. */
  37952. get rawFragmentSourceCode(): string;
  37953. /**
  37954. * Recompiles the webGL program
  37955. * @param vertexSourceCode The source code for the vertex shader.
  37956. * @param fragmentSourceCode The source code for the fragment shader.
  37957. * @param onCompiled Callback called when completed.
  37958. * @param onError Callback called on error.
  37959. * @hidden
  37960. */
  37961. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  37962. /**
  37963. * Prepares the effect
  37964. * @hidden
  37965. */
  37966. _prepareEffect(): void;
  37967. private _getShaderCodeAndErrorLine;
  37968. private _processCompilationErrors;
  37969. /**
  37970. * Checks if the effect is supported. (Must be called after compilation)
  37971. */
  37972. get isSupported(): boolean;
  37973. /**
  37974. * Binds a texture to the engine to be used as output of the shader.
  37975. * @param channel Name of the output variable.
  37976. * @param texture Texture to bind.
  37977. * @hidden
  37978. */
  37979. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  37980. /**
  37981. * Sets a texture on the engine to be used in the shader.
  37982. * @param channel Name of the sampler variable.
  37983. * @param texture Texture to set.
  37984. */
  37985. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  37986. /**
  37987. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  37988. * @param channel Name of the sampler variable.
  37989. * @param texture Texture to set.
  37990. */
  37991. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  37992. /**
  37993. * Sets an array of textures on the engine to be used in the shader.
  37994. * @param channel Name of the variable.
  37995. * @param textures Textures to set.
  37996. */
  37997. setTextureArray(channel: string, textures: BaseTexture[]): void;
  37998. /**
  37999. * 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)
  38000. * @param channel Name of the sampler variable.
  38001. * @param postProcess Post process to get the input texture from.
  38002. */
  38003. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  38004. /**
  38005. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  38006. * 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)
  38007. * @param channel Name of the sampler variable.
  38008. * @param postProcess Post process to get the output texture from.
  38009. */
  38010. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  38011. /** @hidden */
  38012. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  38013. /** @hidden */
  38014. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  38015. /** @hidden */
  38016. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  38017. /** @hidden */
  38018. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  38019. /**
  38020. * Binds a buffer to a uniform.
  38021. * @param buffer Buffer to bind.
  38022. * @param name Name of the uniform variable to bind to.
  38023. */
  38024. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  38025. /**
  38026. * Binds block to a uniform.
  38027. * @param blockName Name of the block to bind.
  38028. * @param index Index to bind.
  38029. */
  38030. bindUniformBlock(blockName: string, index: number): void;
  38031. /**
  38032. * Sets an interger value on a uniform variable.
  38033. * @param uniformName Name of the variable.
  38034. * @param value Value to be set.
  38035. * @returns this effect.
  38036. */
  38037. setInt(uniformName: string, value: number): Effect;
  38038. /**
  38039. * Sets an int array on a uniform variable.
  38040. * @param uniformName Name of the variable.
  38041. * @param array array to be set.
  38042. * @returns this effect.
  38043. */
  38044. setIntArray(uniformName: string, array: Int32Array): Effect;
  38045. /**
  38046. * 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)
  38047. * @param uniformName Name of the variable.
  38048. * @param array array to be set.
  38049. * @returns this effect.
  38050. */
  38051. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38052. /**
  38053. * 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)
  38054. * @param uniformName Name of the variable.
  38055. * @param array array to be set.
  38056. * @returns this effect.
  38057. */
  38058. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38059. /**
  38060. * 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)
  38061. * @param uniformName Name of the variable.
  38062. * @param array array to be set.
  38063. * @returns this effect.
  38064. */
  38065. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38066. /**
  38067. * Sets an float array on a uniform variable.
  38068. * @param uniformName Name of the variable.
  38069. * @param array array to be set.
  38070. * @returns this effect.
  38071. */
  38072. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38073. /**
  38074. * 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)
  38075. * @param uniformName Name of the variable.
  38076. * @param array array to be set.
  38077. * @returns this effect.
  38078. */
  38079. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38080. /**
  38081. * 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)
  38082. * @param uniformName Name of the variable.
  38083. * @param array array to be set.
  38084. * @returns this effect.
  38085. */
  38086. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38087. /**
  38088. * 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)
  38089. * @param uniformName Name of the variable.
  38090. * @param array array to be set.
  38091. * @returns this effect.
  38092. */
  38093. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38094. /**
  38095. * Sets an array on a uniform variable.
  38096. * @param uniformName Name of the variable.
  38097. * @param array array to be set.
  38098. * @returns this effect.
  38099. */
  38100. setArray(uniformName: string, array: number[]): Effect;
  38101. /**
  38102. * 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)
  38103. * @param uniformName Name of the variable.
  38104. * @param array array to be set.
  38105. * @returns this effect.
  38106. */
  38107. setArray2(uniformName: string, array: number[]): Effect;
  38108. /**
  38109. * 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)
  38110. * @param uniformName Name of the variable.
  38111. * @param array array to be set.
  38112. * @returns this effect.
  38113. */
  38114. setArray3(uniformName: string, array: number[]): Effect;
  38115. /**
  38116. * 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)
  38117. * @param uniformName Name of the variable.
  38118. * @param array array to be set.
  38119. * @returns this effect.
  38120. */
  38121. setArray4(uniformName: string, array: number[]): Effect;
  38122. /**
  38123. * Sets matrices on a uniform variable.
  38124. * @param uniformName Name of the variable.
  38125. * @param matrices matrices to be set.
  38126. * @returns this effect.
  38127. */
  38128. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38129. /**
  38130. * Sets matrix on a uniform variable.
  38131. * @param uniformName Name of the variable.
  38132. * @param matrix matrix to be set.
  38133. * @returns this effect.
  38134. */
  38135. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38136. /**
  38137. * 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)
  38138. * @param uniformName Name of the variable.
  38139. * @param matrix matrix to be set.
  38140. * @returns this effect.
  38141. */
  38142. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38143. /**
  38144. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38145. * @param uniformName Name of the variable.
  38146. * @param matrix matrix to be set.
  38147. * @returns this effect.
  38148. */
  38149. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38150. /**
  38151. * Sets a float on a uniform variable.
  38152. * @param uniformName Name of the variable.
  38153. * @param value value to be set.
  38154. * @returns this effect.
  38155. */
  38156. setFloat(uniformName: string, value: number): Effect;
  38157. /**
  38158. * Sets a boolean on a uniform variable.
  38159. * @param uniformName Name of the variable.
  38160. * @param bool value to be set.
  38161. * @returns this effect.
  38162. */
  38163. setBool(uniformName: string, bool: boolean): Effect;
  38164. /**
  38165. * Sets a Vector2 on a uniform variable.
  38166. * @param uniformName Name of the variable.
  38167. * @param vector2 vector2 to be set.
  38168. * @returns this effect.
  38169. */
  38170. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38171. /**
  38172. * Sets a float2 on a uniform variable.
  38173. * @param uniformName Name of the variable.
  38174. * @param x First float in float2.
  38175. * @param y Second float in float2.
  38176. * @returns this effect.
  38177. */
  38178. setFloat2(uniformName: string, x: number, y: number): Effect;
  38179. /**
  38180. * Sets a Vector3 on a uniform variable.
  38181. * @param uniformName Name of the variable.
  38182. * @param vector3 Value to be set.
  38183. * @returns this effect.
  38184. */
  38185. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38186. /**
  38187. * Sets a float3 on a uniform variable.
  38188. * @param uniformName Name of the variable.
  38189. * @param x First float in float3.
  38190. * @param y Second float in float3.
  38191. * @param z Third float in float3.
  38192. * @returns this effect.
  38193. */
  38194. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38195. /**
  38196. * Sets a Vector4 on a uniform variable.
  38197. * @param uniformName Name of the variable.
  38198. * @param vector4 Value to be set.
  38199. * @returns this effect.
  38200. */
  38201. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38202. /**
  38203. * Sets a float4 on a uniform variable.
  38204. * @param uniformName Name of the variable.
  38205. * @param x First float in float4.
  38206. * @param y Second float in float4.
  38207. * @param z Third float in float4.
  38208. * @param w Fourth float in float4.
  38209. * @returns this effect.
  38210. */
  38211. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38212. /**
  38213. * Sets a Color3 on a uniform variable.
  38214. * @param uniformName Name of the variable.
  38215. * @param color3 Value to be set.
  38216. * @returns this effect.
  38217. */
  38218. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38219. /**
  38220. * Sets a Color4 on a uniform variable.
  38221. * @param uniformName Name of the variable.
  38222. * @param color3 Value to be set.
  38223. * @param alpha Alpha value to be set.
  38224. * @returns this effect.
  38225. */
  38226. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38227. /**
  38228. * Sets a Color4 on a uniform variable
  38229. * @param uniformName defines the name of the variable
  38230. * @param color4 defines the value to be set
  38231. * @returns this effect.
  38232. */
  38233. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38234. /** Release all associated resources */
  38235. dispose(): void;
  38236. /**
  38237. * This function will add a new shader to the shader store
  38238. * @param name the name of the shader
  38239. * @param pixelShader optional pixel shader content
  38240. * @param vertexShader optional vertex shader content
  38241. */
  38242. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38243. /**
  38244. * Store of each shader (The can be looked up using effect.key)
  38245. */
  38246. static ShadersStore: {
  38247. [key: string]: string;
  38248. };
  38249. /**
  38250. * Store of each included file for a shader (The can be looked up using effect.key)
  38251. */
  38252. static IncludesShadersStore: {
  38253. [key: string]: string;
  38254. };
  38255. /**
  38256. * Resets the cache of effects.
  38257. */
  38258. static ResetCache(): void;
  38259. }
  38260. }
  38261. declare module BABYLON {
  38262. /**
  38263. * Interface used to describe the capabilities of the engine relatively to the current browser
  38264. */
  38265. export interface EngineCapabilities {
  38266. /** Maximum textures units per fragment shader */
  38267. maxTexturesImageUnits: number;
  38268. /** Maximum texture units per vertex shader */
  38269. maxVertexTextureImageUnits: number;
  38270. /** Maximum textures units in the entire pipeline */
  38271. maxCombinedTexturesImageUnits: number;
  38272. /** Maximum texture size */
  38273. maxTextureSize: number;
  38274. /** Maximum texture samples */
  38275. maxSamples?: number;
  38276. /** Maximum cube texture size */
  38277. maxCubemapTextureSize: number;
  38278. /** Maximum render texture size */
  38279. maxRenderTextureSize: number;
  38280. /** Maximum number of vertex attributes */
  38281. maxVertexAttribs: number;
  38282. /** Maximum number of varyings */
  38283. maxVaryingVectors: number;
  38284. /** Maximum number of uniforms per vertex shader */
  38285. maxVertexUniformVectors: number;
  38286. /** Maximum number of uniforms per fragment shader */
  38287. maxFragmentUniformVectors: number;
  38288. /** Defines if standard derivates (dx/dy) are supported */
  38289. standardDerivatives: boolean;
  38290. /** Defines if s3tc texture compression is supported */
  38291. s3tc?: WEBGL_compressed_texture_s3tc;
  38292. /** Defines if pvrtc texture compression is supported */
  38293. pvrtc: any;
  38294. /** Defines if etc1 texture compression is supported */
  38295. etc1: any;
  38296. /** Defines if etc2 texture compression is supported */
  38297. etc2: any;
  38298. /** Defines if astc texture compression is supported */
  38299. astc: any;
  38300. /** Defines if bptc texture compression is supported */
  38301. bptc: any;
  38302. /** Defines if float textures are supported */
  38303. textureFloat: boolean;
  38304. /** Defines if vertex array objects are supported */
  38305. vertexArrayObject: boolean;
  38306. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38307. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38308. /** Gets the maximum level of anisotropy supported */
  38309. maxAnisotropy: number;
  38310. /** Defines if instancing is supported */
  38311. instancedArrays: boolean;
  38312. /** Defines if 32 bits indices are supported */
  38313. uintIndices: boolean;
  38314. /** Defines if high precision shaders are supported */
  38315. highPrecisionShaderSupported: boolean;
  38316. /** Defines if depth reading in the fragment shader is supported */
  38317. fragmentDepthSupported: boolean;
  38318. /** Defines if float texture linear filtering is supported*/
  38319. textureFloatLinearFiltering: boolean;
  38320. /** Defines if rendering to float textures is supported */
  38321. textureFloatRender: boolean;
  38322. /** Defines if half float textures are supported*/
  38323. textureHalfFloat: boolean;
  38324. /** Defines if half float texture linear filtering is supported*/
  38325. textureHalfFloatLinearFiltering: boolean;
  38326. /** Defines if rendering to half float textures is supported */
  38327. textureHalfFloatRender: boolean;
  38328. /** Defines if textureLOD shader command is supported */
  38329. textureLOD: boolean;
  38330. /** Defines if draw buffers extension is supported */
  38331. drawBuffersExtension: boolean;
  38332. /** Defines if depth textures are supported */
  38333. depthTextureExtension: boolean;
  38334. /** Defines if float color buffer are supported */
  38335. colorBufferFloat: boolean;
  38336. /** Gets disjoint timer query extension (null if not supported) */
  38337. timerQuery?: EXT_disjoint_timer_query;
  38338. /** Defines if timestamp can be used with timer query */
  38339. canUseTimestampForTimerQuery: boolean;
  38340. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38341. multiview?: any;
  38342. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38343. oculusMultiview?: any;
  38344. /** Function used to let the system compiles shaders in background */
  38345. parallelShaderCompile?: {
  38346. COMPLETION_STATUS_KHR: number;
  38347. };
  38348. /** Max number of texture samples for MSAA */
  38349. maxMSAASamples: number;
  38350. /** Defines if the blend min max extension is supported */
  38351. blendMinMax: boolean;
  38352. }
  38353. }
  38354. declare module BABYLON {
  38355. /**
  38356. * @hidden
  38357. **/
  38358. export class DepthCullingState {
  38359. private _isDepthTestDirty;
  38360. private _isDepthMaskDirty;
  38361. private _isDepthFuncDirty;
  38362. private _isCullFaceDirty;
  38363. private _isCullDirty;
  38364. private _isZOffsetDirty;
  38365. private _isFrontFaceDirty;
  38366. private _depthTest;
  38367. private _depthMask;
  38368. private _depthFunc;
  38369. private _cull;
  38370. private _cullFace;
  38371. private _zOffset;
  38372. private _frontFace;
  38373. /**
  38374. * Initializes the state.
  38375. */
  38376. constructor();
  38377. get isDirty(): boolean;
  38378. get zOffset(): number;
  38379. set zOffset(value: number);
  38380. get cullFace(): Nullable<number>;
  38381. set cullFace(value: Nullable<number>);
  38382. get cull(): Nullable<boolean>;
  38383. set cull(value: Nullable<boolean>);
  38384. get depthFunc(): Nullable<number>;
  38385. set depthFunc(value: Nullable<number>);
  38386. get depthMask(): boolean;
  38387. set depthMask(value: boolean);
  38388. get depthTest(): boolean;
  38389. set depthTest(value: boolean);
  38390. get frontFace(): Nullable<number>;
  38391. set frontFace(value: Nullable<number>);
  38392. reset(): void;
  38393. apply(gl: WebGLRenderingContext): void;
  38394. }
  38395. }
  38396. declare module BABYLON {
  38397. /**
  38398. * @hidden
  38399. **/
  38400. export class StencilState {
  38401. /** 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 */
  38402. static readonly ALWAYS: number;
  38403. /** Passed to stencilOperation to specify that stencil value must be kept */
  38404. static readonly KEEP: number;
  38405. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38406. static readonly REPLACE: number;
  38407. private _isStencilTestDirty;
  38408. private _isStencilMaskDirty;
  38409. private _isStencilFuncDirty;
  38410. private _isStencilOpDirty;
  38411. private _stencilTest;
  38412. private _stencilMask;
  38413. private _stencilFunc;
  38414. private _stencilFuncRef;
  38415. private _stencilFuncMask;
  38416. private _stencilOpStencilFail;
  38417. private _stencilOpDepthFail;
  38418. private _stencilOpStencilDepthPass;
  38419. get isDirty(): boolean;
  38420. get stencilFunc(): number;
  38421. set stencilFunc(value: number);
  38422. get stencilFuncRef(): number;
  38423. set stencilFuncRef(value: number);
  38424. get stencilFuncMask(): number;
  38425. set stencilFuncMask(value: number);
  38426. get stencilOpStencilFail(): number;
  38427. set stencilOpStencilFail(value: number);
  38428. get stencilOpDepthFail(): number;
  38429. set stencilOpDepthFail(value: number);
  38430. get stencilOpStencilDepthPass(): number;
  38431. set stencilOpStencilDepthPass(value: number);
  38432. get stencilMask(): number;
  38433. set stencilMask(value: number);
  38434. get stencilTest(): boolean;
  38435. set stencilTest(value: boolean);
  38436. constructor();
  38437. reset(): void;
  38438. apply(gl: WebGLRenderingContext): void;
  38439. }
  38440. }
  38441. declare module BABYLON {
  38442. /**
  38443. * @hidden
  38444. **/
  38445. export class AlphaState {
  38446. private _isAlphaBlendDirty;
  38447. private _isBlendFunctionParametersDirty;
  38448. private _isBlendEquationParametersDirty;
  38449. private _isBlendConstantsDirty;
  38450. private _alphaBlend;
  38451. private _blendFunctionParameters;
  38452. private _blendEquationParameters;
  38453. private _blendConstants;
  38454. /**
  38455. * Initializes the state.
  38456. */
  38457. constructor();
  38458. get isDirty(): boolean;
  38459. get alphaBlend(): boolean;
  38460. set alphaBlend(value: boolean);
  38461. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38462. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38463. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38464. reset(): void;
  38465. apply(gl: WebGLRenderingContext): void;
  38466. }
  38467. }
  38468. declare module BABYLON {
  38469. /** @hidden */
  38470. export class WebGLShaderProcessor implements IShaderProcessor {
  38471. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38472. }
  38473. }
  38474. declare module BABYLON {
  38475. /** @hidden */
  38476. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38477. attributeProcessor(attribute: string): string;
  38478. varyingProcessor(varying: string, isFragment: boolean): string;
  38479. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38480. }
  38481. }
  38482. declare module BABYLON {
  38483. /**
  38484. * Interface for attribute information associated with buffer instanciation
  38485. */
  38486. export interface InstancingAttributeInfo {
  38487. /**
  38488. * Name of the GLSL attribute
  38489. * if attribute index is not specified, this is used to retrieve the index from the effect
  38490. */
  38491. attributeName: string;
  38492. /**
  38493. * Index/offset of the attribute in the vertex shader
  38494. * if not specified, this will be computes from the name.
  38495. */
  38496. index?: number;
  38497. /**
  38498. * size of the attribute, 1, 2, 3 or 4
  38499. */
  38500. attributeSize: number;
  38501. /**
  38502. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38503. */
  38504. offset: number;
  38505. /**
  38506. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38507. * default to 1
  38508. */
  38509. divisor?: number;
  38510. /**
  38511. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38512. * default is FLOAT
  38513. */
  38514. attributeType?: number;
  38515. /**
  38516. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38517. */
  38518. normalized?: boolean;
  38519. }
  38520. }
  38521. declare module BABYLON {
  38522. interface ThinEngine {
  38523. /**
  38524. * Update a video texture
  38525. * @param texture defines the texture to update
  38526. * @param video defines the video element to use
  38527. * @param invertY defines if data must be stored with Y axis inverted
  38528. */
  38529. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38530. }
  38531. }
  38532. declare module BABYLON {
  38533. interface ThinEngine {
  38534. /**
  38535. * Creates a dynamic texture
  38536. * @param width defines the width of the texture
  38537. * @param height defines the height of the texture
  38538. * @param generateMipMaps defines if the engine should generate the mip levels
  38539. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38540. * @returns the dynamic texture inside an InternalTexture
  38541. */
  38542. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38543. /**
  38544. * Update the content of a dynamic texture
  38545. * @param texture defines the texture to update
  38546. * @param canvas defines the canvas containing the source
  38547. * @param invertY defines if data must be stored with Y axis inverted
  38548. * @param premulAlpha defines if alpha is stored as premultiplied
  38549. * @param format defines the format of the data
  38550. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38551. */
  38552. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38553. }
  38554. }
  38555. declare module BABYLON {
  38556. /**
  38557. * Settings for finer control over video usage
  38558. */
  38559. export interface VideoTextureSettings {
  38560. /**
  38561. * Applies `autoplay` to video, if specified
  38562. */
  38563. autoPlay?: boolean;
  38564. /**
  38565. * Applies `muted` to video, if specified
  38566. */
  38567. muted?: boolean;
  38568. /**
  38569. * Applies `loop` to video, if specified
  38570. */
  38571. loop?: boolean;
  38572. /**
  38573. * Automatically updates internal texture from video at every frame in the render loop
  38574. */
  38575. autoUpdateTexture: boolean;
  38576. /**
  38577. * Image src displayed during the video loading or until the user interacts with the video.
  38578. */
  38579. poster?: string;
  38580. }
  38581. /**
  38582. * If you want to display a video in your scene, this is the special texture for that.
  38583. * This special texture works similar to other textures, with the exception of a few parameters.
  38584. * @see https://doc.babylonjs.com/how_to/video_texture
  38585. */
  38586. export class VideoTexture extends Texture {
  38587. /**
  38588. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38589. */
  38590. readonly autoUpdateTexture: boolean;
  38591. /**
  38592. * The video instance used by the texture internally
  38593. */
  38594. readonly video: HTMLVideoElement;
  38595. private _onUserActionRequestedObservable;
  38596. /**
  38597. * Event triggerd when a dom action is required by the user to play the video.
  38598. * This happens due to recent changes in browser policies preventing video to auto start.
  38599. */
  38600. get onUserActionRequestedObservable(): Observable<Texture>;
  38601. private _generateMipMaps;
  38602. private _stillImageCaptured;
  38603. private _displayingPosterTexture;
  38604. private _settings;
  38605. private _createInternalTextureOnEvent;
  38606. private _frameId;
  38607. private _currentSrc;
  38608. /**
  38609. * Creates a video texture.
  38610. * If you want to display a video in your scene, this is the special texture for that.
  38611. * This special texture works similar to other textures, with the exception of a few parameters.
  38612. * @see https://doc.babylonjs.com/how_to/video_texture
  38613. * @param name optional name, will detect from video source, if not defined
  38614. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38615. * @param scene is obviously the current scene.
  38616. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38617. * @param invertY is false by default but can be used to invert video on Y axis
  38618. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38619. * @param settings allows finer control over video usage
  38620. */
  38621. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38622. private _getName;
  38623. private _getVideo;
  38624. private _createInternalTexture;
  38625. private reset;
  38626. /**
  38627. * @hidden Internal method to initiate `update`.
  38628. */
  38629. _rebuild(): void;
  38630. /**
  38631. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38632. */
  38633. update(): void;
  38634. /**
  38635. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38636. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38637. */
  38638. updateTexture(isVisible: boolean): void;
  38639. protected _updateInternalTexture: () => void;
  38640. /**
  38641. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38642. * @param url New url.
  38643. */
  38644. updateURL(url: string): void;
  38645. /**
  38646. * Clones the texture.
  38647. * @returns the cloned texture
  38648. */
  38649. clone(): VideoTexture;
  38650. /**
  38651. * Dispose the texture and release its associated resources.
  38652. */
  38653. dispose(): void;
  38654. /**
  38655. * Creates a video texture straight from a stream.
  38656. * @param scene Define the scene the texture should be created in
  38657. * @param stream Define the stream the texture should be created from
  38658. * @returns The created video texture as a promise
  38659. */
  38660. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38661. /**
  38662. * Creates a video texture straight from your WebCam video feed.
  38663. * @param scene Define the scene the texture should be created in
  38664. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38665. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38666. * @returns The created video texture as a promise
  38667. */
  38668. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38669. minWidth: number;
  38670. maxWidth: number;
  38671. minHeight: number;
  38672. maxHeight: number;
  38673. deviceId: string;
  38674. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38675. /**
  38676. * Creates a video texture straight from your WebCam video feed.
  38677. * @param scene Define the scene the texture should be created in
  38678. * @param onReady Define a callback to triggered once the texture will be ready
  38679. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38680. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38681. */
  38682. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38683. minWidth: number;
  38684. maxWidth: number;
  38685. minHeight: number;
  38686. maxHeight: number;
  38687. deviceId: string;
  38688. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38689. }
  38690. }
  38691. declare module BABYLON {
  38692. /**
  38693. * Defines the interface used by objects working like Scene
  38694. * @hidden
  38695. */
  38696. export interface ISceneLike {
  38697. _addPendingData(data: any): void;
  38698. _removePendingData(data: any): void;
  38699. offlineProvider: IOfflineProvider;
  38700. }
  38701. /**
  38702. * Information about the current host
  38703. */
  38704. export interface HostInformation {
  38705. /**
  38706. * Defines if the current host is a mobile
  38707. */
  38708. isMobile: boolean;
  38709. }
  38710. /** Interface defining initialization parameters for Engine class */
  38711. export interface EngineOptions extends WebGLContextAttributes {
  38712. /**
  38713. * Defines if the engine should no exceed a specified device ratio
  38714. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38715. */
  38716. limitDeviceRatio?: number;
  38717. /**
  38718. * Defines if webvr should be enabled automatically
  38719. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38720. */
  38721. autoEnableWebVR?: boolean;
  38722. /**
  38723. * Defines if webgl2 should be turned off even if supported
  38724. * @see https://doc.babylonjs.com/features/webgl2
  38725. */
  38726. disableWebGL2Support?: boolean;
  38727. /**
  38728. * Defines if webaudio should be initialized as well
  38729. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38730. */
  38731. audioEngine?: boolean;
  38732. /**
  38733. * Defines if animations should run using a deterministic lock step
  38734. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38735. */
  38736. deterministicLockstep?: boolean;
  38737. /** Defines the maximum steps to use with deterministic lock step mode */
  38738. lockstepMaxSteps?: number;
  38739. /** Defines the seconds between each deterministic lock step */
  38740. timeStep?: number;
  38741. /**
  38742. * Defines that engine should ignore context lost events
  38743. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38744. */
  38745. doNotHandleContextLost?: boolean;
  38746. /**
  38747. * Defines that engine should ignore modifying touch action attribute and style
  38748. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  38749. */
  38750. doNotHandleTouchAction?: boolean;
  38751. /**
  38752. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  38753. */
  38754. useHighPrecisionFloats?: boolean;
  38755. /**
  38756. * Make the canvas XR Compatible for XR sessions
  38757. */
  38758. xrCompatible?: boolean;
  38759. /**
  38760. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  38761. */
  38762. useHighPrecisionMatrix?: boolean;
  38763. /**
  38764. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  38765. */
  38766. failIfMajorPerformanceCaveat?: boolean;
  38767. }
  38768. /**
  38769. * The base engine class (root of all engines)
  38770. */
  38771. export class ThinEngine {
  38772. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  38773. static ExceptionList: ({
  38774. key: string;
  38775. capture: string;
  38776. captureConstraint: number;
  38777. targets: string[];
  38778. } | {
  38779. key: string;
  38780. capture: null;
  38781. captureConstraint: null;
  38782. targets: string[];
  38783. })[];
  38784. /** @hidden */
  38785. static _TextureLoaders: IInternalTextureLoader[];
  38786. /**
  38787. * Returns the current npm package of the sdk
  38788. */
  38789. static get NpmPackage(): string;
  38790. /**
  38791. * Returns the current version of the framework
  38792. */
  38793. static get Version(): string;
  38794. /**
  38795. * Returns a string describing the current engine
  38796. */
  38797. get description(): string;
  38798. /**
  38799. * Gets or sets the epsilon value used by collision engine
  38800. */
  38801. static CollisionsEpsilon: number;
  38802. /**
  38803. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38804. */
  38805. static get ShadersRepository(): string;
  38806. static set ShadersRepository(value: string);
  38807. /** @hidden */
  38808. _shaderProcessor: IShaderProcessor;
  38809. /**
  38810. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  38811. */
  38812. forcePOTTextures: boolean;
  38813. /**
  38814. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  38815. */
  38816. isFullscreen: boolean;
  38817. /**
  38818. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  38819. */
  38820. cullBackFaces: boolean;
  38821. /**
  38822. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  38823. */
  38824. renderEvenInBackground: boolean;
  38825. /**
  38826. * Gets or sets a boolean indicating that cache can be kept between frames
  38827. */
  38828. preventCacheWipeBetweenFrames: boolean;
  38829. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  38830. validateShaderPrograms: boolean;
  38831. /**
  38832. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  38833. * This can provide greater z depth for distant objects.
  38834. */
  38835. useReverseDepthBuffer: boolean;
  38836. /**
  38837. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  38838. */
  38839. disableUniformBuffers: boolean;
  38840. /** @hidden */
  38841. _uniformBuffers: UniformBuffer[];
  38842. /**
  38843. * Gets a boolean indicating that the engine supports uniform buffers
  38844. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  38845. */
  38846. get supportsUniformBuffers(): boolean;
  38847. /** @hidden */
  38848. _gl: WebGLRenderingContext;
  38849. /** @hidden */
  38850. _webGLVersion: number;
  38851. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  38852. protected _windowIsBackground: boolean;
  38853. protected _creationOptions: EngineOptions;
  38854. protected _highPrecisionShadersAllowed: boolean;
  38855. /** @hidden */
  38856. get _shouldUseHighPrecisionShader(): boolean;
  38857. /**
  38858. * Gets a boolean indicating that only power of 2 textures are supported
  38859. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  38860. */
  38861. get needPOTTextures(): boolean;
  38862. /** @hidden */
  38863. _badOS: boolean;
  38864. /** @hidden */
  38865. _badDesktopOS: boolean;
  38866. private _hardwareScalingLevel;
  38867. /** @hidden */
  38868. _caps: EngineCapabilities;
  38869. private _isStencilEnable;
  38870. private _glVersion;
  38871. private _glRenderer;
  38872. private _glVendor;
  38873. /** @hidden */
  38874. _videoTextureSupported: boolean;
  38875. protected _renderingQueueLaunched: boolean;
  38876. protected _activeRenderLoops: (() => void)[];
  38877. /**
  38878. * Observable signaled when a context lost event is raised
  38879. */
  38880. onContextLostObservable: Observable<ThinEngine>;
  38881. /**
  38882. * Observable signaled when a context restored event is raised
  38883. */
  38884. onContextRestoredObservable: Observable<ThinEngine>;
  38885. private _onContextLost;
  38886. private _onContextRestored;
  38887. protected _contextWasLost: boolean;
  38888. /** @hidden */
  38889. _doNotHandleContextLost: boolean;
  38890. /**
  38891. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  38892. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  38893. */
  38894. get doNotHandleContextLost(): boolean;
  38895. set doNotHandleContextLost(value: boolean);
  38896. /**
  38897. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  38898. */
  38899. disableVertexArrayObjects: boolean;
  38900. /** @hidden */
  38901. protected _colorWrite: boolean;
  38902. /** @hidden */
  38903. protected _colorWriteChanged: boolean;
  38904. /** @hidden */
  38905. protected _depthCullingState: DepthCullingState;
  38906. /** @hidden */
  38907. protected _stencilState: StencilState;
  38908. /** @hidden */
  38909. _alphaState: AlphaState;
  38910. /** @hidden */
  38911. _alphaMode: number;
  38912. /** @hidden */
  38913. _alphaEquation: number;
  38914. /** @hidden */
  38915. _internalTexturesCache: InternalTexture[];
  38916. /** @hidden */
  38917. protected _activeChannel: number;
  38918. private _currentTextureChannel;
  38919. /** @hidden */
  38920. protected _boundTexturesCache: {
  38921. [key: string]: Nullable<InternalTexture>;
  38922. };
  38923. /** @hidden */
  38924. protected _currentEffect: Nullable<Effect>;
  38925. /** @hidden */
  38926. protected _currentProgram: Nullable<WebGLProgram>;
  38927. private _compiledEffects;
  38928. private _vertexAttribArraysEnabled;
  38929. /** @hidden */
  38930. protected _cachedViewport: Nullable<IViewportLike>;
  38931. private _cachedVertexArrayObject;
  38932. /** @hidden */
  38933. protected _cachedVertexBuffers: any;
  38934. /** @hidden */
  38935. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  38936. /** @hidden */
  38937. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  38938. /** @hidden */
  38939. _currentRenderTarget: Nullable<InternalTexture>;
  38940. private _uintIndicesCurrentlySet;
  38941. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  38942. /** @hidden */
  38943. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  38944. /** @hidden */
  38945. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  38946. private _currentBufferPointers;
  38947. private _currentInstanceLocations;
  38948. private _currentInstanceBuffers;
  38949. private _textureUnits;
  38950. /** @hidden */
  38951. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38952. /** @hidden */
  38953. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38954. /** @hidden */
  38955. _boundRenderFunction: any;
  38956. private _vaoRecordInProgress;
  38957. private _mustWipeVertexAttributes;
  38958. private _emptyTexture;
  38959. private _emptyCubeTexture;
  38960. private _emptyTexture3D;
  38961. private _emptyTexture2DArray;
  38962. /** @hidden */
  38963. _frameHandler: number;
  38964. private _nextFreeTextureSlots;
  38965. private _maxSimultaneousTextures;
  38966. private _activeRequests;
  38967. /** @hidden */
  38968. _transformTextureUrl: Nullable<(url: string) => string>;
  38969. /**
  38970. * Gets information about the current host
  38971. */
  38972. hostInformation: HostInformation;
  38973. protected get _supportsHardwareTextureRescaling(): boolean;
  38974. private _framebufferDimensionsObject;
  38975. /**
  38976. * sets the object from which width and height will be taken from when getting render width and height
  38977. * Will fallback to the gl object
  38978. * @param dimensions the framebuffer width and height that will be used.
  38979. */
  38980. set framebufferDimensionsObject(dimensions: Nullable<{
  38981. framebufferWidth: number;
  38982. framebufferHeight: number;
  38983. }>);
  38984. /**
  38985. * Gets the current viewport
  38986. */
  38987. get currentViewport(): Nullable<IViewportLike>;
  38988. /**
  38989. * Gets the default empty texture
  38990. */
  38991. get emptyTexture(): InternalTexture;
  38992. /**
  38993. * Gets the default empty 3D texture
  38994. */
  38995. get emptyTexture3D(): InternalTexture;
  38996. /**
  38997. * Gets the default empty 2D array texture
  38998. */
  38999. get emptyTexture2DArray(): InternalTexture;
  39000. /**
  39001. * Gets the default empty cube texture
  39002. */
  39003. get emptyCubeTexture(): InternalTexture;
  39004. /**
  39005. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  39006. */
  39007. readonly premultipliedAlpha: boolean;
  39008. /**
  39009. * Observable event triggered before each texture is initialized
  39010. */
  39011. onBeforeTextureInitObservable: Observable<Texture>;
  39012. /**
  39013. * Creates a new engine
  39014. * @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
  39015. * @param antialias defines enable antialiasing (default: false)
  39016. * @param options defines further options to be sent to the getContext() function
  39017. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39018. */
  39019. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39020. private _rebuildInternalTextures;
  39021. private _rebuildEffects;
  39022. /**
  39023. * Gets a boolean indicating if all created effects are ready
  39024. * @returns true if all effects are ready
  39025. */
  39026. areAllEffectsReady(): boolean;
  39027. protected _rebuildBuffers(): void;
  39028. protected _initGLContext(): void;
  39029. /**
  39030. * Gets version of the current webGL context
  39031. */
  39032. get webGLVersion(): number;
  39033. /**
  39034. * Gets a string identifying the name of the class
  39035. * @returns "Engine" string
  39036. */
  39037. getClassName(): string;
  39038. /**
  39039. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39040. */
  39041. get isStencilEnable(): boolean;
  39042. /** @hidden */
  39043. _prepareWorkingCanvas(): void;
  39044. /**
  39045. * Reset the texture cache to empty state
  39046. */
  39047. resetTextureCache(): void;
  39048. /**
  39049. * Gets an object containing information about the current webGL context
  39050. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39051. */
  39052. getGlInfo(): {
  39053. vendor: string;
  39054. renderer: string;
  39055. version: string;
  39056. };
  39057. /**
  39058. * Defines the hardware scaling level.
  39059. * By default the hardware scaling level is computed from the window device ratio.
  39060. * 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.
  39061. * @param level defines the level to use
  39062. */
  39063. setHardwareScalingLevel(level: number): void;
  39064. /**
  39065. * Gets the current hardware scaling level.
  39066. * By default the hardware scaling level is computed from the window device ratio.
  39067. * 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.
  39068. * @returns a number indicating the current hardware scaling level
  39069. */
  39070. getHardwareScalingLevel(): number;
  39071. /**
  39072. * Gets the list of loaded textures
  39073. * @returns an array containing all loaded textures
  39074. */
  39075. getLoadedTexturesCache(): InternalTexture[];
  39076. /**
  39077. * Gets the object containing all engine capabilities
  39078. * @returns the EngineCapabilities object
  39079. */
  39080. getCaps(): EngineCapabilities;
  39081. /**
  39082. * stop executing a render loop function and remove it from the execution array
  39083. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39084. */
  39085. stopRenderLoop(renderFunction?: () => void): void;
  39086. /** @hidden */
  39087. _renderLoop(): void;
  39088. /**
  39089. * Gets the HTML canvas attached with the current webGL context
  39090. * @returns a HTML canvas
  39091. */
  39092. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39093. /**
  39094. * Gets host window
  39095. * @returns the host window object
  39096. */
  39097. getHostWindow(): Nullable<Window>;
  39098. /**
  39099. * Gets the current render width
  39100. * @param useScreen defines if screen size must be used (or the current render target if any)
  39101. * @returns a number defining the current render width
  39102. */
  39103. getRenderWidth(useScreen?: boolean): number;
  39104. /**
  39105. * Gets the current render height
  39106. * @param useScreen defines if screen size must be used (or the current render target if any)
  39107. * @returns a number defining the current render height
  39108. */
  39109. getRenderHeight(useScreen?: boolean): number;
  39110. /**
  39111. * Can be used to override the current requestAnimationFrame requester.
  39112. * @hidden
  39113. */
  39114. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39115. /**
  39116. * Register and execute a render loop. The engine can have more than one render function
  39117. * @param renderFunction defines the function to continuously execute
  39118. */
  39119. runRenderLoop(renderFunction: () => void): void;
  39120. /**
  39121. * Clear the current render buffer or the current render target (if any is set up)
  39122. * @param color defines the color to use
  39123. * @param backBuffer defines if the back buffer must be cleared
  39124. * @param depth defines if the depth buffer must be cleared
  39125. * @param stencil defines if the stencil buffer must be cleared
  39126. */
  39127. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39128. private _viewportCached;
  39129. /** @hidden */
  39130. _viewport(x: number, y: number, width: number, height: number): void;
  39131. /**
  39132. * Set the WebGL's viewport
  39133. * @param viewport defines the viewport element to be used
  39134. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39135. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39136. */
  39137. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39138. /**
  39139. * Begin a new frame
  39140. */
  39141. beginFrame(): void;
  39142. /**
  39143. * Enf the current frame
  39144. */
  39145. endFrame(): void;
  39146. /**
  39147. * Resize the view according to the canvas' size
  39148. */
  39149. resize(): void;
  39150. /**
  39151. * Force a specific size of the canvas
  39152. * @param width defines the new canvas' width
  39153. * @param height defines the new canvas' height
  39154. * @returns true if the size was changed
  39155. */
  39156. setSize(width: number, height: number): boolean;
  39157. /**
  39158. * Binds the frame buffer to the specified texture.
  39159. * @param texture The texture to render to or null for the default canvas
  39160. * @param faceIndex The face of the texture to render to in case of cube texture
  39161. * @param requiredWidth The width of the target to render to
  39162. * @param requiredHeight The height of the target to render to
  39163. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39164. * @param lodLevel defines the lod level to bind to the frame buffer
  39165. * @param layer defines the 2d array index to bind to frame buffer to
  39166. */
  39167. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39168. /** @hidden */
  39169. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39170. /**
  39171. * Unbind the current render target texture from the webGL context
  39172. * @param texture defines the render target texture to unbind
  39173. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39174. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39175. */
  39176. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39177. /**
  39178. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39179. */
  39180. flushFramebuffer(): void;
  39181. /**
  39182. * Unbind the current render target and bind the default framebuffer
  39183. */
  39184. restoreDefaultFramebuffer(): void;
  39185. /** @hidden */
  39186. protected _resetVertexBufferBinding(): void;
  39187. /**
  39188. * Creates a vertex buffer
  39189. * @param data the data for the vertex buffer
  39190. * @returns the new WebGL static buffer
  39191. */
  39192. createVertexBuffer(data: DataArray): DataBuffer;
  39193. private _createVertexBuffer;
  39194. /**
  39195. * Creates a dynamic vertex buffer
  39196. * @param data the data for the dynamic vertex buffer
  39197. * @returns the new WebGL dynamic buffer
  39198. */
  39199. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39200. protected _resetIndexBufferBinding(): void;
  39201. /**
  39202. * Creates a new index buffer
  39203. * @param indices defines the content of the index buffer
  39204. * @param updatable defines if the index buffer must be updatable
  39205. * @returns a new webGL buffer
  39206. */
  39207. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39208. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39209. /**
  39210. * Bind a webGL buffer to the webGL context
  39211. * @param buffer defines the buffer to bind
  39212. */
  39213. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39214. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39215. private bindBuffer;
  39216. /**
  39217. * update the bound buffer with the given data
  39218. * @param data defines the data to update
  39219. */
  39220. updateArrayBuffer(data: Float32Array): void;
  39221. private _vertexAttribPointer;
  39222. /** @hidden */
  39223. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39224. private _bindVertexBuffersAttributes;
  39225. /**
  39226. * Records a vertex array object
  39227. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39228. * @param vertexBuffers defines the list of vertex buffers to store
  39229. * @param indexBuffer defines the index buffer to store
  39230. * @param effect defines the effect to store
  39231. * @returns the new vertex array object
  39232. */
  39233. recordVertexArrayObject(vertexBuffers: {
  39234. [key: string]: VertexBuffer;
  39235. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39236. /**
  39237. * Bind a specific vertex array object
  39238. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39239. * @param vertexArrayObject defines the vertex array object to bind
  39240. * @param indexBuffer defines the index buffer to bind
  39241. */
  39242. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39243. /**
  39244. * Bind webGl buffers directly to the webGL context
  39245. * @param vertexBuffer defines the vertex buffer to bind
  39246. * @param indexBuffer defines the index buffer to bind
  39247. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39248. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39249. * @param effect defines the effect associated with the vertex buffer
  39250. */
  39251. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39252. private _unbindVertexArrayObject;
  39253. /**
  39254. * Bind a list of vertex buffers to the webGL context
  39255. * @param vertexBuffers defines the list of vertex buffers to bind
  39256. * @param indexBuffer defines the index buffer to bind
  39257. * @param effect defines the effect associated with the vertex buffers
  39258. */
  39259. bindBuffers(vertexBuffers: {
  39260. [key: string]: Nullable<VertexBuffer>;
  39261. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39262. /**
  39263. * Unbind all instance attributes
  39264. */
  39265. unbindInstanceAttributes(): void;
  39266. /**
  39267. * Release and free the memory of a vertex array object
  39268. * @param vao defines the vertex array object to delete
  39269. */
  39270. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39271. /** @hidden */
  39272. _releaseBuffer(buffer: DataBuffer): boolean;
  39273. protected _deleteBuffer(buffer: DataBuffer): void;
  39274. /**
  39275. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39276. * @param instancesBuffer defines the webGL buffer to update and bind
  39277. * @param data defines the data to store in the buffer
  39278. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39279. */
  39280. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39281. /**
  39282. * Bind the content of a webGL buffer used with instantiation
  39283. * @param instancesBuffer defines the webGL buffer to bind
  39284. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39285. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39286. */
  39287. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39288. /**
  39289. * Disable the instance attribute corresponding to the name in parameter
  39290. * @param name defines the name of the attribute to disable
  39291. */
  39292. disableInstanceAttributeByName(name: string): void;
  39293. /**
  39294. * Disable the instance attribute corresponding to the location in parameter
  39295. * @param attributeLocation defines the attribute location of the attribute to disable
  39296. */
  39297. disableInstanceAttribute(attributeLocation: number): void;
  39298. /**
  39299. * Disable the attribute corresponding to the location in parameter
  39300. * @param attributeLocation defines the attribute location of the attribute to disable
  39301. */
  39302. disableAttributeByIndex(attributeLocation: number): void;
  39303. /**
  39304. * Send a draw order
  39305. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39306. * @param indexStart defines the starting index
  39307. * @param indexCount defines the number of index to draw
  39308. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39309. */
  39310. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39311. /**
  39312. * Draw a list of points
  39313. * @param verticesStart defines the index of first vertex to draw
  39314. * @param verticesCount defines the count of vertices to draw
  39315. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39316. */
  39317. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39318. /**
  39319. * Draw a list of unindexed primitives
  39320. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39321. * @param verticesStart defines the index of first vertex to draw
  39322. * @param verticesCount defines the count of vertices to draw
  39323. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39324. */
  39325. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39326. /**
  39327. * Draw a list of indexed primitives
  39328. * @param fillMode defines the primitive to use
  39329. * @param indexStart defines the starting index
  39330. * @param indexCount defines the number of index to draw
  39331. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39332. */
  39333. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39334. /**
  39335. * Draw a list of unindexed primitives
  39336. * @param fillMode defines the primitive to use
  39337. * @param verticesStart defines the index of first vertex to draw
  39338. * @param verticesCount defines the count of vertices to draw
  39339. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39340. */
  39341. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39342. private _drawMode;
  39343. /** @hidden */
  39344. protected _reportDrawCall(): void;
  39345. /** @hidden */
  39346. _releaseEffect(effect: Effect): void;
  39347. /** @hidden */
  39348. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39349. /**
  39350. * Create a new effect (used to store vertex/fragment shaders)
  39351. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39352. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39353. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39354. * @param samplers defines an array of string used to represent textures
  39355. * @param defines defines the string containing the defines to use to compile the shaders
  39356. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39357. * @param onCompiled defines a function to call when the effect creation is successful
  39358. * @param onError defines a function to call when the effect creation has failed
  39359. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39360. * @returns the new Effect
  39361. */
  39362. 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;
  39363. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39364. private _compileShader;
  39365. private _compileRawShader;
  39366. /** @hidden */
  39367. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39368. /**
  39369. * Directly creates a webGL program
  39370. * @param pipelineContext defines the pipeline context to attach to
  39371. * @param vertexCode defines the vertex shader code to use
  39372. * @param fragmentCode defines the fragment shader code to use
  39373. * @param context defines the webGL context to use (if not set, the current one will be used)
  39374. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39375. * @returns the new webGL program
  39376. */
  39377. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39378. /**
  39379. * Creates a webGL program
  39380. * @param pipelineContext defines the pipeline context to attach to
  39381. * @param vertexCode defines the vertex shader code to use
  39382. * @param fragmentCode defines the fragment shader code to use
  39383. * @param defines defines the string containing the defines to use to compile the shaders
  39384. * @param context defines the webGL context to use (if not set, the current one will be used)
  39385. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39386. * @returns the new webGL program
  39387. */
  39388. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39389. /**
  39390. * Creates a new pipeline context
  39391. * @returns the new pipeline
  39392. */
  39393. createPipelineContext(): IPipelineContext;
  39394. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39395. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39396. /** @hidden */
  39397. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39398. /** @hidden */
  39399. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39400. /** @hidden */
  39401. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39402. /**
  39403. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39404. * @param pipelineContext defines the pipeline context to use
  39405. * @param uniformsNames defines the list of uniform names
  39406. * @returns an array of webGL uniform locations
  39407. */
  39408. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39409. /**
  39410. * Gets the lsit of active attributes for a given webGL program
  39411. * @param pipelineContext defines the pipeline context to use
  39412. * @param attributesNames defines the list of attribute names to get
  39413. * @returns an array of indices indicating the offset of each attribute
  39414. */
  39415. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39416. /**
  39417. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39418. * @param effect defines the effect to activate
  39419. */
  39420. enableEffect(effect: Nullable<Effect>): void;
  39421. /**
  39422. * Set the value of an uniform to a number (int)
  39423. * @param uniform defines the webGL uniform location where to store the value
  39424. * @param value defines the int number to store
  39425. * @returns true if the value was set
  39426. */
  39427. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39428. /**
  39429. * Set the value of an uniform to an array of int32
  39430. * @param uniform defines the webGL uniform location where to store the value
  39431. * @param array defines the array of int32 to store
  39432. * @returns true if the value was set
  39433. */
  39434. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39435. /**
  39436. * Set the value of an uniform to an array of int32 (stored as vec2)
  39437. * @param uniform defines the webGL uniform location where to store the value
  39438. * @param array defines the array of int32 to store
  39439. * @returns true if the value was set
  39440. */
  39441. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39442. /**
  39443. * Set the value of an uniform to an array of int32 (stored as vec3)
  39444. * @param uniform defines the webGL uniform location where to store the value
  39445. * @param array defines the array of int32 to store
  39446. * @returns true if the value was set
  39447. */
  39448. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39449. /**
  39450. * Set the value of an uniform to an array of int32 (stored as vec4)
  39451. * @param uniform defines the webGL uniform location where to store the value
  39452. * @param array defines the array of int32 to store
  39453. * @returns true if the value was set
  39454. */
  39455. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39456. /**
  39457. * Set the value of an uniform to an array of number
  39458. * @param uniform defines the webGL uniform location where to store the value
  39459. * @param array defines the array of number to store
  39460. * @returns true if the value was set
  39461. */
  39462. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39463. /**
  39464. * Set the value of an uniform to an array of number (stored as vec2)
  39465. * @param uniform defines the webGL uniform location where to store the value
  39466. * @param array defines the array of number to store
  39467. * @returns true if the value was set
  39468. */
  39469. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39470. /**
  39471. * Set the value of an uniform to an array of number (stored as vec3)
  39472. * @param uniform defines the webGL uniform location where to store the value
  39473. * @param array defines the array of number to store
  39474. * @returns true if the value was set
  39475. */
  39476. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39477. /**
  39478. * Set the value of an uniform to an array of number (stored as vec4)
  39479. * @param uniform defines the webGL uniform location where to store the value
  39480. * @param array defines the array of number to store
  39481. * @returns true if the value was set
  39482. */
  39483. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39484. /**
  39485. * Set the value of an uniform to an array of float32 (stored as matrices)
  39486. * @param uniform defines the webGL uniform location where to store the value
  39487. * @param matrices defines the array of float32 to store
  39488. * @returns true if the value was set
  39489. */
  39490. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39491. /**
  39492. * Set the value of an uniform to a matrix (3x3)
  39493. * @param uniform defines the webGL uniform location where to store the value
  39494. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39495. * @returns true if the value was set
  39496. */
  39497. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39498. /**
  39499. * Set the value of an uniform to a matrix (2x2)
  39500. * @param uniform defines the webGL uniform location where to store the value
  39501. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39502. * @returns true if the value was set
  39503. */
  39504. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39505. /**
  39506. * Set the value of an uniform to a number (float)
  39507. * @param uniform defines the webGL uniform location where to store the value
  39508. * @param value defines the float number to store
  39509. * @returns true if the value was transfered
  39510. */
  39511. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39512. /**
  39513. * Set the value of an uniform to a vec2
  39514. * @param uniform defines the webGL uniform location where to store the value
  39515. * @param x defines the 1st component of the value
  39516. * @param y defines the 2nd component of the value
  39517. * @returns true if the value was set
  39518. */
  39519. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39520. /**
  39521. * Set the value of an uniform to a vec3
  39522. * @param uniform defines the webGL uniform location where to store the value
  39523. * @param x defines the 1st component of the value
  39524. * @param y defines the 2nd component of the value
  39525. * @param z defines the 3rd component of the value
  39526. * @returns true if the value was set
  39527. */
  39528. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39529. /**
  39530. * Set the value of an uniform to a vec4
  39531. * @param uniform defines the webGL uniform location where to store the value
  39532. * @param x defines the 1st component of the value
  39533. * @param y defines the 2nd component of the value
  39534. * @param z defines the 3rd component of the value
  39535. * @param w defines the 4th component of the value
  39536. * @returns true if the value was set
  39537. */
  39538. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39539. /**
  39540. * Apply all cached states (depth, culling, stencil and alpha)
  39541. */
  39542. applyStates(): void;
  39543. /**
  39544. * Enable or disable color writing
  39545. * @param enable defines the state to set
  39546. */
  39547. setColorWrite(enable: boolean): void;
  39548. /**
  39549. * Gets a boolean indicating if color writing is enabled
  39550. * @returns the current color writing state
  39551. */
  39552. getColorWrite(): boolean;
  39553. /**
  39554. * Gets the depth culling state manager
  39555. */
  39556. get depthCullingState(): DepthCullingState;
  39557. /**
  39558. * Gets the alpha state manager
  39559. */
  39560. get alphaState(): AlphaState;
  39561. /**
  39562. * Gets the stencil state manager
  39563. */
  39564. get stencilState(): StencilState;
  39565. /**
  39566. * Clears the list of texture accessible through engine.
  39567. * This can help preventing texture load conflict due to name collision.
  39568. */
  39569. clearInternalTexturesCache(): void;
  39570. /**
  39571. * Force the entire cache to be cleared
  39572. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39573. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39574. */
  39575. wipeCaches(bruteForce?: boolean): void;
  39576. /** @hidden */
  39577. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39578. min: number;
  39579. mag: number;
  39580. };
  39581. /** @hidden */
  39582. _createTexture(): WebGLTexture;
  39583. /**
  39584. * Usually called from Texture.ts.
  39585. * Passed information to create a WebGLTexture
  39586. * @param url defines a value which contains one of the following:
  39587. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39588. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39589. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39590. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39591. * @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)
  39592. * @param scene needed for loading to the correct scene
  39593. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39594. * @param onLoad optional callback to be called upon successful completion
  39595. * @param onError optional callback to be called upon failure
  39596. * @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
  39597. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39598. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39599. * @param forcedExtension defines the extension to use to pick the right loader
  39600. * @param mimeType defines an optional mime type
  39601. * @param loaderOptions options to be passed to the loader
  39602. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39603. */
  39604. 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;
  39605. /**
  39606. * Loads an image as an HTMLImageElement.
  39607. * @param input url string, ArrayBuffer, or Blob to load
  39608. * @param onLoad callback called when the image successfully loads
  39609. * @param onError callback called when the image fails to load
  39610. * @param offlineProvider offline provider for caching
  39611. * @param mimeType optional mime type
  39612. * @returns the HTMLImageElement of the loaded image
  39613. * @hidden
  39614. */
  39615. 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>;
  39616. /**
  39617. * @hidden
  39618. */
  39619. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39620. private _unpackFlipYCached;
  39621. /**
  39622. * In case you are sharing the context with other applications, it might
  39623. * be interested to not cache the unpack flip y state to ensure a consistent
  39624. * value would be set.
  39625. */
  39626. enableUnpackFlipYCached: boolean;
  39627. /** @hidden */
  39628. _unpackFlipY(value: boolean): void;
  39629. /** @hidden */
  39630. _getUnpackAlignement(): number;
  39631. private _getTextureTarget;
  39632. /**
  39633. * Update the sampling mode of a given texture
  39634. * @param samplingMode defines the required sampling mode
  39635. * @param texture defines the texture to update
  39636. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39637. */
  39638. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39639. /**
  39640. * Update the sampling mode of a given texture
  39641. * @param texture defines the texture to update
  39642. * @param wrapU defines the texture wrap mode of the u coordinates
  39643. * @param wrapV defines the texture wrap mode of the v coordinates
  39644. * @param wrapR defines the texture wrap mode of the r coordinates
  39645. */
  39646. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39647. /** @hidden */
  39648. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39649. width: number;
  39650. height: number;
  39651. layers?: number;
  39652. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39653. /** @hidden */
  39654. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39655. /** @hidden */
  39656. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39657. /**
  39658. * Update a portion of an internal texture
  39659. * @param texture defines the texture to update
  39660. * @param imageData defines the data to store into the texture
  39661. * @param xOffset defines the x coordinates of the update rectangle
  39662. * @param yOffset defines the y coordinates of the update rectangle
  39663. * @param width defines the width of the update rectangle
  39664. * @param height defines the height of the update rectangle
  39665. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39666. * @param lod defines the lod level to update (0 by default)
  39667. */
  39668. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39669. /** @hidden */
  39670. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39671. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39672. private _prepareWebGLTexture;
  39673. /** @hidden */
  39674. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39675. private _getDepthStencilBuffer;
  39676. /** @hidden */
  39677. _releaseFramebufferObjects(texture: InternalTexture): void;
  39678. /** @hidden */
  39679. _releaseTexture(texture: InternalTexture): void;
  39680. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39681. protected _setProgram(program: WebGLProgram): void;
  39682. protected _boundUniforms: {
  39683. [key: number]: WebGLUniformLocation;
  39684. };
  39685. /**
  39686. * Binds an effect to the webGL context
  39687. * @param effect defines the effect to bind
  39688. */
  39689. bindSamplers(effect: Effect): void;
  39690. private _activateCurrentTexture;
  39691. /** @hidden */
  39692. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39693. /** @hidden */
  39694. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39695. /**
  39696. * Unbind all textures from the webGL context
  39697. */
  39698. unbindAllTextures(): void;
  39699. /**
  39700. * Sets a texture to the according uniform.
  39701. * @param channel The texture channel
  39702. * @param uniform The uniform to set
  39703. * @param texture The texture to apply
  39704. */
  39705. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  39706. private _bindSamplerUniformToChannel;
  39707. private _getTextureWrapMode;
  39708. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39709. /**
  39710. * Sets an array of texture to the webGL context
  39711. * @param channel defines the channel where the texture array must be set
  39712. * @param uniform defines the associated uniform location
  39713. * @param textures defines the array of textures to bind
  39714. */
  39715. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  39716. /** @hidden */
  39717. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39718. private _setTextureParameterFloat;
  39719. private _setTextureParameterInteger;
  39720. /**
  39721. * Unbind all vertex attributes from the webGL context
  39722. */
  39723. unbindAllAttributes(): void;
  39724. /**
  39725. * 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
  39726. */
  39727. releaseEffects(): void;
  39728. /**
  39729. * Dispose and release all associated resources
  39730. */
  39731. dispose(): void;
  39732. /**
  39733. * Attach a new callback raised when context lost event is fired
  39734. * @param callback defines the callback to call
  39735. */
  39736. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39737. /**
  39738. * Attach a new callback raised when context restored event is fired
  39739. * @param callback defines the callback to call
  39740. */
  39741. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39742. /**
  39743. * Get the current error code of the webGL context
  39744. * @returns the error code
  39745. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39746. */
  39747. getError(): number;
  39748. private _canRenderToFloatFramebuffer;
  39749. private _canRenderToHalfFloatFramebuffer;
  39750. private _canRenderToFramebuffer;
  39751. /** @hidden */
  39752. _getWebGLTextureType(type: number): number;
  39753. /** @hidden */
  39754. _getInternalFormat(format: number): number;
  39755. /** @hidden */
  39756. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  39757. /** @hidden */
  39758. _getRGBAMultiSampleBufferFormat(type: number): number;
  39759. /** @hidden */
  39760. _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;
  39761. /**
  39762. * Loads a file from a url
  39763. * @param url url to load
  39764. * @param onSuccess callback called when the file successfully loads
  39765. * @param onProgress callback called while file is loading (if the server supports this mode)
  39766. * @param offlineProvider defines the offline provider for caching
  39767. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39768. * @param onError callback called when the file fails to load
  39769. * @returns a file request object
  39770. * @hidden
  39771. */
  39772. 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;
  39773. /**
  39774. * Reads pixels from the current frame buffer. Please note that this function can be slow
  39775. * @param x defines the x coordinate of the rectangle where pixels must be read
  39776. * @param y defines the y coordinate of the rectangle where pixels must be read
  39777. * @param width defines the width of the rectangle where pixels must be read
  39778. * @param height defines the height of the rectangle where pixels must be read
  39779. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  39780. * @returns a Uint8Array containing RGBA colors
  39781. */
  39782. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  39783. private static _IsSupported;
  39784. private static _HasMajorPerformanceCaveat;
  39785. /**
  39786. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39787. */
  39788. static get IsSupported(): boolean;
  39789. /**
  39790. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39791. * @returns true if the engine can be created
  39792. * @ignorenaming
  39793. */
  39794. static isSupported(): boolean;
  39795. /**
  39796. * 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)
  39797. */
  39798. static get HasMajorPerformanceCaveat(): boolean;
  39799. /**
  39800. * Find the next highest power of two.
  39801. * @param x Number to start search from.
  39802. * @return Next highest power of two.
  39803. */
  39804. static CeilingPOT(x: number): number;
  39805. /**
  39806. * Find the next lowest power of two.
  39807. * @param x Number to start search from.
  39808. * @return Next lowest power of two.
  39809. */
  39810. static FloorPOT(x: number): number;
  39811. /**
  39812. * Find the nearest power of two.
  39813. * @param x Number to start search from.
  39814. * @return Next nearest power of two.
  39815. */
  39816. static NearestPOT(x: number): number;
  39817. /**
  39818. * Get the closest exponent of two
  39819. * @param value defines the value to approximate
  39820. * @param max defines the maximum value to return
  39821. * @param mode defines how to define the closest value
  39822. * @returns closest exponent of two of the given value
  39823. */
  39824. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39825. /**
  39826. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39827. * @param func - the function to be called
  39828. * @param requester - the object that will request the next frame. Falls back to window.
  39829. * @returns frame number
  39830. */
  39831. static QueueNewFrame(func: () => void, requester?: any): number;
  39832. /**
  39833. * Gets host document
  39834. * @returns the host document object
  39835. */
  39836. getHostDocument(): Nullable<Document>;
  39837. }
  39838. }
  39839. declare module BABYLON {
  39840. /**
  39841. * Defines the source of the internal texture
  39842. */
  39843. export enum InternalTextureSource {
  39844. /**
  39845. * The source of the texture data is unknown
  39846. */
  39847. Unknown = 0,
  39848. /**
  39849. * Texture data comes from an URL
  39850. */
  39851. Url = 1,
  39852. /**
  39853. * Texture data is only used for temporary storage
  39854. */
  39855. Temp = 2,
  39856. /**
  39857. * Texture data comes from raw data (ArrayBuffer)
  39858. */
  39859. Raw = 3,
  39860. /**
  39861. * Texture content is dynamic (video or dynamic texture)
  39862. */
  39863. Dynamic = 4,
  39864. /**
  39865. * Texture content is generated by rendering to it
  39866. */
  39867. RenderTarget = 5,
  39868. /**
  39869. * Texture content is part of a multi render target process
  39870. */
  39871. MultiRenderTarget = 6,
  39872. /**
  39873. * Texture data comes from a cube data file
  39874. */
  39875. Cube = 7,
  39876. /**
  39877. * Texture data comes from a raw cube data
  39878. */
  39879. CubeRaw = 8,
  39880. /**
  39881. * Texture data come from a prefiltered cube data file
  39882. */
  39883. CubePrefiltered = 9,
  39884. /**
  39885. * Texture content is raw 3D data
  39886. */
  39887. Raw3D = 10,
  39888. /**
  39889. * Texture content is raw 2D array data
  39890. */
  39891. Raw2DArray = 11,
  39892. /**
  39893. * Texture content is a depth texture
  39894. */
  39895. Depth = 12,
  39896. /**
  39897. * Texture data comes from a raw cube data encoded with RGBD
  39898. */
  39899. CubeRawRGBD = 13
  39900. }
  39901. /**
  39902. * Class used to store data associated with WebGL texture data for the engine
  39903. * This class should not be used directly
  39904. */
  39905. export class InternalTexture {
  39906. /** @hidden */
  39907. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  39908. /**
  39909. * Defines if the texture is ready
  39910. */
  39911. isReady: boolean;
  39912. /**
  39913. * Defines if the texture is a cube texture
  39914. */
  39915. isCube: boolean;
  39916. /**
  39917. * Defines if the texture contains 3D data
  39918. */
  39919. is3D: boolean;
  39920. /**
  39921. * Defines if the texture contains 2D array data
  39922. */
  39923. is2DArray: boolean;
  39924. /**
  39925. * Defines if the texture contains multiview data
  39926. */
  39927. isMultiview: boolean;
  39928. /**
  39929. * Gets the URL used to load this texture
  39930. */
  39931. url: string;
  39932. /**
  39933. * Gets the sampling mode of the texture
  39934. */
  39935. samplingMode: number;
  39936. /**
  39937. * Gets a boolean indicating if the texture needs mipmaps generation
  39938. */
  39939. generateMipMaps: boolean;
  39940. /**
  39941. * Gets the number of samples used by the texture (WebGL2+ only)
  39942. */
  39943. samples: number;
  39944. /**
  39945. * Gets the type of the texture (int, float...)
  39946. */
  39947. type: number;
  39948. /**
  39949. * Gets the format of the texture (RGB, RGBA...)
  39950. */
  39951. format: number;
  39952. /**
  39953. * Observable called when the texture is loaded
  39954. */
  39955. onLoadedObservable: Observable<InternalTexture>;
  39956. /**
  39957. * Gets the width of the texture
  39958. */
  39959. width: number;
  39960. /**
  39961. * Gets the height of the texture
  39962. */
  39963. height: number;
  39964. /**
  39965. * Gets the depth of the texture
  39966. */
  39967. depth: number;
  39968. /**
  39969. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  39970. */
  39971. baseWidth: number;
  39972. /**
  39973. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  39974. */
  39975. baseHeight: number;
  39976. /**
  39977. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  39978. */
  39979. baseDepth: number;
  39980. /**
  39981. * Gets a boolean indicating if the texture is inverted on Y axis
  39982. */
  39983. invertY: boolean;
  39984. /** @hidden */
  39985. _invertVScale: boolean;
  39986. /** @hidden */
  39987. _associatedChannel: number;
  39988. /** @hidden */
  39989. _source: InternalTextureSource;
  39990. /** @hidden */
  39991. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  39992. /** @hidden */
  39993. _bufferView: Nullable<ArrayBufferView>;
  39994. /** @hidden */
  39995. _bufferViewArray: Nullable<ArrayBufferView[]>;
  39996. /** @hidden */
  39997. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  39998. /** @hidden */
  39999. _size: number;
  40000. /** @hidden */
  40001. _extension: string;
  40002. /** @hidden */
  40003. _files: Nullable<string[]>;
  40004. /** @hidden */
  40005. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40006. /** @hidden */
  40007. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40008. /** @hidden */
  40009. _framebuffer: Nullable<WebGLFramebuffer>;
  40010. /** @hidden */
  40011. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  40012. /** @hidden */
  40013. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  40014. /** @hidden */
  40015. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  40016. /** @hidden */
  40017. _attachments: Nullable<number[]>;
  40018. /** @hidden */
  40019. _textureArray: Nullable<InternalTexture[]>;
  40020. /** @hidden */
  40021. _cachedCoordinatesMode: Nullable<number>;
  40022. /** @hidden */
  40023. _cachedWrapU: Nullable<number>;
  40024. /** @hidden */
  40025. _cachedWrapV: Nullable<number>;
  40026. /** @hidden */
  40027. _cachedWrapR: Nullable<number>;
  40028. /** @hidden */
  40029. _cachedAnisotropicFilteringLevel: Nullable<number>;
  40030. /** @hidden */
  40031. _isDisabled: boolean;
  40032. /** @hidden */
  40033. _compression: Nullable<string>;
  40034. /** @hidden */
  40035. _generateStencilBuffer: boolean;
  40036. /** @hidden */
  40037. _generateDepthBuffer: boolean;
  40038. /** @hidden */
  40039. _comparisonFunction: number;
  40040. /** @hidden */
  40041. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40042. /** @hidden */
  40043. _lodGenerationScale: number;
  40044. /** @hidden */
  40045. _lodGenerationOffset: number;
  40046. /** @hidden */
  40047. _depthStencilTexture: Nullable<InternalTexture>;
  40048. /** @hidden */
  40049. _colorTextureArray: Nullable<WebGLTexture>;
  40050. /** @hidden */
  40051. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40052. /** @hidden */
  40053. _lodTextureHigh: Nullable<BaseTexture>;
  40054. /** @hidden */
  40055. _lodTextureMid: Nullable<BaseTexture>;
  40056. /** @hidden */
  40057. _lodTextureLow: Nullable<BaseTexture>;
  40058. /** @hidden */
  40059. _isRGBD: boolean;
  40060. /** @hidden */
  40061. _linearSpecularLOD: boolean;
  40062. /** @hidden */
  40063. _irradianceTexture: Nullable<BaseTexture>;
  40064. /** @hidden */
  40065. _webGLTexture: Nullable<WebGLTexture>;
  40066. /** @hidden */
  40067. _references: number;
  40068. /** @hidden */
  40069. _gammaSpace: Nullable<boolean>;
  40070. private _engine;
  40071. /**
  40072. * Gets the Engine the texture belongs to.
  40073. * @returns The babylon engine
  40074. */
  40075. getEngine(): ThinEngine;
  40076. /**
  40077. * Gets the data source type of the texture
  40078. */
  40079. get source(): InternalTextureSource;
  40080. /**
  40081. * Creates a new InternalTexture
  40082. * @param engine defines the engine to use
  40083. * @param source defines the type of data that will be used
  40084. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40085. */
  40086. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40087. /**
  40088. * Increments the number of references (ie. the number of Texture that point to it)
  40089. */
  40090. incrementReferences(): void;
  40091. /**
  40092. * Change the size of the texture (not the size of the content)
  40093. * @param width defines the new width
  40094. * @param height defines the new height
  40095. * @param depth defines the new depth (1 by default)
  40096. */
  40097. updateSize(width: int, height: int, depth?: int): void;
  40098. /** @hidden */
  40099. _rebuild(): void;
  40100. /** @hidden */
  40101. _swapAndDie(target: InternalTexture): void;
  40102. /**
  40103. * Dispose the current allocated resources
  40104. */
  40105. dispose(): void;
  40106. }
  40107. }
  40108. declare module BABYLON {
  40109. /**
  40110. * Interface used to present a loading screen while loading a scene
  40111. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40112. */
  40113. export interface ILoadingScreen {
  40114. /**
  40115. * Function called to display the loading screen
  40116. */
  40117. displayLoadingUI: () => void;
  40118. /**
  40119. * Function called to hide the loading screen
  40120. */
  40121. hideLoadingUI: () => void;
  40122. /**
  40123. * Gets or sets the color to use for the background
  40124. */
  40125. loadingUIBackgroundColor: string;
  40126. /**
  40127. * Gets or sets the text to display while loading
  40128. */
  40129. loadingUIText: string;
  40130. }
  40131. /**
  40132. * Class used for the default loading screen
  40133. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40134. */
  40135. export class DefaultLoadingScreen implements ILoadingScreen {
  40136. private _renderingCanvas;
  40137. private _loadingText;
  40138. private _loadingDivBackgroundColor;
  40139. private _loadingDiv;
  40140. private _loadingTextDiv;
  40141. /** Gets or sets the logo url to use for the default loading screen */
  40142. static DefaultLogoUrl: string;
  40143. /** Gets or sets the spinner url to use for the default loading screen */
  40144. static DefaultSpinnerUrl: string;
  40145. /**
  40146. * Creates a new default loading screen
  40147. * @param _renderingCanvas defines the canvas used to render the scene
  40148. * @param _loadingText defines the default text to display
  40149. * @param _loadingDivBackgroundColor defines the default background color
  40150. */
  40151. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40152. /**
  40153. * Function called to display the loading screen
  40154. */
  40155. displayLoadingUI(): void;
  40156. /**
  40157. * Function called to hide the loading screen
  40158. */
  40159. hideLoadingUI(): void;
  40160. /**
  40161. * Gets or sets the text to display while loading
  40162. */
  40163. set loadingUIText(text: string);
  40164. get loadingUIText(): string;
  40165. /**
  40166. * Gets or sets the color to use for the background
  40167. */
  40168. get loadingUIBackgroundColor(): string;
  40169. set loadingUIBackgroundColor(color: string);
  40170. private _resizeLoadingUI;
  40171. }
  40172. }
  40173. declare module BABYLON {
  40174. /**
  40175. * Interface for any object that can request an animation frame
  40176. */
  40177. export interface ICustomAnimationFrameRequester {
  40178. /**
  40179. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40180. */
  40181. renderFunction?: Function;
  40182. /**
  40183. * Called to request the next frame to render to
  40184. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40185. */
  40186. requestAnimationFrame: Function;
  40187. /**
  40188. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40189. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40190. */
  40191. requestID?: number;
  40192. }
  40193. }
  40194. declare module BABYLON {
  40195. /**
  40196. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40197. */
  40198. export class PerformanceMonitor {
  40199. private _enabled;
  40200. private _rollingFrameTime;
  40201. private _lastFrameTimeMs;
  40202. /**
  40203. * constructor
  40204. * @param frameSampleSize The number of samples required to saturate the sliding window
  40205. */
  40206. constructor(frameSampleSize?: number);
  40207. /**
  40208. * Samples current frame
  40209. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40210. */
  40211. sampleFrame(timeMs?: number): void;
  40212. /**
  40213. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40214. */
  40215. get averageFrameTime(): number;
  40216. /**
  40217. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40218. */
  40219. get averageFrameTimeVariance(): number;
  40220. /**
  40221. * Returns the frame time of the most recent frame
  40222. */
  40223. get instantaneousFrameTime(): number;
  40224. /**
  40225. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40226. */
  40227. get averageFPS(): number;
  40228. /**
  40229. * Returns the average framerate in frames per second using the most recent frame time
  40230. */
  40231. get instantaneousFPS(): number;
  40232. /**
  40233. * Returns true if enough samples have been taken to completely fill the sliding window
  40234. */
  40235. get isSaturated(): boolean;
  40236. /**
  40237. * Enables contributions to the sliding window sample set
  40238. */
  40239. enable(): void;
  40240. /**
  40241. * Disables contributions to the sliding window sample set
  40242. * Samples will not be interpolated over the disabled period
  40243. */
  40244. disable(): void;
  40245. /**
  40246. * Returns true if sampling is enabled
  40247. */
  40248. get isEnabled(): boolean;
  40249. /**
  40250. * Resets performance monitor
  40251. */
  40252. reset(): void;
  40253. }
  40254. /**
  40255. * RollingAverage
  40256. *
  40257. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40258. */
  40259. export class RollingAverage {
  40260. /**
  40261. * Current average
  40262. */
  40263. average: number;
  40264. /**
  40265. * Current variance
  40266. */
  40267. variance: number;
  40268. protected _samples: Array<number>;
  40269. protected _sampleCount: number;
  40270. protected _pos: number;
  40271. protected _m2: number;
  40272. /**
  40273. * constructor
  40274. * @param length The number of samples required to saturate the sliding window
  40275. */
  40276. constructor(length: number);
  40277. /**
  40278. * Adds a sample to the sample set
  40279. * @param v The sample value
  40280. */
  40281. add(v: number): void;
  40282. /**
  40283. * Returns previously added values or null if outside of history or outside the sliding window domain
  40284. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40285. * @return Value previously recorded with add() or null if outside of range
  40286. */
  40287. history(i: number): number;
  40288. /**
  40289. * Returns true if enough samples have been taken to completely fill the sliding window
  40290. * @return true if sample-set saturated
  40291. */
  40292. isSaturated(): boolean;
  40293. /**
  40294. * Resets the rolling average (equivalent to 0 samples taken so far)
  40295. */
  40296. reset(): void;
  40297. /**
  40298. * Wraps a value around the sample range boundaries
  40299. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40300. * @return Wrapped position in sample range
  40301. */
  40302. protected _wrapPosition(i: number): number;
  40303. }
  40304. }
  40305. declare module BABYLON {
  40306. /**
  40307. * This class is used to track a performance counter which is number based.
  40308. * The user has access to many properties which give statistics of different nature.
  40309. *
  40310. * The implementer can track two kinds of Performance Counter: time and count.
  40311. * 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.
  40312. * 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.
  40313. */
  40314. export class PerfCounter {
  40315. /**
  40316. * Gets or sets a global boolean to turn on and off all the counters
  40317. */
  40318. static Enabled: boolean;
  40319. /**
  40320. * Returns the smallest value ever
  40321. */
  40322. get min(): number;
  40323. /**
  40324. * Returns the biggest value ever
  40325. */
  40326. get max(): number;
  40327. /**
  40328. * Returns the average value since the performance counter is running
  40329. */
  40330. get average(): number;
  40331. /**
  40332. * Returns the average value of the last second the counter was monitored
  40333. */
  40334. get lastSecAverage(): number;
  40335. /**
  40336. * Returns the current value
  40337. */
  40338. get current(): number;
  40339. /**
  40340. * Gets the accumulated total
  40341. */
  40342. get total(): number;
  40343. /**
  40344. * Gets the total value count
  40345. */
  40346. get count(): number;
  40347. /**
  40348. * Creates a new counter
  40349. */
  40350. constructor();
  40351. /**
  40352. * Call this method to start monitoring a new frame.
  40353. * 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.
  40354. */
  40355. fetchNewFrame(): void;
  40356. /**
  40357. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40358. * @param newCount the count value to add to the monitored count
  40359. * @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.
  40360. */
  40361. addCount(newCount: number, fetchResult: boolean): void;
  40362. /**
  40363. * Start monitoring this performance counter
  40364. */
  40365. beginMonitoring(): void;
  40366. /**
  40367. * Compute the time lapsed since the previous beginMonitoring() call.
  40368. * @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
  40369. */
  40370. endMonitoring(newFrame?: boolean): void;
  40371. private _fetchResult;
  40372. private _startMonitoringTime;
  40373. private _min;
  40374. private _max;
  40375. private _average;
  40376. private _current;
  40377. private _totalValueCount;
  40378. private _totalAccumulated;
  40379. private _lastSecAverage;
  40380. private _lastSecAccumulated;
  40381. private _lastSecTime;
  40382. private _lastSecValueCount;
  40383. }
  40384. }
  40385. declare module BABYLON {
  40386. interface ThinEngine {
  40387. /** @hidden */
  40388. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40389. }
  40390. }
  40391. declare module BABYLON {
  40392. /**
  40393. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40394. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40395. */
  40396. export class Analyser {
  40397. /**
  40398. * Gets or sets the smoothing
  40399. * @ignorenaming
  40400. */
  40401. SMOOTHING: number;
  40402. /**
  40403. * Gets or sets the FFT table size
  40404. * @ignorenaming
  40405. */
  40406. FFT_SIZE: number;
  40407. /**
  40408. * Gets or sets the bar graph amplitude
  40409. * @ignorenaming
  40410. */
  40411. BARGRAPHAMPLITUDE: number;
  40412. /**
  40413. * Gets or sets the position of the debug canvas
  40414. * @ignorenaming
  40415. */
  40416. DEBUGCANVASPOS: {
  40417. x: number;
  40418. y: number;
  40419. };
  40420. /**
  40421. * Gets or sets the debug canvas size
  40422. * @ignorenaming
  40423. */
  40424. DEBUGCANVASSIZE: {
  40425. width: number;
  40426. height: number;
  40427. };
  40428. private _byteFreqs;
  40429. private _byteTime;
  40430. private _floatFreqs;
  40431. private _webAudioAnalyser;
  40432. private _debugCanvas;
  40433. private _debugCanvasContext;
  40434. private _scene;
  40435. private _registerFunc;
  40436. private _audioEngine;
  40437. /**
  40438. * Creates a new analyser
  40439. * @param scene defines hosting scene
  40440. */
  40441. constructor(scene: Scene);
  40442. /**
  40443. * Get the number of data values you will have to play with for the visualization
  40444. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40445. * @returns a number
  40446. */
  40447. getFrequencyBinCount(): number;
  40448. /**
  40449. * Gets the current frequency data as a byte array
  40450. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40451. * @returns a Uint8Array
  40452. */
  40453. getByteFrequencyData(): Uint8Array;
  40454. /**
  40455. * Gets the current waveform as a byte array
  40456. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40457. * @returns a Uint8Array
  40458. */
  40459. getByteTimeDomainData(): Uint8Array;
  40460. /**
  40461. * Gets the current frequency data as a float array
  40462. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40463. * @returns a Float32Array
  40464. */
  40465. getFloatFrequencyData(): Float32Array;
  40466. /**
  40467. * Renders the debug canvas
  40468. */
  40469. drawDebugCanvas(): void;
  40470. /**
  40471. * Stops rendering the debug canvas and removes it
  40472. */
  40473. stopDebugCanvas(): void;
  40474. /**
  40475. * Connects two audio nodes
  40476. * @param inputAudioNode defines first node to connect
  40477. * @param outputAudioNode defines second node to connect
  40478. */
  40479. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40480. /**
  40481. * Releases all associated resources
  40482. */
  40483. dispose(): void;
  40484. }
  40485. }
  40486. declare module BABYLON {
  40487. /**
  40488. * This represents an audio engine and it is responsible
  40489. * to play, synchronize and analyse sounds throughout the application.
  40490. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40491. */
  40492. export interface IAudioEngine extends IDisposable {
  40493. /**
  40494. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40495. */
  40496. readonly canUseWebAudio: boolean;
  40497. /**
  40498. * Gets the current AudioContext if available.
  40499. */
  40500. readonly audioContext: Nullable<AudioContext>;
  40501. /**
  40502. * The master gain node defines the global audio volume of your audio engine.
  40503. */
  40504. readonly masterGain: GainNode;
  40505. /**
  40506. * Gets whether or not mp3 are supported by your browser.
  40507. */
  40508. readonly isMP3supported: boolean;
  40509. /**
  40510. * Gets whether or not ogg are supported by your browser.
  40511. */
  40512. readonly isOGGsupported: boolean;
  40513. /**
  40514. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40515. * @ignoreNaming
  40516. */
  40517. WarnedWebAudioUnsupported: boolean;
  40518. /**
  40519. * Defines if the audio engine relies on a custom unlocked button.
  40520. * In this case, the embedded button will not be displayed.
  40521. */
  40522. useCustomUnlockedButton: boolean;
  40523. /**
  40524. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40525. */
  40526. readonly unlocked: boolean;
  40527. /**
  40528. * Event raised when audio has been unlocked on the browser.
  40529. */
  40530. onAudioUnlockedObservable: Observable<IAudioEngine>;
  40531. /**
  40532. * Event raised when audio has been locked on the browser.
  40533. */
  40534. onAudioLockedObservable: Observable<IAudioEngine>;
  40535. /**
  40536. * Flags the audio engine in Locked state.
  40537. * This happens due to new browser policies preventing audio to autoplay.
  40538. */
  40539. lock(): void;
  40540. /**
  40541. * Unlocks the audio engine once a user action has been done on the dom.
  40542. * This is helpful to resume play once browser policies have been satisfied.
  40543. */
  40544. unlock(): void;
  40545. /**
  40546. * Gets the global volume sets on the master gain.
  40547. * @returns the global volume if set or -1 otherwise
  40548. */
  40549. getGlobalVolume(): number;
  40550. /**
  40551. * Sets the global volume of your experience (sets on the master gain).
  40552. * @param newVolume Defines the new global volume of the application
  40553. */
  40554. setGlobalVolume(newVolume: number): void;
  40555. /**
  40556. * Connect the audio engine to an audio analyser allowing some amazing
  40557. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40558. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40559. * @param analyser The analyser to connect to the engine
  40560. */
  40561. connectToAnalyser(analyser: Analyser): void;
  40562. }
  40563. }
  40564. declare module BABYLON {
  40565. /**
  40566. * Defines the interface used by display changed events
  40567. */
  40568. export interface IDisplayChangedEventArgs {
  40569. /** Gets the vrDisplay object (if any) */
  40570. vrDisplay: Nullable<any>;
  40571. /** Gets a boolean indicating if webVR is supported */
  40572. vrSupported: boolean;
  40573. }
  40574. /**
  40575. * Defines the interface used by objects containing a viewport (like a camera)
  40576. */
  40577. interface IViewportOwnerLike {
  40578. /**
  40579. * Gets or sets the viewport
  40580. */
  40581. viewport: IViewportLike;
  40582. }
  40583. /**
  40584. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40585. */
  40586. export class Engine extends ThinEngine {
  40587. /** Defines that alpha blending is disabled */
  40588. static readonly ALPHA_DISABLE: number;
  40589. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40590. static readonly ALPHA_ADD: number;
  40591. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40592. static readonly ALPHA_COMBINE: number;
  40593. /** Defines that alpha blending to DEST - SRC * DEST */
  40594. static readonly ALPHA_SUBTRACT: number;
  40595. /** Defines that alpha blending to SRC * DEST */
  40596. static readonly ALPHA_MULTIPLY: number;
  40597. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40598. static readonly ALPHA_MAXIMIZED: number;
  40599. /** Defines that alpha blending to SRC + DEST */
  40600. static readonly ALPHA_ONEONE: number;
  40601. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40602. static readonly ALPHA_PREMULTIPLIED: number;
  40603. /**
  40604. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40605. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40606. */
  40607. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40608. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40609. static readonly ALPHA_INTERPOLATE: number;
  40610. /**
  40611. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40612. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40613. */
  40614. static readonly ALPHA_SCREENMODE: number;
  40615. /** Defines that the ressource is not delayed*/
  40616. static readonly DELAYLOADSTATE_NONE: number;
  40617. /** Defines that the ressource was successfully delay loaded */
  40618. static readonly DELAYLOADSTATE_LOADED: number;
  40619. /** Defines that the ressource is currently delay loading */
  40620. static readonly DELAYLOADSTATE_LOADING: number;
  40621. /** Defines that the ressource is delayed and has not started loading */
  40622. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40623. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40624. static readonly NEVER: number;
  40625. /** 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 */
  40626. static readonly ALWAYS: number;
  40627. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40628. static readonly LESS: number;
  40629. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40630. static readonly EQUAL: number;
  40631. /** 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 */
  40632. static readonly LEQUAL: number;
  40633. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40634. static readonly GREATER: number;
  40635. /** 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 */
  40636. static readonly GEQUAL: number;
  40637. /** 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 */
  40638. static readonly NOTEQUAL: number;
  40639. /** Passed to stencilOperation to specify that stencil value must be kept */
  40640. static readonly KEEP: number;
  40641. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40642. static readonly REPLACE: number;
  40643. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40644. static readonly INCR: number;
  40645. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40646. static readonly DECR: number;
  40647. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40648. static readonly INVERT: number;
  40649. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40650. static readonly INCR_WRAP: number;
  40651. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40652. static readonly DECR_WRAP: number;
  40653. /** Texture is not repeating outside of 0..1 UVs */
  40654. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40655. /** Texture is repeating outside of 0..1 UVs */
  40656. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40657. /** Texture is repeating and mirrored */
  40658. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40659. /** ALPHA */
  40660. static readonly TEXTUREFORMAT_ALPHA: number;
  40661. /** LUMINANCE */
  40662. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40663. /** LUMINANCE_ALPHA */
  40664. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40665. /** RGB */
  40666. static readonly TEXTUREFORMAT_RGB: number;
  40667. /** RGBA */
  40668. static readonly TEXTUREFORMAT_RGBA: number;
  40669. /** RED */
  40670. static readonly TEXTUREFORMAT_RED: number;
  40671. /** RED (2nd reference) */
  40672. static readonly TEXTUREFORMAT_R: number;
  40673. /** RG */
  40674. static readonly TEXTUREFORMAT_RG: number;
  40675. /** RED_INTEGER */
  40676. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40677. /** RED_INTEGER (2nd reference) */
  40678. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40679. /** RG_INTEGER */
  40680. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40681. /** RGB_INTEGER */
  40682. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40683. /** RGBA_INTEGER */
  40684. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40685. /** UNSIGNED_BYTE */
  40686. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40687. /** UNSIGNED_BYTE (2nd reference) */
  40688. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40689. /** FLOAT */
  40690. static readonly TEXTURETYPE_FLOAT: number;
  40691. /** HALF_FLOAT */
  40692. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40693. /** BYTE */
  40694. static readonly TEXTURETYPE_BYTE: number;
  40695. /** SHORT */
  40696. static readonly TEXTURETYPE_SHORT: number;
  40697. /** UNSIGNED_SHORT */
  40698. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40699. /** INT */
  40700. static readonly TEXTURETYPE_INT: number;
  40701. /** UNSIGNED_INT */
  40702. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40703. /** UNSIGNED_SHORT_4_4_4_4 */
  40704. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40705. /** UNSIGNED_SHORT_5_5_5_1 */
  40706. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40707. /** UNSIGNED_SHORT_5_6_5 */
  40708. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40709. /** UNSIGNED_INT_2_10_10_10_REV */
  40710. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40711. /** UNSIGNED_INT_24_8 */
  40712. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40713. /** UNSIGNED_INT_10F_11F_11F_REV */
  40714. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40715. /** UNSIGNED_INT_5_9_9_9_REV */
  40716. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40717. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40718. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40719. /** nearest is mag = nearest and min = nearest and mip = linear */
  40720. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40721. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40722. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40723. /** Trilinear is mag = linear and min = linear and mip = linear */
  40724. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40725. /** nearest is mag = nearest and min = nearest and mip = linear */
  40726. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40727. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40728. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40729. /** Trilinear is mag = linear and min = linear and mip = linear */
  40730. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40731. /** mag = nearest and min = nearest and mip = nearest */
  40732. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40733. /** mag = nearest and min = linear and mip = nearest */
  40734. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40735. /** mag = nearest and min = linear and mip = linear */
  40736. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40737. /** mag = nearest and min = linear and mip = none */
  40738. static readonly TEXTURE_NEAREST_LINEAR: number;
  40739. /** mag = nearest and min = nearest and mip = none */
  40740. static readonly TEXTURE_NEAREST_NEAREST: number;
  40741. /** mag = linear and min = nearest and mip = nearest */
  40742. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40743. /** mag = linear and min = nearest and mip = linear */
  40744. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  40745. /** mag = linear and min = linear and mip = none */
  40746. static readonly TEXTURE_LINEAR_LINEAR: number;
  40747. /** mag = linear and min = nearest and mip = none */
  40748. static readonly TEXTURE_LINEAR_NEAREST: number;
  40749. /** Explicit coordinates mode */
  40750. static readonly TEXTURE_EXPLICIT_MODE: number;
  40751. /** Spherical coordinates mode */
  40752. static readonly TEXTURE_SPHERICAL_MODE: number;
  40753. /** Planar coordinates mode */
  40754. static readonly TEXTURE_PLANAR_MODE: number;
  40755. /** Cubic coordinates mode */
  40756. static readonly TEXTURE_CUBIC_MODE: number;
  40757. /** Projection coordinates mode */
  40758. static readonly TEXTURE_PROJECTION_MODE: number;
  40759. /** Skybox coordinates mode */
  40760. static readonly TEXTURE_SKYBOX_MODE: number;
  40761. /** Inverse Cubic coordinates mode */
  40762. static readonly TEXTURE_INVCUBIC_MODE: number;
  40763. /** Equirectangular coordinates mode */
  40764. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  40765. /** Equirectangular Fixed coordinates mode */
  40766. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  40767. /** Equirectangular Fixed Mirrored coordinates mode */
  40768. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  40769. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  40770. static readonly SCALEMODE_FLOOR: number;
  40771. /** Defines that texture rescaling will look for the nearest power of 2 size */
  40772. static readonly SCALEMODE_NEAREST: number;
  40773. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  40774. static readonly SCALEMODE_CEILING: number;
  40775. /**
  40776. * Returns the current npm package of the sdk
  40777. */
  40778. static get NpmPackage(): string;
  40779. /**
  40780. * Returns the current version of the framework
  40781. */
  40782. static get Version(): string;
  40783. /** Gets the list of created engines */
  40784. static get Instances(): Engine[];
  40785. /**
  40786. * Gets the latest created engine
  40787. */
  40788. static get LastCreatedEngine(): Nullable<Engine>;
  40789. /**
  40790. * Gets the latest created scene
  40791. */
  40792. static get LastCreatedScene(): Nullable<Scene>;
  40793. /**
  40794. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  40795. * @param flag defines which part of the materials must be marked as dirty
  40796. * @param predicate defines a predicate used to filter which materials should be affected
  40797. */
  40798. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40799. /**
  40800. * Method called to create the default loading screen.
  40801. * This can be overriden in your own app.
  40802. * @param canvas The rendering canvas element
  40803. * @returns The loading screen
  40804. */
  40805. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  40806. /**
  40807. * Method called to create the default rescale post process on each engine.
  40808. */
  40809. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  40810. /**
  40811. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  40812. **/
  40813. enableOfflineSupport: boolean;
  40814. /**
  40815. * 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)
  40816. **/
  40817. disableManifestCheck: boolean;
  40818. /**
  40819. * Gets the list of created scenes
  40820. */
  40821. scenes: Scene[];
  40822. /**
  40823. * Event raised when a new scene is created
  40824. */
  40825. onNewSceneAddedObservable: Observable<Scene>;
  40826. /**
  40827. * Gets the list of created postprocesses
  40828. */
  40829. postProcesses: PostProcess[];
  40830. /**
  40831. * Gets a boolean indicating if the pointer is currently locked
  40832. */
  40833. isPointerLock: boolean;
  40834. /**
  40835. * Observable event triggered each time the rendering canvas is resized
  40836. */
  40837. onResizeObservable: Observable<Engine>;
  40838. /**
  40839. * Observable event triggered each time the canvas loses focus
  40840. */
  40841. onCanvasBlurObservable: Observable<Engine>;
  40842. /**
  40843. * Observable event triggered each time the canvas gains focus
  40844. */
  40845. onCanvasFocusObservable: Observable<Engine>;
  40846. /**
  40847. * Observable event triggered each time the canvas receives pointerout event
  40848. */
  40849. onCanvasPointerOutObservable: Observable<PointerEvent>;
  40850. /**
  40851. * Observable raised when the engine begins a new frame
  40852. */
  40853. onBeginFrameObservable: Observable<Engine>;
  40854. /**
  40855. * If set, will be used to request the next animation frame for the render loop
  40856. */
  40857. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  40858. /**
  40859. * Observable raised when the engine ends the current frame
  40860. */
  40861. onEndFrameObservable: Observable<Engine>;
  40862. /**
  40863. * Observable raised when the engine is about to compile a shader
  40864. */
  40865. onBeforeShaderCompilationObservable: Observable<Engine>;
  40866. /**
  40867. * Observable raised when the engine has jsut compiled a shader
  40868. */
  40869. onAfterShaderCompilationObservable: Observable<Engine>;
  40870. /**
  40871. * Gets the audio engine
  40872. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40873. * @ignorenaming
  40874. */
  40875. static audioEngine: IAudioEngine;
  40876. /**
  40877. * Default AudioEngine factory responsible of creating the Audio Engine.
  40878. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  40879. */
  40880. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  40881. /**
  40882. * Default offline support factory responsible of creating a tool used to store data locally.
  40883. * By default, this will create a Database object if the workload has been embedded.
  40884. */
  40885. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  40886. private _loadingScreen;
  40887. private _pointerLockRequested;
  40888. private _rescalePostProcess;
  40889. private _deterministicLockstep;
  40890. private _lockstepMaxSteps;
  40891. private _timeStep;
  40892. protected get _supportsHardwareTextureRescaling(): boolean;
  40893. private _fps;
  40894. private _deltaTime;
  40895. /** @hidden */
  40896. _drawCalls: PerfCounter;
  40897. /** 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 */
  40898. canvasTabIndex: number;
  40899. /**
  40900. * Turn this value on if you want to pause FPS computation when in background
  40901. */
  40902. disablePerformanceMonitorInBackground: boolean;
  40903. private _performanceMonitor;
  40904. /**
  40905. * Gets the performance monitor attached to this engine
  40906. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40907. */
  40908. get performanceMonitor(): PerformanceMonitor;
  40909. private _onFocus;
  40910. private _onBlur;
  40911. private _onCanvasPointerOut;
  40912. private _onCanvasBlur;
  40913. private _onCanvasFocus;
  40914. private _onFullscreenChange;
  40915. private _onPointerLockChange;
  40916. /**
  40917. * Gets the HTML element used to attach event listeners
  40918. * @returns a HTML element
  40919. */
  40920. getInputElement(): Nullable<HTMLElement>;
  40921. /**
  40922. * Creates a new engine
  40923. * @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
  40924. * @param antialias defines enable antialiasing (default: false)
  40925. * @param options defines further options to be sent to the getContext() function
  40926. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40927. */
  40928. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40929. /**
  40930. * Gets current aspect ratio
  40931. * @param viewportOwner defines the camera to use to get the aspect ratio
  40932. * @param useScreen defines if screen size must be used (or the current render target if any)
  40933. * @returns a number defining the aspect ratio
  40934. */
  40935. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  40936. /**
  40937. * Gets current screen aspect ratio
  40938. * @returns a number defining the aspect ratio
  40939. */
  40940. getScreenAspectRatio(): number;
  40941. /**
  40942. * Gets the client rect of the HTML canvas attached with the current webGL context
  40943. * @returns a client rectanglee
  40944. */
  40945. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  40946. /**
  40947. * Gets the client rect of the HTML element used for events
  40948. * @returns a client rectanglee
  40949. */
  40950. getInputElementClientRect(): Nullable<ClientRect>;
  40951. /**
  40952. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  40953. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40954. * @returns true if engine is in deterministic lock step mode
  40955. */
  40956. isDeterministicLockStep(): boolean;
  40957. /**
  40958. * Gets the max steps when engine is running in deterministic lock step
  40959. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40960. * @returns the max steps
  40961. */
  40962. getLockstepMaxSteps(): number;
  40963. /**
  40964. * Returns the time in ms between steps when using deterministic lock step.
  40965. * @returns time step in (ms)
  40966. */
  40967. getTimeStep(): number;
  40968. /**
  40969. * Force the mipmap generation for the given render target texture
  40970. * @param texture defines the render target texture to use
  40971. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  40972. */
  40973. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  40974. /** States */
  40975. /**
  40976. * Set various states to the webGL context
  40977. * @param culling defines backface culling state
  40978. * @param zOffset defines the value to apply to zOffset (0 by default)
  40979. * @param force defines if states must be applied even if cache is up to date
  40980. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  40981. */
  40982. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40983. /**
  40984. * Set the z offset to apply to current rendering
  40985. * @param value defines the offset to apply
  40986. */
  40987. setZOffset(value: number): void;
  40988. /**
  40989. * Gets the current value of the zOffset
  40990. * @returns the current zOffset state
  40991. */
  40992. getZOffset(): number;
  40993. /**
  40994. * Enable or disable depth buffering
  40995. * @param enable defines the state to set
  40996. */
  40997. setDepthBuffer(enable: boolean): void;
  40998. /**
  40999. * Gets a boolean indicating if depth writing is enabled
  41000. * @returns the current depth writing state
  41001. */
  41002. getDepthWrite(): boolean;
  41003. /**
  41004. * Enable or disable depth writing
  41005. * @param enable defines the state to set
  41006. */
  41007. setDepthWrite(enable: boolean): void;
  41008. /**
  41009. * Gets a boolean indicating if stencil buffer is enabled
  41010. * @returns the current stencil buffer state
  41011. */
  41012. getStencilBuffer(): boolean;
  41013. /**
  41014. * Enable or disable the stencil buffer
  41015. * @param enable defines if the stencil buffer must be enabled or disabled
  41016. */
  41017. setStencilBuffer(enable: boolean): void;
  41018. /**
  41019. * Gets the current stencil mask
  41020. * @returns a number defining the new stencil mask to use
  41021. */
  41022. getStencilMask(): number;
  41023. /**
  41024. * Sets the current stencil mask
  41025. * @param mask defines the new stencil mask to use
  41026. */
  41027. setStencilMask(mask: number): void;
  41028. /**
  41029. * Gets the current stencil function
  41030. * @returns a number defining the stencil function to use
  41031. */
  41032. getStencilFunction(): number;
  41033. /**
  41034. * Gets the current stencil reference value
  41035. * @returns a number defining the stencil reference value to use
  41036. */
  41037. getStencilFunctionReference(): number;
  41038. /**
  41039. * Gets the current stencil mask
  41040. * @returns a number defining the stencil mask to use
  41041. */
  41042. getStencilFunctionMask(): number;
  41043. /**
  41044. * Sets the current stencil function
  41045. * @param stencilFunc defines the new stencil function to use
  41046. */
  41047. setStencilFunction(stencilFunc: number): void;
  41048. /**
  41049. * Sets the current stencil reference
  41050. * @param reference defines the new stencil reference to use
  41051. */
  41052. setStencilFunctionReference(reference: number): void;
  41053. /**
  41054. * Sets the current stencil mask
  41055. * @param mask defines the new stencil mask to use
  41056. */
  41057. setStencilFunctionMask(mask: number): void;
  41058. /**
  41059. * Gets the current stencil operation when stencil fails
  41060. * @returns a number defining stencil operation to use when stencil fails
  41061. */
  41062. getStencilOperationFail(): number;
  41063. /**
  41064. * Gets the current stencil operation when depth fails
  41065. * @returns a number defining stencil operation to use when depth fails
  41066. */
  41067. getStencilOperationDepthFail(): number;
  41068. /**
  41069. * Gets the current stencil operation when stencil passes
  41070. * @returns a number defining stencil operation to use when stencil passes
  41071. */
  41072. getStencilOperationPass(): number;
  41073. /**
  41074. * Sets the stencil operation to use when stencil fails
  41075. * @param operation defines the stencil operation to use when stencil fails
  41076. */
  41077. setStencilOperationFail(operation: number): void;
  41078. /**
  41079. * Sets the stencil operation to use when depth fails
  41080. * @param operation defines the stencil operation to use when depth fails
  41081. */
  41082. setStencilOperationDepthFail(operation: number): void;
  41083. /**
  41084. * Sets the stencil operation to use when stencil passes
  41085. * @param operation defines the stencil operation to use when stencil passes
  41086. */
  41087. setStencilOperationPass(operation: number): void;
  41088. /**
  41089. * Sets a boolean indicating if the dithering state is enabled or disabled
  41090. * @param value defines the dithering state
  41091. */
  41092. setDitheringState(value: boolean): void;
  41093. /**
  41094. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41095. * @param value defines the rasterizer state
  41096. */
  41097. setRasterizerState(value: boolean): void;
  41098. /**
  41099. * Gets the current depth function
  41100. * @returns a number defining the depth function
  41101. */
  41102. getDepthFunction(): Nullable<number>;
  41103. /**
  41104. * Sets the current depth function
  41105. * @param depthFunc defines the function to use
  41106. */
  41107. setDepthFunction(depthFunc: number): void;
  41108. /**
  41109. * Sets the current depth function to GREATER
  41110. */
  41111. setDepthFunctionToGreater(): void;
  41112. /**
  41113. * Sets the current depth function to GEQUAL
  41114. */
  41115. setDepthFunctionToGreaterOrEqual(): void;
  41116. /**
  41117. * Sets the current depth function to LESS
  41118. */
  41119. setDepthFunctionToLess(): void;
  41120. /**
  41121. * Sets the current depth function to LEQUAL
  41122. */
  41123. setDepthFunctionToLessOrEqual(): void;
  41124. private _cachedStencilBuffer;
  41125. private _cachedStencilFunction;
  41126. private _cachedStencilMask;
  41127. private _cachedStencilOperationPass;
  41128. private _cachedStencilOperationFail;
  41129. private _cachedStencilOperationDepthFail;
  41130. private _cachedStencilReference;
  41131. /**
  41132. * Caches the the state of the stencil buffer
  41133. */
  41134. cacheStencilState(): void;
  41135. /**
  41136. * Restores the state of the stencil buffer
  41137. */
  41138. restoreStencilState(): void;
  41139. /**
  41140. * Directly set the WebGL Viewport
  41141. * @param x defines the x coordinate of the viewport (in screen space)
  41142. * @param y defines the y coordinate of the viewport (in screen space)
  41143. * @param width defines the width of the viewport (in screen space)
  41144. * @param height defines the height of the viewport (in screen space)
  41145. * @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
  41146. */
  41147. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41148. /**
  41149. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41150. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41151. * @param y defines the y-coordinate of the corner of the clear rectangle
  41152. * @param width defines the width of the clear rectangle
  41153. * @param height defines the height of the clear rectangle
  41154. * @param clearColor defines the clear color
  41155. */
  41156. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41157. /**
  41158. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41159. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41160. * @param y defines the y-coordinate of the corner of the clear rectangle
  41161. * @param width defines the width of the clear rectangle
  41162. * @param height defines the height of the clear rectangle
  41163. */
  41164. enableScissor(x: number, y: number, width: number, height: number): void;
  41165. /**
  41166. * Disable previously set scissor test rectangle
  41167. */
  41168. disableScissor(): void;
  41169. protected _reportDrawCall(): void;
  41170. /**
  41171. * Initializes a webVR display and starts listening to display change events
  41172. * The onVRDisplayChangedObservable will be notified upon these changes
  41173. * @returns The onVRDisplayChangedObservable
  41174. */
  41175. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41176. /** @hidden */
  41177. _prepareVRComponent(): void;
  41178. /** @hidden */
  41179. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41180. /** @hidden */
  41181. _submitVRFrame(): void;
  41182. /**
  41183. * Call this function to leave webVR mode
  41184. * Will do nothing if webVR is not supported or if there is no webVR device
  41185. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41186. */
  41187. disableVR(): void;
  41188. /**
  41189. * Gets a boolean indicating that the system is in VR mode and is presenting
  41190. * @returns true if VR mode is engaged
  41191. */
  41192. isVRPresenting(): boolean;
  41193. /** @hidden */
  41194. _requestVRFrame(): void;
  41195. /** @hidden */
  41196. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41197. /**
  41198. * Gets the source code of the vertex shader associated with a specific webGL program
  41199. * @param program defines the program to use
  41200. * @returns a string containing the source code of the vertex shader associated with the program
  41201. */
  41202. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41203. /**
  41204. * Gets the source code of the fragment shader associated with a specific webGL program
  41205. * @param program defines the program to use
  41206. * @returns a string containing the source code of the fragment shader associated with the program
  41207. */
  41208. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41209. /**
  41210. * Sets a depth stencil texture from a render target to the according uniform.
  41211. * @param channel The texture channel
  41212. * @param uniform The uniform to set
  41213. * @param texture The render target texture containing the depth stencil texture to apply
  41214. */
  41215. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41216. /**
  41217. * Sets a texture to the webGL context from a postprocess
  41218. * @param channel defines the channel to use
  41219. * @param postProcess defines the source postprocess
  41220. */
  41221. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41222. /**
  41223. * Binds the output of the passed in post process to the texture channel specified
  41224. * @param channel The channel the texture should be bound to
  41225. * @param postProcess The post process which's output should be bound
  41226. */
  41227. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41228. protected _rebuildBuffers(): void;
  41229. /** @hidden */
  41230. _renderFrame(): void;
  41231. _renderLoop(): void;
  41232. /** @hidden */
  41233. _renderViews(): boolean;
  41234. /**
  41235. * Toggle full screen mode
  41236. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41237. */
  41238. switchFullscreen(requestPointerLock: boolean): void;
  41239. /**
  41240. * Enters full screen mode
  41241. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41242. */
  41243. enterFullscreen(requestPointerLock: boolean): void;
  41244. /**
  41245. * Exits full screen mode
  41246. */
  41247. exitFullscreen(): void;
  41248. /**
  41249. * Enters Pointerlock mode
  41250. */
  41251. enterPointerlock(): void;
  41252. /**
  41253. * Exits Pointerlock mode
  41254. */
  41255. exitPointerlock(): void;
  41256. /**
  41257. * Begin a new frame
  41258. */
  41259. beginFrame(): void;
  41260. /**
  41261. * Enf the current frame
  41262. */
  41263. endFrame(): void;
  41264. resize(): void;
  41265. /**
  41266. * Force a specific size of the canvas
  41267. * @param width defines the new canvas' width
  41268. * @param height defines the new canvas' height
  41269. * @returns true if the size was changed
  41270. */
  41271. setSize(width: number, height: number): boolean;
  41272. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41273. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41274. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41275. _releaseTexture(texture: InternalTexture): void;
  41276. /**
  41277. * @hidden
  41278. * Rescales a texture
  41279. * @param source input texutre
  41280. * @param destination destination texture
  41281. * @param scene scene to use to render the resize
  41282. * @param internalFormat format to use when resizing
  41283. * @param onComplete callback to be called when resize has completed
  41284. */
  41285. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41286. /**
  41287. * Gets the current framerate
  41288. * @returns a number representing the framerate
  41289. */
  41290. getFps(): number;
  41291. /**
  41292. * Gets the time spent between current and previous frame
  41293. * @returns a number representing the delta time in ms
  41294. */
  41295. getDeltaTime(): number;
  41296. private _measureFps;
  41297. /** @hidden */
  41298. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41299. /**
  41300. * Updates the sample count of a render target texture
  41301. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41302. * @param texture defines the texture to update
  41303. * @param samples defines the sample count to set
  41304. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41305. */
  41306. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41307. /**
  41308. * Updates a depth texture Comparison Mode and Function.
  41309. * If the comparison Function is equal to 0, the mode will be set to none.
  41310. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41311. * @param texture The texture to set the comparison function for
  41312. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41313. */
  41314. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41315. /**
  41316. * Creates a webGL buffer to use with instanciation
  41317. * @param capacity defines the size of the buffer
  41318. * @returns the webGL buffer
  41319. */
  41320. createInstancesBuffer(capacity: number): DataBuffer;
  41321. /**
  41322. * Delete a webGL buffer used with instanciation
  41323. * @param buffer defines the webGL buffer to delete
  41324. */
  41325. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41326. private _clientWaitAsync;
  41327. /** @hidden */
  41328. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41329. dispose(): void;
  41330. private _disableTouchAction;
  41331. /**
  41332. * Display the loading screen
  41333. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41334. */
  41335. displayLoadingUI(): void;
  41336. /**
  41337. * Hide the loading screen
  41338. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41339. */
  41340. hideLoadingUI(): void;
  41341. /**
  41342. * Gets the current loading screen object
  41343. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41344. */
  41345. get loadingScreen(): ILoadingScreen;
  41346. /**
  41347. * Sets the current loading screen object
  41348. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41349. */
  41350. set loadingScreen(loadingScreen: ILoadingScreen);
  41351. /**
  41352. * Sets the current loading screen text
  41353. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41354. */
  41355. set loadingUIText(text: string);
  41356. /**
  41357. * Sets the current loading screen background color
  41358. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41359. */
  41360. set loadingUIBackgroundColor(color: string);
  41361. /** Pointerlock and fullscreen */
  41362. /**
  41363. * Ask the browser to promote the current element to pointerlock mode
  41364. * @param element defines the DOM element to promote
  41365. */
  41366. static _RequestPointerlock(element: HTMLElement): void;
  41367. /**
  41368. * Asks the browser to exit pointerlock mode
  41369. */
  41370. static _ExitPointerlock(): void;
  41371. /**
  41372. * Ask the browser to promote the current element to fullscreen rendering mode
  41373. * @param element defines the DOM element to promote
  41374. */
  41375. static _RequestFullscreen(element: HTMLElement): void;
  41376. /**
  41377. * Asks the browser to exit fullscreen mode
  41378. */
  41379. static _ExitFullscreen(): void;
  41380. }
  41381. }
  41382. declare module BABYLON {
  41383. /**
  41384. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41385. * during the life time of the application.
  41386. */
  41387. export class EngineStore {
  41388. /** Gets the list of created engines */
  41389. static Instances: Engine[];
  41390. /** @hidden */
  41391. static _LastCreatedScene: Nullable<Scene>;
  41392. /**
  41393. * Gets the latest created engine
  41394. */
  41395. static get LastCreatedEngine(): Nullable<Engine>;
  41396. /**
  41397. * Gets the latest created scene
  41398. */
  41399. static get LastCreatedScene(): Nullable<Scene>;
  41400. /**
  41401. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41402. * @ignorenaming
  41403. */
  41404. static UseFallbackTexture: boolean;
  41405. /**
  41406. * Texture content used if a texture cannot loaded
  41407. * @ignorenaming
  41408. */
  41409. static FallbackTexture: string;
  41410. }
  41411. }
  41412. declare module BABYLON {
  41413. /**
  41414. * Helper class that provides a small promise polyfill
  41415. */
  41416. export class PromisePolyfill {
  41417. /**
  41418. * Static function used to check if the polyfill is required
  41419. * If this is the case then the function will inject the polyfill to window.Promise
  41420. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41421. */
  41422. static Apply(force?: boolean): void;
  41423. }
  41424. }
  41425. declare module BABYLON {
  41426. /**
  41427. * Interface for screenshot methods with describe argument called `size` as object with options
  41428. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41429. */
  41430. export interface IScreenshotSize {
  41431. /**
  41432. * number in pixels for canvas height
  41433. */
  41434. height?: number;
  41435. /**
  41436. * multiplier allowing render at a higher or lower resolution
  41437. * If value is defined then height and width will be ignored and taken from camera
  41438. */
  41439. precision?: number;
  41440. /**
  41441. * number in pixels for canvas width
  41442. */
  41443. width?: number;
  41444. }
  41445. }
  41446. declare module BABYLON {
  41447. interface IColor4Like {
  41448. r: float;
  41449. g: float;
  41450. b: float;
  41451. a: float;
  41452. }
  41453. /**
  41454. * Class containing a set of static utilities functions
  41455. */
  41456. export class Tools {
  41457. /**
  41458. * Gets or sets the base URL to use to load assets
  41459. */
  41460. static get BaseUrl(): string;
  41461. static set BaseUrl(value: string);
  41462. /**
  41463. * Enable/Disable Custom HTTP Request Headers globally.
  41464. * default = false
  41465. * @see CustomRequestHeaders
  41466. */
  41467. static UseCustomRequestHeaders: boolean;
  41468. /**
  41469. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41470. * i.e. when loading files, where the server/service expects an Authorization header
  41471. */
  41472. static CustomRequestHeaders: {
  41473. [key: string]: string;
  41474. };
  41475. /**
  41476. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41477. */
  41478. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41479. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41480. /**
  41481. * Default behaviour for cors in the application.
  41482. * It can be a string if the expected behavior is identical in the entire app.
  41483. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41484. */
  41485. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41486. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41487. /**
  41488. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41489. * @ignorenaming
  41490. */
  41491. static get UseFallbackTexture(): boolean;
  41492. static set UseFallbackTexture(value: boolean);
  41493. /**
  41494. * Use this object to register external classes like custom textures or material
  41495. * to allow the laoders to instantiate them
  41496. */
  41497. static get RegisteredExternalClasses(): {
  41498. [key: string]: Object;
  41499. };
  41500. static set RegisteredExternalClasses(classes: {
  41501. [key: string]: Object;
  41502. });
  41503. /**
  41504. * Texture content used if a texture cannot loaded
  41505. * @ignorenaming
  41506. */
  41507. static get fallbackTexture(): string;
  41508. static set fallbackTexture(value: string);
  41509. /**
  41510. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41511. * @param u defines the coordinate on X axis
  41512. * @param v defines the coordinate on Y axis
  41513. * @param width defines the width of the source data
  41514. * @param height defines the height of the source data
  41515. * @param pixels defines the source byte array
  41516. * @param color defines the output color
  41517. */
  41518. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41519. /**
  41520. * Interpolates between a and b via alpha
  41521. * @param a The lower value (returned when alpha = 0)
  41522. * @param b The upper value (returned when alpha = 1)
  41523. * @param alpha The interpolation-factor
  41524. * @return The mixed value
  41525. */
  41526. static Mix(a: number, b: number, alpha: number): number;
  41527. /**
  41528. * Tries to instantiate a new object from a given class name
  41529. * @param className defines the class name to instantiate
  41530. * @returns the new object or null if the system was not able to do the instantiation
  41531. */
  41532. static Instantiate(className: string): any;
  41533. /**
  41534. * Provides a slice function that will work even on IE
  41535. * @param data defines the array to slice
  41536. * @param start defines the start of the data (optional)
  41537. * @param end defines the end of the data (optional)
  41538. * @returns the new sliced array
  41539. */
  41540. static Slice<T>(data: T, start?: number, end?: number): T;
  41541. /**
  41542. * Provides a slice function that will work even on IE
  41543. * The difference between this and Slice is that this will force-convert to array
  41544. * @param data defines the array to slice
  41545. * @param start defines the start of the data (optional)
  41546. * @param end defines the end of the data (optional)
  41547. * @returns the new sliced array
  41548. */
  41549. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41550. /**
  41551. * Polyfill for setImmediate
  41552. * @param action defines the action to execute after the current execution block
  41553. */
  41554. static SetImmediate(action: () => void): void;
  41555. /**
  41556. * Function indicating if a number is an exponent of 2
  41557. * @param value defines the value to test
  41558. * @returns true if the value is an exponent of 2
  41559. */
  41560. static IsExponentOfTwo(value: number): boolean;
  41561. private static _tmpFloatArray;
  41562. /**
  41563. * Returns the nearest 32-bit single precision float representation of a Number
  41564. * @param value A Number. If the parameter is of a different type, it will get converted
  41565. * to a number or to NaN if it cannot be converted
  41566. * @returns number
  41567. */
  41568. static FloatRound(value: number): number;
  41569. /**
  41570. * Extracts the filename from a path
  41571. * @param path defines the path to use
  41572. * @returns the filename
  41573. */
  41574. static GetFilename(path: string): string;
  41575. /**
  41576. * Extracts the "folder" part of a path (everything before the filename).
  41577. * @param uri The URI to extract the info from
  41578. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41579. * @returns The "folder" part of the path
  41580. */
  41581. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41582. /**
  41583. * Extracts text content from a DOM element hierarchy
  41584. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41585. */
  41586. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41587. /**
  41588. * Convert an angle in radians to degrees
  41589. * @param angle defines the angle to convert
  41590. * @returns the angle in degrees
  41591. */
  41592. static ToDegrees(angle: number): number;
  41593. /**
  41594. * Convert an angle in degrees to radians
  41595. * @param angle defines the angle to convert
  41596. * @returns the angle in radians
  41597. */
  41598. static ToRadians(angle: number): number;
  41599. /**
  41600. * Returns an array if obj is not an array
  41601. * @param obj defines the object to evaluate as an array
  41602. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41603. * @returns either obj directly if obj is an array or a new array containing obj
  41604. */
  41605. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41606. /**
  41607. * Gets the pointer prefix to use
  41608. * @param engine defines the engine we are finding the prefix for
  41609. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41610. */
  41611. static GetPointerPrefix(engine: Engine): string;
  41612. /**
  41613. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41614. * @param url define the url we are trying
  41615. * @param element define the dom element where to configure the cors policy
  41616. */
  41617. static SetCorsBehavior(url: string | string[], element: {
  41618. crossOrigin: string | null;
  41619. }): void;
  41620. /**
  41621. * Removes unwanted characters from an url
  41622. * @param url defines the url to clean
  41623. * @returns the cleaned url
  41624. */
  41625. static CleanUrl(url: string): string;
  41626. /**
  41627. * Gets or sets a function used to pre-process url before using them to load assets
  41628. */
  41629. static get PreprocessUrl(): (url: string) => string;
  41630. static set PreprocessUrl(processor: (url: string) => string);
  41631. /**
  41632. * Loads an image as an HTMLImageElement.
  41633. * @param input url string, ArrayBuffer, or Blob to load
  41634. * @param onLoad callback called when the image successfully loads
  41635. * @param onError callback called when the image fails to load
  41636. * @param offlineProvider offline provider for caching
  41637. * @param mimeType optional mime type
  41638. * @returns the HTMLImageElement of the loaded image
  41639. */
  41640. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41641. /**
  41642. * Loads a file from a url
  41643. * @param url url string, ArrayBuffer, or Blob to load
  41644. * @param onSuccess callback called when the file successfully loads
  41645. * @param onProgress callback called while file is loading (if the server supports this mode)
  41646. * @param offlineProvider defines the offline provider for caching
  41647. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41648. * @param onError callback called when the file fails to load
  41649. * @returns a file request object
  41650. */
  41651. 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;
  41652. /**
  41653. * Loads a file from a url
  41654. * @param url the file url to load
  41655. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41656. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41657. */
  41658. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41659. /**
  41660. * Load a script (identified by an url). When the url returns, the
  41661. * content of this file is added into a new script element, attached to the DOM (body element)
  41662. * @param scriptUrl defines the url of the script to laod
  41663. * @param onSuccess defines the callback called when the script is loaded
  41664. * @param onError defines the callback to call if an error occurs
  41665. * @param scriptId defines the id of the script element
  41666. */
  41667. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41668. /**
  41669. * Load an asynchronous script (identified by an url). When the url returns, the
  41670. * content of this file is added into a new script element, attached to the DOM (body element)
  41671. * @param scriptUrl defines the url of the script to laod
  41672. * @param scriptId defines the id of the script element
  41673. * @returns a promise request object
  41674. */
  41675. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41676. /**
  41677. * Loads a file from a blob
  41678. * @param fileToLoad defines the blob to use
  41679. * @param callback defines the callback to call when data is loaded
  41680. * @param progressCallback defines the callback to call during loading process
  41681. * @returns a file request object
  41682. */
  41683. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41684. /**
  41685. * Reads a file from a File object
  41686. * @param file defines the file to load
  41687. * @param onSuccess defines the callback to call when data is loaded
  41688. * @param onProgress defines the callback to call during loading process
  41689. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41690. * @param onError defines the callback to call when an error occurs
  41691. * @returns a file request object
  41692. */
  41693. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41694. /**
  41695. * Creates a data url from a given string content
  41696. * @param content defines the content to convert
  41697. * @returns the new data url link
  41698. */
  41699. static FileAsURL(content: string): string;
  41700. /**
  41701. * Format the given number to a specific decimal format
  41702. * @param value defines the number to format
  41703. * @param decimals defines the number of decimals to use
  41704. * @returns the formatted string
  41705. */
  41706. static Format(value: number, decimals?: number): string;
  41707. /**
  41708. * Tries to copy an object by duplicating every property
  41709. * @param source defines the source object
  41710. * @param destination defines the target object
  41711. * @param doNotCopyList defines a list of properties to avoid
  41712. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41713. */
  41714. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41715. /**
  41716. * Gets a boolean indicating if the given object has no own property
  41717. * @param obj defines the object to test
  41718. * @returns true if object has no own property
  41719. */
  41720. static IsEmpty(obj: any): boolean;
  41721. /**
  41722. * Function used to register events at window level
  41723. * @param windowElement defines the Window object to use
  41724. * @param events defines the events to register
  41725. */
  41726. static RegisterTopRootEvents(windowElement: Window, events: {
  41727. name: string;
  41728. handler: Nullable<(e: FocusEvent) => any>;
  41729. }[]): void;
  41730. /**
  41731. * Function used to unregister events from window level
  41732. * @param windowElement defines the Window object to use
  41733. * @param events defines the events to unregister
  41734. */
  41735. static UnregisterTopRootEvents(windowElement: Window, events: {
  41736. name: string;
  41737. handler: Nullable<(e: FocusEvent) => any>;
  41738. }[]): void;
  41739. /**
  41740. * @ignore
  41741. */
  41742. static _ScreenshotCanvas: HTMLCanvasElement;
  41743. /**
  41744. * Dumps the current bound framebuffer
  41745. * @param width defines the rendering width
  41746. * @param height defines the rendering height
  41747. * @param engine defines the hosting engine
  41748. * @param successCallback defines the callback triggered once the data are available
  41749. * @param mimeType defines the mime type of the result
  41750. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  41751. */
  41752. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41753. /**
  41754. * Converts the canvas data to blob.
  41755. * This acts as a polyfill for browsers not supporting the to blob function.
  41756. * @param canvas Defines the canvas to extract the data from
  41757. * @param successCallback Defines the callback triggered once the data are available
  41758. * @param mimeType Defines the mime type of the result
  41759. */
  41760. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  41761. /**
  41762. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  41763. * @param successCallback defines the callback triggered once the data are available
  41764. * @param mimeType defines the mime type of the result
  41765. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  41766. */
  41767. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41768. /**
  41769. * Downloads a blob in the browser
  41770. * @param blob defines the blob to download
  41771. * @param fileName defines the name of the downloaded file
  41772. */
  41773. static Download(blob: Blob, fileName: string): void;
  41774. /**
  41775. * Will return the right value of the noPreventDefault variable
  41776. * Needed to keep backwards compatibility to the old API.
  41777. *
  41778. * @param args arguments passed to the attachControl function
  41779. * @returns the correct value for noPreventDefault
  41780. */
  41781. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  41782. /**
  41783. * Captures a screenshot of the current rendering
  41784. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41785. * @param engine defines the rendering engine
  41786. * @param camera defines the source camera
  41787. * @param size This parameter can be set to a single number or to an object with the
  41788. * following (optional) properties: precision, width, height. If a single number is passed,
  41789. * it will be used for both width and height. If an object is passed, the screenshot size
  41790. * will be derived from the parameters. The precision property is a multiplier allowing
  41791. * rendering at a higher or lower resolution
  41792. * @param successCallback defines the callback receives a single parameter which contains the
  41793. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41794. * src parameter of an <img> to display it
  41795. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41796. * Check your browser for supported MIME types
  41797. */
  41798. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  41799. /**
  41800. * Captures a screenshot of the current rendering
  41801. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41802. * @param engine defines the rendering engine
  41803. * @param camera defines the source camera
  41804. * @param size This parameter can be set to a single number or to an object with the
  41805. * following (optional) properties: precision, width, height. If a single number is passed,
  41806. * it will be used for both width and height. If an object is passed, the screenshot size
  41807. * will be derived from the parameters. The precision property is a multiplier allowing
  41808. * rendering at a higher or lower resolution
  41809. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41810. * Check your browser for supported MIME types
  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 CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  41815. /**
  41816. * Generates an image screenshot from the specified camera.
  41817. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41818. * @param engine The engine to use for rendering
  41819. * @param camera The camera to use for rendering
  41820. * @param size This parameter can be set to a single number or to an object with the
  41821. * following (optional) properties: precision, width, height. If a single number is passed,
  41822. * it will be used for both width and height. If an object is passed, the screenshot size
  41823. * will be derived from the parameters. The precision property is a multiplier allowing
  41824. * rendering at a higher or lower resolution
  41825. * @param successCallback The callback receives a single parameter which contains the
  41826. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41827. * src parameter of an <img> to display it
  41828. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41829. * Check your browser for supported MIME types
  41830. * @param samples Texture samples (default: 1)
  41831. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41832. * @param fileName A name for for the downloaded file.
  41833. */
  41834. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  41835. /**
  41836. * Generates an image screenshot from the specified camera.
  41837. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41838. * @param engine The engine to use for rendering
  41839. * @param camera The camera to use for rendering
  41840. * @param size This parameter can be set to a single number or to an object with the
  41841. * following (optional) properties: precision, width, height. If a single number is passed,
  41842. * it will be used for both width and height. If an object is passed, the screenshot size
  41843. * will be derived from the parameters. The precision property is a multiplier allowing
  41844. * rendering at a higher or lower resolution
  41845. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41846. * Check your browser for supported MIME types
  41847. * @param samples Texture samples (default: 1)
  41848. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41849. * @param fileName A name for for the downloaded file.
  41850. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41851. * to the src parameter of an <img> to display it
  41852. */
  41853. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  41854. /**
  41855. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  41856. * Be aware Math.random() could cause collisions, but:
  41857. * "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"
  41858. * @returns a pseudo random id
  41859. */
  41860. static RandomId(): string;
  41861. /**
  41862. * Test if the given uri is a base64 string
  41863. * @param uri The uri to test
  41864. * @return True if the uri is a base64 string or false otherwise
  41865. */
  41866. static IsBase64(uri: string): boolean;
  41867. /**
  41868. * Decode the given base64 uri.
  41869. * @param uri The uri to decode
  41870. * @return The decoded base64 data.
  41871. */
  41872. static DecodeBase64(uri: string): ArrayBuffer;
  41873. /**
  41874. * Gets the absolute url.
  41875. * @param url the input url
  41876. * @return the absolute url
  41877. */
  41878. static GetAbsoluteUrl(url: string): string;
  41879. /**
  41880. * No log
  41881. */
  41882. static readonly NoneLogLevel: number;
  41883. /**
  41884. * Only message logs
  41885. */
  41886. static readonly MessageLogLevel: number;
  41887. /**
  41888. * Only warning logs
  41889. */
  41890. static readonly WarningLogLevel: number;
  41891. /**
  41892. * Only error logs
  41893. */
  41894. static readonly ErrorLogLevel: number;
  41895. /**
  41896. * All logs
  41897. */
  41898. static readonly AllLogLevel: number;
  41899. /**
  41900. * Gets a value indicating the number of loading errors
  41901. * @ignorenaming
  41902. */
  41903. static get errorsCount(): number;
  41904. /**
  41905. * Callback called when a new log is added
  41906. */
  41907. static OnNewCacheEntry: (entry: string) => void;
  41908. /**
  41909. * Log a message to the console
  41910. * @param message defines the message to log
  41911. */
  41912. static Log(message: string): void;
  41913. /**
  41914. * Write a warning message to the console
  41915. * @param message defines the message to log
  41916. */
  41917. static Warn(message: string): void;
  41918. /**
  41919. * Write an error message to the console
  41920. * @param message defines the message to log
  41921. */
  41922. static Error(message: string): void;
  41923. /**
  41924. * Gets current log cache (list of logs)
  41925. */
  41926. static get LogCache(): string;
  41927. /**
  41928. * Clears the log cache
  41929. */
  41930. static ClearLogCache(): void;
  41931. /**
  41932. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  41933. */
  41934. static set LogLevels(level: number);
  41935. /**
  41936. * Checks if the window object exists
  41937. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  41938. */
  41939. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  41940. /**
  41941. * No performance log
  41942. */
  41943. static readonly PerformanceNoneLogLevel: number;
  41944. /**
  41945. * Use user marks to log performance
  41946. */
  41947. static readonly PerformanceUserMarkLogLevel: number;
  41948. /**
  41949. * Log performance to the console
  41950. */
  41951. static readonly PerformanceConsoleLogLevel: number;
  41952. private static _performance;
  41953. /**
  41954. * Sets the current performance log level
  41955. */
  41956. static set PerformanceLogLevel(level: number);
  41957. private static _StartPerformanceCounterDisabled;
  41958. private static _EndPerformanceCounterDisabled;
  41959. private static _StartUserMark;
  41960. private static _EndUserMark;
  41961. private static _StartPerformanceConsole;
  41962. private static _EndPerformanceConsole;
  41963. /**
  41964. * Starts a performance counter
  41965. */
  41966. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41967. /**
  41968. * Ends a specific performance coutner
  41969. */
  41970. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41971. /**
  41972. * Gets either window.performance.now() if supported or Date.now() else
  41973. */
  41974. static get Now(): number;
  41975. /**
  41976. * This method will return the name of the class used to create the instance of the given object.
  41977. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  41978. * @param object the object to get the class name from
  41979. * @param isType defines if the object is actually a type
  41980. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  41981. */
  41982. static GetClassName(object: any, isType?: boolean): string;
  41983. /**
  41984. * Gets the first element of an array satisfying a given predicate
  41985. * @param array defines the array to browse
  41986. * @param predicate defines the predicate to use
  41987. * @returns null if not found or the element
  41988. */
  41989. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  41990. /**
  41991. * This method will return the name of the full name of the class, including its owning module (if any).
  41992. * 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).
  41993. * @param object the object to get the class name from
  41994. * @param isType defines if the object is actually a type
  41995. * @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.
  41996. * @ignorenaming
  41997. */
  41998. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  41999. /**
  42000. * Returns a promise that resolves after the given amount of time.
  42001. * @param delay Number of milliseconds to delay
  42002. * @returns Promise that resolves after the given amount of time
  42003. */
  42004. static DelayAsync(delay: number): Promise<void>;
  42005. /**
  42006. * Utility function to detect if the current user agent is Safari
  42007. * @returns whether or not the current user agent is safari
  42008. */
  42009. static IsSafari(): boolean;
  42010. }
  42011. /**
  42012. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  42013. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  42014. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  42015. * @param name The name of the class, case should be preserved
  42016. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  42017. */
  42018. export function className(name: string, module?: string): (target: Object) => void;
  42019. /**
  42020. * An implementation of a loop for asynchronous functions.
  42021. */
  42022. export class AsyncLoop {
  42023. /**
  42024. * Defines the number of iterations for the loop
  42025. */
  42026. iterations: number;
  42027. /**
  42028. * Defines the current index of the loop.
  42029. */
  42030. index: number;
  42031. private _done;
  42032. private _fn;
  42033. private _successCallback;
  42034. /**
  42035. * Constructor.
  42036. * @param iterations the number of iterations.
  42037. * @param func the function to run each iteration
  42038. * @param successCallback the callback that will be called upon succesful execution
  42039. * @param offset starting offset.
  42040. */
  42041. constructor(
  42042. /**
  42043. * Defines the number of iterations for the loop
  42044. */
  42045. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42046. /**
  42047. * Execute the next iteration. Must be called after the last iteration was finished.
  42048. */
  42049. executeNext(): void;
  42050. /**
  42051. * Break the loop and run the success callback.
  42052. */
  42053. breakLoop(): void;
  42054. /**
  42055. * Create and run an async loop.
  42056. * @param iterations the number of iterations.
  42057. * @param fn the function to run each iteration
  42058. * @param successCallback the callback that will be called upon succesful execution
  42059. * @param offset starting offset.
  42060. * @returns the created async loop object
  42061. */
  42062. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42063. /**
  42064. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42065. * @param iterations total number of iterations
  42066. * @param syncedIterations number of synchronous iterations in each async iteration.
  42067. * @param fn the function to call each iteration.
  42068. * @param callback a success call back that will be called when iterating stops.
  42069. * @param breakFunction a break condition (optional)
  42070. * @param timeout timeout settings for the setTimeout function. default - 0.
  42071. * @returns the created async loop object
  42072. */
  42073. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42074. }
  42075. }
  42076. declare module BABYLON {
  42077. /**
  42078. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42079. * The underlying implementation relies on an associative array to ensure the best performances.
  42080. * The value can be anything including 'null' but except 'undefined'
  42081. */
  42082. export class StringDictionary<T> {
  42083. /**
  42084. * This will clear this dictionary and copy the content from the 'source' one.
  42085. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42086. * @param source the dictionary to take the content from and copy to this dictionary
  42087. */
  42088. copyFrom(source: StringDictionary<T>): void;
  42089. /**
  42090. * Get a value based from its key
  42091. * @param key the given key to get the matching value from
  42092. * @return the value if found, otherwise undefined is returned
  42093. */
  42094. get(key: string): T | undefined;
  42095. /**
  42096. * Get a value from its key or add it if it doesn't exist.
  42097. * This method will ensure you that a given key/data will be present in the dictionary.
  42098. * @param key the given key to get the matching value from
  42099. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42100. * The factory will only be invoked if there's no data for the given key.
  42101. * @return the value corresponding to the key.
  42102. */
  42103. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42104. /**
  42105. * Get a value from its key if present in the dictionary otherwise add it
  42106. * @param key the key to get the value from
  42107. * @param val if there's no such key/value pair in the dictionary add it with this value
  42108. * @return the value corresponding to the key
  42109. */
  42110. getOrAdd(key: string, val: T): T;
  42111. /**
  42112. * Check if there's a given key in the dictionary
  42113. * @param key the key to check for
  42114. * @return true if the key is present, false otherwise
  42115. */
  42116. contains(key: string): boolean;
  42117. /**
  42118. * Add a new key and its corresponding value
  42119. * @param key the key to add
  42120. * @param value the value corresponding to the key
  42121. * @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
  42122. */
  42123. add(key: string, value: T): boolean;
  42124. /**
  42125. * Update a specific value associated to a key
  42126. * @param key defines the key to use
  42127. * @param value defines the value to store
  42128. * @returns true if the value was updated (or false if the key was not found)
  42129. */
  42130. set(key: string, value: T): boolean;
  42131. /**
  42132. * Get the element of the given key and remove it from the dictionary
  42133. * @param key defines the key to search
  42134. * @returns the value associated with the key or null if not found
  42135. */
  42136. getAndRemove(key: string): Nullable<T>;
  42137. /**
  42138. * Remove a key/value from the dictionary.
  42139. * @param key the key to remove
  42140. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42141. */
  42142. remove(key: string): boolean;
  42143. /**
  42144. * Clear the whole content of the dictionary
  42145. */
  42146. clear(): void;
  42147. /**
  42148. * Gets the current count
  42149. */
  42150. get count(): number;
  42151. /**
  42152. * Execute a callback on each key/val of the dictionary.
  42153. * Note that you can remove any element in this dictionary in the callback implementation
  42154. * @param callback the callback to execute on a given key/value pair
  42155. */
  42156. forEach(callback: (key: string, val: T) => void): void;
  42157. /**
  42158. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42159. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42160. * Note that you can remove any element in this dictionary in the callback implementation
  42161. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42162. * @returns the first item
  42163. */
  42164. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42165. private _count;
  42166. private _data;
  42167. }
  42168. }
  42169. declare module BABYLON {
  42170. /** @hidden */
  42171. export interface ICollisionCoordinator {
  42172. createCollider(): Collider;
  42173. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42174. init(scene: Scene): void;
  42175. }
  42176. /** @hidden */
  42177. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42178. private _scene;
  42179. private _scaledPosition;
  42180. private _scaledVelocity;
  42181. private _finalPosition;
  42182. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42183. createCollider(): Collider;
  42184. init(scene: Scene): void;
  42185. private _collideWithWorld;
  42186. }
  42187. }
  42188. declare module BABYLON {
  42189. /**
  42190. * Class used to manage all inputs for the scene.
  42191. */
  42192. export class InputManager {
  42193. /** The distance in pixel that you have to move to prevent some events */
  42194. static DragMovementThreshold: number;
  42195. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42196. static LongPressDelay: number;
  42197. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42198. static DoubleClickDelay: number;
  42199. /** If you need to check double click without raising a single click at first click, enable this flag */
  42200. static ExclusiveDoubleClickMode: boolean;
  42201. /** 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. */
  42202. private _alreadyAttached;
  42203. private _alreadyAttachedTo;
  42204. private _wheelEventName;
  42205. private _onPointerMove;
  42206. private _onPointerDown;
  42207. private _onPointerUp;
  42208. private _initClickEvent;
  42209. private _initActionManager;
  42210. private _delayedSimpleClick;
  42211. private _delayedSimpleClickTimeout;
  42212. private _previousDelayedSimpleClickTimeout;
  42213. private _meshPickProceed;
  42214. private _previousButtonPressed;
  42215. private _currentPickResult;
  42216. private _previousPickResult;
  42217. private _totalPointersPressed;
  42218. private _doubleClickOccured;
  42219. private _pointerOverMesh;
  42220. private _pickedDownMesh;
  42221. private _pickedUpMesh;
  42222. private _pointerX;
  42223. private _pointerY;
  42224. private _unTranslatedPointerX;
  42225. private _unTranslatedPointerY;
  42226. private _startingPointerPosition;
  42227. private _previousStartingPointerPosition;
  42228. private _startingPointerTime;
  42229. private _previousStartingPointerTime;
  42230. private _pointerCaptures;
  42231. private _meshUnderPointerId;
  42232. private _onKeyDown;
  42233. private _onKeyUp;
  42234. private _keyboardIsAttached;
  42235. private _onCanvasFocusObserver;
  42236. private _onCanvasBlurObserver;
  42237. private _scene;
  42238. /**
  42239. * Creates a new InputManager
  42240. * @param scene defines the hosting scene
  42241. */
  42242. constructor(scene: Scene);
  42243. /**
  42244. * Gets the mesh that is currently under the pointer
  42245. */
  42246. get meshUnderPointer(): Nullable<AbstractMesh>;
  42247. /**
  42248. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42249. * @param pointerId the pointer id to use
  42250. * @returns The mesh under this pointer id or null if not found
  42251. */
  42252. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42253. /**
  42254. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42255. */
  42256. get unTranslatedPointer(): Vector2;
  42257. /**
  42258. * Gets or sets the current on-screen X position of the pointer
  42259. */
  42260. get pointerX(): number;
  42261. set pointerX(value: number);
  42262. /**
  42263. * Gets or sets the current on-screen Y position of the pointer
  42264. */
  42265. get pointerY(): number;
  42266. set pointerY(value: number);
  42267. private _updatePointerPosition;
  42268. private _processPointerMove;
  42269. private _setRayOnPointerInfo;
  42270. private _checkPrePointerObservable;
  42271. /**
  42272. * Use this method to simulate a pointer move on a mesh
  42273. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42274. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42275. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42276. */
  42277. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42278. /**
  42279. * Use this method to simulate a pointer down on a mesh
  42280. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42281. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42282. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42283. */
  42284. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42285. private _processPointerDown;
  42286. /** @hidden */
  42287. _isPointerSwiping(): boolean;
  42288. /**
  42289. * Use this method to simulate a pointer up on a mesh
  42290. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42291. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42292. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42293. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42294. */
  42295. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42296. private _processPointerUp;
  42297. /**
  42298. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42299. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42300. * @returns true if the pointer was captured
  42301. */
  42302. isPointerCaptured(pointerId?: number): boolean;
  42303. /**
  42304. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42305. * @param attachUp defines if you want to attach events to pointerup
  42306. * @param attachDown defines if you want to attach events to pointerdown
  42307. * @param attachMove defines if you want to attach events to pointermove
  42308. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42309. */
  42310. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42311. /**
  42312. * Detaches all event handlers
  42313. */
  42314. detachControl(): void;
  42315. /**
  42316. * Force the value of meshUnderPointer
  42317. * @param mesh defines the mesh to use
  42318. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42319. */
  42320. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42321. /**
  42322. * Gets the mesh under the pointer
  42323. * @returns a Mesh or null if no mesh is under the pointer
  42324. */
  42325. getPointerOverMesh(): Nullable<AbstractMesh>;
  42326. }
  42327. }
  42328. declare module BABYLON {
  42329. /**
  42330. * This class defines the direct association between an animation and a target
  42331. */
  42332. export class TargetedAnimation {
  42333. /**
  42334. * Animation to perform
  42335. */
  42336. animation: Animation;
  42337. /**
  42338. * Target to animate
  42339. */
  42340. target: any;
  42341. /**
  42342. * Returns the string "TargetedAnimation"
  42343. * @returns "TargetedAnimation"
  42344. */
  42345. getClassName(): string;
  42346. /**
  42347. * Serialize the object
  42348. * @returns the JSON object representing the current entity
  42349. */
  42350. serialize(): any;
  42351. }
  42352. /**
  42353. * Use this class to create coordinated animations on multiple targets
  42354. */
  42355. export class AnimationGroup implements IDisposable {
  42356. /** The name of the animation group */
  42357. name: string;
  42358. private _scene;
  42359. private _targetedAnimations;
  42360. private _animatables;
  42361. private _from;
  42362. private _to;
  42363. private _isStarted;
  42364. private _isPaused;
  42365. private _speedRatio;
  42366. private _loopAnimation;
  42367. private _isAdditive;
  42368. /**
  42369. * Gets or sets the unique id of the node
  42370. */
  42371. uniqueId: number;
  42372. /**
  42373. * This observable will notify when one animation have ended
  42374. */
  42375. onAnimationEndObservable: Observable<TargetedAnimation>;
  42376. /**
  42377. * Observer raised when one animation loops
  42378. */
  42379. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42380. /**
  42381. * Observer raised when all animations have looped
  42382. */
  42383. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42384. /**
  42385. * This observable will notify when all animations have ended.
  42386. */
  42387. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42388. /**
  42389. * This observable will notify when all animations have paused.
  42390. */
  42391. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42392. /**
  42393. * This observable will notify when all animations are playing.
  42394. */
  42395. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42396. /**
  42397. * Gets the first frame
  42398. */
  42399. get from(): number;
  42400. /**
  42401. * Gets the last frame
  42402. */
  42403. get to(): number;
  42404. /**
  42405. * Define if the animations are started
  42406. */
  42407. get isStarted(): boolean;
  42408. /**
  42409. * Gets a value indicating that the current group is playing
  42410. */
  42411. get isPlaying(): boolean;
  42412. /**
  42413. * Gets or sets the speed ratio to use for all animations
  42414. */
  42415. get speedRatio(): number;
  42416. /**
  42417. * Gets or sets the speed ratio to use for all animations
  42418. */
  42419. set speedRatio(value: number);
  42420. /**
  42421. * Gets or sets if all animations should loop or not
  42422. */
  42423. get loopAnimation(): boolean;
  42424. set loopAnimation(value: boolean);
  42425. /**
  42426. * Gets or sets if all animations should be evaluated additively
  42427. */
  42428. get isAdditive(): boolean;
  42429. set isAdditive(value: boolean);
  42430. /**
  42431. * Gets the targeted animations for this animation group
  42432. */
  42433. get targetedAnimations(): Array<TargetedAnimation>;
  42434. /**
  42435. * returning the list of animatables controlled by this animation group.
  42436. */
  42437. get animatables(): Array<Animatable>;
  42438. /**
  42439. * Gets the list of target animations
  42440. */
  42441. get children(): TargetedAnimation[];
  42442. /**
  42443. * Instantiates a new Animation Group.
  42444. * This helps managing several animations at once.
  42445. * @see https://doc.babylonjs.com/how_to/group
  42446. * @param name Defines the name of the group
  42447. * @param scene Defines the scene the group belongs to
  42448. */
  42449. constructor(
  42450. /** The name of the animation group */
  42451. name: string, scene?: Nullable<Scene>);
  42452. /**
  42453. * Add an animation (with its target) in the group
  42454. * @param animation defines the animation we want to add
  42455. * @param target defines the target of the animation
  42456. * @returns the TargetedAnimation object
  42457. */
  42458. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42459. /**
  42460. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42461. * It can add constant keys at begin or end
  42462. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42463. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42464. * @returns the animation group
  42465. */
  42466. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42467. private _animationLoopCount;
  42468. private _animationLoopFlags;
  42469. private _processLoop;
  42470. /**
  42471. * Start all animations on given targets
  42472. * @param loop defines if animations must loop
  42473. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42474. * @param from defines the from key (optional)
  42475. * @param to defines the to key (optional)
  42476. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42477. * @returns the current animation group
  42478. */
  42479. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42480. /**
  42481. * Pause all animations
  42482. * @returns the animation group
  42483. */
  42484. pause(): AnimationGroup;
  42485. /**
  42486. * Play all animations to initial state
  42487. * This function will start() the animations if they were not started or will restart() them if they were paused
  42488. * @param loop defines if animations must loop
  42489. * @returns the animation group
  42490. */
  42491. play(loop?: boolean): AnimationGroup;
  42492. /**
  42493. * Reset all animations to initial state
  42494. * @returns the animation group
  42495. */
  42496. reset(): AnimationGroup;
  42497. /**
  42498. * Restart animations from key 0
  42499. * @returns the animation group
  42500. */
  42501. restart(): AnimationGroup;
  42502. /**
  42503. * Stop all animations
  42504. * @returns the animation group
  42505. */
  42506. stop(): AnimationGroup;
  42507. /**
  42508. * Set animation weight for all animatables
  42509. * @param weight defines the weight to use
  42510. * @return the animationGroup
  42511. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42512. */
  42513. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42514. /**
  42515. * Synchronize and normalize all animatables with a source animatable
  42516. * @param root defines the root animatable to synchronize with
  42517. * @return the animationGroup
  42518. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42519. */
  42520. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42521. /**
  42522. * Goes to a specific frame in this animation group
  42523. * @param frame the frame number to go to
  42524. * @return the animationGroup
  42525. */
  42526. goToFrame(frame: number): AnimationGroup;
  42527. /**
  42528. * Dispose all associated resources
  42529. */
  42530. dispose(): void;
  42531. private _checkAnimationGroupEnded;
  42532. /**
  42533. * Clone the current animation group and returns a copy
  42534. * @param newName defines the name of the new group
  42535. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42536. * @returns the new aniamtion group
  42537. */
  42538. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42539. /**
  42540. * Serializes the animationGroup to an object
  42541. * @returns Serialized object
  42542. */
  42543. serialize(): any;
  42544. /**
  42545. * Returns a new AnimationGroup object parsed from the source provided.
  42546. * @param parsedAnimationGroup defines the source
  42547. * @param scene defines the scene that will receive the animationGroup
  42548. * @returns a new AnimationGroup
  42549. */
  42550. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42551. /**
  42552. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42553. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42554. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42555. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42556. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42557. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42558. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42559. */
  42560. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42561. /**
  42562. * Returns the string "AnimationGroup"
  42563. * @returns "AnimationGroup"
  42564. */
  42565. getClassName(): string;
  42566. /**
  42567. * Creates a detailled string about the object
  42568. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42569. * @returns a string representing the object
  42570. */
  42571. toString(fullDetails?: boolean): string;
  42572. }
  42573. }
  42574. declare module BABYLON {
  42575. /**
  42576. * Define an interface for all classes that will hold resources
  42577. */
  42578. export interface IDisposable {
  42579. /**
  42580. * Releases all held resources
  42581. */
  42582. dispose(): void;
  42583. }
  42584. /** Interface defining initialization parameters for Scene class */
  42585. export interface SceneOptions {
  42586. /**
  42587. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42588. * It will improve performance when the number of geometries becomes important.
  42589. */
  42590. useGeometryUniqueIdsMap?: boolean;
  42591. /**
  42592. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42593. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42594. */
  42595. useMaterialMeshMap?: boolean;
  42596. /**
  42597. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42598. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42599. */
  42600. useClonedMeshMap?: boolean;
  42601. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42602. virtual?: boolean;
  42603. }
  42604. /**
  42605. * Represents a scene to be rendered by the engine.
  42606. * @see https://doc.babylonjs.com/features/scene
  42607. */
  42608. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42609. /** The fog is deactivated */
  42610. static readonly FOGMODE_NONE: number;
  42611. /** The fog density is following an exponential function */
  42612. static readonly FOGMODE_EXP: number;
  42613. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42614. static readonly FOGMODE_EXP2: number;
  42615. /** The fog density is following a linear function. */
  42616. static readonly FOGMODE_LINEAR: number;
  42617. /**
  42618. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42619. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42620. */
  42621. static MinDeltaTime: number;
  42622. /**
  42623. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42624. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42625. */
  42626. static MaxDeltaTime: number;
  42627. /**
  42628. * Factory used to create the default material.
  42629. * @param name The name of the material to create
  42630. * @param scene The scene to create the material for
  42631. * @returns The default material
  42632. */
  42633. static DefaultMaterialFactory(scene: Scene): Material;
  42634. /**
  42635. * Factory used to create the a collision coordinator.
  42636. * @returns The collision coordinator
  42637. */
  42638. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42639. /** @hidden */
  42640. _inputManager: InputManager;
  42641. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42642. cameraToUseForPointers: Nullable<Camera>;
  42643. /** @hidden */
  42644. readonly _isScene: boolean;
  42645. /** @hidden */
  42646. _blockEntityCollection: boolean;
  42647. /**
  42648. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42649. */
  42650. autoClear: boolean;
  42651. /**
  42652. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42653. */
  42654. autoClearDepthAndStencil: boolean;
  42655. /**
  42656. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42657. */
  42658. clearColor: Color4;
  42659. /**
  42660. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42661. */
  42662. ambientColor: Color3;
  42663. /**
  42664. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42665. * It should only be one of the following (if not the default embedded one):
  42666. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42667. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42668. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42669. * The material properties need to be setup according to the type of texture in use.
  42670. */
  42671. environmentBRDFTexture: BaseTexture;
  42672. /**
  42673. * Texture used in all pbr material as the reflection texture.
  42674. * As in the majority of the scene they are the same (exception for multi room and so on),
  42675. * this is easier to reference from here than from all the materials.
  42676. */
  42677. get environmentTexture(): Nullable<BaseTexture>;
  42678. /**
  42679. * Texture used in all pbr material as the reflection texture.
  42680. * As in the majority of the scene they are the same (exception for multi room and so on),
  42681. * this is easier to set here than in all the materials.
  42682. */
  42683. set environmentTexture(value: Nullable<BaseTexture>);
  42684. /** @hidden */
  42685. protected _environmentIntensity: number;
  42686. /**
  42687. * Intensity of the environment in all pbr material.
  42688. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42689. * As in the majority of the scene they are the same (exception for multi room and so on),
  42690. * this is easier to reference from here than from all the materials.
  42691. */
  42692. get environmentIntensity(): number;
  42693. /**
  42694. * Intensity of the environment in all pbr material.
  42695. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42696. * As in the majority of the scene they are the same (exception for multi room and so on),
  42697. * this is easier to set here than in all the materials.
  42698. */
  42699. set environmentIntensity(value: number);
  42700. /** @hidden */
  42701. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42702. /**
  42703. * Default image processing configuration used either in the rendering
  42704. * Forward main pass or through the imageProcessingPostProcess if present.
  42705. * As in the majority of the scene they are the same (exception for multi camera),
  42706. * this is easier to reference from here than from all the materials and post process.
  42707. *
  42708. * No setter as we it is a shared configuration, you can set the values instead.
  42709. */
  42710. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42711. private _forceWireframe;
  42712. /**
  42713. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42714. */
  42715. set forceWireframe(value: boolean);
  42716. get forceWireframe(): boolean;
  42717. private _skipFrustumClipping;
  42718. /**
  42719. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42720. */
  42721. set skipFrustumClipping(value: boolean);
  42722. get skipFrustumClipping(): boolean;
  42723. private _forcePointsCloud;
  42724. /**
  42725. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42726. */
  42727. set forcePointsCloud(value: boolean);
  42728. get forcePointsCloud(): boolean;
  42729. /**
  42730. * Gets or sets the active clipplane 1
  42731. */
  42732. clipPlane: Nullable<Plane>;
  42733. /**
  42734. * Gets or sets the active clipplane 2
  42735. */
  42736. clipPlane2: Nullable<Plane>;
  42737. /**
  42738. * Gets or sets the active clipplane 3
  42739. */
  42740. clipPlane3: Nullable<Plane>;
  42741. /**
  42742. * Gets or sets the active clipplane 4
  42743. */
  42744. clipPlane4: Nullable<Plane>;
  42745. /**
  42746. * Gets or sets the active clipplane 5
  42747. */
  42748. clipPlane5: Nullable<Plane>;
  42749. /**
  42750. * Gets or sets the active clipplane 6
  42751. */
  42752. clipPlane6: Nullable<Plane>;
  42753. /**
  42754. * Gets or sets a boolean indicating if animations are enabled
  42755. */
  42756. animationsEnabled: boolean;
  42757. private _animationPropertiesOverride;
  42758. /**
  42759. * Gets or sets the animation properties override
  42760. */
  42761. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  42762. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  42763. /**
  42764. * Gets or sets a boolean indicating if a constant deltatime has to be used
  42765. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  42766. */
  42767. useConstantAnimationDeltaTime: boolean;
  42768. /**
  42769. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  42770. * Please note that it requires to run a ray cast through the scene on every frame
  42771. */
  42772. constantlyUpdateMeshUnderPointer: boolean;
  42773. /**
  42774. * Defines the HTML cursor to use when hovering over interactive elements
  42775. */
  42776. hoverCursor: string;
  42777. /**
  42778. * Defines the HTML default cursor to use (empty by default)
  42779. */
  42780. defaultCursor: string;
  42781. /**
  42782. * Defines whether cursors are handled by the scene.
  42783. */
  42784. doNotHandleCursors: boolean;
  42785. /**
  42786. * This is used to call preventDefault() on pointer down
  42787. * in order to block unwanted artifacts like system double clicks
  42788. */
  42789. preventDefaultOnPointerDown: boolean;
  42790. /**
  42791. * This is used to call preventDefault() on pointer up
  42792. * in order to block unwanted artifacts like system double clicks
  42793. */
  42794. preventDefaultOnPointerUp: boolean;
  42795. /**
  42796. * Gets or sets user defined metadata
  42797. */
  42798. metadata: any;
  42799. /**
  42800. * For internal use only. Please do not use.
  42801. */
  42802. reservedDataStore: any;
  42803. /**
  42804. * Gets the name of the plugin used to load this scene (null by default)
  42805. */
  42806. loadingPluginName: string;
  42807. /**
  42808. * Use this array to add regular expressions used to disable offline support for specific urls
  42809. */
  42810. disableOfflineSupportExceptionRules: RegExp[];
  42811. /**
  42812. * An event triggered when the scene is disposed.
  42813. */
  42814. onDisposeObservable: Observable<Scene>;
  42815. private _onDisposeObserver;
  42816. /** Sets a function to be executed when this scene is disposed. */
  42817. set onDispose(callback: () => void);
  42818. /**
  42819. * An event triggered before rendering the scene (right after animations and physics)
  42820. */
  42821. onBeforeRenderObservable: Observable<Scene>;
  42822. private _onBeforeRenderObserver;
  42823. /** Sets a function to be executed before rendering this scene */
  42824. set beforeRender(callback: Nullable<() => void>);
  42825. /**
  42826. * An event triggered after rendering the scene
  42827. */
  42828. onAfterRenderObservable: Observable<Scene>;
  42829. /**
  42830. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  42831. */
  42832. onAfterRenderCameraObservable: Observable<Camera>;
  42833. private _onAfterRenderObserver;
  42834. /** Sets a function to be executed after rendering this scene */
  42835. set afterRender(callback: Nullable<() => void>);
  42836. /**
  42837. * An event triggered before animating the scene
  42838. */
  42839. onBeforeAnimationsObservable: Observable<Scene>;
  42840. /**
  42841. * An event triggered after animations processing
  42842. */
  42843. onAfterAnimationsObservable: Observable<Scene>;
  42844. /**
  42845. * An event triggered before draw calls are ready to be sent
  42846. */
  42847. onBeforeDrawPhaseObservable: Observable<Scene>;
  42848. /**
  42849. * An event triggered after draw calls have been sent
  42850. */
  42851. onAfterDrawPhaseObservable: Observable<Scene>;
  42852. /**
  42853. * An event triggered when the scene is ready
  42854. */
  42855. onReadyObservable: Observable<Scene>;
  42856. /**
  42857. * An event triggered before rendering a camera
  42858. */
  42859. onBeforeCameraRenderObservable: Observable<Camera>;
  42860. private _onBeforeCameraRenderObserver;
  42861. /** Sets a function to be executed before rendering a camera*/
  42862. set beforeCameraRender(callback: () => void);
  42863. /**
  42864. * An event triggered after rendering a camera
  42865. */
  42866. onAfterCameraRenderObservable: Observable<Camera>;
  42867. private _onAfterCameraRenderObserver;
  42868. /** Sets a function to be executed after rendering a camera*/
  42869. set afterCameraRender(callback: () => void);
  42870. /**
  42871. * An event triggered when active meshes evaluation is about to start
  42872. */
  42873. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  42874. /**
  42875. * An event triggered when active meshes evaluation is done
  42876. */
  42877. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  42878. /**
  42879. * An event triggered when particles rendering is about to start
  42880. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42881. */
  42882. onBeforeParticlesRenderingObservable: Observable<Scene>;
  42883. /**
  42884. * An event triggered when particles rendering is done
  42885. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42886. */
  42887. onAfterParticlesRenderingObservable: Observable<Scene>;
  42888. /**
  42889. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  42890. */
  42891. onDataLoadedObservable: Observable<Scene>;
  42892. /**
  42893. * An event triggered when a camera is created
  42894. */
  42895. onNewCameraAddedObservable: Observable<Camera>;
  42896. /**
  42897. * An event triggered when a camera is removed
  42898. */
  42899. onCameraRemovedObservable: Observable<Camera>;
  42900. /**
  42901. * An event triggered when a light is created
  42902. */
  42903. onNewLightAddedObservable: Observable<Light>;
  42904. /**
  42905. * An event triggered when a light is removed
  42906. */
  42907. onLightRemovedObservable: Observable<Light>;
  42908. /**
  42909. * An event triggered when a geometry is created
  42910. */
  42911. onNewGeometryAddedObservable: Observable<Geometry>;
  42912. /**
  42913. * An event triggered when a geometry is removed
  42914. */
  42915. onGeometryRemovedObservable: Observable<Geometry>;
  42916. /**
  42917. * An event triggered when a transform node is created
  42918. */
  42919. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  42920. /**
  42921. * An event triggered when a transform node is removed
  42922. */
  42923. onTransformNodeRemovedObservable: Observable<TransformNode>;
  42924. /**
  42925. * An event triggered when a mesh is created
  42926. */
  42927. onNewMeshAddedObservable: Observable<AbstractMesh>;
  42928. /**
  42929. * An event triggered when a mesh is removed
  42930. */
  42931. onMeshRemovedObservable: Observable<AbstractMesh>;
  42932. /**
  42933. * An event triggered when a skeleton is created
  42934. */
  42935. onNewSkeletonAddedObservable: Observable<Skeleton>;
  42936. /**
  42937. * An event triggered when a skeleton is removed
  42938. */
  42939. onSkeletonRemovedObservable: Observable<Skeleton>;
  42940. /**
  42941. * An event triggered when a material is created
  42942. */
  42943. onNewMaterialAddedObservable: Observable<Material>;
  42944. /**
  42945. * An event triggered when a material is removed
  42946. */
  42947. onMaterialRemovedObservable: Observable<Material>;
  42948. /**
  42949. * An event triggered when a texture is created
  42950. */
  42951. onNewTextureAddedObservable: Observable<BaseTexture>;
  42952. /**
  42953. * An event triggered when a texture is removed
  42954. */
  42955. onTextureRemovedObservable: Observable<BaseTexture>;
  42956. /**
  42957. * An event triggered when render targets are about to be rendered
  42958. * Can happen multiple times per frame.
  42959. */
  42960. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  42961. /**
  42962. * An event triggered when render targets were rendered.
  42963. * Can happen multiple times per frame.
  42964. */
  42965. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  42966. /**
  42967. * An event triggered before calculating deterministic simulation step
  42968. */
  42969. onBeforeStepObservable: Observable<Scene>;
  42970. /**
  42971. * An event triggered after calculating deterministic simulation step
  42972. */
  42973. onAfterStepObservable: Observable<Scene>;
  42974. /**
  42975. * An event triggered when the activeCamera property is updated
  42976. */
  42977. onActiveCameraChanged: Observable<Scene>;
  42978. /**
  42979. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  42980. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42981. * 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)
  42982. */
  42983. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42984. /**
  42985. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  42986. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42987. * 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)
  42988. */
  42989. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42990. /**
  42991. * This Observable will when a mesh has been imported into the scene.
  42992. */
  42993. onMeshImportedObservable: Observable<AbstractMesh>;
  42994. /**
  42995. * This Observable will when an animation file has been imported into the scene.
  42996. */
  42997. onAnimationFileImportedObservable: Observable<Scene>;
  42998. /**
  42999. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  43000. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  43001. */
  43002. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  43003. /** @hidden */
  43004. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  43005. /**
  43006. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  43007. */
  43008. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  43009. /**
  43010. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  43011. */
  43012. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  43013. /**
  43014. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  43015. */
  43016. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  43017. /** Callback called when a pointer move is detected */
  43018. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43019. /** Callback called when a pointer down is detected */
  43020. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43021. /** Callback called when a pointer up is detected */
  43022. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  43023. /** Callback called when a pointer pick is detected */
  43024. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  43025. /**
  43026. * 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).
  43027. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  43028. */
  43029. onPrePointerObservable: Observable<PointerInfoPre>;
  43030. /**
  43031. * Observable event triggered each time an input event is received from the rendering canvas
  43032. */
  43033. onPointerObservable: Observable<PointerInfo>;
  43034. /**
  43035. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  43036. */
  43037. get unTranslatedPointer(): Vector2;
  43038. /**
  43039. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43040. */
  43041. static get DragMovementThreshold(): number;
  43042. static set DragMovementThreshold(value: number);
  43043. /**
  43044. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43045. */
  43046. static get LongPressDelay(): number;
  43047. static set LongPressDelay(value: number);
  43048. /**
  43049. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43050. */
  43051. static get DoubleClickDelay(): number;
  43052. static set DoubleClickDelay(value: number);
  43053. /** If you need to check double click without raising a single click at first click, enable this flag */
  43054. static get ExclusiveDoubleClickMode(): boolean;
  43055. static set ExclusiveDoubleClickMode(value: boolean);
  43056. /** @hidden */
  43057. _mirroredCameraPosition: Nullable<Vector3>;
  43058. /**
  43059. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43060. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43061. */
  43062. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43063. /**
  43064. * Observable event triggered each time an keyboard event is received from the hosting window
  43065. */
  43066. onKeyboardObservable: Observable<KeyboardInfo>;
  43067. private _useRightHandedSystem;
  43068. /**
  43069. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43070. */
  43071. set useRightHandedSystem(value: boolean);
  43072. get useRightHandedSystem(): boolean;
  43073. private _timeAccumulator;
  43074. private _currentStepId;
  43075. private _currentInternalStep;
  43076. /**
  43077. * Sets the step Id used by deterministic lock step
  43078. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43079. * @param newStepId defines the step Id
  43080. */
  43081. setStepId(newStepId: number): void;
  43082. /**
  43083. * Gets the step Id used by deterministic lock step
  43084. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43085. * @returns the step Id
  43086. */
  43087. getStepId(): number;
  43088. /**
  43089. * Gets the internal step used by deterministic lock step
  43090. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43091. * @returns the internal step
  43092. */
  43093. getInternalStep(): number;
  43094. private _fogEnabled;
  43095. /**
  43096. * Gets or sets a boolean indicating if fog is enabled on this scene
  43097. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43098. * (Default is true)
  43099. */
  43100. set fogEnabled(value: boolean);
  43101. get fogEnabled(): boolean;
  43102. private _fogMode;
  43103. /**
  43104. * Gets or sets the fog mode to use
  43105. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43106. * | mode | value |
  43107. * | --- | --- |
  43108. * | FOGMODE_NONE | 0 |
  43109. * | FOGMODE_EXP | 1 |
  43110. * | FOGMODE_EXP2 | 2 |
  43111. * | FOGMODE_LINEAR | 3 |
  43112. */
  43113. set fogMode(value: number);
  43114. get fogMode(): number;
  43115. /**
  43116. * Gets or sets the fog color to use
  43117. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43118. * (Default is Color3(0.2, 0.2, 0.3))
  43119. */
  43120. fogColor: Color3;
  43121. /**
  43122. * Gets or sets the fog density to use
  43123. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43124. * (Default is 0.1)
  43125. */
  43126. fogDensity: number;
  43127. /**
  43128. * Gets or sets the fog start distance to use
  43129. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43130. * (Default is 0)
  43131. */
  43132. fogStart: number;
  43133. /**
  43134. * Gets or sets the fog end distance to use
  43135. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43136. * (Default is 1000)
  43137. */
  43138. fogEnd: number;
  43139. /**
  43140. * Flag indicating that the frame buffer binding is handled by another component
  43141. */
  43142. prePass: boolean;
  43143. private _shadowsEnabled;
  43144. /**
  43145. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43146. */
  43147. set shadowsEnabled(value: boolean);
  43148. get shadowsEnabled(): boolean;
  43149. private _lightsEnabled;
  43150. /**
  43151. * Gets or sets a boolean indicating if lights are enabled on this scene
  43152. */
  43153. set lightsEnabled(value: boolean);
  43154. get lightsEnabled(): boolean;
  43155. /** All of the active cameras added to this scene. */
  43156. activeCameras: Camera[];
  43157. /** @hidden */
  43158. _activeCamera: Nullable<Camera>;
  43159. /** Gets or sets the current active camera */
  43160. get activeCamera(): Nullable<Camera>;
  43161. set activeCamera(value: Nullable<Camera>);
  43162. private _defaultMaterial;
  43163. /** The default material used on meshes when no material is affected */
  43164. get defaultMaterial(): Material;
  43165. /** The default material used on meshes when no material is affected */
  43166. set defaultMaterial(value: Material);
  43167. private _texturesEnabled;
  43168. /**
  43169. * Gets or sets a boolean indicating if textures are enabled on this scene
  43170. */
  43171. set texturesEnabled(value: boolean);
  43172. get texturesEnabled(): boolean;
  43173. /**
  43174. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43175. */
  43176. physicsEnabled: boolean;
  43177. /**
  43178. * Gets or sets a boolean indicating if particles are enabled on this scene
  43179. */
  43180. particlesEnabled: boolean;
  43181. /**
  43182. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43183. */
  43184. spritesEnabled: boolean;
  43185. private _skeletonsEnabled;
  43186. /**
  43187. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43188. */
  43189. set skeletonsEnabled(value: boolean);
  43190. get skeletonsEnabled(): boolean;
  43191. /**
  43192. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43193. */
  43194. lensFlaresEnabled: boolean;
  43195. /**
  43196. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43197. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43198. */
  43199. collisionsEnabled: boolean;
  43200. private _collisionCoordinator;
  43201. /** @hidden */
  43202. get collisionCoordinator(): ICollisionCoordinator;
  43203. /**
  43204. * Defines the gravity applied to this scene (used only for collisions)
  43205. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43206. */
  43207. gravity: Vector3;
  43208. /**
  43209. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43210. */
  43211. postProcessesEnabled: boolean;
  43212. /**
  43213. * Gets the current postprocess manager
  43214. */
  43215. postProcessManager: PostProcessManager;
  43216. /**
  43217. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43218. */
  43219. renderTargetsEnabled: boolean;
  43220. /**
  43221. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43222. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43223. */
  43224. dumpNextRenderTargets: boolean;
  43225. /**
  43226. * The list of user defined render targets added to the scene
  43227. */
  43228. customRenderTargets: RenderTargetTexture[];
  43229. /**
  43230. * Defines if texture loading must be delayed
  43231. * If true, textures will only be loaded when they need to be rendered
  43232. */
  43233. useDelayedTextureLoading: boolean;
  43234. /**
  43235. * Gets the list of meshes imported to the scene through SceneLoader
  43236. */
  43237. importedMeshesFiles: String[];
  43238. /**
  43239. * Gets or sets a boolean indicating if probes are enabled on this scene
  43240. */
  43241. probesEnabled: boolean;
  43242. /**
  43243. * Gets or sets the current offline provider to use to store scene data
  43244. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43245. */
  43246. offlineProvider: IOfflineProvider;
  43247. /**
  43248. * Gets or sets the action manager associated with the scene
  43249. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43250. */
  43251. actionManager: AbstractActionManager;
  43252. private _meshesForIntersections;
  43253. /**
  43254. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43255. */
  43256. proceduralTexturesEnabled: boolean;
  43257. private _engine;
  43258. private _totalVertices;
  43259. /** @hidden */
  43260. _activeIndices: PerfCounter;
  43261. /** @hidden */
  43262. _activeParticles: PerfCounter;
  43263. /** @hidden */
  43264. _activeBones: PerfCounter;
  43265. private _animationRatio;
  43266. /** @hidden */
  43267. _animationTimeLast: number;
  43268. /** @hidden */
  43269. _animationTime: number;
  43270. /**
  43271. * Gets or sets a general scale for animation speed
  43272. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43273. */
  43274. animationTimeScale: number;
  43275. /** @hidden */
  43276. _cachedMaterial: Nullable<Material>;
  43277. /** @hidden */
  43278. _cachedEffect: Nullable<Effect>;
  43279. /** @hidden */
  43280. _cachedVisibility: Nullable<number>;
  43281. private _renderId;
  43282. private _frameId;
  43283. private _executeWhenReadyTimeoutId;
  43284. private _intermediateRendering;
  43285. private _viewUpdateFlag;
  43286. private _projectionUpdateFlag;
  43287. /** @hidden */
  43288. _toBeDisposed: Nullable<IDisposable>[];
  43289. private _activeRequests;
  43290. /** @hidden */
  43291. _pendingData: any[];
  43292. private _isDisposed;
  43293. /**
  43294. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43295. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43296. */
  43297. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43298. private _activeMeshes;
  43299. private _processedMaterials;
  43300. private _renderTargets;
  43301. /** @hidden */
  43302. _activeParticleSystems: SmartArray<IParticleSystem>;
  43303. private _activeSkeletons;
  43304. private _softwareSkinnedMeshes;
  43305. private _renderingManager;
  43306. /** @hidden */
  43307. _activeAnimatables: Animatable[];
  43308. private _transformMatrix;
  43309. private _sceneUbo;
  43310. /** @hidden */
  43311. _viewMatrix: Matrix;
  43312. private _projectionMatrix;
  43313. /** @hidden */
  43314. _forcedViewPosition: Nullable<Vector3>;
  43315. /** @hidden */
  43316. _frustumPlanes: Plane[];
  43317. /**
  43318. * Gets the list of frustum planes (built from the active camera)
  43319. */
  43320. get frustumPlanes(): Plane[];
  43321. /**
  43322. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43323. * This is useful if there are more lights that the maximum simulteanous authorized
  43324. */
  43325. requireLightSorting: boolean;
  43326. /** @hidden */
  43327. readonly useMaterialMeshMap: boolean;
  43328. /** @hidden */
  43329. readonly useClonedMeshMap: boolean;
  43330. private _externalData;
  43331. private _uid;
  43332. /**
  43333. * @hidden
  43334. * Backing store of defined scene components.
  43335. */
  43336. _components: ISceneComponent[];
  43337. /**
  43338. * @hidden
  43339. * Backing store of defined scene components.
  43340. */
  43341. _serializableComponents: ISceneSerializableComponent[];
  43342. /**
  43343. * List of components to register on the next registration step.
  43344. */
  43345. private _transientComponents;
  43346. /**
  43347. * Registers the transient components if needed.
  43348. */
  43349. private _registerTransientComponents;
  43350. /**
  43351. * @hidden
  43352. * Add a component to the scene.
  43353. * Note that the ccomponent could be registered on th next frame if this is called after
  43354. * the register component stage.
  43355. * @param component Defines the component to add to the scene
  43356. */
  43357. _addComponent(component: ISceneComponent): void;
  43358. /**
  43359. * @hidden
  43360. * Gets a component from the scene.
  43361. * @param name defines the name of the component to retrieve
  43362. * @returns the component or null if not present
  43363. */
  43364. _getComponent(name: string): Nullable<ISceneComponent>;
  43365. /**
  43366. * @hidden
  43367. * Defines the actions happening before camera updates.
  43368. */
  43369. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43370. /**
  43371. * @hidden
  43372. * Defines the actions happening before clear the canvas.
  43373. */
  43374. _beforeClearStage: Stage<SimpleStageAction>;
  43375. /**
  43376. * @hidden
  43377. * Defines the actions when collecting render targets for the frame.
  43378. */
  43379. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43380. /**
  43381. * @hidden
  43382. * Defines the actions happening for one camera in the frame.
  43383. */
  43384. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43385. /**
  43386. * @hidden
  43387. * Defines the actions happening during the per mesh ready checks.
  43388. */
  43389. _isReadyForMeshStage: Stage<MeshStageAction>;
  43390. /**
  43391. * @hidden
  43392. * Defines the actions happening before evaluate active mesh checks.
  43393. */
  43394. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43395. /**
  43396. * @hidden
  43397. * Defines the actions happening during the evaluate sub mesh checks.
  43398. */
  43399. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43400. /**
  43401. * @hidden
  43402. * Defines the actions happening during the active mesh stage.
  43403. */
  43404. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43405. /**
  43406. * @hidden
  43407. * Defines the actions happening during the per camera render target step.
  43408. */
  43409. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43410. /**
  43411. * @hidden
  43412. * Defines the actions happening just before the active camera is drawing.
  43413. */
  43414. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43415. /**
  43416. * @hidden
  43417. * Defines the actions happening just before a render target is drawing.
  43418. */
  43419. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43420. /**
  43421. * @hidden
  43422. * Defines the actions happening just before a rendering group is drawing.
  43423. */
  43424. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43425. /**
  43426. * @hidden
  43427. * Defines the actions happening just before a mesh is drawing.
  43428. */
  43429. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43430. /**
  43431. * @hidden
  43432. * Defines the actions happening just after a mesh has been drawn.
  43433. */
  43434. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43435. /**
  43436. * @hidden
  43437. * Defines the actions happening just after a rendering group has been drawn.
  43438. */
  43439. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43440. /**
  43441. * @hidden
  43442. * Defines the actions happening just after the active camera has been drawn.
  43443. */
  43444. _afterCameraDrawStage: Stage<CameraStageAction>;
  43445. /**
  43446. * @hidden
  43447. * Defines the actions happening just after a render target has been drawn.
  43448. */
  43449. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43450. /**
  43451. * @hidden
  43452. * Defines the actions happening just after rendering all cameras and computing intersections.
  43453. */
  43454. _afterRenderStage: Stage<SimpleStageAction>;
  43455. /**
  43456. * @hidden
  43457. * Defines the actions happening when a pointer move event happens.
  43458. */
  43459. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43460. /**
  43461. * @hidden
  43462. * Defines the actions happening when a pointer down event happens.
  43463. */
  43464. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43465. /**
  43466. * @hidden
  43467. * Defines the actions happening when a pointer up event happens.
  43468. */
  43469. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43470. /**
  43471. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43472. */
  43473. private geometriesByUniqueId;
  43474. /**
  43475. * Creates a new Scene
  43476. * @param engine defines the engine to use to render this scene
  43477. * @param options defines the scene options
  43478. */
  43479. constructor(engine: Engine, options?: SceneOptions);
  43480. /**
  43481. * Gets a string identifying the name of the class
  43482. * @returns "Scene" string
  43483. */
  43484. getClassName(): string;
  43485. private _defaultMeshCandidates;
  43486. /**
  43487. * @hidden
  43488. */
  43489. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43490. private _defaultSubMeshCandidates;
  43491. /**
  43492. * @hidden
  43493. */
  43494. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43495. /**
  43496. * Sets the default candidate providers for the scene.
  43497. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43498. * and getCollidingSubMeshCandidates to their default function
  43499. */
  43500. setDefaultCandidateProviders(): void;
  43501. /**
  43502. * Gets the mesh that is currently under the pointer
  43503. */
  43504. get meshUnderPointer(): Nullable<AbstractMesh>;
  43505. /**
  43506. * Gets or sets the current on-screen X position of the pointer
  43507. */
  43508. get pointerX(): number;
  43509. set pointerX(value: number);
  43510. /**
  43511. * Gets or sets the current on-screen Y position of the pointer
  43512. */
  43513. get pointerY(): number;
  43514. set pointerY(value: number);
  43515. /**
  43516. * Gets the cached material (ie. the latest rendered one)
  43517. * @returns the cached material
  43518. */
  43519. getCachedMaterial(): Nullable<Material>;
  43520. /**
  43521. * Gets the cached effect (ie. the latest rendered one)
  43522. * @returns the cached effect
  43523. */
  43524. getCachedEffect(): Nullable<Effect>;
  43525. /**
  43526. * Gets the cached visibility state (ie. the latest rendered one)
  43527. * @returns the cached visibility state
  43528. */
  43529. getCachedVisibility(): Nullable<number>;
  43530. /**
  43531. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43532. * @param material defines the current material
  43533. * @param effect defines the current effect
  43534. * @param visibility defines the current visibility state
  43535. * @returns true if one parameter is not cached
  43536. */
  43537. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43538. /**
  43539. * Gets the engine associated with the scene
  43540. * @returns an Engine
  43541. */
  43542. getEngine(): Engine;
  43543. /**
  43544. * Gets the total number of vertices rendered per frame
  43545. * @returns the total number of vertices rendered per frame
  43546. */
  43547. getTotalVertices(): number;
  43548. /**
  43549. * Gets the performance counter for total vertices
  43550. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43551. */
  43552. get totalVerticesPerfCounter(): PerfCounter;
  43553. /**
  43554. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43555. * @returns the total number of active indices rendered per frame
  43556. */
  43557. getActiveIndices(): number;
  43558. /**
  43559. * Gets the performance counter for active indices
  43560. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43561. */
  43562. get totalActiveIndicesPerfCounter(): PerfCounter;
  43563. /**
  43564. * Gets the total number of active particles rendered per frame
  43565. * @returns the total number of active particles rendered per frame
  43566. */
  43567. getActiveParticles(): number;
  43568. /**
  43569. * Gets the performance counter for active particles
  43570. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43571. */
  43572. get activeParticlesPerfCounter(): PerfCounter;
  43573. /**
  43574. * Gets the total number of active bones rendered per frame
  43575. * @returns the total number of active bones rendered per frame
  43576. */
  43577. getActiveBones(): number;
  43578. /**
  43579. * Gets the performance counter for active bones
  43580. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43581. */
  43582. get activeBonesPerfCounter(): PerfCounter;
  43583. /**
  43584. * Gets the array of active meshes
  43585. * @returns an array of AbstractMesh
  43586. */
  43587. getActiveMeshes(): SmartArray<AbstractMesh>;
  43588. /**
  43589. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43590. * @returns a number
  43591. */
  43592. getAnimationRatio(): number;
  43593. /**
  43594. * Gets an unique Id for the current render phase
  43595. * @returns a number
  43596. */
  43597. getRenderId(): number;
  43598. /**
  43599. * Gets an unique Id for the current frame
  43600. * @returns a number
  43601. */
  43602. getFrameId(): number;
  43603. /** Call this function if you want to manually increment the render Id*/
  43604. incrementRenderId(): void;
  43605. private _createUbo;
  43606. /**
  43607. * Use this method to simulate a pointer move on a mesh
  43608. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43609. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43610. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43611. * @returns the current scene
  43612. */
  43613. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43614. /**
  43615. * Use this method to simulate a pointer down on a mesh
  43616. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43617. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43618. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43619. * @returns the current scene
  43620. */
  43621. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43622. /**
  43623. * Use this method to simulate a pointer up on a mesh
  43624. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43625. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43626. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43627. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43628. * @returns the current scene
  43629. */
  43630. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43631. /**
  43632. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43633. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43634. * @returns true if the pointer was captured
  43635. */
  43636. isPointerCaptured(pointerId?: number): boolean;
  43637. /**
  43638. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43639. * @param attachUp defines if you want to attach events to pointerup
  43640. * @param attachDown defines if you want to attach events to pointerdown
  43641. * @param attachMove defines if you want to attach events to pointermove
  43642. */
  43643. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43644. /** Detaches all event handlers*/
  43645. detachControl(): void;
  43646. /**
  43647. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43648. * Delay loaded resources are not taking in account
  43649. * @return true if all required resources are ready
  43650. */
  43651. isReady(): boolean;
  43652. /** Resets all cached information relative to material (including effect and visibility) */
  43653. resetCachedMaterial(): void;
  43654. /**
  43655. * Registers a function to be called before every frame render
  43656. * @param func defines the function to register
  43657. */
  43658. registerBeforeRender(func: () => void): void;
  43659. /**
  43660. * Unregisters a function called before every frame render
  43661. * @param func defines the function to unregister
  43662. */
  43663. unregisterBeforeRender(func: () => void): void;
  43664. /**
  43665. * Registers a function to be called after every frame render
  43666. * @param func defines the function to register
  43667. */
  43668. registerAfterRender(func: () => void): void;
  43669. /**
  43670. * Unregisters a function called after every frame render
  43671. * @param func defines the function to unregister
  43672. */
  43673. unregisterAfterRender(func: () => void): void;
  43674. private _executeOnceBeforeRender;
  43675. /**
  43676. * The provided function will run before render once and will be disposed afterwards.
  43677. * A timeout delay can be provided so that the function will be executed in N ms.
  43678. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43679. * @param func The function to be executed.
  43680. * @param timeout optional delay in ms
  43681. */
  43682. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43683. /** @hidden */
  43684. _addPendingData(data: any): void;
  43685. /** @hidden */
  43686. _removePendingData(data: any): void;
  43687. /**
  43688. * Returns the number of items waiting to be loaded
  43689. * @returns the number of items waiting to be loaded
  43690. */
  43691. getWaitingItemsCount(): number;
  43692. /**
  43693. * Returns a boolean indicating if the scene is still loading data
  43694. */
  43695. get isLoading(): boolean;
  43696. /**
  43697. * Registers a function to be executed when the scene is ready
  43698. * @param {Function} func - the function to be executed
  43699. */
  43700. executeWhenReady(func: () => void): void;
  43701. /**
  43702. * Returns a promise that resolves when the scene is ready
  43703. * @returns A promise that resolves when the scene is ready
  43704. */
  43705. whenReadyAsync(): Promise<void>;
  43706. /** @hidden */
  43707. _checkIsReady(): void;
  43708. /**
  43709. * Gets all animatable attached to the scene
  43710. */
  43711. get animatables(): Animatable[];
  43712. /**
  43713. * Resets the last animation time frame.
  43714. * Useful to override when animations start running when loading a scene for the first time.
  43715. */
  43716. resetLastAnimationTimeFrame(): void;
  43717. /**
  43718. * Gets the current view matrix
  43719. * @returns a Matrix
  43720. */
  43721. getViewMatrix(): Matrix;
  43722. /**
  43723. * Gets the current projection matrix
  43724. * @returns a Matrix
  43725. */
  43726. getProjectionMatrix(): Matrix;
  43727. /**
  43728. * Gets the current transform matrix
  43729. * @returns a Matrix made of View * Projection
  43730. */
  43731. getTransformMatrix(): Matrix;
  43732. /**
  43733. * Sets the current transform matrix
  43734. * @param viewL defines the View matrix to use
  43735. * @param projectionL defines the Projection matrix to use
  43736. * @param viewR defines the right View matrix to use (if provided)
  43737. * @param projectionR defines the right Projection matrix to use (if provided)
  43738. */
  43739. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  43740. /**
  43741. * Gets the uniform buffer used to store scene data
  43742. * @returns a UniformBuffer
  43743. */
  43744. getSceneUniformBuffer(): UniformBuffer;
  43745. /**
  43746. * Gets an unique (relatively to the current scene) Id
  43747. * @returns an unique number for the scene
  43748. */
  43749. getUniqueId(): number;
  43750. /**
  43751. * Add a mesh to the list of scene's meshes
  43752. * @param newMesh defines the mesh to add
  43753. * @param recursive if all child meshes should also be added to the scene
  43754. */
  43755. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  43756. /**
  43757. * Remove a mesh for the list of scene's meshes
  43758. * @param toRemove defines the mesh to remove
  43759. * @param recursive if all child meshes should also be removed from the scene
  43760. * @returns the index where the mesh was in the mesh list
  43761. */
  43762. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  43763. /**
  43764. * Add a transform node to the list of scene's transform nodes
  43765. * @param newTransformNode defines the transform node to add
  43766. */
  43767. addTransformNode(newTransformNode: TransformNode): void;
  43768. /**
  43769. * Remove a transform node for the list of scene's transform nodes
  43770. * @param toRemove defines the transform node to remove
  43771. * @returns the index where the transform node was in the transform node list
  43772. */
  43773. removeTransformNode(toRemove: TransformNode): number;
  43774. /**
  43775. * Remove a skeleton for the list of scene's skeletons
  43776. * @param toRemove defines the skeleton to remove
  43777. * @returns the index where the skeleton was in the skeleton list
  43778. */
  43779. removeSkeleton(toRemove: Skeleton): number;
  43780. /**
  43781. * Remove a morph target for the list of scene's morph targets
  43782. * @param toRemove defines the morph target to remove
  43783. * @returns the index where the morph target was in the morph target list
  43784. */
  43785. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  43786. /**
  43787. * Remove a light for the list of scene's lights
  43788. * @param toRemove defines the light to remove
  43789. * @returns the index where the light was in the light list
  43790. */
  43791. removeLight(toRemove: Light): number;
  43792. /**
  43793. * Remove a camera for the list of scene's cameras
  43794. * @param toRemove defines the camera to remove
  43795. * @returns the index where the camera was in the camera list
  43796. */
  43797. removeCamera(toRemove: Camera): number;
  43798. /**
  43799. * Remove a particle system for the list of scene's particle systems
  43800. * @param toRemove defines the particle system to remove
  43801. * @returns the index where the particle system was in the particle system list
  43802. */
  43803. removeParticleSystem(toRemove: IParticleSystem): number;
  43804. /**
  43805. * Remove a animation for the list of scene's animations
  43806. * @param toRemove defines the animation to remove
  43807. * @returns the index where the animation was in the animation list
  43808. */
  43809. removeAnimation(toRemove: Animation): number;
  43810. /**
  43811. * Will stop the animation of the given target
  43812. * @param target - the target
  43813. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  43814. * @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)
  43815. */
  43816. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  43817. /**
  43818. * Removes the given animation group from this scene.
  43819. * @param toRemove The animation group to remove
  43820. * @returns The index of the removed animation group
  43821. */
  43822. removeAnimationGroup(toRemove: AnimationGroup): number;
  43823. /**
  43824. * Removes the given multi-material from this scene.
  43825. * @param toRemove The multi-material to remove
  43826. * @returns The index of the removed multi-material
  43827. */
  43828. removeMultiMaterial(toRemove: MultiMaterial): number;
  43829. /**
  43830. * Removes the given material from this scene.
  43831. * @param toRemove The material to remove
  43832. * @returns The index of the removed material
  43833. */
  43834. removeMaterial(toRemove: Material): number;
  43835. /**
  43836. * Removes the given action manager from this scene.
  43837. * @param toRemove The action manager to remove
  43838. * @returns The index of the removed action manager
  43839. */
  43840. removeActionManager(toRemove: AbstractActionManager): number;
  43841. /**
  43842. * Removes the given texture from this scene.
  43843. * @param toRemove The texture to remove
  43844. * @returns The index of the removed texture
  43845. */
  43846. removeTexture(toRemove: BaseTexture): number;
  43847. /**
  43848. * Adds the given light to this scene
  43849. * @param newLight The light to add
  43850. */
  43851. addLight(newLight: Light): void;
  43852. /**
  43853. * Sorts the list list based on light priorities
  43854. */
  43855. sortLightsByPriority(): void;
  43856. /**
  43857. * Adds the given camera to this scene
  43858. * @param newCamera The camera to add
  43859. */
  43860. addCamera(newCamera: Camera): void;
  43861. /**
  43862. * Adds the given skeleton to this scene
  43863. * @param newSkeleton The skeleton to add
  43864. */
  43865. addSkeleton(newSkeleton: Skeleton): void;
  43866. /**
  43867. * Adds the given particle system to this scene
  43868. * @param newParticleSystem The particle system to add
  43869. */
  43870. addParticleSystem(newParticleSystem: IParticleSystem): void;
  43871. /**
  43872. * Adds the given animation to this scene
  43873. * @param newAnimation The animation to add
  43874. */
  43875. addAnimation(newAnimation: Animation): void;
  43876. /**
  43877. * Adds the given animation group to this scene.
  43878. * @param newAnimationGroup The animation group to add
  43879. */
  43880. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  43881. /**
  43882. * Adds the given multi-material to this scene
  43883. * @param newMultiMaterial The multi-material to add
  43884. */
  43885. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  43886. /**
  43887. * Adds the given material to this scene
  43888. * @param newMaterial The material to add
  43889. */
  43890. addMaterial(newMaterial: Material): void;
  43891. /**
  43892. * Adds the given morph target to this scene
  43893. * @param newMorphTargetManager The morph target to add
  43894. */
  43895. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  43896. /**
  43897. * Adds the given geometry to this scene
  43898. * @param newGeometry The geometry to add
  43899. */
  43900. addGeometry(newGeometry: Geometry): void;
  43901. /**
  43902. * Adds the given action manager to this scene
  43903. * @param newActionManager The action manager to add
  43904. */
  43905. addActionManager(newActionManager: AbstractActionManager): void;
  43906. /**
  43907. * Adds the given texture to this scene.
  43908. * @param newTexture The texture to add
  43909. */
  43910. addTexture(newTexture: BaseTexture): void;
  43911. /**
  43912. * Switch active camera
  43913. * @param newCamera defines the new active camera
  43914. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  43915. */
  43916. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  43917. /**
  43918. * sets the active camera of the scene using its ID
  43919. * @param id defines the camera's ID
  43920. * @return the new active camera or null if none found.
  43921. */
  43922. setActiveCameraByID(id: string): Nullable<Camera>;
  43923. /**
  43924. * sets the active camera of the scene using its name
  43925. * @param name defines the camera's name
  43926. * @returns the new active camera or null if none found.
  43927. */
  43928. setActiveCameraByName(name: string): Nullable<Camera>;
  43929. /**
  43930. * get an animation group using its name
  43931. * @param name defines the material's name
  43932. * @return the animation group or null if none found.
  43933. */
  43934. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  43935. /**
  43936. * Get a material using its unique id
  43937. * @param uniqueId defines the material's unique id
  43938. * @return the material or null if none found.
  43939. */
  43940. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  43941. /**
  43942. * get a material using its id
  43943. * @param id defines the material's ID
  43944. * @return the material or null if none found.
  43945. */
  43946. getMaterialByID(id: string): Nullable<Material>;
  43947. /**
  43948. * Gets a the last added material using a given id
  43949. * @param id defines the material's ID
  43950. * @return the last material with the given id or null if none found.
  43951. */
  43952. getLastMaterialByID(id: string): Nullable<Material>;
  43953. /**
  43954. * Gets a material using its name
  43955. * @param name defines the material's name
  43956. * @return the material or null if none found.
  43957. */
  43958. getMaterialByName(name: string): Nullable<Material>;
  43959. /**
  43960. * Get a texture using its unique id
  43961. * @param uniqueId defines the texture's unique id
  43962. * @return the texture or null if none found.
  43963. */
  43964. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  43965. /**
  43966. * Gets a camera using its id
  43967. * @param id defines the id to look for
  43968. * @returns the camera or null if not found
  43969. */
  43970. getCameraByID(id: string): Nullable<Camera>;
  43971. /**
  43972. * Gets a camera using its unique id
  43973. * @param uniqueId defines the unique id to look for
  43974. * @returns the camera or null if not found
  43975. */
  43976. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  43977. /**
  43978. * Gets a camera using its name
  43979. * @param name defines the camera's name
  43980. * @return the camera or null if none found.
  43981. */
  43982. getCameraByName(name: string): Nullable<Camera>;
  43983. /**
  43984. * Gets a bone using its id
  43985. * @param id defines the bone's id
  43986. * @return the bone or null if not found
  43987. */
  43988. getBoneByID(id: string): Nullable<Bone>;
  43989. /**
  43990. * Gets a bone using its id
  43991. * @param name defines the bone's name
  43992. * @return the bone or null if not found
  43993. */
  43994. getBoneByName(name: string): Nullable<Bone>;
  43995. /**
  43996. * Gets a light node using its name
  43997. * @param name defines the the light's name
  43998. * @return the light or null if none found.
  43999. */
  44000. getLightByName(name: string): Nullable<Light>;
  44001. /**
  44002. * Gets a light node using its id
  44003. * @param id defines the light's id
  44004. * @return the light or null if none found.
  44005. */
  44006. getLightByID(id: string): Nullable<Light>;
  44007. /**
  44008. * Gets a light node using its scene-generated unique ID
  44009. * @param uniqueId defines the light's unique id
  44010. * @return the light or null if none found.
  44011. */
  44012. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  44013. /**
  44014. * Gets a particle system by id
  44015. * @param id defines the particle system id
  44016. * @return the corresponding system or null if none found
  44017. */
  44018. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  44019. /**
  44020. * Gets a geometry using its ID
  44021. * @param id defines the geometry's id
  44022. * @return the geometry or null if none found.
  44023. */
  44024. getGeometryByID(id: string): Nullable<Geometry>;
  44025. private _getGeometryByUniqueID;
  44026. /**
  44027. * Add a new geometry to this scene
  44028. * @param geometry defines the geometry to be added to the scene.
  44029. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  44030. * @return a boolean defining if the geometry was added or not
  44031. */
  44032. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  44033. /**
  44034. * Removes an existing geometry
  44035. * @param geometry defines the geometry to be removed from the scene
  44036. * @return a boolean defining if the geometry was removed or not
  44037. */
  44038. removeGeometry(geometry: Geometry): boolean;
  44039. /**
  44040. * Gets the list of geometries attached to the scene
  44041. * @returns an array of Geometry
  44042. */
  44043. getGeometries(): Geometry[];
  44044. /**
  44045. * Gets the first added mesh found of a given ID
  44046. * @param id defines the id to search for
  44047. * @return the mesh found or null if not found at all
  44048. */
  44049. getMeshByID(id: string): Nullable<AbstractMesh>;
  44050. /**
  44051. * Gets a list of meshes using their id
  44052. * @param id defines the id to search for
  44053. * @returns a list of meshes
  44054. */
  44055. getMeshesByID(id: string): Array<AbstractMesh>;
  44056. /**
  44057. * Gets the first added transform node found of a given ID
  44058. * @param id defines the id to search for
  44059. * @return the found transform node or null if not found at all.
  44060. */
  44061. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44062. /**
  44063. * Gets a transform node with its auto-generated unique id
  44064. * @param uniqueId efines the unique id to search for
  44065. * @return the found transform node or null if not found at all.
  44066. */
  44067. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44068. /**
  44069. * Gets a list of transform nodes using their id
  44070. * @param id defines the id to search for
  44071. * @returns a list of transform nodes
  44072. */
  44073. getTransformNodesByID(id: string): Array<TransformNode>;
  44074. /**
  44075. * Gets a mesh with its auto-generated unique id
  44076. * @param uniqueId defines the unique id to search for
  44077. * @return the found mesh or null if not found at all.
  44078. */
  44079. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44080. /**
  44081. * Gets a the last added mesh using a given id
  44082. * @param id defines the id to search for
  44083. * @return the found mesh or null if not found at all.
  44084. */
  44085. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44086. /**
  44087. * Gets a the last added node (Mesh, Camera, Light) using a given id
  44088. * @param id defines the id to search for
  44089. * @return the found node or null if not found at all
  44090. */
  44091. getLastEntryByID(id: string): Nullable<Node>;
  44092. /**
  44093. * Gets a node (Mesh, Camera, Light) using a given id
  44094. * @param id defines the id to search for
  44095. * @return the found node or null if not found at all
  44096. */
  44097. getNodeByID(id: string): Nullable<Node>;
  44098. /**
  44099. * Gets a node (Mesh, Camera, Light) using a given name
  44100. * @param name defines the name to search for
  44101. * @return the found node or null if not found at all.
  44102. */
  44103. getNodeByName(name: string): Nullable<Node>;
  44104. /**
  44105. * Gets a mesh using a given name
  44106. * @param name defines the name to search for
  44107. * @return the found mesh or null if not found at all.
  44108. */
  44109. getMeshByName(name: string): Nullable<AbstractMesh>;
  44110. /**
  44111. * Gets a transform node using a given name
  44112. * @param name defines the name to search for
  44113. * @return the found transform node or null if not found at all.
  44114. */
  44115. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44116. /**
  44117. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  44118. * @param id defines the id to search for
  44119. * @return the found skeleton or null if not found at all.
  44120. */
  44121. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44122. /**
  44123. * Gets a skeleton using a given auto generated unique id
  44124. * @param uniqueId defines the unique id to search for
  44125. * @return the found skeleton or null if not found at all.
  44126. */
  44127. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44128. /**
  44129. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44130. * @param id defines the id to search for
  44131. * @return the found skeleton or null if not found at all.
  44132. */
  44133. getSkeletonById(id: string): Nullable<Skeleton>;
  44134. /**
  44135. * Gets a skeleton using a given name
  44136. * @param name defines the name to search for
  44137. * @return the found skeleton or null if not found at all.
  44138. */
  44139. getSkeletonByName(name: string): Nullable<Skeleton>;
  44140. /**
  44141. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44142. * @param id defines the id to search for
  44143. * @return the found morph target manager or null if not found at all.
  44144. */
  44145. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44146. /**
  44147. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44148. * @param id defines the id to search for
  44149. * @return the found morph target or null if not found at all.
  44150. */
  44151. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44152. /**
  44153. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  44154. * @param name defines the name to search for
  44155. * @return the found morph target or null if not found at all.
  44156. */
  44157. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44158. /**
  44159. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44160. * @param name defines the name to search for
  44161. * @return the found post process or null if not found at all.
  44162. */
  44163. getPostProcessByName(name: string): Nullable<PostProcess>;
  44164. /**
  44165. * Gets a boolean indicating if the given mesh is active
  44166. * @param mesh defines the mesh to look for
  44167. * @returns true if the mesh is in the active list
  44168. */
  44169. isActiveMesh(mesh: AbstractMesh): boolean;
  44170. /**
  44171. * Return a unique id as a string which can serve as an identifier for the scene
  44172. */
  44173. get uid(): string;
  44174. /**
  44175. * Add an externaly attached data from its key.
  44176. * This method call will fail and return false, if such key already exists.
  44177. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44178. * @param key the unique key that identifies the data
  44179. * @param data the data object to associate to the key for this Engine instance
  44180. * @return true if no such key were already present and the data was added successfully, false otherwise
  44181. */
  44182. addExternalData<T>(key: string, data: T): boolean;
  44183. /**
  44184. * Get an externaly attached data from its key
  44185. * @param key the unique key that identifies the data
  44186. * @return the associated data, if present (can be null), or undefined if not present
  44187. */
  44188. getExternalData<T>(key: string): Nullable<T>;
  44189. /**
  44190. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44191. * @param key the unique key that identifies the data
  44192. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44193. * @return the associated data, can be null if the factory returned null.
  44194. */
  44195. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44196. /**
  44197. * Remove an externaly attached data from the Engine instance
  44198. * @param key the unique key that identifies the data
  44199. * @return true if the data was successfully removed, false if it doesn't exist
  44200. */
  44201. removeExternalData(key: string): boolean;
  44202. private _evaluateSubMesh;
  44203. /**
  44204. * Clear the processed materials smart array preventing retention point in material dispose.
  44205. */
  44206. freeProcessedMaterials(): void;
  44207. private _preventFreeActiveMeshesAndRenderingGroups;
  44208. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44209. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44210. * when disposing several meshes in a row or a hierarchy of meshes.
  44211. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44212. */
  44213. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44214. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44215. /**
  44216. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44217. */
  44218. freeActiveMeshes(): void;
  44219. /**
  44220. * Clear the info related to rendering groups preventing retention points during dispose.
  44221. */
  44222. freeRenderingGroups(): void;
  44223. /** @hidden */
  44224. _isInIntermediateRendering(): boolean;
  44225. /**
  44226. * Lambda returning the list of potentially active meshes.
  44227. */
  44228. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44229. /**
  44230. * Lambda returning the list of potentially active sub meshes.
  44231. */
  44232. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44233. /**
  44234. * Lambda returning the list of potentially intersecting sub meshes.
  44235. */
  44236. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44237. /**
  44238. * Lambda returning the list of potentially colliding sub meshes.
  44239. */
  44240. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44241. private _activeMeshesFrozen;
  44242. private _skipEvaluateActiveMeshesCompletely;
  44243. /**
  44244. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44245. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44246. * @param onSuccess optional success callback
  44247. * @param onError optional error callback
  44248. * @returns the current scene
  44249. */
  44250. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44251. /**
  44252. * Use this function to restart evaluating active meshes on every frame
  44253. * @returns the current scene
  44254. */
  44255. unfreezeActiveMeshes(): Scene;
  44256. private _evaluateActiveMeshes;
  44257. private _activeMesh;
  44258. /**
  44259. * Update the transform matrix to update from the current active camera
  44260. * @param force defines a boolean used to force the update even if cache is up to date
  44261. */
  44262. updateTransformMatrix(force?: boolean): void;
  44263. private _bindFrameBuffer;
  44264. /** @hidden */
  44265. _allowPostProcessClearColor: boolean;
  44266. /** @hidden */
  44267. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44268. private _processSubCameras;
  44269. private _checkIntersections;
  44270. /** @hidden */
  44271. _advancePhysicsEngineStep(step: number): void;
  44272. /**
  44273. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44274. */
  44275. getDeterministicFrameTime: () => number;
  44276. /** @hidden */
  44277. _animate(): void;
  44278. /** Execute all animations (for a frame) */
  44279. animate(): void;
  44280. /**
  44281. * Render the scene
  44282. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44283. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44284. */
  44285. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44286. /**
  44287. * Freeze all materials
  44288. * A frozen material will not be updatable but should be faster to render
  44289. */
  44290. freezeMaterials(): void;
  44291. /**
  44292. * Unfreeze all materials
  44293. * A frozen material will not be updatable but should be faster to render
  44294. */
  44295. unfreezeMaterials(): void;
  44296. /**
  44297. * Releases all held ressources
  44298. */
  44299. dispose(): void;
  44300. /**
  44301. * Gets if the scene is already disposed
  44302. */
  44303. get isDisposed(): boolean;
  44304. /**
  44305. * Call this function to reduce memory footprint of the scene.
  44306. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44307. */
  44308. clearCachedVertexData(): void;
  44309. /**
  44310. * This function will remove the local cached buffer data from texture.
  44311. * It will save memory but will prevent the texture from being rebuilt
  44312. */
  44313. cleanCachedTextureBuffer(): void;
  44314. /**
  44315. * Get the world extend vectors with an optional filter
  44316. *
  44317. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44318. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44319. */
  44320. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44321. min: Vector3;
  44322. max: Vector3;
  44323. };
  44324. /**
  44325. * Creates a ray that can be used to pick in the scene
  44326. * @param x defines the x coordinate of the origin (on-screen)
  44327. * @param y defines the y coordinate of the origin (on-screen)
  44328. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44329. * @param camera defines the camera to use for the picking
  44330. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44331. * @returns a Ray
  44332. */
  44333. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44334. /**
  44335. * Creates a ray that can be used to pick in the scene
  44336. * @param x defines the x coordinate of the origin (on-screen)
  44337. * @param y defines the y coordinate of the origin (on-screen)
  44338. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44339. * @param result defines the ray where to store the picking ray
  44340. * @param camera defines the camera to use for the picking
  44341. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44342. * @returns the current scene
  44343. */
  44344. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44345. /**
  44346. * Creates a ray that can be used to pick in the scene
  44347. * @param x defines the x coordinate of the origin (on-screen)
  44348. * @param y defines the y coordinate of the origin (on-screen)
  44349. * @param camera defines the camera to use for the picking
  44350. * @returns a Ray
  44351. */
  44352. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44353. /**
  44354. * Creates a ray that can be used to pick in the scene
  44355. * @param x defines the x coordinate of the origin (on-screen)
  44356. * @param y defines the y coordinate of the origin (on-screen)
  44357. * @param result defines the ray where to store the picking ray
  44358. * @param camera defines the camera to use for the picking
  44359. * @returns the current scene
  44360. */
  44361. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44362. /** Launch a ray to try to pick a mesh in the scene
  44363. * @param x position on screen
  44364. * @param y position on screen
  44365. * @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
  44366. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44367. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44368. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44369. * @returns a PickingInfo
  44370. */
  44371. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44372. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44373. * @param x position on screen
  44374. * @param y position on screen
  44375. * @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
  44376. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44377. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44378. * @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)
  44379. */
  44380. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44381. /** Use the given ray to pick a mesh in the scene
  44382. * @param ray The ray to use to pick meshes
  44383. * @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
  44384. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44385. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44386. * @returns a PickingInfo
  44387. */
  44388. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44389. /**
  44390. * Launch a ray to try to pick a mesh in the scene
  44391. * @param x X position on screen
  44392. * @param y Y position on screen
  44393. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  44394. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44395. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44396. * @returns an array of PickingInfo
  44397. */
  44398. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44399. /**
  44400. * Launch a ray to try to pick a mesh in the scene
  44401. * @param ray Ray to use
  44402. * @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
  44403. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44404. * @returns an array of PickingInfo
  44405. */
  44406. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44407. /**
  44408. * Force the value of meshUnderPointer
  44409. * @param mesh defines the mesh to use
  44410. * @param pointerId optional pointer id when using more than one pointer
  44411. */
  44412. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44413. /**
  44414. * Gets the mesh under the pointer
  44415. * @returns a Mesh or null if no mesh is under the pointer
  44416. */
  44417. getPointerOverMesh(): Nullable<AbstractMesh>;
  44418. /** @hidden */
  44419. _rebuildGeometries(): void;
  44420. /** @hidden */
  44421. _rebuildTextures(): void;
  44422. private _getByTags;
  44423. /**
  44424. * Get a list of meshes by tags
  44425. * @param tagsQuery defines the tags query to use
  44426. * @param forEach defines a predicate used to filter results
  44427. * @returns an array of Mesh
  44428. */
  44429. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44430. /**
  44431. * Get a list of cameras by tags
  44432. * @param tagsQuery defines the tags query to use
  44433. * @param forEach defines a predicate used to filter results
  44434. * @returns an array of Camera
  44435. */
  44436. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44437. /**
  44438. * Get a list of lights by tags
  44439. * @param tagsQuery defines the tags query to use
  44440. * @param forEach defines a predicate used to filter results
  44441. * @returns an array of Light
  44442. */
  44443. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44444. /**
  44445. * Get a list of materials by tags
  44446. * @param tagsQuery defines the tags query to use
  44447. * @param forEach defines a predicate used to filter results
  44448. * @returns an array of Material
  44449. */
  44450. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44451. /**
  44452. * Get a list of transform nodes by tags
  44453. * @param tagsQuery defines the tags query to use
  44454. * @param forEach defines a predicate used to filter results
  44455. * @returns an array of TransformNode
  44456. */
  44457. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44458. /**
  44459. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44460. * This allowed control for front to back rendering or reversly depending of the special needs.
  44461. *
  44462. * @param renderingGroupId The rendering group id corresponding to its index
  44463. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44464. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44465. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44466. */
  44467. 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;
  44468. /**
  44469. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44470. *
  44471. * @param renderingGroupId The rendering group id corresponding to its index
  44472. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44473. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44474. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44475. */
  44476. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44477. /**
  44478. * Gets the current auto clear configuration for one rendering group of the rendering
  44479. * manager.
  44480. * @param index the rendering group index to get the information for
  44481. * @returns The auto clear setup for the requested rendering group
  44482. */
  44483. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44484. private _blockMaterialDirtyMechanism;
  44485. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44486. get blockMaterialDirtyMechanism(): boolean;
  44487. set blockMaterialDirtyMechanism(value: boolean);
  44488. /**
  44489. * Will flag all materials as dirty to trigger new shader compilation
  44490. * @param flag defines the flag used to specify which material part must be marked as dirty
  44491. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44492. */
  44493. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44494. /** @hidden */
  44495. _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;
  44496. /** @hidden */
  44497. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44498. /** @hidden */
  44499. _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;
  44500. /** @hidden */
  44501. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44502. /** @hidden */
  44503. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44504. /** @hidden */
  44505. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44506. }
  44507. }
  44508. declare module BABYLON {
  44509. /**
  44510. * Set of assets to keep when moving a scene into an asset container.
  44511. */
  44512. export class KeepAssets extends AbstractScene {
  44513. }
  44514. /**
  44515. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44516. */
  44517. export class InstantiatedEntries {
  44518. /**
  44519. * List of new root nodes (eg. nodes with no parent)
  44520. */
  44521. rootNodes: TransformNode[];
  44522. /**
  44523. * List of new skeletons
  44524. */
  44525. skeletons: Skeleton[];
  44526. /**
  44527. * List of new animation groups
  44528. */
  44529. animationGroups: AnimationGroup[];
  44530. }
  44531. /**
  44532. * Container with a set of assets that can be added or removed from a scene.
  44533. */
  44534. export class AssetContainer extends AbstractScene {
  44535. private _wasAddedToScene;
  44536. /**
  44537. * The scene the AssetContainer belongs to.
  44538. */
  44539. scene: Scene;
  44540. /**
  44541. * Instantiates an AssetContainer.
  44542. * @param scene The scene the AssetContainer belongs to.
  44543. */
  44544. constructor(scene: Scene);
  44545. /**
  44546. * Instantiate or clone all meshes and add the new ones to the scene.
  44547. * Skeletons and animation groups will all be cloned
  44548. * @param nameFunction defines an optional function used to get new names for clones
  44549. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44550. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44551. */
  44552. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44553. /**
  44554. * Adds all the assets from the container to the scene.
  44555. */
  44556. addAllToScene(): void;
  44557. /**
  44558. * Removes all the assets in the container from the scene
  44559. */
  44560. removeAllFromScene(): void;
  44561. /**
  44562. * Disposes all the assets in the container
  44563. */
  44564. dispose(): void;
  44565. private _moveAssets;
  44566. /**
  44567. * Removes all the assets contained in the scene and adds them to the container.
  44568. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44569. */
  44570. moveAllFromScene(keepAssets?: KeepAssets): void;
  44571. /**
  44572. * 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.
  44573. * @returns the root mesh
  44574. */
  44575. createRootMesh(): Mesh;
  44576. /**
  44577. * Merge animations (direct and animation groups) from this asset container into a scene
  44578. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44579. * @param animatables set of animatables to retarget to a node from the scene
  44580. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44581. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44582. */
  44583. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44584. }
  44585. }
  44586. declare module BABYLON {
  44587. /**
  44588. * Defines how the parser contract is defined.
  44589. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44590. */
  44591. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44592. /**
  44593. * Defines how the individual parser contract is defined.
  44594. * These parser can parse an individual asset
  44595. */
  44596. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44597. /**
  44598. * Base class of the scene acting as a container for the different elements composing a scene.
  44599. * This class is dynamically extended by the different components of the scene increasing
  44600. * flexibility and reducing coupling
  44601. */
  44602. export abstract class AbstractScene {
  44603. /**
  44604. * Stores the list of available parsers in the application.
  44605. */
  44606. private static _BabylonFileParsers;
  44607. /**
  44608. * Stores the list of available individual parsers in the application.
  44609. */
  44610. private static _IndividualBabylonFileParsers;
  44611. /**
  44612. * Adds a parser in the list of available ones
  44613. * @param name Defines the name of the parser
  44614. * @param parser Defines the parser to add
  44615. */
  44616. static AddParser(name: string, parser: BabylonFileParser): void;
  44617. /**
  44618. * Gets a general parser from the list of avaialble ones
  44619. * @param name Defines the name of the parser
  44620. * @returns the requested parser or null
  44621. */
  44622. static GetParser(name: string): Nullable<BabylonFileParser>;
  44623. /**
  44624. * Adds n individual parser in the list of available ones
  44625. * @param name Defines the name of the parser
  44626. * @param parser Defines the parser to add
  44627. */
  44628. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44629. /**
  44630. * Gets an individual parser from the list of avaialble ones
  44631. * @param name Defines the name of the parser
  44632. * @returns the requested parser or null
  44633. */
  44634. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44635. /**
  44636. * Parser json data and populate both a scene and its associated container object
  44637. * @param jsonData Defines the data to parse
  44638. * @param scene Defines the scene to parse the data for
  44639. * @param container Defines the container attached to the parsing sequence
  44640. * @param rootUrl Defines the root url of the data
  44641. */
  44642. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44643. /**
  44644. * Gets the list of root nodes (ie. nodes with no parent)
  44645. */
  44646. rootNodes: Node[];
  44647. /** All of the cameras added to this scene
  44648. * @see https://doc.babylonjs.com/babylon101/cameras
  44649. */
  44650. cameras: Camera[];
  44651. /**
  44652. * All of the lights added to this scene
  44653. * @see https://doc.babylonjs.com/babylon101/lights
  44654. */
  44655. lights: Light[];
  44656. /**
  44657. * All of the (abstract) meshes added to this scene
  44658. */
  44659. meshes: AbstractMesh[];
  44660. /**
  44661. * The list of skeletons added to the scene
  44662. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44663. */
  44664. skeletons: Skeleton[];
  44665. /**
  44666. * All of the particle systems added to this scene
  44667. * @see https://doc.babylonjs.com/babylon101/particles
  44668. */
  44669. particleSystems: IParticleSystem[];
  44670. /**
  44671. * Gets a list of Animations associated with the scene
  44672. */
  44673. animations: Animation[];
  44674. /**
  44675. * All of the animation groups added to this scene
  44676. * @see https://doc.babylonjs.com/how_to/group
  44677. */
  44678. animationGroups: AnimationGroup[];
  44679. /**
  44680. * All of the multi-materials added to this scene
  44681. * @see https://doc.babylonjs.com/how_to/multi_materials
  44682. */
  44683. multiMaterials: MultiMaterial[];
  44684. /**
  44685. * All of the materials added to this scene
  44686. * In the context of a Scene, it is not supposed to be modified manually.
  44687. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44688. * Note also that the order of the Material within the array is not significant and might change.
  44689. * @see https://doc.babylonjs.com/babylon101/materials
  44690. */
  44691. materials: Material[];
  44692. /**
  44693. * The list of morph target managers added to the scene
  44694. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44695. */
  44696. morphTargetManagers: MorphTargetManager[];
  44697. /**
  44698. * The list of geometries used in the scene.
  44699. */
  44700. geometries: Geometry[];
  44701. /**
  44702. * All of the tranform nodes added to this scene
  44703. * In the context of a Scene, it is not supposed to be modified manually.
  44704. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44705. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44706. * @see https://doc.babylonjs.com/how_to/transformnode
  44707. */
  44708. transformNodes: TransformNode[];
  44709. /**
  44710. * ActionManagers available on the scene.
  44711. */
  44712. actionManagers: AbstractActionManager[];
  44713. /**
  44714. * Textures to keep.
  44715. */
  44716. textures: BaseTexture[];
  44717. /** @hidden */
  44718. protected _environmentTexture: Nullable<BaseTexture>;
  44719. /**
  44720. * Texture used in all pbr material as the reflection texture.
  44721. * As in the majority of the scene they are the same (exception for multi room and so on),
  44722. * this is easier to reference from here than from all the materials.
  44723. */
  44724. get environmentTexture(): Nullable<BaseTexture>;
  44725. set environmentTexture(value: Nullable<BaseTexture>);
  44726. /**
  44727. * The list of postprocesses added to the scene
  44728. */
  44729. postProcesses: PostProcess[];
  44730. /**
  44731. * @returns all meshes, lights, cameras, transformNodes and bones
  44732. */
  44733. getNodes(): Array<Node>;
  44734. }
  44735. }
  44736. declare module BABYLON {
  44737. /**
  44738. * Interface used to define options for Sound class
  44739. */
  44740. export interface ISoundOptions {
  44741. /**
  44742. * Does the sound autoplay once loaded.
  44743. */
  44744. autoplay?: boolean;
  44745. /**
  44746. * Does the sound loop after it finishes playing once.
  44747. */
  44748. loop?: boolean;
  44749. /**
  44750. * Sound's volume
  44751. */
  44752. volume?: number;
  44753. /**
  44754. * Is it a spatial sound?
  44755. */
  44756. spatialSound?: boolean;
  44757. /**
  44758. * Maximum distance to hear that sound
  44759. */
  44760. maxDistance?: number;
  44761. /**
  44762. * Uses user defined attenuation function
  44763. */
  44764. useCustomAttenuation?: boolean;
  44765. /**
  44766. * Define the roll off factor of spatial sounds.
  44767. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44768. */
  44769. rolloffFactor?: number;
  44770. /**
  44771. * Define the reference distance the sound should be heard perfectly.
  44772. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44773. */
  44774. refDistance?: number;
  44775. /**
  44776. * Define the distance attenuation model the sound will follow.
  44777. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44778. */
  44779. distanceModel?: string;
  44780. /**
  44781. * Defines the playback speed (1 by default)
  44782. */
  44783. playbackRate?: number;
  44784. /**
  44785. * Defines if the sound is from a streaming source
  44786. */
  44787. streaming?: boolean;
  44788. /**
  44789. * Defines an optional length (in seconds) inside the sound file
  44790. */
  44791. length?: number;
  44792. /**
  44793. * Defines an optional offset (in seconds) inside the sound file
  44794. */
  44795. offset?: number;
  44796. /**
  44797. * If true, URLs will not be required to state the audio file codec to use.
  44798. */
  44799. skipCodecCheck?: boolean;
  44800. }
  44801. }
  44802. declare module BABYLON {
  44803. /**
  44804. * Defines a sound that can be played in the application.
  44805. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  44806. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44807. */
  44808. export class Sound {
  44809. /**
  44810. * The name of the sound in the scene.
  44811. */
  44812. name: string;
  44813. /**
  44814. * Does the sound autoplay once loaded.
  44815. */
  44816. autoplay: boolean;
  44817. /**
  44818. * Does the sound loop after it finishes playing once.
  44819. */
  44820. loop: boolean;
  44821. /**
  44822. * Does the sound use a custom attenuation curve to simulate the falloff
  44823. * happening when the source gets further away from the camera.
  44824. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44825. */
  44826. useCustomAttenuation: boolean;
  44827. /**
  44828. * The sound track id this sound belongs to.
  44829. */
  44830. soundTrackId: number;
  44831. /**
  44832. * Is this sound currently played.
  44833. */
  44834. isPlaying: boolean;
  44835. /**
  44836. * Is this sound currently paused.
  44837. */
  44838. isPaused: boolean;
  44839. /**
  44840. * Does this sound enables spatial sound.
  44841. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44842. */
  44843. spatialSound: boolean;
  44844. /**
  44845. * Define the reference distance the sound should be heard perfectly.
  44846. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44847. */
  44848. refDistance: number;
  44849. /**
  44850. * Define the roll off factor of spatial sounds.
  44851. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44852. */
  44853. rolloffFactor: number;
  44854. /**
  44855. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  44856. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44857. */
  44858. maxDistance: number;
  44859. /**
  44860. * Define the distance attenuation model the sound will follow.
  44861. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44862. */
  44863. distanceModel: string;
  44864. /**
  44865. * @hidden
  44866. * Back Compat
  44867. **/
  44868. onended: () => any;
  44869. /**
  44870. * Gets or sets an object used to store user defined information for the sound.
  44871. */
  44872. metadata: any;
  44873. /**
  44874. * Observable event when the current playing sound finishes.
  44875. */
  44876. onEndedObservable: Observable<Sound>;
  44877. /**
  44878. * Gets the current time for the sound.
  44879. */
  44880. get currentTime(): number;
  44881. private _panningModel;
  44882. private _playbackRate;
  44883. private _streaming;
  44884. private _startTime;
  44885. private _startOffset;
  44886. private _position;
  44887. /** @hidden */
  44888. _positionInEmitterSpace: boolean;
  44889. private _localDirection;
  44890. private _volume;
  44891. private _isReadyToPlay;
  44892. private _isDirectional;
  44893. private _readyToPlayCallback;
  44894. private _audioBuffer;
  44895. private _soundSource;
  44896. private _streamingSource;
  44897. private _soundPanner;
  44898. private _soundGain;
  44899. private _inputAudioNode;
  44900. private _outputAudioNode;
  44901. private _coneInnerAngle;
  44902. private _coneOuterAngle;
  44903. private _coneOuterGain;
  44904. private _scene;
  44905. private _connectedTransformNode;
  44906. private _customAttenuationFunction;
  44907. private _registerFunc;
  44908. private _isOutputConnected;
  44909. private _htmlAudioElement;
  44910. private _urlType;
  44911. private _length?;
  44912. private _offset?;
  44913. /** @hidden */
  44914. static _SceneComponentInitialization: (scene: Scene) => void;
  44915. /**
  44916. * Create a sound and attach it to a scene
  44917. * @param name Name of your sound
  44918. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  44919. * @param scene defines the scene the sound belongs to
  44920. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  44921. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  44922. */
  44923. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  44924. /**
  44925. * Release the sound and its associated resources
  44926. */
  44927. dispose(): void;
  44928. /**
  44929. * Gets if the sounds is ready to be played or not.
  44930. * @returns true if ready, otherwise false
  44931. */
  44932. isReady(): boolean;
  44933. private _soundLoaded;
  44934. /**
  44935. * Sets the data of the sound from an audiobuffer
  44936. * @param audioBuffer The audioBuffer containing the data
  44937. */
  44938. setAudioBuffer(audioBuffer: AudioBuffer): void;
  44939. /**
  44940. * Updates the current sounds options such as maxdistance, loop...
  44941. * @param options A JSON object containing values named as the object properties
  44942. */
  44943. updateOptions(options: ISoundOptions): void;
  44944. private _createSpatialParameters;
  44945. private _updateSpatialParameters;
  44946. /**
  44947. * Switch the panning model to HRTF:
  44948. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  44949. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44950. */
  44951. switchPanningModelToHRTF(): void;
  44952. /**
  44953. * Switch the panning model to Equal Power:
  44954. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  44955. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44956. */
  44957. switchPanningModelToEqualPower(): void;
  44958. private _switchPanningModel;
  44959. /**
  44960. * Connect this sound to a sound track audio node like gain...
  44961. * @param soundTrackAudioNode the sound track audio node to connect to
  44962. */
  44963. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  44964. /**
  44965. * Transform this sound into a directional source
  44966. * @param coneInnerAngle Size of the inner cone in degree
  44967. * @param coneOuterAngle Size of the outer cone in degree
  44968. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  44969. */
  44970. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  44971. /**
  44972. * Gets or sets the inner angle for the directional cone.
  44973. */
  44974. get directionalConeInnerAngle(): number;
  44975. /**
  44976. * Gets or sets the inner angle for the directional cone.
  44977. */
  44978. set directionalConeInnerAngle(value: number);
  44979. /**
  44980. * Gets or sets the outer angle for the directional cone.
  44981. */
  44982. get directionalConeOuterAngle(): number;
  44983. /**
  44984. * Gets or sets the outer angle for the directional cone.
  44985. */
  44986. set directionalConeOuterAngle(value: number);
  44987. /**
  44988. * Sets the position of the emitter if spatial sound is enabled
  44989. * @param newPosition Defines the new posisiton
  44990. */
  44991. setPosition(newPosition: Vector3): void;
  44992. /**
  44993. * Sets the local direction of the emitter if spatial sound is enabled
  44994. * @param newLocalDirection Defines the new local direction
  44995. */
  44996. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  44997. private _updateDirection;
  44998. /** @hidden */
  44999. updateDistanceFromListener(): void;
  45000. /**
  45001. * Sets a new custom attenuation function for the sound.
  45002. * @param callback Defines the function used for the attenuation
  45003. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45004. */
  45005. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  45006. /**
  45007. * Play the sound
  45008. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  45009. * @param offset (optional) Start the sound at a specific time in seconds
  45010. * @param length (optional) Sound duration (in seconds)
  45011. */
  45012. play(time?: number, offset?: number, length?: number): void;
  45013. private _onended;
  45014. /**
  45015. * Stop the sound
  45016. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  45017. */
  45018. stop(time?: number): void;
  45019. /**
  45020. * Put the sound in pause
  45021. */
  45022. pause(): void;
  45023. /**
  45024. * Sets a dedicated volume for this sounds
  45025. * @param newVolume Define the new volume of the sound
  45026. * @param time Define time for gradual change to new volume
  45027. */
  45028. setVolume(newVolume: number, time?: number): void;
  45029. /**
  45030. * Set the sound play back rate
  45031. * @param newPlaybackRate Define the playback rate the sound should be played at
  45032. */
  45033. setPlaybackRate(newPlaybackRate: number): void;
  45034. /**
  45035. * Gets the volume of the sound.
  45036. * @returns the volume of the sound
  45037. */
  45038. getVolume(): number;
  45039. /**
  45040. * Attach the sound to a dedicated mesh
  45041. * @param transformNode The transform node to connect the sound with
  45042. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45043. */
  45044. attachToMesh(transformNode: TransformNode): void;
  45045. /**
  45046. * Detach the sound from the previously attached mesh
  45047. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45048. */
  45049. detachFromMesh(): void;
  45050. private _onRegisterAfterWorldMatrixUpdate;
  45051. /**
  45052. * Clone the current sound in the scene.
  45053. * @returns the new sound clone
  45054. */
  45055. clone(): Nullable<Sound>;
  45056. /**
  45057. * Gets the current underlying audio buffer containing the data
  45058. * @returns the audio buffer
  45059. */
  45060. getAudioBuffer(): Nullable<AudioBuffer>;
  45061. /**
  45062. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45063. * @returns the source node
  45064. */
  45065. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45066. /**
  45067. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45068. * @returns the gain node
  45069. */
  45070. getSoundGain(): Nullable<GainNode>;
  45071. /**
  45072. * Serializes the Sound in a JSON representation
  45073. * @returns the JSON representation of the sound
  45074. */
  45075. serialize(): any;
  45076. /**
  45077. * Parse a JSON representation of a sound to innstantiate in a given scene
  45078. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45079. * @param scene Define the scene the new parsed sound should be created in
  45080. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45081. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45082. * @returns the newly parsed sound
  45083. */
  45084. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45085. }
  45086. }
  45087. declare module BABYLON {
  45088. /**
  45089. * This defines an action helpful to play a defined sound on a triggered action.
  45090. */
  45091. export class PlaySoundAction extends Action {
  45092. private _sound;
  45093. /**
  45094. * Instantiate the action
  45095. * @param triggerOptions defines the trigger options
  45096. * @param sound defines the sound to play
  45097. * @param condition defines the trigger related conditions
  45098. */
  45099. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45100. /** @hidden */
  45101. _prepare(): void;
  45102. /**
  45103. * Execute the action and play the sound.
  45104. */
  45105. execute(): void;
  45106. /**
  45107. * Serializes the actions and its related information.
  45108. * @param parent defines the object to serialize in
  45109. * @returns the serialized object
  45110. */
  45111. serialize(parent: any): any;
  45112. }
  45113. /**
  45114. * This defines an action helpful to stop a defined sound on a triggered action.
  45115. */
  45116. export class StopSoundAction extends Action {
  45117. private _sound;
  45118. /**
  45119. * Instantiate the action
  45120. * @param triggerOptions defines the trigger options
  45121. * @param sound defines the sound to stop
  45122. * @param condition defines the trigger related conditions
  45123. */
  45124. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45125. /** @hidden */
  45126. _prepare(): void;
  45127. /**
  45128. * Execute the action and stop the sound.
  45129. */
  45130. execute(): void;
  45131. /**
  45132. * Serializes the actions and its related information.
  45133. * @param parent defines the object to serialize in
  45134. * @returns the serialized object
  45135. */
  45136. serialize(parent: any): any;
  45137. }
  45138. }
  45139. declare module BABYLON {
  45140. /**
  45141. * This defines an action responsible to change the value of a property
  45142. * by interpolating between its current value and the newly set one once triggered.
  45143. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45144. */
  45145. export class InterpolateValueAction extends Action {
  45146. /**
  45147. * Defines the path of the property where the value should be interpolated
  45148. */
  45149. propertyPath: string;
  45150. /**
  45151. * Defines the target value at the end of the interpolation.
  45152. */
  45153. value: any;
  45154. /**
  45155. * Defines the time it will take for the property to interpolate to the value.
  45156. */
  45157. duration: number;
  45158. /**
  45159. * Defines if the other scene animations should be stopped when the action has been triggered
  45160. */
  45161. stopOtherAnimations?: boolean;
  45162. /**
  45163. * Defines a callback raised once the interpolation animation has been done.
  45164. */
  45165. onInterpolationDone?: () => void;
  45166. /**
  45167. * Observable triggered once the interpolation animation has been done.
  45168. */
  45169. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45170. private _target;
  45171. private _effectiveTarget;
  45172. private _property;
  45173. /**
  45174. * Instantiate the action
  45175. * @param triggerOptions defines the trigger options
  45176. * @param target defines the object containing the value to interpolate
  45177. * @param propertyPath defines the path to the property in the target object
  45178. * @param value defines the target value at the end of the interpolation
  45179. * @param duration deines the time it will take for the property to interpolate to the value.
  45180. * @param condition defines the trigger related conditions
  45181. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45182. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45183. */
  45184. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45185. /** @hidden */
  45186. _prepare(): void;
  45187. /**
  45188. * Execute the action starts the value interpolation.
  45189. */
  45190. execute(): void;
  45191. /**
  45192. * Serializes the actions and its related information.
  45193. * @param parent defines the object to serialize in
  45194. * @returns the serialized object
  45195. */
  45196. serialize(parent: any): any;
  45197. }
  45198. }
  45199. declare module BABYLON {
  45200. /**
  45201. * This represents the default audio engine used in babylon.
  45202. * It is responsible to play, synchronize and analyse sounds throughout the application.
  45203. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45204. */
  45205. export class AudioEngine implements IAudioEngine {
  45206. private _audioContext;
  45207. private _audioContextInitialized;
  45208. private _muteButton;
  45209. private _hostElement;
  45210. /**
  45211. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  45212. */
  45213. canUseWebAudio: boolean;
  45214. /**
  45215. * The master gain node defines the global audio volume of your audio engine.
  45216. */
  45217. masterGain: GainNode;
  45218. /**
  45219. * Defines if Babylon should emit a warning if WebAudio is not supported.
  45220. * @ignoreNaming
  45221. */
  45222. WarnedWebAudioUnsupported: boolean;
  45223. /**
  45224. * Gets whether or not mp3 are supported by your browser.
  45225. */
  45226. isMP3supported: boolean;
  45227. /**
  45228. * Gets whether or not ogg are supported by your browser.
  45229. */
  45230. isOGGsupported: boolean;
  45231. /**
  45232. * Gets whether audio has been unlocked on the device.
  45233. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  45234. * a user interaction has happened.
  45235. */
  45236. unlocked: boolean;
  45237. /**
  45238. * Defines if the audio engine relies on a custom unlocked button.
  45239. * In this case, the embedded button will not be displayed.
  45240. */
  45241. useCustomUnlockedButton: boolean;
  45242. /**
  45243. * Event raised when audio has been unlocked on the browser.
  45244. */
  45245. onAudioUnlockedObservable: Observable<IAudioEngine>;
  45246. /**
  45247. * Event raised when audio has been locked on the browser.
  45248. */
  45249. onAudioLockedObservable: Observable<IAudioEngine>;
  45250. /**
  45251. * Gets the current AudioContext if available.
  45252. */
  45253. get audioContext(): Nullable<AudioContext>;
  45254. private _connectedAnalyser;
  45255. /**
  45256. * Instantiates a new audio engine.
  45257. *
  45258. * There should be only one per page as some browsers restrict the number
  45259. * of audio contexts you can create.
  45260. * @param hostElement defines the host element where to display the mute icon if necessary
  45261. */
  45262. constructor(hostElement?: Nullable<HTMLElement>);
  45263. /**
  45264. * Flags the audio engine in Locked state.
  45265. * This happens due to new browser policies preventing audio to autoplay.
  45266. */
  45267. lock(): void;
  45268. /**
  45269. * Unlocks the audio engine once a user action has been done on the dom.
  45270. * This is helpful to resume play once browser policies have been satisfied.
  45271. */
  45272. unlock(): void;
  45273. private _resumeAudioContext;
  45274. private _initializeAudioContext;
  45275. private _tryToRun;
  45276. private _triggerRunningState;
  45277. private _triggerSuspendedState;
  45278. private _displayMuteButton;
  45279. private _moveButtonToTopLeft;
  45280. private _onResize;
  45281. private _hideMuteButton;
  45282. /**
  45283. * Destroy and release the resources associated with the audio ccontext.
  45284. */
  45285. dispose(): void;
  45286. /**
  45287. * Gets the global volume sets on the master gain.
  45288. * @returns the global volume if set or -1 otherwise
  45289. */
  45290. getGlobalVolume(): number;
  45291. /**
  45292. * Sets the global volume of your experience (sets on the master gain).
  45293. * @param newVolume Defines the new global volume of the application
  45294. */
  45295. setGlobalVolume(newVolume: number): void;
  45296. /**
  45297. * Connect the audio engine to an audio analyser allowing some amazing
  45298. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45299. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45300. * @param analyser The analyser to connect to the engine
  45301. */
  45302. connectToAnalyser(analyser: Analyser): void;
  45303. }
  45304. }
  45305. declare module BABYLON {
  45306. /**
  45307. * Options allowed during the creation of a sound track.
  45308. */
  45309. export interface ISoundTrackOptions {
  45310. /**
  45311. * The volume the sound track should take during creation
  45312. */
  45313. volume?: number;
  45314. /**
  45315. * Define if the sound track is the main sound track of the scene
  45316. */
  45317. mainTrack?: boolean;
  45318. }
  45319. /**
  45320. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45321. * It will be also used in a future release to apply effects on a specific track.
  45322. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45323. */
  45324. export class SoundTrack {
  45325. /**
  45326. * The unique identifier of the sound track in the scene.
  45327. */
  45328. id: number;
  45329. /**
  45330. * The list of sounds included in the sound track.
  45331. */
  45332. soundCollection: Array<Sound>;
  45333. private _outputAudioNode;
  45334. private _scene;
  45335. private _connectedAnalyser;
  45336. private _options;
  45337. private _isInitialized;
  45338. /**
  45339. * Creates a new sound track.
  45340. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45341. * @param scene Define the scene the sound track belongs to
  45342. * @param options
  45343. */
  45344. constructor(scene: Scene, options?: ISoundTrackOptions);
  45345. private _initializeSoundTrackAudioGraph;
  45346. /**
  45347. * Release the sound track and its associated resources
  45348. */
  45349. dispose(): void;
  45350. /**
  45351. * Adds a sound to this sound track
  45352. * @param sound define the cound to add
  45353. * @ignoreNaming
  45354. */
  45355. addSound(sound: Sound): void;
  45356. /**
  45357. * Removes a sound to this sound track
  45358. * @param sound define the cound to remove
  45359. * @ignoreNaming
  45360. */
  45361. removeSound(sound: Sound): void;
  45362. /**
  45363. * Set a global volume for the full sound track.
  45364. * @param newVolume Define the new volume of the sound track
  45365. */
  45366. setVolume(newVolume: number): void;
  45367. /**
  45368. * Switch the panning model to HRTF:
  45369. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45370. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45371. */
  45372. switchPanningModelToHRTF(): void;
  45373. /**
  45374. * Switch the panning model to Equal Power:
  45375. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45376. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45377. */
  45378. switchPanningModelToEqualPower(): void;
  45379. /**
  45380. * Connect the sound track to an audio analyser allowing some amazing
  45381. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45382. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45383. * @param analyser The analyser to connect to the engine
  45384. */
  45385. connectToAnalyser(analyser: Analyser): void;
  45386. }
  45387. }
  45388. declare module BABYLON {
  45389. interface AbstractScene {
  45390. /**
  45391. * The list of sounds used in the scene.
  45392. */
  45393. sounds: Nullable<Array<Sound>>;
  45394. }
  45395. interface Scene {
  45396. /**
  45397. * @hidden
  45398. * Backing field
  45399. */
  45400. _mainSoundTrack: SoundTrack;
  45401. /**
  45402. * The main sound track played by the scene.
  45403. * It cotains your primary collection of sounds.
  45404. */
  45405. mainSoundTrack: SoundTrack;
  45406. /**
  45407. * The list of sound tracks added to the scene
  45408. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45409. */
  45410. soundTracks: Nullable<Array<SoundTrack>>;
  45411. /**
  45412. * Gets a sound using a given name
  45413. * @param name defines the name to search for
  45414. * @return the found sound or null if not found at all.
  45415. */
  45416. getSoundByName(name: string): Nullable<Sound>;
  45417. /**
  45418. * Gets or sets if audio support is enabled
  45419. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45420. */
  45421. audioEnabled: boolean;
  45422. /**
  45423. * Gets or sets if audio will be output to headphones
  45424. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45425. */
  45426. headphone: boolean;
  45427. /**
  45428. * Gets or sets custom audio listener position provider
  45429. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45430. */
  45431. audioListenerPositionProvider: Nullable<() => Vector3>;
  45432. /**
  45433. * Gets or sets a refresh rate when using 3D audio positioning
  45434. */
  45435. audioPositioningRefreshRate: number;
  45436. }
  45437. /**
  45438. * Defines the sound scene component responsible to manage any sounds
  45439. * in a given scene.
  45440. */
  45441. export class AudioSceneComponent implements ISceneSerializableComponent {
  45442. private static _CameraDirectionLH;
  45443. private static _CameraDirectionRH;
  45444. /**
  45445. * The component name helpfull to identify the component in the list of scene components.
  45446. */
  45447. readonly name: string;
  45448. /**
  45449. * The scene the component belongs to.
  45450. */
  45451. scene: Scene;
  45452. private _audioEnabled;
  45453. /**
  45454. * Gets whether audio is enabled or not.
  45455. * Please use related enable/disable method to switch state.
  45456. */
  45457. get audioEnabled(): boolean;
  45458. private _headphone;
  45459. /**
  45460. * Gets whether audio is outputing to headphone or not.
  45461. * Please use the according Switch methods to change output.
  45462. */
  45463. get headphone(): boolean;
  45464. /**
  45465. * Gets or sets a refresh rate when using 3D audio positioning
  45466. */
  45467. audioPositioningRefreshRate: number;
  45468. private _audioListenerPositionProvider;
  45469. /**
  45470. * Gets the current audio listener position provider
  45471. */
  45472. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45473. /**
  45474. * Sets a custom listener position for all sounds in the scene
  45475. * By default, this is the position of the first active camera
  45476. */
  45477. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45478. /**
  45479. * Creates a new instance of the component for the given scene
  45480. * @param scene Defines the scene to register the component in
  45481. */
  45482. constructor(scene: Scene);
  45483. /**
  45484. * Registers the component in a given scene
  45485. */
  45486. register(): void;
  45487. /**
  45488. * Rebuilds the elements related to this component in case of
  45489. * context lost for instance.
  45490. */
  45491. rebuild(): void;
  45492. /**
  45493. * Serializes the component data to the specified json object
  45494. * @param serializationObject The object to serialize to
  45495. */
  45496. serialize(serializationObject: any): void;
  45497. /**
  45498. * Adds all the elements from the container to the scene
  45499. * @param container the container holding the elements
  45500. */
  45501. addFromContainer(container: AbstractScene): void;
  45502. /**
  45503. * Removes all the elements in the container from the scene
  45504. * @param container contains the elements to remove
  45505. * @param dispose if the removed element should be disposed (default: false)
  45506. */
  45507. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45508. /**
  45509. * Disposes the component and the associated ressources.
  45510. */
  45511. dispose(): void;
  45512. /**
  45513. * Disables audio in the associated scene.
  45514. */
  45515. disableAudio(): void;
  45516. /**
  45517. * Enables audio in the associated scene.
  45518. */
  45519. enableAudio(): void;
  45520. /**
  45521. * Switch audio to headphone output.
  45522. */
  45523. switchAudioModeForHeadphones(): void;
  45524. /**
  45525. * Switch audio to normal speakers.
  45526. */
  45527. switchAudioModeForNormalSpeakers(): void;
  45528. private _cachedCameraDirection;
  45529. private _cachedCameraPosition;
  45530. private _lastCheck;
  45531. private _afterRender;
  45532. }
  45533. }
  45534. declare module BABYLON {
  45535. /**
  45536. * Wraps one or more Sound objects and selects one with random weight for playback.
  45537. */
  45538. export class WeightedSound {
  45539. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45540. loop: boolean;
  45541. private _coneInnerAngle;
  45542. private _coneOuterAngle;
  45543. private _volume;
  45544. /** A Sound is currently playing. */
  45545. isPlaying: boolean;
  45546. /** A Sound is currently paused. */
  45547. isPaused: boolean;
  45548. private _sounds;
  45549. private _weights;
  45550. private _currentIndex?;
  45551. /**
  45552. * Creates a new WeightedSound from the list of sounds given.
  45553. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45554. * @param sounds Array of Sounds that will be selected from.
  45555. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45556. */
  45557. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45558. /**
  45559. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45560. */
  45561. get directionalConeInnerAngle(): number;
  45562. /**
  45563. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45564. */
  45565. set directionalConeInnerAngle(value: number);
  45566. /**
  45567. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45568. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45569. */
  45570. get directionalConeOuterAngle(): number;
  45571. /**
  45572. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45573. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45574. */
  45575. set directionalConeOuterAngle(value: number);
  45576. /**
  45577. * Playback volume.
  45578. */
  45579. get volume(): number;
  45580. /**
  45581. * Playback volume.
  45582. */
  45583. set volume(value: number);
  45584. private _onended;
  45585. /**
  45586. * Suspend playback
  45587. */
  45588. pause(): void;
  45589. /**
  45590. * Stop playback
  45591. */
  45592. stop(): void;
  45593. /**
  45594. * Start playback.
  45595. * @param startOffset Position the clip head at a specific time in seconds.
  45596. */
  45597. play(startOffset?: number): void;
  45598. }
  45599. }
  45600. declare module BABYLON {
  45601. /**
  45602. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45603. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45604. */
  45605. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45606. /**
  45607. * Gets the name of the behavior.
  45608. */
  45609. get name(): string;
  45610. /**
  45611. * The easing function used by animations
  45612. */
  45613. static EasingFunction: BackEase;
  45614. /**
  45615. * The easing mode used by animations
  45616. */
  45617. static EasingMode: number;
  45618. /**
  45619. * The duration of the animation, in milliseconds
  45620. */
  45621. transitionDuration: number;
  45622. /**
  45623. * Length of the distance animated by the transition when lower radius is reached
  45624. */
  45625. lowerRadiusTransitionRange: number;
  45626. /**
  45627. * Length of the distance animated by the transition when upper radius is reached
  45628. */
  45629. upperRadiusTransitionRange: number;
  45630. private _autoTransitionRange;
  45631. /**
  45632. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45633. */
  45634. get autoTransitionRange(): boolean;
  45635. /**
  45636. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45637. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45638. */
  45639. set autoTransitionRange(value: boolean);
  45640. private _attachedCamera;
  45641. private _onAfterCheckInputsObserver;
  45642. private _onMeshTargetChangedObserver;
  45643. /**
  45644. * Initializes the behavior.
  45645. */
  45646. init(): void;
  45647. /**
  45648. * Attaches the behavior to its arc rotate camera.
  45649. * @param camera Defines the camera to attach the behavior to
  45650. */
  45651. attach(camera: ArcRotateCamera): void;
  45652. /**
  45653. * Detaches the behavior from its current arc rotate camera.
  45654. */
  45655. detach(): void;
  45656. private _radiusIsAnimating;
  45657. private _radiusBounceTransition;
  45658. private _animatables;
  45659. private _cachedWheelPrecision;
  45660. /**
  45661. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45662. * @param radiusLimit The limit to check against.
  45663. * @return Bool to indicate if at limit.
  45664. */
  45665. private _isRadiusAtLimit;
  45666. /**
  45667. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45668. * @param radiusDelta The delta by which to animate to. Can be negative.
  45669. */
  45670. private _applyBoundRadiusAnimation;
  45671. /**
  45672. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45673. */
  45674. protected _clearAnimationLocks(): void;
  45675. /**
  45676. * Stops and removes all animations that have been applied to the camera
  45677. */
  45678. stopAllAnimations(): void;
  45679. }
  45680. }
  45681. declare module BABYLON {
  45682. /**
  45683. * 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.
  45684. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45685. */
  45686. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45687. /**
  45688. * Gets the name of the behavior.
  45689. */
  45690. get name(): string;
  45691. private _mode;
  45692. private _radiusScale;
  45693. private _positionScale;
  45694. private _defaultElevation;
  45695. private _elevationReturnTime;
  45696. private _elevationReturnWaitTime;
  45697. private _zoomStopsAnimation;
  45698. private _framingTime;
  45699. /**
  45700. * The easing function used by animations
  45701. */
  45702. static EasingFunction: ExponentialEase;
  45703. /**
  45704. * The easing mode used by animations
  45705. */
  45706. static EasingMode: number;
  45707. /**
  45708. * Sets the current mode used by the behavior
  45709. */
  45710. set mode(mode: number);
  45711. /**
  45712. * Gets current mode used by the behavior.
  45713. */
  45714. get mode(): number;
  45715. /**
  45716. * Sets the scale applied to the radius (1 by default)
  45717. */
  45718. set radiusScale(radius: number);
  45719. /**
  45720. * Gets the scale applied to the radius
  45721. */
  45722. get radiusScale(): number;
  45723. /**
  45724. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45725. */
  45726. set positionScale(scale: number);
  45727. /**
  45728. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45729. */
  45730. get positionScale(): number;
  45731. /**
  45732. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45733. * behaviour is triggered, in radians.
  45734. */
  45735. set defaultElevation(elevation: number);
  45736. /**
  45737. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45738. * behaviour is triggered, in radians.
  45739. */
  45740. get defaultElevation(): number;
  45741. /**
  45742. * Sets the time (in milliseconds) taken to return to the default beta position.
  45743. * Negative value indicates camera should not return to default.
  45744. */
  45745. set elevationReturnTime(speed: number);
  45746. /**
  45747. * Gets the time (in milliseconds) taken to return to the default beta position.
  45748. * Negative value indicates camera should not return to default.
  45749. */
  45750. get elevationReturnTime(): number;
  45751. /**
  45752. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45753. */
  45754. set elevationReturnWaitTime(time: number);
  45755. /**
  45756. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45757. */
  45758. get elevationReturnWaitTime(): number;
  45759. /**
  45760. * Sets the flag that indicates if user zooming should stop animation.
  45761. */
  45762. set zoomStopsAnimation(flag: boolean);
  45763. /**
  45764. * Gets the flag that indicates if user zooming should stop animation.
  45765. */
  45766. get zoomStopsAnimation(): boolean;
  45767. /**
  45768. * Sets the transition time when framing the mesh, in milliseconds
  45769. */
  45770. set framingTime(time: number);
  45771. /**
  45772. * Gets the transition time when framing the mesh, in milliseconds
  45773. */
  45774. get framingTime(): number;
  45775. /**
  45776. * Define if the behavior should automatically change the configured
  45777. * camera limits and sensibilities.
  45778. */
  45779. autoCorrectCameraLimitsAndSensibility: boolean;
  45780. private _onPrePointerObservableObserver;
  45781. private _onAfterCheckInputsObserver;
  45782. private _onMeshTargetChangedObserver;
  45783. private _attachedCamera;
  45784. private _isPointerDown;
  45785. private _lastInteractionTime;
  45786. /**
  45787. * Initializes the behavior.
  45788. */
  45789. init(): void;
  45790. /**
  45791. * Attaches the behavior to its arc rotate camera.
  45792. * @param camera Defines the camera to attach the behavior to
  45793. */
  45794. attach(camera: ArcRotateCamera): void;
  45795. /**
  45796. * Detaches the behavior from its current arc rotate camera.
  45797. */
  45798. detach(): void;
  45799. private _animatables;
  45800. private _betaIsAnimating;
  45801. private _betaTransition;
  45802. private _radiusTransition;
  45803. private _vectorTransition;
  45804. /**
  45805. * Targets the given mesh and updates zoom level accordingly.
  45806. * @param mesh The mesh to target.
  45807. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45808. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45809. */
  45810. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45811. /**
  45812. * Targets the given mesh with its children and updates zoom level accordingly.
  45813. * @param mesh The mesh to target.
  45814. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45815. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45816. */
  45817. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45818. /**
  45819. * Targets the given meshes with their children and updates zoom level accordingly.
  45820. * @param meshes The mesh to target.
  45821. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45822. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45823. */
  45824. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45825. /**
  45826. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  45827. * @param minimumWorld Determines the smaller position of the bounding box extend
  45828. * @param maximumWorld Determines the bigger position of the bounding box extend
  45829. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45830. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45831. */
  45832. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45833. /**
  45834. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  45835. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  45836. * frustum width.
  45837. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  45838. * to fully enclose the mesh in the viewing frustum.
  45839. */
  45840. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  45841. /**
  45842. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  45843. * is automatically returned to its default position (expected to be above ground plane).
  45844. */
  45845. private _maintainCameraAboveGround;
  45846. /**
  45847. * Returns the frustum slope based on the canvas ratio and camera FOV
  45848. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  45849. */
  45850. private _getFrustumSlope;
  45851. /**
  45852. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  45853. */
  45854. private _clearAnimationLocks;
  45855. /**
  45856. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45857. */
  45858. private _applyUserInteraction;
  45859. /**
  45860. * Stops and removes all animations that have been applied to the camera
  45861. */
  45862. stopAllAnimations(): void;
  45863. /**
  45864. * Gets a value indicating if the user is moving the camera
  45865. */
  45866. get isUserIsMoving(): boolean;
  45867. /**
  45868. * The camera can move all the way towards the mesh.
  45869. */
  45870. static IgnoreBoundsSizeMode: number;
  45871. /**
  45872. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  45873. */
  45874. static FitFrustumSidesMode: number;
  45875. }
  45876. }
  45877. declare module BABYLON {
  45878. /**
  45879. * Base class for Camera Pointer Inputs.
  45880. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  45881. * for example usage.
  45882. */
  45883. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  45884. /**
  45885. * Defines the camera the input is attached to.
  45886. */
  45887. abstract camera: Camera;
  45888. /**
  45889. * Whether keyboard modifier keys are pressed at time of last mouse event.
  45890. */
  45891. protected _altKey: boolean;
  45892. protected _ctrlKey: boolean;
  45893. protected _metaKey: boolean;
  45894. protected _shiftKey: boolean;
  45895. /**
  45896. * Which mouse buttons were pressed at time of last mouse event.
  45897. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  45898. */
  45899. protected _buttonsPressed: number;
  45900. /**
  45901. * Defines the buttons associated with the input to handle camera move.
  45902. */
  45903. buttons: number[];
  45904. /**
  45905. * Attach the input controls to a specific dom element to get the input from.
  45906. * @param element Defines the element the controls should be listened from
  45907. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45908. */
  45909. attachControl(noPreventDefault?: boolean): void;
  45910. /**
  45911. * Detach the current controls from the specified dom element.
  45912. */
  45913. detachControl(): void;
  45914. /**
  45915. * Gets the class name of the current input.
  45916. * @returns the class name
  45917. */
  45918. getClassName(): string;
  45919. /**
  45920. * Get the friendly name associated with the input class.
  45921. * @returns the input friendly name
  45922. */
  45923. getSimpleName(): string;
  45924. /**
  45925. * Called on pointer POINTERDOUBLETAP event.
  45926. * Override this method to provide functionality on POINTERDOUBLETAP event.
  45927. */
  45928. protected onDoubleTap(type: string): void;
  45929. /**
  45930. * Called on pointer POINTERMOVE event if only a single touch is active.
  45931. * Override this method to provide functionality.
  45932. */
  45933. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45934. /**
  45935. * Called on pointer POINTERMOVE event if multiple touches are active.
  45936. * Override this method to provide functionality.
  45937. */
  45938. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45939. /**
  45940. * Called on JS contextmenu event.
  45941. * Override this method to provide functionality.
  45942. */
  45943. protected onContextMenu(evt: PointerEvent): void;
  45944. /**
  45945. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45946. * press.
  45947. * Override this method to provide functionality.
  45948. */
  45949. protected onButtonDown(evt: PointerEvent): void;
  45950. /**
  45951. * Called each time a new POINTERUP event occurs. Ie, for each button
  45952. * release.
  45953. * Override this method to provide functionality.
  45954. */
  45955. protected onButtonUp(evt: PointerEvent): void;
  45956. /**
  45957. * Called when window becomes inactive.
  45958. * Override this method to provide functionality.
  45959. */
  45960. protected onLostFocus(): void;
  45961. private _pointerInput;
  45962. private _observer;
  45963. private _onLostFocus;
  45964. private pointA;
  45965. private pointB;
  45966. }
  45967. }
  45968. declare module BABYLON {
  45969. /**
  45970. * Manage the pointers inputs to control an arc rotate camera.
  45971. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45972. */
  45973. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  45974. /**
  45975. * Defines the camera the input is attached to.
  45976. */
  45977. camera: ArcRotateCamera;
  45978. /**
  45979. * Gets the class name of the current input.
  45980. * @returns the class name
  45981. */
  45982. getClassName(): string;
  45983. /**
  45984. * Defines the buttons associated with the input to handle camera move.
  45985. */
  45986. buttons: number[];
  45987. /**
  45988. * Defines the pointer angular sensibility along the X axis or how fast is
  45989. * the camera rotating.
  45990. */
  45991. angularSensibilityX: number;
  45992. /**
  45993. * Defines the pointer angular sensibility along the Y axis or how fast is
  45994. * the camera rotating.
  45995. */
  45996. angularSensibilityY: number;
  45997. /**
  45998. * Defines the pointer pinch precision or how fast is the camera zooming.
  45999. */
  46000. pinchPrecision: number;
  46001. /**
  46002. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46003. * from 0.
  46004. * It defines the percentage of current camera.radius to use as delta when
  46005. * pinch zoom is used.
  46006. */
  46007. pinchDeltaPercentage: number;
  46008. /**
  46009. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46010. * that any object in the plane at the camera's target point will scale
  46011. * perfectly with finger motion.
  46012. * Overrides pinchDeltaPercentage and pinchPrecision.
  46013. */
  46014. useNaturalPinchZoom: boolean;
  46015. /**
  46016. * Defines the pointer panning sensibility or how fast is the camera moving.
  46017. */
  46018. panningSensibility: number;
  46019. /**
  46020. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  46021. */
  46022. multiTouchPanning: boolean;
  46023. /**
  46024. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  46025. * zoom (pinch) through multitouch.
  46026. */
  46027. multiTouchPanAndZoom: boolean;
  46028. /**
  46029. * Revers pinch action direction.
  46030. */
  46031. pinchInwards: boolean;
  46032. private _isPanClick;
  46033. private _twoFingerActivityCount;
  46034. private _isPinching;
  46035. /**
  46036. * Called on pointer POINTERMOVE event if only a single touch is active.
  46037. */
  46038. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46039. /**
  46040. * Called on pointer POINTERDOUBLETAP event.
  46041. */
  46042. protected onDoubleTap(type: string): void;
  46043. /**
  46044. * Called on pointer POINTERMOVE event if multiple touches are active.
  46045. */
  46046. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46047. /**
  46048. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46049. * press.
  46050. */
  46051. protected onButtonDown(evt: PointerEvent): void;
  46052. /**
  46053. * Called each time a new POINTERUP event occurs. Ie, for each button
  46054. * release.
  46055. */
  46056. protected onButtonUp(evt: PointerEvent): void;
  46057. /**
  46058. * Called when window becomes inactive.
  46059. */
  46060. protected onLostFocus(): void;
  46061. }
  46062. }
  46063. declare module BABYLON {
  46064. /**
  46065. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46066. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46067. */
  46068. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46069. /**
  46070. * Defines the camera the input is attached to.
  46071. */
  46072. camera: ArcRotateCamera;
  46073. /**
  46074. * Defines the list of key codes associated with the up action (increase alpha)
  46075. */
  46076. keysUp: number[];
  46077. /**
  46078. * Defines the list of key codes associated with the down action (decrease alpha)
  46079. */
  46080. keysDown: number[];
  46081. /**
  46082. * Defines the list of key codes associated with the left action (increase beta)
  46083. */
  46084. keysLeft: number[];
  46085. /**
  46086. * Defines the list of key codes associated with the right action (decrease beta)
  46087. */
  46088. keysRight: number[];
  46089. /**
  46090. * Defines the list of key codes associated with the reset action.
  46091. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46092. */
  46093. keysReset: number[];
  46094. /**
  46095. * Defines the panning sensibility of the inputs.
  46096. * (How fast is the camera panning)
  46097. */
  46098. panningSensibility: number;
  46099. /**
  46100. * Defines the zooming sensibility of the inputs.
  46101. * (How fast is the camera zooming)
  46102. */
  46103. zoomingSensibility: number;
  46104. /**
  46105. * Defines whether maintaining the alt key down switch the movement mode from
  46106. * orientation to zoom.
  46107. */
  46108. useAltToZoom: boolean;
  46109. /**
  46110. * Rotation speed of the camera
  46111. */
  46112. angularSpeed: number;
  46113. private _keys;
  46114. private _ctrlPressed;
  46115. private _altPressed;
  46116. private _onCanvasBlurObserver;
  46117. private _onKeyboardObserver;
  46118. private _engine;
  46119. private _scene;
  46120. /**
  46121. * Attach the input controls to a specific dom element to get the input from.
  46122. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46123. */
  46124. attachControl(noPreventDefault?: boolean): void;
  46125. /**
  46126. * Detach the current controls from the specified dom element.
  46127. */
  46128. detachControl(): void;
  46129. /**
  46130. * Update the current camera state depending on the inputs that have been used this frame.
  46131. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46132. */
  46133. checkInputs(): void;
  46134. /**
  46135. * Gets the class name of the current intput.
  46136. * @returns the class name
  46137. */
  46138. getClassName(): string;
  46139. /**
  46140. * Get the friendly name associated with the input class.
  46141. * @returns the input friendly name
  46142. */
  46143. getSimpleName(): string;
  46144. }
  46145. }
  46146. declare module BABYLON {
  46147. /**
  46148. * Manage the mouse wheel inputs to control an arc rotate camera.
  46149. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46150. */
  46151. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46152. /**
  46153. * Defines the camera the input is attached to.
  46154. */
  46155. camera: ArcRotateCamera;
  46156. /**
  46157. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46158. */
  46159. wheelPrecision: number;
  46160. /**
  46161. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46162. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46163. */
  46164. wheelDeltaPercentage: number;
  46165. private _wheel;
  46166. private _observer;
  46167. private computeDeltaFromMouseWheelLegacyEvent;
  46168. /**
  46169. * Attach the input controls to a specific dom element to get the input from.
  46170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46171. */
  46172. attachControl(noPreventDefault?: boolean): void;
  46173. /**
  46174. * Detach the current controls from the specified dom element.
  46175. */
  46176. detachControl(): void;
  46177. /**
  46178. * Gets the class name of the current intput.
  46179. * @returns the class name
  46180. */
  46181. getClassName(): string;
  46182. /**
  46183. * Get the friendly name associated with the input class.
  46184. * @returns the input friendly name
  46185. */
  46186. getSimpleName(): string;
  46187. }
  46188. }
  46189. declare module BABYLON {
  46190. /**
  46191. * Default Inputs manager for the ArcRotateCamera.
  46192. * It groups all the default supported inputs for ease of use.
  46193. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46194. */
  46195. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46196. /**
  46197. * Instantiates a new ArcRotateCameraInputsManager.
  46198. * @param camera Defines the camera the inputs belong to
  46199. */
  46200. constructor(camera: ArcRotateCamera);
  46201. /**
  46202. * Add mouse wheel input support to the input manager.
  46203. * @returns the current input manager
  46204. */
  46205. addMouseWheel(): ArcRotateCameraInputsManager;
  46206. /**
  46207. * Add pointers input support to the input manager.
  46208. * @returns the current input manager
  46209. */
  46210. addPointers(): ArcRotateCameraInputsManager;
  46211. /**
  46212. * Add keyboard input support to the input manager.
  46213. * @returns the current input manager
  46214. */
  46215. addKeyboard(): ArcRotateCameraInputsManager;
  46216. }
  46217. }
  46218. declare module BABYLON {
  46219. /**
  46220. * This represents an orbital type of camera.
  46221. *
  46222. * 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.
  46223. * 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.
  46224. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46225. */
  46226. export class ArcRotateCamera extends TargetCamera {
  46227. /**
  46228. * Defines the rotation angle of the camera along the longitudinal axis.
  46229. */
  46230. alpha: number;
  46231. /**
  46232. * Defines the rotation angle of the camera along the latitudinal axis.
  46233. */
  46234. beta: number;
  46235. /**
  46236. * Defines the radius of the camera from it s target point.
  46237. */
  46238. radius: number;
  46239. protected _target: Vector3;
  46240. protected _targetHost: Nullable<AbstractMesh>;
  46241. /**
  46242. * Defines the target point of the camera.
  46243. * The camera looks towards it form the radius distance.
  46244. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46245. */
  46246. get target(): Vector3;
  46247. set target(value: Vector3);
  46248. /**
  46249. * Define the current local position of the camera in the scene
  46250. */
  46251. get position(): Vector3;
  46252. set position(newPosition: Vector3);
  46253. protected _upToYMatrix: Matrix;
  46254. protected _YToUpMatrix: Matrix;
  46255. /**
  46256. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46257. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46258. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46259. */
  46260. set upVector(vec: Vector3);
  46261. get upVector(): Vector3;
  46262. /**
  46263. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46264. */
  46265. setMatUp(): void;
  46266. /**
  46267. * Current inertia value on the longitudinal axis.
  46268. * The bigger this number the longer it will take for the camera to stop.
  46269. */
  46270. inertialAlphaOffset: number;
  46271. /**
  46272. * Current inertia value on the latitudinal axis.
  46273. * The bigger this number the longer it will take for the camera to stop.
  46274. */
  46275. inertialBetaOffset: number;
  46276. /**
  46277. * Current inertia value on the radius axis.
  46278. * The bigger this number the longer it will take for the camera to stop.
  46279. */
  46280. inertialRadiusOffset: number;
  46281. /**
  46282. * Minimum allowed angle on the longitudinal axis.
  46283. * This can help limiting how the Camera is able to move in the scene.
  46284. */
  46285. lowerAlphaLimit: Nullable<number>;
  46286. /**
  46287. * Maximum allowed angle on the longitudinal axis.
  46288. * This can help limiting how the Camera is able to move in the scene.
  46289. */
  46290. upperAlphaLimit: Nullable<number>;
  46291. /**
  46292. * Minimum allowed angle on the latitudinal axis.
  46293. * This can help limiting how the Camera is able to move in the scene.
  46294. */
  46295. lowerBetaLimit: number;
  46296. /**
  46297. * Maximum allowed angle on the latitudinal axis.
  46298. * This can help limiting how the Camera is able to move in the scene.
  46299. */
  46300. upperBetaLimit: number;
  46301. /**
  46302. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46303. * This can help limiting how the Camera is able to move in the scene.
  46304. */
  46305. lowerRadiusLimit: Nullable<number>;
  46306. /**
  46307. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46308. * This can help limiting how the Camera is able to move in the scene.
  46309. */
  46310. upperRadiusLimit: Nullable<number>;
  46311. /**
  46312. * Defines the current inertia value used during panning of the camera along the X axis.
  46313. */
  46314. inertialPanningX: number;
  46315. /**
  46316. * Defines the current inertia value used during panning of the camera along the Y axis.
  46317. */
  46318. inertialPanningY: number;
  46319. /**
  46320. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46321. * Basically if your fingers moves away from more than this distance you will be considered
  46322. * in pinch mode.
  46323. */
  46324. pinchToPanMaxDistance: number;
  46325. /**
  46326. * Defines the maximum distance the camera can pan.
  46327. * This could help keeping the cammera always in your scene.
  46328. */
  46329. panningDistanceLimit: Nullable<number>;
  46330. /**
  46331. * Defines the target of the camera before paning.
  46332. */
  46333. panningOriginTarget: Vector3;
  46334. /**
  46335. * Defines the value of the inertia used during panning.
  46336. * 0 would mean stop inertia and one would mean no decelleration at all.
  46337. */
  46338. panningInertia: number;
  46339. /**
  46340. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46341. */
  46342. get angularSensibilityX(): number;
  46343. set angularSensibilityX(value: number);
  46344. /**
  46345. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46346. */
  46347. get angularSensibilityY(): number;
  46348. set angularSensibilityY(value: number);
  46349. /**
  46350. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46351. */
  46352. get pinchPrecision(): number;
  46353. set pinchPrecision(value: number);
  46354. /**
  46355. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46356. * It will be used instead of pinchDeltaPrecision if different from 0.
  46357. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46358. */
  46359. get pinchDeltaPercentage(): number;
  46360. set pinchDeltaPercentage(value: number);
  46361. /**
  46362. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46363. * and pinch delta percentage.
  46364. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46365. * that any object in the plane at the camera's target point will scale
  46366. * perfectly with finger motion.
  46367. */
  46368. get useNaturalPinchZoom(): boolean;
  46369. set useNaturalPinchZoom(value: boolean);
  46370. /**
  46371. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46372. */
  46373. get panningSensibility(): number;
  46374. set panningSensibility(value: number);
  46375. /**
  46376. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46377. */
  46378. get keysUp(): number[];
  46379. set keysUp(value: number[]);
  46380. /**
  46381. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46382. */
  46383. get keysDown(): number[];
  46384. set keysDown(value: number[]);
  46385. /**
  46386. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46387. */
  46388. get keysLeft(): number[];
  46389. set keysLeft(value: number[]);
  46390. /**
  46391. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46392. */
  46393. get keysRight(): number[];
  46394. set keysRight(value: number[]);
  46395. /**
  46396. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46397. */
  46398. get wheelPrecision(): number;
  46399. set wheelPrecision(value: number);
  46400. /**
  46401. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46402. * It will be used instead of pinchDeltaPrecision if different from 0.
  46403. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46404. */
  46405. get wheelDeltaPercentage(): number;
  46406. set wheelDeltaPercentage(value: number);
  46407. /**
  46408. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46409. */
  46410. zoomOnFactor: number;
  46411. /**
  46412. * Defines a screen offset for the camera position.
  46413. */
  46414. targetScreenOffset: Vector2;
  46415. /**
  46416. * Allows the camera to be completely reversed.
  46417. * If false the camera can not arrive upside down.
  46418. */
  46419. allowUpsideDown: boolean;
  46420. /**
  46421. * Define if double tap/click is used to restore the previously saved state of the camera.
  46422. */
  46423. useInputToRestoreState: boolean;
  46424. /** @hidden */
  46425. _viewMatrix: Matrix;
  46426. /** @hidden */
  46427. _useCtrlForPanning: boolean;
  46428. /** @hidden */
  46429. _panningMouseButton: number;
  46430. /**
  46431. * Defines the input associated to the camera.
  46432. */
  46433. inputs: ArcRotateCameraInputsManager;
  46434. /** @hidden */
  46435. _reset: () => void;
  46436. /**
  46437. * Defines the allowed panning axis.
  46438. */
  46439. panningAxis: Vector3;
  46440. protected _localDirection: Vector3;
  46441. protected _transformedDirection: Vector3;
  46442. private _bouncingBehavior;
  46443. /**
  46444. * Gets the bouncing behavior of the camera if it has been enabled.
  46445. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46446. */
  46447. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46448. /**
  46449. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46450. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46451. */
  46452. get useBouncingBehavior(): boolean;
  46453. set useBouncingBehavior(value: boolean);
  46454. private _framingBehavior;
  46455. /**
  46456. * Gets the framing behavior of the camera if it has been enabled.
  46457. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46458. */
  46459. get framingBehavior(): Nullable<FramingBehavior>;
  46460. /**
  46461. * Defines if the framing behavior of the camera is enabled on the camera.
  46462. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46463. */
  46464. get useFramingBehavior(): boolean;
  46465. set useFramingBehavior(value: boolean);
  46466. private _autoRotationBehavior;
  46467. /**
  46468. * Gets the auto rotation behavior of the camera if it has been enabled.
  46469. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46470. */
  46471. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46472. /**
  46473. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46474. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46475. */
  46476. get useAutoRotationBehavior(): boolean;
  46477. set useAutoRotationBehavior(value: boolean);
  46478. /**
  46479. * Observable triggered when the mesh target has been changed on the camera.
  46480. */
  46481. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46482. /**
  46483. * Event raised when the camera is colliding with a mesh.
  46484. */
  46485. onCollide: (collidedMesh: AbstractMesh) => void;
  46486. /**
  46487. * Defines whether the camera should check collision with the objects oh the scene.
  46488. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46489. */
  46490. checkCollisions: boolean;
  46491. /**
  46492. * Defines the collision radius of the camera.
  46493. * This simulates a sphere around the camera.
  46494. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46495. */
  46496. collisionRadius: Vector3;
  46497. protected _collider: Collider;
  46498. protected _previousPosition: Vector3;
  46499. protected _collisionVelocity: Vector3;
  46500. protected _newPosition: Vector3;
  46501. protected _previousAlpha: number;
  46502. protected _previousBeta: number;
  46503. protected _previousRadius: number;
  46504. protected _collisionTriggered: boolean;
  46505. protected _targetBoundingCenter: Nullable<Vector3>;
  46506. private _computationVector;
  46507. /**
  46508. * Instantiates a new ArcRotateCamera in a given scene
  46509. * @param name Defines the name of the camera
  46510. * @param alpha Defines the camera rotation along the logitudinal axis
  46511. * @param beta Defines the camera rotation along the latitudinal axis
  46512. * @param radius Defines the camera distance from its target
  46513. * @param target Defines the camera target
  46514. * @param scene Defines the scene the camera belongs to
  46515. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46516. */
  46517. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46518. /** @hidden */
  46519. _initCache(): void;
  46520. /** @hidden */
  46521. _updateCache(ignoreParentClass?: boolean): void;
  46522. protected _getTargetPosition(): Vector3;
  46523. private _storedAlpha;
  46524. private _storedBeta;
  46525. private _storedRadius;
  46526. private _storedTarget;
  46527. private _storedTargetScreenOffset;
  46528. /**
  46529. * Stores the current state of the camera (alpha, beta, radius and target)
  46530. * @returns the camera itself
  46531. */
  46532. storeState(): Camera;
  46533. /**
  46534. * @hidden
  46535. * Restored camera state. You must call storeState() first
  46536. */
  46537. _restoreStateValues(): boolean;
  46538. /** @hidden */
  46539. _isSynchronizedViewMatrix(): boolean;
  46540. /**
  46541. * Attach the input controls to a specific dom element to get the input from.
  46542. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46543. */
  46544. attachControl(noPreventDefault?: boolean): void;
  46545. /**
  46546. * Attach the input controls to a specific dom element to get the input from.
  46547. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46549. */
  46550. attachControl(ignored: any, noPreventDefault?: boolean): void;
  46551. /**
  46552. * Attached controls to the current camera.
  46553. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46554. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46555. */
  46556. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46557. /**
  46558. * Attached controls to the current camera.
  46559. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46560. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46561. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46562. */
  46563. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46564. /**
  46565. * Attached controls to the current camera.
  46566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46567. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46568. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46569. */
  46570. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  46571. /**
  46572. * Detach the current controls from the camera.
  46573. * The camera will stop reacting to inputs.
  46574. */
  46575. detachControl(): void;
  46576. /** @hidden */
  46577. _checkInputs(): void;
  46578. protected _checkLimits(): void;
  46579. /**
  46580. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46581. */
  46582. rebuildAnglesAndRadius(): void;
  46583. /**
  46584. * Use a position to define the current camera related information like alpha, beta and radius
  46585. * @param position Defines the position to set the camera at
  46586. */
  46587. setPosition(position: Vector3): void;
  46588. /**
  46589. * Defines the target the camera should look at.
  46590. * This will automatically adapt alpha beta and radius to fit within the new target.
  46591. * @param target Defines the new target as a Vector or a mesh
  46592. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46593. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46594. */
  46595. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46596. /** @hidden */
  46597. _getViewMatrix(): Matrix;
  46598. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46599. /**
  46600. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46601. * @param meshes Defines the mesh to zoom on
  46602. * @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)
  46603. */
  46604. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46605. /**
  46606. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46607. * The target will be changed but the radius
  46608. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46609. * @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)
  46610. */
  46611. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46612. min: Vector3;
  46613. max: Vector3;
  46614. distance: number;
  46615. }, doNotUpdateMaxZ?: boolean): void;
  46616. /**
  46617. * @override
  46618. * Override Camera.createRigCamera
  46619. */
  46620. createRigCamera(name: string, cameraIndex: number): Camera;
  46621. /**
  46622. * @hidden
  46623. * @override
  46624. * Override Camera._updateRigCameras
  46625. */
  46626. _updateRigCameras(): void;
  46627. /**
  46628. * Destroy the camera and release the current resources hold by it.
  46629. */
  46630. dispose(): void;
  46631. /**
  46632. * Gets the current object class name.
  46633. * @return the class name
  46634. */
  46635. getClassName(): string;
  46636. }
  46637. }
  46638. declare module BABYLON {
  46639. /**
  46640. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46641. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46642. */
  46643. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46644. /**
  46645. * Gets the name of the behavior.
  46646. */
  46647. get name(): string;
  46648. private _zoomStopsAnimation;
  46649. private _idleRotationSpeed;
  46650. private _idleRotationWaitTime;
  46651. private _idleRotationSpinupTime;
  46652. /**
  46653. * Sets the flag that indicates if user zooming should stop animation.
  46654. */
  46655. set zoomStopsAnimation(flag: boolean);
  46656. /**
  46657. * Gets the flag that indicates if user zooming should stop animation.
  46658. */
  46659. get zoomStopsAnimation(): boolean;
  46660. /**
  46661. * Sets the default speed at which the camera rotates around the model.
  46662. */
  46663. set idleRotationSpeed(speed: number);
  46664. /**
  46665. * Gets the default speed at which the camera rotates around the model.
  46666. */
  46667. get idleRotationSpeed(): number;
  46668. /**
  46669. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46670. */
  46671. set idleRotationWaitTime(time: number);
  46672. /**
  46673. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46674. */
  46675. get idleRotationWaitTime(): number;
  46676. /**
  46677. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46678. */
  46679. set idleRotationSpinupTime(time: number);
  46680. /**
  46681. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46682. */
  46683. get idleRotationSpinupTime(): number;
  46684. /**
  46685. * Gets a value indicating if the camera is currently rotating because of this behavior
  46686. */
  46687. get rotationInProgress(): boolean;
  46688. private _onPrePointerObservableObserver;
  46689. private _onAfterCheckInputsObserver;
  46690. private _attachedCamera;
  46691. private _isPointerDown;
  46692. private _lastFrameTime;
  46693. private _lastInteractionTime;
  46694. private _cameraRotationSpeed;
  46695. /**
  46696. * Initializes the behavior.
  46697. */
  46698. init(): void;
  46699. /**
  46700. * Attaches the behavior to its arc rotate camera.
  46701. * @param camera Defines the camera to attach the behavior to
  46702. */
  46703. attach(camera: ArcRotateCamera): void;
  46704. /**
  46705. * Detaches the behavior from its current arc rotate camera.
  46706. */
  46707. detach(): void;
  46708. /**
  46709. * Returns true if user is scrolling.
  46710. * @return true if user is scrolling.
  46711. */
  46712. private _userIsZooming;
  46713. private _lastFrameRadius;
  46714. private _shouldAnimationStopForInteraction;
  46715. /**
  46716. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46717. */
  46718. private _applyUserInteraction;
  46719. private _userIsMoving;
  46720. }
  46721. }
  46722. declare module BABYLON {
  46723. /**
  46724. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46725. */
  46726. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46727. private ui;
  46728. /**
  46729. * The name of the behavior
  46730. */
  46731. name: string;
  46732. /**
  46733. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  46734. */
  46735. distanceAwayFromFace: number;
  46736. /**
  46737. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  46738. */
  46739. distanceAwayFromBottomOfFace: number;
  46740. private _faceVectors;
  46741. private _target;
  46742. private _scene;
  46743. private _onRenderObserver;
  46744. private _tmpMatrix;
  46745. private _tmpVector;
  46746. /**
  46747. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  46748. * @param ui The transform node that should be attched to the mesh
  46749. */
  46750. constructor(ui: TransformNode);
  46751. /**
  46752. * Initializes the behavior
  46753. */
  46754. init(): void;
  46755. private _closestFace;
  46756. private _zeroVector;
  46757. private _lookAtTmpMatrix;
  46758. private _lookAtToRef;
  46759. /**
  46760. * Attaches the AttachToBoxBehavior to the passed in mesh
  46761. * @param target The mesh that the specified node will be attached to
  46762. */
  46763. attach(target: Mesh): void;
  46764. /**
  46765. * Detaches the behavior from the mesh
  46766. */
  46767. detach(): void;
  46768. }
  46769. }
  46770. declare module BABYLON {
  46771. /**
  46772. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  46773. */
  46774. export class FadeInOutBehavior implements Behavior<Mesh> {
  46775. /**
  46776. * Time in milliseconds to delay before fading in (Default: 0)
  46777. */
  46778. delay: number;
  46779. /**
  46780. * Time in milliseconds for the mesh to fade in (Default: 300)
  46781. */
  46782. fadeInTime: number;
  46783. private _millisecondsPerFrame;
  46784. private _hovered;
  46785. private _hoverValue;
  46786. private _ownerNode;
  46787. /**
  46788. * Instatiates the FadeInOutBehavior
  46789. */
  46790. constructor();
  46791. /**
  46792. * The name of the behavior
  46793. */
  46794. get name(): string;
  46795. /**
  46796. * Initializes the behavior
  46797. */
  46798. init(): void;
  46799. /**
  46800. * Attaches the fade behavior on the passed in mesh
  46801. * @param ownerNode The mesh that will be faded in/out once attached
  46802. */
  46803. attach(ownerNode: Mesh): void;
  46804. /**
  46805. * Detaches the behavior from the mesh
  46806. */
  46807. detach(): void;
  46808. /**
  46809. * Triggers the mesh to begin fading in or out
  46810. * @param value if the object should fade in or out (true to fade in)
  46811. */
  46812. fadeIn(value: boolean): void;
  46813. private _update;
  46814. private _setAllVisibility;
  46815. }
  46816. }
  46817. declare module BABYLON {
  46818. /**
  46819. * Class containing a set of static utilities functions for managing Pivots
  46820. * @hidden
  46821. */
  46822. export class PivotTools {
  46823. private static _PivotCached;
  46824. private static _OldPivotPoint;
  46825. private static _PivotTranslation;
  46826. private static _PivotTmpVector;
  46827. private static _PivotPostMultiplyPivotMatrix;
  46828. /** @hidden */
  46829. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  46830. /** @hidden */
  46831. static _RestorePivotPoint(mesh: AbstractMesh): void;
  46832. }
  46833. }
  46834. declare module BABYLON {
  46835. /**
  46836. * Class containing static functions to help procedurally build meshes
  46837. */
  46838. export class PlaneBuilder {
  46839. /**
  46840. * Creates a plane mesh
  46841. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46842. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46843. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46844. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46845. * * 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
  46846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46847. * @param name defines the name of the mesh
  46848. * @param options defines the options used to create the mesh
  46849. * @param scene defines the hosting scene
  46850. * @returns the plane mesh
  46851. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46852. */
  46853. static CreatePlane(name: string, options: {
  46854. size?: number;
  46855. width?: number;
  46856. height?: number;
  46857. sideOrientation?: number;
  46858. frontUVs?: Vector4;
  46859. backUVs?: Vector4;
  46860. updatable?: boolean;
  46861. sourcePlane?: Plane;
  46862. }, scene?: Nullable<Scene>): Mesh;
  46863. }
  46864. }
  46865. declare module BABYLON {
  46866. /**
  46867. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  46868. */
  46869. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  46870. private static _AnyMouseID;
  46871. /**
  46872. * Abstract mesh the behavior is set on
  46873. */
  46874. attachedNode: AbstractMesh;
  46875. private _dragPlane;
  46876. private _scene;
  46877. private _pointerObserver;
  46878. private _beforeRenderObserver;
  46879. private static _planeScene;
  46880. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  46881. /**
  46882. * 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)
  46883. */
  46884. maxDragAngle: number;
  46885. /**
  46886. * @hidden
  46887. */
  46888. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  46889. /**
  46890. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46891. */
  46892. currentDraggingPointerID: number;
  46893. /**
  46894. * The last position where the pointer hit the drag plane in world space
  46895. */
  46896. lastDragPosition: Vector3;
  46897. /**
  46898. * If the behavior is currently in a dragging state
  46899. */
  46900. dragging: boolean;
  46901. /**
  46902. * 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)
  46903. */
  46904. dragDeltaRatio: number;
  46905. /**
  46906. * If the drag plane orientation should be updated during the dragging (Default: true)
  46907. */
  46908. updateDragPlane: boolean;
  46909. private _debugMode;
  46910. private _moving;
  46911. /**
  46912. * Fires each time the attached mesh is dragged with the pointer
  46913. * * delta between last drag position and current drag position in world space
  46914. * * dragDistance along the drag axis
  46915. * * dragPlaneNormal normal of the current drag plane used during the drag
  46916. * * dragPlanePoint in world space where the drag intersects the drag plane
  46917. */
  46918. onDragObservable: Observable<{
  46919. delta: Vector3;
  46920. dragPlanePoint: Vector3;
  46921. dragPlaneNormal: Vector3;
  46922. dragDistance: number;
  46923. pointerId: number;
  46924. }>;
  46925. /**
  46926. * Fires each time a drag begins (eg. mouse down on mesh)
  46927. */
  46928. onDragStartObservable: Observable<{
  46929. dragPlanePoint: Vector3;
  46930. pointerId: number;
  46931. }>;
  46932. /**
  46933. * Fires each time a drag ends (eg. mouse release after drag)
  46934. */
  46935. onDragEndObservable: Observable<{
  46936. dragPlanePoint: Vector3;
  46937. pointerId: number;
  46938. }>;
  46939. /**
  46940. * If the attached mesh should be moved when dragged
  46941. */
  46942. moveAttached: boolean;
  46943. /**
  46944. * If the drag behavior will react to drag events (Default: true)
  46945. */
  46946. enabled: boolean;
  46947. /**
  46948. * If pointer events should start and release the drag (Default: true)
  46949. */
  46950. startAndReleaseDragOnPointerEvents: boolean;
  46951. /**
  46952. * If camera controls should be detached during the drag
  46953. */
  46954. detachCameraControls: boolean;
  46955. /**
  46956. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  46957. */
  46958. useObjectOrientationForDragging: boolean;
  46959. private _options;
  46960. /**
  46961. * Gets the options used by the behavior
  46962. */
  46963. get options(): {
  46964. dragAxis?: Vector3;
  46965. dragPlaneNormal?: Vector3;
  46966. };
  46967. /**
  46968. * Sets the options used by the behavior
  46969. */
  46970. set options(options: {
  46971. dragAxis?: Vector3;
  46972. dragPlaneNormal?: Vector3;
  46973. });
  46974. /**
  46975. * Creates a pointer drag behavior that can be attached to a mesh
  46976. * @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)
  46977. */
  46978. constructor(options?: {
  46979. dragAxis?: Vector3;
  46980. dragPlaneNormal?: Vector3;
  46981. });
  46982. /**
  46983. * Predicate to determine if it is valid to move the object to a new position when it is moved
  46984. */
  46985. validateDrag: (targetPosition: Vector3) => boolean;
  46986. /**
  46987. * The name of the behavior
  46988. */
  46989. get name(): string;
  46990. /**
  46991. * Initializes the behavior
  46992. */
  46993. init(): void;
  46994. private _tmpVector;
  46995. private _alternatePickedPoint;
  46996. private _worldDragAxis;
  46997. private _targetPosition;
  46998. private _attachedToElement;
  46999. /**
  47000. * Attaches the drag behavior the passed in mesh
  47001. * @param ownerNode The mesh that will be dragged around once attached
  47002. * @param predicate Predicate to use for pick filtering
  47003. */
  47004. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  47005. /**
  47006. * Force relase the drag action by code.
  47007. */
  47008. releaseDrag(): void;
  47009. private _startDragRay;
  47010. private _lastPointerRay;
  47011. /**
  47012. * Simulates the start of a pointer drag event on the behavior
  47013. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  47014. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  47015. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  47016. */
  47017. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47018. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47019. private _dragDelta;
  47020. protected _moveDrag(ray: Ray): void;
  47021. private _pickWithRayOnDragPlane;
  47022. private _pointA;
  47023. private _pointC;
  47024. private _localAxis;
  47025. private _lookAt;
  47026. private _updateDragPlanePosition;
  47027. /**
  47028. * Detaches the behavior from the mesh
  47029. */
  47030. detach(): void;
  47031. }
  47032. }
  47033. declare module BABYLON {
  47034. /**
  47035. * A behavior that when attached to a mesh will allow the mesh to be scaled
  47036. */
  47037. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  47038. private _dragBehaviorA;
  47039. private _dragBehaviorB;
  47040. private _startDistance;
  47041. private _initialScale;
  47042. private _targetScale;
  47043. private _ownerNode;
  47044. private _sceneRenderObserver;
  47045. /**
  47046. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  47047. */
  47048. constructor();
  47049. /**
  47050. * The name of the behavior
  47051. */
  47052. get name(): string;
  47053. /**
  47054. * Initializes the behavior
  47055. */
  47056. init(): void;
  47057. private _getCurrentDistance;
  47058. /**
  47059. * Attaches the scale behavior the passed in mesh
  47060. * @param ownerNode The mesh that will be scaled around once attached
  47061. */
  47062. attach(ownerNode: Mesh): void;
  47063. /**
  47064. * Detaches the behavior from the mesh
  47065. */
  47066. detach(): void;
  47067. }
  47068. }
  47069. declare module BABYLON {
  47070. /**
  47071. * 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
  47072. */
  47073. export class SixDofDragBehavior implements Behavior<Mesh> {
  47074. private static _virtualScene;
  47075. private _ownerNode;
  47076. private _sceneRenderObserver;
  47077. private _scene;
  47078. private _targetPosition;
  47079. private _virtualOriginMesh;
  47080. private _virtualDragMesh;
  47081. private _pointerObserver;
  47082. private _moving;
  47083. private _startingOrientation;
  47084. private _attachedToElement;
  47085. /**
  47086. * 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)
  47087. */
  47088. private zDragFactor;
  47089. /**
  47090. * If the object should rotate to face the drag origin
  47091. */
  47092. rotateDraggedObject: boolean;
  47093. /**
  47094. * If the behavior is currently in a dragging state
  47095. */
  47096. dragging: boolean;
  47097. /**
  47098. * 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)
  47099. */
  47100. dragDeltaRatio: number;
  47101. /**
  47102. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47103. */
  47104. currentDraggingPointerID: number;
  47105. /**
  47106. * If camera controls should be detached during the drag
  47107. */
  47108. detachCameraControls: boolean;
  47109. /**
  47110. * Fires each time a drag starts
  47111. */
  47112. onDragStartObservable: Observable<{}>;
  47113. /**
  47114. * Fires each time a drag ends (eg. mouse release after drag)
  47115. */
  47116. onDragEndObservable: Observable<{}>;
  47117. /**
  47118. * 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
  47119. */
  47120. constructor();
  47121. /**
  47122. * The name of the behavior
  47123. */
  47124. get name(): string;
  47125. /**
  47126. * Initializes the behavior
  47127. */
  47128. init(): void;
  47129. /**
  47130. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47131. */
  47132. private get _pointerCamera();
  47133. /**
  47134. * Attaches the scale behavior the passed in mesh
  47135. * @param ownerNode The mesh that will be scaled around once attached
  47136. */
  47137. attach(ownerNode: Mesh): void;
  47138. /**
  47139. * Detaches the behavior from the mesh
  47140. */
  47141. detach(): void;
  47142. }
  47143. }
  47144. declare module BABYLON {
  47145. /**
  47146. * Class used to apply inverse kinematics to bones
  47147. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47148. */
  47149. export class BoneIKController {
  47150. private static _tmpVecs;
  47151. private static _tmpQuat;
  47152. private static _tmpMats;
  47153. /**
  47154. * Gets or sets the target mesh
  47155. */
  47156. targetMesh: AbstractMesh;
  47157. /** Gets or sets the mesh used as pole */
  47158. poleTargetMesh: AbstractMesh;
  47159. /**
  47160. * Gets or sets the bone used as pole
  47161. */
  47162. poleTargetBone: Nullable<Bone>;
  47163. /**
  47164. * Gets or sets the target position
  47165. */
  47166. targetPosition: Vector3;
  47167. /**
  47168. * Gets or sets the pole target position
  47169. */
  47170. poleTargetPosition: Vector3;
  47171. /**
  47172. * Gets or sets the pole target local offset
  47173. */
  47174. poleTargetLocalOffset: Vector3;
  47175. /**
  47176. * Gets or sets the pole angle
  47177. */
  47178. poleAngle: number;
  47179. /**
  47180. * Gets or sets the mesh associated with the controller
  47181. */
  47182. mesh: AbstractMesh;
  47183. /**
  47184. * 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)
  47185. */
  47186. slerpAmount: number;
  47187. private _bone1Quat;
  47188. private _bone1Mat;
  47189. private _bone2Ang;
  47190. private _bone1;
  47191. private _bone2;
  47192. private _bone1Length;
  47193. private _bone2Length;
  47194. private _maxAngle;
  47195. private _maxReach;
  47196. private _rightHandedSystem;
  47197. private _bendAxis;
  47198. private _slerping;
  47199. private _adjustRoll;
  47200. /**
  47201. * Gets or sets maximum allowed angle
  47202. */
  47203. get maxAngle(): number;
  47204. set maxAngle(value: number);
  47205. /**
  47206. * Creates a new BoneIKController
  47207. * @param mesh defines the mesh to control
  47208. * @param bone defines the bone to control
  47209. * @param options defines options to set up the controller
  47210. */
  47211. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47212. targetMesh?: AbstractMesh;
  47213. poleTargetMesh?: AbstractMesh;
  47214. poleTargetBone?: Bone;
  47215. poleTargetLocalOffset?: Vector3;
  47216. poleAngle?: number;
  47217. bendAxis?: Vector3;
  47218. maxAngle?: number;
  47219. slerpAmount?: number;
  47220. });
  47221. private _setMaxAngle;
  47222. /**
  47223. * Force the controller to update the bones
  47224. */
  47225. update(): void;
  47226. }
  47227. }
  47228. declare module BABYLON {
  47229. /**
  47230. * Class used to make a bone look toward a point in space
  47231. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47232. */
  47233. export class BoneLookController {
  47234. private static _tmpVecs;
  47235. private static _tmpQuat;
  47236. private static _tmpMats;
  47237. /**
  47238. * The target Vector3 that the bone will look at
  47239. */
  47240. target: Vector3;
  47241. /**
  47242. * The mesh that the bone is attached to
  47243. */
  47244. mesh: AbstractMesh;
  47245. /**
  47246. * The bone that will be looking to the target
  47247. */
  47248. bone: Bone;
  47249. /**
  47250. * The up axis of the coordinate system that is used when the bone is rotated
  47251. */
  47252. upAxis: Vector3;
  47253. /**
  47254. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47255. */
  47256. upAxisSpace: Space;
  47257. /**
  47258. * Used to make an adjustment to the yaw of the bone
  47259. */
  47260. adjustYaw: number;
  47261. /**
  47262. * Used to make an adjustment to the pitch of the bone
  47263. */
  47264. adjustPitch: number;
  47265. /**
  47266. * Used to make an adjustment to the roll of the bone
  47267. */
  47268. adjustRoll: number;
  47269. /**
  47270. * 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)
  47271. */
  47272. slerpAmount: number;
  47273. private _minYaw;
  47274. private _maxYaw;
  47275. private _minPitch;
  47276. private _maxPitch;
  47277. private _minYawSin;
  47278. private _minYawCos;
  47279. private _maxYawSin;
  47280. private _maxYawCos;
  47281. private _midYawConstraint;
  47282. private _minPitchTan;
  47283. private _maxPitchTan;
  47284. private _boneQuat;
  47285. private _slerping;
  47286. private _transformYawPitch;
  47287. private _transformYawPitchInv;
  47288. private _firstFrameSkipped;
  47289. private _yawRange;
  47290. private _fowardAxis;
  47291. /**
  47292. * Gets or sets the minimum yaw angle that the bone can look to
  47293. */
  47294. get minYaw(): number;
  47295. set minYaw(value: number);
  47296. /**
  47297. * Gets or sets the maximum yaw angle that the bone can look to
  47298. */
  47299. get maxYaw(): number;
  47300. set maxYaw(value: number);
  47301. /**
  47302. * Gets or sets the minimum pitch angle that the bone can look to
  47303. */
  47304. get minPitch(): number;
  47305. set minPitch(value: number);
  47306. /**
  47307. * Gets or sets the maximum pitch angle that the bone can look to
  47308. */
  47309. get maxPitch(): number;
  47310. set maxPitch(value: number);
  47311. /**
  47312. * Create a BoneLookController
  47313. * @param mesh the mesh that the bone belongs to
  47314. * @param bone the bone that will be looking to the target
  47315. * @param target the target Vector3 to look at
  47316. * @param options optional settings:
  47317. * * maxYaw: the maximum angle the bone will yaw to
  47318. * * minYaw: the minimum angle the bone will yaw to
  47319. * * maxPitch: the maximum angle the bone will pitch to
  47320. * * minPitch: the minimum angle the bone will yaw to
  47321. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47322. * * upAxis: the up axis of the coordinate system
  47323. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47324. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47325. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47326. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47327. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47328. * * adjustRoll: used to make an adjustment to the roll of the bone
  47329. **/
  47330. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47331. maxYaw?: number;
  47332. minYaw?: number;
  47333. maxPitch?: number;
  47334. minPitch?: number;
  47335. slerpAmount?: number;
  47336. upAxis?: Vector3;
  47337. upAxisSpace?: Space;
  47338. yawAxis?: Vector3;
  47339. pitchAxis?: Vector3;
  47340. adjustYaw?: number;
  47341. adjustPitch?: number;
  47342. adjustRoll?: number;
  47343. });
  47344. /**
  47345. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47346. */
  47347. update(): void;
  47348. private _getAngleDiff;
  47349. private _getAngleBetween;
  47350. private _isAngleBetween;
  47351. }
  47352. }
  47353. declare module BABYLON {
  47354. /**
  47355. * Manage the gamepad inputs to control an arc rotate camera.
  47356. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47357. */
  47358. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47359. /**
  47360. * Defines the camera the input is attached to.
  47361. */
  47362. camera: ArcRotateCamera;
  47363. /**
  47364. * Defines the gamepad the input is gathering event from.
  47365. */
  47366. gamepad: Nullable<Gamepad>;
  47367. /**
  47368. * Defines the gamepad rotation sensiblity.
  47369. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47370. */
  47371. gamepadRotationSensibility: number;
  47372. /**
  47373. * Defines the gamepad move sensiblity.
  47374. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47375. */
  47376. gamepadMoveSensibility: number;
  47377. private _yAxisScale;
  47378. /**
  47379. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47380. */
  47381. get invertYAxis(): boolean;
  47382. set invertYAxis(value: boolean);
  47383. private _onGamepadConnectedObserver;
  47384. private _onGamepadDisconnectedObserver;
  47385. /**
  47386. * Attach the input controls to a specific dom element to get the input from.
  47387. */
  47388. attachControl(): void;
  47389. /**
  47390. * Detach the current controls from the specified dom element.
  47391. * @param element Defines the element to stop listening the inputs from
  47392. */
  47393. detachControl(): void;
  47394. /**
  47395. * Update the current camera state depending on the inputs that have been used this frame.
  47396. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47397. */
  47398. checkInputs(): void;
  47399. /**
  47400. * Gets the class name of the current intput.
  47401. * @returns the class name
  47402. */
  47403. getClassName(): string;
  47404. /**
  47405. * Get the friendly name associated with the input class.
  47406. * @returns the input friendly name
  47407. */
  47408. getSimpleName(): string;
  47409. }
  47410. }
  47411. declare module BABYLON {
  47412. interface ArcRotateCameraInputsManager {
  47413. /**
  47414. * Add orientation input support to the input manager.
  47415. * @returns the current input manager
  47416. */
  47417. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47418. }
  47419. /**
  47420. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47421. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47422. */
  47423. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47424. /**
  47425. * Defines the camera the input is attached to.
  47426. */
  47427. camera: ArcRotateCamera;
  47428. /**
  47429. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47430. */
  47431. alphaCorrection: number;
  47432. /**
  47433. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47434. */
  47435. gammaCorrection: number;
  47436. private _alpha;
  47437. private _gamma;
  47438. private _dirty;
  47439. private _deviceOrientationHandler;
  47440. /**
  47441. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47442. */
  47443. constructor();
  47444. /**
  47445. * Attach the input controls to a specific dom element to get the input from.
  47446. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47447. */
  47448. attachControl(noPreventDefault?: boolean): void;
  47449. /** @hidden */
  47450. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47451. /**
  47452. * Update the current camera state depending on the inputs that have been used this frame.
  47453. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47454. */
  47455. checkInputs(): void;
  47456. /**
  47457. * Detach the current controls from the specified dom element.
  47458. */
  47459. detachControl(): void;
  47460. /**
  47461. * Gets the class name of the current intput.
  47462. * @returns the class name
  47463. */
  47464. getClassName(): string;
  47465. /**
  47466. * Get the friendly name associated with the input class.
  47467. * @returns the input friendly name
  47468. */
  47469. getSimpleName(): string;
  47470. }
  47471. }
  47472. declare module BABYLON {
  47473. /**
  47474. * Listen to mouse events to control the camera.
  47475. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47476. */
  47477. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47478. /**
  47479. * Defines the camera the input is attached to.
  47480. */
  47481. camera: FlyCamera;
  47482. /**
  47483. * Defines if touch is enabled. (Default is true.)
  47484. */
  47485. touchEnabled: boolean;
  47486. /**
  47487. * Defines the buttons associated with the input to handle camera rotation.
  47488. */
  47489. buttons: number[];
  47490. /**
  47491. * Assign buttons for Yaw control.
  47492. */
  47493. buttonsYaw: number[];
  47494. /**
  47495. * Assign buttons for Pitch control.
  47496. */
  47497. buttonsPitch: number[];
  47498. /**
  47499. * Assign buttons for Roll control.
  47500. */
  47501. buttonsRoll: number[];
  47502. /**
  47503. * Detect if any button is being pressed while mouse is moved.
  47504. * -1 = Mouse locked.
  47505. * 0 = Left button.
  47506. * 1 = Middle Button.
  47507. * 2 = Right Button.
  47508. */
  47509. activeButton: number;
  47510. /**
  47511. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47512. * Higher values reduce its sensitivity.
  47513. */
  47514. angularSensibility: number;
  47515. private _observer;
  47516. private _rollObserver;
  47517. private previousPosition;
  47518. private noPreventDefault;
  47519. private element;
  47520. /**
  47521. * Listen to mouse events to control the camera.
  47522. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47523. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47524. */
  47525. constructor(touchEnabled?: boolean);
  47526. /**
  47527. * Attach the mouse control to the HTML DOM element.
  47528. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47529. */
  47530. attachControl(noPreventDefault?: boolean): void;
  47531. /**
  47532. * Detach the current controls from the specified dom element.
  47533. */
  47534. detachControl(): void;
  47535. /**
  47536. * Gets the class name of the current input.
  47537. * @returns the class name.
  47538. */
  47539. getClassName(): string;
  47540. /**
  47541. * Get the friendly name associated with the input class.
  47542. * @returns the input's friendly name.
  47543. */
  47544. getSimpleName(): string;
  47545. private _pointerInput;
  47546. private _onMouseMove;
  47547. /**
  47548. * Rotate camera by mouse offset.
  47549. */
  47550. private rotateCamera;
  47551. }
  47552. }
  47553. declare module BABYLON {
  47554. /**
  47555. * Default Inputs manager for the FlyCamera.
  47556. * It groups all the default supported inputs for ease of use.
  47557. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47558. */
  47559. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47560. /**
  47561. * Instantiates a new FlyCameraInputsManager.
  47562. * @param camera Defines the camera the inputs belong to.
  47563. */
  47564. constructor(camera: FlyCamera);
  47565. /**
  47566. * Add keyboard input support to the input manager.
  47567. * @returns the new FlyCameraKeyboardMoveInput().
  47568. */
  47569. addKeyboard(): FlyCameraInputsManager;
  47570. /**
  47571. * Add mouse input support to the input manager.
  47572. * @param touchEnabled Enable touch screen support.
  47573. * @returns the new FlyCameraMouseInput().
  47574. */
  47575. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47576. }
  47577. }
  47578. declare module BABYLON {
  47579. /**
  47580. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47581. * such as in a 3D Space Shooter or a Flight Simulator.
  47582. */
  47583. export class FlyCamera extends TargetCamera {
  47584. /**
  47585. * Define the collision ellipsoid of the camera.
  47586. * This is helpful for simulating a camera body, like a player's body.
  47587. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47588. */
  47589. ellipsoid: Vector3;
  47590. /**
  47591. * Define an offset for the position of the ellipsoid around the camera.
  47592. * This can be helpful if the camera is attached away from the player's body center,
  47593. * such as at its head.
  47594. */
  47595. ellipsoidOffset: Vector3;
  47596. /**
  47597. * Enable or disable collisions of the camera with the rest of the scene objects.
  47598. */
  47599. checkCollisions: boolean;
  47600. /**
  47601. * Enable or disable gravity on the camera.
  47602. */
  47603. applyGravity: boolean;
  47604. /**
  47605. * Define the current direction the camera is moving to.
  47606. */
  47607. cameraDirection: Vector3;
  47608. /**
  47609. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47610. * This overrides and empties cameraRotation.
  47611. */
  47612. rotationQuaternion: Quaternion;
  47613. /**
  47614. * Track Roll to maintain the wanted Rolling when looking around.
  47615. */
  47616. _trackRoll: number;
  47617. /**
  47618. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47619. */
  47620. rollCorrect: number;
  47621. /**
  47622. * Mimic a banked turn, Rolling the camera when Yawing.
  47623. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47624. */
  47625. bankedTurn: boolean;
  47626. /**
  47627. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47628. */
  47629. bankedTurnLimit: number;
  47630. /**
  47631. * Value of 0 disables the banked Roll.
  47632. * Value of 1 is equal to the Yaw angle in radians.
  47633. */
  47634. bankedTurnMultiplier: number;
  47635. /**
  47636. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47637. */
  47638. inputs: FlyCameraInputsManager;
  47639. /**
  47640. * Gets the input sensibility for mouse input.
  47641. * Higher values reduce sensitivity.
  47642. */
  47643. get angularSensibility(): number;
  47644. /**
  47645. * Sets the input sensibility for a mouse input.
  47646. * Higher values reduce sensitivity.
  47647. */
  47648. set angularSensibility(value: number);
  47649. /**
  47650. * Get the keys for camera movement forward.
  47651. */
  47652. get keysForward(): number[];
  47653. /**
  47654. * Set the keys for camera movement forward.
  47655. */
  47656. set keysForward(value: number[]);
  47657. /**
  47658. * Get the keys for camera movement backward.
  47659. */
  47660. get keysBackward(): number[];
  47661. set keysBackward(value: number[]);
  47662. /**
  47663. * Get the keys for camera movement up.
  47664. */
  47665. get keysUp(): number[];
  47666. /**
  47667. * Set the keys for camera movement up.
  47668. */
  47669. set keysUp(value: number[]);
  47670. /**
  47671. * Get the keys for camera movement down.
  47672. */
  47673. get keysDown(): number[];
  47674. /**
  47675. * Set the keys for camera movement down.
  47676. */
  47677. set keysDown(value: number[]);
  47678. /**
  47679. * Get the keys for camera movement left.
  47680. */
  47681. get keysLeft(): number[];
  47682. /**
  47683. * Set the keys for camera movement left.
  47684. */
  47685. set keysLeft(value: number[]);
  47686. /**
  47687. * Set the keys for camera movement right.
  47688. */
  47689. get keysRight(): number[];
  47690. /**
  47691. * Set the keys for camera movement right.
  47692. */
  47693. set keysRight(value: number[]);
  47694. /**
  47695. * Event raised when the camera collides with a mesh in the scene.
  47696. */
  47697. onCollide: (collidedMesh: AbstractMesh) => void;
  47698. private _collider;
  47699. private _needMoveForGravity;
  47700. private _oldPosition;
  47701. private _diffPosition;
  47702. private _newPosition;
  47703. /** @hidden */
  47704. _localDirection: Vector3;
  47705. /** @hidden */
  47706. _transformedDirection: Vector3;
  47707. /**
  47708. * Instantiates a FlyCamera.
  47709. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47710. * such as in a 3D Space Shooter or a Flight Simulator.
  47711. * @param name Define the name of the camera in the scene.
  47712. * @param position Define the starting position of the camera in the scene.
  47713. * @param scene Define the scene the camera belongs to.
  47714. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47715. */
  47716. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47717. /**
  47718. * Attach a control to the HTML DOM element.
  47719. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  47720. */
  47721. attachControl(noPreventDefault?: boolean): void;
  47722. /**
  47723. * Detach a control from the HTML DOM element.
  47724. * The camera will stop reacting to that input.
  47725. */
  47726. detachControl(): void;
  47727. private _collisionMask;
  47728. /**
  47729. * Get the mask that the camera ignores in collision events.
  47730. */
  47731. get collisionMask(): number;
  47732. /**
  47733. * Set the mask that the camera ignores in collision events.
  47734. */
  47735. set collisionMask(mask: number);
  47736. /** @hidden */
  47737. _collideWithWorld(displacement: Vector3): void;
  47738. /** @hidden */
  47739. private _onCollisionPositionChange;
  47740. /** @hidden */
  47741. _checkInputs(): void;
  47742. /** @hidden */
  47743. _decideIfNeedsToMove(): boolean;
  47744. /** @hidden */
  47745. _updatePosition(): void;
  47746. /**
  47747. * Restore the Roll to its target value at the rate specified.
  47748. * @param rate - Higher means slower restoring.
  47749. * @hidden
  47750. */
  47751. restoreRoll(rate: number): void;
  47752. /**
  47753. * Destroy the camera and release the current resources held by it.
  47754. */
  47755. dispose(): void;
  47756. /**
  47757. * Get the current object class name.
  47758. * @returns the class name.
  47759. */
  47760. getClassName(): string;
  47761. }
  47762. }
  47763. declare module BABYLON {
  47764. /**
  47765. * Listen to keyboard events to control the camera.
  47766. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47767. */
  47768. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  47769. /**
  47770. * Defines the camera the input is attached to.
  47771. */
  47772. camera: FlyCamera;
  47773. /**
  47774. * The list of keyboard keys used to control the forward move of the camera.
  47775. */
  47776. keysForward: number[];
  47777. /**
  47778. * The list of keyboard keys used to control the backward move of the camera.
  47779. */
  47780. keysBackward: number[];
  47781. /**
  47782. * The list of keyboard keys used to control the forward move of the camera.
  47783. */
  47784. keysUp: number[];
  47785. /**
  47786. * The list of keyboard keys used to control the backward move of the camera.
  47787. */
  47788. keysDown: number[];
  47789. /**
  47790. * The list of keyboard keys used to control the right strafe move of the camera.
  47791. */
  47792. keysRight: number[];
  47793. /**
  47794. * The list of keyboard keys used to control the left strafe move of the camera.
  47795. */
  47796. keysLeft: number[];
  47797. private _keys;
  47798. private _onCanvasBlurObserver;
  47799. private _onKeyboardObserver;
  47800. private _engine;
  47801. private _scene;
  47802. /**
  47803. * Attach the input controls to a specific dom element to get the input from.
  47804. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47805. */
  47806. attachControl(noPreventDefault?: boolean): void;
  47807. /**
  47808. * Detach the current controls from the specified dom element.
  47809. */
  47810. detachControl(): void;
  47811. /**
  47812. * Gets the class name of the current intput.
  47813. * @returns the class name
  47814. */
  47815. getClassName(): string;
  47816. /** @hidden */
  47817. _onLostFocus(e: FocusEvent): void;
  47818. /**
  47819. * Get the friendly name associated with the input class.
  47820. * @returns the input friendly name
  47821. */
  47822. getSimpleName(): string;
  47823. /**
  47824. * Update the current camera state depending on the inputs that have been used this frame.
  47825. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47826. */
  47827. checkInputs(): void;
  47828. }
  47829. }
  47830. declare module BABYLON {
  47831. /**
  47832. * Manage the mouse wheel inputs to control a follow camera.
  47833. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47834. */
  47835. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  47836. /**
  47837. * Defines the camera the input is attached to.
  47838. */
  47839. camera: FollowCamera;
  47840. /**
  47841. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  47842. */
  47843. axisControlRadius: boolean;
  47844. /**
  47845. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  47846. */
  47847. axisControlHeight: boolean;
  47848. /**
  47849. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  47850. */
  47851. axisControlRotation: boolean;
  47852. /**
  47853. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  47854. * relation to mouseWheel events.
  47855. */
  47856. wheelPrecision: number;
  47857. /**
  47858. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47859. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47860. */
  47861. wheelDeltaPercentage: number;
  47862. private _wheel;
  47863. private _observer;
  47864. /**
  47865. * Attach the input controls to a specific dom element to get the input from.
  47866. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47867. */
  47868. attachControl(noPreventDefault?: boolean): void;
  47869. /**
  47870. * Detach the current controls from the specified dom element.
  47871. */
  47872. detachControl(): void;
  47873. /**
  47874. * Gets the class name of the current intput.
  47875. * @returns the class name
  47876. */
  47877. getClassName(): string;
  47878. /**
  47879. * Get the friendly name associated with the input class.
  47880. * @returns the input friendly name
  47881. */
  47882. getSimpleName(): string;
  47883. }
  47884. }
  47885. declare module BABYLON {
  47886. /**
  47887. * Manage the pointers inputs to control an follow camera.
  47888. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47889. */
  47890. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  47891. /**
  47892. * Defines the camera the input is attached to.
  47893. */
  47894. camera: FollowCamera;
  47895. /**
  47896. * Gets the class name of the current input.
  47897. * @returns the class name
  47898. */
  47899. getClassName(): string;
  47900. /**
  47901. * Defines the pointer angular sensibility along the X axis or how fast is
  47902. * the camera rotating.
  47903. * A negative number will reverse the axis direction.
  47904. */
  47905. angularSensibilityX: number;
  47906. /**
  47907. * Defines the pointer angular sensibility along the Y axis or how fast is
  47908. * the camera rotating.
  47909. * A negative number will reverse the axis direction.
  47910. */
  47911. angularSensibilityY: number;
  47912. /**
  47913. * Defines the pointer pinch precision or how fast is the camera zooming.
  47914. * A negative number will reverse the axis direction.
  47915. */
  47916. pinchPrecision: number;
  47917. /**
  47918. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47919. * from 0.
  47920. * It defines the percentage of current camera.radius to use as delta when
  47921. * pinch zoom is used.
  47922. */
  47923. pinchDeltaPercentage: number;
  47924. /**
  47925. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  47926. */
  47927. axisXControlRadius: boolean;
  47928. /**
  47929. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  47930. */
  47931. axisXControlHeight: boolean;
  47932. /**
  47933. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  47934. */
  47935. axisXControlRotation: boolean;
  47936. /**
  47937. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  47938. */
  47939. axisYControlRadius: boolean;
  47940. /**
  47941. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  47942. */
  47943. axisYControlHeight: boolean;
  47944. /**
  47945. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  47946. */
  47947. axisYControlRotation: boolean;
  47948. /**
  47949. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  47950. */
  47951. axisPinchControlRadius: boolean;
  47952. /**
  47953. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  47954. */
  47955. axisPinchControlHeight: boolean;
  47956. /**
  47957. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  47958. */
  47959. axisPinchControlRotation: boolean;
  47960. /**
  47961. * Log error messages if basic misconfiguration has occurred.
  47962. */
  47963. warningEnable: boolean;
  47964. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47965. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47966. private _warningCounter;
  47967. private _warning;
  47968. }
  47969. }
  47970. declare module BABYLON {
  47971. /**
  47972. * Default Inputs manager for the FollowCamera.
  47973. * It groups all the default supported inputs for ease of use.
  47974. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47975. */
  47976. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  47977. /**
  47978. * Instantiates a new FollowCameraInputsManager.
  47979. * @param camera Defines the camera the inputs belong to
  47980. */
  47981. constructor(camera: FollowCamera);
  47982. /**
  47983. * Add keyboard input support to the input manager.
  47984. * @returns the current input manager
  47985. */
  47986. addKeyboard(): FollowCameraInputsManager;
  47987. /**
  47988. * Add mouse wheel input support to the input manager.
  47989. * @returns the current input manager
  47990. */
  47991. addMouseWheel(): FollowCameraInputsManager;
  47992. /**
  47993. * Add pointers input support to the input manager.
  47994. * @returns the current input manager
  47995. */
  47996. addPointers(): FollowCameraInputsManager;
  47997. /**
  47998. * Add orientation input support to the input manager.
  47999. * @returns the current input manager
  48000. */
  48001. addVRDeviceOrientation(): FollowCameraInputsManager;
  48002. }
  48003. }
  48004. declare module BABYLON {
  48005. /**
  48006. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  48007. * an arc rotate version arcFollowCamera are available.
  48008. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48009. */
  48010. export class FollowCamera extends TargetCamera {
  48011. /**
  48012. * Distance the follow camera should follow an object at
  48013. */
  48014. radius: number;
  48015. /**
  48016. * Minimum allowed distance of the camera to the axis of rotation
  48017. * (The camera can not get closer).
  48018. * This can help limiting how the Camera is able to move in the scene.
  48019. */
  48020. lowerRadiusLimit: Nullable<number>;
  48021. /**
  48022. * Maximum allowed distance of the camera to the axis of rotation
  48023. * (The camera can not get further).
  48024. * This can help limiting how the Camera is able to move in the scene.
  48025. */
  48026. upperRadiusLimit: Nullable<number>;
  48027. /**
  48028. * Define a rotation offset between the camera and the object it follows
  48029. */
  48030. rotationOffset: number;
  48031. /**
  48032. * Minimum allowed angle to camera position relative to target object.
  48033. * This can help limiting how the Camera is able to move in the scene.
  48034. */
  48035. lowerRotationOffsetLimit: Nullable<number>;
  48036. /**
  48037. * Maximum allowed angle to camera position relative to target object.
  48038. * This can help limiting how the Camera is able to move in the scene.
  48039. */
  48040. upperRotationOffsetLimit: Nullable<number>;
  48041. /**
  48042. * Define a height offset between the camera and the object it follows.
  48043. * It can help following an object from the top (like a car chaing a plane)
  48044. */
  48045. heightOffset: number;
  48046. /**
  48047. * Minimum allowed height of camera position relative to target object.
  48048. * This can help limiting how the Camera is able to move in the scene.
  48049. */
  48050. lowerHeightOffsetLimit: Nullable<number>;
  48051. /**
  48052. * Maximum allowed height of camera position relative to target object.
  48053. * This can help limiting how the Camera is able to move in the scene.
  48054. */
  48055. upperHeightOffsetLimit: Nullable<number>;
  48056. /**
  48057. * Define how fast the camera can accelerate to follow it s target.
  48058. */
  48059. cameraAcceleration: number;
  48060. /**
  48061. * Define the speed limit of the camera following an object.
  48062. */
  48063. maxCameraSpeed: number;
  48064. /**
  48065. * Define the target of the camera.
  48066. */
  48067. lockedTarget: Nullable<AbstractMesh>;
  48068. /**
  48069. * Defines the input associated with the camera.
  48070. */
  48071. inputs: FollowCameraInputsManager;
  48072. /**
  48073. * Instantiates the follow camera.
  48074. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48075. * @param name Define the name of the camera in the scene
  48076. * @param position Define the position of the camera
  48077. * @param scene Define the scene the camera belong to
  48078. * @param lockedTarget Define the target of the camera
  48079. */
  48080. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48081. private _follow;
  48082. /**
  48083. * Attached controls to the current camera.
  48084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48085. */
  48086. attachControl(noPreventDefault?: boolean): void;
  48087. /**
  48088. * Detach the current controls from the camera.
  48089. * The camera will stop reacting to inputs.
  48090. */
  48091. detachControl(): void;
  48092. /** @hidden */
  48093. _checkInputs(): void;
  48094. private _checkLimits;
  48095. /**
  48096. * Gets the camera class name.
  48097. * @returns the class name
  48098. */
  48099. getClassName(): string;
  48100. }
  48101. /**
  48102. * Arc Rotate version of the follow camera.
  48103. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48104. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48105. */
  48106. export class ArcFollowCamera extends TargetCamera {
  48107. /** The longitudinal angle of the camera */
  48108. alpha: number;
  48109. /** The latitudinal angle of the camera */
  48110. beta: number;
  48111. /** The radius of the camera from its target */
  48112. radius: number;
  48113. private _cartesianCoordinates;
  48114. /** Define the camera target (the mesh it should follow) */
  48115. private _meshTarget;
  48116. /**
  48117. * Instantiates a new ArcFollowCamera
  48118. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48119. * @param name Define the name of the camera
  48120. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48121. * @param beta Define the rotation angle of the camera around the elevation axis
  48122. * @param radius Define the radius of the camera from its target point
  48123. * @param target Define the target of the camera
  48124. * @param scene Define the scene the camera belongs to
  48125. */
  48126. constructor(name: string,
  48127. /** The longitudinal angle of the camera */
  48128. alpha: number,
  48129. /** The latitudinal angle of the camera */
  48130. beta: number,
  48131. /** The radius of the camera from its target */
  48132. radius: number,
  48133. /** Define the camera target (the mesh it should follow) */
  48134. target: Nullable<AbstractMesh>, scene: Scene);
  48135. private _follow;
  48136. /** @hidden */
  48137. _checkInputs(): void;
  48138. /**
  48139. * Returns the class name of the object.
  48140. * It is mostly used internally for serialization purposes.
  48141. */
  48142. getClassName(): string;
  48143. }
  48144. }
  48145. declare module BABYLON {
  48146. /**
  48147. * Manage the keyboard inputs to control the movement of a follow camera.
  48148. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48149. */
  48150. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48151. /**
  48152. * Defines the camera the input is attached to.
  48153. */
  48154. camera: FollowCamera;
  48155. /**
  48156. * Defines the list of key codes associated with the up action (increase heightOffset)
  48157. */
  48158. keysHeightOffsetIncr: number[];
  48159. /**
  48160. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48161. */
  48162. keysHeightOffsetDecr: number[];
  48163. /**
  48164. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48165. */
  48166. keysHeightOffsetModifierAlt: boolean;
  48167. /**
  48168. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48169. */
  48170. keysHeightOffsetModifierCtrl: boolean;
  48171. /**
  48172. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48173. */
  48174. keysHeightOffsetModifierShift: boolean;
  48175. /**
  48176. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48177. */
  48178. keysRotationOffsetIncr: number[];
  48179. /**
  48180. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48181. */
  48182. keysRotationOffsetDecr: number[];
  48183. /**
  48184. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48185. */
  48186. keysRotationOffsetModifierAlt: boolean;
  48187. /**
  48188. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48189. */
  48190. keysRotationOffsetModifierCtrl: boolean;
  48191. /**
  48192. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48193. */
  48194. keysRotationOffsetModifierShift: boolean;
  48195. /**
  48196. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48197. */
  48198. keysRadiusIncr: number[];
  48199. /**
  48200. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48201. */
  48202. keysRadiusDecr: number[];
  48203. /**
  48204. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48205. */
  48206. keysRadiusModifierAlt: boolean;
  48207. /**
  48208. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48209. */
  48210. keysRadiusModifierCtrl: boolean;
  48211. /**
  48212. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48213. */
  48214. keysRadiusModifierShift: boolean;
  48215. /**
  48216. * Defines the rate of change of heightOffset.
  48217. */
  48218. heightSensibility: number;
  48219. /**
  48220. * Defines the rate of change of rotationOffset.
  48221. */
  48222. rotationSensibility: number;
  48223. /**
  48224. * Defines the rate of change of radius.
  48225. */
  48226. radiusSensibility: number;
  48227. private _keys;
  48228. private _ctrlPressed;
  48229. private _altPressed;
  48230. private _shiftPressed;
  48231. private _onCanvasBlurObserver;
  48232. private _onKeyboardObserver;
  48233. private _engine;
  48234. private _scene;
  48235. /**
  48236. * Attach the input controls to a specific dom element to get the input from.
  48237. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48238. */
  48239. attachControl(noPreventDefault?: boolean): void;
  48240. /**
  48241. * Detach the current controls from the specified dom element.
  48242. */
  48243. detachControl(): void;
  48244. /**
  48245. * Update the current camera state depending on the inputs that have been used this frame.
  48246. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48247. */
  48248. checkInputs(): void;
  48249. /**
  48250. * Gets the class name of the current input.
  48251. * @returns the class name
  48252. */
  48253. getClassName(): string;
  48254. /**
  48255. * Get the friendly name associated with the input class.
  48256. * @returns the input friendly name
  48257. */
  48258. getSimpleName(): string;
  48259. /**
  48260. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48261. * allow modification of the heightOffset value.
  48262. */
  48263. private _modifierHeightOffset;
  48264. /**
  48265. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48266. * allow modification of the rotationOffset value.
  48267. */
  48268. private _modifierRotationOffset;
  48269. /**
  48270. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48271. * allow modification of the radius value.
  48272. */
  48273. private _modifierRadius;
  48274. }
  48275. }
  48276. declare module BABYLON {
  48277. interface FreeCameraInputsManager {
  48278. /**
  48279. * @hidden
  48280. */
  48281. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48282. /**
  48283. * Add orientation input support to the input manager.
  48284. * @returns the current input manager
  48285. */
  48286. addDeviceOrientation(): FreeCameraInputsManager;
  48287. }
  48288. /**
  48289. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48290. * Screen rotation is taken into account.
  48291. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48292. */
  48293. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48294. private _camera;
  48295. private _screenOrientationAngle;
  48296. private _constantTranform;
  48297. private _screenQuaternion;
  48298. private _alpha;
  48299. private _beta;
  48300. private _gamma;
  48301. /**
  48302. * Can be used to detect if a device orientation sensor is available on a device
  48303. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48304. * @returns a promise that will resolve on orientation change
  48305. */
  48306. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  48307. /**
  48308. * @hidden
  48309. */
  48310. _onDeviceOrientationChangedObservable: Observable<void>;
  48311. /**
  48312. * Instantiates a new input
  48313. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48314. */
  48315. constructor();
  48316. /**
  48317. * Define the camera controlled by the input.
  48318. */
  48319. get camera(): FreeCamera;
  48320. set camera(camera: FreeCamera);
  48321. /**
  48322. * Attach the input controls to a specific dom element to get the input from.
  48323. */
  48324. attachControl(): void;
  48325. private _orientationChanged;
  48326. private _deviceOrientation;
  48327. /**
  48328. * Detach the current controls from the specified dom element.
  48329. */
  48330. detachControl(): void;
  48331. /**
  48332. * Update the current camera state depending on the inputs that have been used this frame.
  48333. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48334. */
  48335. checkInputs(): void;
  48336. /**
  48337. * Gets the class name of the current intput.
  48338. * @returns the class name
  48339. */
  48340. getClassName(): string;
  48341. /**
  48342. * Get the friendly name associated with the input class.
  48343. * @returns the input friendly name
  48344. */
  48345. getSimpleName(): string;
  48346. }
  48347. }
  48348. declare module BABYLON {
  48349. /**
  48350. * Manage the gamepad inputs to control a free camera.
  48351. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48352. */
  48353. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48354. /**
  48355. * Define the camera the input is attached to.
  48356. */
  48357. camera: FreeCamera;
  48358. /**
  48359. * Define the Gamepad controlling the input
  48360. */
  48361. gamepad: Nullable<Gamepad>;
  48362. /**
  48363. * Defines the gamepad rotation sensiblity.
  48364. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48365. */
  48366. gamepadAngularSensibility: number;
  48367. /**
  48368. * Defines the gamepad move sensiblity.
  48369. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48370. */
  48371. gamepadMoveSensibility: number;
  48372. private _yAxisScale;
  48373. /**
  48374. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48375. */
  48376. get invertYAxis(): boolean;
  48377. set invertYAxis(value: boolean);
  48378. private _onGamepadConnectedObserver;
  48379. private _onGamepadDisconnectedObserver;
  48380. private _cameraTransform;
  48381. private _deltaTransform;
  48382. private _vector3;
  48383. private _vector2;
  48384. /**
  48385. * Attach the input controls to a specific dom element to get the input from.
  48386. */
  48387. attachControl(): void;
  48388. /**
  48389. * Detach the current controls from the specified dom element.
  48390. */
  48391. detachControl(): void;
  48392. /**
  48393. * Update the current camera state depending on the inputs that have been used this frame.
  48394. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48395. */
  48396. checkInputs(): void;
  48397. /**
  48398. * Gets the class name of the current intput.
  48399. * @returns the class name
  48400. */
  48401. getClassName(): string;
  48402. /**
  48403. * Get the friendly name associated with the input class.
  48404. * @returns the input friendly name
  48405. */
  48406. getSimpleName(): string;
  48407. }
  48408. }
  48409. declare module BABYLON {
  48410. /**
  48411. * Defines the potential axis of a Joystick
  48412. */
  48413. export enum JoystickAxis {
  48414. /** X axis */
  48415. X = 0,
  48416. /** Y axis */
  48417. Y = 1,
  48418. /** Z axis */
  48419. Z = 2
  48420. }
  48421. /**
  48422. * Represents the different customization options available
  48423. * for VirtualJoystick
  48424. */
  48425. interface VirtualJoystickCustomizations {
  48426. /**
  48427. * Size of the joystick's puck
  48428. */
  48429. puckSize: number;
  48430. /**
  48431. * Size of the joystick's container
  48432. */
  48433. containerSize: number;
  48434. /**
  48435. * Color of the joystick && puck
  48436. */
  48437. color: string;
  48438. /**
  48439. * Image URL for the joystick's puck
  48440. */
  48441. puckImage?: string;
  48442. /**
  48443. * Image URL for the joystick's container
  48444. */
  48445. containerImage?: string;
  48446. /**
  48447. * Defines the unmoving position of the joystick container
  48448. */
  48449. position?: {
  48450. x: number;
  48451. y: number;
  48452. };
  48453. /**
  48454. * Defines whether or not the joystick container is always visible
  48455. */
  48456. alwaysVisible: boolean;
  48457. /**
  48458. * Defines whether or not to limit the movement of the puck to the joystick's container
  48459. */
  48460. limitToContainer: boolean;
  48461. }
  48462. /**
  48463. * Class used to define virtual joystick (used in touch mode)
  48464. */
  48465. export class VirtualJoystick {
  48466. /**
  48467. * Gets or sets a boolean indicating that left and right values must be inverted
  48468. */
  48469. reverseLeftRight: boolean;
  48470. /**
  48471. * Gets or sets a boolean indicating that up and down values must be inverted
  48472. */
  48473. reverseUpDown: boolean;
  48474. /**
  48475. * Gets the offset value for the position (ie. the change of the position value)
  48476. */
  48477. deltaPosition: Vector3;
  48478. /**
  48479. * Gets a boolean indicating if the virtual joystick was pressed
  48480. */
  48481. pressed: boolean;
  48482. /**
  48483. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48484. */
  48485. static Canvas: Nullable<HTMLCanvasElement>;
  48486. /**
  48487. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48488. */
  48489. limitToContainer: boolean;
  48490. private static _globalJoystickIndex;
  48491. private static _alwaysVisibleSticks;
  48492. private static vjCanvasContext;
  48493. private static vjCanvasWidth;
  48494. private static vjCanvasHeight;
  48495. private static halfWidth;
  48496. private static _GetDefaultOptions;
  48497. private _action;
  48498. private _axisTargetedByLeftAndRight;
  48499. private _axisTargetedByUpAndDown;
  48500. private _joystickSensibility;
  48501. private _inversedSensibility;
  48502. private _joystickPointerID;
  48503. private _joystickColor;
  48504. private _joystickPointerPos;
  48505. private _joystickPreviousPointerPos;
  48506. private _joystickPointerStartPos;
  48507. private _deltaJoystickVector;
  48508. private _leftJoystick;
  48509. private _touches;
  48510. private _joystickPosition;
  48511. private _alwaysVisible;
  48512. private _puckImage;
  48513. private _containerImage;
  48514. private _joystickPuckSize;
  48515. private _joystickContainerSize;
  48516. private _clearPuckSize;
  48517. private _clearContainerSize;
  48518. private _clearPuckSizeOffset;
  48519. private _clearContainerSizeOffset;
  48520. private _onPointerDownHandlerRef;
  48521. private _onPointerMoveHandlerRef;
  48522. private _onPointerUpHandlerRef;
  48523. private _onResize;
  48524. /**
  48525. * Creates a new virtual joystick
  48526. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48527. * @param customizations Defines the options we want to customize the VirtualJoystick
  48528. */
  48529. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48530. /**
  48531. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48532. * @param newJoystickSensibility defines the new sensibility
  48533. */
  48534. setJoystickSensibility(newJoystickSensibility: number): void;
  48535. private _onPointerDown;
  48536. private _onPointerMove;
  48537. private _onPointerUp;
  48538. /**
  48539. * Change the color of the virtual joystick
  48540. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48541. */
  48542. setJoystickColor(newColor: string): void;
  48543. /**
  48544. * Size of the joystick's container
  48545. */
  48546. set containerSize(newSize: number);
  48547. get containerSize(): number;
  48548. /**
  48549. * Size of the joystick's puck
  48550. */
  48551. set puckSize(newSize: number);
  48552. get puckSize(): number;
  48553. /**
  48554. * Clears the set position of the joystick
  48555. */
  48556. clearPosition(): void;
  48557. /**
  48558. * Defines whether or not the joystick container is always visible
  48559. */
  48560. set alwaysVisible(value: boolean);
  48561. get alwaysVisible(): boolean;
  48562. /**
  48563. * Sets the constant position of the Joystick container
  48564. * @param x X axis coordinate
  48565. * @param y Y axis coordinate
  48566. */
  48567. setPosition(x: number, y: number): void;
  48568. /**
  48569. * Defines a callback to call when the joystick is touched
  48570. * @param action defines the callback
  48571. */
  48572. setActionOnTouch(action: () => any): void;
  48573. /**
  48574. * Defines which axis you'd like to control for left & right
  48575. * @param axis defines the axis to use
  48576. */
  48577. setAxisForLeftRight(axis: JoystickAxis): void;
  48578. /**
  48579. * Defines which axis you'd like to control for up & down
  48580. * @param axis defines the axis to use
  48581. */
  48582. setAxisForUpDown(axis: JoystickAxis): void;
  48583. /**
  48584. * Clears the canvas from the previous puck / container draw
  48585. */
  48586. private _clearPreviousDraw;
  48587. /**
  48588. * Loads `urlPath` to be used for the container's image
  48589. * @param urlPath defines the urlPath of an image to use
  48590. */
  48591. setContainerImage(urlPath: string): void;
  48592. /**
  48593. * Loads `urlPath` to be used for the puck's image
  48594. * @param urlPath defines the urlPath of an image to use
  48595. */
  48596. setPuckImage(urlPath: string): void;
  48597. /**
  48598. * Draws the Virtual Joystick's container
  48599. */
  48600. private _drawContainer;
  48601. /**
  48602. * Draws the Virtual Joystick's puck
  48603. */
  48604. private _drawPuck;
  48605. private _drawVirtualJoystick;
  48606. /**
  48607. * Release internal HTML canvas
  48608. */
  48609. releaseCanvas(): void;
  48610. }
  48611. }
  48612. declare module BABYLON {
  48613. interface FreeCameraInputsManager {
  48614. /**
  48615. * Add virtual joystick input support to the input manager.
  48616. * @returns the current input manager
  48617. */
  48618. addVirtualJoystick(): FreeCameraInputsManager;
  48619. }
  48620. /**
  48621. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48622. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48623. */
  48624. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48625. /**
  48626. * Defines the camera the input is attached to.
  48627. */
  48628. camera: FreeCamera;
  48629. private _leftjoystick;
  48630. private _rightjoystick;
  48631. /**
  48632. * Gets the left stick of the virtual joystick.
  48633. * @returns The virtual Joystick
  48634. */
  48635. getLeftJoystick(): VirtualJoystick;
  48636. /**
  48637. * Gets the right stick of the virtual joystick.
  48638. * @returns The virtual Joystick
  48639. */
  48640. getRightJoystick(): VirtualJoystick;
  48641. /**
  48642. * Update the current camera state depending on the inputs that have been used this frame.
  48643. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48644. */
  48645. checkInputs(): void;
  48646. /**
  48647. * Attach the input controls to a specific dom element to get the input from.
  48648. */
  48649. attachControl(): void;
  48650. /**
  48651. * Detach the current controls from the specified dom element.
  48652. */
  48653. detachControl(): void;
  48654. /**
  48655. * Gets the class name of the current intput.
  48656. * @returns the class name
  48657. */
  48658. getClassName(): string;
  48659. /**
  48660. * Get the friendly name associated with the input class.
  48661. * @returns the input friendly name
  48662. */
  48663. getSimpleName(): string;
  48664. }
  48665. }
  48666. declare module BABYLON {
  48667. /**
  48668. * This represents a FPS type of camera controlled by touch.
  48669. * This is like a universal camera minus the Gamepad controls.
  48670. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48671. */
  48672. export class TouchCamera extends FreeCamera {
  48673. /**
  48674. * Defines the touch sensibility for rotation.
  48675. * The higher the faster.
  48676. */
  48677. get touchAngularSensibility(): number;
  48678. set touchAngularSensibility(value: number);
  48679. /**
  48680. * Defines the touch sensibility for move.
  48681. * The higher the faster.
  48682. */
  48683. get touchMoveSensibility(): number;
  48684. set touchMoveSensibility(value: number);
  48685. /**
  48686. * Instantiates a new touch camera.
  48687. * This represents a FPS type of camera controlled by touch.
  48688. * This is like a universal camera minus the Gamepad controls.
  48689. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48690. * @param name Define the name of the camera in the scene
  48691. * @param position Define the start position of the camera in the scene
  48692. * @param scene Define the scene the camera belongs to
  48693. */
  48694. constructor(name: string, position: Vector3, scene: Scene);
  48695. /**
  48696. * Gets the current object class name.
  48697. * @return the class name
  48698. */
  48699. getClassName(): string;
  48700. /** @hidden */
  48701. _setupInputs(): void;
  48702. }
  48703. }
  48704. declare module BABYLON {
  48705. /**
  48706. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48707. * being tilted forward or back and left or right.
  48708. */
  48709. export class DeviceOrientationCamera extends FreeCamera {
  48710. private _initialQuaternion;
  48711. private _quaternionCache;
  48712. private _tmpDragQuaternion;
  48713. private _disablePointerInputWhenUsingDeviceOrientation;
  48714. /**
  48715. * Creates a new device orientation camera
  48716. * @param name The name of the camera
  48717. * @param position The start position camera
  48718. * @param scene The scene the camera belongs to
  48719. */
  48720. constructor(name: string, position: Vector3, scene: Scene);
  48721. /**
  48722. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48723. */
  48724. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48725. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48726. private _dragFactor;
  48727. /**
  48728. * Enabled turning on the y axis when the orientation sensor is active
  48729. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  48730. */
  48731. enableHorizontalDragging(dragFactor?: number): void;
  48732. /**
  48733. * Gets the current instance class name ("DeviceOrientationCamera").
  48734. * This helps avoiding instanceof at run time.
  48735. * @returns the class name
  48736. */
  48737. getClassName(): string;
  48738. /**
  48739. * @hidden
  48740. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  48741. */
  48742. _checkInputs(): void;
  48743. /**
  48744. * Reset the camera to its default orientation on the specified axis only.
  48745. * @param axis The axis to reset
  48746. */
  48747. resetToCurrentRotation(axis?: Axis): void;
  48748. }
  48749. }
  48750. declare module BABYLON {
  48751. /**
  48752. * Defines supported buttons for XBox360 compatible gamepads
  48753. */
  48754. export enum Xbox360Button {
  48755. /** A */
  48756. A = 0,
  48757. /** B */
  48758. B = 1,
  48759. /** X */
  48760. X = 2,
  48761. /** Y */
  48762. Y = 3,
  48763. /** Left button */
  48764. LB = 4,
  48765. /** Right button */
  48766. RB = 5,
  48767. /** Back */
  48768. Back = 8,
  48769. /** Start */
  48770. Start = 9,
  48771. /** Left stick */
  48772. LeftStick = 10,
  48773. /** Right stick */
  48774. RightStick = 11
  48775. }
  48776. /** Defines values for XBox360 DPad */
  48777. export enum Xbox360Dpad {
  48778. /** Up */
  48779. Up = 12,
  48780. /** Down */
  48781. Down = 13,
  48782. /** Left */
  48783. Left = 14,
  48784. /** Right */
  48785. Right = 15
  48786. }
  48787. /**
  48788. * Defines a XBox360 gamepad
  48789. */
  48790. export class Xbox360Pad extends Gamepad {
  48791. private _leftTrigger;
  48792. private _rightTrigger;
  48793. private _onlefttriggerchanged;
  48794. private _onrighttriggerchanged;
  48795. private _onbuttondown;
  48796. private _onbuttonup;
  48797. private _ondpaddown;
  48798. private _ondpadup;
  48799. /** Observable raised when a button is pressed */
  48800. onButtonDownObservable: Observable<Xbox360Button>;
  48801. /** Observable raised when a button is released */
  48802. onButtonUpObservable: Observable<Xbox360Button>;
  48803. /** Observable raised when a pad is pressed */
  48804. onPadDownObservable: Observable<Xbox360Dpad>;
  48805. /** Observable raised when a pad is released */
  48806. onPadUpObservable: Observable<Xbox360Dpad>;
  48807. private _buttonA;
  48808. private _buttonB;
  48809. private _buttonX;
  48810. private _buttonY;
  48811. private _buttonBack;
  48812. private _buttonStart;
  48813. private _buttonLB;
  48814. private _buttonRB;
  48815. private _buttonLeftStick;
  48816. private _buttonRightStick;
  48817. private _dPadUp;
  48818. private _dPadDown;
  48819. private _dPadLeft;
  48820. private _dPadRight;
  48821. private _isXboxOnePad;
  48822. /**
  48823. * Creates a new XBox360 gamepad object
  48824. * @param id defines the id of this gamepad
  48825. * @param index defines its index
  48826. * @param gamepad defines the internal HTML gamepad object
  48827. * @param xboxOne defines if it is a XBox One gamepad
  48828. */
  48829. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  48830. /**
  48831. * Defines the callback to call when left trigger is pressed
  48832. * @param callback defines the callback to use
  48833. */
  48834. onlefttriggerchanged(callback: (value: number) => void): void;
  48835. /**
  48836. * Defines the callback to call when right trigger is pressed
  48837. * @param callback defines the callback to use
  48838. */
  48839. onrighttriggerchanged(callback: (value: number) => void): void;
  48840. /**
  48841. * Gets the left trigger value
  48842. */
  48843. get leftTrigger(): number;
  48844. /**
  48845. * Sets the left trigger value
  48846. */
  48847. set leftTrigger(newValue: number);
  48848. /**
  48849. * Gets the right trigger value
  48850. */
  48851. get rightTrigger(): number;
  48852. /**
  48853. * Sets the right trigger value
  48854. */
  48855. set rightTrigger(newValue: number);
  48856. /**
  48857. * Defines the callback to call when a button is pressed
  48858. * @param callback defines the callback to use
  48859. */
  48860. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  48861. /**
  48862. * Defines the callback to call when a button is released
  48863. * @param callback defines the callback to use
  48864. */
  48865. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  48866. /**
  48867. * Defines the callback to call when a pad is pressed
  48868. * @param callback defines the callback to use
  48869. */
  48870. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  48871. /**
  48872. * Defines the callback to call when a pad is released
  48873. * @param callback defines the callback to use
  48874. */
  48875. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  48876. private _setButtonValue;
  48877. private _setDPadValue;
  48878. /**
  48879. * Gets the value of the `A` button
  48880. */
  48881. get buttonA(): number;
  48882. /**
  48883. * Sets the value of the `A` button
  48884. */
  48885. set buttonA(value: number);
  48886. /**
  48887. * Gets the value of the `B` button
  48888. */
  48889. get buttonB(): number;
  48890. /**
  48891. * Sets the value of the `B` button
  48892. */
  48893. set buttonB(value: number);
  48894. /**
  48895. * Gets the value of the `X` button
  48896. */
  48897. get buttonX(): number;
  48898. /**
  48899. * Sets the value of the `X` button
  48900. */
  48901. set buttonX(value: number);
  48902. /**
  48903. * Gets the value of the `Y` button
  48904. */
  48905. get buttonY(): number;
  48906. /**
  48907. * Sets the value of the `Y` button
  48908. */
  48909. set buttonY(value: number);
  48910. /**
  48911. * Gets the value of the `Start` button
  48912. */
  48913. get buttonStart(): number;
  48914. /**
  48915. * Sets the value of the `Start` button
  48916. */
  48917. set buttonStart(value: number);
  48918. /**
  48919. * Gets the value of the `Back` button
  48920. */
  48921. get buttonBack(): number;
  48922. /**
  48923. * Sets the value of the `Back` button
  48924. */
  48925. set buttonBack(value: number);
  48926. /**
  48927. * Gets the value of the `Left` button
  48928. */
  48929. get buttonLB(): number;
  48930. /**
  48931. * Sets the value of the `Left` button
  48932. */
  48933. set buttonLB(value: number);
  48934. /**
  48935. * Gets the value of the `Right` button
  48936. */
  48937. get buttonRB(): number;
  48938. /**
  48939. * Sets the value of the `Right` button
  48940. */
  48941. set buttonRB(value: number);
  48942. /**
  48943. * Gets the value of the Left joystick
  48944. */
  48945. get buttonLeftStick(): number;
  48946. /**
  48947. * Sets the value of the Left joystick
  48948. */
  48949. set buttonLeftStick(value: number);
  48950. /**
  48951. * Gets the value of the Right joystick
  48952. */
  48953. get buttonRightStick(): number;
  48954. /**
  48955. * Sets the value of the Right joystick
  48956. */
  48957. set buttonRightStick(value: number);
  48958. /**
  48959. * Gets the value of D-pad up
  48960. */
  48961. get dPadUp(): number;
  48962. /**
  48963. * Sets the value of D-pad up
  48964. */
  48965. set dPadUp(value: number);
  48966. /**
  48967. * Gets the value of D-pad down
  48968. */
  48969. get dPadDown(): number;
  48970. /**
  48971. * Sets the value of D-pad down
  48972. */
  48973. set dPadDown(value: number);
  48974. /**
  48975. * Gets the value of D-pad left
  48976. */
  48977. get dPadLeft(): number;
  48978. /**
  48979. * Sets the value of D-pad left
  48980. */
  48981. set dPadLeft(value: number);
  48982. /**
  48983. * Gets the value of D-pad right
  48984. */
  48985. get dPadRight(): number;
  48986. /**
  48987. * Sets the value of D-pad right
  48988. */
  48989. set dPadRight(value: number);
  48990. /**
  48991. * Force the gamepad to synchronize with device values
  48992. */
  48993. update(): void;
  48994. /**
  48995. * Disposes the gamepad
  48996. */
  48997. dispose(): void;
  48998. }
  48999. }
  49000. declare module BABYLON {
  49001. /**
  49002. * Defines supported buttons for DualShock compatible gamepads
  49003. */
  49004. export enum DualShockButton {
  49005. /** Cross */
  49006. Cross = 0,
  49007. /** Circle */
  49008. Circle = 1,
  49009. /** Square */
  49010. Square = 2,
  49011. /** Triangle */
  49012. Triangle = 3,
  49013. /** L1 */
  49014. L1 = 4,
  49015. /** R1 */
  49016. R1 = 5,
  49017. /** Share */
  49018. Share = 8,
  49019. /** Options */
  49020. Options = 9,
  49021. /** Left stick */
  49022. LeftStick = 10,
  49023. /** Right stick */
  49024. RightStick = 11
  49025. }
  49026. /** Defines values for DualShock DPad */
  49027. export enum DualShockDpad {
  49028. /** Up */
  49029. Up = 12,
  49030. /** Down */
  49031. Down = 13,
  49032. /** Left */
  49033. Left = 14,
  49034. /** Right */
  49035. Right = 15
  49036. }
  49037. /**
  49038. * Defines a DualShock gamepad
  49039. */
  49040. export class DualShockPad extends Gamepad {
  49041. private _leftTrigger;
  49042. private _rightTrigger;
  49043. private _onlefttriggerchanged;
  49044. private _onrighttriggerchanged;
  49045. private _onbuttondown;
  49046. private _onbuttonup;
  49047. private _ondpaddown;
  49048. private _ondpadup;
  49049. /** Observable raised when a button is pressed */
  49050. onButtonDownObservable: Observable<DualShockButton>;
  49051. /** Observable raised when a button is released */
  49052. onButtonUpObservable: Observable<DualShockButton>;
  49053. /** Observable raised when a pad is pressed */
  49054. onPadDownObservable: Observable<DualShockDpad>;
  49055. /** Observable raised when a pad is released */
  49056. onPadUpObservable: Observable<DualShockDpad>;
  49057. private _buttonCross;
  49058. private _buttonCircle;
  49059. private _buttonSquare;
  49060. private _buttonTriangle;
  49061. private _buttonShare;
  49062. private _buttonOptions;
  49063. private _buttonL1;
  49064. private _buttonR1;
  49065. private _buttonLeftStick;
  49066. private _buttonRightStick;
  49067. private _dPadUp;
  49068. private _dPadDown;
  49069. private _dPadLeft;
  49070. private _dPadRight;
  49071. /**
  49072. * Creates a new DualShock gamepad object
  49073. * @param id defines the id of this gamepad
  49074. * @param index defines its index
  49075. * @param gamepad defines the internal HTML gamepad object
  49076. */
  49077. constructor(id: string, index: number, gamepad: any);
  49078. /**
  49079. * Defines the callback to call when left trigger is pressed
  49080. * @param callback defines the callback to use
  49081. */
  49082. onlefttriggerchanged(callback: (value: number) => void): void;
  49083. /**
  49084. * Defines the callback to call when right trigger is pressed
  49085. * @param callback defines the callback to use
  49086. */
  49087. onrighttriggerchanged(callback: (value: number) => void): void;
  49088. /**
  49089. * Gets the left trigger value
  49090. */
  49091. get leftTrigger(): number;
  49092. /**
  49093. * Sets the left trigger value
  49094. */
  49095. set leftTrigger(newValue: number);
  49096. /**
  49097. * Gets the right trigger value
  49098. */
  49099. get rightTrigger(): number;
  49100. /**
  49101. * Sets the right trigger value
  49102. */
  49103. set rightTrigger(newValue: number);
  49104. /**
  49105. * Defines the callback to call when a button is pressed
  49106. * @param callback defines the callback to use
  49107. */
  49108. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49109. /**
  49110. * Defines the callback to call when a button is released
  49111. * @param callback defines the callback to use
  49112. */
  49113. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49114. /**
  49115. * Defines the callback to call when a pad is pressed
  49116. * @param callback defines the callback to use
  49117. */
  49118. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49119. /**
  49120. * Defines the callback to call when a pad is released
  49121. * @param callback defines the callback to use
  49122. */
  49123. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49124. private _setButtonValue;
  49125. private _setDPadValue;
  49126. /**
  49127. * Gets the value of the `Cross` button
  49128. */
  49129. get buttonCross(): number;
  49130. /**
  49131. * Sets the value of the `Cross` button
  49132. */
  49133. set buttonCross(value: number);
  49134. /**
  49135. * Gets the value of the `Circle` button
  49136. */
  49137. get buttonCircle(): number;
  49138. /**
  49139. * Sets the value of the `Circle` button
  49140. */
  49141. set buttonCircle(value: number);
  49142. /**
  49143. * Gets the value of the `Square` button
  49144. */
  49145. get buttonSquare(): number;
  49146. /**
  49147. * Sets the value of the `Square` button
  49148. */
  49149. set buttonSquare(value: number);
  49150. /**
  49151. * Gets the value of the `Triangle` button
  49152. */
  49153. get buttonTriangle(): number;
  49154. /**
  49155. * Sets the value of the `Triangle` button
  49156. */
  49157. set buttonTriangle(value: number);
  49158. /**
  49159. * Gets the value of the `Options` button
  49160. */
  49161. get buttonOptions(): number;
  49162. /**
  49163. * Sets the value of the `Options` button
  49164. */
  49165. set buttonOptions(value: number);
  49166. /**
  49167. * Gets the value of the `Share` button
  49168. */
  49169. get buttonShare(): number;
  49170. /**
  49171. * Sets the value of the `Share` button
  49172. */
  49173. set buttonShare(value: number);
  49174. /**
  49175. * Gets the value of the `L1` button
  49176. */
  49177. get buttonL1(): number;
  49178. /**
  49179. * Sets the value of the `L1` button
  49180. */
  49181. set buttonL1(value: number);
  49182. /**
  49183. * Gets the value of the `R1` button
  49184. */
  49185. get buttonR1(): number;
  49186. /**
  49187. * Sets the value of the `R1` button
  49188. */
  49189. set buttonR1(value: number);
  49190. /**
  49191. * Gets the value of the Left joystick
  49192. */
  49193. get buttonLeftStick(): number;
  49194. /**
  49195. * Sets the value of the Left joystick
  49196. */
  49197. set buttonLeftStick(value: number);
  49198. /**
  49199. * Gets the value of the Right joystick
  49200. */
  49201. get buttonRightStick(): number;
  49202. /**
  49203. * Sets the value of the Right joystick
  49204. */
  49205. set buttonRightStick(value: number);
  49206. /**
  49207. * Gets the value of D-pad up
  49208. */
  49209. get dPadUp(): number;
  49210. /**
  49211. * Sets the value of D-pad up
  49212. */
  49213. set dPadUp(value: number);
  49214. /**
  49215. * Gets the value of D-pad down
  49216. */
  49217. get dPadDown(): number;
  49218. /**
  49219. * Sets the value of D-pad down
  49220. */
  49221. set dPadDown(value: number);
  49222. /**
  49223. * Gets the value of D-pad left
  49224. */
  49225. get dPadLeft(): number;
  49226. /**
  49227. * Sets the value of D-pad left
  49228. */
  49229. set dPadLeft(value: number);
  49230. /**
  49231. * Gets the value of D-pad right
  49232. */
  49233. get dPadRight(): number;
  49234. /**
  49235. * Sets the value of D-pad right
  49236. */
  49237. set dPadRight(value: number);
  49238. /**
  49239. * Force the gamepad to synchronize with device values
  49240. */
  49241. update(): void;
  49242. /**
  49243. * Disposes the gamepad
  49244. */
  49245. dispose(): void;
  49246. }
  49247. }
  49248. declare module BABYLON {
  49249. /**
  49250. * Manager for handling gamepads
  49251. */
  49252. export class GamepadManager {
  49253. private _scene?;
  49254. private _babylonGamepads;
  49255. private _oneGamepadConnected;
  49256. /** @hidden */
  49257. _isMonitoring: boolean;
  49258. private _gamepadEventSupported;
  49259. private _gamepadSupport?;
  49260. /**
  49261. * observable to be triggered when the gamepad controller has been connected
  49262. */
  49263. onGamepadConnectedObservable: Observable<Gamepad>;
  49264. /**
  49265. * observable to be triggered when the gamepad controller has been disconnected
  49266. */
  49267. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49268. private _onGamepadConnectedEvent;
  49269. private _onGamepadDisconnectedEvent;
  49270. /**
  49271. * Initializes the gamepad manager
  49272. * @param _scene BabylonJS scene
  49273. */
  49274. constructor(_scene?: Scene | undefined);
  49275. /**
  49276. * The gamepads in the game pad manager
  49277. */
  49278. get gamepads(): Gamepad[];
  49279. /**
  49280. * Get the gamepad controllers based on type
  49281. * @param type The type of gamepad controller
  49282. * @returns Nullable gamepad
  49283. */
  49284. getGamepadByType(type?: number): Nullable<Gamepad>;
  49285. /**
  49286. * Disposes the gamepad manager
  49287. */
  49288. dispose(): void;
  49289. private _addNewGamepad;
  49290. private _startMonitoringGamepads;
  49291. private _stopMonitoringGamepads;
  49292. /** @hidden */
  49293. _checkGamepadsStatus(): void;
  49294. private _updateGamepadObjects;
  49295. }
  49296. }
  49297. declare module BABYLON {
  49298. interface Scene {
  49299. /** @hidden */
  49300. _gamepadManager: Nullable<GamepadManager>;
  49301. /**
  49302. * Gets the gamepad manager associated with the scene
  49303. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49304. */
  49305. gamepadManager: GamepadManager;
  49306. }
  49307. /**
  49308. * Interface representing a free camera inputs manager
  49309. */
  49310. interface FreeCameraInputsManager {
  49311. /**
  49312. * Adds gamepad input support to the FreeCameraInputsManager.
  49313. * @returns the FreeCameraInputsManager
  49314. */
  49315. addGamepad(): FreeCameraInputsManager;
  49316. }
  49317. /**
  49318. * Interface representing an arc rotate camera inputs manager
  49319. */
  49320. interface ArcRotateCameraInputsManager {
  49321. /**
  49322. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49323. * @returns the camera inputs manager
  49324. */
  49325. addGamepad(): ArcRotateCameraInputsManager;
  49326. }
  49327. /**
  49328. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49329. */
  49330. export class GamepadSystemSceneComponent implements ISceneComponent {
  49331. /**
  49332. * The component name helpfull to identify the component in the list of scene components.
  49333. */
  49334. readonly name: string;
  49335. /**
  49336. * The scene the component belongs to.
  49337. */
  49338. scene: Scene;
  49339. /**
  49340. * Creates a new instance of the component for the given scene
  49341. * @param scene Defines the scene to register the component in
  49342. */
  49343. constructor(scene: Scene);
  49344. /**
  49345. * Registers the component in a given scene
  49346. */
  49347. register(): void;
  49348. /**
  49349. * Rebuilds the elements related to this component in case of
  49350. * context lost for instance.
  49351. */
  49352. rebuild(): void;
  49353. /**
  49354. * Disposes the component and the associated ressources
  49355. */
  49356. dispose(): void;
  49357. private _beforeCameraUpdate;
  49358. }
  49359. }
  49360. declare module BABYLON {
  49361. /**
  49362. * 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,
  49363. * which still works and will still be found in many Playgrounds.
  49364. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49365. */
  49366. export class UniversalCamera extends TouchCamera {
  49367. /**
  49368. * Defines the gamepad rotation sensiblity.
  49369. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49370. */
  49371. get gamepadAngularSensibility(): number;
  49372. set gamepadAngularSensibility(value: number);
  49373. /**
  49374. * Defines the gamepad move sensiblity.
  49375. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49376. */
  49377. get gamepadMoveSensibility(): number;
  49378. set gamepadMoveSensibility(value: number);
  49379. /**
  49380. * 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,
  49381. * which still works and will still be found in many Playgrounds.
  49382. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49383. * @param name Define the name of the camera in the scene
  49384. * @param position Define the start position of the camera in the scene
  49385. * @param scene Define the scene the camera belongs to
  49386. */
  49387. constructor(name: string, position: Vector3, scene: Scene);
  49388. /**
  49389. * Gets the current object class name.
  49390. * @return the class name
  49391. */
  49392. getClassName(): string;
  49393. }
  49394. }
  49395. declare module BABYLON {
  49396. /**
  49397. * This represents a FPS type of camera. This is only here for back compat purpose.
  49398. * Please use the UniversalCamera instead as both are identical.
  49399. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49400. */
  49401. export class GamepadCamera extends UniversalCamera {
  49402. /**
  49403. * Instantiates a new Gamepad Camera
  49404. * This represents a FPS type of camera. This is only here for back compat purpose.
  49405. * Please use the UniversalCamera instead as both are identical.
  49406. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49407. * @param name Define the name of the camera in the scene
  49408. * @param position Define the start position of the camera in the scene
  49409. * @param scene Define the scene the camera belongs to
  49410. */
  49411. constructor(name: string, position: Vector3, scene: Scene);
  49412. /**
  49413. * Gets the current object class name.
  49414. * @return the class name
  49415. */
  49416. getClassName(): string;
  49417. }
  49418. }
  49419. declare module BABYLON {
  49420. /** @hidden */
  49421. export var passPixelShader: {
  49422. name: string;
  49423. shader: string;
  49424. };
  49425. }
  49426. declare module BABYLON {
  49427. /** @hidden */
  49428. export var passCubePixelShader: {
  49429. name: string;
  49430. shader: string;
  49431. };
  49432. }
  49433. declare module BABYLON {
  49434. /**
  49435. * PassPostProcess which produces an output the same as it's input
  49436. */
  49437. export class PassPostProcess extends PostProcess {
  49438. /**
  49439. * Gets a string identifying the name of the class
  49440. * @returns "PassPostProcess" string
  49441. */
  49442. getClassName(): string;
  49443. /**
  49444. * Creates the PassPostProcess
  49445. * @param name The name of the effect.
  49446. * @param options The required width/height ratio to downsize to before computing the render pass.
  49447. * @param camera The camera to apply the render pass to.
  49448. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49449. * @param engine The engine which the post process will be applied. (default: current engine)
  49450. * @param reusable If the post process can be reused on the same frame. (default: false)
  49451. * @param textureType The type of texture to be used when performing the post processing.
  49452. * @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)
  49453. */
  49454. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49455. /** @hidden */
  49456. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49457. }
  49458. /**
  49459. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49460. */
  49461. export class PassCubePostProcess extends PostProcess {
  49462. private _face;
  49463. /**
  49464. * Gets or sets the cube face to display.
  49465. * * 0 is +X
  49466. * * 1 is -X
  49467. * * 2 is +Y
  49468. * * 3 is -Y
  49469. * * 4 is +Z
  49470. * * 5 is -Z
  49471. */
  49472. get face(): number;
  49473. set face(value: number);
  49474. /**
  49475. * Gets a string identifying the name of the class
  49476. * @returns "PassCubePostProcess" string
  49477. */
  49478. getClassName(): string;
  49479. /**
  49480. * Creates the PassCubePostProcess
  49481. * @param name The name of the effect.
  49482. * @param options The required width/height ratio to downsize to before computing the render pass.
  49483. * @param camera The camera to apply the render pass to.
  49484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49485. * @param engine The engine which the post process will be applied. (default: current engine)
  49486. * @param reusable If the post process can be reused on the same frame. (default: false)
  49487. * @param textureType The type of texture to be used when performing the post processing.
  49488. * @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)
  49489. */
  49490. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49491. /** @hidden */
  49492. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49493. }
  49494. }
  49495. declare module BABYLON {
  49496. /** @hidden */
  49497. export var anaglyphPixelShader: {
  49498. name: string;
  49499. shader: string;
  49500. };
  49501. }
  49502. declare module BABYLON {
  49503. /**
  49504. * Postprocess used to generate anaglyphic rendering
  49505. */
  49506. export class AnaglyphPostProcess extends PostProcess {
  49507. private _passedProcess;
  49508. /**
  49509. * Gets a string identifying the name of the class
  49510. * @returns "AnaglyphPostProcess" string
  49511. */
  49512. getClassName(): string;
  49513. /**
  49514. * Creates a new AnaglyphPostProcess
  49515. * @param name defines postprocess name
  49516. * @param options defines creation options or target ratio scale
  49517. * @param rigCameras defines cameras using this postprocess
  49518. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49519. * @param engine defines hosting engine
  49520. * @param reusable defines if the postprocess will be reused multiple times per frame
  49521. */
  49522. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49523. }
  49524. }
  49525. declare module BABYLON {
  49526. /**
  49527. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49528. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49529. */
  49530. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49531. /**
  49532. * Creates a new AnaglyphArcRotateCamera
  49533. * @param name defines camera name
  49534. * @param alpha defines alpha angle (in radians)
  49535. * @param beta defines beta angle (in radians)
  49536. * @param radius defines radius
  49537. * @param target defines camera target
  49538. * @param interaxialDistance defines distance between each color axis
  49539. * @param scene defines the hosting scene
  49540. */
  49541. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49542. /**
  49543. * Gets camera class name
  49544. * @returns AnaglyphArcRotateCamera
  49545. */
  49546. getClassName(): string;
  49547. }
  49548. }
  49549. declare module BABYLON {
  49550. /**
  49551. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49552. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49553. */
  49554. export class AnaglyphFreeCamera extends FreeCamera {
  49555. /**
  49556. * Creates a new AnaglyphFreeCamera
  49557. * @param name defines camera name
  49558. * @param position defines initial position
  49559. * @param interaxialDistance defines distance between each color axis
  49560. * @param scene defines the hosting scene
  49561. */
  49562. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49563. /**
  49564. * Gets camera class name
  49565. * @returns AnaglyphFreeCamera
  49566. */
  49567. getClassName(): string;
  49568. }
  49569. }
  49570. declare module BABYLON {
  49571. /**
  49572. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49573. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49574. */
  49575. export class AnaglyphGamepadCamera extends GamepadCamera {
  49576. /**
  49577. * Creates a new AnaglyphGamepadCamera
  49578. * @param name defines camera name
  49579. * @param position defines initial position
  49580. * @param interaxialDistance defines distance between each color axis
  49581. * @param scene defines the hosting scene
  49582. */
  49583. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49584. /**
  49585. * Gets camera class name
  49586. * @returns AnaglyphGamepadCamera
  49587. */
  49588. getClassName(): string;
  49589. }
  49590. }
  49591. declare module BABYLON {
  49592. /**
  49593. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49594. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49595. */
  49596. export class AnaglyphUniversalCamera extends UniversalCamera {
  49597. /**
  49598. * Creates a new AnaglyphUniversalCamera
  49599. * @param name defines camera name
  49600. * @param position defines initial position
  49601. * @param interaxialDistance defines distance between each color axis
  49602. * @param scene defines the hosting scene
  49603. */
  49604. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49605. /**
  49606. * Gets camera class name
  49607. * @returns AnaglyphUniversalCamera
  49608. */
  49609. getClassName(): string;
  49610. }
  49611. }
  49612. declare module BABYLON {
  49613. /**
  49614. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49615. * @see https://doc.babylonjs.com/features/cameras
  49616. */
  49617. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49618. /**
  49619. * Creates a new StereoscopicArcRotateCamera
  49620. * @param name defines camera name
  49621. * @param alpha defines alpha angle (in radians)
  49622. * @param beta defines beta angle (in radians)
  49623. * @param radius defines radius
  49624. * @param target defines camera target
  49625. * @param interaxialDistance defines distance between each color axis
  49626. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49627. * @param scene defines the hosting scene
  49628. */
  49629. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49630. /**
  49631. * Gets camera class name
  49632. * @returns StereoscopicArcRotateCamera
  49633. */
  49634. getClassName(): string;
  49635. }
  49636. }
  49637. declare module BABYLON {
  49638. /**
  49639. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49640. * @see https://doc.babylonjs.com/features/cameras
  49641. */
  49642. export class StereoscopicFreeCamera extends FreeCamera {
  49643. /**
  49644. * Creates a new StereoscopicFreeCamera
  49645. * @param name defines camera name
  49646. * @param position defines initial position
  49647. * @param interaxialDistance defines distance between each color axis
  49648. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49649. * @param scene defines the hosting scene
  49650. */
  49651. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49652. /**
  49653. * Gets camera class name
  49654. * @returns StereoscopicFreeCamera
  49655. */
  49656. getClassName(): string;
  49657. }
  49658. }
  49659. declare module BABYLON {
  49660. /**
  49661. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49662. * @see https://doc.babylonjs.com/features/cameras
  49663. */
  49664. export class StereoscopicGamepadCamera extends GamepadCamera {
  49665. /**
  49666. * Creates a new StereoscopicGamepadCamera
  49667. * @param name defines camera name
  49668. * @param position defines initial position
  49669. * @param interaxialDistance defines distance between each color axis
  49670. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49671. * @param scene defines the hosting scene
  49672. */
  49673. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49674. /**
  49675. * Gets camera class name
  49676. * @returns StereoscopicGamepadCamera
  49677. */
  49678. getClassName(): string;
  49679. }
  49680. }
  49681. declare module BABYLON {
  49682. /**
  49683. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49684. * @see https://doc.babylonjs.com/features/cameras
  49685. */
  49686. export class StereoscopicUniversalCamera extends UniversalCamera {
  49687. /**
  49688. * Creates a new StereoscopicUniversalCamera
  49689. * @param name defines camera name
  49690. * @param position defines initial position
  49691. * @param interaxialDistance defines distance between each color axis
  49692. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49693. * @param scene defines the hosting scene
  49694. */
  49695. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49696. /**
  49697. * Gets camera class name
  49698. * @returns StereoscopicUniversalCamera
  49699. */
  49700. getClassName(): string;
  49701. }
  49702. }
  49703. declare module BABYLON {
  49704. /**
  49705. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49706. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49707. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49708. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49709. */
  49710. export class VirtualJoysticksCamera extends FreeCamera {
  49711. /**
  49712. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49713. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49714. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49715. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49716. * @param name Define the name of the camera in the scene
  49717. * @param position Define the start position of the camera in the scene
  49718. * @param scene Define the scene the camera belongs to
  49719. */
  49720. constructor(name: string, position: Vector3, scene: Scene);
  49721. /**
  49722. * Gets the current object class name.
  49723. * @return the class name
  49724. */
  49725. getClassName(): string;
  49726. }
  49727. }
  49728. declare module BABYLON {
  49729. /**
  49730. * This represents all the required metrics to create a VR camera.
  49731. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  49732. */
  49733. export class VRCameraMetrics {
  49734. /**
  49735. * Define the horizontal resolution off the screen.
  49736. */
  49737. hResolution: number;
  49738. /**
  49739. * Define the vertical resolution off the screen.
  49740. */
  49741. vResolution: number;
  49742. /**
  49743. * Define the horizontal screen size.
  49744. */
  49745. hScreenSize: number;
  49746. /**
  49747. * Define the vertical screen size.
  49748. */
  49749. vScreenSize: number;
  49750. /**
  49751. * Define the vertical screen center position.
  49752. */
  49753. vScreenCenter: number;
  49754. /**
  49755. * Define the distance of the eyes to the screen.
  49756. */
  49757. eyeToScreenDistance: number;
  49758. /**
  49759. * Define the distance between both lenses
  49760. */
  49761. lensSeparationDistance: number;
  49762. /**
  49763. * Define the distance between both viewer's eyes.
  49764. */
  49765. interpupillaryDistance: number;
  49766. /**
  49767. * Define the distortion factor of the VR postprocess.
  49768. * Please, touch with care.
  49769. */
  49770. distortionK: number[];
  49771. /**
  49772. * Define the chromatic aberration correction factors for the VR post process.
  49773. */
  49774. chromaAbCorrection: number[];
  49775. /**
  49776. * Define the scale factor of the post process.
  49777. * The smaller the better but the slower.
  49778. */
  49779. postProcessScaleFactor: number;
  49780. /**
  49781. * Define an offset for the lens center.
  49782. */
  49783. lensCenterOffset: number;
  49784. /**
  49785. * Define if the current vr camera should compensate the distortion of the lense or not.
  49786. */
  49787. compensateDistortion: boolean;
  49788. /**
  49789. * Defines if multiview should be enabled when rendering (Default: false)
  49790. */
  49791. multiviewEnabled: boolean;
  49792. /**
  49793. * Gets the rendering aspect ratio based on the provided resolutions.
  49794. */
  49795. get aspectRatio(): number;
  49796. /**
  49797. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  49798. */
  49799. get aspectRatioFov(): number;
  49800. /**
  49801. * @hidden
  49802. */
  49803. get leftHMatrix(): Matrix;
  49804. /**
  49805. * @hidden
  49806. */
  49807. get rightHMatrix(): Matrix;
  49808. /**
  49809. * @hidden
  49810. */
  49811. get leftPreViewMatrix(): Matrix;
  49812. /**
  49813. * @hidden
  49814. */
  49815. get rightPreViewMatrix(): Matrix;
  49816. /**
  49817. * Get the default VRMetrics based on the most generic setup.
  49818. * @returns the default vr metrics
  49819. */
  49820. static GetDefault(): VRCameraMetrics;
  49821. }
  49822. }
  49823. declare module BABYLON {
  49824. /** @hidden */
  49825. export var vrDistortionCorrectionPixelShader: {
  49826. name: string;
  49827. shader: string;
  49828. };
  49829. }
  49830. declare module BABYLON {
  49831. /**
  49832. * VRDistortionCorrectionPostProcess used for mobile VR
  49833. */
  49834. export class VRDistortionCorrectionPostProcess extends PostProcess {
  49835. private _isRightEye;
  49836. private _distortionFactors;
  49837. private _postProcessScaleFactor;
  49838. private _lensCenterOffset;
  49839. private _scaleIn;
  49840. private _scaleFactor;
  49841. private _lensCenter;
  49842. /**
  49843. * Gets a string identifying the name of the class
  49844. * @returns "VRDistortionCorrectionPostProcess" string
  49845. */
  49846. getClassName(): string;
  49847. /**
  49848. * Initializes the VRDistortionCorrectionPostProcess
  49849. * @param name The name of the effect.
  49850. * @param camera The camera to apply the render pass to.
  49851. * @param isRightEye If this is for the right eye distortion
  49852. * @param vrMetrics All the required metrics for the VR camera
  49853. */
  49854. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  49855. }
  49856. }
  49857. declare module BABYLON {
  49858. /**
  49859. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  49860. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49861. */
  49862. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  49863. /**
  49864. * Creates a new VRDeviceOrientationArcRotateCamera
  49865. * @param name defines camera name
  49866. * @param alpha defines the camera rotation along the logitudinal axis
  49867. * @param beta defines the camera rotation along the latitudinal axis
  49868. * @param radius defines the camera distance from its target
  49869. * @param target defines the camera target
  49870. * @param scene defines the scene the camera belongs to
  49871. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49872. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49873. */
  49874. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49875. /**
  49876. * Gets camera class name
  49877. * @returns VRDeviceOrientationArcRotateCamera
  49878. */
  49879. getClassName(): string;
  49880. }
  49881. }
  49882. declare module BABYLON {
  49883. /**
  49884. * Camera used to simulate VR rendering (based on FreeCamera)
  49885. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49886. */
  49887. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  49888. /**
  49889. * Creates a new VRDeviceOrientationFreeCamera
  49890. * @param name defines camera name
  49891. * @param position defines the start position of the camera
  49892. * @param scene defines the scene the camera belongs to
  49893. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49894. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49895. */
  49896. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49897. /**
  49898. * Gets camera class name
  49899. * @returns VRDeviceOrientationFreeCamera
  49900. */
  49901. getClassName(): string;
  49902. }
  49903. }
  49904. declare module BABYLON {
  49905. /**
  49906. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  49907. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49908. */
  49909. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  49910. /**
  49911. * Creates a new VRDeviceOrientationGamepadCamera
  49912. * @param name defines camera name
  49913. * @param position defines the start position of the camera
  49914. * @param scene defines the scene the camera belongs to
  49915. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49916. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49917. */
  49918. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49919. /**
  49920. * Gets camera class name
  49921. * @returns VRDeviceOrientationGamepadCamera
  49922. */
  49923. getClassName(): string;
  49924. }
  49925. }
  49926. declare module BABYLON {
  49927. /**
  49928. * A class extending Texture allowing drawing on a texture
  49929. * @see https://doc.babylonjs.com/how_to/dynamictexture
  49930. */
  49931. export class DynamicTexture extends Texture {
  49932. private _generateMipMaps;
  49933. private _canvas;
  49934. private _context;
  49935. /**
  49936. * Creates a DynamicTexture
  49937. * @param name defines the name of the texture
  49938. * @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
  49939. * @param scene defines the scene where you want the texture
  49940. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  49941. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  49942. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  49943. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  49944. */
  49945. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  49946. /**
  49947. * Get the current class name of the texture useful for serialization or dynamic coding.
  49948. * @returns "DynamicTexture"
  49949. */
  49950. getClassName(): string;
  49951. /**
  49952. * Gets the current state of canRescale
  49953. */
  49954. get canRescale(): boolean;
  49955. private _recreate;
  49956. /**
  49957. * Scales the texture
  49958. * @param ratio the scale factor to apply to both width and height
  49959. */
  49960. scale(ratio: number): void;
  49961. /**
  49962. * Resizes the texture
  49963. * @param width the new width
  49964. * @param height the new height
  49965. */
  49966. scaleTo(width: number, height: number): void;
  49967. /**
  49968. * Gets the context of the canvas used by the texture
  49969. * @returns the canvas context of the dynamic texture
  49970. */
  49971. getContext(): CanvasRenderingContext2D;
  49972. /**
  49973. * Clears the texture
  49974. */
  49975. clear(): void;
  49976. /**
  49977. * Updates the texture
  49978. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49979. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  49980. */
  49981. update(invertY?: boolean, premulAlpha?: boolean): void;
  49982. /**
  49983. * Draws text onto the texture
  49984. * @param text defines the text to be drawn
  49985. * @param x defines the placement of the text from the left
  49986. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  49987. * @param font defines the font to be used with font-style, font-size, font-name
  49988. * @param color defines the color used for the text
  49989. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  49990. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49991. * @param update defines whether texture is immediately update (default is true)
  49992. */
  49993. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  49994. /**
  49995. * Clones the texture
  49996. * @returns the clone of the texture.
  49997. */
  49998. clone(): DynamicTexture;
  49999. /**
  50000. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  50001. * @returns a serialized dynamic texture object
  50002. */
  50003. serialize(): any;
  50004. private _IsCanvasElement;
  50005. /** @hidden */
  50006. _rebuild(): void;
  50007. }
  50008. }
  50009. declare module BABYLON {
  50010. /**
  50011. * Class containing static functions to help procedurally build meshes
  50012. */
  50013. export class GroundBuilder {
  50014. /**
  50015. * Creates a ground mesh
  50016. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50017. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50019. * @param name defines the name of the mesh
  50020. * @param options defines the options used to create the mesh
  50021. * @param scene defines the hosting scene
  50022. * @returns the ground mesh
  50023. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50024. */
  50025. static CreateGround(name: string, options: {
  50026. width?: number;
  50027. height?: number;
  50028. subdivisions?: number;
  50029. subdivisionsX?: number;
  50030. subdivisionsY?: number;
  50031. updatable?: boolean;
  50032. }, scene: any): Mesh;
  50033. /**
  50034. * Creates a tiled ground mesh
  50035. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50036. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50037. * * 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
  50038. * * 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
  50039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50040. * @param name defines the name of the mesh
  50041. * @param options defines the options used to create the mesh
  50042. * @param scene defines the hosting scene
  50043. * @returns the tiled ground mesh
  50044. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50045. */
  50046. static CreateTiledGround(name: string, options: {
  50047. xmin: number;
  50048. zmin: number;
  50049. xmax: number;
  50050. zmax: number;
  50051. subdivisions?: {
  50052. w: number;
  50053. h: number;
  50054. };
  50055. precision?: {
  50056. w: number;
  50057. h: number;
  50058. };
  50059. updatable?: boolean;
  50060. }, scene?: Nullable<Scene>): Mesh;
  50061. /**
  50062. * Creates a ground mesh from a height map
  50063. * * The parameter `url` sets the URL of the height map image resource.
  50064. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50065. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50066. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50067. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50068. * * 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.
  50069. * * 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).
  50070. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50072. * @param name defines the name of the mesh
  50073. * @param url defines the url to the height map
  50074. * @param options defines the options used to create the mesh
  50075. * @param scene defines the hosting scene
  50076. * @returns the ground mesh
  50077. * @see https://doc.babylonjs.com/babylon101/height_map
  50078. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50079. */
  50080. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50081. width?: number;
  50082. height?: number;
  50083. subdivisions?: number;
  50084. minHeight?: number;
  50085. maxHeight?: number;
  50086. colorFilter?: Color3;
  50087. alphaFilter?: number;
  50088. updatable?: boolean;
  50089. onReady?: (mesh: GroundMesh) => void;
  50090. }, scene?: Nullable<Scene>): GroundMesh;
  50091. }
  50092. }
  50093. declare module BABYLON {
  50094. /**
  50095. * Class containing static functions to help procedurally build meshes
  50096. */
  50097. export class TorusBuilder {
  50098. /**
  50099. * Creates a torus mesh
  50100. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50101. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50102. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50104. * * 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
  50105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50106. * @param name defines the name of the mesh
  50107. * @param options defines the options used to create the mesh
  50108. * @param scene defines the hosting scene
  50109. * @returns the torus mesh
  50110. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50111. */
  50112. static CreateTorus(name: string, options: {
  50113. diameter?: number;
  50114. thickness?: number;
  50115. tessellation?: number;
  50116. updatable?: boolean;
  50117. sideOrientation?: number;
  50118. frontUVs?: Vector4;
  50119. backUVs?: Vector4;
  50120. }, scene: any): Mesh;
  50121. }
  50122. }
  50123. declare module BABYLON {
  50124. /**
  50125. * Class containing static functions to help procedurally build meshes
  50126. */
  50127. export class CylinderBuilder {
  50128. /**
  50129. * Creates a cylinder or a cone mesh
  50130. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50131. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50132. * * 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.
  50133. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50134. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50135. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50136. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50137. * * 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).
  50138. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50139. * * 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).
  50140. * * 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
  50141. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50142. * * 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
  50143. * * 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.
  50144. * * If `enclose` is false, a ring surface is one element.
  50145. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50146. * * 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
  50147. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50148. * * 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
  50149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50150. * @param name defines the name of the mesh
  50151. * @param options defines the options used to create the mesh
  50152. * @param scene defines the hosting scene
  50153. * @returns the cylinder mesh
  50154. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50155. */
  50156. static CreateCylinder(name: string, options: {
  50157. height?: number;
  50158. diameterTop?: number;
  50159. diameterBottom?: number;
  50160. diameter?: number;
  50161. tessellation?: number;
  50162. subdivisions?: number;
  50163. arc?: number;
  50164. faceColors?: Color4[];
  50165. faceUV?: Vector4[];
  50166. updatable?: boolean;
  50167. hasRings?: boolean;
  50168. enclose?: boolean;
  50169. cap?: number;
  50170. sideOrientation?: number;
  50171. frontUVs?: Vector4;
  50172. backUVs?: Vector4;
  50173. }, scene: any): Mesh;
  50174. }
  50175. }
  50176. declare module BABYLON {
  50177. /**
  50178. * States of the webXR experience
  50179. */
  50180. export enum WebXRState {
  50181. /**
  50182. * Transitioning to being in XR mode
  50183. */
  50184. ENTERING_XR = 0,
  50185. /**
  50186. * Transitioning to non XR mode
  50187. */
  50188. EXITING_XR = 1,
  50189. /**
  50190. * In XR mode and presenting
  50191. */
  50192. IN_XR = 2,
  50193. /**
  50194. * Not entered XR mode
  50195. */
  50196. NOT_IN_XR = 3
  50197. }
  50198. /**
  50199. * The state of the XR camera's tracking
  50200. */
  50201. export enum WebXRTrackingState {
  50202. /**
  50203. * No transformation received, device is not being tracked
  50204. */
  50205. NOT_TRACKING = 0,
  50206. /**
  50207. * Tracking lost - using emulated position
  50208. */
  50209. TRACKING_LOST = 1,
  50210. /**
  50211. * Transformation tracking works normally
  50212. */
  50213. TRACKING = 2
  50214. }
  50215. /**
  50216. * Abstraction of the XR render target
  50217. */
  50218. export interface WebXRRenderTarget extends IDisposable {
  50219. /**
  50220. * xrpresent context of the canvas which can be used to display/mirror xr content
  50221. */
  50222. canvasContext: WebGLRenderingContext;
  50223. /**
  50224. * xr layer for the canvas
  50225. */
  50226. xrLayer: Nullable<XRWebGLLayer>;
  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. }
  50234. }
  50235. declare module BABYLON {
  50236. /**
  50237. * COnfiguration object for WebXR output canvas
  50238. */
  50239. export class WebXRManagedOutputCanvasOptions {
  50240. /**
  50241. * An optional canvas in case you wish to create it yourself and provide it here.
  50242. * If not provided, a new canvas will be created
  50243. */
  50244. canvasElement?: HTMLCanvasElement;
  50245. /**
  50246. * Options for this XR Layer output
  50247. */
  50248. canvasOptions?: XRWebGLLayerInit;
  50249. /**
  50250. * CSS styling for a newly created canvas (if not provided)
  50251. */
  50252. newCanvasCssStyle?: string;
  50253. /**
  50254. * Get the default values of the configuration object
  50255. * @param engine defines the engine to use (can be null)
  50256. * @returns default values of this configuration object
  50257. */
  50258. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50259. }
  50260. /**
  50261. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50262. */
  50263. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50264. private _options;
  50265. private _canvas;
  50266. private _engine;
  50267. private _originalCanvasSize;
  50268. /**
  50269. * Rendering context of the canvas which can be used to display/mirror xr content
  50270. */
  50271. canvasContext: WebGLRenderingContext;
  50272. /**
  50273. * xr layer for the canvas
  50274. */
  50275. xrLayer: Nullable<XRWebGLLayer>;
  50276. /**
  50277. * Obseervers registered here will be triggered when the xr layer was initialized
  50278. */
  50279. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50280. /**
  50281. * Initializes the canvas to be added/removed upon entering/exiting xr
  50282. * @param _xrSessionManager The XR Session manager
  50283. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50284. */
  50285. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50286. /**
  50287. * Disposes of the object
  50288. */
  50289. dispose(): void;
  50290. /**
  50291. * Initializes the xr layer for the session
  50292. * @param xrSession xr session
  50293. * @returns a promise that will resolve once the XR Layer has been created
  50294. */
  50295. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50296. private _addCanvas;
  50297. private _removeCanvas;
  50298. private _setCanvasSize;
  50299. private _setManagedOutputCanvas;
  50300. }
  50301. }
  50302. declare module BABYLON {
  50303. /**
  50304. * Manages an XRSession to work with Babylon's engine
  50305. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50306. */
  50307. export class WebXRSessionManager implements IDisposable {
  50308. /** The scene which the session should be created for */
  50309. scene: Scene;
  50310. private _referenceSpace;
  50311. private _rttProvider;
  50312. private _sessionEnded;
  50313. private _xrNavigator;
  50314. private baseLayer;
  50315. /**
  50316. * The base reference space from which the session started. good if you want to reset your
  50317. * reference space
  50318. */
  50319. baseReferenceSpace: XRReferenceSpace;
  50320. /**
  50321. * Current XR frame
  50322. */
  50323. currentFrame: Nullable<XRFrame>;
  50324. /** WebXR timestamp updated every frame */
  50325. currentTimestamp: number;
  50326. /**
  50327. * Used just in case of a failure to initialize an immersive session.
  50328. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50329. */
  50330. defaultHeightCompensation: number;
  50331. /**
  50332. * Fires every time a new xrFrame arrives which can be used to update the camera
  50333. */
  50334. onXRFrameObservable: Observable<XRFrame>;
  50335. /**
  50336. * Fires when the reference space changed
  50337. */
  50338. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50339. /**
  50340. * Fires when the xr session is ended either by the device or manually done
  50341. */
  50342. onXRSessionEnded: Observable<any>;
  50343. /**
  50344. * Fires when the xr session is ended either by the device or manually done
  50345. */
  50346. onXRSessionInit: Observable<XRSession>;
  50347. /**
  50348. * Underlying xr session
  50349. */
  50350. session: XRSession;
  50351. /**
  50352. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50353. * or get the offset the player is currently at.
  50354. */
  50355. viewerReferenceSpace: XRReferenceSpace;
  50356. /**
  50357. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50358. * @param scene The scene which the session should be created for
  50359. */
  50360. constructor(
  50361. /** The scene which the session should be created for */
  50362. scene: Scene);
  50363. /**
  50364. * The current reference space used in this session. This reference space can constantly change!
  50365. * It is mainly used to offset the camera's position.
  50366. */
  50367. get referenceSpace(): XRReferenceSpace;
  50368. /**
  50369. * Set a new reference space and triggers the observable
  50370. */
  50371. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50372. /**
  50373. * Disposes of the session manager
  50374. */
  50375. dispose(): void;
  50376. /**
  50377. * Stops the xrSession and restores the render loop
  50378. * @returns Promise which resolves after it exits XR
  50379. */
  50380. exitXRAsync(): Promise<void>;
  50381. /**
  50382. * Gets the correct render target texture to be rendered this frame for this eye
  50383. * @param eye the eye for which to get the render target
  50384. * @returns the render target for the specified eye
  50385. */
  50386. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50387. /**
  50388. * Creates a WebXRRenderTarget object for the XR session
  50389. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50390. * @param options optional options to provide when creating a new render target
  50391. * @returns a WebXR render target to which the session can render
  50392. */
  50393. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50394. /**
  50395. * Initializes the manager
  50396. * After initialization enterXR can be called to start an XR session
  50397. * @returns Promise which resolves after it is initialized
  50398. */
  50399. initializeAsync(): Promise<void>;
  50400. /**
  50401. * Initializes an xr session
  50402. * @param xrSessionMode mode to initialize
  50403. * @param xrSessionInit defines optional and required values to pass to the session builder
  50404. * @returns a promise which will resolve once the session has been initialized
  50405. */
  50406. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50407. /**
  50408. * Checks if a session would be supported for the creation options specified
  50409. * @param sessionMode session mode to check if supported eg. immersive-vr
  50410. * @returns A Promise that resolves to true if supported and false if not
  50411. */
  50412. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50413. /**
  50414. * Resets the reference space to the one started the session
  50415. */
  50416. resetReferenceSpace(): void;
  50417. /**
  50418. * Starts rendering to the xr layer
  50419. */
  50420. runXRRenderLoop(): void;
  50421. /**
  50422. * Sets the reference space on the xr session
  50423. * @param referenceSpaceType space to set
  50424. * @returns a promise that will resolve once the reference space has been set
  50425. */
  50426. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50427. /**
  50428. * Updates the render state of the session
  50429. * @param state state to set
  50430. * @returns a promise that resolves once the render state has been updated
  50431. */
  50432. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50433. /**
  50434. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50435. * @param sessionMode defines the session to test
  50436. * @returns a promise with boolean as final value
  50437. */
  50438. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50439. private _createRenderTargetTexture;
  50440. }
  50441. }
  50442. declare module BABYLON {
  50443. /**
  50444. * WebXR Camera which holds the views for the xrSession
  50445. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50446. */
  50447. export class WebXRCamera extends FreeCamera {
  50448. private _xrSessionManager;
  50449. private _firstFrame;
  50450. private _referenceQuaternion;
  50451. private _referencedPosition;
  50452. private _xrInvPositionCache;
  50453. private _xrInvQuaternionCache;
  50454. private _trackingState;
  50455. /**
  50456. * Observable raised before camera teleportation
  50457. */
  50458. onBeforeCameraTeleport: Observable<Vector3>;
  50459. /**
  50460. * Observable raised after camera teleportation
  50461. */
  50462. onAfterCameraTeleport: Observable<Vector3>;
  50463. /**
  50464. * Notifies when the camera's tracking state has changed.
  50465. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50466. */
  50467. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50468. /**
  50469. * Should position compensation execute on first frame.
  50470. * This is used when copying the position from a native (non XR) camera
  50471. */
  50472. compensateOnFirstFrame: boolean;
  50473. /**
  50474. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50475. * @param name the name of the camera
  50476. * @param scene the scene to add the camera to
  50477. * @param _xrSessionManager a constructed xr session manager
  50478. */
  50479. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50480. /**
  50481. * Get the current XR tracking state of the camera
  50482. */
  50483. get trackingState(): WebXRTrackingState;
  50484. private _setTrackingState;
  50485. /**
  50486. * Return the user's height, unrelated to the current ground.
  50487. * This will be the y position of this camera, when ground level is 0.
  50488. */
  50489. get realWorldHeight(): number;
  50490. /** @hidden */
  50491. _updateForDualEyeDebugging(): void;
  50492. /**
  50493. * Sets this camera's transformation based on a non-vr camera
  50494. * @param otherCamera the non-vr camera to copy the transformation from
  50495. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50496. */
  50497. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50498. /**
  50499. * Gets the current instance class name ("WebXRCamera").
  50500. * @returns the class name
  50501. */
  50502. getClassName(): string;
  50503. private _rotate180;
  50504. private _updateFromXRSession;
  50505. private _updateNumberOfRigCameras;
  50506. private _updateReferenceSpace;
  50507. private _updateReferenceSpaceOffset;
  50508. }
  50509. }
  50510. declare module BABYLON {
  50511. /**
  50512. * Defining the interface required for a (webxr) feature
  50513. */
  50514. export interface IWebXRFeature extends IDisposable {
  50515. /**
  50516. * Is this feature attached
  50517. */
  50518. attached: boolean;
  50519. /**
  50520. * Should auto-attach be disabled?
  50521. */
  50522. disableAutoAttach: boolean;
  50523. /**
  50524. * Attach the feature to the session
  50525. * Will usually be called by the features manager
  50526. *
  50527. * @param force should attachment be forced (even when already attached)
  50528. * @returns true if successful.
  50529. */
  50530. attach(force?: boolean): boolean;
  50531. /**
  50532. * Detach the feature from the session
  50533. * Will usually be called by the features manager
  50534. *
  50535. * @returns true if successful.
  50536. */
  50537. detach(): boolean;
  50538. /**
  50539. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50540. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50541. *
  50542. * @returns whether or not the feature is compatible in this environment
  50543. */
  50544. isCompatible(): boolean;
  50545. /**
  50546. * Was this feature disposed;
  50547. */
  50548. isDisposed: boolean;
  50549. /**
  50550. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50551. */
  50552. xrNativeFeatureName?: string;
  50553. /**
  50554. * A list of (Babylon WebXR) features this feature depends on
  50555. */
  50556. dependsOn?: string[];
  50557. }
  50558. /**
  50559. * A list of the currently available features without referencing them
  50560. */
  50561. export class WebXRFeatureName {
  50562. /**
  50563. * The name of the anchor system feature
  50564. */
  50565. static readonly ANCHOR_SYSTEM: string;
  50566. /**
  50567. * The name of the background remover feature
  50568. */
  50569. static readonly BACKGROUND_REMOVER: string;
  50570. /**
  50571. * The name of the hit test feature
  50572. */
  50573. static readonly HIT_TEST: string;
  50574. /**
  50575. * physics impostors for xr controllers feature
  50576. */
  50577. static readonly PHYSICS_CONTROLLERS: string;
  50578. /**
  50579. * The name of the plane detection feature
  50580. */
  50581. static readonly PLANE_DETECTION: string;
  50582. /**
  50583. * The name of the pointer selection feature
  50584. */
  50585. static readonly POINTER_SELECTION: string;
  50586. /**
  50587. * The name of the teleportation feature
  50588. */
  50589. static readonly TELEPORTATION: string;
  50590. /**
  50591. * The name of the feature points feature.
  50592. */
  50593. static readonly FEATURE_POINTS: string;
  50594. /**
  50595. * The name of the hand tracking feature.
  50596. */
  50597. static readonly HAND_TRACKING: string;
  50598. }
  50599. /**
  50600. * Defining the constructor of a feature. Used to register the modules.
  50601. */
  50602. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50603. /**
  50604. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50605. * It is mainly used in AR sessions.
  50606. *
  50607. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50608. */
  50609. export class WebXRFeaturesManager implements IDisposable {
  50610. private _xrSessionManager;
  50611. private static readonly _AvailableFeatures;
  50612. private _features;
  50613. /**
  50614. * constructs a new features manages.
  50615. *
  50616. * @param _xrSessionManager an instance of WebXRSessionManager
  50617. */
  50618. constructor(_xrSessionManager: WebXRSessionManager);
  50619. /**
  50620. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50621. * Mainly used internally.
  50622. *
  50623. * @param featureName the name of the feature to register
  50624. * @param constructorFunction the function used to construct the module
  50625. * @param version the (babylon) version of the module
  50626. * @param stable is that a stable version of this module
  50627. */
  50628. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50629. /**
  50630. * Returns a constructor of a specific feature.
  50631. *
  50632. * @param featureName the name of the feature to construct
  50633. * @param version the version of the feature to load
  50634. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50635. * @param options optional options provided to the module.
  50636. * @returns a function that, when called, will return a new instance of this feature
  50637. */
  50638. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50639. /**
  50640. * Can be used to return the list of features currently registered
  50641. *
  50642. * @returns an Array of available features
  50643. */
  50644. static GetAvailableFeatures(): string[];
  50645. /**
  50646. * Gets the versions available for a specific feature
  50647. * @param featureName the name of the feature
  50648. * @returns an array with the available versions
  50649. */
  50650. static GetAvailableVersions(featureName: string): string[];
  50651. /**
  50652. * Return the latest unstable version of this feature
  50653. * @param featureName the name of the feature to search
  50654. * @returns the version number. if not found will return -1
  50655. */
  50656. static GetLatestVersionOfFeature(featureName: string): number;
  50657. /**
  50658. * Return the latest stable version of this feature
  50659. * @param featureName the name of the feature to search
  50660. * @returns the version number. if not found will return -1
  50661. */
  50662. static GetStableVersionOfFeature(featureName: string): number;
  50663. /**
  50664. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50665. * Can be used during a session to start a feature
  50666. * @param featureName the name of feature to attach
  50667. */
  50668. attachFeature(featureName: string): void;
  50669. /**
  50670. * Can be used inside a session or when the session ends to detach a specific feature
  50671. * @param featureName the name of the feature to detach
  50672. */
  50673. detachFeature(featureName: string): void;
  50674. /**
  50675. * Used to disable an already-enabled feature
  50676. * The feature will be disposed and will be recreated once enabled.
  50677. * @param featureName the feature to disable
  50678. * @returns true if disable was successful
  50679. */
  50680. disableFeature(featureName: string | {
  50681. Name: string;
  50682. }): boolean;
  50683. /**
  50684. * dispose this features manager
  50685. */
  50686. dispose(): void;
  50687. /**
  50688. * 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.
  50689. * 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.
  50690. *
  50691. * @param featureName the name of the feature to load or the class of the feature
  50692. * @param version optional version to load. if not provided the latest version will be enabled
  50693. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50694. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50695. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50696. * @returns a new constructed feature or throws an error if feature not found.
  50697. */
  50698. enableFeature(featureName: string | {
  50699. Name: string;
  50700. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50701. /**
  50702. * get the implementation of an enabled feature.
  50703. * @param featureName the name of the feature to load
  50704. * @returns the feature class, if found
  50705. */
  50706. getEnabledFeature(featureName: string): IWebXRFeature;
  50707. /**
  50708. * Get the list of enabled features
  50709. * @returns an array of enabled features
  50710. */
  50711. getEnabledFeatures(): string[];
  50712. /**
  50713. * This function will exten the session creation configuration object with enabled features.
  50714. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50715. * according to the defined "required" variable, provided during enableFeature call
  50716. * @param xrSessionInit the xr Session init object to extend
  50717. *
  50718. * @returns an extended XRSessionInit object
  50719. */
  50720. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50721. }
  50722. }
  50723. declare module BABYLON {
  50724. /**
  50725. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50726. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50727. */
  50728. export class WebXRExperienceHelper implements IDisposable {
  50729. private scene;
  50730. private _nonVRCamera;
  50731. private _originalSceneAutoClear;
  50732. private _supported;
  50733. /**
  50734. * Camera used to render xr content
  50735. */
  50736. camera: WebXRCamera;
  50737. /** A features manager for this xr session */
  50738. featuresManager: WebXRFeaturesManager;
  50739. /**
  50740. * Observers registered here will be triggered after the camera's initial transformation is set
  50741. * This can be used to set a different ground level or an extra rotation.
  50742. *
  50743. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  50744. * to the position set after this observable is done executing.
  50745. */
  50746. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  50747. /**
  50748. * Fires when the state of the experience helper has changed
  50749. */
  50750. onStateChangedObservable: Observable<WebXRState>;
  50751. /** Session manager used to keep track of xr session */
  50752. sessionManager: WebXRSessionManager;
  50753. /**
  50754. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  50755. */
  50756. state: WebXRState;
  50757. /**
  50758. * Creates a WebXRExperienceHelper
  50759. * @param scene The scene the helper should be created in
  50760. */
  50761. private constructor();
  50762. /**
  50763. * Creates the experience helper
  50764. * @param scene the scene to attach the experience helper to
  50765. * @returns a promise for the experience helper
  50766. */
  50767. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  50768. /**
  50769. * Disposes of the experience helper
  50770. */
  50771. dispose(): void;
  50772. /**
  50773. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  50774. * @param sessionMode options for the XR session
  50775. * @param referenceSpaceType frame of reference of the XR session
  50776. * @param renderTarget the output canvas that will be used to enter XR mode
  50777. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  50778. * @returns promise that resolves after xr mode has entered
  50779. */
  50780. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  50781. /**
  50782. * Exits XR mode and returns the scene to its original state
  50783. * @returns promise that resolves after xr mode has exited
  50784. */
  50785. exitXRAsync(): Promise<void>;
  50786. private _nonXRToXRCamera;
  50787. private _setState;
  50788. }
  50789. }
  50790. declare module BABYLON {
  50791. /**
  50792. * X-Y values for axes in WebXR
  50793. */
  50794. export interface IWebXRMotionControllerAxesValue {
  50795. /**
  50796. * The value of the x axis
  50797. */
  50798. x: number;
  50799. /**
  50800. * The value of the y-axis
  50801. */
  50802. y: number;
  50803. }
  50804. /**
  50805. * changed / previous values for the values of this component
  50806. */
  50807. export interface IWebXRMotionControllerComponentChangesValues<T> {
  50808. /**
  50809. * current (this frame) value
  50810. */
  50811. current: T;
  50812. /**
  50813. * previous (last change) value
  50814. */
  50815. previous: T;
  50816. }
  50817. /**
  50818. * Represents changes in the component between current frame and last values recorded
  50819. */
  50820. export interface IWebXRMotionControllerComponentChanges {
  50821. /**
  50822. * will be populated with previous and current values if axes changed
  50823. */
  50824. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  50825. /**
  50826. * will be populated with previous and current values if pressed changed
  50827. */
  50828. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50829. /**
  50830. * will be populated with previous and current values if touched changed
  50831. */
  50832. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50833. /**
  50834. * will be populated with previous and current values if value changed
  50835. */
  50836. value?: IWebXRMotionControllerComponentChangesValues<number>;
  50837. }
  50838. /**
  50839. * This class represents a single component (for example button or thumbstick) of a motion controller
  50840. */
  50841. export class WebXRControllerComponent implements IDisposable {
  50842. /**
  50843. * the id of this component
  50844. */
  50845. id: string;
  50846. /**
  50847. * the type of the component
  50848. */
  50849. type: MotionControllerComponentType;
  50850. private _buttonIndex;
  50851. private _axesIndices;
  50852. private _axes;
  50853. private _changes;
  50854. private _currentValue;
  50855. private _hasChanges;
  50856. private _pressed;
  50857. private _touched;
  50858. /**
  50859. * button component type
  50860. */
  50861. static BUTTON_TYPE: MotionControllerComponentType;
  50862. /**
  50863. * squeeze component type
  50864. */
  50865. static SQUEEZE_TYPE: MotionControllerComponentType;
  50866. /**
  50867. * Thumbstick component type
  50868. */
  50869. static THUMBSTICK_TYPE: MotionControllerComponentType;
  50870. /**
  50871. * Touchpad component type
  50872. */
  50873. static TOUCHPAD_TYPE: MotionControllerComponentType;
  50874. /**
  50875. * trigger component type
  50876. */
  50877. static TRIGGER_TYPE: MotionControllerComponentType;
  50878. /**
  50879. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  50880. * the axes data changes
  50881. */
  50882. onAxisValueChangedObservable: Observable<{
  50883. x: number;
  50884. y: number;
  50885. }>;
  50886. /**
  50887. * Observers registered here will be triggered when the state of a button changes
  50888. * State change is either pressed / touched / value
  50889. */
  50890. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  50891. /**
  50892. * Creates a new component for a motion controller.
  50893. * It is created by the motion controller itself
  50894. *
  50895. * @param id the id of this component
  50896. * @param type the type of the component
  50897. * @param _buttonIndex index in the buttons array of the gamepad
  50898. * @param _axesIndices indices of the values in the axes array of the gamepad
  50899. */
  50900. constructor(
  50901. /**
  50902. * the id of this component
  50903. */
  50904. id: string,
  50905. /**
  50906. * the type of the component
  50907. */
  50908. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  50909. /**
  50910. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  50911. */
  50912. get axes(): IWebXRMotionControllerAxesValue;
  50913. /**
  50914. * Get the changes. Elements will be populated only if they changed with their previous and current value
  50915. */
  50916. get changes(): IWebXRMotionControllerComponentChanges;
  50917. /**
  50918. * Return whether or not the component changed the last frame
  50919. */
  50920. get hasChanges(): boolean;
  50921. /**
  50922. * is the button currently pressed
  50923. */
  50924. get pressed(): boolean;
  50925. /**
  50926. * is the button currently touched
  50927. */
  50928. get touched(): boolean;
  50929. /**
  50930. * Get the current value of this component
  50931. */
  50932. get value(): number;
  50933. /**
  50934. * Dispose this component
  50935. */
  50936. dispose(): void;
  50937. /**
  50938. * Are there axes correlating to this component
  50939. * @return true is axes data is available
  50940. */
  50941. isAxes(): boolean;
  50942. /**
  50943. * Is this component a button (hence - pressable)
  50944. * @returns true if can be pressed
  50945. */
  50946. isButton(): boolean;
  50947. /**
  50948. * update this component using the gamepad object it is in. Called on every frame
  50949. * @param nativeController the native gamepad controller object
  50950. */
  50951. update(nativeController: IMinimalMotionControllerObject): void;
  50952. }
  50953. }
  50954. declare module BABYLON {
  50955. /**
  50956. * Interface used to represent data loading progression
  50957. */
  50958. export interface ISceneLoaderProgressEvent {
  50959. /**
  50960. * Defines if data length to load can be evaluated
  50961. */
  50962. readonly lengthComputable: boolean;
  50963. /**
  50964. * Defines the loaded data length
  50965. */
  50966. readonly loaded: number;
  50967. /**
  50968. * Defines the data length to load
  50969. */
  50970. readonly total: number;
  50971. }
  50972. /**
  50973. * Interface used by SceneLoader plugins to define supported file extensions
  50974. */
  50975. export interface ISceneLoaderPluginExtensions {
  50976. /**
  50977. * Defines the list of supported extensions
  50978. */
  50979. [extension: string]: {
  50980. isBinary: boolean;
  50981. };
  50982. }
  50983. /**
  50984. * Interface used by SceneLoader plugin factory
  50985. */
  50986. export interface ISceneLoaderPluginFactory {
  50987. /**
  50988. * Defines the name of the factory
  50989. */
  50990. name: string;
  50991. /**
  50992. * Function called to create a new plugin
  50993. * @return the new plugin
  50994. */
  50995. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  50996. /**
  50997. * The callback that returns true if the data can be directly loaded.
  50998. * @param data string containing the file data
  50999. * @returns if the data can be loaded directly
  51000. */
  51001. canDirectLoad?(data: string): boolean;
  51002. }
  51003. /**
  51004. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  51005. */
  51006. export interface ISceneLoaderPluginBase {
  51007. /**
  51008. * The friendly name of this plugin.
  51009. */
  51010. name: string;
  51011. /**
  51012. * The file extensions supported by this plugin.
  51013. */
  51014. extensions: string | ISceneLoaderPluginExtensions;
  51015. /**
  51016. * The callback called when loading from a url.
  51017. * @param scene scene loading this url
  51018. * @param url url to load
  51019. * @param onSuccess callback called when the file successfully loads
  51020. * @param onProgress callback called while file is loading (if the server supports this mode)
  51021. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  51022. * @param onError callback called when the file fails to load
  51023. * @returns a file request object
  51024. */
  51025. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51026. /**
  51027. * The callback called when loading from a file object.
  51028. * @param scene scene loading this file
  51029. * @param file defines the file to load
  51030. * @param onSuccess defines the callback to call when data is loaded
  51031. * @param onProgress defines the callback to call during loading process
  51032. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  51033. * @param onError defines the callback to call when an error occurs
  51034. * @returns a file request object
  51035. */
  51036. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51037. /**
  51038. * The callback that returns true if the data can be directly loaded.
  51039. * @param data string containing the file data
  51040. * @returns if the data can be loaded directly
  51041. */
  51042. canDirectLoad?(data: string): boolean;
  51043. /**
  51044. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  51045. * @param scene scene loading this data
  51046. * @param data string containing the data
  51047. * @returns data to pass to the plugin
  51048. */
  51049. directLoad?(scene: Scene, data: string): any;
  51050. /**
  51051. * The callback that allows custom handling of the root url based on the response url.
  51052. * @param rootUrl the original root url
  51053. * @param responseURL the response url if available
  51054. * @returns the new root url
  51055. */
  51056. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  51057. }
  51058. /**
  51059. * Interface used to define a SceneLoader plugin
  51060. */
  51061. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  51062. /**
  51063. * Import meshes into a scene.
  51064. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51065. * @param scene The scene to import into
  51066. * @param data The data to import
  51067. * @param rootUrl The root url for scene and resources
  51068. * @param meshes The meshes array to import into
  51069. * @param particleSystems The particle systems array to import into
  51070. * @param skeletons The skeletons array to import into
  51071. * @param onError The callback when import fails
  51072. * @returns True if successful or false otherwise
  51073. */
  51074. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51075. /**
  51076. * Load into a scene.
  51077. * @param scene The scene to load into
  51078. * @param data The data to import
  51079. * @param rootUrl The root url for scene and resources
  51080. * @param onError The callback when import fails
  51081. * @returns True if successful or false otherwise
  51082. */
  51083. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51084. /**
  51085. * Load into an asset container.
  51086. * @param scene The scene to load into
  51087. * @param data The data to import
  51088. * @param rootUrl The root url for scene and resources
  51089. * @param onError The callback when import fails
  51090. * @returns The loaded asset container
  51091. */
  51092. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51093. }
  51094. /**
  51095. * Interface used to define an async SceneLoader plugin
  51096. */
  51097. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51098. /**
  51099. * Import meshes into a scene.
  51100. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51101. * @param scene The scene to import into
  51102. * @param data The data to import
  51103. * @param rootUrl The root url for scene and resources
  51104. * @param onProgress The callback when the load progresses
  51105. * @param fileName Defines the name of the file to load
  51106. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  51107. */
  51108. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  51109. meshes: AbstractMesh[];
  51110. particleSystems: IParticleSystem[];
  51111. skeletons: Skeleton[];
  51112. animationGroups: AnimationGroup[];
  51113. }>;
  51114. /**
  51115. * Load into a scene.
  51116. * @param scene The scene to load into
  51117. * @param data The data to import
  51118. * @param rootUrl The root url for scene and resources
  51119. * @param onProgress The callback when the load progresses
  51120. * @param fileName Defines the name of the file to load
  51121. * @returns Nothing
  51122. */
  51123. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51124. /**
  51125. * Load into an asset container.
  51126. * @param scene The scene to load into
  51127. * @param data The data to import
  51128. * @param rootUrl The root url for scene and resources
  51129. * @param onProgress The callback when the load progresses
  51130. * @param fileName Defines the name of the file to load
  51131. * @returns The loaded asset container
  51132. */
  51133. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51134. }
  51135. /**
  51136. * Mode that determines how to handle old animation groups before loading new ones.
  51137. */
  51138. export enum SceneLoaderAnimationGroupLoadingMode {
  51139. /**
  51140. * Reset all old animations to initial state then dispose them.
  51141. */
  51142. Clean = 0,
  51143. /**
  51144. * Stop all old animations.
  51145. */
  51146. Stop = 1,
  51147. /**
  51148. * Restart old animations from first frame.
  51149. */
  51150. Sync = 2,
  51151. /**
  51152. * Old animations remains untouched.
  51153. */
  51154. NoSync = 3
  51155. }
  51156. /**
  51157. * Defines a plugin registered by the SceneLoader
  51158. */
  51159. interface IRegisteredPlugin {
  51160. /**
  51161. * Defines the plugin to use
  51162. */
  51163. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51164. /**
  51165. * Defines if the plugin supports binary data
  51166. */
  51167. isBinary: boolean;
  51168. }
  51169. /**
  51170. * Class used to load scene from various file formats using registered plugins
  51171. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51172. */
  51173. export class SceneLoader {
  51174. /**
  51175. * No logging while loading
  51176. */
  51177. static readonly NO_LOGGING: number;
  51178. /**
  51179. * Minimal logging while loading
  51180. */
  51181. static readonly MINIMAL_LOGGING: number;
  51182. /**
  51183. * Summary logging while loading
  51184. */
  51185. static readonly SUMMARY_LOGGING: number;
  51186. /**
  51187. * Detailled logging while loading
  51188. */
  51189. static readonly DETAILED_LOGGING: number;
  51190. /**
  51191. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51192. */
  51193. static get ForceFullSceneLoadingForIncremental(): boolean;
  51194. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51195. /**
  51196. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51197. */
  51198. static get ShowLoadingScreen(): boolean;
  51199. static set ShowLoadingScreen(value: boolean);
  51200. /**
  51201. * Defines the current logging level (while loading the scene)
  51202. * @ignorenaming
  51203. */
  51204. static get loggingLevel(): number;
  51205. static set loggingLevel(value: number);
  51206. /**
  51207. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51208. */
  51209. static get CleanBoneMatrixWeights(): boolean;
  51210. static set CleanBoneMatrixWeights(value: boolean);
  51211. /**
  51212. * Event raised when a plugin is used to load a scene
  51213. */
  51214. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51215. private static _registeredPlugins;
  51216. private static _showingLoadingScreen;
  51217. /**
  51218. * Gets the default plugin (used to load Babylon files)
  51219. * @returns the .babylon plugin
  51220. */
  51221. static GetDefaultPlugin(): IRegisteredPlugin;
  51222. private static _GetPluginForExtension;
  51223. private static _GetPluginForDirectLoad;
  51224. private static _GetPluginForFilename;
  51225. private static _GetDirectLoad;
  51226. private static _LoadData;
  51227. private static _GetFileInfo;
  51228. /**
  51229. * Gets a plugin that can load the given extension
  51230. * @param extension defines the extension to load
  51231. * @returns a plugin or null if none works
  51232. */
  51233. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51234. /**
  51235. * Gets a boolean indicating that the given extension can be loaded
  51236. * @param extension defines the extension to load
  51237. * @returns true if the extension is supported
  51238. */
  51239. static IsPluginForExtensionAvailable(extension: string): boolean;
  51240. /**
  51241. * Adds a new plugin to the list of registered plugins
  51242. * @param plugin defines the plugin to add
  51243. */
  51244. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51245. /**
  51246. * Import meshes into a scene
  51247. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51248. * @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)
  51249. * @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)
  51250. * @param scene the instance of BABYLON.Scene to append to
  51251. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51252. * @param onProgress a callback with a progress event for each file being loaded
  51253. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51254. * @param pluginExtension the extension used to determine the plugin
  51255. * @returns The loaded plugin
  51256. */
  51257. 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>;
  51258. /**
  51259. * Import meshes into a scene
  51260. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51261. * @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)
  51262. * @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)
  51263. * @param scene the instance of BABYLON.Scene to append to
  51264. * @param onProgress a callback with a progress event for each file being loaded
  51265. * @param pluginExtension the extension used to determine the plugin
  51266. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51267. */
  51268. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  51269. meshes: AbstractMesh[];
  51270. particleSystems: IParticleSystem[];
  51271. skeletons: Skeleton[];
  51272. animationGroups: AnimationGroup[];
  51273. }>;
  51274. /**
  51275. * Load a scene
  51276. * @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)
  51277. * @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)
  51278. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51279. * @param onSuccess a callback with the scene when import succeeds
  51280. * @param onProgress a callback with a progress event for each file being loaded
  51281. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51282. * @param pluginExtension the extension used to determine the plugin
  51283. * @returns The loaded plugin
  51284. */
  51285. 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>;
  51286. /**
  51287. * Load a scene
  51288. * @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)
  51289. * @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)
  51290. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51291. * @param onProgress a callback with a progress event for each file being loaded
  51292. * @param pluginExtension the extension used to determine the plugin
  51293. * @returns The loaded scene
  51294. */
  51295. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51296. /**
  51297. * Append a scene
  51298. * @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)
  51299. * @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)
  51300. * @param scene is the instance of BABYLON.Scene to append to
  51301. * @param onSuccess a callback with the scene when import succeeds
  51302. * @param onProgress a callback with a progress event for each file being loaded
  51303. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51304. * @param pluginExtension the extension used to determine the plugin
  51305. * @returns The loaded plugin
  51306. */
  51307. 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>;
  51308. /**
  51309. * Append a scene
  51310. * @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)
  51311. * @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)
  51312. * @param scene is the instance of BABYLON.Scene to append to
  51313. * @param onProgress a callback with a progress event for each file being loaded
  51314. * @param pluginExtension the extension used to determine the plugin
  51315. * @returns The given scene
  51316. */
  51317. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51318. /**
  51319. * Load a scene into an asset container
  51320. * @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)
  51321. * @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)
  51322. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51323. * @param onSuccess a callback with the scene when import succeeds
  51324. * @param onProgress a callback with a progress event for each file being loaded
  51325. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51326. * @param pluginExtension the extension used to determine the plugin
  51327. * @returns The loaded plugin
  51328. */
  51329. 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>;
  51330. /**
  51331. * Load a scene into an asset container
  51332. * @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)
  51333. * @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)
  51334. * @param scene is the instance of Scene to append to
  51335. * @param onProgress a callback with a progress event for each file being loaded
  51336. * @param pluginExtension the extension used to determine the plugin
  51337. * @returns The loaded asset container
  51338. */
  51339. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51340. /**
  51341. * Import animations from a file into a scene
  51342. * @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)
  51343. * @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)
  51344. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51345. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51346. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51347. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51348. * @param onSuccess a callback with the scene when import succeeds
  51349. * @param onProgress a callback with a progress event for each file being loaded
  51350. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51351. * @param pluginExtension the extension used to determine the plugin
  51352. */
  51353. 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;
  51354. /**
  51355. * Import animations from a file into a scene
  51356. * @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)
  51357. * @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)
  51358. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51359. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51360. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51361. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51362. * @param onSuccess a callback with the scene when import succeeds
  51363. * @param onProgress a callback with a progress event for each file being loaded
  51364. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51365. * @param pluginExtension the extension used to determine the plugin
  51366. * @returns the updated scene with imported animations
  51367. */
  51368. 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>;
  51369. }
  51370. }
  51371. declare module BABYLON {
  51372. /**
  51373. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51374. */
  51375. export type MotionControllerHandedness = "none" | "left" | "right";
  51376. /**
  51377. * The type of components available in motion controllers.
  51378. * This is not the name of the component.
  51379. */
  51380. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51381. /**
  51382. * The state of a controller component
  51383. */
  51384. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51385. /**
  51386. * The schema of motion controller layout.
  51387. * No object will be initialized using this interface
  51388. * This is used just to define the profile.
  51389. */
  51390. export interface IMotionControllerLayout {
  51391. /**
  51392. * Path to load the assets. Usually relative to the base path
  51393. */
  51394. assetPath: string;
  51395. /**
  51396. * Available components (unsorted)
  51397. */
  51398. components: {
  51399. /**
  51400. * A map of component Ids
  51401. */
  51402. [componentId: string]: {
  51403. /**
  51404. * The type of input the component outputs
  51405. */
  51406. type: MotionControllerComponentType;
  51407. /**
  51408. * The indices of this component in the gamepad object
  51409. */
  51410. gamepadIndices: {
  51411. /**
  51412. * Index of button
  51413. */
  51414. button?: number;
  51415. /**
  51416. * If available, index of x-axis
  51417. */
  51418. xAxis?: number;
  51419. /**
  51420. * If available, index of y-axis
  51421. */
  51422. yAxis?: number;
  51423. };
  51424. /**
  51425. * The mesh's root node name
  51426. */
  51427. rootNodeName: string;
  51428. /**
  51429. * Animation definitions for this model
  51430. */
  51431. visualResponses: {
  51432. [stateKey: string]: {
  51433. /**
  51434. * What property will be animated
  51435. */
  51436. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51437. /**
  51438. * What states influence this visual response
  51439. */
  51440. states: MotionControllerComponentStateType[];
  51441. /**
  51442. * Type of animation - movement or visibility
  51443. */
  51444. valueNodeProperty: "transform" | "visibility";
  51445. /**
  51446. * Base node name to move. Its position will be calculated according to the min and max nodes
  51447. */
  51448. valueNodeName?: string;
  51449. /**
  51450. * Minimum movement node
  51451. */
  51452. minNodeName?: string;
  51453. /**
  51454. * Max movement node
  51455. */
  51456. maxNodeName?: string;
  51457. };
  51458. };
  51459. /**
  51460. * If touch enabled, what is the name of node to display user feedback
  51461. */
  51462. touchPointNodeName?: string;
  51463. };
  51464. };
  51465. /**
  51466. * Is it xr standard mapping or not
  51467. */
  51468. gamepadMapping: "" | "xr-standard";
  51469. /**
  51470. * Base root node of this entire model
  51471. */
  51472. rootNodeName: string;
  51473. /**
  51474. * Defines the main button component id
  51475. */
  51476. selectComponentId: string;
  51477. }
  51478. /**
  51479. * A definition for the layout map in the input profile
  51480. */
  51481. export interface IMotionControllerLayoutMap {
  51482. /**
  51483. * Layouts with handedness type as a key
  51484. */
  51485. [handedness: string]: IMotionControllerLayout;
  51486. }
  51487. /**
  51488. * The XR Input profile schema
  51489. * Profiles can be found here:
  51490. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51491. */
  51492. export interface IMotionControllerProfile {
  51493. /**
  51494. * fallback profiles for this profileId
  51495. */
  51496. fallbackProfileIds: string[];
  51497. /**
  51498. * The layout map, with handedness as key
  51499. */
  51500. layouts: IMotionControllerLayoutMap;
  51501. /**
  51502. * The id of this profile
  51503. * correlates to the profile(s) in the xrInput.profiles array
  51504. */
  51505. profileId: string;
  51506. }
  51507. /**
  51508. * A helper-interface for the 3 meshes needed for controller button animation
  51509. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51510. */
  51511. export interface IMotionControllerButtonMeshMap {
  51512. /**
  51513. * the mesh that defines the pressed value mesh position.
  51514. * This is used to find the max-position of this button
  51515. */
  51516. pressedMesh: AbstractMesh;
  51517. /**
  51518. * the mesh that defines the unpressed value mesh position.
  51519. * This is used to find the min (or initial) position of this button
  51520. */
  51521. unpressedMesh: AbstractMesh;
  51522. /**
  51523. * The mesh that will be changed when value changes
  51524. */
  51525. valueMesh: AbstractMesh;
  51526. }
  51527. /**
  51528. * A helper-interface for the 3 meshes needed for controller axis animation.
  51529. * This will be expanded when touchpad animations are fully supported
  51530. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51531. */
  51532. export interface IMotionControllerMeshMap {
  51533. /**
  51534. * the mesh that defines the maximum value mesh position.
  51535. */
  51536. maxMesh?: AbstractMesh;
  51537. /**
  51538. * the mesh that defines the minimum value mesh position.
  51539. */
  51540. minMesh?: AbstractMesh;
  51541. /**
  51542. * The mesh that will be changed when axis value changes
  51543. */
  51544. valueMesh?: AbstractMesh;
  51545. }
  51546. /**
  51547. * The elements needed for change-detection of the gamepad objects in motion controllers
  51548. */
  51549. export interface IMinimalMotionControllerObject {
  51550. /**
  51551. * Available axes of this controller
  51552. */
  51553. axes: number[];
  51554. /**
  51555. * An array of available buttons
  51556. */
  51557. buttons: Array<{
  51558. /**
  51559. * Value of the button/trigger
  51560. */
  51561. value: number;
  51562. /**
  51563. * If the button/trigger is currently touched
  51564. */
  51565. touched: boolean;
  51566. /**
  51567. * If the button/trigger is currently pressed
  51568. */
  51569. pressed: boolean;
  51570. }>;
  51571. /**
  51572. * EXPERIMENTAL haptic support.
  51573. */
  51574. hapticActuators?: Array<{
  51575. pulse: (value: number, duration: number) => Promise<boolean>;
  51576. }>;
  51577. }
  51578. /**
  51579. * An Abstract Motion controller
  51580. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51581. * Each component has an observable to check for changes in value and state
  51582. */
  51583. export abstract class WebXRAbstractMotionController implements IDisposable {
  51584. protected scene: Scene;
  51585. protected layout: IMotionControllerLayout;
  51586. /**
  51587. * The gamepad object correlating to this controller
  51588. */
  51589. gamepadObject: IMinimalMotionControllerObject;
  51590. /**
  51591. * handedness (left/right/none) of this controller
  51592. */
  51593. handedness: MotionControllerHandedness;
  51594. private _initComponent;
  51595. private _modelReady;
  51596. /**
  51597. * A map of components (WebXRControllerComponent) in this motion controller
  51598. * Components have a ComponentType and can also have both button and axis definitions
  51599. */
  51600. readonly components: {
  51601. [id: string]: WebXRControllerComponent;
  51602. };
  51603. /**
  51604. * Disable the model's animation. Can be set at any time.
  51605. */
  51606. disableAnimation: boolean;
  51607. /**
  51608. * Observers registered here will be triggered when the model of this controller is done loading
  51609. */
  51610. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51611. /**
  51612. * The profile id of this motion controller
  51613. */
  51614. abstract profileId: string;
  51615. /**
  51616. * The root mesh of the model. It is null if the model was not yet initialized
  51617. */
  51618. rootMesh: Nullable<AbstractMesh>;
  51619. /**
  51620. * constructs a new abstract motion controller
  51621. * @param scene the scene to which the model of the controller will be added
  51622. * @param layout The profile layout to load
  51623. * @param gamepadObject The gamepad object correlating to this controller
  51624. * @param handedness handedness (left/right/none) of this controller
  51625. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51626. */
  51627. constructor(scene: Scene, layout: IMotionControllerLayout,
  51628. /**
  51629. * The gamepad object correlating to this controller
  51630. */
  51631. gamepadObject: IMinimalMotionControllerObject,
  51632. /**
  51633. * handedness (left/right/none) of this controller
  51634. */
  51635. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51636. /**
  51637. * Dispose this controller, the model mesh and all its components
  51638. */
  51639. dispose(): void;
  51640. /**
  51641. * Returns all components of specific type
  51642. * @param type the type to search for
  51643. * @return an array of components with this type
  51644. */
  51645. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51646. /**
  51647. * get a component based an its component id as defined in layout.components
  51648. * @param id the id of the component
  51649. * @returns the component correlates to the id or undefined if not found
  51650. */
  51651. getComponent(id: string): WebXRControllerComponent;
  51652. /**
  51653. * Get the list of components available in this motion controller
  51654. * @returns an array of strings correlating to available components
  51655. */
  51656. getComponentIds(): string[];
  51657. /**
  51658. * Get the first component of specific type
  51659. * @param type type of component to find
  51660. * @return a controller component or null if not found
  51661. */
  51662. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51663. /**
  51664. * Get the main (Select) component of this controller as defined in the layout
  51665. * @returns the main component of this controller
  51666. */
  51667. getMainComponent(): WebXRControllerComponent;
  51668. /**
  51669. * Loads the model correlating to this controller
  51670. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51671. * @returns A promise fulfilled with the result of the model loading
  51672. */
  51673. loadModel(): Promise<boolean>;
  51674. /**
  51675. * Update this model using the current XRFrame
  51676. * @param xrFrame the current xr frame to use and update the model
  51677. */
  51678. updateFromXRFrame(xrFrame: XRFrame): void;
  51679. /**
  51680. * Backwards compatibility due to a deeply-integrated typo
  51681. */
  51682. get handness(): XREye;
  51683. /**
  51684. * Pulse (vibrate) this controller
  51685. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51686. * Consecutive calls to this function will cancel the last pulse call
  51687. *
  51688. * @param value the strength of the pulse in 0.0...1.0 range
  51689. * @param duration Duration of the pulse in milliseconds
  51690. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51691. * @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
  51692. */
  51693. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51694. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51695. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51696. /**
  51697. * Moves the axis on the controller mesh based on its current state
  51698. * @param axis the index of the axis
  51699. * @param axisValue the value of the axis which determines the meshes new position
  51700. * @hidden
  51701. */
  51702. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  51703. /**
  51704. * Update the model itself with the current frame data
  51705. * @param xrFrame the frame to use for updating the model mesh
  51706. */
  51707. protected updateModel(xrFrame: XRFrame): void;
  51708. /**
  51709. * Get the filename and path for this controller's model
  51710. * @returns a map of filename and path
  51711. */
  51712. protected abstract _getFilenameAndPath(): {
  51713. filename: string;
  51714. path: string;
  51715. };
  51716. /**
  51717. * This function is called before the mesh is loaded. It checks for loading constraints.
  51718. * For example, this function can check if the GLB loader is available
  51719. * If this function returns false, the generic controller will be loaded instead
  51720. * @returns Is the client ready to load the mesh
  51721. */
  51722. protected abstract _getModelLoadingConstraints(): boolean;
  51723. /**
  51724. * This function will be called after the model was successfully loaded and can be used
  51725. * for mesh transformations before it is available for the user
  51726. * @param meshes the loaded meshes
  51727. */
  51728. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  51729. /**
  51730. * Set the root mesh for this controller. Important for the WebXR controller class
  51731. * @param meshes the loaded meshes
  51732. */
  51733. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  51734. /**
  51735. * A function executed each frame that updates the mesh (if needed)
  51736. * @param xrFrame the current xrFrame
  51737. */
  51738. protected abstract _updateModel(xrFrame: XRFrame): void;
  51739. private _getGenericFilenameAndPath;
  51740. private _getGenericParentMesh;
  51741. }
  51742. }
  51743. declare module BABYLON {
  51744. /**
  51745. * A generic trigger-only motion controller for WebXR
  51746. */
  51747. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  51748. /**
  51749. * Static version of the profile id of this controller
  51750. */
  51751. static ProfileId: string;
  51752. profileId: string;
  51753. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  51754. protected _getFilenameAndPath(): {
  51755. filename: string;
  51756. path: string;
  51757. };
  51758. protected _getModelLoadingConstraints(): boolean;
  51759. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  51760. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51761. protected _updateModel(): void;
  51762. }
  51763. }
  51764. declare module BABYLON {
  51765. /**
  51766. * Class containing static functions to help procedurally build meshes
  51767. */
  51768. export class SphereBuilder {
  51769. /**
  51770. * Creates a sphere mesh
  51771. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51772. * * 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`)
  51773. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51774. * * 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
  51775. * * 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)
  51776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51777. * * 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
  51778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51779. * @param name defines the name of the mesh
  51780. * @param options defines the options used to create the mesh
  51781. * @param scene defines the hosting scene
  51782. * @returns the sphere mesh
  51783. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51784. */
  51785. static CreateSphere(name: string, options: {
  51786. segments?: number;
  51787. diameter?: number;
  51788. diameterX?: number;
  51789. diameterY?: number;
  51790. diameterZ?: number;
  51791. arc?: number;
  51792. slice?: number;
  51793. sideOrientation?: number;
  51794. frontUVs?: Vector4;
  51795. backUVs?: Vector4;
  51796. updatable?: boolean;
  51797. }, scene?: Nullable<Scene>): Mesh;
  51798. }
  51799. }
  51800. declare module BABYLON {
  51801. /**
  51802. * A profiled motion controller has its profile loaded from an online repository.
  51803. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  51804. */
  51805. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  51806. private _repositoryUrl;
  51807. private _buttonMeshMapping;
  51808. private _touchDots;
  51809. /**
  51810. * The profile ID of this controller. Will be populated when the controller initializes.
  51811. */
  51812. profileId: string;
  51813. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  51814. dispose(): void;
  51815. protected _getFilenameAndPath(): {
  51816. filename: string;
  51817. path: string;
  51818. };
  51819. protected _getModelLoadingConstraints(): boolean;
  51820. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  51821. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51822. protected _updateModel(_xrFrame: XRFrame): void;
  51823. }
  51824. }
  51825. declare module BABYLON {
  51826. /**
  51827. * A construction function type to create a new controller based on an xrInput object
  51828. */
  51829. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  51830. /**
  51831. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  51832. *
  51833. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  51834. * it should be replaced with auto-loaded controllers.
  51835. *
  51836. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  51837. */
  51838. export class WebXRMotionControllerManager {
  51839. private static _AvailableControllers;
  51840. private static _Fallbacks;
  51841. private static _ProfileLoadingPromises;
  51842. private static _ProfilesList;
  51843. /**
  51844. * The base URL of the online controller repository. Can be changed at any time.
  51845. */
  51846. static BaseRepositoryUrl: string;
  51847. /**
  51848. * Which repository gets priority - local or online
  51849. */
  51850. static PrioritizeOnlineRepository: boolean;
  51851. /**
  51852. * Use the online repository, or use only locally-defined controllers
  51853. */
  51854. static UseOnlineRepository: boolean;
  51855. /**
  51856. * Clear the cache used for profile loading and reload when requested again
  51857. */
  51858. static ClearProfilesCache(): void;
  51859. /**
  51860. * Register the default fallbacks.
  51861. * This function is called automatically when this file is imported.
  51862. */
  51863. static DefaultFallbacks(): void;
  51864. /**
  51865. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  51866. * @param profileId the profile to which a fallback needs to be found
  51867. * @return an array with corresponding fallback profiles
  51868. */
  51869. static FindFallbackWithProfileId(profileId: string): string[];
  51870. /**
  51871. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  51872. * The order of search:
  51873. *
  51874. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  51875. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  51876. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  51877. * 4) return the generic trigger controller if none were found
  51878. *
  51879. * @param xrInput the xrInput to which a new controller is initialized
  51880. * @param scene the scene to which the model will be added
  51881. * @param forceProfile force a certain profile for this controller
  51882. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  51883. */
  51884. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  51885. /**
  51886. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  51887. *
  51888. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  51889. *
  51890. * @param type the profile type to register
  51891. * @param constructFunction the function to be called when loading this profile
  51892. */
  51893. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  51894. /**
  51895. * Register a fallback to a specific profile.
  51896. * @param profileId the profileId that will receive the fallbacks
  51897. * @param fallbacks A list of fallback profiles
  51898. */
  51899. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  51900. /**
  51901. * Will update the list of profiles available in the repository
  51902. * @return a promise that resolves to a map of profiles available online
  51903. */
  51904. static UpdateProfilesList(): Promise<{
  51905. [profile: string]: string;
  51906. }>;
  51907. private static _LoadProfileFromRepository;
  51908. private static _LoadProfilesFromAvailableControllers;
  51909. }
  51910. }
  51911. declare module BABYLON {
  51912. /**
  51913. * Configuration options for the WebXR controller creation
  51914. */
  51915. export interface IWebXRControllerOptions {
  51916. /**
  51917. * Should the controller mesh be animated when a user interacts with it
  51918. * The pressed buttons / thumbstick and touchpad animations will be disabled
  51919. */
  51920. disableMotionControllerAnimation?: boolean;
  51921. /**
  51922. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  51923. */
  51924. doNotLoadControllerMesh?: boolean;
  51925. /**
  51926. * Force a specific controller type for this controller.
  51927. * This can be used when creating your own profile or when testing different controllers
  51928. */
  51929. forceControllerProfile?: string;
  51930. /**
  51931. * Defines a rendering group ID for meshes that will be loaded.
  51932. * This is for the default controllers only.
  51933. */
  51934. renderingGroupId?: number;
  51935. }
  51936. /**
  51937. * Represents an XR controller
  51938. */
  51939. export class WebXRInputSource {
  51940. private _scene;
  51941. /** The underlying input source for the controller */
  51942. inputSource: XRInputSource;
  51943. private _options;
  51944. private _tmpVector;
  51945. private _uniqueId;
  51946. private _disposed;
  51947. /**
  51948. * 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
  51949. */
  51950. grip?: AbstractMesh;
  51951. /**
  51952. * If available, this is the gamepad object related to this controller.
  51953. * Using this object it is possible to get click events and trackpad changes of the
  51954. * webxr controller that is currently being used.
  51955. */
  51956. motionController?: WebXRAbstractMotionController;
  51957. /**
  51958. * Event that fires when the controller is removed/disposed.
  51959. * The object provided as event data is this controller, after associated assets were disposed.
  51960. * uniqueId is still available.
  51961. */
  51962. onDisposeObservable: Observable<WebXRInputSource>;
  51963. /**
  51964. * Will be triggered when the mesh associated with the motion controller is done loading.
  51965. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  51966. * A shortened version of controller -> motion controller -> on mesh loaded.
  51967. */
  51968. onMeshLoadedObservable: Observable<AbstractMesh>;
  51969. /**
  51970. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  51971. */
  51972. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  51973. /**
  51974. * Pointer which can be used to select objects or attach a visible laser to
  51975. */
  51976. pointer: AbstractMesh;
  51977. /**
  51978. * Creates the input source object
  51979. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  51980. * @param _scene the scene which the controller should be associated to
  51981. * @param inputSource the underlying input source for the controller
  51982. * @param _options options for this controller creation
  51983. */
  51984. constructor(_scene: Scene,
  51985. /** The underlying input source for the controller */
  51986. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  51987. /**
  51988. * Get this controllers unique id
  51989. */
  51990. get uniqueId(): string;
  51991. /**
  51992. * Disposes of the object
  51993. */
  51994. dispose(): void;
  51995. /**
  51996. * Gets a world space ray coming from the pointer or grip
  51997. * @param result the resulting ray
  51998. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  51999. */
  52000. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  52001. /**
  52002. * Updates the controller pose based on the given XRFrame
  52003. * @param xrFrame xr frame to update the pose with
  52004. * @param referenceSpace reference space to use
  52005. */
  52006. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  52007. }
  52008. }
  52009. declare module BABYLON {
  52010. /**
  52011. * The schema for initialization options of the XR Input class
  52012. */
  52013. export interface IWebXRInputOptions {
  52014. /**
  52015. * If set to true no model will be automatically loaded
  52016. */
  52017. doNotLoadControllerMeshes?: boolean;
  52018. /**
  52019. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  52020. * If not found, the xr input profile data will be used.
  52021. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  52022. */
  52023. forceInputProfile?: string;
  52024. /**
  52025. * Do not send a request to the controller repository to load the profile.
  52026. *
  52027. * Instead, use the controllers available in babylon itself.
  52028. */
  52029. disableOnlineControllerRepository?: boolean;
  52030. /**
  52031. * A custom URL for the controllers repository
  52032. */
  52033. customControllersRepositoryURL?: string;
  52034. /**
  52035. * Should the controller model's components not move according to the user input
  52036. */
  52037. disableControllerAnimation?: boolean;
  52038. /**
  52039. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  52040. */
  52041. controllerOptions?: IWebXRControllerOptions;
  52042. }
  52043. /**
  52044. * XR input used to track XR inputs such as controllers/rays
  52045. */
  52046. export class WebXRInput implements IDisposable {
  52047. /**
  52048. * the xr session manager for this session
  52049. */
  52050. xrSessionManager: WebXRSessionManager;
  52051. /**
  52052. * the WebXR camera for this session. Mainly used for teleportation
  52053. */
  52054. xrCamera: WebXRCamera;
  52055. private readonly options;
  52056. /**
  52057. * XR controllers being tracked
  52058. */
  52059. controllers: Array<WebXRInputSource>;
  52060. private _frameObserver;
  52061. private _sessionEndedObserver;
  52062. private _sessionInitObserver;
  52063. /**
  52064. * Event when a controller has been connected/added
  52065. */
  52066. onControllerAddedObservable: Observable<WebXRInputSource>;
  52067. /**
  52068. * Event when a controller has been removed/disconnected
  52069. */
  52070. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52071. /**
  52072. * Initializes the WebXRInput
  52073. * @param xrSessionManager the xr session manager for this session
  52074. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52075. * @param options = initialization options for this xr input
  52076. */
  52077. constructor(
  52078. /**
  52079. * the xr session manager for this session
  52080. */
  52081. xrSessionManager: WebXRSessionManager,
  52082. /**
  52083. * the WebXR camera for this session. Mainly used for teleportation
  52084. */
  52085. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  52086. private _onInputSourcesChange;
  52087. private _addAndRemoveControllers;
  52088. /**
  52089. * Disposes of the object
  52090. */
  52091. dispose(): void;
  52092. }
  52093. }
  52094. declare module BABYLON {
  52095. /**
  52096. * This is the base class for all WebXR features.
  52097. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52098. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52099. */
  52100. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52101. protected _xrSessionManager: WebXRSessionManager;
  52102. private _attached;
  52103. private _removeOnDetach;
  52104. /**
  52105. * Is this feature disposed?
  52106. */
  52107. isDisposed: boolean;
  52108. /**
  52109. * Should auto-attach be disabled?
  52110. */
  52111. disableAutoAttach: boolean;
  52112. /**
  52113. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52114. */
  52115. xrNativeFeatureName: string;
  52116. /**
  52117. * Construct a new (abstract) WebXR feature
  52118. * @param _xrSessionManager the xr session manager for this feature
  52119. */
  52120. constructor(_xrSessionManager: WebXRSessionManager);
  52121. /**
  52122. * Is this feature attached
  52123. */
  52124. get attached(): boolean;
  52125. /**
  52126. * attach this feature
  52127. *
  52128. * @param force should attachment be forced (even when already attached)
  52129. * @returns true if successful, false is failed or already attached
  52130. */
  52131. attach(force?: boolean): boolean;
  52132. /**
  52133. * detach this feature.
  52134. *
  52135. * @returns true if successful, false if failed or already detached
  52136. */
  52137. detach(): boolean;
  52138. /**
  52139. * Dispose this feature and all of the resources attached
  52140. */
  52141. dispose(): void;
  52142. /**
  52143. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52144. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52145. *
  52146. * @returns whether or not the feature is compatible in this environment
  52147. */
  52148. isCompatible(): boolean;
  52149. /**
  52150. * This is used to register callbacks that will automatically be removed when detach is called.
  52151. * @param observable the observable to which the observer will be attached
  52152. * @param callback the callback to register
  52153. */
  52154. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52155. /**
  52156. * Code in this function will be executed on each xrFrame received from the browser.
  52157. * This function will not execute after the feature is detached.
  52158. * @param _xrFrame the current frame
  52159. */
  52160. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52161. }
  52162. }
  52163. declare module BABYLON {
  52164. /**
  52165. * Renders a layer on top of an existing scene
  52166. */
  52167. export class UtilityLayerRenderer implements IDisposable {
  52168. /** the original scene that will be rendered on top of */
  52169. originalScene: Scene;
  52170. private _pointerCaptures;
  52171. private _lastPointerEvents;
  52172. private static _DefaultUtilityLayer;
  52173. private static _DefaultKeepDepthUtilityLayer;
  52174. private _sharedGizmoLight;
  52175. private _renderCamera;
  52176. /**
  52177. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52178. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52179. * @returns the camera that is used when rendering the utility layer
  52180. */
  52181. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52182. /**
  52183. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52184. * @param cam the camera that should be used when rendering the utility layer
  52185. */
  52186. setRenderCamera(cam: Nullable<Camera>): void;
  52187. /**
  52188. * @hidden
  52189. * Light which used by gizmos to get light shading
  52190. */
  52191. _getSharedGizmoLight(): HemisphericLight;
  52192. /**
  52193. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52194. */
  52195. pickUtilitySceneFirst: boolean;
  52196. /**
  52197. * 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)
  52198. */
  52199. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52200. /**
  52201. * 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)
  52202. */
  52203. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52204. /**
  52205. * The scene that is rendered on top of the original scene
  52206. */
  52207. utilityLayerScene: Scene;
  52208. /**
  52209. * If the utility layer should automatically be rendered on top of existing scene
  52210. */
  52211. shouldRender: boolean;
  52212. /**
  52213. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52214. */
  52215. onlyCheckPointerDownEvents: boolean;
  52216. /**
  52217. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52218. */
  52219. processAllEvents: boolean;
  52220. /**
  52221. * Observable raised when the pointer move from the utility layer scene to the main scene
  52222. */
  52223. onPointerOutObservable: Observable<number>;
  52224. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52225. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52226. private _afterRenderObserver;
  52227. private _sceneDisposeObserver;
  52228. private _originalPointerObserver;
  52229. /**
  52230. * Instantiates a UtilityLayerRenderer
  52231. * @param originalScene the original scene that will be rendered on top of
  52232. * @param handleEvents boolean indicating if the utility layer should handle events
  52233. */
  52234. constructor(
  52235. /** the original scene that will be rendered on top of */
  52236. originalScene: Scene, handleEvents?: boolean);
  52237. private _notifyObservers;
  52238. /**
  52239. * Renders the utility layers scene on top of the original scene
  52240. */
  52241. render(): void;
  52242. /**
  52243. * Disposes of the renderer
  52244. */
  52245. dispose(): void;
  52246. private _updateCamera;
  52247. }
  52248. }
  52249. declare module BABYLON {
  52250. /**
  52251. * Options interface for the pointer selection module
  52252. */
  52253. export interface IWebXRControllerPointerSelectionOptions {
  52254. /**
  52255. * if provided, this scene will be used to render meshes.
  52256. */
  52257. customUtilityLayerScene?: Scene;
  52258. /**
  52259. * 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)
  52260. * If not disabled, the last picked point will be used to execute a pointer up event
  52261. * If disabled, pointer up event will be triggered right after the pointer down event.
  52262. * Used in screen and gaze target ray mode only
  52263. */
  52264. disablePointerUpOnTouchOut: boolean;
  52265. /**
  52266. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52267. */
  52268. forceGazeMode: boolean;
  52269. /**
  52270. * 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
  52271. * to start a new countdown to the pointer down event.
  52272. * Defaults to 1.
  52273. */
  52274. gazeModePointerMovedFactor?: number;
  52275. /**
  52276. * Different button type to use instead of the main component
  52277. */
  52278. overrideButtonId?: string;
  52279. /**
  52280. * use this rendering group id for the meshes (optional)
  52281. */
  52282. renderingGroupId?: number;
  52283. /**
  52284. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52285. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52286. * 3000 means 3 seconds between pointing at something and selecting it
  52287. */
  52288. timeToSelect?: number;
  52289. /**
  52290. * Should meshes created here be added to a utility layer or the main scene
  52291. */
  52292. useUtilityLayer?: boolean;
  52293. /**
  52294. * Optional WebXR camera to be used for gaze selection
  52295. */
  52296. gazeCamera?: WebXRCamera;
  52297. /**
  52298. * the xr input to use with this pointer selection
  52299. */
  52300. xrInput: WebXRInput;
  52301. /**
  52302. * Should the scene pointerX and pointerY update be disabled
  52303. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52304. * Disable in VR, if not needed.
  52305. * The first rig camera (left eye) will be used to calculate the projection
  52306. */
  52307. disableScenePointerVectorUpdate: boolean;
  52308. /**
  52309. * Enable pointer selection on all controllers instead of switching between them
  52310. */
  52311. enablePointerSelectionOnAllControllers?: boolean;
  52312. /**
  52313. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52314. * If switch is enabled, it will still allow the user to switch between the different controllers
  52315. */
  52316. preferredHandedness?: XRHandedness;
  52317. /**
  52318. * Disable switching the pointer selection from one controller to the other.
  52319. * 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
  52320. */
  52321. disableSwitchOnClick?: boolean;
  52322. /**
  52323. * The maximum distance of the pointer selection feature. Defaults to 100.
  52324. */
  52325. maxPointerDistance?: number;
  52326. }
  52327. /**
  52328. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52329. */
  52330. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52331. private readonly _options;
  52332. private static _idCounter;
  52333. private _attachController;
  52334. private _controllers;
  52335. private _scene;
  52336. private _tmpVectorForPickCompare;
  52337. private _attachedController;
  52338. /**
  52339. * The module's name
  52340. */
  52341. static readonly Name: string;
  52342. /**
  52343. * The (Babylon) version of this module.
  52344. * This is an integer representing the implementation version.
  52345. * This number does not correspond to the WebXR specs version
  52346. */
  52347. static readonly Version: number;
  52348. /**
  52349. * Disable lighting on the laser pointer (so it will always be visible)
  52350. */
  52351. disablePointerLighting: boolean;
  52352. /**
  52353. * Disable lighting on the selection mesh (so it will always be visible)
  52354. */
  52355. disableSelectionMeshLighting: boolean;
  52356. /**
  52357. * Should the laser pointer be displayed
  52358. */
  52359. displayLaserPointer: boolean;
  52360. /**
  52361. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52362. */
  52363. displaySelectionMesh: boolean;
  52364. /**
  52365. * This color will be set to the laser pointer when selection is triggered
  52366. */
  52367. laserPointerPickedColor: Color3;
  52368. /**
  52369. * Default color of the laser pointer
  52370. */
  52371. laserPointerDefaultColor: Color3;
  52372. /**
  52373. * default color of the selection ring
  52374. */
  52375. selectionMeshDefaultColor: Color3;
  52376. /**
  52377. * This color will be applied to the selection ring when selection is triggered
  52378. */
  52379. selectionMeshPickedColor: Color3;
  52380. /**
  52381. * Optional filter to be used for ray selection. This predicate shares behavior with
  52382. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52383. */
  52384. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52385. /**
  52386. * constructs a new background remover module
  52387. * @param _xrSessionManager the session manager for this module
  52388. * @param _options read-only options to be used in this module
  52389. */
  52390. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52391. /**
  52392. * attach this feature
  52393. * Will usually be called by the features manager
  52394. *
  52395. * @returns true if successful.
  52396. */
  52397. attach(): boolean;
  52398. /**
  52399. * detach this feature.
  52400. * Will usually be called by the features manager
  52401. *
  52402. * @returns true if successful.
  52403. */
  52404. detach(): boolean;
  52405. /**
  52406. * Will get the mesh under a specific pointer.
  52407. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52408. * @param controllerId the controllerId to check
  52409. * @returns The mesh under pointer or null if no mesh is under the pointer
  52410. */
  52411. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52412. /**
  52413. * Get the xr controller that correlates to the pointer id in the pointer event
  52414. *
  52415. * @param id the pointer id to search for
  52416. * @returns the controller that correlates to this id or null if not found
  52417. */
  52418. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52419. private _identityMatrix;
  52420. private _screenCoordinatesRef;
  52421. private _viewportRef;
  52422. protected _onXRFrame(_xrFrame: XRFrame): void;
  52423. private _attachGazeMode;
  52424. private _attachScreenRayMode;
  52425. private _attachTrackedPointerRayMode;
  52426. private _convertNormalToDirectionOfRay;
  52427. private _detachController;
  52428. private _generateNewMeshPair;
  52429. private _pickingMoved;
  52430. private _updatePointerDistance;
  52431. /** @hidden */
  52432. get lasterPointerDefaultColor(): Color3;
  52433. }
  52434. }
  52435. declare module BABYLON {
  52436. /**
  52437. * Button which can be used to enter a different mode of XR
  52438. */
  52439. export class WebXREnterExitUIButton {
  52440. /** button element */
  52441. element: HTMLElement;
  52442. /** XR initialization options for the button */
  52443. sessionMode: XRSessionMode;
  52444. /** Reference space type */
  52445. referenceSpaceType: XRReferenceSpaceType;
  52446. /**
  52447. * Creates a WebXREnterExitUIButton
  52448. * @param element button element
  52449. * @param sessionMode XR initialization session mode
  52450. * @param referenceSpaceType the type of reference space to be used
  52451. */
  52452. constructor(
  52453. /** button element */
  52454. element: HTMLElement,
  52455. /** XR initialization options for the button */
  52456. sessionMode: XRSessionMode,
  52457. /** Reference space type */
  52458. referenceSpaceType: XRReferenceSpaceType);
  52459. /**
  52460. * Extendable function which can be used to update the button's visuals when the state changes
  52461. * @param activeButton the current active button in the UI
  52462. */
  52463. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52464. }
  52465. /**
  52466. * Options to create the webXR UI
  52467. */
  52468. export class WebXREnterExitUIOptions {
  52469. /**
  52470. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52471. */
  52472. customButtons?: Array<WebXREnterExitUIButton>;
  52473. /**
  52474. * A reference space type to use when creating the default button.
  52475. * Default is local-floor
  52476. */
  52477. referenceSpaceType?: XRReferenceSpaceType;
  52478. /**
  52479. * Context to enter xr with
  52480. */
  52481. renderTarget?: Nullable<WebXRRenderTarget>;
  52482. /**
  52483. * A session mode to use when creating the default button.
  52484. * Default is immersive-vr
  52485. */
  52486. sessionMode?: XRSessionMode;
  52487. /**
  52488. * A list of optional features to init the session with
  52489. */
  52490. optionalFeatures?: string[];
  52491. /**
  52492. * A list of optional features to init the session with
  52493. */
  52494. requiredFeatures?: string[];
  52495. /**
  52496. * If defined, this function will be executed if the UI encounters an error when entering XR
  52497. */
  52498. onError?: (error: any) => void;
  52499. }
  52500. /**
  52501. * UI to allow the user to enter/exit XR mode
  52502. */
  52503. export class WebXREnterExitUI implements IDisposable {
  52504. private scene;
  52505. /** version of the options passed to this UI */
  52506. options: WebXREnterExitUIOptions;
  52507. private _activeButton;
  52508. private _buttons;
  52509. /**
  52510. * The HTML Div Element to which buttons are added.
  52511. */
  52512. readonly overlay: HTMLDivElement;
  52513. /**
  52514. * Fired every time the active button is changed.
  52515. *
  52516. * When xr is entered via a button that launches xr that button will be the callback parameter
  52517. *
  52518. * When exiting xr the callback parameter will be null)
  52519. */
  52520. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52521. /**
  52522. *
  52523. * @param scene babylon scene object to use
  52524. * @param options (read-only) version of the options passed to this UI
  52525. */
  52526. private constructor();
  52527. /**
  52528. * Creates UI to allow the user to enter/exit XR mode
  52529. * @param scene the scene to add the ui to
  52530. * @param helper the xr experience helper to enter/exit xr with
  52531. * @param options options to configure the UI
  52532. * @returns the created ui
  52533. */
  52534. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52535. /**
  52536. * Disposes of the XR UI component
  52537. */
  52538. dispose(): void;
  52539. private _updateButtons;
  52540. }
  52541. }
  52542. declare module BABYLON {
  52543. /**
  52544. * Class containing static functions to help procedurally build meshes
  52545. */
  52546. export class LinesBuilder {
  52547. /**
  52548. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52549. * * 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
  52550. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52551. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52552. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52553. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52554. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52555. * * 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
  52556. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52558. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52559. * @param name defines the name of the new line system
  52560. * @param options defines the options used to create the line system
  52561. * @param scene defines the hosting scene
  52562. * @returns a new line system mesh
  52563. */
  52564. static CreateLineSystem(name: string, options: {
  52565. lines: Vector3[][];
  52566. updatable?: boolean;
  52567. instance?: Nullable<LinesMesh>;
  52568. colors?: Nullable<Color4[][]>;
  52569. useVertexAlpha?: boolean;
  52570. }, scene: Nullable<Scene>): LinesMesh;
  52571. /**
  52572. * Creates a line mesh
  52573. * 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
  52574. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52575. * * The parameter `points` is an array successive Vector3
  52576. * * 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
  52577. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52578. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52579. * * When updating an instance, remember that only point positions can change, not the number of points
  52580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52581. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52582. * @param name defines the name of the new line system
  52583. * @param options defines the options used to create the line system
  52584. * @param scene defines the hosting scene
  52585. * @returns a new line mesh
  52586. */
  52587. static CreateLines(name: string, options: {
  52588. points: Vector3[];
  52589. updatable?: boolean;
  52590. instance?: Nullable<LinesMesh>;
  52591. colors?: Color4[];
  52592. useVertexAlpha?: boolean;
  52593. }, scene?: Nullable<Scene>): LinesMesh;
  52594. /**
  52595. * Creates a dashed line mesh
  52596. * * 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
  52597. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52598. * * The parameter `points` is an array successive Vector3
  52599. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52600. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52601. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52602. * * 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
  52603. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52604. * * When updating an instance, remember that only point positions can change, not the number of points
  52605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52606. * @param name defines the name of the mesh
  52607. * @param options defines the options used to create the mesh
  52608. * @param scene defines the hosting scene
  52609. * @returns the dashed line mesh
  52610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52611. */
  52612. static CreateDashedLines(name: string, options: {
  52613. points: Vector3[];
  52614. dashSize?: number;
  52615. gapSize?: number;
  52616. dashNb?: number;
  52617. updatable?: boolean;
  52618. instance?: LinesMesh;
  52619. useVertexAlpha?: boolean;
  52620. }, scene?: Nullable<Scene>): LinesMesh;
  52621. }
  52622. }
  52623. declare module BABYLON {
  52624. /**
  52625. * Construction options for a timer
  52626. */
  52627. export interface ITimerOptions<T> {
  52628. /**
  52629. * Time-to-end
  52630. */
  52631. timeout: number;
  52632. /**
  52633. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52634. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52635. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52636. */
  52637. contextObservable: Observable<T>;
  52638. /**
  52639. * Optional parameters when adding an observer to the observable
  52640. */
  52641. observableParameters?: {
  52642. mask?: number;
  52643. insertFirst?: boolean;
  52644. scope?: any;
  52645. };
  52646. /**
  52647. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52648. */
  52649. breakCondition?: (data?: ITimerData<T>) => boolean;
  52650. /**
  52651. * Will be triggered when the time condition has met
  52652. */
  52653. onEnded?: (data: ITimerData<any>) => void;
  52654. /**
  52655. * Will be triggered when the break condition has met (prematurely ended)
  52656. */
  52657. onAborted?: (data: ITimerData<any>) => void;
  52658. /**
  52659. * Optional function to execute on each tick (or count)
  52660. */
  52661. onTick?: (data: ITimerData<any>) => void;
  52662. }
  52663. /**
  52664. * An interface defining the data sent by the timer
  52665. */
  52666. export interface ITimerData<T> {
  52667. /**
  52668. * When did it start
  52669. */
  52670. startTime: number;
  52671. /**
  52672. * Time now
  52673. */
  52674. currentTime: number;
  52675. /**
  52676. * Time passed since started
  52677. */
  52678. deltaTime: number;
  52679. /**
  52680. * How much is completed, in [0.0...1.0].
  52681. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52682. */
  52683. completeRate: number;
  52684. /**
  52685. * What the registered observable sent in the last count
  52686. */
  52687. payload: T;
  52688. }
  52689. /**
  52690. * The current state of the timer
  52691. */
  52692. export enum TimerState {
  52693. /**
  52694. * Timer initialized, not yet started
  52695. */
  52696. INIT = 0,
  52697. /**
  52698. * Timer started and counting
  52699. */
  52700. STARTED = 1,
  52701. /**
  52702. * Timer ended (whether aborted or time reached)
  52703. */
  52704. ENDED = 2
  52705. }
  52706. /**
  52707. * A simple version of the timer. Will take options and start the timer immediately after calling it
  52708. *
  52709. * @param options options with which to initialize this timer
  52710. */
  52711. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  52712. /**
  52713. * An advanced implementation of a timer class
  52714. */
  52715. export class AdvancedTimer<T = any> implements IDisposable {
  52716. /**
  52717. * Will notify each time the timer calculates the remaining time
  52718. */
  52719. onEachCountObservable: Observable<ITimerData<T>>;
  52720. /**
  52721. * Will trigger when the timer was aborted due to the break condition
  52722. */
  52723. onTimerAbortedObservable: Observable<ITimerData<T>>;
  52724. /**
  52725. * Will trigger when the timer ended successfully
  52726. */
  52727. onTimerEndedObservable: Observable<ITimerData<T>>;
  52728. /**
  52729. * Will trigger when the timer state has changed
  52730. */
  52731. onStateChangedObservable: Observable<TimerState>;
  52732. private _observer;
  52733. private _contextObservable;
  52734. private _observableParameters;
  52735. private _startTime;
  52736. private _timer;
  52737. private _state;
  52738. private _breakCondition;
  52739. private _timeToEnd;
  52740. private _breakOnNextTick;
  52741. /**
  52742. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  52743. * @param options construction options for this advanced timer
  52744. */
  52745. constructor(options: ITimerOptions<T>);
  52746. /**
  52747. * set a breaking condition for this timer. Default is to never break during count
  52748. * @param predicate the new break condition. Returns true to break, false otherwise
  52749. */
  52750. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  52751. /**
  52752. * Reset ALL associated observables in this advanced timer
  52753. */
  52754. clearObservables(): void;
  52755. /**
  52756. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  52757. *
  52758. * @param timeToEnd how much time to measure until timer ended
  52759. */
  52760. start(timeToEnd?: number): void;
  52761. /**
  52762. * Will force a stop on the next tick.
  52763. */
  52764. stop(): void;
  52765. /**
  52766. * Dispose this timer, clearing all resources
  52767. */
  52768. dispose(): void;
  52769. private _setState;
  52770. private _tick;
  52771. private _stop;
  52772. }
  52773. }
  52774. declare module BABYLON {
  52775. /**
  52776. * The options container for the teleportation module
  52777. */
  52778. export interface IWebXRTeleportationOptions {
  52779. /**
  52780. * if provided, this scene will be used to render meshes.
  52781. */
  52782. customUtilityLayerScene?: Scene;
  52783. /**
  52784. * Values to configure the default target mesh
  52785. */
  52786. defaultTargetMeshOptions?: {
  52787. /**
  52788. * Fill color of the teleportation area
  52789. */
  52790. teleportationFillColor?: string;
  52791. /**
  52792. * Border color for the teleportation area
  52793. */
  52794. teleportationBorderColor?: string;
  52795. /**
  52796. * Disable the mesh's animation sequence
  52797. */
  52798. disableAnimation?: boolean;
  52799. /**
  52800. * Disable lighting on the material or the ring and arrow
  52801. */
  52802. disableLighting?: boolean;
  52803. /**
  52804. * Override the default material of the torus and arrow
  52805. */
  52806. torusArrowMaterial?: Material;
  52807. };
  52808. /**
  52809. * A list of meshes to use as floor meshes.
  52810. * Meshes can be added and removed after initializing the feature using the
  52811. * addFloorMesh and removeFloorMesh functions
  52812. * If empty, rotation will still work
  52813. */
  52814. floorMeshes?: AbstractMesh[];
  52815. /**
  52816. * use this rendering group id for the meshes (optional)
  52817. */
  52818. renderingGroupId?: number;
  52819. /**
  52820. * Should teleportation move only to snap points
  52821. */
  52822. snapPointsOnly?: boolean;
  52823. /**
  52824. * An array of points to which the teleportation will snap to.
  52825. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  52826. */
  52827. snapPositions?: Vector3[];
  52828. /**
  52829. * How close should the teleportation ray be in order to snap to position.
  52830. * Default to 0.8 units (meters)
  52831. */
  52832. snapToPositionRadius?: number;
  52833. /**
  52834. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  52835. * If you want to support rotation, make sure your mesh has a direction indicator.
  52836. *
  52837. * When left untouched, the default mesh will be initialized.
  52838. */
  52839. teleportationTargetMesh?: AbstractMesh;
  52840. /**
  52841. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  52842. */
  52843. timeToTeleport?: number;
  52844. /**
  52845. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  52846. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  52847. */
  52848. useMainComponentOnly?: boolean;
  52849. /**
  52850. * Should meshes created here be added to a utility layer or the main scene
  52851. */
  52852. useUtilityLayer?: boolean;
  52853. /**
  52854. * Babylon XR Input class for controller
  52855. */
  52856. xrInput: WebXRInput;
  52857. /**
  52858. * Meshes that the teleportation ray cannot go through
  52859. */
  52860. pickBlockerMeshes?: AbstractMesh[];
  52861. }
  52862. /**
  52863. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  52864. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  52865. * the input of the attached controllers.
  52866. */
  52867. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  52868. private _options;
  52869. private _controllers;
  52870. private _currentTeleportationControllerId;
  52871. private _floorMeshes;
  52872. private _quadraticBezierCurve;
  52873. private _selectionFeature;
  52874. private _snapToPositions;
  52875. private _snappedToPoint;
  52876. private _teleportationRingMaterial?;
  52877. private _tmpRay;
  52878. private _tmpVector;
  52879. private _tmpQuaternion;
  52880. /**
  52881. * The module's name
  52882. */
  52883. static readonly Name: string;
  52884. /**
  52885. * The (Babylon) version of this module.
  52886. * This is an integer representing the implementation version.
  52887. * This number does not correspond to the webxr specs version
  52888. */
  52889. static readonly Version: number;
  52890. /**
  52891. * Is movement backwards enabled
  52892. */
  52893. backwardsMovementEnabled: boolean;
  52894. /**
  52895. * Distance to travel when moving backwards
  52896. */
  52897. backwardsTeleportationDistance: number;
  52898. /**
  52899. * The distance from the user to the inspection point in the direction of the controller
  52900. * A higher number will allow the user to move further
  52901. * defaults to 5 (meters, in xr units)
  52902. */
  52903. parabolicCheckRadius: number;
  52904. /**
  52905. * Should the module support parabolic ray on top of direct ray
  52906. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  52907. * Very helpful when moving between floors / different heights
  52908. */
  52909. parabolicRayEnabled: boolean;
  52910. /**
  52911. * How much rotation should be applied when rotating right and left
  52912. */
  52913. rotationAngle: number;
  52914. /**
  52915. * Is rotation enabled when moving forward?
  52916. * Disabling this feature will prevent the user from deciding the direction when teleporting
  52917. */
  52918. rotationEnabled: boolean;
  52919. /**
  52920. * constructs a new anchor system
  52921. * @param _xrSessionManager an instance of WebXRSessionManager
  52922. * @param _options configuration object for this feature
  52923. */
  52924. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  52925. /**
  52926. * Get the snapPointsOnly flag
  52927. */
  52928. get snapPointsOnly(): boolean;
  52929. /**
  52930. * Sets the snapPointsOnly flag
  52931. * @param snapToPoints should teleportation be exclusively to snap points
  52932. */
  52933. set snapPointsOnly(snapToPoints: boolean);
  52934. /**
  52935. * Add a new mesh to the floor meshes array
  52936. * @param mesh the mesh to use as floor mesh
  52937. */
  52938. addFloorMesh(mesh: AbstractMesh): void;
  52939. /**
  52940. * Add a new snap-to point to fix teleportation to this position
  52941. * @param newSnapPoint The new Snap-To point
  52942. */
  52943. addSnapPoint(newSnapPoint: Vector3): void;
  52944. attach(): boolean;
  52945. detach(): boolean;
  52946. dispose(): void;
  52947. /**
  52948. * Remove a mesh from the floor meshes array
  52949. * @param mesh the mesh to remove
  52950. */
  52951. removeFloorMesh(mesh: AbstractMesh): void;
  52952. /**
  52953. * Remove a mesh from the floor meshes array using its name
  52954. * @param name the mesh name to remove
  52955. */
  52956. removeFloorMeshByName(name: string): void;
  52957. /**
  52958. * 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
  52959. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  52960. * @returns was the point found and removed or not
  52961. */
  52962. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  52963. /**
  52964. * This function sets a selection feature that will be disabled when
  52965. * the forward ray is shown and will be reattached when hidden.
  52966. * This is used to remove the selection rays when moving.
  52967. * @param selectionFeature the feature to disable when forward movement is enabled
  52968. */
  52969. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  52970. protected _onXRFrame(_xrFrame: XRFrame): void;
  52971. private _attachController;
  52972. private _createDefaultTargetMesh;
  52973. private _detachController;
  52974. private _findClosestSnapPointWithRadius;
  52975. private _setTargetMeshPosition;
  52976. private _setTargetMeshVisibility;
  52977. private _showParabolicPath;
  52978. private _teleportForward;
  52979. }
  52980. }
  52981. declare module BABYLON {
  52982. /**
  52983. * Options for the default xr helper
  52984. */
  52985. export class WebXRDefaultExperienceOptions {
  52986. /**
  52987. * Enable or disable default UI to enter XR
  52988. */
  52989. disableDefaultUI?: boolean;
  52990. /**
  52991. * Should teleportation not initialize. defaults to false.
  52992. */
  52993. disableTeleportation?: boolean;
  52994. /**
  52995. * Floor meshes that will be used for teleport
  52996. */
  52997. floorMeshes?: Array<AbstractMesh>;
  52998. /**
  52999. * If set to true, the first frame will not be used to reset position
  53000. * The first frame is mainly used when copying transformation from the old camera
  53001. * Mainly used in AR
  53002. */
  53003. ignoreNativeCameraTransformation?: boolean;
  53004. /**
  53005. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  53006. */
  53007. inputOptions?: IWebXRInputOptions;
  53008. /**
  53009. * optional configuration for the output canvas
  53010. */
  53011. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  53012. /**
  53013. * optional UI options. This can be used among other to change session mode and reference space type
  53014. */
  53015. uiOptions?: WebXREnterExitUIOptions;
  53016. /**
  53017. * When loading teleportation and pointer select, use stable versions instead of latest.
  53018. */
  53019. useStablePlugins?: boolean;
  53020. /**
  53021. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  53022. */
  53023. renderingGroupId?: number;
  53024. /**
  53025. * A list of optional features to init the session with
  53026. * If set to true, all features we support will be added
  53027. */
  53028. optionalFeatures?: boolean | string[];
  53029. }
  53030. /**
  53031. * Default experience which provides a similar setup to the previous webVRExperience
  53032. */
  53033. export class WebXRDefaultExperience {
  53034. /**
  53035. * Base experience
  53036. */
  53037. baseExperience: WebXRExperienceHelper;
  53038. /**
  53039. * Enables ui for entering/exiting xr
  53040. */
  53041. enterExitUI: WebXREnterExitUI;
  53042. /**
  53043. * Input experience extension
  53044. */
  53045. input: WebXRInput;
  53046. /**
  53047. * Enables laser pointer and selection
  53048. */
  53049. pointerSelection: WebXRControllerPointerSelection;
  53050. /**
  53051. * Default target xr should render to
  53052. */
  53053. renderTarget: WebXRRenderTarget;
  53054. /**
  53055. * Enables teleportation
  53056. */
  53057. teleportation: WebXRMotionControllerTeleportation;
  53058. private constructor();
  53059. /**
  53060. * Creates the default xr experience
  53061. * @param scene scene
  53062. * @param options options for basic configuration
  53063. * @returns resulting WebXRDefaultExperience
  53064. */
  53065. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53066. /**
  53067. * DIsposes of the experience helper
  53068. */
  53069. dispose(): void;
  53070. }
  53071. }
  53072. declare module BABYLON {
  53073. /**
  53074. * Options to modify the vr teleportation behavior.
  53075. */
  53076. export interface VRTeleportationOptions {
  53077. /**
  53078. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53079. */
  53080. floorMeshName?: string;
  53081. /**
  53082. * A list of meshes to be used as the teleportation floor. (default: empty)
  53083. */
  53084. floorMeshes?: Mesh[];
  53085. /**
  53086. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53087. */
  53088. teleportationMode?: number;
  53089. /**
  53090. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53091. */
  53092. teleportationTime?: number;
  53093. /**
  53094. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53095. */
  53096. teleportationSpeed?: number;
  53097. /**
  53098. * The easing function used in the animation or null for Linear. (default CircleEase)
  53099. */
  53100. easingFunction?: EasingFunction;
  53101. }
  53102. /**
  53103. * Options to modify the vr experience helper's behavior.
  53104. */
  53105. export interface VRExperienceHelperOptions extends WebVROptions {
  53106. /**
  53107. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53108. */
  53109. createDeviceOrientationCamera?: boolean;
  53110. /**
  53111. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53112. */
  53113. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53114. /**
  53115. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53116. */
  53117. laserToggle?: boolean;
  53118. /**
  53119. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53120. */
  53121. floorMeshes?: Mesh[];
  53122. /**
  53123. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53124. */
  53125. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53126. /**
  53127. * Defines if WebXR should be used instead of WebVR (if available)
  53128. */
  53129. useXR?: boolean;
  53130. }
  53131. /**
  53132. * Event containing information after VR has been entered
  53133. */
  53134. export class OnAfterEnteringVRObservableEvent {
  53135. /**
  53136. * If entering vr was successful
  53137. */
  53138. success: boolean;
  53139. }
  53140. /**
  53141. * Helps to quickly add VR support to an existing scene.
  53142. * See https://doc.babylonjs.com/how_to/webvr_helper
  53143. */
  53144. export class VRExperienceHelper {
  53145. /** Options to modify the vr experience helper's behavior. */
  53146. webVROptions: VRExperienceHelperOptions;
  53147. private _scene;
  53148. private _position;
  53149. private _btnVR;
  53150. private _btnVRDisplayed;
  53151. private _webVRsupported;
  53152. private _webVRready;
  53153. private _webVRrequesting;
  53154. private _webVRpresenting;
  53155. private _hasEnteredVR;
  53156. private _fullscreenVRpresenting;
  53157. private _inputElement;
  53158. private _webVRCamera;
  53159. private _vrDeviceOrientationCamera;
  53160. private _deviceOrientationCamera;
  53161. private _existingCamera;
  53162. private _onKeyDown;
  53163. private _onVrDisplayPresentChange;
  53164. private _onVRDisplayChanged;
  53165. private _onVRRequestPresentStart;
  53166. private _onVRRequestPresentComplete;
  53167. /**
  53168. * 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)
  53169. */
  53170. enableGazeEvenWhenNoPointerLock: boolean;
  53171. /**
  53172. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53173. */
  53174. exitVROnDoubleTap: boolean;
  53175. /**
  53176. * Observable raised right before entering VR.
  53177. */
  53178. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53179. /**
  53180. * Observable raised when entering VR has completed.
  53181. */
  53182. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53183. /**
  53184. * Observable raised when exiting VR.
  53185. */
  53186. onExitingVRObservable: Observable<VRExperienceHelper>;
  53187. /**
  53188. * Observable raised when controller mesh is loaded.
  53189. */
  53190. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53191. /** Return this.onEnteringVRObservable
  53192. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53193. */
  53194. get onEnteringVR(): Observable<VRExperienceHelper>;
  53195. /** Return this.onExitingVRObservable
  53196. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53197. */
  53198. get onExitingVR(): Observable<VRExperienceHelper>;
  53199. /** Return this.onControllerMeshLoadedObservable
  53200. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53201. */
  53202. get onControllerMeshLoaded(): Observable<WebVRController>;
  53203. private _rayLength;
  53204. private _useCustomVRButton;
  53205. private _teleportationRequested;
  53206. private _teleportActive;
  53207. private _floorMeshName;
  53208. private _floorMeshesCollection;
  53209. private _teleportationMode;
  53210. private _teleportationTime;
  53211. private _teleportationSpeed;
  53212. private _teleportationEasing;
  53213. private _rotationAllowed;
  53214. private _teleportBackwardsVector;
  53215. private _teleportationTarget;
  53216. private _isDefaultTeleportationTarget;
  53217. private _postProcessMove;
  53218. private _teleportationFillColor;
  53219. private _teleportationBorderColor;
  53220. private _rotationAngle;
  53221. private _haloCenter;
  53222. private _cameraGazer;
  53223. private _padSensibilityUp;
  53224. private _padSensibilityDown;
  53225. private _leftController;
  53226. private _rightController;
  53227. private _gazeColor;
  53228. private _laserColor;
  53229. private _pickedLaserColor;
  53230. private _pickedGazeColor;
  53231. /**
  53232. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53233. */
  53234. onNewMeshSelected: Observable<AbstractMesh>;
  53235. /**
  53236. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53237. * This observable will provide the mesh and the controller used to select the mesh
  53238. */
  53239. onMeshSelectedWithController: Observable<{
  53240. mesh: AbstractMesh;
  53241. controller: WebVRController;
  53242. }>;
  53243. /**
  53244. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53245. */
  53246. onNewMeshPicked: Observable<PickingInfo>;
  53247. private _circleEase;
  53248. /**
  53249. * Observable raised before camera teleportation
  53250. */
  53251. onBeforeCameraTeleport: Observable<Vector3>;
  53252. /**
  53253. * Observable raised after camera teleportation
  53254. */
  53255. onAfterCameraTeleport: Observable<Vector3>;
  53256. /**
  53257. * Observable raised when current selected mesh gets unselected
  53258. */
  53259. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53260. private _raySelectionPredicate;
  53261. /**
  53262. * To be optionaly changed by user to define custom ray selection
  53263. */
  53264. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53265. /**
  53266. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53267. */
  53268. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53269. /**
  53270. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53271. */
  53272. teleportationEnabled: boolean;
  53273. private _defaultHeight;
  53274. private _teleportationInitialized;
  53275. private _interactionsEnabled;
  53276. private _interactionsRequested;
  53277. private _displayGaze;
  53278. private _displayLaserPointer;
  53279. /**
  53280. * The mesh used to display where the user is going to teleport.
  53281. */
  53282. get teleportationTarget(): Mesh;
  53283. /**
  53284. * Sets the mesh to be used to display where the user is going to teleport.
  53285. */
  53286. set teleportationTarget(value: Mesh);
  53287. /**
  53288. * 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
  53289. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53290. * See https://doc.babylonjs.com/resources/baking_transformations
  53291. */
  53292. get gazeTrackerMesh(): Mesh;
  53293. set gazeTrackerMesh(value: Mesh);
  53294. /**
  53295. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53296. */
  53297. updateGazeTrackerScale: boolean;
  53298. /**
  53299. * If the gaze trackers color should be updated when selecting meshes
  53300. */
  53301. updateGazeTrackerColor: boolean;
  53302. /**
  53303. * If the controller laser color should be updated when selecting meshes
  53304. */
  53305. updateControllerLaserColor: boolean;
  53306. /**
  53307. * The gaze tracking mesh corresponding to the left controller
  53308. */
  53309. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53310. /**
  53311. * The gaze tracking mesh corresponding to the right controller
  53312. */
  53313. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53314. /**
  53315. * If the ray of the gaze should be displayed.
  53316. */
  53317. get displayGaze(): boolean;
  53318. /**
  53319. * Sets if the ray of the gaze should be displayed.
  53320. */
  53321. set displayGaze(value: boolean);
  53322. /**
  53323. * If the ray of the LaserPointer should be displayed.
  53324. */
  53325. get displayLaserPointer(): boolean;
  53326. /**
  53327. * Sets if the ray of the LaserPointer should be displayed.
  53328. */
  53329. set displayLaserPointer(value: boolean);
  53330. /**
  53331. * The deviceOrientationCamera used as the camera when not in VR.
  53332. */
  53333. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53334. /**
  53335. * Based on the current WebVR support, returns the current VR camera used.
  53336. */
  53337. get currentVRCamera(): Nullable<Camera>;
  53338. /**
  53339. * The webVRCamera which is used when in VR.
  53340. */
  53341. get webVRCamera(): WebVRFreeCamera;
  53342. /**
  53343. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53344. */
  53345. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53346. /**
  53347. * The html button that is used to trigger entering into VR.
  53348. */
  53349. get vrButton(): Nullable<HTMLButtonElement>;
  53350. private get _teleportationRequestInitiated();
  53351. /**
  53352. * Defines whether or not Pointer lock should be requested when switching to
  53353. * full screen.
  53354. */
  53355. requestPointerLockOnFullScreen: boolean;
  53356. /**
  53357. * If asking to force XR, this will be populated with the default xr experience
  53358. */
  53359. xr: WebXRDefaultExperience;
  53360. /**
  53361. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53362. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53363. */
  53364. xrTestDone: boolean;
  53365. /**
  53366. * Instantiates a VRExperienceHelper.
  53367. * Helps to quickly add VR support to an existing scene.
  53368. * @param scene The scene the VRExperienceHelper belongs to.
  53369. * @param webVROptions Options to modify the vr experience helper's behavior.
  53370. */
  53371. constructor(scene: Scene,
  53372. /** Options to modify the vr experience helper's behavior. */
  53373. webVROptions?: VRExperienceHelperOptions);
  53374. private completeVRInit;
  53375. private _onDefaultMeshLoaded;
  53376. private _onResize;
  53377. private _onFullscreenChange;
  53378. /**
  53379. * Gets a value indicating if we are currently in VR mode.
  53380. */
  53381. get isInVRMode(): boolean;
  53382. private onVrDisplayPresentChange;
  53383. private onVRDisplayChanged;
  53384. private moveButtonToBottomRight;
  53385. private displayVRButton;
  53386. private updateButtonVisibility;
  53387. private _cachedAngularSensibility;
  53388. /**
  53389. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53390. * Otherwise, will use the fullscreen API.
  53391. */
  53392. enterVR(): void;
  53393. /**
  53394. * Attempt to exit VR, or fullscreen.
  53395. */
  53396. exitVR(): void;
  53397. /**
  53398. * The position of the vr experience helper.
  53399. */
  53400. get position(): Vector3;
  53401. /**
  53402. * Sets the position of the vr experience helper.
  53403. */
  53404. set position(value: Vector3);
  53405. /**
  53406. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53407. */
  53408. enableInteractions(): void;
  53409. private get _noControllerIsActive();
  53410. private beforeRender;
  53411. private _isTeleportationFloor;
  53412. /**
  53413. * Adds a floor mesh to be used for teleportation.
  53414. * @param floorMesh the mesh to be used for teleportation.
  53415. */
  53416. addFloorMesh(floorMesh: Mesh): void;
  53417. /**
  53418. * Removes a floor mesh from being used for teleportation.
  53419. * @param floorMesh the mesh to be removed.
  53420. */
  53421. removeFloorMesh(floorMesh: Mesh): void;
  53422. /**
  53423. * Enables interactions and teleportation using the VR controllers and gaze.
  53424. * @param vrTeleportationOptions options to modify teleportation behavior.
  53425. */
  53426. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53427. private _onNewGamepadConnected;
  53428. private _tryEnableInteractionOnController;
  53429. private _onNewGamepadDisconnected;
  53430. private _enableInteractionOnController;
  53431. private _checkTeleportWithRay;
  53432. private _checkRotate;
  53433. private _checkTeleportBackwards;
  53434. private _enableTeleportationOnController;
  53435. private _createTeleportationCircles;
  53436. private _displayTeleportationTarget;
  53437. private _hideTeleportationTarget;
  53438. private _rotateCamera;
  53439. private _moveTeleportationSelectorTo;
  53440. private _workingVector;
  53441. private _workingQuaternion;
  53442. private _workingMatrix;
  53443. /**
  53444. * Time Constant Teleportation Mode
  53445. */
  53446. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53447. /**
  53448. * Speed Constant Teleportation Mode
  53449. */
  53450. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53451. /**
  53452. * Teleports the users feet to the desired location
  53453. * @param location The location where the user's feet should be placed
  53454. */
  53455. teleportCamera(location: Vector3): void;
  53456. private _convertNormalToDirectionOfRay;
  53457. private _castRayAndSelectObject;
  53458. private _notifySelectedMeshUnselected;
  53459. /**
  53460. * Permanently set new colors for the laser pointer
  53461. * @param color the new laser color
  53462. * @param pickedColor the new laser color when picked mesh detected
  53463. */
  53464. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53465. /**
  53466. * Set lighting enabled / disabled on the laser pointer of both controllers
  53467. * @param enabled should the lighting be enabled on the laser pointer
  53468. */
  53469. setLaserLightingState(enabled?: boolean): void;
  53470. /**
  53471. * Permanently set new colors for the gaze pointer
  53472. * @param color the new gaze color
  53473. * @param pickedColor the new gaze color when picked mesh detected
  53474. */
  53475. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53476. /**
  53477. * Sets the color of the laser ray from the vr controllers.
  53478. * @param color new color for the ray.
  53479. */
  53480. changeLaserColor(color: Color3): void;
  53481. /**
  53482. * Sets the color of the ray from the vr headsets gaze.
  53483. * @param color new color for the ray.
  53484. */
  53485. changeGazeColor(color: Color3): void;
  53486. /**
  53487. * Exits VR and disposes of the vr experience helper
  53488. */
  53489. dispose(): void;
  53490. /**
  53491. * Gets the name of the VRExperienceHelper class
  53492. * @returns "VRExperienceHelper"
  53493. */
  53494. getClassName(): string;
  53495. }
  53496. }
  53497. declare module BABYLON {
  53498. /**
  53499. * Contains an array of blocks representing the octree
  53500. */
  53501. export interface IOctreeContainer<T> {
  53502. /**
  53503. * Blocks within the octree
  53504. */
  53505. blocks: Array<OctreeBlock<T>>;
  53506. }
  53507. /**
  53508. * Class used to store a cell in an octree
  53509. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53510. */
  53511. export class OctreeBlock<T> {
  53512. /**
  53513. * Gets the content of the current block
  53514. */
  53515. entries: T[];
  53516. /**
  53517. * Gets the list of block children
  53518. */
  53519. blocks: Array<OctreeBlock<T>>;
  53520. private _depth;
  53521. private _maxDepth;
  53522. private _capacity;
  53523. private _minPoint;
  53524. private _maxPoint;
  53525. private _boundingVectors;
  53526. private _creationFunc;
  53527. /**
  53528. * Creates a new block
  53529. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53530. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53531. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53532. * @param depth defines the current depth of this block in the octree
  53533. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53534. * @param creationFunc defines a callback to call when an element is added to the block
  53535. */
  53536. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53537. /**
  53538. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53539. */
  53540. get capacity(): number;
  53541. /**
  53542. * Gets the minimum vector (in world space) of the block's bounding box
  53543. */
  53544. get minPoint(): Vector3;
  53545. /**
  53546. * Gets the maximum vector (in world space) of the block's bounding box
  53547. */
  53548. get maxPoint(): Vector3;
  53549. /**
  53550. * Add a new element to this block
  53551. * @param entry defines the element to add
  53552. */
  53553. addEntry(entry: T): void;
  53554. /**
  53555. * Remove an element from this block
  53556. * @param entry defines the element to remove
  53557. */
  53558. removeEntry(entry: T): void;
  53559. /**
  53560. * Add an array of elements to this block
  53561. * @param entries defines the array of elements to add
  53562. */
  53563. addEntries(entries: T[]): void;
  53564. /**
  53565. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53566. * @param frustumPlanes defines the frustum planes to test
  53567. * @param selection defines the array to store current content if selection is positive
  53568. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53569. */
  53570. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53571. /**
  53572. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53573. * @param sphereCenter defines the bounding sphere center
  53574. * @param sphereRadius defines the bounding sphere radius
  53575. * @param selection defines the array to store current content if selection is positive
  53576. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53577. */
  53578. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53579. /**
  53580. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53581. * @param ray defines the ray to test with
  53582. * @param selection defines the array to store current content if selection is positive
  53583. */
  53584. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53585. /**
  53586. * Subdivide the content into child blocks (this block will then be empty)
  53587. */
  53588. createInnerBlocks(): void;
  53589. /**
  53590. * @hidden
  53591. */
  53592. 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;
  53593. }
  53594. }
  53595. declare module BABYLON {
  53596. /**
  53597. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53598. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53599. */
  53600. export class Octree<T> {
  53601. /** 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.) */
  53602. maxDepth: number;
  53603. /**
  53604. * Blocks within the octree containing objects
  53605. */
  53606. blocks: Array<OctreeBlock<T>>;
  53607. /**
  53608. * Content stored in the octree
  53609. */
  53610. dynamicContent: T[];
  53611. private _maxBlockCapacity;
  53612. private _selectionContent;
  53613. private _creationFunc;
  53614. /**
  53615. * Creates a octree
  53616. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53617. * @param creationFunc function to be used to instatiate the octree
  53618. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53619. * @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.)
  53620. */
  53621. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53622. /** 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.) */
  53623. maxDepth?: number);
  53624. /**
  53625. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53626. * @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);
  53627. * @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);
  53628. * @param entries meshes to be added to the octree blocks
  53629. */
  53630. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53631. /**
  53632. * Adds a mesh to the octree
  53633. * @param entry Mesh to add to the octree
  53634. */
  53635. addMesh(entry: T): void;
  53636. /**
  53637. * Remove an element from the octree
  53638. * @param entry defines the element to remove
  53639. */
  53640. removeMesh(entry: T): void;
  53641. /**
  53642. * Selects an array of meshes within the frustum
  53643. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53644. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53645. * @returns array of meshes within the frustum
  53646. */
  53647. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53648. /**
  53649. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53650. * @param sphereCenter defines the bounding sphere center
  53651. * @param sphereRadius defines the bounding sphere radius
  53652. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53653. * @returns an array of objects that intersect the sphere
  53654. */
  53655. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53656. /**
  53657. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53658. * @param ray defines the ray to test with
  53659. * @returns array of intersected objects
  53660. */
  53661. intersectsRay(ray: Ray): SmartArray<T>;
  53662. /**
  53663. * Adds a mesh into the octree block if it intersects the block
  53664. */
  53665. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53666. /**
  53667. * Adds a submesh into the octree block if it intersects the block
  53668. */
  53669. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53670. }
  53671. }
  53672. declare module BABYLON {
  53673. interface Scene {
  53674. /**
  53675. * @hidden
  53676. * Backing Filed
  53677. */
  53678. _selectionOctree: Octree<AbstractMesh>;
  53679. /**
  53680. * Gets the octree used to boost mesh selection (picking)
  53681. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53682. */
  53683. selectionOctree: Octree<AbstractMesh>;
  53684. /**
  53685. * Creates or updates the octree used to boost selection (picking)
  53686. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53687. * @param maxCapacity defines the maximum capacity per leaf
  53688. * @param maxDepth defines the maximum depth of the octree
  53689. * @returns an octree of AbstractMesh
  53690. */
  53691. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  53692. }
  53693. interface AbstractMesh {
  53694. /**
  53695. * @hidden
  53696. * Backing Field
  53697. */
  53698. _submeshesOctree: Octree<SubMesh>;
  53699. /**
  53700. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  53701. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  53702. * @param maxCapacity defines the maximum size of each block (64 by default)
  53703. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  53704. * @returns the new octree
  53705. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  53706. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53707. */
  53708. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  53709. }
  53710. /**
  53711. * Defines the octree scene component responsible to manage any octrees
  53712. * in a given scene.
  53713. */
  53714. export class OctreeSceneComponent {
  53715. /**
  53716. * The component name help to identify the component in the list of scene components.
  53717. */
  53718. readonly name: string;
  53719. /**
  53720. * The scene the component belongs to.
  53721. */
  53722. scene: Scene;
  53723. /**
  53724. * Indicates if the meshes have been checked to make sure they are isEnabled()
  53725. */
  53726. readonly checksIsEnabled: boolean;
  53727. /**
  53728. * Creates a new instance of the component for the given scene
  53729. * @param scene Defines the scene to register the component in
  53730. */
  53731. constructor(scene: Scene);
  53732. /**
  53733. * Registers the component in a given scene
  53734. */
  53735. register(): void;
  53736. /**
  53737. * Return the list of active meshes
  53738. * @returns the list of active meshes
  53739. */
  53740. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  53741. /**
  53742. * Return the list of active sub meshes
  53743. * @param mesh The mesh to get the candidates sub meshes from
  53744. * @returns the list of active sub meshes
  53745. */
  53746. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  53747. private _tempRay;
  53748. /**
  53749. * Return the list of sub meshes intersecting with a given local ray
  53750. * @param mesh defines the mesh to find the submesh for
  53751. * @param localRay defines the ray in local space
  53752. * @returns the list of intersecting sub meshes
  53753. */
  53754. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  53755. /**
  53756. * Return the list of sub meshes colliding with a collider
  53757. * @param mesh defines the mesh to find the submesh for
  53758. * @param collider defines the collider to evaluate the collision against
  53759. * @returns the list of colliding sub meshes
  53760. */
  53761. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  53762. /**
  53763. * Rebuilds the elements related to this component in case of
  53764. * context lost for instance.
  53765. */
  53766. rebuild(): void;
  53767. /**
  53768. * Disposes the component and the associated ressources.
  53769. */
  53770. dispose(): void;
  53771. }
  53772. }
  53773. declare module BABYLON {
  53774. /**
  53775. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  53776. */
  53777. export class Gizmo implements IDisposable {
  53778. /** The utility layer the gizmo will be added to */
  53779. gizmoLayer: UtilityLayerRenderer;
  53780. /**
  53781. * The root mesh of the gizmo
  53782. */
  53783. _rootMesh: Mesh;
  53784. private _attachedMesh;
  53785. private _attachedNode;
  53786. /**
  53787. * Ratio for the scale of the gizmo (Default: 1)
  53788. */
  53789. protected _scaleRatio: number;
  53790. /**
  53791. * boolean updated by pointermove when a gizmo mesh is hovered
  53792. */
  53793. protected _isHovered: boolean;
  53794. /**
  53795. * Ratio for the scale of the gizmo (Default: 1)
  53796. */
  53797. set scaleRatio(value: number);
  53798. get scaleRatio(): number;
  53799. /**
  53800. * True when the mouse pointer is hovered a gizmo mesh
  53801. */
  53802. get isHovered(): boolean;
  53803. /**
  53804. * If a custom mesh has been set (Default: false)
  53805. */
  53806. protected _customMeshSet: boolean;
  53807. /**
  53808. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  53809. * * When set, interactions will be enabled
  53810. */
  53811. get attachedMesh(): Nullable<AbstractMesh>;
  53812. set attachedMesh(value: Nullable<AbstractMesh>);
  53813. /**
  53814. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  53815. * * When set, interactions will be enabled
  53816. */
  53817. get attachedNode(): Nullable<Node>;
  53818. set attachedNode(value: Nullable<Node>);
  53819. /**
  53820. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53821. * @param mesh The mesh to replace the default mesh of the gizmo
  53822. */
  53823. setCustomMesh(mesh: Mesh): void;
  53824. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  53825. /**
  53826. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  53827. */
  53828. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53829. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53830. /**
  53831. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  53832. */
  53833. updateGizmoPositionToMatchAttachedMesh: boolean;
  53834. /**
  53835. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  53836. */
  53837. updateScale: boolean;
  53838. protected _interactionsEnabled: boolean;
  53839. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53840. private _beforeRenderObserver;
  53841. private _tempQuaternion;
  53842. private _tempVector;
  53843. private _tempVector2;
  53844. private _tempMatrix1;
  53845. private _tempMatrix2;
  53846. private _rightHandtoLeftHandMatrix;
  53847. /**
  53848. * Creates a gizmo
  53849. * @param gizmoLayer The utility layer the gizmo will be added to
  53850. */
  53851. constructor(
  53852. /** The utility layer the gizmo will be added to */
  53853. gizmoLayer?: UtilityLayerRenderer);
  53854. /**
  53855. * Updates the gizmo to match the attached mesh's position/rotation
  53856. */
  53857. protected _update(): void;
  53858. /**
  53859. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  53860. * @param value Node, TransformNode or mesh
  53861. */
  53862. protected _matrixChanged(): void;
  53863. /**
  53864. * Disposes of the gizmo
  53865. */
  53866. dispose(): void;
  53867. }
  53868. }
  53869. declare module BABYLON {
  53870. /**
  53871. * Single plane drag gizmo
  53872. */
  53873. export class PlaneDragGizmo extends Gizmo {
  53874. /**
  53875. * Drag behavior responsible for the gizmos dragging interactions
  53876. */
  53877. dragBehavior: PointerDragBehavior;
  53878. private _pointerObserver;
  53879. /**
  53880. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53881. */
  53882. snapDistance: number;
  53883. /**
  53884. * Event that fires each time the gizmo snaps to a new location.
  53885. * * snapDistance is the the change in distance
  53886. */
  53887. onSnapObservable: Observable<{
  53888. snapDistance: number;
  53889. }>;
  53890. private _plane;
  53891. private _coloredMaterial;
  53892. private _hoverMaterial;
  53893. private _isEnabled;
  53894. private _parent;
  53895. /** @hidden */
  53896. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  53897. /** @hidden */
  53898. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53899. /**
  53900. * Creates a PlaneDragGizmo
  53901. * @param gizmoLayer The utility layer the gizmo will be added to
  53902. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  53903. * @param color The color of the gizmo
  53904. */
  53905. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  53906. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53907. /**
  53908. * If the gizmo is enabled
  53909. */
  53910. set isEnabled(value: boolean);
  53911. get isEnabled(): boolean;
  53912. /**
  53913. * Disposes of the gizmo
  53914. */
  53915. dispose(): void;
  53916. }
  53917. }
  53918. declare module BABYLON {
  53919. /**
  53920. * Gizmo that enables dragging a mesh along 3 axis
  53921. */
  53922. export class PositionGizmo extends Gizmo {
  53923. /**
  53924. * Internal gizmo used for interactions on the x axis
  53925. */
  53926. xGizmo: AxisDragGizmo;
  53927. /**
  53928. * Internal gizmo used for interactions on the y axis
  53929. */
  53930. yGizmo: AxisDragGizmo;
  53931. /**
  53932. * Internal gizmo used for interactions on the z axis
  53933. */
  53934. zGizmo: AxisDragGizmo;
  53935. /**
  53936. * Internal gizmo used for interactions on the yz plane
  53937. */
  53938. xPlaneGizmo: PlaneDragGizmo;
  53939. /**
  53940. * Internal gizmo used for interactions on the xz plane
  53941. */
  53942. yPlaneGizmo: PlaneDragGizmo;
  53943. /**
  53944. * Internal gizmo used for interactions on the xy plane
  53945. */
  53946. zPlaneGizmo: PlaneDragGizmo;
  53947. /**
  53948. * private variables
  53949. */
  53950. private _meshAttached;
  53951. private _nodeAttached;
  53952. private _snapDistance;
  53953. /** Fires an event when any of it's sub gizmos are dragged */
  53954. onDragStartObservable: Observable<unknown>;
  53955. /** Fires an event when any of it's sub gizmos are released from dragging */
  53956. onDragEndObservable: Observable<unknown>;
  53957. /**
  53958. * If set to true, planar drag is enabled
  53959. */
  53960. private _planarGizmoEnabled;
  53961. get attachedMesh(): Nullable<AbstractMesh>;
  53962. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53963. get attachedNode(): Nullable<Node>;
  53964. set attachedNode(node: Nullable<Node>);
  53965. /**
  53966. * True when the mouse pointer is hovering a gizmo mesh
  53967. */
  53968. get isHovered(): boolean;
  53969. /**
  53970. * Creates a PositionGizmo
  53971. * @param gizmoLayer The utility layer the gizmo will be added to
  53972. @param thickness display gizmo axis thickness
  53973. */
  53974. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53975. /**
  53976. * If the planar drag gizmo is enabled
  53977. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  53978. */
  53979. set planarGizmoEnabled(value: boolean);
  53980. get planarGizmoEnabled(): boolean;
  53981. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53982. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53983. /**
  53984. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53985. */
  53986. set snapDistance(value: number);
  53987. get snapDistance(): number;
  53988. /**
  53989. * Ratio for the scale of the gizmo (Default: 1)
  53990. */
  53991. set scaleRatio(value: number);
  53992. get scaleRatio(): number;
  53993. /**
  53994. * Disposes of the gizmo
  53995. */
  53996. dispose(): void;
  53997. /**
  53998. * CustomMeshes are not supported by this gizmo
  53999. * @param mesh The mesh to replace the default mesh of the gizmo
  54000. */
  54001. setCustomMesh(mesh: Mesh): void;
  54002. }
  54003. }
  54004. declare module BABYLON {
  54005. /**
  54006. * Single axis drag gizmo
  54007. */
  54008. export class AxisDragGizmo extends Gizmo {
  54009. /**
  54010. * Drag behavior responsible for the gizmos dragging interactions
  54011. */
  54012. dragBehavior: PointerDragBehavior;
  54013. private _pointerObserver;
  54014. /**
  54015. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54016. */
  54017. snapDistance: number;
  54018. /**
  54019. * Event that fires each time the gizmo snaps to a new location.
  54020. * * snapDistance is the the change in distance
  54021. */
  54022. onSnapObservable: Observable<{
  54023. snapDistance: number;
  54024. }>;
  54025. private _isEnabled;
  54026. private _parent;
  54027. private _arrow;
  54028. private _coloredMaterial;
  54029. private _hoverMaterial;
  54030. /** @hidden */
  54031. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  54032. /** @hidden */
  54033. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  54034. /**
  54035. * Creates an AxisDragGizmo
  54036. * @param gizmoLayer The utility layer the gizmo will be added to
  54037. * @param dragAxis The axis which the gizmo will be able to drag on
  54038. * @param color The color of the gizmo
  54039. * @param thickness display gizmo axis thickness
  54040. */
  54041. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  54042. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54043. /**
  54044. * If the gizmo is enabled
  54045. */
  54046. set isEnabled(value: boolean);
  54047. get isEnabled(): boolean;
  54048. /**
  54049. * Disposes of the gizmo
  54050. */
  54051. dispose(): void;
  54052. }
  54053. }
  54054. declare module BABYLON.Debug {
  54055. /**
  54056. * The Axes viewer will show 3 axes in a specific point in space
  54057. */
  54058. export class AxesViewer {
  54059. private _xAxis;
  54060. private _yAxis;
  54061. private _zAxis;
  54062. private _scaleLinesFactor;
  54063. private _instanced;
  54064. /**
  54065. * Gets the hosting scene
  54066. */
  54067. scene: Nullable<Scene>;
  54068. /**
  54069. * Gets or sets a number used to scale line length
  54070. */
  54071. scaleLines: number;
  54072. /** Gets the node hierarchy used to render x-axis */
  54073. get xAxis(): TransformNode;
  54074. /** Gets the node hierarchy used to render y-axis */
  54075. get yAxis(): TransformNode;
  54076. /** Gets the node hierarchy used to render z-axis */
  54077. get zAxis(): TransformNode;
  54078. /**
  54079. * Creates a new AxesViewer
  54080. * @param scene defines the hosting scene
  54081. * @param scaleLines defines a number used to scale line length (1 by default)
  54082. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  54083. * @param xAxis defines the node hierarchy used to render the x-axis
  54084. * @param yAxis defines the node hierarchy used to render the y-axis
  54085. * @param zAxis defines the node hierarchy used to render the z-axis
  54086. */
  54087. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  54088. /**
  54089. * Force the viewer to update
  54090. * @param position defines the position of the viewer
  54091. * @param xaxis defines the x axis of the viewer
  54092. * @param yaxis defines the y axis of the viewer
  54093. * @param zaxis defines the z axis of the viewer
  54094. */
  54095. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  54096. /**
  54097. * Creates an instance of this axes viewer.
  54098. * @returns a new axes viewer with instanced meshes
  54099. */
  54100. createInstance(): AxesViewer;
  54101. /** Releases resources */
  54102. dispose(): void;
  54103. private static _SetRenderingGroupId;
  54104. }
  54105. }
  54106. declare module BABYLON.Debug {
  54107. /**
  54108. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  54109. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  54110. */
  54111. export class BoneAxesViewer extends AxesViewer {
  54112. /**
  54113. * Gets or sets the target mesh where to display the axes viewer
  54114. */
  54115. mesh: Nullable<Mesh>;
  54116. /**
  54117. * Gets or sets the target bone where to display the axes viewer
  54118. */
  54119. bone: Nullable<Bone>;
  54120. /** Gets current position */
  54121. pos: Vector3;
  54122. /** Gets direction of X axis */
  54123. xaxis: Vector3;
  54124. /** Gets direction of Y axis */
  54125. yaxis: Vector3;
  54126. /** Gets direction of Z axis */
  54127. zaxis: Vector3;
  54128. /**
  54129. * Creates a new BoneAxesViewer
  54130. * @param scene defines the hosting scene
  54131. * @param bone defines the target bone
  54132. * @param mesh defines the target mesh
  54133. * @param scaleLines defines a scaling factor for line length (1 by default)
  54134. */
  54135. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  54136. /**
  54137. * Force the viewer to update
  54138. */
  54139. update(): void;
  54140. /** Releases resources */
  54141. dispose(): void;
  54142. }
  54143. }
  54144. declare module BABYLON {
  54145. /**
  54146. * Interface used to define scene explorer extensibility option
  54147. */
  54148. export interface IExplorerExtensibilityOption {
  54149. /**
  54150. * Define the option label
  54151. */
  54152. label: string;
  54153. /**
  54154. * Defines the action to execute on click
  54155. */
  54156. action: (entity: any) => void;
  54157. }
  54158. /**
  54159. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  54160. */
  54161. export interface IExplorerExtensibilityGroup {
  54162. /**
  54163. * Defines a predicate to test if a given type mut be extended
  54164. */
  54165. predicate: (entity: any) => boolean;
  54166. /**
  54167. * Gets the list of options added to a type
  54168. */
  54169. entries: IExplorerExtensibilityOption[];
  54170. }
  54171. /**
  54172. * Interface used to define the options to use to create the Inspector
  54173. */
  54174. export interface IInspectorOptions {
  54175. /**
  54176. * Display in overlay mode (default: false)
  54177. */
  54178. overlay?: boolean;
  54179. /**
  54180. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  54181. */
  54182. globalRoot?: HTMLElement;
  54183. /**
  54184. * Display the Scene explorer
  54185. */
  54186. showExplorer?: boolean;
  54187. /**
  54188. * Display the property inspector
  54189. */
  54190. showInspector?: boolean;
  54191. /**
  54192. * Display in embed mode (both panes on the right)
  54193. */
  54194. embedMode?: boolean;
  54195. /**
  54196. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  54197. */
  54198. handleResize?: boolean;
  54199. /**
  54200. * Allow the panes to popup (default: true)
  54201. */
  54202. enablePopup?: boolean;
  54203. /**
  54204. * Allow the panes to be closed by users (default: true)
  54205. */
  54206. enableClose?: boolean;
  54207. /**
  54208. * Optional list of extensibility entries
  54209. */
  54210. explorerExtensibility?: IExplorerExtensibilityGroup[];
  54211. /**
  54212. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  54213. */
  54214. inspectorURL?: string;
  54215. /**
  54216. * Optional initial tab (default to DebugLayerTab.Properties)
  54217. */
  54218. initialTab?: DebugLayerTab;
  54219. }
  54220. interface Scene {
  54221. /**
  54222. * @hidden
  54223. * Backing field
  54224. */
  54225. _debugLayer: DebugLayer;
  54226. /**
  54227. * Gets the debug layer (aka Inspector) associated with the scene
  54228. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54229. */
  54230. debugLayer: DebugLayer;
  54231. }
  54232. /**
  54233. * Enum of inspector action tab
  54234. */
  54235. export enum DebugLayerTab {
  54236. /**
  54237. * Properties tag (default)
  54238. */
  54239. Properties = 0,
  54240. /**
  54241. * Debug tab
  54242. */
  54243. Debug = 1,
  54244. /**
  54245. * Statistics tab
  54246. */
  54247. Statistics = 2,
  54248. /**
  54249. * Tools tab
  54250. */
  54251. Tools = 3,
  54252. /**
  54253. * Settings tab
  54254. */
  54255. Settings = 4
  54256. }
  54257. /**
  54258. * The debug layer (aka Inspector) is the go to tool in order to better understand
  54259. * what is happening in your scene
  54260. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54261. */
  54262. export class DebugLayer {
  54263. /**
  54264. * Define the url to get the inspector script from.
  54265. * By default it uses the babylonjs CDN.
  54266. * @ignoreNaming
  54267. */
  54268. static InspectorURL: string;
  54269. private _scene;
  54270. private BJSINSPECTOR;
  54271. private _onPropertyChangedObservable?;
  54272. /**
  54273. * Observable triggered when a property is changed through the inspector.
  54274. */
  54275. get onPropertyChangedObservable(): any;
  54276. /**
  54277. * Instantiates a new debug layer.
  54278. * The debug layer (aka Inspector) is the go to tool in order to better understand
  54279. * what is happening in your scene
  54280. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54281. * @param scene Defines the scene to inspect
  54282. */
  54283. constructor(scene: Scene);
  54284. /** Creates the inspector window. */
  54285. private _createInspector;
  54286. /**
  54287. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  54288. * @param entity defines the entity to select
  54289. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  54290. */
  54291. select(entity: any, lineContainerTitles?: string | string[]): void;
  54292. /** Get the inspector from bundle or global */
  54293. private _getGlobalInspector;
  54294. /**
  54295. * Get if the inspector is visible or not.
  54296. * @returns true if visible otherwise, false
  54297. */
  54298. isVisible(): boolean;
  54299. /**
  54300. * Hide the inspector and close its window.
  54301. */
  54302. hide(): void;
  54303. /**
  54304. * Update the scene in the inspector
  54305. */
  54306. setAsActiveScene(): void;
  54307. /**
  54308. * Launch the debugLayer.
  54309. * @param config Define the configuration of the inspector
  54310. * @return a promise fulfilled when the debug layer is visible
  54311. */
  54312. show(config?: IInspectorOptions): Promise<DebugLayer>;
  54313. }
  54314. }
  54315. declare module BABYLON {
  54316. /**
  54317. * Class containing static functions to help procedurally build meshes
  54318. */
  54319. export class BoxBuilder {
  54320. /**
  54321. * Creates a box mesh
  54322. * * The parameter `size` sets the size (float) of each box side (default 1)
  54323. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54324. * * 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)
  54325. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54327. * * 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
  54328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54329. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54330. * @param name defines the name of the mesh
  54331. * @param options defines the options used to create the mesh
  54332. * @param scene defines the hosting scene
  54333. * @returns the box mesh
  54334. */
  54335. static CreateBox(name: string, options: {
  54336. size?: number;
  54337. width?: number;
  54338. height?: number;
  54339. depth?: number;
  54340. faceUV?: Vector4[];
  54341. faceColors?: Color4[];
  54342. sideOrientation?: number;
  54343. frontUVs?: Vector4;
  54344. backUVs?: Vector4;
  54345. wrap?: boolean;
  54346. topBaseAt?: number;
  54347. bottomBaseAt?: number;
  54348. updatable?: boolean;
  54349. }, scene?: Nullable<Scene>): Mesh;
  54350. }
  54351. }
  54352. declare module BABYLON.Debug {
  54353. /**
  54354. * Used to show the physics impostor around the specific mesh
  54355. */
  54356. export class PhysicsViewer {
  54357. /** @hidden */
  54358. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  54359. /** @hidden */
  54360. protected _meshes: Array<Nullable<AbstractMesh>>;
  54361. /** @hidden */
  54362. protected _scene: Nullable<Scene>;
  54363. /** @hidden */
  54364. protected _numMeshes: number;
  54365. /** @hidden */
  54366. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  54367. private _renderFunction;
  54368. private _utilityLayer;
  54369. private _debugBoxMesh;
  54370. private _debugSphereMesh;
  54371. private _debugCylinderMesh;
  54372. private _debugMaterial;
  54373. private _debugMeshMeshes;
  54374. /**
  54375. * Creates a new PhysicsViewer
  54376. * @param scene defines the hosting scene
  54377. */
  54378. constructor(scene: Scene);
  54379. /** @hidden */
  54380. protected _updateDebugMeshes(): void;
  54381. /**
  54382. * Renders a specified physic impostor
  54383. * @param impostor defines the impostor to render
  54384. * @param targetMesh defines the mesh represented by the impostor
  54385. * @returns the new debug mesh used to render the impostor
  54386. */
  54387. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  54388. /**
  54389. * Hides a specified physic impostor
  54390. * @param impostor defines the impostor to hide
  54391. */
  54392. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  54393. private _getDebugMaterial;
  54394. private _getDebugBoxMesh;
  54395. private _getDebugSphereMesh;
  54396. private _getDebugCylinderMesh;
  54397. private _getDebugMeshMesh;
  54398. private _getDebugMesh;
  54399. /** Releases all resources */
  54400. dispose(): void;
  54401. }
  54402. }
  54403. declare module BABYLON {
  54404. /**
  54405. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54406. * in order to better appreciate the issue one might have.
  54407. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54408. */
  54409. export class RayHelper {
  54410. /**
  54411. * Defines the ray we are currently tryin to visualize.
  54412. */
  54413. ray: Nullable<Ray>;
  54414. private _renderPoints;
  54415. private _renderLine;
  54416. private _renderFunction;
  54417. private _scene;
  54418. private _onAfterRenderObserver;
  54419. private _onAfterStepObserver;
  54420. private _attachedToMesh;
  54421. private _meshSpaceDirection;
  54422. private _meshSpaceOrigin;
  54423. /**
  54424. * Helper function to create a colored helper in a scene in one line.
  54425. * @param ray Defines the ray we are currently tryin to visualize
  54426. * @param scene Defines the scene the ray is used in
  54427. * @param color Defines the color we want to see the ray in
  54428. * @returns The newly created ray helper.
  54429. */
  54430. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  54431. /**
  54432. * Instantiate a new ray helper.
  54433. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54434. * in order to better appreciate the issue one might have.
  54435. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54436. * @param ray Defines the ray we are currently tryin to visualize
  54437. */
  54438. constructor(ray: Ray);
  54439. /**
  54440. * Shows the ray we are willing to debug.
  54441. * @param scene Defines the scene the ray needs to be rendered in
  54442. * @param color Defines the color the ray needs to be rendered in
  54443. */
  54444. show(scene: Scene, color?: Color3): void;
  54445. /**
  54446. * Hides the ray we are debugging.
  54447. */
  54448. hide(): void;
  54449. private _render;
  54450. /**
  54451. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  54452. * @param mesh Defines the mesh we want the helper attached to
  54453. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  54454. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  54455. * @param length Defines the length of the ray
  54456. */
  54457. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  54458. /**
  54459. * Detach the ray helper from the mesh it has previously been attached to.
  54460. */
  54461. detachFromMesh(): void;
  54462. private _updateToMesh;
  54463. /**
  54464. * Dispose the helper and release its associated resources.
  54465. */
  54466. dispose(): void;
  54467. }
  54468. }
  54469. declare module BABYLON {
  54470. /**
  54471. * Defines the options associated with the creation of a SkeletonViewer.
  54472. */
  54473. export interface ISkeletonViewerOptions {
  54474. /** Should the system pause animations before building the Viewer? */
  54475. pauseAnimations: boolean;
  54476. /** Should the system return the skeleton to rest before building? */
  54477. returnToRest: boolean;
  54478. /** public Display Mode of the Viewer */
  54479. displayMode: number;
  54480. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54481. displayOptions: ISkeletonViewerDisplayOptions;
  54482. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54483. computeBonesUsingShaders: boolean;
  54484. /** Flag ignore non weighted bones */
  54485. useAllBones: boolean;
  54486. }
  54487. /**
  54488. * Defines how to display the various bone meshes for the viewer.
  54489. */
  54490. export interface ISkeletonViewerDisplayOptions {
  54491. /** How far down to start tapering the bone spurs */
  54492. midStep?: number;
  54493. /** How big is the midStep? */
  54494. midStepFactor?: number;
  54495. /** Base for the Sphere Size */
  54496. sphereBaseSize?: number;
  54497. /** The ratio of the sphere to the longest bone in units */
  54498. sphereScaleUnit?: number;
  54499. /** Ratio for the Sphere Size */
  54500. sphereFactor?: number;
  54501. /** Whether a spur should attach its far end to the child bone position */
  54502. spurFollowsChild?: boolean;
  54503. /** Whether to show local axes or not */
  54504. showLocalAxes?: boolean;
  54505. /** Length of each local axis */
  54506. localAxesSize?: number;
  54507. }
  54508. /**
  54509. * Defines the constructor options for the BoneWeight Shader.
  54510. */
  54511. export interface IBoneWeightShaderOptions {
  54512. /** Skeleton to Map */
  54513. skeleton: Skeleton;
  54514. /** Colors for Uninfluenced bones */
  54515. colorBase?: Color3;
  54516. /** Colors for 0.0-0.25 Weight bones */
  54517. colorZero?: Color3;
  54518. /** Color for 0.25-0.5 Weight Influence */
  54519. colorQuarter?: Color3;
  54520. /** Color for 0.5-0.75 Weight Influence */
  54521. colorHalf?: Color3;
  54522. /** Color for 0.75-1 Weight Influence */
  54523. colorFull?: Color3;
  54524. /** Color for Zero Weight Influence */
  54525. targetBoneIndex?: number;
  54526. }
  54527. /**
  54528. * Simple structure of the gradient steps for the Color Map.
  54529. */
  54530. export interface ISkeletonMapShaderColorMapKnot {
  54531. /** Color of the Knot */
  54532. color: Color3;
  54533. /** Location of the Knot */
  54534. location: number;
  54535. }
  54536. /**
  54537. * Defines the constructor options for the SkeletonMap Shader.
  54538. */
  54539. export interface ISkeletonMapShaderOptions {
  54540. /** Skeleton to Map */
  54541. skeleton: Skeleton;
  54542. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  54543. colorMap?: ISkeletonMapShaderColorMapKnot[];
  54544. }
  54545. }
  54546. declare module BABYLON {
  54547. /**
  54548. * Class containing static functions to help procedurally build meshes
  54549. */
  54550. export class RibbonBuilder {
  54551. /**
  54552. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54553. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54554. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54555. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54556. * * 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
  54557. * * 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
  54558. * * 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
  54559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54560. * * 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
  54561. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54562. * * 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
  54563. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54564. * * 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
  54565. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54567. * @param name defines the name of the mesh
  54568. * @param options defines the options used to create the mesh
  54569. * @param scene defines the hosting scene
  54570. * @returns the ribbon mesh
  54571. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54572. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54573. */
  54574. static CreateRibbon(name: string, options: {
  54575. pathArray: Vector3[][];
  54576. closeArray?: boolean;
  54577. closePath?: boolean;
  54578. offset?: number;
  54579. updatable?: boolean;
  54580. sideOrientation?: number;
  54581. frontUVs?: Vector4;
  54582. backUVs?: Vector4;
  54583. instance?: Mesh;
  54584. invertUV?: boolean;
  54585. uvs?: Vector2[];
  54586. colors?: Color4[];
  54587. }, scene?: Nullable<Scene>): Mesh;
  54588. }
  54589. }
  54590. declare module BABYLON {
  54591. /**
  54592. * Class containing static functions to help procedurally build meshes
  54593. */
  54594. export class ShapeBuilder {
  54595. /**
  54596. * 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.
  54597. * * 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.
  54598. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54599. * * 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.
  54600. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54601. * * 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
  54602. * * 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
  54603. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54605. * * 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
  54606. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54608. * @param name defines the name of the mesh
  54609. * @param options defines the options used to create the mesh
  54610. * @param scene defines the hosting scene
  54611. * @returns the extruded shape mesh
  54612. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54613. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54614. */
  54615. static ExtrudeShape(name: string, options: {
  54616. shape: Vector3[];
  54617. path: Vector3[];
  54618. scale?: number;
  54619. rotation?: number;
  54620. cap?: number;
  54621. updatable?: boolean;
  54622. sideOrientation?: number;
  54623. frontUVs?: Vector4;
  54624. backUVs?: Vector4;
  54625. instance?: Mesh;
  54626. invertUV?: boolean;
  54627. }, scene?: Nullable<Scene>): Mesh;
  54628. /**
  54629. * Creates an custom extruded shape mesh.
  54630. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54631. * * 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.
  54632. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54633. * * 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
  54634. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54635. * * 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
  54636. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54637. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54638. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54639. * * 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
  54640. * * 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
  54641. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54643. * * 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
  54644. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54646. * @param name defines the name of the mesh
  54647. * @param options defines the options used to create the mesh
  54648. * @param scene defines the hosting scene
  54649. * @returns the custom extruded shape mesh
  54650. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54651. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54652. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54653. */
  54654. static ExtrudeShapeCustom(name: string, options: {
  54655. shape: Vector3[];
  54656. path: Vector3[];
  54657. scaleFunction?: any;
  54658. rotationFunction?: any;
  54659. ribbonCloseArray?: boolean;
  54660. ribbonClosePath?: boolean;
  54661. cap?: number;
  54662. updatable?: boolean;
  54663. sideOrientation?: number;
  54664. frontUVs?: Vector4;
  54665. backUVs?: Vector4;
  54666. instance?: Mesh;
  54667. invertUV?: boolean;
  54668. }, scene?: Nullable<Scene>): Mesh;
  54669. private static _ExtrudeShapeGeneric;
  54670. }
  54671. }
  54672. declare module BABYLON.Debug {
  54673. /**
  54674. * Class used to render a debug view of a given skeleton
  54675. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  54676. */
  54677. export class SkeletonViewer {
  54678. /** defines the skeleton to render */
  54679. skeleton: Skeleton;
  54680. /** defines the mesh attached to the skeleton */
  54681. mesh: AbstractMesh;
  54682. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54683. autoUpdateBonesMatrices: boolean;
  54684. /** defines the rendering group id to use with the viewer */
  54685. renderingGroupId: number;
  54686. /** is the options for the viewer */
  54687. options: Partial<ISkeletonViewerOptions>;
  54688. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  54689. static readonly DISPLAY_LINES: number;
  54690. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  54691. static readonly DISPLAY_SPHERES: number;
  54692. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  54693. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  54694. /** public static method to create a BoneWeight Shader
  54695. * @param options The constructor options
  54696. * @param scene The scene that the shader is scoped to
  54697. * @returns The created ShaderMaterial
  54698. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  54699. */
  54700. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  54701. /** public static method to create a BoneWeight Shader
  54702. * @param options The constructor options
  54703. * @param scene The scene that the shader is scoped to
  54704. * @returns The created ShaderMaterial
  54705. */
  54706. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  54707. /** private static method to create a BoneWeight Shader
  54708. * @param size The size of the buffer to create (usually the bone count)
  54709. * @param colorMap The gradient data to generate
  54710. * @param scene The scene that the shader is scoped to
  54711. * @returns an Array of floats from the color gradient values
  54712. */
  54713. private static _CreateBoneMapColorBuffer;
  54714. /** If SkeletonViewer scene scope. */
  54715. private _scene;
  54716. /** Gets or sets the color used to render the skeleton */
  54717. color: Color3;
  54718. /** Array of the points of the skeleton fo the line view. */
  54719. private _debugLines;
  54720. /** The SkeletonViewers Mesh. */
  54721. private _debugMesh;
  54722. /** The local axes Meshes. */
  54723. private _localAxes;
  54724. /** If SkeletonViewer is enabled. */
  54725. private _isEnabled;
  54726. /** If SkeletonViewer is ready. */
  54727. private _ready;
  54728. /** SkeletonViewer render observable. */
  54729. private _obs;
  54730. /** The Utility Layer to render the gizmos in. */
  54731. private _utilityLayer;
  54732. private _boneIndices;
  54733. /** Gets the Scene. */
  54734. get scene(): Scene;
  54735. /** Gets the utilityLayer. */
  54736. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  54737. /** Checks Ready Status. */
  54738. get isReady(): Boolean;
  54739. /** Sets Ready Status. */
  54740. set ready(value: boolean);
  54741. /** Gets the debugMesh */
  54742. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  54743. /** Sets the debugMesh */
  54744. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  54745. /** Gets the displayMode */
  54746. get displayMode(): number;
  54747. /** Sets the displayMode */
  54748. set displayMode(value: number);
  54749. /**
  54750. * Creates a new SkeletonViewer
  54751. * @param skeleton defines the skeleton to render
  54752. * @param mesh defines the mesh attached to the skeleton
  54753. * @param scene defines the hosting scene
  54754. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  54755. * @param renderingGroupId defines the rendering group id to use with the viewer
  54756. * @param options All of the extra constructor options for the SkeletonViewer
  54757. */
  54758. constructor(
  54759. /** defines the skeleton to render */
  54760. skeleton: Skeleton,
  54761. /** defines the mesh attached to the skeleton */
  54762. mesh: AbstractMesh,
  54763. /** The Scene scope*/
  54764. scene: Scene,
  54765. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54766. autoUpdateBonesMatrices?: boolean,
  54767. /** defines the rendering group id to use with the viewer */
  54768. renderingGroupId?: number,
  54769. /** is the options for the viewer */
  54770. options?: Partial<ISkeletonViewerOptions>);
  54771. /** The Dynamic bindings for the update functions */
  54772. private _bindObs;
  54773. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  54774. update(): void;
  54775. /** Gets or sets a boolean indicating if the viewer is enabled */
  54776. set isEnabled(value: boolean);
  54777. get isEnabled(): boolean;
  54778. private _getBonePosition;
  54779. private _getLinesForBonesWithLength;
  54780. private _getLinesForBonesNoLength;
  54781. /** function to revert the mesh and scene back to the initial state. */
  54782. private _revert;
  54783. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  54784. private _getAbsoluteBindPoseToRef;
  54785. /** function to build and bind sphere joint points and spur bone representations. */
  54786. private _buildSpheresAndSpurs;
  54787. private _buildLocalAxes;
  54788. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  54789. private _displayLinesUpdate;
  54790. /** Changes the displayMode of the skeleton viewer
  54791. * @param mode The displayMode numerical value
  54792. */
  54793. changeDisplayMode(mode: number): void;
  54794. /** Sets a display option of the skeleton viewer
  54795. *
  54796. * | Option | Type | Default | Description |
  54797. * | ---------------- | ------- | ------- | ----------- |
  54798. * | 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`. |
  54799. * | 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`. |
  54800. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54801. * | 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`. |
  54802. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  54803. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  54804. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  54805. *
  54806. * @param option String of the option name
  54807. * @param value The numerical option value
  54808. */
  54809. changeDisplayOptions(option: string, value: number): void;
  54810. /** Release associated resources */
  54811. dispose(): void;
  54812. }
  54813. }
  54814. declare module BABYLON {
  54815. /**
  54816. * Enum for Device Types
  54817. */
  54818. export enum DeviceType {
  54819. /** Generic */
  54820. Generic = 0,
  54821. /** Keyboard */
  54822. Keyboard = 1,
  54823. /** Mouse */
  54824. Mouse = 2,
  54825. /** Touch Pointers */
  54826. Touch = 3,
  54827. /** PS4 Dual Shock */
  54828. DualShock = 4,
  54829. /** Xbox */
  54830. Xbox = 5,
  54831. /** Switch Controller */
  54832. Switch = 6
  54833. }
  54834. /**
  54835. * Enum for All Pointers (Touch/Mouse)
  54836. */
  54837. export enum PointerInput {
  54838. /** Horizontal Axis */
  54839. Horizontal = 0,
  54840. /** Vertical Axis */
  54841. Vertical = 1,
  54842. /** Left Click or Touch */
  54843. LeftClick = 2,
  54844. /** Middle Click */
  54845. MiddleClick = 3,
  54846. /** Right Click */
  54847. RightClick = 4,
  54848. /** Browser Back */
  54849. BrowserBack = 5,
  54850. /** Browser Forward */
  54851. BrowserForward = 6
  54852. }
  54853. /**
  54854. * Enum for Dual Shock Gamepad
  54855. */
  54856. export enum DualShockInput {
  54857. /** Cross */
  54858. Cross = 0,
  54859. /** Circle */
  54860. Circle = 1,
  54861. /** Square */
  54862. Square = 2,
  54863. /** Triangle */
  54864. Triangle = 3,
  54865. /** L1 */
  54866. L1 = 4,
  54867. /** R1 */
  54868. R1 = 5,
  54869. /** L2 */
  54870. L2 = 6,
  54871. /** R2 */
  54872. R2 = 7,
  54873. /** Share */
  54874. Share = 8,
  54875. /** Options */
  54876. Options = 9,
  54877. /** L3 */
  54878. L3 = 10,
  54879. /** R3 */
  54880. R3 = 11,
  54881. /** DPadUp */
  54882. DPadUp = 12,
  54883. /** DPadDown */
  54884. DPadDown = 13,
  54885. /** DPadLeft */
  54886. DPadLeft = 14,
  54887. /** DRight */
  54888. DPadRight = 15,
  54889. /** Home */
  54890. Home = 16,
  54891. /** TouchPad */
  54892. TouchPad = 17,
  54893. /** LStickXAxis */
  54894. LStickXAxis = 18,
  54895. /** LStickYAxis */
  54896. LStickYAxis = 19,
  54897. /** RStickXAxis */
  54898. RStickXAxis = 20,
  54899. /** RStickYAxis */
  54900. RStickYAxis = 21
  54901. }
  54902. /**
  54903. * Enum for Xbox Gamepad
  54904. */
  54905. export enum XboxInput {
  54906. /** A */
  54907. A = 0,
  54908. /** B */
  54909. B = 1,
  54910. /** X */
  54911. X = 2,
  54912. /** Y */
  54913. Y = 3,
  54914. /** LB */
  54915. LB = 4,
  54916. /** RB */
  54917. RB = 5,
  54918. /** LT */
  54919. LT = 6,
  54920. /** RT */
  54921. RT = 7,
  54922. /** Back */
  54923. Back = 8,
  54924. /** Start */
  54925. Start = 9,
  54926. /** LS */
  54927. LS = 10,
  54928. /** RS */
  54929. RS = 11,
  54930. /** DPadUp */
  54931. DPadUp = 12,
  54932. /** DPadDown */
  54933. DPadDown = 13,
  54934. /** DPadLeft */
  54935. DPadLeft = 14,
  54936. /** DRight */
  54937. DPadRight = 15,
  54938. /** Home */
  54939. Home = 16,
  54940. /** LStickXAxis */
  54941. LStickXAxis = 17,
  54942. /** LStickYAxis */
  54943. LStickYAxis = 18,
  54944. /** RStickXAxis */
  54945. RStickXAxis = 19,
  54946. /** RStickYAxis */
  54947. RStickYAxis = 20
  54948. }
  54949. /**
  54950. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  54951. */
  54952. export enum SwitchInput {
  54953. /** B */
  54954. B = 0,
  54955. /** A */
  54956. A = 1,
  54957. /** Y */
  54958. Y = 2,
  54959. /** X */
  54960. X = 3,
  54961. /** L */
  54962. L = 4,
  54963. /** R */
  54964. R = 5,
  54965. /** ZL */
  54966. ZL = 6,
  54967. /** ZR */
  54968. ZR = 7,
  54969. /** Minus */
  54970. Minus = 8,
  54971. /** Plus */
  54972. Plus = 9,
  54973. /** LS */
  54974. LS = 10,
  54975. /** RS */
  54976. RS = 11,
  54977. /** DPadUp */
  54978. DPadUp = 12,
  54979. /** DPadDown */
  54980. DPadDown = 13,
  54981. /** DPadLeft */
  54982. DPadLeft = 14,
  54983. /** DRight */
  54984. DPadRight = 15,
  54985. /** Home */
  54986. Home = 16,
  54987. /** Capture */
  54988. Capture = 17,
  54989. /** LStickXAxis */
  54990. LStickXAxis = 18,
  54991. /** LStickYAxis */
  54992. LStickYAxis = 19,
  54993. /** RStickXAxis */
  54994. RStickXAxis = 20,
  54995. /** RStickYAxis */
  54996. RStickYAxis = 21
  54997. }
  54998. }
  54999. declare module BABYLON {
  55000. /**
  55001. * This class will take all inputs from Keyboard, Pointer, and
  55002. * any Gamepads and provide a polling system that all devices
  55003. * will use. This class assumes that there will only be one
  55004. * pointer device and one keyboard.
  55005. */
  55006. export class DeviceInputSystem implements IDisposable {
  55007. /**
  55008. * Returns onDeviceConnected callback property
  55009. * @returns Callback with function to execute when a device is connected
  55010. */
  55011. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  55012. /**
  55013. * Sets callback function when a device is connected and executes against all connected devices
  55014. * @param callback Function to execute when a device is connected
  55015. */
  55016. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  55017. /**
  55018. * Callback to be triggered when a device is disconnected
  55019. */
  55020. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  55021. /**
  55022. * Callback to be triggered when event driven input is updated
  55023. */
  55024. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  55025. private _inputs;
  55026. private _gamepads;
  55027. private _keyboardActive;
  55028. private _pointerActive;
  55029. private _elementToAttachTo;
  55030. private _keyboardDownEvent;
  55031. private _keyboardUpEvent;
  55032. private _pointerMoveEvent;
  55033. private _pointerDownEvent;
  55034. private _pointerUpEvent;
  55035. private _gamepadConnectedEvent;
  55036. private _gamepadDisconnectedEvent;
  55037. private _onDeviceConnected;
  55038. private static _MAX_KEYCODES;
  55039. private static _MAX_POINTER_INPUTS;
  55040. private constructor();
  55041. /**
  55042. * Creates a new DeviceInputSystem instance
  55043. * @param engine Engine to pull input element from
  55044. * @returns The new instance
  55045. */
  55046. static Create(engine: Engine): DeviceInputSystem;
  55047. /**
  55048. * Checks for current device input value, given an id and input index
  55049. * @param deviceName Id of connected device
  55050. * @param inputIndex Index of device input
  55051. * @returns Current value of input
  55052. */
  55053. /**
  55054. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  55055. * @param deviceType Enum specifiying device type
  55056. * @param deviceSlot "Slot" or index that device is referenced in
  55057. * @param inputIndex Id of input to be checked
  55058. * @returns Current value of input
  55059. */
  55060. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  55061. /**
  55062. * Dispose of all the eventlisteners
  55063. */
  55064. dispose(): void;
  55065. /**
  55066. * Checks for existing connections to devices and register them, if necessary
  55067. * Currently handles gamepads and mouse
  55068. */
  55069. private _checkForConnectedDevices;
  55070. /**
  55071. * Add a gamepad to the DeviceInputSystem
  55072. * @param gamepad A single DOM Gamepad object
  55073. */
  55074. private _addGamePad;
  55075. /**
  55076. * Add pointer device to DeviceInputSystem
  55077. * @param deviceType Type of Pointer to add
  55078. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  55079. * @param currentX Current X at point of adding
  55080. * @param currentY Current Y at point of adding
  55081. */
  55082. private _addPointerDevice;
  55083. /**
  55084. * Add device and inputs to device array
  55085. * @param deviceType Enum specifiying device type
  55086. * @param deviceSlot "Slot" or index that device is referenced in
  55087. * @param numberOfInputs Number of input entries to create for given device
  55088. */
  55089. private _registerDevice;
  55090. /**
  55091. * Given a specific device name, remove that device from the device map
  55092. * @param deviceType Enum specifiying device type
  55093. * @param deviceSlot "Slot" or index that device is referenced in
  55094. */
  55095. private _unregisterDevice;
  55096. /**
  55097. * Handle all actions that come from keyboard interaction
  55098. */
  55099. private _handleKeyActions;
  55100. /**
  55101. * Handle all actions that come from pointer interaction
  55102. */
  55103. private _handlePointerActions;
  55104. /**
  55105. * Handle all actions that come from gamepad interaction
  55106. */
  55107. private _handleGamepadActions;
  55108. /**
  55109. * Update all non-event based devices with each frame
  55110. * @param deviceType Enum specifiying device type
  55111. * @param deviceSlot "Slot" or index that device is referenced in
  55112. * @param inputIndex Id of input to be checked
  55113. */
  55114. private _updateDevice;
  55115. /**
  55116. * Gets DeviceType from the device name
  55117. * @param deviceName Name of Device from DeviceInputSystem
  55118. * @returns DeviceType enum value
  55119. */
  55120. private _getGamepadDeviceType;
  55121. }
  55122. }
  55123. declare module BABYLON {
  55124. /**
  55125. * Type to handle enforcement of inputs
  55126. */
  55127. 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;
  55128. }
  55129. declare module BABYLON {
  55130. /**
  55131. * Class that handles all input for a specific device
  55132. */
  55133. export class DeviceSource<T extends DeviceType> {
  55134. /** Type of device */
  55135. readonly deviceType: DeviceType;
  55136. /** "Slot" or index that device is referenced in */
  55137. readonly deviceSlot: number;
  55138. /**
  55139. * Observable to handle device input changes per device
  55140. */
  55141. readonly onInputChangedObservable: Observable<{
  55142. inputIndex: DeviceInput<T>;
  55143. previousState: Nullable<number>;
  55144. currentState: Nullable<number>;
  55145. }>;
  55146. private readonly _deviceInputSystem;
  55147. /**
  55148. * Default Constructor
  55149. * @param deviceInputSystem Reference to DeviceInputSystem
  55150. * @param deviceType Type of device
  55151. * @param deviceSlot "Slot" or index that device is referenced in
  55152. */
  55153. constructor(deviceInputSystem: DeviceInputSystem,
  55154. /** Type of device */
  55155. deviceType: DeviceType,
  55156. /** "Slot" or index that device is referenced in */
  55157. deviceSlot?: number);
  55158. /**
  55159. * Get input for specific input
  55160. * @param inputIndex index of specific input on device
  55161. * @returns Input value from DeviceInputSystem
  55162. */
  55163. getInput(inputIndex: DeviceInput<T>): number;
  55164. }
  55165. /**
  55166. * Class to keep track of devices
  55167. */
  55168. export class DeviceSourceManager implements IDisposable {
  55169. /**
  55170. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  55171. */
  55172. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  55173. /**
  55174. * Observable to be triggered when after a device is disconnected
  55175. */
  55176. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  55177. private readonly _devices;
  55178. private readonly _firstDevice;
  55179. private readonly _deviceInputSystem;
  55180. /**
  55181. * Default Constructor
  55182. * @param engine engine to pull input element from
  55183. */
  55184. constructor(engine: Engine);
  55185. /**
  55186. * Gets a DeviceSource, given a type and slot
  55187. * @param deviceType Enum specifying device type
  55188. * @param deviceSlot "Slot" or index that device is referenced in
  55189. * @returns DeviceSource object
  55190. */
  55191. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  55192. /**
  55193. * Gets an array of DeviceSource objects for a given device type
  55194. * @param deviceType Enum specifying device type
  55195. * @returns Array of DeviceSource objects
  55196. */
  55197. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  55198. /**
  55199. * Returns a read-only list of all available devices
  55200. * @returns Read-only array with active devices
  55201. */
  55202. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  55203. /**
  55204. * Dispose of DeviceInputSystem and other parts
  55205. */
  55206. dispose(): void;
  55207. /**
  55208. * Function to add device name to device list
  55209. * @param deviceType Enum specifying device type
  55210. * @param deviceSlot "Slot" or index that device is referenced in
  55211. */
  55212. private _addDevice;
  55213. /**
  55214. * Function to remove device name to device list
  55215. * @param deviceType Enum specifying device type
  55216. * @param deviceSlot "Slot" or index that device is referenced in
  55217. */
  55218. private _removeDevice;
  55219. /**
  55220. * Updates array storing first connected device of each type
  55221. * @param type Type of Device
  55222. */
  55223. private _updateFirstDevices;
  55224. }
  55225. }
  55226. declare module BABYLON {
  55227. /**
  55228. * Options to create the null engine
  55229. */
  55230. export class NullEngineOptions {
  55231. /**
  55232. * Render width (Default: 512)
  55233. */
  55234. renderWidth: number;
  55235. /**
  55236. * Render height (Default: 256)
  55237. */
  55238. renderHeight: number;
  55239. /**
  55240. * Texture size (Default: 512)
  55241. */
  55242. textureSize: number;
  55243. /**
  55244. * If delta time between frames should be constant
  55245. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55246. */
  55247. deterministicLockstep: boolean;
  55248. /**
  55249. * Maximum about of steps between frames (Default: 4)
  55250. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55251. */
  55252. lockstepMaxSteps: number;
  55253. /**
  55254. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  55255. */
  55256. useHighPrecisionMatrix?: boolean;
  55257. }
  55258. /**
  55259. * The null engine class provides support for headless version of babylon.js.
  55260. * This can be used in server side scenario or for testing purposes
  55261. */
  55262. export class NullEngine extends Engine {
  55263. private _options;
  55264. /**
  55265. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  55266. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55267. * @returns true if engine is in deterministic lock step mode
  55268. */
  55269. isDeterministicLockStep(): boolean;
  55270. /**
  55271. * Gets the max steps when engine is running in deterministic lock step
  55272. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55273. * @returns the max steps
  55274. */
  55275. getLockstepMaxSteps(): number;
  55276. /**
  55277. * Gets the current hardware scaling level.
  55278. * By default the hardware scaling level is computed from the window device ratio.
  55279. * 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.
  55280. * @returns a number indicating the current hardware scaling level
  55281. */
  55282. getHardwareScalingLevel(): number;
  55283. constructor(options?: NullEngineOptions);
  55284. /**
  55285. * Creates a vertex buffer
  55286. * @param vertices the data for the vertex buffer
  55287. * @returns the new WebGL static buffer
  55288. */
  55289. createVertexBuffer(vertices: FloatArray): DataBuffer;
  55290. /**
  55291. * Creates a new index buffer
  55292. * @param indices defines the content of the index buffer
  55293. * @param updatable defines if the index buffer must be updatable
  55294. * @returns a new webGL buffer
  55295. */
  55296. createIndexBuffer(indices: IndicesArray): DataBuffer;
  55297. /**
  55298. * Clear the current render buffer or the current render target (if any is set up)
  55299. * @param color defines the color to use
  55300. * @param backBuffer defines if the back buffer must be cleared
  55301. * @param depth defines if the depth buffer must be cleared
  55302. * @param stencil defines if the stencil buffer must be cleared
  55303. */
  55304. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55305. /**
  55306. * Gets the current render width
  55307. * @param useScreen defines if screen size must be used (or the current render target if any)
  55308. * @returns a number defining the current render width
  55309. */
  55310. getRenderWidth(useScreen?: boolean): number;
  55311. /**
  55312. * Gets the current render height
  55313. * @param useScreen defines if screen size must be used (or the current render target if any)
  55314. * @returns a number defining the current render height
  55315. */
  55316. getRenderHeight(useScreen?: boolean): number;
  55317. /**
  55318. * Set the WebGL's viewport
  55319. * @param viewport defines the viewport element to be used
  55320. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  55321. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  55322. */
  55323. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  55324. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  55325. /**
  55326. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  55327. * @param pipelineContext defines the pipeline context to use
  55328. * @param uniformsNames defines the list of uniform names
  55329. * @returns an array of webGL uniform locations
  55330. */
  55331. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  55332. /**
  55333. * Gets the lsit of active attributes for a given webGL program
  55334. * @param pipelineContext defines the pipeline context to use
  55335. * @param attributesNames defines the list of attribute names to get
  55336. * @returns an array of indices indicating the offset of each attribute
  55337. */
  55338. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55339. /**
  55340. * Binds an effect to the webGL context
  55341. * @param effect defines the effect to bind
  55342. */
  55343. bindSamplers(effect: Effect): void;
  55344. /**
  55345. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  55346. * @param effect defines the effect to activate
  55347. */
  55348. enableEffect(effect: Effect): void;
  55349. /**
  55350. * Set various states to the webGL context
  55351. * @param culling defines backface culling state
  55352. * @param zOffset defines the value to apply to zOffset (0 by default)
  55353. * @param force defines if states must be applied even if cache is up to date
  55354. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  55355. */
  55356. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55357. /**
  55358. * Set the value of an uniform to an array of int32
  55359. * @param uniform defines the webGL uniform location where to store the value
  55360. * @param array defines the array of int32 to store
  55361. * @returns true if value was set
  55362. */
  55363. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55364. /**
  55365. * Set the value of an uniform to an array of int32 (stored as vec2)
  55366. * @param uniform defines the webGL uniform location where to store the value
  55367. * @param array defines the array of int32 to store
  55368. * @returns true if value was set
  55369. */
  55370. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55371. /**
  55372. * Set the value of an uniform to an array of int32 (stored as vec3)
  55373. * @param uniform defines the webGL uniform location where to store the value
  55374. * @param array defines the array of int32 to store
  55375. * @returns true if value was set
  55376. */
  55377. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55378. /**
  55379. * Set the value of an uniform to an array of int32 (stored as vec4)
  55380. * @param uniform defines the webGL uniform location where to store the value
  55381. * @param array defines the array of int32 to store
  55382. * @returns true if value was set
  55383. */
  55384. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55385. /**
  55386. * Set the value of an uniform to an array of float32
  55387. * @param uniform defines the webGL uniform location where to store the value
  55388. * @param array defines the array of float32 to store
  55389. * @returns true if value was set
  55390. */
  55391. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55392. /**
  55393. * Set the value of an uniform to an array of float32 (stored as vec2)
  55394. * @param uniform defines the webGL uniform location where to store the value
  55395. * @param array defines the array of float32 to store
  55396. * @returns true if value was set
  55397. */
  55398. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55399. /**
  55400. * Set the value of an uniform to an array of float32 (stored as vec3)
  55401. * @param uniform defines the webGL uniform location where to store the value
  55402. * @param array defines the array of float32 to store
  55403. * @returns true if value was set
  55404. */
  55405. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55406. /**
  55407. * Set the value of an uniform to an array of float32 (stored as vec4)
  55408. * @param uniform defines the webGL uniform location where to store the value
  55409. * @param array defines the array of float32 to store
  55410. * @returns true if value was set
  55411. */
  55412. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55413. /**
  55414. * Set the value of an uniform to an array of number
  55415. * @param uniform defines the webGL uniform location where to store the value
  55416. * @param array defines the array of number to store
  55417. * @returns true if value was set
  55418. */
  55419. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55420. /**
  55421. * Set the value of an uniform to an array of number (stored as vec2)
  55422. * @param uniform defines the webGL uniform location where to store the value
  55423. * @param array defines the array of number to store
  55424. * @returns true if value was set
  55425. */
  55426. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55427. /**
  55428. * Set the value of an uniform to an array of number (stored as vec3)
  55429. * @param uniform defines the webGL uniform location where to store the value
  55430. * @param array defines the array of number to store
  55431. * @returns true if value was set
  55432. */
  55433. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55434. /**
  55435. * Set the value of an uniform to an array of number (stored as vec4)
  55436. * @param uniform defines the webGL uniform location where to store the value
  55437. * @param array defines the array of number to store
  55438. * @returns true if value was set
  55439. */
  55440. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55441. /**
  55442. * Set the value of an uniform to an array of float32 (stored as matrices)
  55443. * @param uniform defines the webGL uniform location where to store the value
  55444. * @param matrices defines the array of float32 to store
  55445. * @returns true if value was set
  55446. */
  55447. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55448. /**
  55449. * Set the value of an uniform to a matrix (3x3)
  55450. * @param uniform defines the webGL uniform location where to store the value
  55451. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  55452. * @returns true if value was set
  55453. */
  55454. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55455. /**
  55456. * Set the value of an uniform to a matrix (2x2)
  55457. * @param uniform defines the webGL uniform location where to store the value
  55458. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  55459. * @returns true if value was set
  55460. */
  55461. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55462. /**
  55463. * Set the value of an uniform to a number (float)
  55464. * @param uniform defines the webGL uniform location where to store the value
  55465. * @param value defines the float number to store
  55466. * @returns true if value was set
  55467. */
  55468. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55469. /**
  55470. * Set the value of an uniform to a vec2
  55471. * @param uniform defines the webGL uniform location where to store the value
  55472. * @param x defines the 1st component of the value
  55473. * @param y defines the 2nd component of the value
  55474. * @returns true if value was set
  55475. */
  55476. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55477. /**
  55478. * Set the value of an uniform to a vec3
  55479. * @param uniform defines the webGL uniform location where to store the value
  55480. * @param x defines the 1st component of the value
  55481. * @param y defines the 2nd component of the value
  55482. * @param z defines the 3rd component of the value
  55483. * @returns true if value was set
  55484. */
  55485. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55486. /**
  55487. * Set the value of an uniform to a boolean
  55488. * @param uniform defines the webGL uniform location where to store the value
  55489. * @param bool defines the boolean to store
  55490. * @returns true if value was set
  55491. */
  55492. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  55493. /**
  55494. * Set the value of an uniform to a vec4
  55495. * @param uniform defines the webGL uniform location where to store the value
  55496. * @param x defines the 1st component of the value
  55497. * @param y defines the 2nd component of the value
  55498. * @param z defines the 3rd component of the value
  55499. * @param w defines the 4th component of the value
  55500. * @returns true if value was set
  55501. */
  55502. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55503. /**
  55504. * Sets the current alpha mode
  55505. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  55506. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55507. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55508. */
  55509. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55510. /**
  55511. * Bind webGl buffers directly to the webGL context
  55512. * @param vertexBuffers defines the vertex buffer to bind
  55513. * @param indexBuffer defines the index buffer to bind
  55514. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  55515. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  55516. * @param effect defines the effect associated with the vertex buffer
  55517. */
  55518. bindBuffers(vertexBuffers: {
  55519. [key: string]: VertexBuffer;
  55520. }, indexBuffer: DataBuffer, effect: Effect): void;
  55521. /**
  55522. * Force the entire cache to be cleared
  55523. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  55524. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  55525. */
  55526. wipeCaches(bruteForce?: boolean): void;
  55527. /**
  55528. * Send a draw order
  55529. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  55530. * @param indexStart defines the starting index
  55531. * @param indexCount defines the number of index to draw
  55532. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55533. */
  55534. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  55535. /**
  55536. * Draw a list of indexed primitives
  55537. * @param fillMode defines the primitive to use
  55538. * @param indexStart defines the starting index
  55539. * @param indexCount defines the number of index to draw
  55540. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55541. */
  55542. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55543. /**
  55544. * Draw a list of unindexed primitives
  55545. * @param fillMode defines the primitive to use
  55546. * @param verticesStart defines the index of first vertex to draw
  55547. * @param verticesCount defines the count of vertices to draw
  55548. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55549. */
  55550. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55551. /** @hidden */
  55552. _createTexture(): WebGLTexture;
  55553. /** @hidden */
  55554. _releaseTexture(texture: InternalTexture): void;
  55555. /**
  55556. * Usually called from Texture.ts.
  55557. * Passed information to create a WebGLTexture
  55558. * @param urlArg defines a value which contains one of the following:
  55559. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55560. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55561. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55562. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55563. * @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)
  55564. * @param scene needed for loading to the correct scene
  55565. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55566. * @param onLoad optional callback to be called upon successful completion
  55567. * @param onError optional callback to be called upon failure
  55568. * @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
  55569. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55570. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55571. * @param forcedExtension defines the extension to use to pick the right loader
  55572. * @param mimeType defines an optional mime type
  55573. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55574. */
  55575. 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;
  55576. /**
  55577. * Creates a new render target texture
  55578. * @param size defines the size of the texture
  55579. * @param options defines the options used to create the texture
  55580. * @returns a new render target texture stored in an InternalTexture
  55581. */
  55582. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  55583. /**
  55584. * Update the sampling mode of a given texture
  55585. * @param samplingMode defines the required sampling mode
  55586. * @param texture defines the texture to update
  55587. */
  55588. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55589. /**
  55590. * Binds the frame buffer to the specified texture.
  55591. * @param texture The texture to render to or null for the default canvas
  55592. * @param faceIndex The face of the texture to render to in case of cube texture
  55593. * @param requiredWidth The width of the target to render to
  55594. * @param requiredHeight The height of the target to render to
  55595. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  55596. * @param lodLevel defines le lod level to bind to the frame buffer
  55597. */
  55598. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55599. /**
  55600. * Unbind the current render target texture from the webGL context
  55601. * @param texture defines the render target texture to unbind
  55602. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  55603. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  55604. */
  55605. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55606. /**
  55607. * Creates a dynamic vertex buffer
  55608. * @param vertices the data for the dynamic vertex buffer
  55609. * @returns the new WebGL dynamic buffer
  55610. */
  55611. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  55612. /**
  55613. * Update the content of a dynamic texture
  55614. * @param texture defines the texture to update
  55615. * @param canvas defines the canvas containing the source
  55616. * @param invertY defines if data must be stored with Y axis inverted
  55617. * @param premulAlpha defines if alpha is stored as premultiplied
  55618. * @param format defines the format of the data
  55619. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55620. */
  55621. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55622. /**
  55623. * Gets a boolean indicating if all created effects are ready
  55624. * @returns true if all effects are ready
  55625. */
  55626. areAllEffectsReady(): boolean;
  55627. /**
  55628. * @hidden
  55629. * Get the current error code of the webGL context
  55630. * @returns the error code
  55631. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  55632. */
  55633. getError(): number;
  55634. /** @hidden */
  55635. _getUnpackAlignement(): number;
  55636. /** @hidden */
  55637. _unpackFlipY(value: boolean): void;
  55638. /**
  55639. * Update a dynamic index buffer
  55640. * @param indexBuffer defines the target index buffer
  55641. * @param indices defines the data to update
  55642. * @param offset defines the offset in the target index buffer where update should start
  55643. */
  55644. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  55645. /**
  55646. * Updates a dynamic vertex buffer.
  55647. * @param vertexBuffer the vertex buffer to update
  55648. * @param vertices the data used to update the vertex buffer
  55649. * @param byteOffset the byte offset of the data (optional)
  55650. * @param byteLength the byte length of the data (optional)
  55651. */
  55652. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  55653. /** @hidden */
  55654. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  55655. /** @hidden */
  55656. _bindTexture(channel: number, texture: InternalTexture): void;
  55657. protected _deleteBuffer(buffer: WebGLBuffer): void;
  55658. /**
  55659. * 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
  55660. */
  55661. releaseEffects(): void;
  55662. displayLoadingUI(): void;
  55663. hideLoadingUI(): void;
  55664. /** @hidden */
  55665. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55666. /** @hidden */
  55667. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55668. /** @hidden */
  55669. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55670. /** @hidden */
  55671. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55672. }
  55673. }
  55674. declare module BABYLON {
  55675. /**
  55676. * @hidden
  55677. **/
  55678. export class _TimeToken {
  55679. _startTimeQuery: Nullable<WebGLQuery>;
  55680. _endTimeQuery: Nullable<WebGLQuery>;
  55681. _timeElapsedQuery: Nullable<WebGLQuery>;
  55682. _timeElapsedQueryEnded: boolean;
  55683. }
  55684. }
  55685. declare module BABYLON {
  55686. /** @hidden */
  55687. export class _OcclusionDataStorage {
  55688. /** @hidden */
  55689. occlusionInternalRetryCounter: number;
  55690. /** @hidden */
  55691. isOcclusionQueryInProgress: boolean;
  55692. /** @hidden */
  55693. isOccluded: boolean;
  55694. /** @hidden */
  55695. occlusionRetryCount: number;
  55696. /** @hidden */
  55697. occlusionType: number;
  55698. /** @hidden */
  55699. occlusionQueryAlgorithmType: number;
  55700. }
  55701. interface Engine {
  55702. /**
  55703. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  55704. * @return the new query
  55705. */
  55706. createQuery(): WebGLQuery;
  55707. /**
  55708. * Delete and release a webGL query
  55709. * @param query defines the query to delete
  55710. * @return the current engine
  55711. */
  55712. deleteQuery(query: WebGLQuery): Engine;
  55713. /**
  55714. * Check if a given query has resolved and got its value
  55715. * @param query defines the query to check
  55716. * @returns true if the query got its value
  55717. */
  55718. isQueryResultAvailable(query: WebGLQuery): boolean;
  55719. /**
  55720. * Gets the value of a given query
  55721. * @param query defines the query to check
  55722. * @returns the value of the query
  55723. */
  55724. getQueryResult(query: WebGLQuery): number;
  55725. /**
  55726. * Initiates an occlusion query
  55727. * @param algorithmType defines the algorithm to use
  55728. * @param query defines the query to use
  55729. * @returns the current engine
  55730. * @see https://doc.babylonjs.com/features/occlusionquery
  55731. */
  55732. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  55733. /**
  55734. * Ends an occlusion query
  55735. * @see https://doc.babylonjs.com/features/occlusionquery
  55736. * @param algorithmType defines the algorithm to use
  55737. * @returns the current engine
  55738. */
  55739. endOcclusionQuery(algorithmType: number): Engine;
  55740. /**
  55741. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  55742. * Please note that only one query can be issued at a time
  55743. * @returns a time token used to track the time span
  55744. */
  55745. startTimeQuery(): Nullable<_TimeToken>;
  55746. /**
  55747. * Ends a time query
  55748. * @param token defines the token used to measure the time span
  55749. * @returns the time spent (in ns)
  55750. */
  55751. endTimeQuery(token: _TimeToken): int;
  55752. /** @hidden */
  55753. _currentNonTimestampToken: Nullable<_TimeToken>;
  55754. /** @hidden */
  55755. _createTimeQuery(): WebGLQuery;
  55756. /** @hidden */
  55757. _deleteTimeQuery(query: WebGLQuery): void;
  55758. /** @hidden */
  55759. _getGlAlgorithmType(algorithmType: number): number;
  55760. /** @hidden */
  55761. _getTimeQueryResult(query: WebGLQuery): any;
  55762. /** @hidden */
  55763. _getTimeQueryAvailability(query: WebGLQuery): any;
  55764. }
  55765. interface AbstractMesh {
  55766. /**
  55767. * Backing filed
  55768. * @hidden
  55769. */
  55770. __occlusionDataStorage: _OcclusionDataStorage;
  55771. /**
  55772. * Access property
  55773. * @hidden
  55774. */
  55775. _occlusionDataStorage: _OcclusionDataStorage;
  55776. /**
  55777. * 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.
  55778. * The default value is -1 which means don't break the query and wait till the result
  55779. * @see https://doc.babylonjs.com/features/occlusionquery
  55780. */
  55781. occlusionRetryCount: number;
  55782. /**
  55783. * 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:
  55784. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  55785. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  55786. * * 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.
  55787. * @see https://doc.babylonjs.com/features/occlusionquery
  55788. */
  55789. occlusionType: number;
  55790. /**
  55791. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  55792. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  55793. * * 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.
  55794. * @see https://doc.babylonjs.com/features/occlusionquery
  55795. */
  55796. occlusionQueryAlgorithmType: number;
  55797. /**
  55798. * 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
  55799. * @see https://doc.babylonjs.com/features/occlusionquery
  55800. */
  55801. isOccluded: boolean;
  55802. /**
  55803. * Flag to check the progress status of the query
  55804. * @see https://doc.babylonjs.com/features/occlusionquery
  55805. */
  55806. isOcclusionQueryInProgress: boolean;
  55807. }
  55808. }
  55809. declare module BABYLON {
  55810. /** @hidden */
  55811. export var _forceTransformFeedbackToBundle: boolean;
  55812. interface Engine {
  55813. /**
  55814. * Creates a webGL transform feedback object
  55815. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  55816. * @returns the webGL transform feedback object
  55817. */
  55818. createTransformFeedback(): WebGLTransformFeedback;
  55819. /**
  55820. * Delete a webGL transform feedback object
  55821. * @param value defines the webGL transform feedback object to delete
  55822. */
  55823. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  55824. /**
  55825. * Bind a webGL transform feedback object to the webgl context
  55826. * @param value defines the webGL transform feedback object to bind
  55827. */
  55828. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  55829. /**
  55830. * Begins a transform feedback operation
  55831. * @param usePoints defines if points or triangles must be used
  55832. */
  55833. beginTransformFeedback(usePoints: boolean): void;
  55834. /**
  55835. * Ends a transform feedback operation
  55836. */
  55837. endTransformFeedback(): void;
  55838. /**
  55839. * Specify the varyings to use with transform feedback
  55840. * @param program defines the associated webGL program
  55841. * @param value defines the list of strings representing the varying names
  55842. */
  55843. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  55844. /**
  55845. * Bind a webGL buffer for a transform feedback operation
  55846. * @param value defines the webGL buffer to bind
  55847. */
  55848. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  55849. }
  55850. }
  55851. declare module BABYLON {
  55852. /**
  55853. * Class used to define an additional view for the engine
  55854. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55855. */
  55856. export class EngineView {
  55857. /** Defines the canvas where to render the view */
  55858. target: HTMLCanvasElement;
  55859. /** Defines an optional camera used to render the view (will use active camera else) */
  55860. camera?: Camera;
  55861. }
  55862. interface Engine {
  55863. /**
  55864. * Gets or sets the HTML element to use for attaching events
  55865. */
  55866. inputElement: Nullable<HTMLElement>;
  55867. /**
  55868. * Gets the current engine view
  55869. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55870. */
  55871. activeView: Nullable<EngineView>;
  55872. /** Gets or sets the list of views */
  55873. views: EngineView[];
  55874. /**
  55875. * Register a new child canvas
  55876. * @param canvas defines the canvas to register
  55877. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  55878. * @returns the associated view
  55879. */
  55880. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  55881. /**
  55882. * Remove a registered child canvas
  55883. * @param canvas defines the canvas to remove
  55884. * @returns the current engine
  55885. */
  55886. unRegisterView(canvas: HTMLCanvasElement): Engine;
  55887. }
  55888. }
  55889. declare module BABYLON {
  55890. interface Engine {
  55891. /** @hidden */
  55892. _excludedCompressedTextures: string[];
  55893. /** @hidden */
  55894. _textureFormatInUse: string;
  55895. /**
  55896. * Gets the list of texture formats supported
  55897. */
  55898. readonly texturesSupported: Array<string>;
  55899. /**
  55900. * Gets the texture format in use
  55901. */
  55902. readonly textureFormatInUse: Nullable<string>;
  55903. /**
  55904. * Set the compressed texture extensions or file names to skip.
  55905. *
  55906. * @param skippedFiles defines the list of those texture files you want to skip
  55907. * Example: [".dds", ".env", "myfile.png"]
  55908. */
  55909. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  55910. /**
  55911. * Set the compressed texture format to use, based on the formats you have, and the formats
  55912. * supported by the hardware / browser.
  55913. *
  55914. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  55915. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  55916. * to API arguments needed to compressed textures. This puts the burden on the container
  55917. * generator to house the arcane code for determining these for current & future formats.
  55918. *
  55919. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55920. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55921. *
  55922. * Note: The result of this call is not taken into account when a texture is base64.
  55923. *
  55924. * @param formatsAvailable defines the list of those format families you have created
  55925. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  55926. *
  55927. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  55928. * @returns The extension selected.
  55929. */
  55930. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  55931. }
  55932. }
  55933. declare module BABYLON {
  55934. /** @hidden */
  55935. export var rgbdEncodePixelShader: {
  55936. name: string;
  55937. shader: string;
  55938. };
  55939. }
  55940. declare module BABYLON {
  55941. /**
  55942. * Raw texture data and descriptor sufficient for WebGL texture upload
  55943. */
  55944. export interface EnvironmentTextureInfo {
  55945. /**
  55946. * Version of the environment map
  55947. */
  55948. version: number;
  55949. /**
  55950. * Width of image
  55951. */
  55952. width: number;
  55953. /**
  55954. * Irradiance information stored in the file.
  55955. */
  55956. irradiance: any;
  55957. /**
  55958. * Specular information stored in the file.
  55959. */
  55960. specular: any;
  55961. }
  55962. /**
  55963. * Defines One Image in the file. It requires only the position in the file
  55964. * as well as the length.
  55965. */
  55966. interface BufferImageData {
  55967. /**
  55968. * Length of the image data.
  55969. */
  55970. length: number;
  55971. /**
  55972. * Position of the data from the null terminator delimiting the end of the JSON.
  55973. */
  55974. position: number;
  55975. }
  55976. /**
  55977. * Defines the specular data enclosed in the file.
  55978. * This corresponds to the version 1 of the data.
  55979. */
  55980. export interface EnvironmentTextureSpecularInfoV1 {
  55981. /**
  55982. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  55983. */
  55984. specularDataPosition?: number;
  55985. /**
  55986. * This contains all the images data needed to reconstruct the cubemap.
  55987. */
  55988. mipmaps: Array<BufferImageData>;
  55989. /**
  55990. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  55991. */
  55992. lodGenerationScale: number;
  55993. }
  55994. /**
  55995. * Sets of helpers addressing the serialization and deserialization of environment texture
  55996. * stored in a BabylonJS env file.
  55997. * Those files are usually stored as .env files.
  55998. */
  55999. export class EnvironmentTextureTools {
  56000. /**
  56001. * Magic number identifying the env file.
  56002. */
  56003. private static _MagicBytes;
  56004. /**
  56005. * Gets the environment info from an env file.
  56006. * @param data The array buffer containing the .env bytes.
  56007. * @returns the environment file info (the json header) if successfully parsed.
  56008. */
  56009. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  56010. /**
  56011. * Creates an environment texture from a loaded cube texture.
  56012. * @param texture defines the cube texture to convert in env file
  56013. * @return a promise containing the environment data if succesfull.
  56014. */
  56015. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  56016. /**
  56017. * Creates a JSON representation of the spherical data.
  56018. * @param texture defines the texture containing the polynomials
  56019. * @return the JSON representation of the spherical info
  56020. */
  56021. private static _CreateEnvTextureIrradiance;
  56022. /**
  56023. * Creates the ArrayBufferViews used for initializing environment texture image data.
  56024. * @param data the image data
  56025. * @param info parameters that determine what views will be created for accessing the underlying buffer
  56026. * @return the views described by info providing access to the underlying buffer
  56027. */
  56028. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  56029. /**
  56030. * Uploads the texture info contained in the env file to the GPU.
  56031. * @param texture defines the internal texture to upload to
  56032. * @param data defines the data to load
  56033. * @param info defines the texture info retrieved through the GetEnvInfo method
  56034. * @returns a promise
  56035. */
  56036. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  56037. private static _OnImageReadyAsync;
  56038. /**
  56039. * Uploads the levels of image data to the GPU.
  56040. * @param texture defines the internal texture to upload to
  56041. * @param imageData defines the array buffer views of image data [mipmap][face]
  56042. * @returns a promise
  56043. */
  56044. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  56045. /**
  56046. * Uploads spherical polynomials information to the texture.
  56047. * @param texture defines the texture we are trying to upload the information to
  56048. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  56049. */
  56050. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  56051. /** @hidden */
  56052. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56053. }
  56054. }
  56055. declare module BABYLON {
  56056. /**
  56057. * Class used to inline functions in shader code
  56058. */
  56059. export class ShaderCodeInliner {
  56060. private static readonly _RegexpFindFunctionNameAndType;
  56061. private _sourceCode;
  56062. private _functionDescr;
  56063. private _numMaxIterations;
  56064. /** Gets or sets the token used to mark the functions to inline */
  56065. inlineToken: string;
  56066. /** Gets or sets the debug mode */
  56067. debug: boolean;
  56068. /** Gets the code after the inlining process */
  56069. get code(): string;
  56070. /**
  56071. * Initializes the inliner
  56072. * @param sourceCode shader code source to inline
  56073. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  56074. */
  56075. constructor(sourceCode: string, numMaxIterations?: number);
  56076. /**
  56077. * Start the processing of the shader code
  56078. */
  56079. processCode(): void;
  56080. private _collectFunctions;
  56081. private _processInlining;
  56082. private _extractBetweenMarkers;
  56083. private _skipWhitespaces;
  56084. private _removeComments;
  56085. private _replaceFunctionCallsByCode;
  56086. private _findBackward;
  56087. private _escapeRegExp;
  56088. private _replaceNames;
  56089. }
  56090. }
  56091. declare module BABYLON {
  56092. /**
  56093. * Container for accessors for natively-stored mesh data buffers.
  56094. */
  56095. class NativeDataBuffer extends DataBuffer {
  56096. /**
  56097. * Accessor value used to identify/retrieve a natively-stored index buffer.
  56098. */
  56099. nativeIndexBuffer?: any;
  56100. /**
  56101. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  56102. */
  56103. nativeVertexBuffer?: any;
  56104. }
  56105. /** @hidden */
  56106. class NativeTexture extends InternalTexture {
  56107. getInternalTexture(): InternalTexture;
  56108. getViewCount(): number;
  56109. }
  56110. /** @hidden */
  56111. export class NativeEngine extends Engine {
  56112. private readonly _native;
  56113. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  56114. private readonly INVALID_HANDLE;
  56115. private _boundBuffersVertexArray;
  56116. private _currentDepthTest;
  56117. getHardwareScalingLevel(): number;
  56118. constructor();
  56119. dispose(): void;
  56120. /**
  56121. * Can be used to override the current requestAnimationFrame requester.
  56122. * @hidden
  56123. */
  56124. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  56125. /**
  56126. * Override default engine behavior.
  56127. * @param color
  56128. * @param backBuffer
  56129. * @param depth
  56130. * @param stencil
  56131. */
  56132. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  56133. /**
  56134. * Gets host document
  56135. * @returns the host document object
  56136. */
  56137. getHostDocument(): Nullable<Document>;
  56138. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56139. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  56140. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  56141. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  56142. [key: string]: VertexBuffer;
  56143. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56144. bindBuffers(vertexBuffers: {
  56145. [key: string]: VertexBuffer;
  56146. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56147. recordVertexArrayObject(vertexBuffers: {
  56148. [key: string]: VertexBuffer;
  56149. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  56150. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56151. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56152. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56153. /**
  56154. * Draw a list of indexed primitives
  56155. * @param fillMode defines the primitive to use
  56156. * @param indexStart defines the starting index
  56157. * @param indexCount defines the number of index to draw
  56158. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56159. */
  56160. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56161. /**
  56162. * Draw a list of unindexed primitives
  56163. * @param fillMode defines the primitive to use
  56164. * @param verticesStart defines the index of first vertex to draw
  56165. * @param verticesCount defines the count of vertices to draw
  56166. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56167. */
  56168. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56169. createPipelineContext(): IPipelineContext;
  56170. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  56171. /** @hidden */
  56172. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  56173. /** @hidden */
  56174. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  56175. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56176. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56177. protected _setProgram(program: WebGLProgram): void;
  56178. _releaseEffect(effect: Effect): void;
  56179. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  56180. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  56181. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  56182. bindSamplers(effect: Effect): void;
  56183. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  56184. getRenderWidth(useScreen?: boolean): number;
  56185. getRenderHeight(useScreen?: boolean): number;
  56186. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  56187. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56188. /**
  56189. * Set the z offset to apply to current rendering
  56190. * @param value defines the offset to apply
  56191. */
  56192. setZOffset(value: number): void;
  56193. /**
  56194. * Gets the current value of the zOffset
  56195. * @returns the current zOffset state
  56196. */
  56197. getZOffset(): number;
  56198. /**
  56199. * Enable or disable depth buffering
  56200. * @param enable defines the state to set
  56201. */
  56202. setDepthBuffer(enable: boolean): void;
  56203. /**
  56204. * Gets a boolean indicating if depth writing is enabled
  56205. * @returns the current depth writing state
  56206. */
  56207. getDepthWrite(): boolean;
  56208. setDepthFunctionToGreater(): void;
  56209. setDepthFunctionToGreaterOrEqual(): void;
  56210. setDepthFunctionToLess(): void;
  56211. setDepthFunctionToLessOrEqual(): void;
  56212. /**
  56213. * Enable or disable depth writing
  56214. * @param enable defines the state to set
  56215. */
  56216. setDepthWrite(enable: boolean): void;
  56217. /**
  56218. * Enable or disable color writing
  56219. * @param enable defines the state to set
  56220. */
  56221. setColorWrite(enable: boolean): void;
  56222. /**
  56223. * Gets a boolean indicating if color writing is enabled
  56224. * @returns the current color writing state
  56225. */
  56226. getColorWrite(): boolean;
  56227. /**
  56228. * Sets alpha constants used by some alpha blending modes
  56229. * @param r defines the red component
  56230. * @param g defines the green component
  56231. * @param b defines the blue component
  56232. * @param a defines the alpha component
  56233. */
  56234. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  56235. /**
  56236. * Sets the current alpha mode
  56237. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  56238. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56239. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56240. */
  56241. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56242. /**
  56243. * Gets the current alpha mode
  56244. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56245. * @returns the current alpha mode
  56246. */
  56247. getAlphaMode(): number;
  56248. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  56249. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56250. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56251. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56252. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56253. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56254. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56255. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56256. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56257. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56258. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56259. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56260. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56261. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56262. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56263. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56264. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56265. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56266. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56267. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56268. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  56269. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  56270. wipeCaches(bruteForce?: boolean): void;
  56271. _createTexture(): WebGLTexture;
  56272. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  56273. /**
  56274. * Update the content of a dynamic texture
  56275. * @param texture defines the texture to update
  56276. * @param canvas defines the canvas containing the source
  56277. * @param invertY defines if data must be stored with Y axis inverted
  56278. * @param premulAlpha defines if alpha is stored as premultiplied
  56279. * @param format defines the format of the data
  56280. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56281. */
  56282. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56283. /**
  56284. * Usually called from Texture.ts.
  56285. * Passed information to create a WebGLTexture
  56286. * @param url defines a value which contains one of the following:
  56287. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56288. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56289. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56290. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56291. * @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)
  56292. * @param scene needed for loading to the correct scene
  56293. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56294. * @param onLoad optional callback to be called upon successful completion
  56295. * @param onError optional callback to be called upon failure
  56296. * @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
  56297. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56298. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56299. * @param forcedExtension defines the extension to use to pick the right loader
  56300. * @param mimeType defines an optional mime type
  56301. * @param loaderOptions options to be passed to the loader
  56302. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56303. */
  56304. 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;
  56305. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  56306. _releaseFramebufferObjects(texture: InternalTexture): void;
  56307. /**
  56308. * Creates a cube texture
  56309. * @param rootUrl defines the url where the files to load is located
  56310. * @param scene defines the current scene
  56311. * @param files defines the list of files to load (1 per face)
  56312. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  56313. * @param onLoad defines an optional callback raised when the texture is loaded
  56314. * @param onError defines an optional callback raised if there is an issue to load the texture
  56315. * @param format defines the format of the data
  56316. * @param forcedExtension defines the extension to use to pick the right loader
  56317. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  56318. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56319. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56320. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  56321. * @returns the cube texture as an InternalTexture
  56322. */
  56323. 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;
  56324. createRenderTargetTexture(size: number | {
  56325. width: number;
  56326. height: number;
  56327. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  56328. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56329. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56330. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56331. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  56332. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  56333. /**
  56334. * Updates a dynamic vertex buffer.
  56335. * @param vertexBuffer the vertex buffer to update
  56336. * @param data the data used to update the vertex buffer
  56337. * @param byteOffset the byte offset of the data (optional)
  56338. * @param byteLength the byte length of the data (optional)
  56339. */
  56340. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  56341. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  56342. private _updateAnisotropicLevel;
  56343. private _getAddressMode;
  56344. /** @hidden */
  56345. _bindTexture(channel: number, texture: InternalTexture): void;
  56346. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  56347. releaseEffects(): void;
  56348. /** @hidden */
  56349. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56350. /** @hidden */
  56351. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56352. /** @hidden */
  56353. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56354. /** @hidden */
  56355. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56356. private _getNativeSamplingMode;
  56357. private _getNativeTextureFormat;
  56358. private _getNativeAlphaMode;
  56359. private _getNativeAttribType;
  56360. }
  56361. }
  56362. declare module BABYLON {
  56363. /**
  56364. * Gather the list of clipboard event types as constants.
  56365. */
  56366. export class ClipboardEventTypes {
  56367. /**
  56368. * The clipboard event is fired when a copy command is active (pressed).
  56369. */
  56370. static readonly COPY: number;
  56371. /**
  56372. * The clipboard event is fired when a cut command is active (pressed).
  56373. */
  56374. static readonly CUT: number;
  56375. /**
  56376. * The clipboard event is fired when a paste command is active (pressed).
  56377. */
  56378. static readonly PASTE: number;
  56379. }
  56380. /**
  56381. * This class is used to store clipboard related info for the onClipboardObservable event.
  56382. */
  56383. export class ClipboardInfo {
  56384. /**
  56385. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56386. */
  56387. type: number;
  56388. /**
  56389. * Defines the related dom event
  56390. */
  56391. event: ClipboardEvent;
  56392. /**
  56393. *Creates an instance of ClipboardInfo.
  56394. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  56395. * @param event Defines the related dom event
  56396. */
  56397. constructor(
  56398. /**
  56399. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56400. */
  56401. type: number,
  56402. /**
  56403. * Defines the related dom event
  56404. */
  56405. event: ClipboardEvent);
  56406. /**
  56407. * Get the clipboard event's type from the keycode.
  56408. * @param keyCode Defines the keyCode for the current keyboard event.
  56409. * @return {number}
  56410. */
  56411. static GetTypeFromCharacter(keyCode: number): number;
  56412. }
  56413. }
  56414. declare module BABYLON {
  56415. /**
  56416. * Google Daydream controller
  56417. */
  56418. export class DaydreamController extends WebVRController {
  56419. /**
  56420. * Base Url for the controller model.
  56421. */
  56422. static MODEL_BASE_URL: string;
  56423. /**
  56424. * File name for the controller model.
  56425. */
  56426. static MODEL_FILENAME: string;
  56427. /**
  56428. * Gamepad Id prefix used to identify Daydream Controller.
  56429. */
  56430. static readonly GAMEPAD_ID_PREFIX: string;
  56431. /**
  56432. * Creates a new DaydreamController from a gamepad
  56433. * @param vrGamepad the gamepad that the controller should be created from
  56434. */
  56435. constructor(vrGamepad: any);
  56436. /**
  56437. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56438. * @param scene scene in which to add meshes
  56439. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56440. */
  56441. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56442. /**
  56443. * Called once for each button that changed state since the last frame
  56444. * @param buttonIdx Which button index changed
  56445. * @param state New state of the button
  56446. * @param changes Which properties on the state changed since last frame
  56447. */
  56448. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56449. }
  56450. }
  56451. declare module BABYLON {
  56452. /**
  56453. * Gear VR Controller
  56454. */
  56455. export class GearVRController extends WebVRController {
  56456. /**
  56457. * Base Url for the controller model.
  56458. */
  56459. static MODEL_BASE_URL: string;
  56460. /**
  56461. * File name for the controller model.
  56462. */
  56463. static MODEL_FILENAME: string;
  56464. /**
  56465. * Gamepad Id prefix used to identify this controller.
  56466. */
  56467. static readonly GAMEPAD_ID_PREFIX: string;
  56468. private readonly _buttonIndexToObservableNameMap;
  56469. /**
  56470. * Creates a new GearVRController from a gamepad
  56471. * @param vrGamepad the gamepad that the controller should be created from
  56472. */
  56473. constructor(vrGamepad: any);
  56474. /**
  56475. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56476. * @param scene scene in which to add meshes
  56477. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56478. */
  56479. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56480. /**
  56481. * Called once for each button that changed state since the last frame
  56482. * @param buttonIdx Which button index changed
  56483. * @param state New state of the button
  56484. * @param changes Which properties on the state changed since last frame
  56485. */
  56486. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56487. }
  56488. }
  56489. declare module BABYLON {
  56490. /**
  56491. * Generic Controller
  56492. */
  56493. export class GenericController extends WebVRController {
  56494. /**
  56495. * Base Url for the controller model.
  56496. */
  56497. static readonly MODEL_BASE_URL: string;
  56498. /**
  56499. * File name for the controller model.
  56500. */
  56501. static readonly MODEL_FILENAME: string;
  56502. /**
  56503. * Creates a new GenericController from a gamepad
  56504. * @param vrGamepad the gamepad that the controller should be created from
  56505. */
  56506. constructor(vrGamepad: any);
  56507. /**
  56508. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56509. * @param scene scene in which to add meshes
  56510. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56511. */
  56512. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56513. /**
  56514. * Called once for each button that changed state since the last frame
  56515. * @param buttonIdx Which button index changed
  56516. * @param state New state of the button
  56517. * @param changes Which properties on the state changed since last frame
  56518. */
  56519. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56520. }
  56521. }
  56522. declare module BABYLON {
  56523. /**
  56524. * Oculus Touch Controller
  56525. */
  56526. export class OculusTouchController extends WebVRController {
  56527. /**
  56528. * Base Url for the controller model.
  56529. */
  56530. static MODEL_BASE_URL: string;
  56531. /**
  56532. * File name for the left controller model.
  56533. */
  56534. static MODEL_LEFT_FILENAME: string;
  56535. /**
  56536. * File name for the right controller model.
  56537. */
  56538. static MODEL_RIGHT_FILENAME: string;
  56539. /**
  56540. * Base Url for the Quest controller model.
  56541. */
  56542. static QUEST_MODEL_BASE_URL: string;
  56543. /**
  56544. * @hidden
  56545. * If the controllers are running on a device that needs the updated Quest controller models
  56546. */
  56547. static _IsQuest: boolean;
  56548. /**
  56549. * Fired when the secondary trigger on this controller is modified
  56550. */
  56551. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  56552. /**
  56553. * Fired when the thumb rest on this controller is modified
  56554. */
  56555. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  56556. /**
  56557. * Creates a new OculusTouchController from a gamepad
  56558. * @param vrGamepad the gamepad that the controller should be created from
  56559. */
  56560. constructor(vrGamepad: any);
  56561. /**
  56562. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56563. * @param scene scene in which to add meshes
  56564. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56565. */
  56566. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56567. /**
  56568. * Fired when the A button on this controller is modified
  56569. */
  56570. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56571. /**
  56572. * Fired when the B button on this controller is modified
  56573. */
  56574. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56575. /**
  56576. * Fired when the X button on this controller is modified
  56577. */
  56578. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56579. /**
  56580. * Fired when the Y button on this controller is modified
  56581. */
  56582. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56583. /**
  56584. * Called once for each button that changed state since the last frame
  56585. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  56586. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  56587. * 2) secondary trigger (same)
  56588. * 3) A (right) X (left), touch, pressed = value
  56589. * 4) B / Y
  56590. * 5) thumb rest
  56591. * @param buttonIdx Which button index changed
  56592. * @param state New state of the button
  56593. * @param changes Which properties on the state changed since last frame
  56594. */
  56595. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56596. }
  56597. }
  56598. declare module BABYLON {
  56599. /**
  56600. * Vive Controller
  56601. */
  56602. export class ViveController extends WebVRController {
  56603. /**
  56604. * Base Url for the controller model.
  56605. */
  56606. static MODEL_BASE_URL: string;
  56607. /**
  56608. * File name for the controller model.
  56609. */
  56610. static MODEL_FILENAME: string;
  56611. /**
  56612. * Creates a new ViveController from a gamepad
  56613. * @param vrGamepad the gamepad that the controller should be created from
  56614. */
  56615. constructor(vrGamepad: any);
  56616. /**
  56617. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56618. * @param scene scene in which to add meshes
  56619. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56620. */
  56621. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56622. /**
  56623. * Fired when the left button on this controller is modified
  56624. */
  56625. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56626. /**
  56627. * Fired when the right button on this controller is modified
  56628. */
  56629. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56630. /**
  56631. * Fired when the menu button on this controller is modified
  56632. */
  56633. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56634. /**
  56635. * Called once for each button that changed state since the last frame
  56636. * Vive mapping:
  56637. * 0: touchpad
  56638. * 1: trigger
  56639. * 2: left AND right buttons
  56640. * 3: menu button
  56641. * @param buttonIdx Which button index changed
  56642. * @param state New state of the button
  56643. * @param changes Which properties on the state changed since last frame
  56644. */
  56645. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56646. }
  56647. }
  56648. declare module BABYLON {
  56649. /**
  56650. * Defines the WindowsMotionController object that the state of the windows motion controller
  56651. */
  56652. export class WindowsMotionController extends WebVRController {
  56653. /**
  56654. * The base url used to load the left and right controller models
  56655. */
  56656. static MODEL_BASE_URL: string;
  56657. /**
  56658. * The name of the left controller model file
  56659. */
  56660. static MODEL_LEFT_FILENAME: string;
  56661. /**
  56662. * The name of the right controller model file
  56663. */
  56664. static MODEL_RIGHT_FILENAME: string;
  56665. /**
  56666. * The controller name prefix for this controller type
  56667. */
  56668. static readonly GAMEPAD_ID_PREFIX: string;
  56669. /**
  56670. * The controller id pattern for this controller type
  56671. */
  56672. private static readonly GAMEPAD_ID_PATTERN;
  56673. private _loadedMeshInfo;
  56674. protected readonly _mapping: {
  56675. buttons: string[];
  56676. buttonMeshNames: {
  56677. trigger: string;
  56678. menu: string;
  56679. grip: string;
  56680. thumbstick: string;
  56681. trackpad: string;
  56682. };
  56683. buttonObservableNames: {
  56684. trigger: string;
  56685. menu: string;
  56686. grip: string;
  56687. thumbstick: string;
  56688. trackpad: string;
  56689. };
  56690. axisMeshNames: string[];
  56691. pointingPoseMeshName: string;
  56692. };
  56693. /**
  56694. * Fired when the trackpad on this controller is clicked
  56695. */
  56696. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56697. /**
  56698. * Fired when the trackpad on this controller is modified
  56699. */
  56700. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56701. /**
  56702. * The current x and y values of this controller's trackpad
  56703. */
  56704. trackpad: StickValues;
  56705. /**
  56706. * Creates a new WindowsMotionController from a gamepad
  56707. * @param vrGamepad the gamepad that the controller should be created from
  56708. */
  56709. constructor(vrGamepad: any);
  56710. /**
  56711. * Fired when the trigger on this controller is modified
  56712. */
  56713. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56714. /**
  56715. * Fired when the menu button on this controller is modified
  56716. */
  56717. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56718. /**
  56719. * Fired when the grip button on this controller is modified
  56720. */
  56721. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56722. /**
  56723. * Fired when the thumbstick button on this controller is modified
  56724. */
  56725. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56726. /**
  56727. * Fired when the touchpad button on this controller is modified
  56728. */
  56729. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56730. /**
  56731. * Fired when the touchpad values on this controller are modified
  56732. */
  56733. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  56734. protected _updateTrackpad(): void;
  56735. /**
  56736. * Called once per frame by the engine.
  56737. */
  56738. update(): void;
  56739. /**
  56740. * Called once for each button that changed state since the last frame
  56741. * @param buttonIdx Which button index changed
  56742. * @param state New state of the button
  56743. * @param changes Which properties on the state changed since last frame
  56744. */
  56745. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56746. /**
  56747. * Moves the buttons on the controller mesh based on their current state
  56748. * @param buttonName the name of the button to move
  56749. * @param buttonValue the value of the button which determines the buttons new position
  56750. */
  56751. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  56752. /**
  56753. * Moves the axis on the controller mesh based on its current state
  56754. * @param axis the index of the axis
  56755. * @param axisValue the value of the axis which determines the meshes new position
  56756. * @hidden
  56757. */
  56758. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  56759. /**
  56760. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56761. * @param scene scene in which to add meshes
  56762. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56763. */
  56764. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  56765. /**
  56766. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  56767. * can be transformed by button presses and axes values, based on this._mapping.
  56768. *
  56769. * @param scene scene in which the meshes exist
  56770. * @param meshes list of meshes that make up the controller model to process
  56771. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  56772. */
  56773. private processModel;
  56774. private createMeshInfo;
  56775. /**
  56776. * Gets the ray of the controller in the direction the controller is pointing
  56777. * @param length the length the resulting ray should be
  56778. * @returns a ray in the direction the controller is pointing
  56779. */
  56780. getForwardRay(length?: number): Ray;
  56781. /**
  56782. * Disposes of the controller
  56783. */
  56784. dispose(): void;
  56785. }
  56786. /**
  56787. * This class represents a new windows motion controller in XR.
  56788. */
  56789. export class XRWindowsMotionController extends WindowsMotionController {
  56790. /**
  56791. * Changing the original WIndowsMotionController mapping to fir the new mapping
  56792. */
  56793. protected readonly _mapping: {
  56794. buttons: string[];
  56795. buttonMeshNames: {
  56796. trigger: string;
  56797. menu: string;
  56798. grip: string;
  56799. thumbstick: string;
  56800. trackpad: string;
  56801. };
  56802. buttonObservableNames: {
  56803. trigger: string;
  56804. menu: string;
  56805. grip: string;
  56806. thumbstick: string;
  56807. trackpad: string;
  56808. };
  56809. axisMeshNames: string[];
  56810. pointingPoseMeshName: string;
  56811. };
  56812. /**
  56813. * Construct a new XR-Based windows motion controller
  56814. *
  56815. * @param gamepadInfo the gamepad object from the browser
  56816. */
  56817. constructor(gamepadInfo: any);
  56818. /**
  56819. * holds the thumbstick values (X,Y)
  56820. */
  56821. thumbstickValues: StickValues;
  56822. /**
  56823. * Fired when the thumbstick on this controller is clicked
  56824. */
  56825. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  56826. /**
  56827. * Fired when the thumbstick on this controller is modified
  56828. */
  56829. onThumbstickValuesChangedObservable: Observable<StickValues>;
  56830. /**
  56831. * Fired when the touchpad button on this controller is modified
  56832. */
  56833. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56834. /**
  56835. * Fired when the touchpad values on this controller are modified
  56836. */
  56837. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56838. /**
  56839. * Fired when the thumbstick button on this controller is modified
  56840. * here to prevent breaking changes
  56841. */
  56842. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56843. /**
  56844. * updating the thumbstick(!) and not the trackpad.
  56845. * This is named this way due to the difference between WebVR and XR and to avoid
  56846. * changing the parent class.
  56847. */
  56848. protected _updateTrackpad(): void;
  56849. /**
  56850. * Disposes the class with joy
  56851. */
  56852. dispose(): void;
  56853. }
  56854. }
  56855. declare module BABYLON {
  56856. /**
  56857. * Class containing static functions to help procedurally build meshes
  56858. */
  56859. export class PolyhedronBuilder {
  56860. /**
  56861. * Creates a polyhedron mesh
  56862. * * 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
  56863. * * The parameter `size` (positive float, default 1) sets the polygon size
  56864. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56865. * * 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`
  56866. * * 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
  56867. * * 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)`)
  56868. * * 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
  56869. * * 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
  56870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56871. * * 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
  56872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56873. * @param name defines the name of the mesh
  56874. * @param options defines the options used to create the mesh
  56875. * @param scene defines the hosting scene
  56876. * @returns the polyhedron mesh
  56877. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56878. */
  56879. static CreatePolyhedron(name: string, options: {
  56880. type?: number;
  56881. size?: number;
  56882. sizeX?: number;
  56883. sizeY?: number;
  56884. sizeZ?: number;
  56885. custom?: any;
  56886. faceUV?: Vector4[];
  56887. faceColors?: Color4[];
  56888. flat?: boolean;
  56889. updatable?: boolean;
  56890. sideOrientation?: number;
  56891. frontUVs?: Vector4;
  56892. backUVs?: Vector4;
  56893. }, scene?: Nullable<Scene>): Mesh;
  56894. }
  56895. }
  56896. declare module BABYLON {
  56897. /**
  56898. * Gizmo that enables scaling a mesh along 3 axis
  56899. */
  56900. export class ScaleGizmo extends Gizmo {
  56901. /**
  56902. * Internal gizmo used for interactions on the x axis
  56903. */
  56904. xGizmo: AxisScaleGizmo;
  56905. /**
  56906. * Internal gizmo used for interactions on the y axis
  56907. */
  56908. yGizmo: AxisScaleGizmo;
  56909. /**
  56910. * Internal gizmo used for interactions on the z axis
  56911. */
  56912. zGizmo: AxisScaleGizmo;
  56913. /**
  56914. * Internal gizmo used to scale all axis equally
  56915. */
  56916. uniformScaleGizmo: AxisScaleGizmo;
  56917. private _meshAttached;
  56918. private _nodeAttached;
  56919. private _snapDistance;
  56920. private _uniformScalingMesh;
  56921. private _octahedron;
  56922. private _sensitivity;
  56923. /** Fires an event when any of it's sub gizmos are dragged */
  56924. onDragStartObservable: Observable<unknown>;
  56925. /** Fires an event when any of it's sub gizmos are released from dragging */
  56926. onDragEndObservable: Observable<unknown>;
  56927. get attachedMesh(): Nullable<AbstractMesh>;
  56928. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56929. get attachedNode(): Nullable<Node>;
  56930. set attachedNode(node: Nullable<Node>);
  56931. /**
  56932. * True when the mouse pointer is hovering a gizmo mesh
  56933. */
  56934. get isHovered(): boolean;
  56935. /**
  56936. * Creates a ScaleGizmo
  56937. * @param gizmoLayer The utility layer the gizmo will be added to
  56938. * @param thickness display gizmo axis thickness
  56939. */
  56940. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56941. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56942. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56943. /**
  56944. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56945. */
  56946. set snapDistance(value: number);
  56947. get snapDistance(): number;
  56948. /**
  56949. * Ratio for the scale of the gizmo (Default: 1)
  56950. */
  56951. set scaleRatio(value: number);
  56952. get scaleRatio(): number;
  56953. /**
  56954. * Sensitivity factor for dragging (Default: 1)
  56955. */
  56956. set sensitivity(value: number);
  56957. get sensitivity(): number;
  56958. /**
  56959. * Disposes of the gizmo
  56960. */
  56961. dispose(): void;
  56962. }
  56963. }
  56964. declare module BABYLON {
  56965. /**
  56966. * Single axis scale gizmo
  56967. */
  56968. export class AxisScaleGizmo extends Gizmo {
  56969. /**
  56970. * Drag behavior responsible for the gizmos dragging interactions
  56971. */
  56972. dragBehavior: PointerDragBehavior;
  56973. private _pointerObserver;
  56974. /**
  56975. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56976. */
  56977. snapDistance: number;
  56978. /**
  56979. * Event that fires each time the gizmo snaps to a new location.
  56980. * * snapDistance is the the change in distance
  56981. */
  56982. onSnapObservable: Observable<{
  56983. snapDistance: number;
  56984. }>;
  56985. /**
  56986. * If the scaling operation should be done on all axis (default: false)
  56987. */
  56988. uniformScaling: boolean;
  56989. /**
  56990. * Custom sensitivity value for the drag strength
  56991. */
  56992. sensitivity: number;
  56993. private _isEnabled;
  56994. private _parent;
  56995. private _arrow;
  56996. private _coloredMaterial;
  56997. private _hoverMaterial;
  56998. /**
  56999. * Creates an AxisScaleGizmo
  57000. * @param gizmoLayer The utility layer the gizmo will be added to
  57001. * @param dragAxis The axis which the gizmo will be able to scale on
  57002. * @param color The color of the gizmo
  57003. * @param thickness display gizmo axis thickness
  57004. */
  57005. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  57006. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57007. /**
  57008. * If the gizmo is enabled
  57009. */
  57010. set isEnabled(value: boolean);
  57011. get isEnabled(): boolean;
  57012. /**
  57013. * Disposes of the gizmo
  57014. */
  57015. dispose(): void;
  57016. /**
  57017. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57018. * @param mesh The mesh to replace the default mesh of the gizmo
  57019. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  57020. */
  57021. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  57022. }
  57023. }
  57024. declare module BABYLON {
  57025. /**
  57026. * Bounding box gizmo
  57027. */
  57028. export class BoundingBoxGizmo extends Gizmo {
  57029. private _lineBoundingBox;
  57030. private _rotateSpheresParent;
  57031. private _scaleBoxesParent;
  57032. private _boundingDimensions;
  57033. private _renderObserver;
  57034. private _pointerObserver;
  57035. private _scaleDragSpeed;
  57036. private _tmpQuaternion;
  57037. private _tmpVector;
  57038. private _tmpRotationMatrix;
  57039. /**
  57040. * 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)
  57041. */
  57042. ignoreChildren: boolean;
  57043. /**
  57044. * 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)
  57045. */
  57046. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  57047. /**
  57048. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  57049. */
  57050. rotationSphereSize: number;
  57051. /**
  57052. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  57053. */
  57054. scaleBoxSize: number;
  57055. /**
  57056. * 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)
  57057. */
  57058. fixedDragMeshScreenSize: boolean;
  57059. /**
  57060. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  57061. */
  57062. fixedDragMeshScreenSizeDistanceFactor: number;
  57063. /**
  57064. * Fired when a rotation sphere or scale box is dragged
  57065. */
  57066. onDragStartObservable: Observable<{}>;
  57067. /**
  57068. * Fired when a scale box is dragged
  57069. */
  57070. onScaleBoxDragObservable: Observable<{}>;
  57071. /**
  57072. * Fired when a scale box drag is ended
  57073. */
  57074. onScaleBoxDragEndObservable: Observable<{}>;
  57075. /**
  57076. * Fired when a rotation sphere is dragged
  57077. */
  57078. onRotationSphereDragObservable: Observable<{}>;
  57079. /**
  57080. * Fired when a rotation sphere drag is ended
  57081. */
  57082. onRotationSphereDragEndObservable: Observable<{}>;
  57083. /**
  57084. * 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)
  57085. */
  57086. scalePivot: Nullable<Vector3>;
  57087. /**
  57088. * Mesh used as a pivot to rotate the attached node
  57089. */
  57090. private _anchorMesh;
  57091. private _existingMeshScale;
  57092. private _dragMesh;
  57093. private pointerDragBehavior;
  57094. private coloredMaterial;
  57095. private hoverColoredMaterial;
  57096. /**
  57097. * Sets the color of the bounding box gizmo
  57098. * @param color the color to set
  57099. */
  57100. setColor(color: Color3): void;
  57101. /**
  57102. * Creates an BoundingBoxGizmo
  57103. * @param gizmoLayer The utility layer the gizmo will be added to
  57104. * @param color The color of the gizmo
  57105. */
  57106. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57107. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57108. private _selectNode;
  57109. /**
  57110. * Updates the bounding box information for the Gizmo
  57111. */
  57112. updateBoundingBox(): void;
  57113. private _updateRotationSpheres;
  57114. private _updateScaleBoxes;
  57115. /**
  57116. * Enables rotation on the specified axis and disables rotation on the others
  57117. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57118. */
  57119. setEnabledRotationAxis(axis: string): void;
  57120. /**
  57121. * Enables/disables scaling
  57122. * @param enable if scaling should be enabled
  57123. * @param homogeneousScaling defines if scaling should only be homogeneous
  57124. */
  57125. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57126. private _updateDummy;
  57127. /**
  57128. * Enables a pointer drag behavior on the bounding box of the gizmo
  57129. */
  57130. enableDragBehavior(): void;
  57131. /**
  57132. * Disposes of the gizmo
  57133. */
  57134. dispose(): void;
  57135. /**
  57136. * 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)
  57137. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57138. * @returns the bounding box mesh with the passed in mesh as a child
  57139. */
  57140. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57141. /**
  57142. * CustomMeshes are not supported by this gizmo
  57143. * @param mesh The mesh to replace the default mesh of the gizmo
  57144. */
  57145. setCustomMesh(mesh: Mesh): void;
  57146. }
  57147. }
  57148. declare module BABYLON {
  57149. /**
  57150. * Single plane rotation gizmo
  57151. */
  57152. export class PlaneRotationGizmo extends Gizmo {
  57153. /**
  57154. * Drag behavior responsible for the gizmos dragging interactions
  57155. */
  57156. dragBehavior: PointerDragBehavior;
  57157. private _pointerObserver;
  57158. /**
  57159. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57160. */
  57161. snapDistance: number;
  57162. /**
  57163. * Event that fires each time the gizmo snaps to a new location.
  57164. * * snapDistance is the the change in distance
  57165. */
  57166. onSnapObservable: Observable<{
  57167. snapDistance: number;
  57168. }>;
  57169. private _isEnabled;
  57170. private _parent;
  57171. /**
  57172. * Creates a PlaneRotationGizmo
  57173. * @param gizmoLayer The utility layer the gizmo will be added to
  57174. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57175. * @param color The color of the gizmo
  57176. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57177. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57178. * @param thickness display gizmo axis thickness
  57179. */
  57180. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57181. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57182. /**
  57183. * If the gizmo is enabled
  57184. */
  57185. set isEnabled(value: boolean);
  57186. get isEnabled(): boolean;
  57187. /**
  57188. * Disposes of the gizmo
  57189. */
  57190. dispose(): void;
  57191. }
  57192. }
  57193. declare module BABYLON {
  57194. /**
  57195. * Gizmo that enables rotating a mesh along 3 axis
  57196. */
  57197. export class RotationGizmo extends Gizmo {
  57198. /**
  57199. * Internal gizmo used for interactions on the x axis
  57200. */
  57201. xGizmo: PlaneRotationGizmo;
  57202. /**
  57203. * Internal gizmo used for interactions on the y axis
  57204. */
  57205. yGizmo: PlaneRotationGizmo;
  57206. /**
  57207. * Internal gizmo used for interactions on the z axis
  57208. */
  57209. zGizmo: PlaneRotationGizmo;
  57210. /** Fires an event when any of it's sub gizmos are dragged */
  57211. onDragStartObservable: Observable<unknown>;
  57212. /** Fires an event when any of it's sub gizmos are released from dragging */
  57213. onDragEndObservable: Observable<unknown>;
  57214. private _meshAttached;
  57215. private _nodeAttached;
  57216. get attachedMesh(): Nullable<AbstractMesh>;
  57217. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57218. get attachedNode(): Nullable<Node>;
  57219. set attachedNode(node: Nullable<Node>);
  57220. protected _checkBillboardTransform(): void;
  57221. /**
  57222. * True when the mouse pointer is hovering a gizmo mesh
  57223. */
  57224. get isHovered(): boolean;
  57225. /**
  57226. * Creates a RotationGizmo
  57227. * @param gizmoLayer The utility layer the gizmo will be added to
  57228. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57229. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57230. * @param thickness display gizmo axis thickness
  57231. */
  57232. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  57233. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57234. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57235. /**
  57236. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57237. */
  57238. set snapDistance(value: number);
  57239. get snapDistance(): number;
  57240. /**
  57241. * Ratio for the scale of the gizmo (Default: 1)
  57242. */
  57243. set scaleRatio(value: number);
  57244. get scaleRatio(): number;
  57245. /**
  57246. * Disposes of the gizmo
  57247. */
  57248. dispose(): void;
  57249. /**
  57250. * CustomMeshes are not supported by this gizmo
  57251. * @param mesh The mesh to replace the default mesh of the gizmo
  57252. */
  57253. setCustomMesh(mesh: Mesh): void;
  57254. }
  57255. }
  57256. declare module BABYLON {
  57257. /**
  57258. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57259. */
  57260. export class GizmoManager implements IDisposable {
  57261. private scene;
  57262. /**
  57263. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57264. */
  57265. gizmos: {
  57266. positionGizmo: Nullable<PositionGizmo>;
  57267. rotationGizmo: Nullable<RotationGizmo>;
  57268. scaleGizmo: Nullable<ScaleGizmo>;
  57269. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57270. };
  57271. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57272. clearGizmoOnEmptyPointerEvent: boolean;
  57273. /** Fires an event when the manager is attached to a mesh */
  57274. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57275. /** Fires an event when the manager is attached to a node */
  57276. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57277. private _gizmosEnabled;
  57278. private _pointerObserver;
  57279. private _attachedMesh;
  57280. private _attachedNode;
  57281. private _boundingBoxColor;
  57282. private _defaultUtilityLayer;
  57283. private _defaultKeepDepthUtilityLayer;
  57284. private _thickness;
  57285. /**
  57286. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57287. */
  57288. boundingBoxDragBehavior: SixDofDragBehavior;
  57289. /**
  57290. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57291. */
  57292. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57293. /**
  57294. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57295. */
  57296. attachableNodes: Nullable<Array<Node>>;
  57297. /**
  57298. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57299. */
  57300. usePointerToAttachGizmos: boolean;
  57301. /**
  57302. * Utility layer that the bounding box gizmo belongs to
  57303. */
  57304. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57305. /**
  57306. * Utility layer that all gizmos besides bounding box belong to
  57307. */
  57308. get utilityLayer(): UtilityLayerRenderer;
  57309. /**
  57310. * True when the mouse pointer is hovering a gizmo mesh
  57311. */
  57312. get isHovered(): boolean;
  57313. /**
  57314. * Instatiates a gizmo manager
  57315. * @param scene the scene to overlay the gizmos on top of
  57316. * @param thickness display gizmo axis thickness
  57317. */
  57318. constructor(scene: Scene, thickness?: number);
  57319. /**
  57320. * Attaches a set of gizmos to the specified mesh
  57321. * @param mesh The mesh the gizmo's should be attached to
  57322. */
  57323. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57324. /**
  57325. * Attaches a set of gizmos to the specified node
  57326. * @param node The node the gizmo's should be attached to
  57327. */
  57328. attachToNode(node: Nullable<Node>): void;
  57329. /**
  57330. * If the position gizmo is enabled
  57331. */
  57332. set positionGizmoEnabled(value: boolean);
  57333. get positionGizmoEnabled(): boolean;
  57334. /**
  57335. * If the rotation gizmo is enabled
  57336. */
  57337. set rotationGizmoEnabled(value: boolean);
  57338. get rotationGizmoEnabled(): boolean;
  57339. /**
  57340. * If the scale gizmo is enabled
  57341. */
  57342. set scaleGizmoEnabled(value: boolean);
  57343. get scaleGizmoEnabled(): boolean;
  57344. /**
  57345. * If the boundingBox gizmo is enabled
  57346. */
  57347. set boundingBoxGizmoEnabled(value: boolean);
  57348. get boundingBoxGizmoEnabled(): boolean;
  57349. /**
  57350. * Disposes of the gizmo manager
  57351. */
  57352. dispose(): void;
  57353. }
  57354. }
  57355. declare module BABYLON {
  57356. /**
  57357. * A directional light is defined by a direction (what a surprise!).
  57358. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57359. * 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.
  57360. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57361. */
  57362. export class DirectionalLight extends ShadowLight {
  57363. private _shadowFrustumSize;
  57364. /**
  57365. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57366. */
  57367. get shadowFrustumSize(): number;
  57368. /**
  57369. * Specifies a fix frustum size for the shadow generation.
  57370. */
  57371. set shadowFrustumSize(value: number);
  57372. private _shadowOrthoScale;
  57373. /**
  57374. * Gets the shadow projection scale against the optimal computed one.
  57375. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57376. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57377. */
  57378. get shadowOrthoScale(): number;
  57379. /**
  57380. * Sets the shadow projection scale against the optimal computed one.
  57381. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57382. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57383. */
  57384. set shadowOrthoScale(value: number);
  57385. /**
  57386. * Automatically compute the projection matrix to best fit (including all the casters)
  57387. * on each frame.
  57388. */
  57389. autoUpdateExtends: boolean;
  57390. /**
  57391. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57392. * on each frame. autoUpdateExtends must be set to true for this to work
  57393. */
  57394. autoCalcShadowZBounds: boolean;
  57395. private _orthoLeft;
  57396. private _orthoRight;
  57397. private _orthoTop;
  57398. private _orthoBottom;
  57399. /**
  57400. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57401. * The directional light is emitted from everywhere in the given direction.
  57402. * It can cast shadows.
  57403. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57404. * @param name The friendly name of the light
  57405. * @param direction The direction of the light
  57406. * @param scene The scene the light belongs to
  57407. */
  57408. constructor(name: string, direction: Vector3, scene: Scene);
  57409. /**
  57410. * Returns the string "DirectionalLight".
  57411. * @return The class name
  57412. */
  57413. getClassName(): string;
  57414. /**
  57415. * Returns the integer 1.
  57416. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57417. */
  57418. getTypeID(): number;
  57419. /**
  57420. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57421. * Returns the DirectionalLight Shadow projection matrix.
  57422. */
  57423. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57424. /**
  57425. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57426. * Returns the DirectionalLight Shadow projection matrix.
  57427. */
  57428. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57429. /**
  57430. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57431. * Returns the DirectionalLight Shadow projection matrix.
  57432. */
  57433. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57434. protected _buildUniformLayout(): void;
  57435. /**
  57436. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57437. * @param effect The effect to update
  57438. * @param lightIndex The index of the light in the effect to update
  57439. * @returns The directional light
  57440. */
  57441. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57442. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57443. /**
  57444. * Gets the minZ used for shadow according to both the scene and the light.
  57445. *
  57446. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57447. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57448. * @param activeCamera The camera we are returning the min for
  57449. * @returns the depth min z
  57450. */
  57451. getDepthMinZ(activeCamera: Camera): number;
  57452. /**
  57453. * Gets the maxZ used for shadow according to both the scene and the light.
  57454. *
  57455. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57456. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57457. * @param activeCamera The camera we are returning the max for
  57458. * @returns the depth max z
  57459. */
  57460. getDepthMaxZ(activeCamera: Camera): number;
  57461. /**
  57462. * Prepares the list of defines specific to the light type.
  57463. * @param defines the list of defines
  57464. * @param lightIndex defines the index of the light for the effect
  57465. */
  57466. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57467. }
  57468. }
  57469. declare module BABYLON {
  57470. /**
  57471. * Class containing static functions to help procedurally build meshes
  57472. */
  57473. export class HemisphereBuilder {
  57474. /**
  57475. * Creates a hemisphere mesh
  57476. * @param name defines the name of the mesh
  57477. * @param options defines the options used to create the mesh
  57478. * @param scene defines the hosting scene
  57479. * @returns the hemisphere mesh
  57480. */
  57481. static CreateHemisphere(name: string, options: {
  57482. segments?: number;
  57483. diameter?: number;
  57484. sideOrientation?: number;
  57485. }, scene: any): Mesh;
  57486. }
  57487. }
  57488. declare module BABYLON {
  57489. /**
  57490. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57491. * These values define a cone of light starting from the position, emitting toward the direction.
  57492. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57493. * and the exponent defines the speed of the decay of the light with distance (reach).
  57494. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57495. */
  57496. export class SpotLight extends ShadowLight {
  57497. private _angle;
  57498. private _innerAngle;
  57499. private _cosHalfAngle;
  57500. private _lightAngleScale;
  57501. private _lightAngleOffset;
  57502. /**
  57503. * Gets the cone angle of the spot light in Radians.
  57504. */
  57505. get angle(): number;
  57506. /**
  57507. * Sets the cone angle of the spot light in Radians.
  57508. */
  57509. set angle(value: number);
  57510. /**
  57511. * Only used in gltf falloff mode, this defines the angle where
  57512. * the directional falloff will start before cutting at angle which could be seen
  57513. * as outer angle.
  57514. */
  57515. get innerAngle(): number;
  57516. /**
  57517. * Only used in gltf falloff mode, this defines the angle where
  57518. * the directional falloff will start before cutting at angle which could be seen
  57519. * as outer angle.
  57520. */
  57521. set innerAngle(value: number);
  57522. private _shadowAngleScale;
  57523. /**
  57524. * Allows scaling the angle of the light for shadow generation only.
  57525. */
  57526. get shadowAngleScale(): number;
  57527. /**
  57528. * Allows scaling the angle of the light for shadow generation only.
  57529. */
  57530. set shadowAngleScale(value: number);
  57531. /**
  57532. * The light decay speed with the distance from the emission spot.
  57533. */
  57534. exponent: number;
  57535. private _projectionTextureMatrix;
  57536. /**
  57537. * Allows reading the projecton texture
  57538. */
  57539. get projectionTextureMatrix(): Matrix;
  57540. protected _projectionTextureLightNear: number;
  57541. /**
  57542. * Gets the near clip of the Spotlight for texture projection.
  57543. */
  57544. get projectionTextureLightNear(): number;
  57545. /**
  57546. * Sets the near clip of the Spotlight for texture projection.
  57547. */
  57548. set projectionTextureLightNear(value: number);
  57549. protected _projectionTextureLightFar: number;
  57550. /**
  57551. * Gets the far clip of the Spotlight for texture projection.
  57552. */
  57553. get projectionTextureLightFar(): number;
  57554. /**
  57555. * Sets the far clip of the Spotlight for texture projection.
  57556. */
  57557. set projectionTextureLightFar(value: number);
  57558. protected _projectionTextureUpDirection: Vector3;
  57559. /**
  57560. * Gets the Up vector of the Spotlight for texture projection.
  57561. */
  57562. get projectionTextureUpDirection(): Vector3;
  57563. /**
  57564. * Sets the Up vector of the Spotlight for texture projection.
  57565. */
  57566. set projectionTextureUpDirection(value: Vector3);
  57567. private _projectionTexture;
  57568. /**
  57569. * Gets the projection texture of the light.
  57570. */
  57571. get projectionTexture(): Nullable<BaseTexture>;
  57572. /**
  57573. * Sets the projection texture of the light.
  57574. */
  57575. set projectionTexture(value: Nullable<BaseTexture>);
  57576. private static _IsProceduralTexture;
  57577. private static _IsTexture;
  57578. private _projectionTextureViewLightDirty;
  57579. private _projectionTextureProjectionLightDirty;
  57580. private _projectionTextureDirty;
  57581. private _projectionTextureViewTargetVector;
  57582. private _projectionTextureViewLightMatrix;
  57583. private _projectionTextureProjectionLightMatrix;
  57584. private _projectionTextureScalingMatrix;
  57585. /**
  57586. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57587. * It can cast shadows.
  57588. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57589. * @param name The light friendly name
  57590. * @param position The position of the spot light in the scene
  57591. * @param direction The direction of the light in the scene
  57592. * @param angle The cone angle of the light in Radians
  57593. * @param exponent The light decay speed with the distance from the emission spot
  57594. * @param scene The scene the lights belongs to
  57595. */
  57596. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  57597. /**
  57598. * Returns the string "SpotLight".
  57599. * @returns the class name
  57600. */
  57601. getClassName(): string;
  57602. /**
  57603. * Returns the integer 2.
  57604. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57605. */
  57606. getTypeID(): number;
  57607. /**
  57608. * Overrides the direction setter to recompute the projection texture view light Matrix.
  57609. */
  57610. protected _setDirection(value: Vector3): void;
  57611. /**
  57612. * Overrides the position setter to recompute the projection texture view light Matrix.
  57613. */
  57614. protected _setPosition(value: Vector3): void;
  57615. /**
  57616. * 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.
  57617. * Returns the SpotLight.
  57618. */
  57619. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57620. protected _computeProjectionTextureViewLightMatrix(): void;
  57621. protected _computeProjectionTextureProjectionLightMatrix(): void;
  57622. /**
  57623. * Main function for light texture projection matrix computing.
  57624. */
  57625. protected _computeProjectionTextureMatrix(): void;
  57626. protected _buildUniformLayout(): void;
  57627. private _computeAngleValues;
  57628. /**
  57629. * Sets the passed Effect "effect" with the Light textures.
  57630. * @param effect The effect to update
  57631. * @param lightIndex The index of the light in the effect to update
  57632. * @returns The light
  57633. */
  57634. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  57635. /**
  57636. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  57637. * @param effect The effect to update
  57638. * @param lightIndex The index of the light in the effect to update
  57639. * @returns The spot light
  57640. */
  57641. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  57642. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57643. /**
  57644. * Disposes the light and the associated resources.
  57645. */
  57646. dispose(): void;
  57647. /**
  57648. * Prepares the list of defines specific to the light type.
  57649. * @param defines the list of defines
  57650. * @param lightIndex defines the index of the light for the effect
  57651. */
  57652. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57653. }
  57654. }
  57655. declare module BABYLON {
  57656. /**
  57657. * Gizmo that enables viewing a light
  57658. */
  57659. export class LightGizmo extends Gizmo {
  57660. private _lightMesh;
  57661. private _material;
  57662. private _cachedPosition;
  57663. private _cachedForward;
  57664. private _attachedMeshParent;
  57665. private _pointerObserver;
  57666. /**
  57667. * Event that fires each time the gizmo is clicked
  57668. */
  57669. onClickedObservable: Observable<Light>;
  57670. /**
  57671. * Creates a LightGizmo
  57672. * @param gizmoLayer The utility layer the gizmo will be added to
  57673. */
  57674. constructor(gizmoLayer?: UtilityLayerRenderer);
  57675. private _light;
  57676. /**
  57677. * The light that the gizmo is attached to
  57678. */
  57679. set light(light: Nullable<Light>);
  57680. get light(): Nullable<Light>;
  57681. /**
  57682. * Gets the material used to render the light gizmo
  57683. */
  57684. get material(): StandardMaterial;
  57685. /**
  57686. * @hidden
  57687. * Updates the gizmo to match the attached mesh's position/rotation
  57688. */
  57689. protected _update(): void;
  57690. private static _Scale;
  57691. /**
  57692. * Creates the lines for a light mesh
  57693. */
  57694. private static _CreateLightLines;
  57695. /**
  57696. * Disposes of the light gizmo
  57697. */
  57698. dispose(): void;
  57699. private static _CreateHemisphericLightMesh;
  57700. private static _CreatePointLightMesh;
  57701. private static _CreateSpotLightMesh;
  57702. private static _CreateDirectionalLightMesh;
  57703. }
  57704. }
  57705. declare module BABYLON {
  57706. /**
  57707. * Gizmo that enables viewing a camera
  57708. */
  57709. export class CameraGizmo extends Gizmo {
  57710. private _cameraMesh;
  57711. private _cameraLinesMesh;
  57712. private _material;
  57713. private _pointerObserver;
  57714. /**
  57715. * Event that fires each time the gizmo is clicked
  57716. */
  57717. onClickedObservable: Observable<Camera>;
  57718. /**
  57719. * Creates a CameraGizmo
  57720. * @param gizmoLayer The utility layer the gizmo will be added to
  57721. */
  57722. constructor(gizmoLayer?: UtilityLayerRenderer);
  57723. private _camera;
  57724. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  57725. get displayFrustum(): boolean;
  57726. set displayFrustum(value: boolean);
  57727. /**
  57728. * The camera that the gizmo is attached to
  57729. */
  57730. set camera(camera: Nullable<Camera>);
  57731. get camera(): Nullable<Camera>;
  57732. /**
  57733. * Gets the material used to render the camera gizmo
  57734. */
  57735. get material(): StandardMaterial;
  57736. /**
  57737. * @hidden
  57738. * Updates the gizmo to match the attached mesh's position/rotation
  57739. */
  57740. protected _update(): void;
  57741. private static _Scale;
  57742. private _invProjection;
  57743. /**
  57744. * Disposes of the camera gizmo
  57745. */
  57746. dispose(): void;
  57747. private static _CreateCameraMesh;
  57748. private static _CreateCameraFrustum;
  57749. }
  57750. }
  57751. declare module BABYLON {
  57752. /** @hidden */
  57753. export var backgroundFragmentDeclaration: {
  57754. name: string;
  57755. shader: string;
  57756. };
  57757. }
  57758. declare module BABYLON {
  57759. /** @hidden */
  57760. export var backgroundUboDeclaration: {
  57761. name: string;
  57762. shader: string;
  57763. };
  57764. }
  57765. declare module BABYLON {
  57766. /** @hidden */
  57767. export var backgroundPixelShader: {
  57768. name: string;
  57769. shader: string;
  57770. };
  57771. }
  57772. declare module BABYLON {
  57773. /** @hidden */
  57774. export var backgroundVertexDeclaration: {
  57775. name: string;
  57776. shader: string;
  57777. };
  57778. }
  57779. declare module BABYLON {
  57780. /** @hidden */
  57781. export var backgroundVertexShader: {
  57782. name: string;
  57783. shader: string;
  57784. };
  57785. }
  57786. declare module BABYLON {
  57787. /**
  57788. * Background material used to create an efficient environement around your scene.
  57789. */
  57790. export class BackgroundMaterial extends PushMaterial {
  57791. /**
  57792. * Standard reflectance value at parallel view angle.
  57793. */
  57794. static StandardReflectance0: number;
  57795. /**
  57796. * Standard reflectance value at grazing angle.
  57797. */
  57798. static StandardReflectance90: number;
  57799. protected _primaryColor: Color3;
  57800. /**
  57801. * Key light Color (multiply against the environement texture)
  57802. */
  57803. primaryColor: Color3;
  57804. protected __perceptualColor: Nullable<Color3>;
  57805. /**
  57806. * Experimental Internal Use Only.
  57807. *
  57808. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  57809. * This acts as a helper to set the primary color to a more "human friendly" value.
  57810. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  57811. * output color as close as possible from the chosen value.
  57812. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  57813. * part of lighting setup.)
  57814. */
  57815. get _perceptualColor(): Nullable<Color3>;
  57816. set _perceptualColor(value: Nullable<Color3>);
  57817. protected _primaryColorShadowLevel: float;
  57818. /**
  57819. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  57820. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  57821. */
  57822. get primaryColorShadowLevel(): float;
  57823. set primaryColorShadowLevel(value: float);
  57824. protected _primaryColorHighlightLevel: float;
  57825. /**
  57826. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  57827. * The primary color is used at the level chosen to define what the white area would look.
  57828. */
  57829. get primaryColorHighlightLevel(): float;
  57830. set primaryColorHighlightLevel(value: float);
  57831. protected _reflectionTexture: Nullable<BaseTexture>;
  57832. /**
  57833. * Reflection Texture used in the material.
  57834. * Should be author in a specific way for the best result (refer to the documentation).
  57835. */
  57836. reflectionTexture: Nullable<BaseTexture>;
  57837. protected _reflectionBlur: float;
  57838. /**
  57839. * Reflection Texture level of blur.
  57840. *
  57841. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57842. * texture twice.
  57843. */
  57844. reflectionBlur: float;
  57845. protected _diffuseTexture: Nullable<BaseTexture>;
  57846. /**
  57847. * Diffuse Texture used in the material.
  57848. * Should be author in a specific way for the best result (refer to the documentation).
  57849. */
  57850. diffuseTexture: Nullable<BaseTexture>;
  57851. protected _shadowLights: Nullable<IShadowLight[]>;
  57852. /**
  57853. * Specify the list of lights casting shadow on the material.
  57854. * All scene shadow lights will be included if null.
  57855. */
  57856. shadowLights: Nullable<IShadowLight[]>;
  57857. protected _shadowLevel: float;
  57858. /**
  57859. * Helps adjusting the shadow to a softer level if required.
  57860. * 0 means black shadows and 1 means no shadows.
  57861. */
  57862. shadowLevel: float;
  57863. protected _sceneCenter: Vector3;
  57864. /**
  57865. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57866. * It is usually zero but might be interesting to modify according to your setup.
  57867. */
  57868. sceneCenter: Vector3;
  57869. protected _opacityFresnel: boolean;
  57870. /**
  57871. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57872. * This helps ensuring a nice transition when the camera goes under the ground.
  57873. */
  57874. opacityFresnel: boolean;
  57875. protected _reflectionFresnel: boolean;
  57876. /**
  57877. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57878. * This helps adding a mirror texture on the ground.
  57879. */
  57880. reflectionFresnel: boolean;
  57881. protected _reflectionFalloffDistance: number;
  57882. /**
  57883. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57884. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57885. */
  57886. reflectionFalloffDistance: number;
  57887. protected _reflectionAmount: number;
  57888. /**
  57889. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57890. */
  57891. reflectionAmount: number;
  57892. protected _reflectionReflectance0: number;
  57893. /**
  57894. * This specifies the weight of the reflection at grazing angle.
  57895. */
  57896. reflectionReflectance0: number;
  57897. protected _reflectionReflectance90: number;
  57898. /**
  57899. * This specifies the weight of the reflection at a perpendicular point of view.
  57900. */
  57901. reflectionReflectance90: number;
  57902. /**
  57903. * Sets the reflection reflectance fresnel values according to the default standard
  57904. * empirically know to work well :-)
  57905. */
  57906. set reflectionStandardFresnelWeight(value: number);
  57907. protected _useRGBColor: boolean;
  57908. /**
  57909. * Helps to directly use the maps channels instead of their level.
  57910. */
  57911. useRGBColor: boolean;
  57912. protected _enableNoise: boolean;
  57913. /**
  57914. * This helps reducing the banding effect that could occur on the background.
  57915. */
  57916. enableNoise: boolean;
  57917. /**
  57918. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57919. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57920. * Recommended to be keep at 1.0 except for special cases.
  57921. */
  57922. get fovMultiplier(): number;
  57923. set fovMultiplier(value: number);
  57924. private _fovMultiplier;
  57925. /**
  57926. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57927. */
  57928. useEquirectangularFOV: boolean;
  57929. private _maxSimultaneousLights;
  57930. /**
  57931. * Number of Simultaneous lights allowed on the material.
  57932. */
  57933. maxSimultaneousLights: int;
  57934. private _shadowOnly;
  57935. /**
  57936. * Make the material only render shadows
  57937. */
  57938. shadowOnly: boolean;
  57939. /**
  57940. * Default configuration related to image processing available in the Background Material.
  57941. */
  57942. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57943. /**
  57944. * Keep track of the image processing observer to allow dispose and replace.
  57945. */
  57946. private _imageProcessingObserver;
  57947. /**
  57948. * Attaches a new image processing configuration to the PBR Material.
  57949. * @param configuration (if null the scene configuration will be use)
  57950. */
  57951. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57952. /**
  57953. * Gets the image processing configuration used either in this material.
  57954. */
  57955. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57956. /**
  57957. * Sets the Default image processing configuration used either in the this material.
  57958. *
  57959. * If sets to null, the scene one is in use.
  57960. */
  57961. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57962. /**
  57963. * Gets wether the color curves effect is enabled.
  57964. */
  57965. get cameraColorCurvesEnabled(): boolean;
  57966. /**
  57967. * Sets wether the color curves effect is enabled.
  57968. */
  57969. set cameraColorCurvesEnabled(value: boolean);
  57970. /**
  57971. * Gets wether the color grading effect is enabled.
  57972. */
  57973. get cameraColorGradingEnabled(): boolean;
  57974. /**
  57975. * Gets wether the color grading effect is enabled.
  57976. */
  57977. set cameraColorGradingEnabled(value: boolean);
  57978. /**
  57979. * Gets wether tonemapping is enabled or not.
  57980. */
  57981. get cameraToneMappingEnabled(): boolean;
  57982. /**
  57983. * Sets wether tonemapping is enabled or not
  57984. */
  57985. set cameraToneMappingEnabled(value: boolean);
  57986. /**
  57987. * The camera exposure used on this material.
  57988. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57989. * This corresponds to a photographic exposure.
  57990. */
  57991. get cameraExposure(): float;
  57992. /**
  57993. * The camera exposure used on this material.
  57994. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57995. * This corresponds to a photographic exposure.
  57996. */
  57997. set cameraExposure(value: float);
  57998. /**
  57999. * Gets The camera contrast used on this material.
  58000. */
  58001. get cameraContrast(): float;
  58002. /**
  58003. * Sets The camera contrast used on this material.
  58004. */
  58005. set cameraContrast(value: float);
  58006. /**
  58007. * Gets the Color Grading 2D Lookup Texture.
  58008. */
  58009. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58010. /**
  58011. * Sets the Color Grading 2D Lookup Texture.
  58012. */
  58013. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58014. /**
  58015. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58016. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58017. * 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;
  58018. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58019. */
  58020. get cameraColorCurves(): Nullable<ColorCurves>;
  58021. /**
  58022. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58023. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58024. * 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;
  58025. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58026. */
  58027. set cameraColorCurves(value: Nullable<ColorCurves>);
  58028. /**
  58029. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  58030. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  58031. */
  58032. switchToBGR: boolean;
  58033. private _renderTargets;
  58034. private _reflectionControls;
  58035. private _white;
  58036. private _primaryShadowColor;
  58037. private _primaryHighlightColor;
  58038. /**
  58039. * Instantiates a Background Material in the given scene
  58040. * @param name The friendly name of the material
  58041. * @param scene The scene to add the material to
  58042. */
  58043. constructor(name: string, scene: Scene);
  58044. /**
  58045. * Gets a boolean indicating that current material needs to register RTT
  58046. */
  58047. get hasRenderTargetTextures(): boolean;
  58048. /**
  58049. * The entire material has been created in order to prevent overdraw.
  58050. * @returns false
  58051. */
  58052. needAlphaTesting(): boolean;
  58053. /**
  58054. * The entire material has been created in order to prevent overdraw.
  58055. * @returns true if blending is enable
  58056. */
  58057. needAlphaBlending(): boolean;
  58058. /**
  58059. * Checks wether the material is ready to be rendered for a given mesh.
  58060. * @param mesh The mesh to render
  58061. * @param subMesh The submesh to check against
  58062. * @param useInstances Specify wether or not the material is used with instances
  58063. * @returns true if all the dependencies are ready (Textures, Effects...)
  58064. */
  58065. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58066. /**
  58067. * Compute the primary color according to the chosen perceptual color.
  58068. */
  58069. private _computePrimaryColorFromPerceptualColor;
  58070. /**
  58071. * Compute the highlights and shadow colors according to their chosen levels.
  58072. */
  58073. private _computePrimaryColors;
  58074. /**
  58075. * Build the uniform buffer used in the material.
  58076. */
  58077. buildUniformLayout(): void;
  58078. /**
  58079. * Unbind the material.
  58080. */
  58081. unbind(): void;
  58082. /**
  58083. * Bind only the world matrix to the material.
  58084. * @param world The world matrix to bind.
  58085. */
  58086. bindOnlyWorldMatrix(world: Matrix): void;
  58087. /**
  58088. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58089. * @param world The world matrix to bind.
  58090. * @param subMesh The submesh to bind for.
  58091. */
  58092. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58093. /**
  58094. * Checks to see if a texture is used in the material.
  58095. * @param texture - Base texture to use.
  58096. * @returns - Boolean specifying if a texture is used in the material.
  58097. */
  58098. hasTexture(texture: BaseTexture): boolean;
  58099. /**
  58100. * Dispose the material.
  58101. * @param forceDisposeEffect Force disposal of the associated effect.
  58102. * @param forceDisposeTextures Force disposal of the associated textures.
  58103. */
  58104. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58105. /**
  58106. * Clones the material.
  58107. * @param name The cloned name.
  58108. * @returns The cloned material.
  58109. */
  58110. clone(name: string): BackgroundMaterial;
  58111. /**
  58112. * Serializes the current material to its JSON representation.
  58113. * @returns The JSON representation.
  58114. */
  58115. serialize(): any;
  58116. /**
  58117. * Gets the class name of the material
  58118. * @returns "BackgroundMaterial"
  58119. */
  58120. getClassName(): string;
  58121. /**
  58122. * Parse a JSON input to create back a background material.
  58123. * @param source The JSON data to parse
  58124. * @param scene The scene to create the parsed material in
  58125. * @param rootUrl The root url of the assets the material depends upon
  58126. * @returns the instantiated BackgroundMaterial.
  58127. */
  58128. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58129. }
  58130. }
  58131. declare module BABYLON {
  58132. /**
  58133. * Represents the different options available during the creation of
  58134. * a Environment helper.
  58135. *
  58136. * This can control the default ground, skybox and image processing setup of your scene.
  58137. */
  58138. export interface IEnvironmentHelperOptions {
  58139. /**
  58140. * Specifies whether or not to create a ground.
  58141. * True by default.
  58142. */
  58143. createGround: boolean;
  58144. /**
  58145. * Specifies the ground size.
  58146. * 15 by default.
  58147. */
  58148. groundSize: number;
  58149. /**
  58150. * The texture used on the ground for the main color.
  58151. * Comes from the BabylonJS CDN by default.
  58152. *
  58153. * Remarks: Can be either a texture or a url.
  58154. */
  58155. groundTexture: string | BaseTexture;
  58156. /**
  58157. * The color mixed in the ground texture by default.
  58158. * BabylonJS clearColor by default.
  58159. */
  58160. groundColor: Color3;
  58161. /**
  58162. * Specifies the ground opacity.
  58163. * 1 by default.
  58164. */
  58165. groundOpacity: number;
  58166. /**
  58167. * Enables the ground to receive shadows.
  58168. * True by default.
  58169. */
  58170. enableGroundShadow: boolean;
  58171. /**
  58172. * Helps preventing the shadow to be fully black on the ground.
  58173. * 0.5 by default.
  58174. */
  58175. groundShadowLevel: number;
  58176. /**
  58177. * Creates a mirror texture attach to the ground.
  58178. * false by default.
  58179. */
  58180. enableGroundMirror: boolean;
  58181. /**
  58182. * Specifies the ground mirror size ratio.
  58183. * 0.3 by default as the default kernel is 64.
  58184. */
  58185. groundMirrorSizeRatio: number;
  58186. /**
  58187. * Specifies the ground mirror blur kernel size.
  58188. * 64 by default.
  58189. */
  58190. groundMirrorBlurKernel: number;
  58191. /**
  58192. * Specifies the ground mirror visibility amount.
  58193. * 1 by default
  58194. */
  58195. groundMirrorAmount: number;
  58196. /**
  58197. * Specifies the ground mirror reflectance weight.
  58198. * This uses the standard weight of the background material to setup the fresnel effect
  58199. * of the mirror.
  58200. * 1 by default.
  58201. */
  58202. groundMirrorFresnelWeight: number;
  58203. /**
  58204. * Specifies the ground mirror Falloff distance.
  58205. * This can helps reducing the size of the reflection.
  58206. * 0 by Default.
  58207. */
  58208. groundMirrorFallOffDistance: number;
  58209. /**
  58210. * Specifies the ground mirror texture type.
  58211. * Unsigned Int by Default.
  58212. */
  58213. groundMirrorTextureType: number;
  58214. /**
  58215. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58216. * the shown objects.
  58217. */
  58218. groundYBias: number;
  58219. /**
  58220. * Specifies whether or not to create a skybox.
  58221. * True by default.
  58222. */
  58223. createSkybox: boolean;
  58224. /**
  58225. * Specifies the skybox size.
  58226. * 20 by default.
  58227. */
  58228. skyboxSize: number;
  58229. /**
  58230. * The texture used on the skybox for the main color.
  58231. * Comes from the BabylonJS CDN by default.
  58232. *
  58233. * Remarks: Can be either a texture or a url.
  58234. */
  58235. skyboxTexture: string | BaseTexture;
  58236. /**
  58237. * The color mixed in the skybox texture by default.
  58238. * BabylonJS clearColor by default.
  58239. */
  58240. skyboxColor: Color3;
  58241. /**
  58242. * The background rotation around the Y axis of the scene.
  58243. * This helps aligning the key lights of your scene with the background.
  58244. * 0 by default.
  58245. */
  58246. backgroundYRotation: number;
  58247. /**
  58248. * Compute automatically the size of the elements to best fit with the scene.
  58249. */
  58250. sizeAuto: boolean;
  58251. /**
  58252. * Default position of the rootMesh if autoSize is not true.
  58253. */
  58254. rootPosition: Vector3;
  58255. /**
  58256. * Sets up the image processing in the scene.
  58257. * true by default.
  58258. */
  58259. setupImageProcessing: boolean;
  58260. /**
  58261. * The texture used as your environment texture in the scene.
  58262. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58263. *
  58264. * Remarks: Can be either a texture or a url.
  58265. */
  58266. environmentTexture: string | BaseTexture;
  58267. /**
  58268. * The value of the exposure to apply to the scene.
  58269. * 0.6 by default if setupImageProcessing is true.
  58270. */
  58271. cameraExposure: number;
  58272. /**
  58273. * The value of the contrast to apply to the scene.
  58274. * 1.6 by default if setupImageProcessing is true.
  58275. */
  58276. cameraContrast: number;
  58277. /**
  58278. * Specifies whether or not tonemapping should be enabled in the scene.
  58279. * true by default if setupImageProcessing is true.
  58280. */
  58281. toneMappingEnabled: boolean;
  58282. }
  58283. /**
  58284. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58285. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58286. * It also helps with the default setup of your imageProcessing configuration.
  58287. */
  58288. export class EnvironmentHelper {
  58289. /**
  58290. * Default ground texture URL.
  58291. */
  58292. private static _groundTextureCDNUrl;
  58293. /**
  58294. * Default skybox texture URL.
  58295. */
  58296. private static _skyboxTextureCDNUrl;
  58297. /**
  58298. * Default environment texture URL.
  58299. */
  58300. private static _environmentTextureCDNUrl;
  58301. /**
  58302. * Creates the default options for the helper.
  58303. */
  58304. private static _getDefaultOptions;
  58305. private _rootMesh;
  58306. /**
  58307. * Gets the root mesh created by the helper.
  58308. */
  58309. get rootMesh(): Mesh;
  58310. private _skybox;
  58311. /**
  58312. * Gets the skybox created by the helper.
  58313. */
  58314. get skybox(): Nullable<Mesh>;
  58315. private _skyboxTexture;
  58316. /**
  58317. * Gets the skybox texture created by the helper.
  58318. */
  58319. get skyboxTexture(): Nullable<BaseTexture>;
  58320. private _skyboxMaterial;
  58321. /**
  58322. * Gets the skybox material created by the helper.
  58323. */
  58324. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58325. private _ground;
  58326. /**
  58327. * Gets the ground mesh created by the helper.
  58328. */
  58329. get ground(): Nullable<Mesh>;
  58330. private _groundTexture;
  58331. /**
  58332. * Gets the ground texture created by the helper.
  58333. */
  58334. get groundTexture(): Nullable<BaseTexture>;
  58335. private _groundMirror;
  58336. /**
  58337. * Gets the ground mirror created by the helper.
  58338. */
  58339. get groundMirror(): Nullable<MirrorTexture>;
  58340. /**
  58341. * Gets the ground mirror render list to helps pushing the meshes
  58342. * you wish in the ground reflection.
  58343. */
  58344. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58345. private _groundMaterial;
  58346. /**
  58347. * Gets the ground material created by the helper.
  58348. */
  58349. get groundMaterial(): Nullable<BackgroundMaterial>;
  58350. /**
  58351. * Stores the creation options.
  58352. */
  58353. private readonly _scene;
  58354. private _options;
  58355. /**
  58356. * This observable will be notified with any error during the creation of the environment,
  58357. * mainly texture creation errors.
  58358. */
  58359. onErrorObservable: Observable<{
  58360. message?: string;
  58361. exception?: any;
  58362. }>;
  58363. /**
  58364. * constructor
  58365. * @param options Defines the options we want to customize the helper
  58366. * @param scene The scene to add the material to
  58367. */
  58368. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58369. /**
  58370. * Updates the background according to the new options
  58371. * @param options
  58372. */
  58373. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58374. /**
  58375. * Sets the primary color of all the available elements.
  58376. * @param color the main color to affect to the ground and the background
  58377. */
  58378. setMainColor(color: Color3): void;
  58379. /**
  58380. * Setup the image processing according to the specified options.
  58381. */
  58382. private _setupImageProcessing;
  58383. /**
  58384. * Setup the environment texture according to the specified options.
  58385. */
  58386. private _setupEnvironmentTexture;
  58387. /**
  58388. * Setup the background according to the specified options.
  58389. */
  58390. private _setupBackground;
  58391. /**
  58392. * Get the scene sizes according to the setup.
  58393. */
  58394. private _getSceneSize;
  58395. /**
  58396. * Setup the ground according to the specified options.
  58397. */
  58398. private _setupGround;
  58399. /**
  58400. * Setup the ground material according to the specified options.
  58401. */
  58402. private _setupGroundMaterial;
  58403. /**
  58404. * Setup the ground diffuse texture according to the specified options.
  58405. */
  58406. private _setupGroundDiffuseTexture;
  58407. /**
  58408. * Setup the ground mirror texture according to the specified options.
  58409. */
  58410. private _setupGroundMirrorTexture;
  58411. /**
  58412. * Setup the ground to receive the mirror texture.
  58413. */
  58414. private _setupMirrorInGroundMaterial;
  58415. /**
  58416. * Setup the skybox according to the specified options.
  58417. */
  58418. private _setupSkybox;
  58419. /**
  58420. * Setup the skybox material according to the specified options.
  58421. */
  58422. private _setupSkyboxMaterial;
  58423. /**
  58424. * Setup the skybox reflection texture according to the specified options.
  58425. */
  58426. private _setupSkyboxReflectionTexture;
  58427. private _errorHandler;
  58428. /**
  58429. * Dispose all the elements created by the Helper.
  58430. */
  58431. dispose(): void;
  58432. }
  58433. }
  58434. declare module BABYLON {
  58435. /**
  58436. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58437. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58438. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58439. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58440. */
  58441. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58442. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58443. /**
  58444. * Define the source as a Monoscopic panoramic 360/180.
  58445. */
  58446. static readonly MODE_MONOSCOPIC: number;
  58447. /**
  58448. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58449. */
  58450. static readonly MODE_TOPBOTTOM: number;
  58451. /**
  58452. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58453. */
  58454. static readonly MODE_SIDEBYSIDE: number;
  58455. private _halfDome;
  58456. private _crossEye;
  58457. protected _useDirectMapping: boolean;
  58458. /**
  58459. * The texture being displayed on the sphere
  58460. */
  58461. protected _texture: T;
  58462. /**
  58463. * Gets the texture being displayed on the sphere
  58464. */
  58465. get texture(): T;
  58466. /**
  58467. * Sets the texture being displayed on the sphere
  58468. */
  58469. set texture(newTexture: T);
  58470. /**
  58471. * The skybox material
  58472. */
  58473. protected _material: BackgroundMaterial;
  58474. /**
  58475. * The surface used for the dome
  58476. */
  58477. protected _mesh: Mesh;
  58478. /**
  58479. * Gets the mesh used for the dome.
  58480. */
  58481. get mesh(): Mesh;
  58482. /**
  58483. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58484. */
  58485. private _halfDomeMask;
  58486. /**
  58487. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58488. * Also see the options.resolution property.
  58489. */
  58490. get fovMultiplier(): number;
  58491. set fovMultiplier(value: number);
  58492. protected _textureMode: number;
  58493. /**
  58494. * Gets or set the current texture mode for the texture. It can be:
  58495. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58496. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58497. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58498. */
  58499. get textureMode(): number;
  58500. /**
  58501. * Sets the current texture mode for the texture. It can be:
  58502. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58503. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58504. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58505. */
  58506. set textureMode(value: number);
  58507. /**
  58508. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58509. */
  58510. get halfDome(): boolean;
  58511. /**
  58512. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58513. */
  58514. set halfDome(enabled: boolean);
  58515. /**
  58516. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58517. */
  58518. set crossEye(enabled: boolean);
  58519. /**
  58520. * Is it a cross-eye texture?
  58521. */
  58522. get crossEye(): boolean;
  58523. /**
  58524. * The background material of this dome.
  58525. */
  58526. get material(): BackgroundMaterial;
  58527. /**
  58528. * Oberserver used in Stereoscopic VR Mode.
  58529. */
  58530. private _onBeforeCameraRenderObserver;
  58531. /**
  58532. * Observable raised when an error occured while loading the 360 image
  58533. */
  58534. onLoadErrorObservable: Observable<string>;
  58535. /**
  58536. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58537. * @param name Element's name, child elements will append suffixes for their own names.
  58538. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58539. * @param options An object containing optional or exposed sub element properties
  58540. */
  58541. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58542. resolution?: number;
  58543. clickToPlay?: boolean;
  58544. autoPlay?: boolean;
  58545. loop?: boolean;
  58546. size?: number;
  58547. poster?: string;
  58548. faceForward?: boolean;
  58549. useDirectMapping?: boolean;
  58550. halfDomeMode?: boolean;
  58551. crossEyeMode?: boolean;
  58552. generateMipMaps?: boolean;
  58553. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58554. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58555. protected _changeTextureMode(value: number): void;
  58556. /**
  58557. * Releases resources associated with this node.
  58558. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58559. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58560. */
  58561. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58562. }
  58563. }
  58564. declare module BABYLON {
  58565. /**
  58566. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58567. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58568. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58569. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58570. */
  58571. export class PhotoDome extends TextureDome<Texture> {
  58572. /**
  58573. * Define the image as a Monoscopic panoramic 360 image.
  58574. */
  58575. static readonly MODE_MONOSCOPIC: number;
  58576. /**
  58577. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58578. */
  58579. static readonly MODE_TOPBOTTOM: number;
  58580. /**
  58581. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58582. */
  58583. static readonly MODE_SIDEBYSIDE: number;
  58584. /**
  58585. * Gets or sets the texture being displayed on the sphere
  58586. */
  58587. get photoTexture(): Texture;
  58588. /**
  58589. * sets the texture being displayed on the sphere
  58590. */
  58591. set photoTexture(value: Texture);
  58592. /**
  58593. * Gets the current video mode for the video. It can be:
  58594. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58595. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58596. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58597. */
  58598. get imageMode(): number;
  58599. /**
  58600. * Sets the current video mode for the video. It can be:
  58601. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58602. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58603. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58604. */
  58605. set imageMode(value: number);
  58606. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  58607. }
  58608. }
  58609. declare module BABYLON {
  58610. /**
  58611. * Direct draw surface info
  58612. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58613. */
  58614. export interface DDSInfo {
  58615. /**
  58616. * Width of the texture
  58617. */
  58618. width: number;
  58619. /**
  58620. * Width of the texture
  58621. */
  58622. height: number;
  58623. /**
  58624. * Number of Mipmaps for the texture
  58625. * @see https://en.wikipedia.org/wiki/Mipmap
  58626. */
  58627. mipmapCount: number;
  58628. /**
  58629. * If the textures format is a known fourCC format
  58630. * @see https://www.fourcc.org/
  58631. */
  58632. isFourCC: boolean;
  58633. /**
  58634. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58635. */
  58636. isRGB: boolean;
  58637. /**
  58638. * If the texture is a lumincance format
  58639. */
  58640. isLuminance: boolean;
  58641. /**
  58642. * If this is a cube texture
  58643. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58644. */
  58645. isCube: boolean;
  58646. /**
  58647. * If the texture is a compressed format eg. FOURCC_DXT1
  58648. */
  58649. isCompressed: boolean;
  58650. /**
  58651. * The dxgiFormat of the texture
  58652. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58653. */
  58654. dxgiFormat: number;
  58655. /**
  58656. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58657. */
  58658. textureType: number;
  58659. /**
  58660. * Sphericle polynomial created for the dds texture
  58661. */
  58662. sphericalPolynomial?: SphericalPolynomial;
  58663. }
  58664. /**
  58665. * Class used to provide DDS decompression tools
  58666. */
  58667. export class DDSTools {
  58668. /**
  58669. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58670. */
  58671. static StoreLODInAlphaChannel: boolean;
  58672. /**
  58673. * Gets DDS information from an array buffer
  58674. * @param data defines the array buffer view to read data from
  58675. * @returns the DDS information
  58676. */
  58677. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58678. private static _FloatView;
  58679. private static _Int32View;
  58680. private static _ToHalfFloat;
  58681. private static _FromHalfFloat;
  58682. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58683. private static _GetHalfFloatRGBAArrayBuffer;
  58684. private static _GetFloatRGBAArrayBuffer;
  58685. private static _GetFloatAsUIntRGBAArrayBuffer;
  58686. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58687. private static _GetRGBAArrayBuffer;
  58688. private static _ExtractLongWordOrder;
  58689. private static _GetRGBArrayBuffer;
  58690. private static _GetLuminanceArrayBuffer;
  58691. /**
  58692. * Uploads DDS Levels to a Babylon Texture
  58693. * @hidden
  58694. */
  58695. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58696. }
  58697. interface ThinEngine {
  58698. /**
  58699. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58700. * @param rootUrl defines the url where the file to load is located
  58701. * @param scene defines the current scene
  58702. * @param lodScale defines scale to apply to the mip map selection
  58703. * @param lodOffset defines offset to apply to the mip map selection
  58704. * @param onLoad defines an optional callback raised when the texture is loaded
  58705. * @param onError defines an optional callback raised if there is an issue to load the texture
  58706. * @param format defines the format of the data
  58707. * @param forcedExtension defines the extension to use to pick the right loader
  58708. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58709. * @returns the cube texture as an InternalTexture
  58710. */
  58711. 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;
  58712. }
  58713. }
  58714. declare module BABYLON {
  58715. /**
  58716. * Implementation of the DDS Texture Loader.
  58717. * @hidden
  58718. */
  58719. export class _DDSTextureLoader implements IInternalTextureLoader {
  58720. /**
  58721. * Defines wether the loader supports cascade loading the different faces.
  58722. */
  58723. readonly supportCascades: boolean;
  58724. /**
  58725. * This returns if the loader support the current file information.
  58726. * @param extension defines the file extension of the file being loaded
  58727. * @returns true if the loader can load the specified file
  58728. */
  58729. canLoad(extension: string): boolean;
  58730. /**
  58731. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58732. * @param data contains the texture data
  58733. * @param texture defines the BabylonJS internal texture
  58734. * @param createPolynomials will be true if polynomials have been requested
  58735. * @param onLoad defines the callback to trigger once the texture is ready
  58736. * @param onError defines the callback to trigger in case of error
  58737. */
  58738. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58739. /**
  58740. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58741. * @param data contains the texture data
  58742. * @param texture defines the BabylonJS internal texture
  58743. * @param callback defines the method to call once ready to upload
  58744. */
  58745. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58746. }
  58747. }
  58748. declare module BABYLON {
  58749. /**
  58750. * Implementation of the ENV Texture Loader.
  58751. * @hidden
  58752. */
  58753. export class _ENVTextureLoader implements IInternalTextureLoader {
  58754. /**
  58755. * Defines wether the loader supports cascade loading the different faces.
  58756. */
  58757. readonly supportCascades: boolean;
  58758. /**
  58759. * This returns if the loader support the current file information.
  58760. * @param extension defines the file extension of the file being loaded
  58761. * @returns true if the loader can load the specified file
  58762. */
  58763. canLoad(extension: string): boolean;
  58764. /**
  58765. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58766. * @param data contains the texture data
  58767. * @param texture defines the BabylonJS internal texture
  58768. * @param createPolynomials will be true if polynomials have been requested
  58769. * @param onLoad defines the callback to trigger once the texture is ready
  58770. * @param onError defines the callback to trigger in case of error
  58771. */
  58772. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58773. /**
  58774. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58775. * @param data contains the texture data
  58776. * @param texture defines the BabylonJS internal texture
  58777. * @param callback defines the method to call once ready to upload
  58778. */
  58779. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58780. }
  58781. }
  58782. declare module BABYLON {
  58783. /**
  58784. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58785. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58786. */
  58787. export class KhronosTextureContainer {
  58788. /** contents of the KTX container file */
  58789. data: ArrayBufferView;
  58790. private static HEADER_LEN;
  58791. private static COMPRESSED_2D;
  58792. private static COMPRESSED_3D;
  58793. private static TEX_2D;
  58794. private static TEX_3D;
  58795. /**
  58796. * Gets the openGL type
  58797. */
  58798. glType: number;
  58799. /**
  58800. * Gets the openGL type size
  58801. */
  58802. glTypeSize: number;
  58803. /**
  58804. * Gets the openGL format
  58805. */
  58806. glFormat: number;
  58807. /**
  58808. * Gets the openGL internal format
  58809. */
  58810. glInternalFormat: number;
  58811. /**
  58812. * Gets the base internal format
  58813. */
  58814. glBaseInternalFormat: number;
  58815. /**
  58816. * Gets image width in pixel
  58817. */
  58818. pixelWidth: number;
  58819. /**
  58820. * Gets image height in pixel
  58821. */
  58822. pixelHeight: number;
  58823. /**
  58824. * Gets image depth in pixels
  58825. */
  58826. pixelDepth: number;
  58827. /**
  58828. * Gets the number of array elements
  58829. */
  58830. numberOfArrayElements: number;
  58831. /**
  58832. * Gets the number of faces
  58833. */
  58834. numberOfFaces: number;
  58835. /**
  58836. * Gets the number of mipmap levels
  58837. */
  58838. numberOfMipmapLevels: number;
  58839. /**
  58840. * Gets the bytes of key value data
  58841. */
  58842. bytesOfKeyValueData: number;
  58843. /**
  58844. * Gets the load type
  58845. */
  58846. loadType: number;
  58847. /**
  58848. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58849. */
  58850. isInvalid: boolean;
  58851. /**
  58852. * Creates a new KhronosTextureContainer
  58853. * @param data contents of the KTX container file
  58854. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58855. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58856. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58857. */
  58858. constructor(
  58859. /** contents of the KTX container file */
  58860. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58861. /**
  58862. * Uploads KTX content to a Babylon Texture.
  58863. * It is assumed that the texture has already been created & is currently bound
  58864. * @hidden
  58865. */
  58866. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58867. private _upload2DCompressedLevels;
  58868. /**
  58869. * Checks if the given data starts with a KTX file identifier.
  58870. * @param data the data to check
  58871. * @returns true if the data is a KTX file or false otherwise
  58872. */
  58873. static IsValid(data: ArrayBufferView): boolean;
  58874. }
  58875. }
  58876. declare module BABYLON {
  58877. /**
  58878. * Helper class to push actions to a pool of workers.
  58879. */
  58880. export class WorkerPool implements IDisposable {
  58881. private _workerInfos;
  58882. private _pendingActions;
  58883. /**
  58884. * Constructor
  58885. * @param workers Array of workers to use for actions
  58886. */
  58887. constructor(workers: Array<Worker>);
  58888. /**
  58889. * Terminates all workers and clears any pending actions.
  58890. */
  58891. dispose(): void;
  58892. /**
  58893. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58894. * pended until a worker has completed its action.
  58895. * @param action The action to perform. Call onComplete when the action is complete.
  58896. */
  58897. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58898. private _execute;
  58899. }
  58900. }
  58901. declare module BABYLON {
  58902. /**
  58903. * Class for loading KTX2 files
  58904. */
  58905. export class KhronosTextureContainer2 {
  58906. private static _WorkerPoolPromise?;
  58907. private static _Initialized;
  58908. private static _Ktx2Decoder;
  58909. /**
  58910. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  58911. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  58912. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  58913. * Urls you can change:
  58914. * URLConfig.jsDecoderModule
  58915. * URLConfig.wasmUASTCToASTC
  58916. * URLConfig.wasmUASTCToBC7
  58917. * URLConfig.wasmUASTCToRGBA_UNORM
  58918. * URLConfig.wasmUASTCToRGBA_SRGB
  58919. * URLConfig.jsMSCTranscoder
  58920. * URLConfig.wasmMSCTranscoder
  58921. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  58922. */
  58923. static URLConfig: {
  58924. jsDecoderModule: string;
  58925. wasmUASTCToASTC: null;
  58926. wasmUASTCToBC7: null;
  58927. wasmUASTCToRGBA_UNORM: null;
  58928. wasmUASTCToRGBA_SRGB: null;
  58929. jsMSCTranscoder: null;
  58930. wasmMSCTranscoder: null;
  58931. };
  58932. /**
  58933. * Default number of workers used to handle data decoding
  58934. */
  58935. static DefaultNumWorkers: number;
  58936. private static GetDefaultNumWorkers;
  58937. private _engine;
  58938. private static _CreateWorkerPool;
  58939. /**
  58940. * Constructor
  58941. * @param engine The engine to use
  58942. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58943. */
  58944. constructor(engine: ThinEngine, numWorkers?: number);
  58945. /** @hidden */
  58946. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  58947. /**
  58948. * Stop all async operations and release resources.
  58949. */
  58950. dispose(): void;
  58951. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  58952. /**
  58953. * Checks if the given data starts with a KTX2 file identifier.
  58954. * @param data the data to check
  58955. * @returns true if the data is a KTX2 file or false otherwise
  58956. */
  58957. static IsValid(data: ArrayBufferView): boolean;
  58958. }
  58959. }
  58960. declare module BABYLON {
  58961. /**
  58962. * Implementation of the KTX Texture Loader.
  58963. * @hidden
  58964. */
  58965. export class _KTXTextureLoader implements IInternalTextureLoader {
  58966. /**
  58967. * Defines wether the loader supports cascade loading the different faces.
  58968. */
  58969. readonly supportCascades: boolean;
  58970. /**
  58971. * This returns if the loader support the current file information.
  58972. * @param extension defines the file extension of the file being loaded
  58973. * @param mimeType defines the optional mime type of the file being loaded
  58974. * @returns true if the loader can load the specified file
  58975. */
  58976. canLoad(extension: string, mimeType?: string): boolean;
  58977. /**
  58978. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58979. * @param data contains the texture data
  58980. * @param texture defines the BabylonJS internal texture
  58981. * @param createPolynomials will be true if polynomials have been requested
  58982. * @param onLoad defines the callback to trigger once the texture is ready
  58983. * @param onError defines the callback to trigger in case of error
  58984. */
  58985. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58986. /**
  58987. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58988. * @param data contains the texture data
  58989. * @param texture defines the BabylonJS internal texture
  58990. * @param callback defines the method to call once ready to upload
  58991. */
  58992. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  58993. }
  58994. }
  58995. declare module BABYLON {
  58996. /** @hidden */
  58997. export var _forceSceneHelpersToBundle: boolean;
  58998. interface Scene {
  58999. /**
  59000. * Creates a default light for the scene.
  59001. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59002. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59003. */
  59004. createDefaultLight(replace?: boolean): void;
  59005. /**
  59006. * Creates a default camera for the scene.
  59007. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59008. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59009. * @param replace has default false, when true replaces the active camera in the scene
  59010. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59011. */
  59012. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59013. /**
  59014. * Creates a default camera and a default light.
  59015. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59016. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59017. * @param replace has the default false, when true replaces the active camera/light in the scene
  59018. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59019. */
  59020. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59021. /**
  59022. * Creates a new sky box
  59023. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59024. * @param environmentTexture defines the texture to use as environment texture
  59025. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59026. * @param scale defines the overall scale of the skybox
  59027. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59028. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59029. * @returns a new mesh holding the sky box
  59030. */
  59031. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59032. /**
  59033. * Creates a new environment
  59034. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59035. * @param options defines the options you can use to configure the environment
  59036. * @returns the new EnvironmentHelper
  59037. */
  59038. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59039. /**
  59040. * Creates a new VREXperienceHelper
  59041. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59042. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59043. * @returns a new VREXperienceHelper
  59044. */
  59045. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59046. /**
  59047. * Creates a new WebXRDefaultExperience
  59048. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59049. * @param options experience options
  59050. * @returns a promise for a new WebXRDefaultExperience
  59051. */
  59052. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59053. }
  59054. }
  59055. declare module BABYLON {
  59056. /**
  59057. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59058. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59059. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59060. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59061. */
  59062. export class VideoDome extends TextureDome<VideoTexture> {
  59063. /**
  59064. * Define the video source as a Monoscopic panoramic 360 video.
  59065. */
  59066. static readonly MODE_MONOSCOPIC: number;
  59067. /**
  59068. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59069. */
  59070. static readonly MODE_TOPBOTTOM: number;
  59071. /**
  59072. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59073. */
  59074. static readonly MODE_SIDEBYSIDE: number;
  59075. /**
  59076. * Get the video texture associated with this video dome
  59077. */
  59078. get videoTexture(): VideoTexture;
  59079. /**
  59080. * Get the video mode of this dome
  59081. */
  59082. get videoMode(): number;
  59083. /**
  59084. * Set the video mode of this dome.
  59085. * @see textureMode
  59086. */
  59087. set videoMode(value: number);
  59088. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59089. }
  59090. }
  59091. declare module BABYLON {
  59092. /**
  59093. * This class can be used to get instrumentation data from a Babylon engine
  59094. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59095. */
  59096. export class EngineInstrumentation implements IDisposable {
  59097. /**
  59098. * Define the instrumented engine.
  59099. */
  59100. engine: Engine;
  59101. private _captureGPUFrameTime;
  59102. private _gpuFrameTimeToken;
  59103. private _gpuFrameTime;
  59104. private _captureShaderCompilationTime;
  59105. private _shaderCompilationTime;
  59106. private _onBeginFrameObserver;
  59107. private _onEndFrameObserver;
  59108. private _onBeforeShaderCompilationObserver;
  59109. private _onAfterShaderCompilationObserver;
  59110. /**
  59111. * Gets the perf counter used for GPU frame time
  59112. */
  59113. get gpuFrameTimeCounter(): PerfCounter;
  59114. /**
  59115. * Gets the GPU frame time capture status
  59116. */
  59117. get captureGPUFrameTime(): boolean;
  59118. /**
  59119. * Enable or disable the GPU frame time capture
  59120. */
  59121. set captureGPUFrameTime(value: boolean);
  59122. /**
  59123. * Gets the perf counter used for shader compilation time
  59124. */
  59125. get shaderCompilationTimeCounter(): PerfCounter;
  59126. /**
  59127. * Gets the shader compilation time capture status
  59128. */
  59129. get captureShaderCompilationTime(): boolean;
  59130. /**
  59131. * Enable or disable the shader compilation time capture
  59132. */
  59133. set captureShaderCompilationTime(value: boolean);
  59134. /**
  59135. * Instantiates a new engine instrumentation.
  59136. * This class can be used to get instrumentation data from a Babylon engine
  59137. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59138. * @param engine Defines the engine to instrument
  59139. */
  59140. constructor(
  59141. /**
  59142. * Define the instrumented engine.
  59143. */
  59144. engine: Engine);
  59145. /**
  59146. * Dispose and release associated resources.
  59147. */
  59148. dispose(): void;
  59149. }
  59150. }
  59151. declare module BABYLON {
  59152. /**
  59153. * This class can be used to get instrumentation data from a Babylon engine
  59154. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59155. */
  59156. export class SceneInstrumentation implements IDisposable {
  59157. /**
  59158. * Defines the scene to instrument
  59159. */
  59160. scene: Scene;
  59161. private _captureActiveMeshesEvaluationTime;
  59162. private _activeMeshesEvaluationTime;
  59163. private _captureRenderTargetsRenderTime;
  59164. private _renderTargetsRenderTime;
  59165. private _captureFrameTime;
  59166. private _frameTime;
  59167. private _captureRenderTime;
  59168. private _renderTime;
  59169. private _captureInterFrameTime;
  59170. private _interFrameTime;
  59171. private _captureParticlesRenderTime;
  59172. private _particlesRenderTime;
  59173. private _captureSpritesRenderTime;
  59174. private _spritesRenderTime;
  59175. private _capturePhysicsTime;
  59176. private _physicsTime;
  59177. private _captureAnimationsTime;
  59178. private _animationsTime;
  59179. private _captureCameraRenderTime;
  59180. private _cameraRenderTime;
  59181. private _onBeforeActiveMeshesEvaluationObserver;
  59182. private _onAfterActiveMeshesEvaluationObserver;
  59183. private _onBeforeRenderTargetsRenderObserver;
  59184. private _onAfterRenderTargetsRenderObserver;
  59185. private _onAfterRenderObserver;
  59186. private _onBeforeDrawPhaseObserver;
  59187. private _onAfterDrawPhaseObserver;
  59188. private _onBeforeAnimationsObserver;
  59189. private _onBeforeParticlesRenderingObserver;
  59190. private _onAfterParticlesRenderingObserver;
  59191. private _onBeforeSpritesRenderingObserver;
  59192. private _onAfterSpritesRenderingObserver;
  59193. private _onBeforePhysicsObserver;
  59194. private _onAfterPhysicsObserver;
  59195. private _onAfterAnimationsObserver;
  59196. private _onBeforeCameraRenderObserver;
  59197. private _onAfterCameraRenderObserver;
  59198. /**
  59199. * Gets the perf counter used for active meshes evaluation time
  59200. */
  59201. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59202. /**
  59203. * Gets the active meshes evaluation time capture status
  59204. */
  59205. get captureActiveMeshesEvaluationTime(): boolean;
  59206. /**
  59207. * Enable or disable the active meshes evaluation time capture
  59208. */
  59209. set captureActiveMeshesEvaluationTime(value: boolean);
  59210. /**
  59211. * Gets the perf counter used for render targets render time
  59212. */
  59213. get renderTargetsRenderTimeCounter(): PerfCounter;
  59214. /**
  59215. * Gets the render targets render time capture status
  59216. */
  59217. get captureRenderTargetsRenderTime(): boolean;
  59218. /**
  59219. * Enable or disable the render targets render time capture
  59220. */
  59221. set captureRenderTargetsRenderTime(value: boolean);
  59222. /**
  59223. * Gets the perf counter used for particles render time
  59224. */
  59225. get particlesRenderTimeCounter(): PerfCounter;
  59226. /**
  59227. * Gets the particles render time capture status
  59228. */
  59229. get captureParticlesRenderTime(): boolean;
  59230. /**
  59231. * Enable or disable the particles render time capture
  59232. */
  59233. set captureParticlesRenderTime(value: boolean);
  59234. /**
  59235. * Gets the perf counter used for sprites render time
  59236. */
  59237. get spritesRenderTimeCounter(): PerfCounter;
  59238. /**
  59239. * Gets the sprites render time capture status
  59240. */
  59241. get captureSpritesRenderTime(): boolean;
  59242. /**
  59243. * Enable or disable the sprites render time capture
  59244. */
  59245. set captureSpritesRenderTime(value: boolean);
  59246. /**
  59247. * Gets the perf counter used for physics time
  59248. */
  59249. get physicsTimeCounter(): PerfCounter;
  59250. /**
  59251. * Gets the physics time capture status
  59252. */
  59253. get capturePhysicsTime(): boolean;
  59254. /**
  59255. * Enable or disable the physics time capture
  59256. */
  59257. set capturePhysicsTime(value: boolean);
  59258. /**
  59259. * Gets the perf counter used for animations time
  59260. */
  59261. get animationsTimeCounter(): PerfCounter;
  59262. /**
  59263. * Gets the animations time capture status
  59264. */
  59265. get captureAnimationsTime(): boolean;
  59266. /**
  59267. * Enable or disable the animations time capture
  59268. */
  59269. set captureAnimationsTime(value: boolean);
  59270. /**
  59271. * Gets the perf counter used for frame time capture
  59272. */
  59273. get frameTimeCounter(): PerfCounter;
  59274. /**
  59275. * Gets the frame time capture status
  59276. */
  59277. get captureFrameTime(): boolean;
  59278. /**
  59279. * Enable or disable the frame time capture
  59280. */
  59281. set captureFrameTime(value: boolean);
  59282. /**
  59283. * Gets the perf counter used for inter-frames time capture
  59284. */
  59285. get interFrameTimeCounter(): PerfCounter;
  59286. /**
  59287. * Gets the inter-frames time capture status
  59288. */
  59289. get captureInterFrameTime(): boolean;
  59290. /**
  59291. * Enable or disable the inter-frames time capture
  59292. */
  59293. set captureInterFrameTime(value: boolean);
  59294. /**
  59295. * Gets the perf counter used for render time capture
  59296. */
  59297. get renderTimeCounter(): PerfCounter;
  59298. /**
  59299. * Gets the render time capture status
  59300. */
  59301. get captureRenderTime(): boolean;
  59302. /**
  59303. * Enable or disable the render time capture
  59304. */
  59305. set captureRenderTime(value: boolean);
  59306. /**
  59307. * Gets the perf counter used for camera render time capture
  59308. */
  59309. get cameraRenderTimeCounter(): PerfCounter;
  59310. /**
  59311. * Gets the camera render time capture status
  59312. */
  59313. get captureCameraRenderTime(): boolean;
  59314. /**
  59315. * Enable or disable the camera render time capture
  59316. */
  59317. set captureCameraRenderTime(value: boolean);
  59318. /**
  59319. * Gets the perf counter used for draw calls
  59320. */
  59321. get drawCallsCounter(): PerfCounter;
  59322. /**
  59323. * Instantiates a new scene instrumentation.
  59324. * This class can be used to get instrumentation data from a Babylon engine
  59325. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59326. * @param scene Defines the scene to instrument
  59327. */
  59328. constructor(
  59329. /**
  59330. * Defines the scene to instrument
  59331. */
  59332. scene: Scene);
  59333. /**
  59334. * Dispose and release associated resources.
  59335. */
  59336. dispose(): void;
  59337. }
  59338. }
  59339. declare module BABYLON {
  59340. /** @hidden */
  59341. export var glowMapGenerationPixelShader: {
  59342. name: string;
  59343. shader: string;
  59344. };
  59345. }
  59346. declare module BABYLON {
  59347. /** @hidden */
  59348. export var glowMapGenerationVertexShader: {
  59349. name: string;
  59350. shader: string;
  59351. };
  59352. }
  59353. declare module BABYLON {
  59354. /**
  59355. * Effect layer options. This helps customizing the behaviour
  59356. * of the effect layer.
  59357. */
  59358. export interface IEffectLayerOptions {
  59359. /**
  59360. * Multiplication factor apply to the canvas size to compute the render target size
  59361. * used to generated the objects (the smaller the faster).
  59362. */
  59363. mainTextureRatio: number;
  59364. /**
  59365. * Enforces a fixed size texture to ensure effect stability across devices.
  59366. */
  59367. mainTextureFixedSize?: number;
  59368. /**
  59369. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59370. */
  59371. alphaBlendingMode: number;
  59372. /**
  59373. * The camera attached to the layer.
  59374. */
  59375. camera: Nullable<Camera>;
  59376. /**
  59377. * The rendering group to draw the layer in.
  59378. */
  59379. renderingGroupId: number;
  59380. }
  59381. /**
  59382. * The effect layer Helps adding post process effect blended with the main pass.
  59383. *
  59384. * This can be for instance use to generate glow or higlight effects on the scene.
  59385. *
  59386. * The effect layer class can not be used directly and is intented to inherited from to be
  59387. * customized per effects.
  59388. */
  59389. export abstract class EffectLayer {
  59390. private _vertexBuffers;
  59391. private _indexBuffer;
  59392. private _cachedDefines;
  59393. private _effectLayerMapGenerationEffect;
  59394. private _effectLayerOptions;
  59395. private _mergeEffect;
  59396. protected _scene: Scene;
  59397. protected _engine: Engine;
  59398. protected _maxSize: number;
  59399. protected _mainTextureDesiredSize: ISize;
  59400. protected _mainTexture: RenderTargetTexture;
  59401. protected _shouldRender: boolean;
  59402. protected _postProcesses: PostProcess[];
  59403. protected _textures: BaseTexture[];
  59404. protected _emissiveTextureAndColor: {
  59405. texture: Nullable<BaseTexture>;
  59406. color: Color4;
  59407. };
  59408. /**
  59409. * The name of the layer
  59410. */
  59411. name: string;
  59412. /**
  59413. * The clear color of the texture used to generate the glow map.
  59414. */
  59415. neutralColor: Color4;
  59416. /**
  59417. * Specifies whether the highlight layer is enabled or not.
  59418. */
  59419. isEnabled: boolean;
  59420. /**
  59421. * Gets the camera attached to the layer.
  59422. */
  59423. get camera(): Nullable<Camera>;
  59424. /**
  59425. * Gets the rendering group id the layer should render in.
  59426. */
  59427. get renderingGroupId(): number;
  59428. set renderingGroupId(renderingGroupId: number);
  59429. /**
  59430. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59431. */
  59432. disableBoundingBoxesFromEffectLayer: boolean;
  59433. /**
  59434. * An event triggered when the effect layer has been disposed.
  59435. */
  59436. onDisposeObservable: Observable<EffectLayer>;
  59437. /**
  59438. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59439. */
  59440. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59441. /**
  59442. * An event triggered when the generated texture is being merged in the scene.
  59443. */
  59444. onBeforeComposeObservable: Observable<EffectLayer>;
  59445. /**
  59446. * An event triggered when the mesh is rendered into the effect render target.
  59447. */
  59448. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59449. /**
  59450. * An event triggered after the mesh has been rendered into the effect render target.
  59451. */
  59452. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59453. /**
  59454. * An event triggered when the generated texture has been merged in the scene.
  59455. */
  59456. onAfterComposeObservable: Observable<EffectLayer>;
  59457. /**
  59458. * An event triggered when the efffect layer changes its size.
  59459. */
  59460. onSizeChangedObservable: Observable<EffectLayer>;
  59461. /** @hidden */
  59462. static _SceneComponentInitialization: (scene: Scene) => void;
  59463. /**
  59464. * Instantiates a new effect Layer and references it in the scene.
  59465. * @param name The name of the layer
  59466. * @param scene The scene to use the layer in
  59467. */
  59468. constructor(
  59469. /** The Friendly of the effect in the scene */
  59470. name: string, scene: Scene);
  59471. /**
  59472. * Get the effect name of the layer.
  59473. * @return The effect name
  59474. */
  59475. abstract getEffectName(): string;
  59476. /**
  59477. * Checks for the readiness of the element composing the layer.
  59478. * @param subMesh the mesh to check for
  59479. * @param useInstances specify whether or not to use instances to render the mesh
  59480. * @return true if ready otherwise, false
  59481. */
  59482. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59483. /**
  59484. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59485. * @returns true if the effect requires stencil during the main canvas render pass.
  59486. */
  59487. abstract needStencil(): boolean;
  59488. /**
  59489. * Create the merge effect. This is the shader use to blit the information back
  59490. * to the main canvas at the end of the scene rendering.
  59491. * @returns The effect containing the shader used to merge the effect on the main canvas
  59492. */
  59493. protected abstract _createMergeEffect(): Effect;
  59494. /**
  59495. * Creates the render target textures and post processes used in the effect layer.
  59496. */
  59497. protected abstract _createTextureAndPostProcesses(): void;
  59498. /**
  59499. * Implementation specific of rendering the generating effect on the main canvas.
  59500. * @param effect The effect used to render through
  59501. */
  59502. protected abstract _internalRender(effect: Effect): void;
  59503. /**
  59504. * Sets the required values for both the emissive texture and and the main color.
  59505. */
  59506. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59507. /**
  59508. * Free any resources and references associated to a mesh.
  59509. * Internal use
  59510. * @param mesh The mesh to free.
  59511. */
  59512. abstract _disposeMesh(mesh: Mesh): void;
  59513. /**
  59514. * Serializes this layer (Glow or Highlight for example)
  59515. * @returns a serialized layer object
  59516. */
  59517. abstract serialize?(): any;
  59518. /**
  59519. * Initializes the effect layer with the required options.
  59520. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59521. */
  59522. protected _init(options: Partial<IEffectLayerOptions>): void;
  59523. /**
  59524. * Generates the index buffer of the full screen quad blending to the main canvas.
  59525. */
  59526. private _generateIndexBuffer;
  59527. /**
  59528. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59529. */
  59530. private _generateVertexBuffer;
  59531. /**
  59532. * Sets the main texture desired size which is the closest power of two
  59533. * of the engine canvas size.
  59534. */
  59535. private _setMainTextureSize;
  59536. /**
  59537. * Creates the main texture for the effect layer.
  59538. */
  59539. protected _createMainTexture(): void;
  59540. /**
  59541. * Adds specific effects defines.
  59542. * @param defines The defines to add specifics to.
  59543. */
  59544. protected _addCustomEffectDefines(defines: string[]): void;
  59545. /**
  59546. * Checks for the readiness of the element composing the layer.
  59547. * @param subMesh the mesh to check for
  59548. * @param useInstances specify whether or not to use instances to render the mesh
  59549. * @param emissiveTexture the associated emissive texture used to generate the glow
  59550. * @return true if ready otherwise, false
  59551. */
  59552. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59553. /**
  59554. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59555. */
  59556. render(): void;
  59557. /**
  59558. * Determine if a given mesh will be used in the current effect.
  59559. * @param mesh mesh to test
  59560. * @returns true if the mesh will be used
  59561. */
  59562. hasMesh(mesh: AbstractMesh): boolean;
  59563. /**
  59564. * Returns true if the layer contains information to display, otherwise false.
  59565. * @returns true if the glow layer should be rendered
  59566. */
  59567. shouldRender(): boolean;
  59568. /**
  59569. * Returns true if the mesh should render, otherwise false.
  59570. * @param mesh The mesh to render
  59571. * @returns true if it should render otherwise false
  59572. */
  59573. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59574. /**
  59575. * Returns true if the mesh can be rendered, otherwise false.
  59576. * @param mesh The mesh to render
  59577. * @param material The material used on the mesh
  59578. * @returns true if it can be rendered otherwise false
  59579. */
  59580. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59581. /**
  59582. * Returns true if the mesh should render, otherwise false.
  59583. * @param mesh The mesh to render
  59584. * @returns true if it should render otherwise false
  59585. */
  59586. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59587. /**
  59588. * Renders the submesh passed in parameter to the generation map.
  59589. */
  59590. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59591. /**
  59592. * Defines whether the current material of the mesh should be use to render the effect.
  59593. * @param mesh defines the current mesh to render
  59594. */
  59595. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59596. /**
  59597. * Rebuild the required buffers.
  59598. * @hidden Internal use only.
  59599. */
  59600. _rebuild(): void;
  59601. /**
  59602. * Dispose only the render target textures and post process.
  59603. */
  59604. private _disposeTextureAndPostProcesses;
  59605. /**
  59606. * Dispose the highlight layer and free resources.
  59607. */
  59608. dispose(): void;
  59609. /**
  59610. * Gets the class name of the effect layer
  59611. * @returns the string with the class name of the effect layer
  59612. */
  59613. getClassName(): string;
  59614. /**
  59615. * Creates an effect layer from parsed effect layer data
  59616. * @param parsedEffectLayer defines effect layer data
  59617. * @param scene defines the current scene
  59618. * @param rootUrl defines the root URL containing the effect layer information
  59619. * @returns a parsed effect Layer
  59620. */
  59621. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59622. }
  59623. }
  59624. declare module BABYLON {
  59625. interface AbstractScene {
  59626. /**
  59627. * The list of effect layers (highlights/glow) added to the scene
  59628. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59629. * @see https://doc.babylonjs.com/how_to/glow_layer
  59630. */
  59631. effectLayers: Array<EffectLayer>;
  59632. /**
  59633. * Removes the given effect layer from this scene.
  59634. * @param toRemove defines the effect layer to remove
  59635. * @returns the index of the removed effect layer
  59636. */
  59637. removeEffectLayer(toRemove: EffectLayer): number;
  59638. /**
  59639. * Adds the given effect layer to this scene
  59640. * @param newEffectLayer defines the effect layer to add
  59641. */
  59642. addEffectLayer(newEffectLayer: EffectLayer): void;
  59643. }
  59644. /**
  59645. * Defines the layer scene component responsible to manage any effect layers
  59646. * in a given scene.
  59647. */
  59648. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59649. /**
  59650. * The component name helpfull to identify the component in the list of scene components.
  59651. */
  59652. readonly name: string;
  59653. /**
  59654. * The scene the component belongs to.
  59655. */
  59656. scene: Scene;
  59657. private _engine;
  59658. private _renderEffects;
  59659. private _needStencil;
  59660. private _previousStencilState;
  59661. /**
  59662. * Creates a new instance of the component for the given scene
  59663. * @param scene Defines the scene to register the component in
  59664. */
  59665. constructor(scene: Scene);
  59666. /**
  59667. * Registers the component in a given scene
  59668. */
  59669. register(): void;
  59670. /**
  59671. * Rebuilds the elements related to this component in case of
  59672. * context lost for instance.
  59673. */
  59674. rebuild(): void;
  59675. /**
  59676. * Serializes the component data to the specified json object
  59677. * @param serializationObject The object to serialize to
  59678. */
  59679. serialize(serializationObject: any): void;
  59680. /**
  59681. * Adds all the elements from the container to the scene
  59682. * @param container the container holding the elements
  59683. */
  59684. addFromContainer(container: AbstractScene): void;
  59685. /**
  59686. * Removes all the elements in the container from the scene
  59687. * @param container contains the elements to remove
  59688. * @param dispose if the removed element should be disposed (default: false)
  59689. */
  59690. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59691. /**
  59692. * Disposes the component and the associated ressources.
  59693. */
  59694. dispose(): void;
  59695. private _isReadyForMesh;
  59696. private _renderMainTexture;
  59697. private _setStencil;
  59698. private _setStencilBack;
  59699. private _draw;
  59700. private _drawCamera;
  59701. private _drawRenderingGroup;
  59702. }
  59703. }
  59704. declare module BABYLON {
  59705. /** @hidden */
  59706. export var glowMapMergePixelShader: {
  59707. name: string;
  59708. shader: string;
  59709. };
  59710. }
  59711. declare module BABYLON {
  59712. /** @hidden */
  59713. export var glowMapMergeVertexShader: {
  59714. name: string;
  59715. shader: string;
  59716. };
  59717. }
  59718. declare module BABYLON {
  59719. interface AbstractScene {
  59720. /**
  59721. * Return a the first highlight layer of the scene with a given name.
  59722. * @param name The name of the highlight layer to look for.
  59723. * @return The highlight layer if found otherwise null.
  59724. */
  59725. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59726. }
  59727. /**
  59728. * Glow layer options. This helps customizing the behaviour
  59729. * of the glow layer.
  59730. */
  59731. export interface IGlowLayerOptions {
  59732. /**
  59733. * Multiplication factor apply to the canvas size to compute the render target size
  59734. * used to generated the glowing objects (the smaller the faster).
  59735. */
  59736. mainTextureRatio: number;
  59737. /**
  59738. * Enforces a fixed size texture to ensure resize independant blur.
  59739. */
  59740. mainTextureFixedSize?: number;
  59741. /**
  59742. * How big is the kernel of the blur texture.
  59743. */
  59744. blurKernelSize: number;
  59745. /**
  59746. * The camera attached to the layer.
  59747. */
  59748. camera: Nullable<Camera>;
  59749. /**
  59750. * Enable MSAA by chosing the number of samples.
  59751. */
  59752. mainTextureSamples?: number;
  59753. /**
  59754. * The rendering group to draw the layer in.
  59755. */
  59756. renderingGroupId: number;
  59757. }
  59758. /**
  59759. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59760. *
  59761. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59762. *
  59763. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59764. */
  59765. export class GlowLayer extends EffectLayer {
  59766. /**
  59767. * Effect Name of the layer.
  59768. */
  59769. static readonly EffectName: string;
  59770. /**
  59771. * The default blur kernel size used for the glow.
  59772. */
  59773. static DefaultBlurKernelSize: number;
  59774. /**
  59775. * The default texture size ratio used for the glow.
  59776. */
  59777. static DefaultTextureRatio: number;
  59778. /**
  59779. * Sets the kernel size of the blur.
  59780. */
  59781. set blurKernelSize(value: number);
  59782. /**
  59783. * Gets the kernel size of the blur.
  59784. */
  59785. get blurKernelSize(): number;
  59786. /**
  59787. * Sets the glow intensity.
  59788. */
  59789. set intensity(value: number);
  59790. /**
  59791. * Gets the glow intensity.
  59792. */
  59793. get intensity(): number;
  59794. private _options;
  59795. private _intensity;
  59796. private _horizontalBlurPostprocess1;
  59797. private _verticalBlurPostprocess1;
  59798. private _horizontalBlurPostprocess2;
  59799. private _verticalBlurPostprocess2;
  59800. private _blurTexture1;
  59801. private _blurTexture2;
  59802. private _postProcesses1;
  59803. private _postProcesses2;
  59804. private _includedOnlyMeshes;
  59805. private _excludedMeshes;
  59806. private _meshesUsingTheirOwnMaterials;
  59807. /**
  59808. * Callback used to let the user override the color selection on a per mesh basis
  59809. */
  59810. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59811. /**
  59812. * Callback used to let the user override the texture selection on a per mesh basis
  59813. */
  59814. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59815. /**
  59816. * Instantiates a new glow Layer and references it to the scene.
  59817. * @param name The name of the layer
  59818. * @param scene The scene to use the layer in
  59819. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59820. */
  59821. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59822. /**
  59823. * Get the effect name of the layer.
  59824. * @return The effect name
  59825. */
  59826. getEffectName(): string;
  59827. /**
  59828. * Create the merge effect. This is the shader use to blit the information back
  59829. * to the main canvas at the end of the scene rendering.
  59830. */
  59831. protected _createMergeEffect(): Effect;
  59832. /**
  59833. * Creates the render target textures and post processes used in the glow layer.
  59834. */
  59835. protected _createTextureAndPostProcesses(): void;
  59836. /**
  59837. * Checks for the readiness of the element composing the layer.
  59838. * @param subMesh the mesh to check for
  59839. * @param useInstances specify wether or not to use instances to render the mesh
  59840. * @param emissiveTexture the associated emissive texture used to generate the glow
  59841. * @return true if ready otherwise, false
  59842. */
  59843. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59844. /**
  59845. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59846. */
  59847. needStencil(): boolean;
  59848. /**
  59849. * Returns true if the mesh can be rendered, otherwise false.
  59850. * @param mesh The mesh to render
  59851. * @param material The material used on the mesh
  59852. * @returns true if it can be rendered otherwise false
  59853. */
  59854. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59855. /**
  59856. * Implementation specific of rendering the generating effect on the main canvas.
  59857. * @param effect The effect used to render through
  59858. */
  59859. protected _internalRender(effect: Effect): void;
  59860. /**
  59861. * Sets the required values for both the emissive texture and and the main color.
  59862. */
  59863. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59864. /**
  59865. * Returns true if the mesh should render, otherwise false.
  59866. * @param mesh The mesh to render
  59867. * @returns true if it should render otherwise false
  59868. */
  59869. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59870. /**
  59871. * Adds specific effects defines.
  59872. * @param defines The defines to add specifics to.
  59873. */
  59874. protected _addCustomEffectDefines(defines: string[]): void;
  59875. /**
  59876. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59877. * @param mesh The mesh to exclude from the glow layer
  59878. */
  59879. addExcludedMesh(mesh: Mesh): void;
  59880. /**
  59881. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59882. * @param mesh The mesh to remove
  59883. */
  59884. removeExcludedMesh(mesh: Mesh): void;
  59885. /**
  59886. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59887. * @param mesh The mesh to include in the glow layer
  59888. */
  59889. addIncludedOnlyMesh(mesh: Mesh): void;
  59890. /**
  59891. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59892. * @param mesh The mesh to remove
  59893. */
  59894. removeIncludedOnlyMesh(mesh: Mesh): void;
  59895. /**
  59896. * Determine if a given mesh will be used in the glow layer
  59897. * @param mesh The mesh to test
  59898. * @returns true if the mesh will be highlighted by the current glow layer
  59899. */
  59900. hasMesh(mesh: AbstractMesh): boolean;
  59901. /**
  59902. * Defines whether the current material of the mesh should be use to render the effect.
  59903. * @param mesh defines the current mesh to render
  59904. */
  59905. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59906. /**
  59907. * Add a mesh to be rendered through its own material and not with emissive only.
  59908. * @param mesh The mesh for which we need to use its material
  59909. */
  59910. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59911. /**
  59912. * Remove a mesh from being rendered through its own material and not with emissive only.
  59913. * @param mesh The mesh for which we need to not use its material
  59914. */
  59915. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59916. /**
  59917. * Free any resources and references associated to a mesh.
  59918. * Internal use
  59919. * @param mesh The mesh to free.
  59920. * @hidden
  59921. */
  59922. _disposeMesh(mesh: Mesh): void;
  59923. /**
  59924. * Gets the class name of the effect layer
  59925. * @returns the string with the class name of the effect layer
  59926. */
  59927. getClassName(): string;
  59928. /**
  59929. * Serializes this glow layer
  59930. * @returns a serialized glow layer object
  59931. */
  59932. serialize(): any;
  59933. /**
  59934. * Creates a Glow Layer from parsed glow layer data
  59935. * @param parsedGlowLayer defines glow layer data
  59936. * @param scene defines the current scene
  59937. * @param rootUrl defines the root URL containing the glow layer information
  59938. * @returns a parsed Glow Layer
  59939. */
  59940. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59941. }
  59942. }
  59943. declare module BABYLON {
  59944. /** @hidden */
  59945. export var glowBlurPostProcessPixelShader: {
  59946. name: string;
  59947. shader: string;
  59948. };
  59949. }
  59950. declare module BABYLON {
  59951. interface AbstractScene {
  59952. /**
  59953. * Return a the first highlight layer of the scene with a given name.
  59954. * @param name The name of the highlight layer to look for.
  59955. * @return The highlight layer if found otherwise null.
  59956. */
  59957. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59958. }
  59959. /**
  59960. * Highlight layer options. This helps customizing the behaviour
  59961. * of the highlight layer.
  59962. */
  59963. export interface IHighlightLayerOptions {
  59964. /**
  59965. * Multiplication factor apply to the canvas size to compute the render target size
  59966. * used to generated the glowing objects (the smaller the faster).
  59967. */
  59968. mainTextureRatio: number;
  59969. /**
  59970. * Enforces a fixed size texture to ensure resize independant blur.
  59971. */
  59972. mainTextureFixedSize?: number;
  59973. /**
  59974. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59975. * of the picture to blur (the smaller the faster).
  59976. */
  59977. blurTextureSizeRatio: number;
  59978. /**
  59979. * How big in texel of the blur texture is the vertical blur.
  59980. */
  59981. blurVerticalSize: number;
  59982. /**
  59983. * How big in texel of the blur texture is the horizontal blur.
  59984. */
  59985. blurHorizontalSize: number;
  59986. /**
  59987. * Alpha blending mode used to apply the blur. Default is combine.
  59988. */
  59989. alphaBlendingMode: number;
  59990. /**
  59991. * The camera attached to the layer.
  59992. */
  59993. camera: Nullable<Camera>;
  59994. /**
  59995. * Should we display highlight as a solid stroke?
  59996. */
  59997. isStroke?: boolean;
  59998. /**
  59999. * The rendering group to draw the layer in.
  60000. */
  60001. renderingGroupId: number;
  60002. }
  60003. /**
  60004. * The highlight layer Helps adding a glow effect around a mesh.
  60005. *
  60006. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60007. * glowy meshes to your scene.
  60008. *
  60009. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60010. */
  60011. export class HighlightLayer extends EffectLayer {
  60012. name: string;
  60013. /**
  60014. * Effect Name of the highlight layer.
  60015. */
  60016. static readonly EffectName: string;
  60017. /**
  60018. * The neutral color used during the preparation of the glow effect.
  60019. * This is black by default as the blend operation is a blend operation.
  60020. */
  60021. static NeutralColor: Color4;
  60022. /**
  60023. * Stencil value used for glowing meshes.
  60024. */
  60025. static GlowingMeshStencilReference: number;
  60026. /**
  60027. * Stencil value used for the other meshes in the scene.
  60028. */
  60029. static NormalMeshStencilReference: number;
  60030. /**
  60031. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60032. */
  60033. innerGlow: boolean;
  60034. /**
  60035. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60036. */
  60037. outerGlow: boolean;
  60038. /**
  60039. * Specifies the horizontal size of the blur.
  60040. */
  60041. set blurHorizontalSize(value: number);
  60042. /**
  60043. * Specifies the vertical size of the blur.
  60044. */
  60045. set blurVerticalSize(value: number);
  60046. /**
  60047. * Gets the horizontal size of the blur.
  60048. */
  60049. get blurHorizontalSize(): number;
  60050. /**
  60051. * Gets the vertical size of the blur.
  60052. */
  60053. get blurVerticalSize(): number;
  60054. /**
  60055. * An event triggered when the highlight layer is being blurred.
  60056. */
  60057. onBeforeBlurObservable: Observable<HighlightLayer>;
  60058. /**
  60059. * An event triggered when the highlight layer has been blurred.
  60060. */
  60061. onAfterBlurObservable: Observable<HighlightLayer>;
  60062. private _instanceGlowingMeshStencilReference;
  60063. private _options;
  60064. private _downSamplePostprocess;
  60065. private _horizontalBlurPostprocess;
  60066. private _verticalBlurPostprocess;
  60067. private _blurTexture;
  60068. private _meshes;
  60069. private _excludedMeshes;
  60070. /**
  60071. * Instantiates a new highlight Layer and references it to the scene..
  60072. * @param name The name of the layer
  60073. * @param scene The scene to use the layer in
  60074. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60075. */
  60076. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60077. /**
  60078. * Get the effect name of the layer.
  60079. * @return The effect name
  60080. */
  60081. getEffectName(): string;
  60082. /**
  60083. * Create the merge effect. This is the shader use to blit the information back
  60084. * to the main canvas at the end of the scene rendering.
  60085. */
  60086. protected _createMergeEffect(): Effect;
  60087. /**
  60088. * Creates the render target textures and post processes used in the highlight layer.
  60089. */
  60090. protected _createTextureAndPostProcesses(): void;
  60091. /**
  60092. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60093. */
  60094. needStencil(): boolean;
  60095. /**
  60096. * Checks for the readiness of the element composing the layer.
  60097. * @param subMesh the mesh to check for
  60098. * @param useInstances specify wether or not to use instances to render the mesh
  60099. * @param emissiveTexture the associated emissive texture used to generate the glow
  60100. * @return true if ready otherwise, false
  60101. */
  60102. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60103. /**
  60104. * Implementation specific of rendering the generating effect on the main canvas.
  60105. * @param effect The effect used to render through
  60106. */
  60107. protected _internalRender(effect: Effect): void;
  60108. /**
  60109. * Returns true if the layer contains information to display, otherwise false.
  60110. */
  60111. shouldRender(): boolean;
  60112. /**
  60113. * Returns true if the mesh should render, otherwise false.
  60114. * @param mesh The mesh to render
  60115. * @returns true if it should render otherwise false
  60116. */
  60117. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60118. /**
  60119. * Returns true if the mesh can be rendered, otherwise false.
  60120. * @param mesh The mesh to render
  60121. * @param material The material used on the mesh
  60122. * @returns true if it can be rendered otherwise false
  60123. */
  60124. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60125. /**
  60126. * Adds specific effects defines.
  60127. * @param defines The defines to add specifics to.
  60128. */
  60129. protected _addCustomEffectDefines(defines: string[]): void;
  60130. /**
  60131. * Sets the required values for both the emissive texture and and the main color.
  60132. */
  60133. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60134. /**
  60135. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60136. * @param mesh The mesh to exclude from the highlight layer
  60137. */
  60138. addExcludedMesh(mesh: Mesh): void;
  60139. /**
  60140. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60141. * @param mesh The mesh to highlight
  60142. */
  60143. removeExcludedMesh(mesh: Mesh): void;
  60144. /**
  60145. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60146. * @param mesh mesh to test
  60147. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60148. */
  60149. hasMesh(mesh: AbstractMesh): boolean;
  60150. /**
  60151. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60152. * @param mesh The mesh to highlight
  60153. * @param color The color of the highlight
  60154. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60155. */
  60156. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60157. /**
  60158. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60159. * @param mesh The mesh to highlight
  60160. */
  60161. removeMesh(mesh: Mesh): void;
  60162. /**
  60163. * Remove all the meshes currently referenced in the highlight layer
  60164. */
  60165. removeAllMeshes(): void;
  60166. /**
  60167. * Force the stencil to the normal expected value for none glowing parts
  60168. */
  60169. private _defaultStencilReference;
  60170. /**
  60171. * Free any resources and references associated to a mesh.
  60172. * Internal use
  60173. * @param mesh The mesh to free.
  60174. * @hidden
  60175. */
  60176. _disposeMesh(mesh: Mesh): void;
  60177. /**
  60178. * Dispose the highlight layer and free resources.
  60179. */
  60180. dispose(): void;
  60181. /**
  60182. * Gets the class name of the effect layer
  60183. * @returns the string with the class name of the effect layer
  60184. */
  60185. getClassName(): string;
  60186. /**
  60187. * Serializes this Highlight layer
  60188. * @returns a serialized Highlight layer object
  60189. */
  60190. serialize(): any;
  60191. /**
  60192. * Creates a Highlight layer from parsed Highlight layer data
  60193. * @param parsedHightlightLayer defines the Highlight layer data
  60194. * @param scene defines the current scene
  60195. * @param rootUrl defines the root URL containing the Highlight layer information
  60196. * @returns a parsed Highlight layer
  60197. */
  60198. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60199. }
  60200. }
  60201. declare module BABYLON {
  60202. interface AbstractScene {
  60203. /**
  60204. * The list of layers (background and foreground) of the scene
  60205. */
  60206. layers: Array<Layer>;
  60207. }
  60208. /**
  60209. * Defines the layer scene component responsible to manage any layers
  60210. * in a given scene.
  60211. */
  60212. export class LayerSceneComponent implements ISceneComponent {
  60213. /**
  60214. * The component name helpfull to identify the component in the list of scene components.
  60215. */
  60216. readonly name: string;
  60217. /**
  60218. * The scene the component belongs to.
  60219. */
  60220. scene: Scene;
  60221. private _engine;
  60222. /**
  60223. * Creates a new instance of the component for the given scene
  60224. * @param scene Defines the scene to register the component in
  60225. */
  60226. constructor(scene: Scene);
  60227. /**
  60228. * Registers the component in a given scene
  60229. */
  60230. register(): void;
  60231. /**
  60232. * Rebuilds the elements related to this component in case of
  60233. * context lost for instance.
  60234. */
  60235. rebuild(): void;
  60236. /**
  60237. * Disposes the component and the associated ressources.
  60238. */
  60239. dispose(): void;
  60240. private _draw;
  60241. private _drawCameraPredicate;
  60242. private _drawCameraBackground;
  60243. private _drawCameraForeground;
  60244. private _drawRenderTargetPredicate;
  60245. private _drawRenderTargetBackground;
  60246. private _drawRenderTargetForeground;
  60247. /**
  60248. * Adds all the elements from the container to the scene
  60249. * @param container the container holding the elements
  60250. */
  60251. addFromContainer(container: AbstractScene): void;
  60252. /**
  60253. * Removes all the elements in the container from the scene
  60254. * @param container contains the elements to remove
  60255. * @param dispose if the removed element should be disposed (default: false)
  60256. */
  60257. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60258. }
  60259. }
  60260. declare module BABYLON {
  60261. /** @hidden */
  60262. export var layerPixelShader: {
  60263. name: string;
  60264. shader: string;
  60265. };
  60266. }
  60267. declare module BABYLON {
  60268. /** @hidden */
  60269. export var layerVertexShader: {
  60270. name: string;
  60271. shader: string;
  60272. };
  60273. }
  60274. declare module BABYLON {
  60275. /**
  60276. * This represents a full screen 2d layer.
  60277. * This can be useful to display a picture in the background of your scene for instance.
  60278. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60279. */
  60280. export class Layer {
  60281. /**
  60282. * Define the name of the layer.
  60283. */
  60284. name: string;
  60285. /**
  60286. * Define the texture the layer should display.
  60287. */
  60288. texture: Nullable<Texture>;
  60289. /**
  60290. * Is the layer in background or foreground.
  60291. */
  60292. isBackground: boolean;
  60293. /**
  60294. * Define the color of the layer (instead of texture).
  60295. */
  60296. color: Color4;
  60297. /**
  60298. * Define the scale of the layer in order to zoom in out of the texture.
  60299. */
  60300. scale: Vector2;
  60301. /**
  60302. * Define an offset for the layer in order to shift the texture.
  60303. */
  60304. offset: Vector2;
  60305. /**
  60306. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60307. */
  60308. alphaBlendingMode: number;
  60309. /**
  60310. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60311. * Alpha test will not mix with the background color in case of transparency.
  60312. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60313. */
  60314. alphaTest: boolean;
  60315. /**
  60316. * Define a mask to restrict the layer to only some of the scene cameras.
  60317. */
  60318. layerMask: number;
  60319. /**
  60320. * Define the list of render target the layer is visible into.
  60321. */
  60322. renderTargetTextures: RenderTargetTexture[];
  60323. /**
  60324. * Define if the layer is only used in renderTarget or if it also
  60325. * renders in the main frame buffer of the canvas.
  60326. */
  60327. renderOnlyInRenderTargetTextures: boolean;
  60328. private _scene;
  60329. private _vertexBuffers;
  60330. private _indexBuffer;
  60331. private _effect;
  60332. private _previousDefines;
  60333. /**
  60334. * An event triggered when the layer is disposed.
  60335. */
  60336. onDisposeObservable: Observable<Layer>;
  60337. private _onDisposeObserver;
  60338. /**
  60339. * Back compatibility with callback before the onDisposeObservable existed.
  60340. * The set callback will be triggered when the layer has been disposed.
  60341. */
  60342. set onDispose(callback: () => void);
  60343. /**
  60344. * An event triggered before rendering the scene
  60345. */
  60346. onBeforeRenderObservable: Observable<Layer>;
  60347. private _onBeforeRenderObserver;
  60348. /**
  60349. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60350. * The set callback will be triggered just before rendering the layer.
  60351. */
  60352. set onBeforeRender(callback: () => void);
  60353. /**
  60354. * An event triggered after rendering the scene
  60355. */
  60356. onAfterRenderObservable: Observable<Layer>;
  60357. private _onAfterRenderObserver;
  60358. /**
  60359. * Back compatibility with callback before the onAfterRenderObservable existed.
  60360. * The set callback will be triggered just after rendering the layer.
  60361. */
  60362. set onAfterRender(callback: () => void);
  60363. /**
  60364. * Instantiates a new layer.
  60365. * This represents a full screen 2d layer.
  60366. * This can be useful to display a picture in the background of your scene for instance.
  60367. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60368. * @param name Define the name of the layer in the scene
  60369. * @param imgUrl Define the url of the texture to display in the layer
  60370. * @param scene Define the scene the layer belongs to
  60371. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60372. * @param color Defines a color for the layer
  60373. */
  60374. constructor(
  60375. /**
  60376. * Define the name of the layer.
  60377. */
  60378. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60379. private _createIndexBuffer;
  60380. /** @hidden */
  60381. _rebuild(): void;
  60382. /**
  60383. * Renders the layer in the scene.
  60384. */
  60385. render(): void;
  60386. /**
  60387. * Disposes and releases the associated ressources.
  60388. */
  60389. dispose(): void;
  60390. }
  60391. }
  60392. declare module BABYLON {
  60393. /** @hidden */
  60394. export var lensFlarePixelShader: {
  60395. name: string;
  60396. shader: string;
  60397. };
  60398. }
  60399. declare module BABYLON {
  60400. /** @hidden */
  60401. export var lensFlareVertexShader: {
  60402. name: string;
  60403. shader: string;
  60404. };
  60405. }
  60406. declare module BABYLON {
  60407. /**
  60408. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60409. * It is usually composed of several `lensFlare`.
  60410. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60411. */
  60412. export class LensFlareSystem {
  60413. /**
  60414. * Define the name of the lens flare system
  60415. */
  60416. name: string;
  60417. /**
  60418. * List of lens flares used in this system.
  60419. */
  60420. lensFlares: LensFlare[];
  60421. /**
  60422. * Define a limit from the border the lens flare can be visible.
  60423. */
  60424. borderLimit: number;
  60425. /**
  60426. * Define a viewport border we do not want to see the lens flare in.
  60427. */
  60428. viewportBorder: number;
  60429. /**
  60430. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60431. */
  60432. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60433. /**
  60434. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60435. */
  60436. layerMask: number;
  60437. /**
  60438. * Define the id of the lens flare system in the scene.
  60439. * (equal to name by default)
  60440. */
  60441. id: string;
  60442. private _scene;
  60443. private _emitter;
  60444. private _vertexBuffers;
  60445. private _indexBuffer;
  60446. private _effect;
  60447. private _positionX;
  60448. private _positionY;
  60449. private _isEnabled;
  60450. /** @hidden */
  60451. static _SceneComponentInitialization: (scene: Scene) => void;
  60452. /**
  60453. * Instantiates a lens flare system.
  60454. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60455. * It is usually composed of several `lensFlare`.
  60456. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60457. * @param name Define the name of the lens flare system in the scene
  60458. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60459. * @param scene Define the scene the lens flare system belongs to
  60460. */
  60461. constructor(
  60462. /**
  60463. * Define the name of the lens flare system
  60464. */
  60465. name: string, emitter: any, scene: Scene);
  60466. /**
  60467. * Define if the lens flare system is enabled.
  60468. */
  60469. get isEnabled(): boolean;
  60470. set isEnabled(value: boolean);
  60471. /**
  60472. * Get the scene the effects belongs to.
  60473. * @returns the scene holding the lens flare system
  60474. */
  60475. getScene(): Scene;
  60476. /**
  60477. * Get the emitter of the lens flare system.
  60478. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60479. * @returns the emitter of the lens flare system
  60480. */
  60481. getEmitter(): any;
  60482. /**
  60483. * Set the emitter of the lens flare system.
  60484. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60485. * @param newEmitter Define the new emitter of the system
  60486. */
  60487. setEmitter(newEmitter: any): void;
  60488. /**
  60489. * Get the lens flare system emitter position.
  60490. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60491. * @returns the position
  60492. */
  60493. getEmitterPosition(): Vector3;
  60494. /**
  60495. * @hidden
  60496. */
  60497. computeEffectivePosition(globalViewport: Viewport): boolean;
  60498. /** @hidden */
  60499. _isVisible(): boolean;
  60500. /**
  60501. * @hidden
  60502. */
  60503. render(): boolean;
  60504. /**
  60505. * Dispose and release the lens flare with its associated resources.
  60506. */
  60507. dispose(): void;
  60508. /**
  60509. * Parse a lens flare system from a JSON repressentation
  60510. * @param parsedLensFlareSystem Define the JSON to parse
  60511. * @param scene Define the scene the parsed system should be instantiated in
  60512. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60513. * @returns the parsed system
  60514. */
  60515. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60516. /**
  60517. * Serialize the current Lens Flare System into a JSON representation.
  60518. * @returns the serialized JSON
  60519. */
  60520. serialize(): any;
  60521. }
  60522. }
  60523. declare module BABYLON {
  60524. /**
  60525. * This represents one of the lens effect in a `lensFlareSystem`.
  60526. * It controls one of the indiviual texture used in the effect.
  60527. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60528. */
  60529. export class LensFlare {
  60530. /**
  60531. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60532. */
  60533. size: number;
  60534. /**
  60535. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  60536. */
  60537. position: number;
  60538. /**
  60539. * Define the lens color.
  60540. */
  60541. color: Color3;
  60542. /**
  60543. * Define the lens texture.
  60544. */
  60545. texture: Nullable<Texture>;
  60546. /**
  60547. * Define the alpha mode to render this particular lens.
  60548. */
  60549. alphaMode: number;
  60550. private _system;
  60551. /**
  60552. * Creates a new Lens Flare.
  60553. * This represents one of the lens effect in a `lensFlareSystem`.
  60554. * It controls one of the indiviual texture used in the effect.
  60555. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60556. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60557. * @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.
  60558. * @param color Define the lens color
  60559. * @param imgUrl Define the lens texture url
  60560. * @param system Define the `lensFlareSystem` this flare is part of
  60561. * @returns The newly created Lens Flare
  60562. */
  60563. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60564. /**
  60565. * Instantiates a new Lens Flare.
  60566. * This represents one of the lens effect in a `lensFlareSystem`.
  60567. * It controls one of the indiviual texture used in the effect.
  60568. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60569. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60570. * @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.
  60571. * @param color Define the lens color
  60572. * @param imgUrl Define the lens texture url
  60573. * @param system Define the `lensFlareSystem` this flare is part of
  60574. */
  60575. constructor(
  60576. /**
  60577. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60578. */
  60579. size: number,
  60580. /**
  60581. * 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.
  60582. */
  60583. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60584. /**
  60585. * Dispose and release the lens flare with its associated resources.
  60586. */
  60587. dispose(): void;
  60588. }
  60589. }
  60590. declare module BABYLON {
  60591. interface AbstractScene {
  60592. /**
  60593. * The list of lens flare system added to the scene
  60594. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60595. */
  60596. lensFlareSystems: Array<LensFlareSystem>;
  60597. /**
  60598. * Removes the given lens flare system from this scene.
  60599. * @param toRemove The lens flare system to remove
  60600. * @returns The index of the removed lens flare system
  60601. */
  60602. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60603. /**
  60604. * Adds the given lens flare system to this scene
  60605. * @param newLensFlareSystem The lens flare system to add
  60606. */
  60607. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60608. /**
  60609. * Gets a lens flare system using its name
  60610. * @param name defines the name to look for
  60611. * @returns the lens flare system or null if not found
  60612. */
  60613. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60614. /**
  60615. * Gets a lens flare system using its id
  60616. * @param id defines the id to look for
  60617. * @returns the lens flare system or null if not found
  60618. */
  60619. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60620. }
  60621. /**
  60622. * Defines the lens flare scene component responsible to manage any lens flares
  60623. * in a given scene.
  60624. */
  60625. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60626. /**
  60627. * The component name helpfull to identify the component in the list of scene components.
  60628. */
  60629. readonly name: string;
  60630. /**
  60631. * The scene the component belongs to.
  60632. */
  60633. scene: Scene;
  60634. /**
  60635. * Creates a new instance of the component for the given scene
  60636. * @param scene Defines the scene to register the component in
  60637. */
  60638. constructor(scene: Scene);
  60639. /**
  60640. * Registers the component in a given scene
  60641. */
  60642. register(): void;
  60643. /**
  60644. * Rebuilds the elements related to this component in case of
  60645. * context lost for instance.
  60646. */
  60647. rebuild(): void;
  60648. /**
  60649. * Adds all the elements from the container to the scene
  60650. * @param container the container holding the elements
  60651. */
  60652. addFromContainer(container: AbstractScene): void;
  60653. /**
  60654. * Removes all the elements in the container from the scene
  60655. * @param container contains the elements to remove
  60656. * @param dispose if the removed element should be disposed (default: false)
  60657. */
  60658. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60659. /**
  60660. * Serializes the component data to the specified json object
  60661. * @param serializationObject The object to serialize to
  60662. */
  60663. serialize(serializationObject: any): void;
  60664. /**
  60665. * Disposes the component and the associated ressources.
  60666. */
  60667. dispose(): void;
  60668. private _draw;
  60669. }
  60670. }
  60671. declare module BABYLON {
  60672. /** @hidden */
  60673. export var depthPixelShader: {
  60674. name: string;
  60675. shader: string;
  60676. };
  60677. }
  60678. declare module BABYLON {
  60679. /** @hidden */
  60680. export var depthVertexShader: {
  60681. name: string;
  60682. shader: string;
  60683. };
  60684. }
  60685. declare module BABYLON {
  60686. /**
  60687. * This represents a depth renderer in Babylon.
  60688. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60689. */
  60690. export class DepthRenderer {
  60691. private _scene;
  60692. private _depthMap;
  60693. private _effect;
  60694. private readonly _storeNonLinearDepth;
  60695. private readonly _clearColor;
  60696. /** Get if the depth renderer is using packed depth or not */
  60697. readonly isPacked: boolean;
  60698. private _cachedDefines;
  60699. private _camera;
  60700. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60701. enabled: boolean;
  60702. /**
  60703. * Specifiess that the depth renderer will only be used within
  60704. * the camera it is created for.
  60705. * This can help forcing its rendering during the camera processing.
  60706. */
  60707. useOnlyInActiveCamera: boolean;
  60708. /** @hidden */
  60709. static _SceneComponentInitialization: (scene: Scene) => void;
  60710. /**
  60711. * Instantiates a depth renderer
  60712. * @param scene The scene the renderer belongs to
  60713. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60714. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60715. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60716. */
  60717. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60718. /**
  60719. * Creates the depth rendering effect and checks if the effect is ready.
  60720. * @param subMesh The submesh to be used to render the depth map of
  60721. * @param useInstances If multiple world instances should be used
  60722. * @returns if the depth renderer is ready to render the depth map
  60723. */
  60724. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60725. /**
  60726. * Gets the texture which the depth map will be written to.
  60727. * @returns The depth map texture
  60728. */
  60729. getDepthMap(): RenderTargetTexture;
  60730. /**
  60731. * Disposes of the depth renderer.
  60732. */
  60733. dispose(): void;
  60734. }
  60735. }
  60736. declare module BABYLON {
  60737. /** @hidden */
  60738. export var minmaxReduxPixelShader: {
  60739. name: string;
  60740. shader: string;
  60741. };
  60742. }
  60743. declare module BABYLON {
  60744. /**
  60745. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60746. * and maximum values from all values of the texture.
  60747. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60748. * The source values are read from the red channel of the texture.
  60749. */
  60750. export class MinMaxReducer {
  60751. /**
  60752. * Observable triggered when the computation has been performed
  60753. */
  60754. onAfterReductionPerformed: Observable<{
  60755. min: number;
  60756. max: number;
  60757. }>;
  60758. protected _camera: Camera;
  60759. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60760. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60761. protected _postProcessManager: PostProcessManager;
  60762. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60763. protected _forceFullscreenViewport: boolean;
  60764. /**
  60765. * Creates a min/max reducer
  60766. * @param camera The camera to use for the post processes
  60767. */
  60768. constructor(camera: Camera);
  60769. /**
  60770. * Gets the texture used to read the values from.
  60771. */
  60772. get sourceTexture(): Nullable<RenderTargetTexture>;
  60773. /**
  60774. * Sets the source texture to read the values from.
  60775. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60776. * because in such textures '1' value must not be taken into account to compute the maximum
  60777. * as this value is used to clear the texture.
  60778. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60779. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60780. * @param depthRedux Indicates if the texture is a depth texture or not
  60781. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60782. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60783. */
  60784. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60785. /**
  60786. * Defines the refresh rate of the computation.
  60787. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60788. */
  60789. get refreshRate(): number;
  60790. set refreshRate(value: number);
  60791. protected _activated: boolean;
  60792. /**
  60793. * Gets the activation status of the reducer
  60794. */
  60795. get activated(): boolean;
  60796. /**
  60797. * Activates the reduction computation.
  60798. * When activated, the observers registered in onAfterReductionPerformed are
  60799. * called after the compuation is performed
  60800. */
  60801. activate(): void;
  60802. /**
  60803. * Deactivates the reduction computation.
  60804. */
  60805. deactivate(): void;
  60806. /**
  60807. * Disposes the min/max reducer
  60808. * @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.
  60809. */
  60810. dispose(disposeAll?: boolean): void;
  60811. }
  60812. }
  60813. declare module BABYLON {
  60814. /**
  60815. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60816. */
  60817. export class DepthReducer extends MinMaxReducer {
  60818. private _depthRenderer;
  60819. private _depthRendererId;
  60820. /**
  60821. * Gets the depth renderer used for the computation.
  60822. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60823. */
  60824. get depthRenderer(): Nullable<DepthRenderer>;
  60825. /**
  60826. * Creates a depth reducer
  60827. * @param camera The camera used to render the depth texture
  60828. */
  60829. constructor(camera: Camera);
  60830. /**
  60831. * Sets the depth renderer to use to generate the depth map
  60832. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60833. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60834. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60835. */
  60836. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60837. /** @hidden */
  60838. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60839. /**
  60840. * Activates the reduction computation.
  60841. * When activated, the observers registered in onAfterReductionPerformed are
  60842. * called after the compuation is performed
  60843. */
  60844. activate(): void;
  60845. /**
  60846. * Deactivates the reduction computation.
  60847. */
  60848. deactivate(): void;
  60849. /**
  60850. * Disposes the depth reducer
  60851. * @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.
  60852. */
  60853. dispose(disposeAll?: boolean): void;
  60854. }
  60855. }
  60856. declare module BABYLON {
  60857. /**
  60858. * A CSM implementation allowing casting shadows on large scenes.
  60859. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60860. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60861. */
  60862. export class CascadedShadowGenerator extends ShadowGenerator {
  60863. private static readonly frustumCornersNDCSpace;
  60864. /**
  60865. * Name of the CSM class
  60866. */
  60867. static CLASSNAME: string;
  60868. /**
  60869. * Defines the default number of cascades used by the CSM.
  60870. */
  60871. static readonly DEFAULT_CASCADES_COUNT: number;
  60872. /**
  60873. * Defines the minimum number of cascades used by the CSM.
  60874. */
  60875. static readonly MIN_CASCADES_COUNT: number;
  60876. /**
  60877. * Defines the maximum number of cascades used by the CSM.
  60878. */
  60879. static readonly MAX_CASCADES_COUNT: number;
  60880. protected _validateFilter(filter: number): number;
  60881. /**
  60882. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60883. */
  60884. penumbraDarkness: number;
  60885. private _numCascades;
  60886. /**
  60887. * Gets or set the number of cascades used by the CSM.
  60888. */
  60889. get numCascades(): number;
  60890. set numCascades(value: number);
  60891. /**
  60892. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60893. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60894. */
  60895. stabilizeCascades: boolean;
  60896. private _freezeShadowCastersBoundingInfo;
  60897. private _freezeShadowCastersBoundingInfoObservable;
  60898. /**
  60899. * Enables or disables the shadow casters bounding info computation.
  60900. * If your shadow casters don't move, you can disable this feature.
  60901. * If it is enabled, the bounding box computation is done every frame.
  60902. */
  60903. get freezeShadowCastersBoundingInfo(): boolean;
  60904. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60905. private _scbiMin;
  60906. private _scbiMax;
  60907. protected _computeShadowCastersBoundingInfo(): void;
  60908. protected _shadowCastersBoundingInfo: BoundingInfo;
  60909. /**
  60910. * Gets or sets the shadow casters bounding info.
  60911. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60912. * so that the system won't overwrite the bounds you provide
  60913. */
  60914. get shadowCastersBoundingInfo(): BoundingInfo;
  60915. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60916. protected _breaksAreDirty: boolean;
  60917. protected _minDistance: number;
  60918. protected _maxDistance: number;
  60919. /**
  60920. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60921. *
  60922. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60923. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60924. * @param min minimal distance for the breaks (default to 0.)
  60925. * @param max maximal distance for the breaks (default to 1.)
  60926. */
  60927. setMinMaxDistance(min: number, max: number): void;
  60928. /** Gets the minimal distance used in the cascade break computation */
  60929. get minDistance(): number;
  60930. /** Gets the maximal distance used in the cascade break computation */
  60931. get maxDistance(): number;
  60932. /**
  60933. * Gets the class name of that object
  60934. * @returns "CascadedShadowGenerator"
  60935. */
  60936. getClassName(): string;
  60937. private _cascadeMinExtents;
  60938. private _cascadeMaxExtents;
  60939. /**
  60940. * Gets a cascade minimum extents
  60941. * @param cascadeIndex index of the cascade
  60942. * @returns the minimum cascade extents
  60943. */
  60944. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60945. /**
  60946. * Gets a cascade maximum extents
  60947. * @param cascadeIndex index of the cascade
  60948. * @returns the maximum cascade extents
  60949. */
  60950. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60951. private _cascades;
  60952. private _currentLayer;
  60953. private _viewSpaceFrustumsZ;
  60954. private _viewMatrices;
  60955. private _projectionMatrices;
  60956. private _transformMatrices;
  60957. private _transformMatricesAsArray;
  60958. private _frustumLengths;
  60959. private _lightSizeUVCorrection;
  60960. private _depthCorrection;
  60961. private _frustumCornersWorldSpace;
  60962. private _frustumCenter;
  60963. private _shadowCameraPos;
  60964. private _shadowMaxZ;
  60965. /**
  60966. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60967. * It defaults to camera.maxZ
  60968. */
  60969. get shadowMaxZ(): number;
  60970. /**
  60971. * Sets the shadow max z distance.
  60972. */
  60973. set shadowMaxZ(value: number);
  60974. protected _debug: boolean;
  60975. /**
  60976. * Gets or sets the debug flag.
  60977. * When enabled, the cascades are materialized by different colors on the screen.
  60978. */
  60979. get debug(): boolean;
  60980. set debug(dbg: boolean);
  60981. private _depthClamp;
  60982. /**
  60983. * Gets or sets the depth clamping value.
  60984. *
  60985. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60986. * to account for the shadow casters far away.
  60987. *
  60988. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60989. */
  60990. get depthClamp(): boolean;
  60991. set depthClamp(value: boolean);
  60992. private _cascadeBlendPercentage;
  60993. /**
  60994. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60995. * It defaults to 0.1 (10% blending).
  60996. */
  60997. get cascadeBlendPercentage(): number;
  60998. set cascadeBlendPercentage(value: number);
  60999. private _lambda;
  61000. /**
  61001. * Gets or set the lambda parameter.
  61002. * This parameter is used to split the camera frustum and create the cascades.
  61003. * 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.
  61004. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61005. */
  61006. get lambda(): number;
  61007. set lambda(value: number);
  61008. /**
  61009. * Gets the view matrix corresponding to a given cascade
  61010. * @param cascadeNum cascade to retrieve the view matrix from
  61011. * @returns the cascade view matrix
  61012. */
  61013. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61014. /**
  61015. * Gets the projection matrix corresponding to a given cascade
  61016. * @param cascadeNum cascade to retrieve the projection matrix from
  61017. * @returns the cascade projection matrix
  61018. */
  61019. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61020. /**
  61021. * Gets the transformation matrix corresponding to a given cascade
  61022. * @param cascadeNum cascade to retrieve the transformation matrix from
  61023. * @returns the cascade transformation matrix
  61024. */
  61025. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61026. private _depthRenderer;
  61027. /**
  61028. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61029. *
  61030. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61031. *
  61032. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61033. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61034. * @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
  61035. */
  61036. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61037. private _depthReducer;
  61038. private _autoCalcDepthBounds;
  61039. /**
  61040. * Gets or sets the autoCalcDepthBounds property.
  61041. *
  61042. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61043. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61044. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61045. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61046. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61047. */
  61048. get autoCalcDepthBounds(): boolean;
  61049. set autoCalcDepthBounds(value: boolean);
  61050. /**
  61051. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61052. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61053. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61054. * for setting the refresh rate on the renderer yourself!
  61055. */
  61056. get autoCalcDepthBoundsRefreshRate(): number;
  61057. set autoCalcDepthBoundsRefreshRate(value: number);
  61058. /**
  61059. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61060. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61061. * you change the camera near/far planes!
  61062. */
  61063. splitFrustum(): void;
  61064. private _splitFrustum;
  61065. private _computeMatrices;
  61066. private _computeFrustumInWorldSpace;
  61067. private _computeCascadeFrustum;
  61068. /**
  61069. * Support test.
  61070. */
  61071. static get IsSupported(): boolean;
  61072. /** @hidden */
  61073. static _SceneComponentInitialization: (scene: Scene) => void;
  61074. /**
  61075. * Creates a Cascaded Shadow Generator object.
  61076. * A ShadowGenerator is the required tool to use the shadows.
  61077. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61078. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61079. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61080. * @param light The directional light object generating the shadows.
  61081. * @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.
  61082. */
  61083. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61084. protected _initializeGenerator(): void;
  61085. protected _createTargetRenderTexture(): void;
  61086. protected _initializeShadowMap(): void;
  61087. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61088. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61089. /**
  61090. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61091. * @param defines Defines of the material we want to update
  61092. * @param lightIndex Index of the light in the enabled light list of the material
  61093. */
  61094. prepareDefines(defines: any, lightIndex: number): void;
  61095. /**
  61096. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61097. * defined in the generator but impacting the effect).
  61098. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61099. * @param effect The effect we are binfing the information for
  61100. */
  61101. bindShadowLight(lightIndex: string, effect: Effect): void;
  61102. /**
  61103. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61104. * (eq to view projection * shadow projection matrices)
  61105. * @returns The transform matrix used to create the shadow map
  61106. */
  61107. getTransformMatrix(): Matrix;
  61108. /**
  61109. * Disposes the ShadowGenerator.
  61110. * Returns nothing.
  61111. */
  61112. dispose(): void;
  61113. /**
  61114. * Serializes the shadow generator setup to a json object.
  61115. * @returns The serialized JSON object
  61116. */
  61117. serialize(): any;
  61118. /**
  61119. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61120. * @param parsedShadowGenerator The JSON object to parse
  61121. * @param scene The scene to create the shadow map for
  61122. * @returns The parsed shadow generator
  61123. */
  61124. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61125. }
  61126. }
  61127. declare module BABYLON {
  61128. /**
  61129. * Defines the shadow generator component responsible to manage any shadow generators
  61130. * in a given scene.
  61131. */
  61132. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61133. /**
  61134. * The component name helpfull to identify the component in the list of scene components.
  61135. */
  61136. readonly name: string;
  61137. /**
  61138. * The scene the component belongs to.
  61139. */
  61140. scene: Scene;
  61141. /**
  61142. * Creates a new instance of the component for the given scene
  61143. * @param scene Defines the scene to register the component in
  61144. */
  61145. constructor(scene: Scene);
  61146. /**
  61147. * Registers the component in a given scene
  61148. */
  61149. register(): void;
  61150. /**
  61151. * Rebuilds the elements related to this component in case of
  61152. * context lost for instance.
  61153. */
  61154. rebuild(): void;
  61155. /**
  61156. * Serializes the component data to the specified json object
  61157. * @param serializationObject The object to serialize to
  61158. */
  61159. serialize(serializationObject: any): void;
  61160. /**
  61161. * Adds all the elements from the container to the scene
  61162. * @param container the container holding the elements
  61163. */
  61164. addFromContainer(container: AbstractScene): void;
  61165. /**
  61166. * Removes all the elements in the container from the scene
  61167. * @param container contains the elements to remove
  61168. * @param dispose if the removed element should be disposed (default: false)
  61169. */
  61170. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61171. /**
  61172. * Rebuilds the elements related to this component in case of
  61173. * context lost for instance.
  61174. */
  61175. dispose(): void;
  61176. private _gatherRenderTargets;
  61177. }
  61178. }
  61179. declare module BABYLON {
  61180. /**
  61181. * A point light is a light defined by an unique point in world space.
  61182. * The light is emitted in every direction from this point.
  61183. * A good example of a point light is a standard light bulb.
  61184. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61185. */
  61186. export class PointLight extends ShadowLight {
  61187. private _shadowAngle;
  61188. /**
  61189. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61190. * This specifies what angle the shadow will use to be created.
  61191. *
  61192. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61193. */
  61194. get shadowAngle(): number;
  61195. /**
  61196. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61197. * This specifies what angle the shadow will use to be created.
  61198. *
  61199. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61200. */
  61201. set shadowAngle(value: number);
  61202. /**
  61203. * Gets the direction if it has been set.
  61204. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61205. */
  61206. get direction(): Vector3;
  61207. /**
  61208. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61209. */
  61210. set direction(value: Vector3);
  61211. /**
  61212. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61213. * A PointLight emits the light in every direction.
  61214. * It can cast shadows.
  61215. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61216. * ```javascript
  61217. * var pointLight = new PointLight("pl", camera.position, scene);
  61218. * ```
  61219. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61220. * @param name The light friendly name
  61221. * @param position The position of the point light in the scene
  61222. * @param scene The scene the lights belongs to
  61223. */
  61224. constructor(name: string, position: Vector3, scene: Scene);
  61225. /**
  61226. * Returns the string "PointLight"
  61227. * @returns the class name
  61228. */
  61229. getClassName(): string;
  61230. /**
  61231. * Returns the integer 0.
  61232. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61233. */
  61234. getTypeID(): number;
  61235. /**
  61236. * Specifies wether or not the shadowmap should be a cube texture.
  61237. * @returns true if the shadowmap needs to be a cube texture.
  61238. */
  61239. needCube(): boolean;
  61240. /**
  61241. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61242. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61243. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61244. */
  61245. getShadowDirection(faceIndex?: number): Vector3;
  61246. /**
  61247. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61248. * - fov = PI / 2
  61249. * - aspect ratio : 1.0
  61250. * - z-near and far equal to the active camera minZ and maxZ.
  61251. * Returns the PointLight.
  61252. */
  61253. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61254. protected _buildUniformLayout(): void;
  61255. /**
  61256. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61257. * @param effect The effect to update
  61258. * @param lightIndex The index of the light in the effect to update
  61259. * @returns The point light
  61260. */
  61261. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61262. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61263. /**
  61264. * Prepares the list of defines specific to the light type.
  61265. * @param defines the list of defines
  61266. * @param lightIndex defines the index of the light for the effect
  61267. */
  61268. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61269. }
  61270. }
  61271. declare module BABYLON {
  61272. /**
  61273. * Header information of HDR texture files.
  61274. */
  61275. export interface HDRInfo {
  61276. /**
  61277. * The height of the texture in pixels.
  61278. */
  61279. height: number;
  61280. /**
  61281. * The width of the texture in pixels.
  61282. */
  61283. width: number;
  61284. /**
  61285. * The index of the beginning of the data in the binary file.
  61286. */
  61287. dataPosition: number;
  61288. }
  61289. /**
  61290. * This groups tools to convert HDR texture to native colors array.
  61291. */
  61292. export class HDRTools {
  61293. private static Ldexp;
  61294. private static Rgbe2float;
  61295. private static readStringLine;
  61296. /**
  61297. * Reads header information from an RGBE texture stored in a native array.
  61298. * More information on this format are available here:
  61299. * https://en.wikipedia.org/wiki/RGBE_image_format
  61300. *
  61301. * @param uint8array The binary file stored in native array.
  61302. * @return The header information.
  61303. */
  61304. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61305. /**
  61306. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61307. * This RGBE texture needs to store the information as a panorama.
  61308. *
  61309. * More information on this format are available here:
  61310. * https://en.wikipedia.org/wiki/RGBE_image_format
  61311. *
  61312. * @param buffer The binary file stored in an array buffer.
  61313. * @param size The expected size of the extracted cubemap.
  61314. * @return The Cube Map information.
  61315. */
  61316. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61317. /**
  61318. * Returns the pixels data extracted from an RGBE texture.
  61319. * This pixels will be stored left to right up to down in the R G B order in one array.
  61320. *
  61321. * More information on this format are available here:
  61322. * https://en.wikipedia.org/wiki/RGBE_image_format
  61323. *
  61324. * @param uint8array The binary file stored in an array buffer.
  61325. * @param hdrInfo The header information of the file.
  61326. * @return The pixels data in RGB right to left up to down order.
  61327. */
  61328. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61329. private static RGBE_ReadPixels_RLE;
  61330. private static RGBE_ReadPixels_NOT_RLE;
  61331. }
  61332. }
  61333. declare module BABYLON {
  61334. /**
  61335. * Effect Render Options
  61336. */
  61337. export interface IEffectRendererOptions {
  61338. /**
  61339. * Defines the vertices positions.
  61340. */
  61341. positions?: number[];
  61342. /**
  61343. * Defines the indices.
  61344. */
  61345. indices?: number[];
  61346. }
  61347. /**
  61348. * Helper class to render one or more effects.
  61349. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61350. */
  61351. export class EffectRenderer {
  61352. private engine;
  61353. private static _DefaultOptions;
  61354. private _vertexBuffers;
  61355. private _indexBuffer;
  61356. private _fullscreenViewport;
  61357. /**
  61358. * Creates an effect renderer
  61359. * @param engine the engine to use for rendering
  61360. * @param options defines the options of the effect renderer
  61361. */
  61362. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61363. /**
  61364. * Sets the current viewport in normalized coordinates 0-1
  61365. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61366. */
  61367. setViewport(viewport?: Viewport): void;
  61368. /**
  61369. * Binds the embedded attributes buffer to the effect.
  61370. * @param effect Defines the effect to bind the attributes for
  61371. */
  61372. bindBuffers(effect: Effect): void;
  61373. /**
  61374. * Sets the current effect wrapper to use during draw.
  61375. * The effect needs to be ready before calling this api.
  61376. * This also sets the default full screen position attribute.
  61377. * @param effectWrapper Defines the effect to draw with
  61378. */
  61379. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61380. /**
  61381. * Restores engine states
  61382. */
  61383. restoreStates(): void;
  61384. /**
  61385. * Draws a full screen quad.
  61386. */
  61387. draw(): void;
  61388. private isRenderTargetTexture;
  61389. /**
  61390. * renders one or more effects to a specified texture
  61391. * @param effectWrapper the effect to renderer
  61392. * @param outputTexture texture to draw to, if null it will render to the screen.
  61393. */
  61394. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61395. /**
  61396. * Disposes of the effect renderer
  61397. */
  61398. dispose(): void;
  61399. }
  61400. /**
  61401. * Options to create an EffectWrapper
  61402. */
  61403. interface EffectWrapperCreationOptions {
  61404. /**
  61405. * Engine to use to create the effect
  61406. */
  61407. engine: ThinEngine;
  61408. /**
  61409. * Fragment shader for the effect
  61410. */
  61411. fragmentShader: string;
  61412. /**
  61413. * Use the shader store instead of direct source code
  61414. */
  61415. useShaderStore?: boolean;
  61416. /**
  61417. * Vertex shader for the effect
  61418. */
  61419. vertexShader?: string;
  61420. /**
  61421. * Attributes to use in the shader
  61422. */
  61423. attributeNames?: Array<string>;
  61424. /**
  61425. * Uniforms to use in the shader
  61426. */
  61427. uniformNames?: Array<string>;
  61428. /**
  61429. * Texture sampler names to use in the shader
  61430. */
  61431. samplerNames?: Array<string>;
  61432. /**
  61433. * Defines to use in the shader
  61434. */
  61435. defines?: Array<string>;
  61436. /**
  61437. * Callback when effect is compiled
  61438. */
  61439. onCompiled?: Nullable<(effect: Effect) => void>;
  61440. /**
  61441. * The friendly name of the effect displayed in Spector.
  61442. */
  61443. name?: string;
  61444. }
  61445. /**
  61446. * Wraps an effect to be used for rendering
  61447. */
  61448. export class EffectWrapper {
  61449. /**
  61450. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61451. */
  61452. onApplyObservable: Observable<{}>;
  61453. /**
  61454. * The underlying effect
  61455. */
  61456. effect: Effect;
  61457. /**
  61458. * Creates an effect to be renderer
  61459. * @param creationOptions options to create the effect
  61460. */
  61461. constructor(creationOptions: EffectWrapperCreationOptions);
  61462. /**
  61463. * Disposes of the effect wrapper
  61464. */
  61465. dispose(): void;
  61466. }
  61467. }
  61468. declare module BABYLON {
  61469. /** @hidden */
  61470. export var hdrFilteringVertexShader: {
  61471. name: string;
  61472. shader: string;
  61473. };
  61474. }
  61475. declare module BABYLON {
  61476. /** @hidden */
  61477. export var hdrFilteringPixelShader: {
  61478. name: string;
  61479. shader: string;
  61480. };
  61481. }
  61482. declare module BABYLON {
  61483. /**
  61484. * Options for texture filtering
  61485. */
  61486. interface IHDRFilteringOptions {
  61487. /**
  61488. * Scales pixel intensity for the input HDR map.
  61489. */
  61490. hdrScale?: number;
  61491. /**
  61492. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61493. */
  61494. quality?: number;
  61495. }
  61496. /**
  61497. * Filters HDR maps to get correct renderings of PBR reflections
  61498. */
  61499. export class HDRFiltering {
  61500. private _engine;
  61501. private _effectRenderer;
  61502. private _effectWrapper;
  61503. private _lodGenerationOffset;
  61504. private _lodGenerationScale;
  61505. /**
  61506. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61507. * you care about baking speed.
  61508. */
  61509. quality: number;
  61510. /**
  61511. * Scales pixel intensity for the input HDR map.
  61512. */
  61513. hdrScale: number;
  61514. /**
  61515. * Instantiates HDR filter for reflection maps
  61516. *
  61517. * @param engine Thin engine
  61518. * @param options Options
  61519. */
  61520. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61521. private _createRenderTarget;
  61522. private _prefilterInternal;
  61523. private _createEffect;
  61524. /**
  61525. * Get a value indicating if the filter is ready to be used
  61526. * @param texture Texture to filter
  61527. * @returns true if the filter is ready
  61528. */
  61529. isReady(texture: BaseTexture): boolean;
  61530. /**
  61531. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61532. * Prefiltering will be invoked at the end of next rendering pass.
  61533. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61534. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61535. * @param texture Texture to filter
  61536. * @param onFinished Callback when filtering is done
  61537. * @return Promise called when prefiltering is done
  61538. */
  61539. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61540. }
  61541. }
  61542. declare module BABYLON {
  61543. /**
  61544. * This represents a texture coming from an HDR input.
  61545. *
  61546. * The only supported format is currently panorama picture stored in RGBE format.
  61547. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61548. */
  61549. export class HDRCubeTexture extends BaseTexture {
  61550. private static _facesMapping;
  61551. private _generateHarmonics;
  61552. private _noMipmap;
  61553. private _prefilterOnLoad;
  61554. private _textureMatrix;
  61555. private _size;
  61556. private _onLoad;
  61557. private _onError;
  61558. /**
  61559. * The texture URL.
  61560. */
  61561. url: string;
  61562. protected _isBlocking: boolean;
  61563. /**
  61564. * Sets wether or not the texture is blocking during loading.
  61565. */
  61566. set isBlocking(value: boolean);
  61567. /**
  61568. * Gets wether or not the texture is blocking during loading.
  61569. */
  61570. get isBlocking(): boolean;
  61571. protected _rotationY: number;
  61572. /**
  61573. * Sets texture matrix rotation angle around Y axis in radians.
  61574. */
  61575. set rotationY(value: number);
  61576. /**
  61577. * Gets texture matrix rotation angle around Y axis radians.
  61578. */
  61579. get rotationY(): number;
  61580. /**
  61581. * Gets or sets the center of the bounding box associated with the cube texture
  61582. * It must define where the camera used to render the texture was set
  61583. */
  61584. boundingBoxPosition: Vector3;
  61585. private _boundingBoxSize;
  61586. /**
  61587. * Gets or sets the size of the bounding box associated with the cube texture
  61588. * When defined, the cubemap will switch to local mode
  61589. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61590. * @example https://www.babylonjs-playground.com/#RNASML
  61591. */
  61592. set boundingBoxSize(value: Vector3);
  61593. get boundingBoxSize(): Vector3;
  61594. /**
  61595. * Instantiates an HDRTexture from the following parameters.
  61596. *
  61597. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61598. * @param sceneOrEngine The scene or engine the texture will be used in
  61599. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61600. * @param noMipmap Forces to not generate the mipmap if true
  61601. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61602. * @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)
  61603. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61604. */
  61605. 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>);
  61606. /**
  61607. * Get the current class name of the texture useful for serialization or dynamic coding.
  61608. * @returns "HDRCubeTexture"
  61609. */
  61610. getClassName(): string;
  61611. /**
  61612. * Occurs when the file is raw .hdr file.
  61613. */
  61614. private loadTexture;
  61615. clone(): HDRCubeTexture;
  61616. delayLoad(): void;
  61617. /**
  61618. * Get the texture reflection matrix used to rotate/transform the reflection.
  61619. * @returns the reflection matrix
  61620. */
  61621. getReflectionTextureMatrix(): Matrix;
  61622. /**
  61623. * Set the texture reflection matrix used to rotate/transform the reflection.
  61624. * @param value Define the reflection matrix to set
  61625. */
  61626. setReflectionTextureMatrix(value: Matrix): void;
  61627. /**
  61628. * Parses a JSON representation of an HDR Texture in order to create the texture
  61629. * @param parsedTexture Define the JSON representation
  61630. * @param scene Define the scene the texture should be created in
  61631. * @param rootUrl Define the root url in case we need to load relative dependencies
  61632. * @returns the newly created texture after parsing
  61633. */
  61634. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61635. serialize(): any;
  61636. }
  61637. }
  61638. declare module BABYLON {
  61639. /**
  61640. * Class used to control physics engine
  61641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61642. */
  61643. export class PhysicsEngine implements IPhysicsEngine {
  61644. private _physicsPlugin;
  61645. /**
  61646. * Global value used to control the smallest number supported by the simulation
  61647. */
  61648. static Epsilon: number;
  61649. private _impostors;
  61650. private _joints;
  61651. private _subTimeStep;
  61652. /**
  61653. * Gets the gravity vector used by the simulation
  61654. */
  61655. gravity: Vector3;
  61656. /**
  61657. * Factory used to create the default physics plugin.
  61658. * @returns The default physics plugin
  61659. */
  61660. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61661. /**
  61662. * Creates a new Physics Engine
  61663. * @param gravity defines the gravity vector used by the simulation
  61664. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61665. */
  61666. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61667. /**
  61668. * Sets the gravity vector used by the simulation
  61669. * @param gravity defines the gravity vector to use
  61670. */
  61671. setGravity(gravity: Vector3): void;
  61672. /**
  61673. * Set the time step of the physics engine.
  61674. * Default is 1/60.
  61675. * To slow it down, enter 1/600 for example.
  61676. * To speed it up, 1/30
  61677. * @param newTimeStep defines the new timestep to apply to this world.
  61678. */
  61679. setTimeStep(newTimeStep?: number): void;
  61680. /**
  61681. * Get the time step of the physics engine.
  61682. * @returns the current time step
  61683. */
  61684. getTimeStep(): number;
  61685. /**
  61686. * Set the sub time step of the physics engine.
  61687. * Default is 0 meaning there is no sub steps
  61688. * To increase physics resolution precision, set a small value (like 1 ms)
  61689. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61690. */
  61691. setSubTimeStep(subTimeStep?: number): void;
  61692. /**
  61693. * Get the sub time step of the physics engine.
  61694. * @returns the current sub time step
  61695. */
  61696. getSubTimeStep(): number;
  61697. /**
  61698. * Release all resources
  61699. */
  61700. dispose(): void;
  61701. /**
  61702. * Gets the name of the current physics plugin
  61703. * @returns the name of the plugin
  61704. */
  61705. getPhysicsPluginName(): string;
  61706. /**
  61707. * Adding a new impostor for the impostor tracking.
  61708. * This will be done by the impostor itself.
  61709. * @param impostor the impostor to add
  61710. */
  61711. addImpostor(impostor: PhysicsImpostor): void;
  61712. /**
  61713. * Remove an impostor from the engine.
  61714. * This impostor and its mesh will not longer be updated by the physics engine.
  61715. * @param impostor the impostor to remove
  61716. */
  61717. removeImpostor(impostor: PhysicsImpostor): void;
  61718. /**
  61719. * Add a joint to the physics engine
  61720. * @param mainImpostor defines the main impostor to which the joint is added.
  61721. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61722. * @param joint defines the joint that will connect both impostors.
  61723. */
  61724. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61725. /**
  61726. * Removes a joint from the simulation
  61727. * @param mainImpostor defines the impostor used with the joint
  61728. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61729. * @param joint defines the joint to remove
  61730. */
  61731. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61732. /**
  61733. * Called by the scene. No need to call it.
  61734. * @param delta defines the timespam between frames
  61735. */
  61736. _step(delta: number): void;
  61737. /**
  61738. * Gets the current plugin used to run the simulation
  61739. * @returns current plugin
  61740. */
  61741. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61742. /**
  61743. * Gets the list of physic impostors
  61744. * @returns an array of PhysicsImpostor
  61745. */
  61746. getImpostors(): Array<PhysicsImpostor>;
  61747. /**
  61748. * Gets the impostor for a physics enabled object
  61749. * @param object defines the object impersonated by the impostor
  61750. * @returns the PhysicsImpostor or null if not found
  61751. */
  61752. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61753. /**
  61754. * Gets the impostor for a physics body object
  61755. * @param body defines physics body used by the impostor
  61756. * @returns the PhysicsImpostor or null if not found
  61757. */
  61758. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61759. /**
  61760. * Does a raycast in the physics world
  61761. * @param from when should the ray start?
  61762. * @param to when should the ray end?
  61763. * @returns PhysicsRaycastResult
  61764. */
  61765. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61766. }
  61767. }
  61768. declare module BABYLON {
  61769. /** @hidden */
  61770. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61771. private _useDeltaForWorldStep;
  61772. world: any;
  61773. name: string;
  61774. private _physicsMaterials;
  61775. private _fixedTimeStep;
  61776. private _cannonRaycastResult;
  61777. private _raycastResult;
  61778. private _physicsBodysToRemoveAfterStep;
  61779. private _firstFrame;
  61780. BJSCANNON: any;
  61781. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61782. setGravity(gravity: Vector3): void;
  61783. setTimeStep(timeStep: number): void;
  61784. getTimeStep(): number;
  61785. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61786. private _removeMarkedPhysicsBodiesFromWorld;
  61787. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61788. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61789. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61790. private _processChildMeshes;
  61791. removePhysicsBody(impostor: PhysicsImpostor): void;
  61792. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61793. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61794. private _addMaterial;
  61795. private _checkWithEpsilon;
  61796. private _createShape;
  61797. private _createHeightmap;
  61798. private _minus90X;
  61799. private _plus90X;
  61800. private _tmpPosition;
  61801. private _tmpDeltaPosition;
  61802. private _tmpUnityRotation;
  61803. private _updatePhysicsBodyTransformation;
  61804. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61805. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61806. isSupported(): boolean;
  61807. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61808. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61809. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61810. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61811. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61812. getBodyMass(impostor: PhysicsImpostor): number;
  61813. getBodyFriction(impostor: PhysicsImpostor): number;
  61814. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61815. getBodyRestitution(impostor: PhysicsImpostor): number;
  61816. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61817. sleepBody(impostor: PhysicsImpostor): void;
  61818. wakeUpBody(impostor: PhysicsImpostor): void;
  61819. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61820. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61821. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61822. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61823. getRadius(impostor: PhysicsImpostor): number;
  61824. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61825. dispose(): void;
  61826. private _extendNamespace;
  61827. /**
  61828. * Does a raycast in the physics world
  61829. * @param from when should the ray start?
  61830. * @param to when should the ray end?
  61831. * @returns PhysicsRaycastResult
  61832. */
  61833. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61834. }
  61835. }
  61836. declare module BABYLON {
  61837. /** @hidden */
  61838. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61839. private _useDeltaForWorldStep;
  61840. world: any;
  61841. name: string;
  61842. BJSOIMO: any;
  61843. private _raycastResult;
  61844. private _fixedTimeStep;
  61845. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61846. setGravity(gravity: Vector3): void;
  61847. setTimeStep(timeStep: number): void;
  61848. getTimeStep(): number;
  61849. private _tmpImpostorsArray;
  61850. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61851. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61852. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61853. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61854. private _tmpPositionVector;
  61855. removePhysicsBody(impostor: PhysicsImpostor): void;
  61856. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61857. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61858. isSupported(): boolean;
  61859. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61860. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61861. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61862. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61863. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61864. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61865. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61866. getBodyMass(impostor: PhysicsImpostor): number;
  61867. getBodyFriction(impostor: PhysicsImpostor): number;
  61868. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61869. getBodyRestitution(impostor: PhysicsImpostor): number;
  61870. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61871. sleepBody(impostor: PhysicsImpostor): void;
  61872. wakeUpBody(impostor: PhysicsImpostor): void;
  61873. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61874. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61875. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61876. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61877. getRadius(impostor: PhysicsImpostor): number;
  61878. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61879. dispose(): void;
  61880. /**
  61881. * Does a raycast in the physics world
  61882. * @param from when should the ray start?
  61883. * @param to when should the ray end?
  61884. * @returns PhysicsRaycastResult
  61885. */
  61886. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61887. }
  61888. }
  61889. declare module BABYLON {
  61890. /**
  61891. * AmmoJS Physics plugin
  61892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61893. * @see https://github.com/kripken/ammo.js/
  61894. */
  61895. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61896. private _useDeltaForWorldStep;
  61897. /**
  61898. * Reference to the Ammo library
  61899. */
  61900. bjsAMMO: any;
  61901. /**
  61902. * Created ammoJS world which physics bodies are added to
  61903. */
  61904. world: any;
  61905. /**
  61906. * Name of the plugin
  61907. */
  61908. name: string;
  61909. private _timeStep;
  61910. private _fixedTimeStep;
  61911. private _maxSteps;
  61912. private _tmpQuaternion;
  61913. private _tmpAmmoTransform;
  61914. private _tmpAmmoQuaternion;
  61915. private _tmpAmmoConcreteContactResultCallback;
  61916. private _collisionConfiguration;
  61917. private _dispatcher;
  61918. private _overlappingPairCache;
  61919. private _solver;
  61920. private _softBodySolver;
  61921. private _tmpAmmoVectorA;
  61922. private _tmpAmmoVectorB;
  61923. private _tmpAmmoVectorC;
  61924. private _tmpAmmoVectorD;
  61925. private _tmpContactCallbackResult;
  61926. private _tmpAmmoVectorRCA;
  61927. private _tmpAmmoVectorRCB;
  61928. private _raycastResult;
  61929. private _tmpContactPoint;
  61930. private static readonly DISABLE_COLLISION_FLAG;
  61931. private static readonly KINEMATIC_FLAG;
  61932. private static readonly DISABLE_DEACTIVATION_FLAG;
  61933. /**
  61934. * Initializes the ammoJS plugin
  61935. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61936. * @param ammoInjection can be used to inject your own ammo reference
  61937. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61938. */
  61939. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61940. /**
  61941. * Sets the gravity of the physics world (m/(s^2))
  61942. * @param gravity Gravity to set
  61943. */
  61944. setGravity(gravity: Vector3): void;
  61945. /**
  61946. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61947. * @param timeStep timestep to use in seconds
  61948. */
  61949. setTimeStep(timeStep: number): void;
  61950. /**
  61951. * 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)
  61952. * @param fixedTimeStep fixedTimeStep to use in seconds
  61953. */
  61954. setFixedTimeStep(fixedTimeStep: number): void;
  61955. /**
  61956. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61957. * @param maxSteps the maximum number of steps by the physics engine per frame
  61958. */
  61959. setMaxSteps(maxSteps: number): void;
  61960. /**
  61961. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61962. * @returns the current timestep in seconds
  61963. */
  61964. getTimeStep(): number;
  61965. /**
  61966. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61967. */
  61968. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61969. private _isImpostorInContact;
  61970. private _isImpostorPairInContact;
  61971. private _stepSimulation;
  61972. /**
  61973. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61974. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61975. * After the step the babylon meshes are set to the position of the physics imposters
  61976. * @param delta amount of time to step forward
  61977. * @param impostors array of imposters to update before/after the step
  61978. */
  61979. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61980. /**
  61981. * Update babylon mesh to match physics world object
  61982. * @param impostor imposter to match
  61983. */
  61984. private _afterSoftStep;
  61985. /**
  61986. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61987. * @param impostor imposter to match
  61988. */
  61989. private _ropeStep;
  61990. /**
  61991. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61992. * @param impostor imposter to match
  61993. */
  61994. private _softbodyOrClothStep;
  61995. private _tmpMatrix;
  61996. /**
  61997. * Applies an impulse on the imposter
  61998. * @param impostor imposter to apply impulse to
  61999. * @param force amount of force to be applied to the imposter
  62000. * @param contactPoint the location to apply the impulse on the imposter
  62001. */
  62002. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62003. /**
  62004. * Applies a force on the imposter
  62005. * @param impostor imposter to apply force
  62006. * @param force amount of force to be applied to the imposter
  62007. * @param contactPoint the location to apply the force on the imposter
  62008. */
  62009. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62010. /**
  62011. * Creates a physics body using the plugin
  62012. * @param impostor the imposter to create the physics body on
  62013. */
  62014. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62015. /**
  62016. * Removes the physics body from the imposter and disposes of the body's memory
  62017. * @param impostor imposter to remove the physics body from
  62018. */
  62019. removePhysicsBody(impostor: PhysicsImpostor): void;
  62020. /**
  62021. * Generates a joint
  62022. * @param impostorJoint the imposter joint to create the joint with
  62023. */
  62024. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62025. /**
  62026. * Removes a joint
  62027. * @param impostorJoint the imposter joint to remove the joint from
  62028. */
  62029. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62030. private _addMeshVerts;
  62031. /**
  62032. * Initialise the soft body vertices to match its object's (mesh) vertices
  62033. * Softbody vertices (nodes) are in world space and to match this
  62034. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62035. * @param impostor to create the softbody for
  62036. */
  62037. private _softVertexData;
  62038. /**
  62039. * Create an impostor's soft body
  62040. * @param impostor to create the softbody for
  62041. */
  62042. private _createSoftbody;
  62043. /**
  62044. * Create cloth for an impostor
  62045. * @param impostor to create the softbody for
  62046. */
  62047. private _createCloth;
  62048. /**
  62049. * Create rope for an impostor
  62050. * @param impostor to create the softbody for
  62051. */
  62052. private _createRope;
  62053. /**
  62054. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62055. * @param impostor to create the custom physics shape for
  62056. */
  62057. private _createCustom;
  62058. private _addHullVerts;
  62059. private _createShape;
  62060. /**
  62061. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62062. * @param impostor imposter containing the physics body and babylon object
  62063. */
  62064. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62065. /**
  62066. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62067. * @param impostor imposter containing the physics body and babylon object
  62068. * @param newPosition new position
  62069. * @param newRotation new rotation
  62070. */
  62071. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62072. /**
  62073. * If this plugin is supported
  62074. * @returns true if its supported
  62075. */
  62076. isSupported(): boolean;
  62077. /**
  62078. * Sets the linear velocity of the physics body
  62079. * @param impostor imposter to set the velocity on
  62080. * @param velocity velocity to set
  62081. */
  62082. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62083. /**
  62084. * Sets the angular velocity of the physics body
  62085. * @param impostor imposter to set the velocity on
  62086. * @param velocity velocity to set
  62087. */
  62088. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62089. /**
  62090. * gets the linear velocity
  62091. * @param impostor imposter to get linear velocity from
  62092. * @returns linear velocity
  62093. */
  62094. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62095. /**
  62096. * gets the angular velocity
  62097. * @param impostor imposter to get angular velocity from
  62098. * @returns angular velocity
  62099. */
  62100. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62101. /**
  62102. * Sets the mass of physics body
  62103. * @param impostor imposter to set the mass on
  62104. * @param mass mass to set
  62105. */
  62106. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62107. /**
  62108. * Gets the mass of the physics body
  62109. * @param impostor imposter to get the mass from
  62110. * @returns mass
  62111. */
  62112. getBodyMass(impostor: PhysicsImpostor): number;
  62113. /**
  62114. * Gets friction of the impostor
  62115. * @param impostor impostor to get friction from
  62116. * @returns friction value
  62117. */
  62118. getBodyFriction(impostor: PhysicsImpostor): number;
  62119. /**
  62120. * Sets friction of the impostor
  62121. * @param impostor impostor to set friction on
  62122. * @param friction friction value
  62123. */
  62124. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62125. /**
  62126. * Gets restitution of the impostor
  62127. * @param impostor impostor to get restitution from
  62128. * @returns restitution value
  62129. */
  62130. getBodyRestitution(impostor: PhysicsImpostor): number;
  62131. /**
  62132. * Sets resitution of the impostor
  62133. * @param impostor impostor to set resitution on
  62134. * @param restitution resitution value
  62135. */
  62136. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62137. /**
  62138. * Gets pressure inside the impostor
  62139. * @param impostor impostor to get pressure from
  62140. * @returns pressure value
  62141. */
  62142. getBodyPressure(impostor: PhysicsImpostor): number;
  62143. /**
  62144. * Sets pressure inside a soft body impostor
  62145. * Cloth and rope must remain 0 pressure
  62146. * @param impostor impostor to set pressure on
  62147. * @param pressure pressure value
  62148. */
  62149. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62150. /**
  62151. * Gets stiffness of the impostor
  62152. * @param impostor impostor to get stiffness from
  62153. * @returns pressure value
  62154. */
  62155. getBodyStiffness(impostor: PhysicsImpostor): number;
  62156. /**
  62157. * Sets stiffness of the impostor
  62158. * @param impostor impostor to set stiffness on
  62159. * @param stiffness stiffness value from 0 to 1
  62160. */
  62161. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62162. /**
  62163. * Gets velocityIterations of the impostor
  62164. * @param impostor impostor to get velocity iterations from
  62165. * @returns velocityIterations value
  62166. */
  62167. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62168. /**
  62169. * Sets velocityIterations of the impostor
  62170. * @param impostor impostor to set velocity iterations on
  62171. * @param velocityIterations velocityIterations value
  62172. */
  62173. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62174. /**
  62175. * Gets positionIterations of the impostor
  62176. * @param impostor impostor to get position iterations from
  62177. * @returns positionIterations value
  62178. */
  62179. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62180. /**
  62181. * Sets positionIterations of the impostor
  62182. * @param impostor impostor to set position on
  62183. * @param positionIterations positionIterations value
  62184. */
  62185. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62186. /**
  62187. * Append an anchor to a cloth object
  62188. * @param impostor is the cloth impostor to add anchor to
  62189. * @param otherImpostor is the rigid impostor to anchor to
  62190. * @param width ratio across width from 0 to 1
  62191. * @param height ratio up height from 0 to 1
  62192. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62193. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62194. */
  62195. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62196. /**
  62197. * Append an hook to a rope object
  62198. * @param impostor is the rope impostor to add hook to
  62199. * @param otherImpostor is the rigid impostor to hook to
  62200. * @param length ratio along the rope from 0 to 1
  62201. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62202. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62203. */
  62204. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62205. /**
  62206. * Sleeps the physics body and stops it from being active
  62207. * @param impostor impostor to sleep
  62208. */
  62209. sleepBody(impostor: PhysicsImpostor): void;
  62210. /**
  62211. * Activates the physics body
  62212. * @param impostor impostor to activate
  62213. */
  62214. wakeUpBody(impostor: PhysicsImpostor): void;
  62215. /**
  62216. * Updates the distance parameters of the joint
  62217. * @param joint joint to update
  62218. * @param maxDistance maximum distance of the joint
  62219. * @param minDistance minimum distance of the joint
  62220. */
  62221. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62222. /**
  62223. * Sets a motor on the joint
  62224. * @param joint joint to set motor on
  62225. * @param speed speed of the motor
  62226. * @param maxForce maximum force of the motor
  62227. * @param motorIndex index of the motor
  62228. */
  62229. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62230. /**
  62231. * Sets the motors limit
  62232. * @param joint joint to set limit on
  62233. * @param upperLimit upper limit
  62234. * @param lowerLimit lower limit
  62235. */
  62236. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62237. /**
  62238. * Syncs the position and rotation of a mesh with the impostor
  62239. * @param mesh mesh to sync
  62240. * @param impostor impostor to update the mesh with
  62241. */
  62242. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62243. /**
  62244. * Gets the radius of the impostor
  62245. * @param impostor impostor to get radius from
  62246. * @returns the radius
  62247. */
  62248. getRadius(impostor: PhysicsImpostor): number;
  62249. /**
  62250. * Gets the box size of the impostor
  62251. * @param impostor impostor to get box size from
  62252. * @param result the resulting box size
  62253. */
  62254. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62255. /**
  62256. * Disposes of the impostor
  62257. */
  62258. dispose(): void;
  62259. /**
  62260. * Does a raycast in the physics world
  62261. * @param from when should the ray start?
  62262. * @param to when should the ray end?
  62263. * @returns PhysicsRaycastResult
  62264. */
  62265. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62266. }
  62267. }
  62268. declare module BABYLON {
  62269. interface AbstractScene {
  62270. /**
  62271. * The list of reflection probes added to the scene
  62272. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62273. */
  62274. reflectionProbes: Array<ReflectionProbe>;
  62275. /**
  62276. * Removes the given reflection probe from this scene.
  62277. * @param toRemove The reflection probe to remove
  62278. * @returns The index of the removed reflection probe
  62279. */
  62280. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62281. /**
  62282. * Adds the given reflection probe to this scene.
  62283. * @param newReflectionProbe The reflection probe to add
  62284. */
  62285. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62286. }
  62287. /**
  62288. * Class used to generate realtime reflection / refraction cube textures
  62289. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62290. */
  62291. export class ReflectionProbe {
  62292. /** defines the name of the probe */
  62293. name: string;
  62294. private _scene;
  62295. private _renderTargetTexture;
  62296. private _projectionMatrix;
  62297. private _viewMatrix;
  62298. private _target;
  62299. private _add;
  62300. private _attachedMesh;
  62301. private _invertYAxis;
  62302. /** Gets or sets probe position (center of the cube map) */
  62303. position: Vector3;
  62304. /**
  62305. * Creates a new reflection probe
  62306. * @param name defines the name of the probe
  62307. * @param size defines the texture resolution (for each face)
  62308. * @param scene defines the hosting scene
  62309. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62310. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62311. */
  62312. constructor(
  62313. /** defines the name of the probe */
  62314. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62315. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62316. get samples(): number;
  62317. set samples(value: number);
  62318. /** Gets or sets the refresh rate to use (on every frame by default) */
  62319. get refreshRate(): number;
  62320. set refreshRate(value: number);
  62321. /**
  62322. * Gets the hosting scene
  62323. * @returns a Scene
  62324. */
  62325. getScene(): Scene;
  62326. /** Gets the internal CubeTexture used to render to */
  62327. get cubeTexture(): RenderTargetTexture;
  62328. /** Gets the list of meshes to render */
  62329. get renderList(): Nullable<AbstractMesh[]>;
  62330. /**
  62331. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62332. * @param mesh defines the mesh to attach to
  62333. */
  62334. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62335. /**
  62336. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62337. * @param renderingGroupId The rendering group id corresponding to its index
  62338. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62339. */
  62340. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62341. /**
  62342. * Clean all associated resources
  62343. */
  62344. dispose(): void;
  62345. /**
  62346. * Converts the reflection probe information to a readable string for debug purpose.
  62347. * @param fullDetails Supports for multiple levels of logging within scene loading
  62348. * @returns the human readable reflection probe info
  62349. */
  62350. toString(fullDetails?: boolean): string;
  62351. /**
  62352. * Get the class name of the relfection probe.
  62353. * @returns "ReflectionProbe"
  62354. */
  62355. getClassName(): string;
  62356. /**
  62357. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62358. * @returns The JSON representation of the texture
  62359. */
  62360. serialize(): any;
  62361. /**
  62362. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62363. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62364. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62365. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62366. * @returns The parsed reflection probe if successful
  62367. */
  62368. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62369. }
  62370. }
  62371. declare module BABYLON {
  62372. /** @hidden */
  62373. export var _BabylonLoaderRegistered: boolean;
  62374. /**
  62375. * Helps setting up some configuration for the babylon file loader.
  62376. */
  62377. export class BabylonFileLoaderConfiguration {
  62378. /**
  62379. * The loader does not allow injecting custom physix engine into the plugins.
  62380. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62381. * So you could set this variable to your engine import to make it work.
  62382. */
  62383. static LoaderInjectedPhysicsEngine: any;
  62384. }
  62385. }
  62386. declare module BABYLON {
  62387. /**
  62388. * The Physically based simple base material of BJS.
  62389. *
  62390. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62391. * It is used as the base class for both the specGloss and metalRough conventions.
  62392. */
  62393. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62394. /**
  62395. * Number of Simultaneous lights allowed on the material.
  62396. */
  62397. maxSimultaneousLights: number;
  62398. /**
  62399. * If sets to true, disables all the lights affecting the material.
  62400. */
  62401. disableLighting: boolean;
  62402. /**
  62403. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62404. */
  62405. environmentTexture: BaseTexture;
  62406. /**
  62407. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62408. */
  62409. invertNormalMapX: boolean;
  62410. /**
  62411. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62412. */
  62413. invertNormalMapY: boolean;
  62414. /**
  62415. * Normal map used in the model.
  62416. */
  62417. normalTexture: BaseTexture;
  62418. /**
  62419. * Emissivie color used to self-illuminate the model.
  62420. */
  62421. emissiveColor: Color3;
  62422. /**
  62423. * Emissivie texture used to self-illuminate the model.
  62424. */
  62425. emissiveTexture: BaseTexture;
  62426. /**
  62427. * Occlusion Channel Strenght.
  62428. */
  62429. occlusionStrength: number;
  62430. /**
  62431. * Occlusion Texture of the material (adding extra occlusion effects).
  62432. */
  62433. occlusionTexture: BaseTexture;
  62434. /**
  62435. * Defines the alpha limits in alpha test mode.
  62436. */
  62437. alphaCutOff: number;
  62438. /**
  62439. * Gets the current double sided mode.
  62440. */
  62441. get doubleSided(): boolean;
  62442. /**
  62443. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62444. */
  62445. set doubleSided(value: boolean);
  62446. /**
  62447. * Stores the pre-calculated light information of a mesh in a texture.
  62448. */
  62449. lightmapTexture: BaseTexture;
  62450. /**
  62451. * If true, the light map contains occlusion information instead of lighting info.
  62452. */
  62453. useLightmapAsShadowmap: boolean;
  62454. /**
  62455. * Instantiates a new PBRMaterial instance.
  62456. *
  62457. * @param name The material name
  62458. * @param scene The scene the material will be use in.
  62459. */
  62460. constructor(name: string, scene: Scene);
  62461. getClassName(): string;
  62462. }
  62463. }
  62464. declare module BABYLON {
  62465. /**
  62466. * The PBR material of BJS following the metal roughness convention.
  62467. *
  62468. * This fits to the PBR convention in the GLTF definition:
  62469. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62470. */
  62471. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62472. /**
  62473. * The base color has two different interpretations depending on the value of metalness.
  62474. * When the material is a metal, the base color is the specific measured reflectance value
  62475. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62476. * of the material.
  62477. */
  62478. baseColor: Color3;
  62479. /**
  62480. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62481. * well as opacity information in the alpha channel.
  62482. */
  62483. baseTexture: BaseTexture;
  62484. /**
  62485. * Specifies the metallic scalar value of the material.
  62486. * Can also be used to scale the metalness values of the metallic texture.
  62487. */
  62488. metallic: number;
  62489. /**
  62490. * Specifies the roughness scalar value of the material.
  62491. * Can also be used to scale the roughness values of the metallic texture.
  62492. */
  62493. roughness: number;
  62494. /**
  62495. * Texture containing both the metallic value in the B channel and the
  62496. * roughness value in the G channel to keep better precision.
  62497. */
  62498. metallicRoughnessTexture: BaseTexture;
  62499. /**
  62500. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62501. *
  62502. * @param name The material name
  62503. * @param scene The scene the material will be use in.
  62504. */
  62505. constructor(name: string, scene: Scene);
  62506. /**
  62507. * Return the currrent class name of the material.
  62508. */
  62509. getClassName(): string;
  62510. /**
  62511. * Makes a duplicate of the current material.
  62512. * @param name - name to use for the new material.
  62513. */
  62514. clone(name: string): PBRMetallicRoughnessMaterial;
  62515. /**
  62516. * Serialize the material to a parsable JSON object.
  62517. */
  62518. serialize(): any;
  62519. /**
  62520. * Parses a JSON object correponding to the serialize function.
  62521. */
  62522. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62523. }
  62524. }
  62525. declare module BABYLON {
  62526. /**
  62527. * The PBR material of BJS following the specular glossiness convention.
  62528. *
  62529. * This fits to the PBR convention in the GLTF definition:
  62530. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62531. */
  62532. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62533. /**
  62534. * Specifies the diffuse color of the material.
  62535. */
  62536. diffuseColor: Color3;
  62537. /**
  62538. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62539. * channel.
  62540. */
  62541. diffuseTexture: BaseTexture;
  62542. /**
  62543. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62544. */
  62545. specularColor: Color3;
  62546. /**
  62547. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62548. */
  62549. glossiness: number;
  62550. /**
  62551. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62552. */
  62553. specularGlossinessTexture: BaseTexture;
  62554. /**
  62555. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62556. *
  62557. * @param name The material name
  62558. * @param scene The scene the material will be use in.
  62559. */
  62560. constructor(name: string, scene: Scene);
  62561. /**
  62562. * Return the currrent class name of the material.
  62563. */
  62564. getClassName(): string;
  62565. /**
  62566. * Makes a duplicate of the current material.
  62567. * @param name - name to use for the new material.
  62568. */
  62569. clone(name: string): PBRSpecularGlossinessMaterial;
  62570. /**
  62571. * Serialize the material to a parsable JSON object.
  62572. */
  62573. serialize(): any;
  62574. /**
  62575. * Parses a JSON object correponding to the serialize function.
  62576. */
  62577. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62578. }
  62579. }
  62580. declare module BABYLON {
  62581. /**
  62582. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62583. * It can help converting any input color in a desired output one. This can then be used to create effects
  62584. * from sepia, black and white to sixties or futuristic rendering...
  62585. *
  62586. * The only supported format is currently 3dl.
  62587. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62588. */
  62589. export class ColorGradingTexture extends BaseTexture {
  62590. /**
  62591. * The texture URL.
  62592. */
  62593. url: string;
  62594. /**
  62595. * Empty line regex stored for GC.
  62596. */
  62597. private static _noneEmptyLineRegex;
  62598. private _textureMatrix;
  62599. private _onLoad;
  62600. /**
  62601. * Instantiates a ColorGradingTexture from the following parameters.
  62602. *
  62603. * @param url The location of the color gradind data (currently only supporting 3dl)
  62604. * @param sceneOrEngine The scene or engine the texture will be used in
  62605. * @param onLoad defines a callback triggered when the texture has been loaded
  62606. */
  62607. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62608. /**
  62609. * Fires the onload event from the constructor if requested.
  62610. */
  62611. private _triggerOnLoad;
  62612. /**
  62613. * Returns the texture matrix used in most of the material.
  62614. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62615. */
  62616. getTextureMatrix(): Matrix;
  62617. /**
  62618. * Occurs when the file being loaded is a .3dl LUT file.
  62619. */
  62620. private load3dlTexture;
  62621. /**
  62622. * Starts the loading process of the texture.
  62623. */
  62624. private loadTexture;
  62625. /**
  62626. * Clones the color gradind texture.
  62627. */
  62628. clone(): ColorGradingTexture;
  62629. /**
  62630. * Called during delayed load for textures.
  62631. */
  62632. delayLoad(): void;
  62633. /**
  62634. * Parses a color grading texture serialized by Babylon.
  62635. * @param parsedTexture The texture information being parsedTexture
  62636. * @param scene The scene to load the texture in
  62637. * @param rootUrl The root url of the data assets to load
  62638. * @return A color gradind texture
  62639. */
  62640. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62641. /**
  62642. * Serializes the LUT texture to json format.
  62643. */
  62644. serialize(): any;
  62645. }
  62646. }
  62647. declare module BABYLON {
  62648. /**
  62649. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62650. */
  62651. export class EquiRectangularCubeTexture extends BaseTexture {
  62652. /** The six faces of the cube. */
  62653. private static _FacesMapping;
  62654. private _noMipmap;
  62655. private _onLoad;
  62656. private _onError;
  62657. /** The size of the cubemap. */
  62658. private _size;
  62659. /** The buffer of the image. */
  62660. private _buffer;
  62661. /** The width of the input image. */
  62662. private _width;
  62663. /** The height of the input image. */
  62664. private _height;
  62665. /** The URL to the image. */
  62666. url: string;
  62667. /**
  62668. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62669. * @param url The location of the image
  62670. * @param scene The scene the texture will be used in
  62671. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62672. * @param noMipmap Forces to not generate the mipmap if true
  62673. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62674. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62675. * @param onLoad — defines a callback called when texture is loaded
  62676. * @param onError — defines a callback called if there is an error
  62677. */
  62678. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62679. /**
  62680. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62681. */
  62682. private loadImage;
  62683. /**
  62684. * Convert the image buffer into a cubemap and create a CubeTexture.
  62685. */
  62686. private loadTexture;
  62687. /**
  62688. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62689. * @param buffer The ArrayBuffer that should be converted.
  62690. * @returns The buffer as Float32Array.
  62691. */
  62692. private getFloat32ArrayFromArrayBuffer;
  62693. /**
  62694. * Get the current class name of the texture useful for serialization or dynamic coding.
  62695. * @returns "EquiRectangularCubeTexture"
  62696. */
  62697. getClassName(): string;
  62698. /**
  62699. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62700. * @returns A clone of the current EquiRectangularCubeTexture.
  62701. */
  62702. clone(): EquiRectangularCubeTexture;
  62703. }
  62704. }
  62705. declare module BABYLON {
  62706. /**
  62707. * Defines the options related to the creation of an HtmlElementTexture
  62708. */
  62709. export interface IHtmlElementTextureOptions {
  62710. /**
  62711. * Defines wether mip maps should be created or not.
  62712. */
  62713. generateMipMaps?: boolean;
  62714. /**
  62715. * Defines the sampling mode of the texture.
  62716. */
  62717. samplingMode?: number;
  62718. /**
  62719. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62720. */
  62721. engine: Nullable<ThinEngine>;
  62722. /**
  62723. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62724. */
  62725. scene: Nullable<Scene>;
  62726. }
  62727. /**
  62728. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62729. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62730. * is automatically managed.
  62731. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62732. * in your application.
  62733. *
  62734. * As the update is not automatic, you need to call them manually.
  62735. */
  62736. export class HtmlElementTexture extends BaseTexture {
  62737. /**
  62738. * The texture URL.
  62739. */
  62740. element: HTMLVideoElement | HTMLCanvasElement;
  62741. private static readonly DefaultOptions;
  62742. private _textureMatrix;
  62743. private _isVideo;
  62744. private _generateMipMaps;
  62745. private _samplingMode;
  62746. /**
  62747. * Instantiates a HtmlElementTexture from the following parameters.
  62748. *
  62749. * @param name Defines the name of the texture
  62750. * @param element Defines the video or canvas the texture is filled with
  62751. * @param options Defines the other none mandatory texture creation options
  62752. */
  62753. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62754. private _createInternalTexture;
  62755. /**
  62756. * Returns the texture matrix used in most of the material.
  62757. */
  62758. getTextureMatrix(): Matrix;
  62759. /**
  62760. * Updates the content of the texture.
  62761. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62762. */
  62763. update(invertY?: Nullable<boolean>): void;
  62764. }
  62765. }
  62766. declare module BABYLON {
  62767. /**
  62768. * Based on jsTGALoader - Javascript loader for TGA file
  62769. * By Vincent Thibault
  62770. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62771. */
  62772. export class TGATools {
  62773. private static _TYPE_INDEXED;
  62774. private static _TYPE_RGB;
  62775. private static _TYPE_GREY;
  62776. private static _TYPE_RLE_INDEXED;
  62777. private static _TYPE_RLE_RGB;
  62778. private static _TYPE_RLE_GREY;
  62779. private static _ORIGIN_MASK;
  62780. private static _ORIGIN_SHIFT;
  62781. private static _ORIGIN_BL;
  62782. private static _ORIGIN_BR;
  62783. private static _ORIGIN_UL;
  62784. private static _ORIGIN_UR;
  62785. /**
  62786. * Gets the header of a TGA file
  62787. * @param data defines the TGA data
  62788. * @returns the header
  62789. */
  62790. static GetTGAHeader(data: Uint8Array): any;
  62791. /**
  62792. * Uploads TGA content to a Babylon Texture
  62793. * @hidden
  62794. */
  62795. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62796. /** @hidden */
  62797. 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;
  62798. /** @hidden */
  62799. 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;
  62800. /** @hidden */
  62801. 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;
  62802. /** @hidden */
  62803. 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;
  62804. /** @hidden */
  62805. 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;
  62806. /** @hidden */
  62807. 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;
  62808. }
  62809. }
  62810. declare module BABYLON {
  62811. /**
  62812. * Implementation of the TGA Texture Loader.
  62813. * @hidden
  62814. */
  62815. export class _TGATextureLoader implements IInternalTextureLoader {
  62816. /**
  62817. * Defines wether the loader supports cascade loading the different faces.
  62818. */
  62819. readonly supportCascades: boolean;
  62820. /**
  62821. * This returns if the loader support the current file information.
  62822. * @param extension defines the file extension of the file being loaded
  62823. * @returns true if the loader can load the specified file
  62824. */
  62825. canLoad(extension: string): boolean;
  62826. /**
  62827. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62828. * @param data contains the texture data
  62829. * @param texture defines the BabylonJS internal texture
  62830. * @param createPolynomials will be true if polynomials have been requested
  62831. * @param onLoad defines the callback to trigger once the texture is ready
  62832. * @param onError defines the callback to trigger in case of error
  62833. */
  62834. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62835. /**
  62836. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62837. * @param data contains the texture data
  62838. * @param texture defines the BabylonJS internal texture
  62839. * @param callback defines the method to call once ready to upload
  62840. */
  62841. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62842. }
  62843. }
  62844. declare module BABYLON {
  62845. /**
  62846. * Info about the .basis files
  62847. */
  62848. class BasisFileInfo {
  62849. /**
  62850. * If the file has alpha
  62851. */
  62852. hasAlpha: boolean;
  62853. /**
  62854. * Info about each image of the basis file
  62855. */
  62856. images: Array<{
  62857. levels: Array<{
  62858. width: number;
  62859. height: number;
  62860. transcodedPixels: ArrayBufferView;
  62861. }>;
  62862. }>;
  62863. }
  62864. /**
  62865. * Result of transcoding a basis file
  62866. */
  62867. class TranscodeResult {
  62868. /**
  62869. * Info about the .basis file
  62870. */
  62871. fileInfo: BasisFileInfo;
  62872. /**
  62873. * Format to use when loading the file
  62874. */
  62875. format: number;
  62876. }
  62877. /**
  62878. * Configuration options for the Basis transcoder
  62879. */
  62880. export class BasisTranscodeConfiguration {
  62881. /**
  62882. * Supported compression formats used to determine the supported output format of the transcoder
  62883. */
  62884. supportedCompressionFormats?: {
  62885. /**
  62886. * etc1 compression format
  62887. */
  62888. etc1?: boolean;
  62889. /**
  62890. * s3tc compression format
  62891. */
  62892. s3tc?: boolean;
  62893. /**
  62894. * pvrtc compression format
  62895. */
  62896. pvrtc?: boolean;
  62897. /**
  62898. * etc2 compression format
  62899. */
  62900. etc2?: boolean;
  62901. };
  62902. /**
  62903. * If mipmap levels should be loaded for transcoded images (Default: true)
  62904. */
  62905. loadMipmapLevels?: boolean;
  62906. /**
  62907. * Index of a single image to load (Default: all images)
  62908. */
  62909. loadSingleImage?: number;
  62910. }
  62911. /**
  62912. * Used to load .Basis files
  62913. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62914. */
  62915. export class BasisTools {
  62916. private static _IgnoreSupportedFormats;
  62917. /**
  62918. * URL to use when loading the basis transcoder
  62919. */
  62920. static JSModuleURL: string;
  62921. /**
  62922. * URL to use when loading the wasm module for the transcoder
  62923. */
  62924. static WasmModuleURL: string;
  62925. /**
  62926. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62927. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62928. * @returns internal format corresponding to the Basis format
  62929. */
  62930. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62931. private static _WorkerPromise;
  62932. private static _Worker;
  62933. private static _actionId;
  62934. private static _CreateWorkerAsync;
  62935. /**
  62936. * Transcodes a loaded image file to compressed pixel data
  62937. * @param data image data to transcode
  62938. * @param config configuration options for the transcoding
  62939. * @returns a promise resulting in the transcoded image
  62940. */
  62941. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62942. /**
  62943. * Loads a texture from the transcode result
  62944. * @param texture texture load to
  62945. * @param transcodeResult the result of transcoding the basis file to load from
  62946. */
  62947. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62948. }
  62949. }
  62950. declare module BABYLON {
  62951. /**
  62952. * Loader for .basis file format
  62953. */
  62954. export class _BasisTextureLoader implements IInternalTextureLoader {
  62955. /**
  62956. * Defines whether the loader supports cascade loading the different faces.
  62957. */
  62958. readonly supportCascades: boolean;
  62959. /**
  62960. * This returns if the loader support the current file information.
  62961. * @param extension defines the file extension of the file being loaded
  62962. * @returns true if the loader can load the specified file
  62963. */
  62964. canLoad(extension: string): boolean;
  62965. /**
  62966. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62967. * @param data contains the texture data
  62968. * @param texture defines the BabylonJS internal texture
  62969. * @param createPolynomials will be true if polynomials have been requested
  62970. * @param onLoad defines the callback to trigger once the texture is ready
  62971. * @param onError defines the callback to trigger in case of error
  62972. */
  62973. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62974. /**
  62975. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62976. * @param data contains the texture data
  62977. * @param texture defines the BabylonJS internal texture
  62978. * @param callback defines the method to call once ready to upload
  62979. */
  62980. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62981. }
  62982. }
  62983. declare module BABYLON {
  62984. /**
  62985. * Defines the basic options interface of a TexturePacker Frame
  62986. */
  62987. export interface ITexturePackerFrame {
  62988. /**
  62989. * The frame ID
  62990. */
  62991. id: number;
  62992. /**
  62993. * The frames Scale
  62994. */
  62995. scale: Vector2;
  62996. /**
  62997. * The Frames offset
  62998. */
  62999. offset: Vector2;
  63000. }
  63001. /**
  63002. * This is a support class for frame Data on texture packer sets.
  63003. */
  63004. export class TexturePackerFrame implements ITexturePackerFrame {
  63005. /**
  63006. * The frame ID
  63007. */
  63008. id: number;
  63009. /**
  63010. * The frames Scale
  63011. */
  63012. scale: Vector2;
  63013. /**
  63014. * The Frames offset
  63015. */
  63016. offset: Vector2;
  63017. /**
  63018. * Initializes a texture package frame.
  63019. * @param id The numerical frame identifier
  63020. * @param scale Scalar Vector2 for UV frame
  63021. * @param offset Vector2 for the frame position in UV units.
  63022. * @returns TexturePackerFrame
  63023. */
  63024. constructor(id: number, scale: Vector2, offset: Vector2);
  63025. }
  63026. }
  63027. declare module BABYLON {
  63028. /**
  63029. * Defines the basic options interface of a TexturePacker
  63030. */
  63031. export interface ITexturePackerOptions {
  63032. /**
  63033. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63034. */
  63035. map?: string[];
  63036. /**
  63037. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63038. */
  63039. uvsIn?: string;
  63040. /**
  63041. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63042. */
  63043. uvsOut?: string;
  63044. /**
  63045. * number representing the layout style. Defaults to LAYOUT_STRIP
  63046. */
  63047. layout?: number;
  63048. /**
  63049. * number of columns if using custom column count layout(2). This defaults to 4.
  63050. */
  63051. colnum?: number;
  63052. /**
  63053. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63054. */
  63055. updateInputMeshes?: boolean;
  63056. /**
  63057. * boolean flag to dispose all the source textures. Defaults to true.
  63058. */
  63059. disposeSources?: boolean;
  63060. /**
  63061. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63062. */
  63063. fillBlanks?: boolean;
  63064. /**
  63065. * string value representing the context fill style color. Defaults to 'black'.
  63066. */
  63067. customFillColor?: string;
  63068. /**
  63069. * Width and Height Value of each Frame in the TexturePacker Sets
  63070. */
  63071. frameSize?: number;
  63072. /**
  63073. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63074. */
  63075. paddingRatio?: number;
  63076. /**
  63077. * Number that declares the fill method for the padding gutter.
  63078. */
  63079. paddingMode?: number;
  63080. /**
  63081. * If in SUBUV_COLOR padding mode what color to use.
  63082. */
  63083. paddingColor?: Color3 | Color4;
  63084. }
  63085. /**
  63086. * Defines the basic interface of a TexturePacker JSON File
  63087. */
  63088. export interface ITexturePackerJSON {
  63089. /**
  63090. * The frame ID
  63091. */
  63092. name: string;
  63093. /**
  63094. * The base64 channel data
  63095. */
  63096. sets: any;
  63097. /**
  63098. * The options of the Packer
  63099. */
  63100. options: ITexturePackerOptions;
  63101. /**
  63102. * The frame data of the Packer
  63103. */
  63104. frames: Array<number>;
  63105. }
  63106. /**
  63107. * This is a support class that generates a series of packed texture sets.
  63108. * @see https://doc.babylonjs.com/babylon101/materials
  63109. */
  63110. export class TexturePacker {
  63111. /** Packer Layout Constant 0 */
  63112. static readonly LAYOUT_STRIP: number;
  63113. /** Packer Layout Constant 1 */
  63114. static readonly LAYOUT_POWER2: number;
  63115. /** Packer Layout Constant 2 */
  63116. static readonly LAYOUT_COLNUM: number;
  63117. /** Packer Layout Constant 0 */
  63118. static readonly SUBUV_WRAP: number;
  63119. /** Packer Layout Constant 1 */
  63120. static readonly SUBUV_EXTEND: number;
  63121. /** Packer Layout Constant 2 */
  63122. static readonly SUBUV_COLOR: number;
  63123. /** The Name of the Texture Package */
  63124. name: string;
  63125. /** The scene scope of the TexturePacker */
  63126. scene: Scene;
  63127. /** The Meshes to target */
  63128. meshes: AbstractMesh[];
  63129. /** Arguments passed with the Constructor */
  63130. options: ITexturePackerOptions;
  63131. /** The promise that is started upon initialization */
  63132. promise: Nullable<Promise<TexturePacker | string>>;
  63133. /** The Container object for the channel sets that are generated */
  63134. sets: object;
  63135. /** The Container array for the frames that are generated */
  63136. frames: TexturePackerFrame[];
  63137. /** The expected number of textures the system is parsing. */
  63138. private _expecting;
  63139. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63140. private _paddingValue;
  63141. /**
  63142. * Initializes a texture package series from an array of meshes or a single mesh.
  63143. * @param name The name of the package
  63144. * @param meshes The target meshes to compose the package from
  63145. * @param options The arguments that texture packer should follow while building.
  63146. * @param scene The scene which the textures are scoped to.
  63147. * @returns TexturePacker
  63148. */
  63149. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63150. /**
  63151. * Starts the package process
  63152. * @param resolve The promises resolution function
  63153. * @returns TexturePacker
  63154. */
  63155. private _createFrames;
  63156. /**
  63157. * Calculates the Size of the Channel Sets
  63158. * @returns Vector2
  63159. */
  63160. private _calculateSize;
  63161. /**
  63162. * Calculates the UV data for the frames.
  63163. * @param baseSize the base frameSize
  63164. * @param padding the base frame padding
  63165. * @param dtSize size of the Dynamic Texture for that channel
  63166. * @param dtUnits is 1/dtSize
  63167. * @param update flag to update the input meshes
  63168. */
  63169. private _calculateMeshUVFrames;
  63170. /**
  63171. * Calculates the frames Offset.
  63172. * @param index of the frame
  63173. * @returns Vector2
  63174. */
  63175. private _getFrameOffset;
  63176. /**
  63177. * Updates a Mesh to the frame data
  63178. * @param mesh that is the target
  63179. * @param frameID or the frame index
  63180. */
  63181. private _updateMeshUV;
  63182. /**
  63183. * Updates a Meshes materials to use the texture packer channels
  63184. * @param m is the mesh to target
  63185. * @param force all channels on the packer to be set.
  63186. */
  63187. private _updateTextureReferences;
  63188. /**
  63189. * Public method to set a Mesh to a frame
  63190. * @param m that is the target
  63191. * @param frameID or the frame index
  63192. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63193. */
  63194. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63195. /**
  63196. * Starts the async promise to compile the texture packer.
  63197. * @returns Promise<void>
  63198. */
  63199. processAsync(): Promise<void>;
  63200. /**
  63201. * Disposes all textures associated with this packer
  63202. */
  63203. dispose(): void;
  63204. /**
  63205. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63206. * @param imageType is the image type to use.
  63207. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63208. */
  63209. download(imageType?: string, quality?: number): void;
  63210. /**
  63211. * Public method to load a texturePacker JSON file.
  63212. * @param data of the JSON file in string format.
  63213. */
  63214. updateFromJSON(data: string): void;
  63215. }
  63216. }
  63217. declare module BABYLON {
  63218. /**
  63219. * 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.
  63220. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63221. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63222. */
  63223. export class CustomProceduralTexture extends ProceduralTexture {
  63224. private _animate;
  63225. private _time;
  63226. private _config;
  63227. private _texturePath;
  63228. /**
  63229. * Instantiates a new Custom Procedural Texture.
  63230. * 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.
  63231. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63232. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63233. * @param name Define the name of the texture
  63234. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63235. * @param size Define the size of the texture to create
  63236. * @param scene Define the scene the texture belongs to
  63237. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63238. * @param generateMipMaps Define if the texture should creates mip maps or not
  63239. */
  63240. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63241. private _loadJson;
  63242. /**
  63243. * Is the texture ready to be used ? (rendered at least once)
  63244. * @returns true if ready, otherwise, false.
  63245. */
  63246. isReady(): boolean;
  63247. /**
  63248. * Render the texture to its associated render target.
  63249. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63250. */
  63251. render(useCameraPostProcess?: boolean): void;
  63252. /**
  63253. * Update the list of dependant textures samplers in the shader.
  63254. */
  63255. updateTextures(): void;
  63256. /**
  63257. * Update the uniform values of the procedural texture in the shader.
  63258. */
  63259. updateShaderUniforms(): void;
  63260. /**
  63261. * Define if the texture animates or not.
  63262. */
  63263. get animate(): boolean;
  63264. set animate(value: boolean);
  63265. }
  63266. }
  63267. declare module BABYLON {
  63268. /** @hidden */
  63269. export var noisePixelShader: {
  63270. name: string;
  63271. shader: string;
  63272. };
  63273. }
  63274. declare module BABYLON {
  63275. /**
  63276. * Class used to generate noise procedural textures
  63277. */
  63278. export class NoiseProceduralTexture extends ProceduralTexture {
  63279. /** Gets or sets the start time (default is 0) */
  63280. time: number;
  63281. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63282. brightness: number;
  63283. /** Defines the number of octaves to process */
  63284. octaves: number;
  63285. /** Defines the level of persistence (0.8 by default) */
  63286. persistence: number;
  63287. /** Gets or sets animation speed factor (default is 1) */
  63288. animationSpeedFactor: number;
  63289. /**
  63290. * Creates a new NoiseProceduralTexture
  63291. * @param name defines the name fo the texture
  63292. * @param size defines the size of the texture (default is 256)
  63293. * @param scene defines the hosting scene
  63294. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63295. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63296. */
  63297. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63298. private _updateShaderUniforms;
  63299. protected _getDefines(): string;
  63300. /** Generate the current state of the procedural texture */
  63301. render(useCameraPostProcess?: boolean): void;
  63302. /**
  63303. * Serializes this noise procedural texture
  63304. * @returns a serialized noise procedural texture object
  63305. */
  63306. serialize(): any;
  63307. /**
  63308. * Clone the texture.
  63309. * @returns the cloned texture
  63310. */
  63311. clone(): NoiseProceduralTexture;
  63312. /**
  63313. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63314. * @param parsedTexture defines parsed texture data
  63315. * @param scene defines the current scene
  63316. * @param rootUrl defines the root URL containing noise procedural texture information
  63317. * @returns a parsed NoiseProceduralTexture
  63318. */
  63319. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63320. }
  63321. }
  63322. declare module BABYLON {
  63323. /**
  63324. * Raw cube texture where the raw buffers are passed in
  63325. */
  63326. export class RawCubeTexture extends CubeTexture {
  63327. /**
  63328. * Creates a cube texture where the raw buffers are passed in.
  63329. * @param scene defines the scene the texture is attached to
  63330. * @param data defines the array of data to use to create each face
  63331. * @param size defines the size of the textures
  63332. * @param format defines the format of the data
  63333. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63334. * @param generateMipMaps defines if the engine should generate the mip levels
  63335. * @param invertY defines if data must be stored with Y axis inverted
  63336. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63337. * @param compression defines the compression used (null by default)
  63338. */
  63339. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63340. /**
  63341. * Updates the raw cube texture.
  63342. * @param data defines the data to store
  63343. * @param format defines the data format
  63344. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63345. * @param invertY defines if data must be stored with Y axis inverted
  63346. * @param compression defines the compression used (null by default)
  63347. * @param level defines which level of the texture to update
  63348. */
  63349. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63350. /**
  63351. * Updates a raw cube texture with RGBD encoded data.
  63352. * @param data defines the array of data [mipmap][face] to use to create each face
  63353. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63354. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63355. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63356. * @returns a promsie that resolves when the operation is complete
  63357. */
  63358. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63359. /**
  63360. * Clones the raw cube texture.
  63361. * @return a new cube texture
  63362. */
  63363. clone(): CubeTexture;
  63364. /** @hidden */
  63365. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63366. }
  63367. }
  63368. declare module BABYLON {
  63369. /**
  63370. * Class used to store 2D array textures containing user data
  63371. */
  63372. export class RawTexture2DArray extends Texture {
  63373. /** Gets or sets the texture format to use */
  63374. format: number;
  63375. /**
  63376. * Create a new RawTexture2DArray
  63377. * @param data defines the data of the texture
  63378. * @param width defines the width of the texture
  63379. * @param height defines the height of the texture
  63380. * @param depth defines the number of layers of the texture
  63381. * @param format defines the texture format to use
  63382. * @param scene defines the hosting scene
  63383. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63384. * @param invertY defines if texture must be stored with Y axis inverted
  63385. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63386. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63387. */
  63388. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63389. /** Gets or sets the texture format to use */
  63390. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63391. /**
  63392. * Update the texture with new data
  63393. * @param data defines the data to store in the texture
  63394. */
  63395. update(data: ArrayBufferView): void;
  63396. }
  63397. }
  63398. declare module BABYLON {
  63399. /**
  63400. * Class used to store 3D textures containing user data
  63401. */
  63402. export class RawTexture3D extends Texture {
  63403. /** Gets or sets the texture format to use */
  63404. format: number;
  63405. /**
  63406. * Create a new RawTexture3D
  63407. * @param data defines the data of the texture
  63408. * @param width defines the width of the texture
  63409. * @param height defines the height of the texture
  63410. * @param depth defines the depth of the texture
  63411. * @param format defines the texture format to use
  63412. * @param scene defines the hosting scene
  63413. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63414. * @param invertY defines if texture must be stored with Y axis inverted
  63415. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63416. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63417. */
  63418. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63419. /** Gets or sets the texture format to use */
  63420. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63421. /**
  63422. * Update the texture with new data
  63423. * @param data defines the data to store in the texture
  63424. */
  63425. update(data: ArrayBufferView): void;
  63426. }
  63427. }
  63428. declare module BABYLON {
  63429. /**
  63430. * Creates a refraction texture used by refraction channel of the standard material.
  63431. * It is like a mirror but to see through a material.
  63432. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63433. */
  63434. export class RefractionTexture extends RenderTargetTexture {
  63435. /**
  63436. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63437. * 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.
  63438. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63439. */
  63440. refractionPlane: Plane;
  63441. /**
  63442. * Define how deep under the surface we should see.
  63443. */
  63444. depth: number;
  63445. /**
  63446. * Creates a refraction texture used by refraction channel of the standard material.
  63447. * It is like a mirror but to see through a material.
  63448. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63449. * @param name Define the texture name
  63450. * @param size Define the size of the underlying texture
  63451. * @param scene Define the scene the refraction belongs to
  63452. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63453. */
  63454. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63455. /**
  63456. * Clone the refraction texture.
  63457. * @returns the cloned texture
  63458. */
  63459. clone(): RefractionTexture;
  63460. /**
  63461. * Serialize the texture to a JSON representation you could use in Parse later on
  63462. * @returns the serialized JSON representation
  63463. */
  63464. serialize(): any;
  63465. }
  63466. }
  63467. declare module BABYLON {
  63468. /**
  63469. * Block used to add support for vertex skinning (bones)
  63470. */
  63471. export class BonesBlock extends NodeMaterialBlock {
  63472. /**
  63473. * Creates a new BonesBlock
  63474. * @param name defines the block name
  63475. */
  63476. constructor(name: string);
  63477. /**
  63478. * Initialize the block and prepare the context for build
  63479. * @param state defines the state that will be used for the build
  63480. */
  63481. initialize(state: NodeMaterialBuildState): void;
  63482. /**
  63483. * Gets the current class name
  63484. * @returns the class name
  63485. */
  63486. getClassName(): string;
  63487. /**
  63488. * Gets the matrix indices input component
  63489. */
  63490. get matricesIndices(): NodeMaterialConnectionPoint;
  63491. /**
  63492. * Gets the matrix weights input component
  63493. */
  63494. get matricesWeights(): NodeMaterialConnectionPoint;
  63495. /**
  63496. * Gets the extra matrix indices input component
  63497. */
  63498. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63499. /**
  63500. * Gets the extra matrix weights input component
  63501. */
  63502. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63503. /**
  63504. * Gets the world input component
  63505. */
  63506. get world(): NodeMaterialConnectionPoint;
  63507. /**
  63508. * Gets the output component
  63509. */
  63510. get output(): NodeMaterialConnectionPoint;
  63511. autoConfigure(material: NodeMaterial): void;
  63512. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63513. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63514. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63515. protected _buildBlock(state: NodeMaterialBuildState): this;
  63516. }
  63517. }
  63518. declare module BABYLON {
  63519. /**
  63520. * Block used to add support for instances
  63521. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63522. */
  63523. export class InstancesBlock extends NodeMaterialBlock {
  63524. /**
  63525. * Creates a new InstancesBlock
  63526. * @param name defines the block name
  63527. */
  63528. constructor(name: string);
  63529. /**
  63530. * Gets the current class name
  63531. * @returns the class name
  63532. */
  63533. getClassName(): string;
  63534. /**
  63535. * Gets the first world row input component
  63536. */
  63537. get world0(): NodeMaterialConnectionPoint;
  63538. /**
  63539. * Gets the second world row input component
  63540. */
  63541. get world1(): NodeMaterialConnectionPoint;
  63542. /**
  63543. * Gets the third world row input component
  63544. */
  63545. get world2(): NodeMaterialConnectionPoint;
  63546. /**
  63547. * Gets the forth world row input component
  63548. */
  63549. get world3(): NodeMaterialConnectionPoint;
  63550. /**
  63551. * Gets the world input component
  63552. */
  63553. get world(): NodeMaterialConnectionPoint;
  63554. /**
  63555. * Gets the output component
  63556. */
  63557. get output(): NodeMaterialConnectionPoint;
  63558. /**
  63559. * Gets the isntanceID component
  63560. */
  63561. get instanceID(): NodeMaterialConnectionPoint;
  63562. autoConfigure(material: NodeMaterial): void;
  63563. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63564. protected _buildBlock(state: NodeMaterialBuildState): this;
  63565. }
  63566. }
  63567. declare module BABYLON {
  63568. /**
  63569. * Block used to add morph targets support to vertex shader
  63570. */
  63571. export class MorphTargetsBlock extends NodeMaterialBlock {
  63572. private _repeatableContentAnchor;
  63573. /**
  63574. * Create a new MorphTargetsBlock
  63575. * @param name defines the block name
  63576. */
  63577. constructor(name: string);
  63578. /**
  63579. * Gets the current class name
  63580. * @returns the class name
  63581. */
  63582. getClassName(): string;
  63583. /**
  63584. * Gets the position input component
  63585. */
  63586. get position(): NodeMaterialConnectionPoint;
  63587. /**
  63588. * Gets the normal input component
  63589. */
  63590. get normal(): NodeMaterialConnectionPoint;
  63591. /**
  63592. * Gets the tangent input component
  63593. */
  63594. get tangent(): NodeMaterialConnectionPoint;
  63595. /**
  63596. * Gets the tangent input component
  63597. */
  63598. get uv(): NodeMaterialConnectionPoint;
  63599. /**
  63600. * Gets the position output component
  63601. */
  63602. get positionOutput(): NodeMaterialConnectionPoint;
  63603. /**
  63604. * Gets the normal output component
  63605. */
  63606. get normalOutput(): NodeMaterialConnectionPoint;
  63607. /**
  63608. * Gets the tangent output component
  63609. */
  63610. get tangentOutput(): NodeMaterialConnectionPoint;
  63611. /**
  63612. * Gets the tangent output component
  63613. */
  63614. get uvOutput(): NodeMaterialConnectionPoint;
  63615. initialize(state: NodeMaterialBuildState): void;
  63616. autoConfigure(material: NodeMaterial): void;
  63617. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63618. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63619. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63620. protected _buildBlock(state: NodeMaterialBuildState): this;
  63621. }
  63622. }
  63623. declare module BABYLON {
  63624. /**
  63625. * Block used to get data information from a light
  63626. */
  63627. export class LightInformationBlock extends NodeMaterialBlock {
  63628. private _lightDataUniformName;
  63629. private _lightColorUniformName;
  63630. private _lightTypeDefineName;
  63631. /**
  63632. * Gets or sets the light associated with this block
  63633. */
  63634. light: Nullable<Light>;
  63635. /**
  63636. * Creates a new LightInformationBlock
  63637. * @param name defines the block name
  63638. */
  63639. constructor(name: string);
  63640. /**
  63641. * Gets the current class name
  63642. * @returns the class name
  63643. */
  63644. getClassName(): string;
  63645. /**
  63646. * Gets the world position input component
  63647. */
  63648. get worldPosition(): NodeMaterialConnectionPoint;
  63649. /**
  63650. * Gets the direction output component
  63651. */
  63652. get direction(): NodeMaterialConnectionPoint;
  63653. /**
  63654. * Gets the direction output component
  63655. */
  63656. get color(): NodeMaterialConnectionPoint;
  63657. /**
  63658. * Gets the direction output component
  63659. */
  63660. get intensity(): NodeMaterialConnectionPoint;
  63661. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63662. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63663. protected _buildBlock(state: NodeMaterialBuildState): this;
  63664. serialize(): any;
  63665. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63666. }
  63667. }
  63668. declare module BABYLON {
  63669. /**
  63670. * Block used to add image processing support to fragment shader
  63671. */
  63672. export class ImageProcessingBlock extends NodeMaterialBlock {
  63673. /**
  63674. * Create a new ImageProcessingBlock
  63675. * @param name defines the block name
  63676. */
  63677. constructor(name: string);
  63678. /**
  63679. * Gets the current class name
  63680. * @returns the class name
  63681. */
  63682. getClassName(): string;
  63683. /**
  63684. * Gets the color input component
  63685. */
  63686. get color(): NodeMaterialConnectionPoint;
  63687. /**
  63688. * Gets the output component
  63689. */
  63690. get output(): NodeMaterialConnectionPoint;
  63691. /**
  63692. * Initialize the block and prepare the context for build
  63693. * @param state defines the state that will be used for the build
  63694. */
  63695. initialize(state: NodeMaterialBuildState): void;
  63696. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63697. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63698. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63699. protected _buildBlock(state: NodeMaterialBuildState): this;
  63700. }
  63701. }
  63702. declare module BABYLON {
  63703. /**
  63704. * Block used to pertub normals based on a normal map
  63705. */
  63706. export class PerturbNormalBlock extends NodeMaterialBlock {
  63707. private _tangentSpaceParameterName;
  63708. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63709. invertX: boolean;
  63710. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63711. invertY: boolean;
  63712. /**
  63713. * Create a new PerturbNormalBlock
  63714. * @param name defines the block name
  63715. */
  63716. constructor(name: string);
  63717. /**
  63718. * Gets the current class name
  63719. * @returns the class name
  63720. */
  63721. getClassName(): string;
  63722. /**
  63723. * Gets the world position input component
  63724. */
  63725. get worldPosition(): NodeMaterialConnectionPoint;
  63726. /**
  63727. * Gets the world normal input component
  63728. */
  63729. get worldNormal(): NodeMaterialConnectionPoint;
  63730. /**
  63731. * Gets the world tangent input component
  63732. */
  63733. get worldTangent(): NodeMaterialConnectionPoint;
  63734. /**
  63735. * Gets the uv input component
  63736. */
  63737. get uv(): NodeMaterialConnectionPoint;
  63738. /**
  63739. * Gets the normal map color input component
  63740. */
  63741. get normalMapColor(): NodeMaterialConnectionPoint;
  63742. /**
  63743. * Gets the strength input component
  63744. */
  63745. get strength(): NodeMaterialConnectionPoint;
  63746. /**
  63747. * Gets the output component
  63748. */
  63749. get output(): NodeMaterialConnectionPoint;
  63750. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63751. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63752. autoConfigure(material: NodeMaterial): void;
  63753. protected _buildBlock(state: NodeMaterialBuildState): this;
  63754. protected _dumpPropertiesCode(): string;
  63755. serialize(): any;
  63756. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63757. }
  63758. }
  63759. declare module BABYLON {
  63760. /**
  63761. * Block used to discard a pixel if a value is smaller than a cutoff
  63762. */
  63763. export class DiscardBlock extends NodeMaterialBlock {
  63764. /**
  63765. * Create a new DiscardBlock
  63766. * @param name defines the block name
  63767. */
  63768. constructor(name: string);
  63769. /**
  63770. * Gets the current class name
  63771. * @returns the class name
  63772. */
  63773. getClassName(): string;
  63774. /**
  63775. * Gets the color input component
  63776. */
  63777. get value(): NodeMaterialConnectionPoint;
  63778. /**
  63779. * Gets the cutoff input component
  63780. */
  63781. get cutoff(): NodeMaterialConnectionPoint;
  63782. protected _buildBlock(state: NodeMaterialBuildState): this;
  63783. }
  63784. }
  63785. declare module BABYLON {
  63786. /**
  63787. * Block used to test if the fragment shader is front facing
  63788. */
  63789. export class FrontFacingBlock extends NodeMaterialBlock {
  63790. /**
  63791. * Creates a new FrontFacingBlock
  63792. * @param name defines the block name
  63793. */
  63794. constructor(name: string);
  63795. /**
  63796. * Gets the current class name
  63797. * @returns the class name
  63798. */
  63799. getClassName(): string;
  63800. /**
  63801. * Gets the output component
  63802. */
  63803. get output(): NodeMaterialConnectionPoint;
  63804. protected _buildBlock(state: NodeMaterialBuildState): this;
  63805. }
  63806. }
  63807. declare module BABYLON {
  63808. /**
  63809. * Block used to get the derivative value on x and y of a given input
  63810. */
  63811. export class DerivativeBlock extends NodeMaterialBlock {
  63812. /**
  63813. * Create a new DerivativeBlock
  63814. * @param name defines the block name
  63815. */
  63816. constructor(name: string);
  63817. /**
  63818. * Gets the current class name
  63819. * @returns the class name
  63820. */
  63821. getClassName(): string;
  63822. /**
  63823. * Gets the input component
  63824. */
  63825. get input(): NodeMaterialConnectionPoint;
  63826. /**
  63827. * Gets the derivative output on x
  63828. */
  63829. get dx(): NodeMaterialConnectionPoint;
  63830. /**
  63831. * Gets the derivative output on y
  63832. */
  63833. get dy(): NodeMaterialConnectionPoint;
  63834. protected _buildBlock(state: NodeMaterialBuildState): this;
  63835. }
  63836. }
  63837. declare module BABYLON {
  63838. /**
  63839. * Block used to make gl_FragCoord available
  63840. */
  63841. export class FragCoordBlock extends NodeMaterialBlock {
  63842. /**
  63843. * Creates a new FragCoordBlock
  63844. * @param name defines the block name
  63845. */
  63846. constructor(name: string);
  63847. /**
  63848. * Gets the current class name
  63849. * @returns the class name
  63850. */
  63851. getClassName(): string;
  63852. /**
  63853. * Gets the xy component
  63854. */
  63855. get xy(): NodeMaterialConnectionPoint;
  63856. /**
  63857. * Gets the xyz component
  63858. */
  63859. get xyz(): NodeMaterialConnectionPoint;
  63860. /**
  63861. * Gets the xyzw component
  63862. */
  63863. get xyzw(): NodeMaterialConnectionPoint;
  63864. /**
  63865. * Gets the x component
  63866. */
  63867. get x(): NodeMaterialConnectionPoint;
  63868. /**
  63869. * Gets the y component
  63870. */
  63871. get y(): NodeMaterialConnectionPoint;
  63872. /**
  63873. * Gets the z component
  63874. */
  63875. get z(): NodeMaterialConnectionPoint;
  63876. /**
  63877. * Gets the w component
  63878. */
  63879. get output(): NodeMaterialConnectionPoint;
  63880. protected writeOutputs(state: NodeMaterialBuildState): string;
  63881. protected _buildBlock(state: NodeMaterialBuildState): this;
  63882. }
  63883. }
  63884. declare module BABYLON {
  63885. /**
  63886. * Block used to get the screen sizes
  63887. */
  63888. export class ScreenSizeBlock extends NodeMaterialBlock {
  63889. private _varName;
  63890. private _scene;
  63891. /**
  63892. * Creates a new ScreenSizeBlock
  63893. * @param name defines the block name
  63894. */
  63895. constructor(name: string);
  63896. /**
  63897. * Gets the current class name
  63898. * @returns the class name
  63899. */
  63900. getClassName(): string;
  63901. /**
  63902. * Gets the xy component
  63903. */
  63904. get xy(): NodeMaterialConnectionPoint;
  63905. /**
  63906. * Gets the x component
  63907. */
  63908. get x(): NodeMaterialConnectionPoint;
  63909. /**
  63910. * Gets the y component
  63911. */
  63912. get y(): NodeMaterialConnectionPoint;
  63913. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63914. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  63915. protected _buildBlock(state: NodeMaterialBuildState): this;
  63916. }
  63917. }
  63918. declare module BABYLON {
  63919. /**
  63920. * Block used to add support for scene fog
  63921. */
  63922. export class FogBlock extends NodeMaterialBlock {
  63923. private _fogDistanceName;
  63924. private _fogParameters;
  63925. /**
  63926. * Create a new FogBlock
  63927. * @param name defines the block name
  63928. */
  63929. constructor(name: string);
  63930. /**
  63931. * Gets the current class name
  63932. * @returns the class name
  63933. */
  63934. getClassName(): string;
  63935. /**
  63936. * Gets the world position input component
  63937. */
  63938. get worldPosition(): NodeMaterialConnectionPoint;
  63939. /**
  63940. * Gets the view input component
  63941. */
  63942. get view(): NodeMaterialConnectionPoint;
  63943. /**
  63944. * Gets the color input component
  63945. */
  63946. get input(): NodeMaterialConnectionPoint;
  63947. /**
  63948. * Gets the fog color input component
  63949. */
  63950. get fogColor(): NodeMaterialConnectionPoint;
  63951. /**
  63952. * Gets the output component
  63953. */
  63954. get output(): NodeMaterialConnectionPoint;
  63955. autoConfigure(material: NodeMaterial): void;
  63956. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63957. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63958. protected _buildBlock(state: NodeMaterialBuildState): this;
  63959. }
  63960. }
  63961. declare module BABYLON {
  63962. /**
  63963. * Block used to add light in the fragment shader
  63964. */
  63965. export class LightBlock extends NodeMaterialBlock {
  63966. private _lightId;
  63967. /**
  63968. * Gets or sets the light associated with this block
  63969. */
  63970. light: Nullable<Light>;
  63971. /**
  63972. * Create a new LightBlock
  63973. * @param name defines the block name
  63974. */
  63975. constructor(name: string);
  63976. /**
  63977. * Gets the current class name
  63978. * @returns the class name
  63979. */
  63980. getClassName(): string;
  63981. /**
  63982. * Gets the world position input component
  63983. */
  63984. get worldPosition(): NodeMaterialConnectionPoint;
  63985. /**
  63986. * Gets the world normal input component
  63987. */
  63988. get worldNormal(): NodeMaterialConnectionPoint;
  63989. /**
  63990. * Gets the camera (or eye) position component
  63991. */
  63992. get cameraPosition(): NodeMaterialConnectionPoint;
  63993. /**
  63994. * Gets the glossiness component
  63995. */
  63996. get glossiness(): NodeMaterialConnectionPoint;
  63997. /**
  63998. * Gets the glossinness power component
  63999. */
  64000. get glossPower(): NodeMaterialConnectionPoint;
  64001. /**
  64002. * Gets the diffuse color component
  64003. */
  64004. get diffuseColor(): NodeMaterialConnectionPoint;
  64005. /**
  64006. * Gets the specular color component
  64007. */
  64008. get specularColor(): NodeMaterialConnectionPoint;
  64009. /**
  64010. * Gets the view matrix component
  64011. */
  64012. get view(): NodeMaterialConnectionPoint;
  64013. /**
  64014. * Gets the diffuse output component
  64015. */
  64016. get diffuseOutput(): NodeMaterialConnectionPoint;
  64017. /**
  64018. * Gets the specular output component
  64019. */
  64020. get specularOutput(): NodeMaterialConnectionPoint;
  64021. /**
  64022. * Gets the shadow output component
  64023. */
  64024. get shadow(): NodeMaterialConnectionPoint;
  64025. autoConfigure(material: NodeMaterial): void;
  64026. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64027. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64028. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64029. private _injectVertexCode;
  64030. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64031. serialize(): any;
  64032. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64033. }
  64034. }
  64035. declare module BABYLON {
  64036. /**
  64037. * Block used to read a reflection texture from a sampler
  64038. */
  64039. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64040. /**
  64041. * Create a new ReflectionTextureBlock
  64042. * @param name defines the block name
  64043. */
  64044. constructor(name: string);
  64045. /**
  64046. * Gets the current class name
  64047. * @returns the class name
  64048. */
  64049. getClassName(): string;
  64050. /**
  64051. * Gets the world position input component
  64052. */
  64053. get position(): NodeMaterialConnectionPoint;
  64054. /**
  64055. * Gets the world position input component
  64056. */
  64057. get worldPosition(): NodeMaterialConnectionPoint;
  64058. /**
  64059. * Gets the world normal input component
  64060. */
  64061. get worldNormal(): NodeMaterialConnectionPoint;
  64062. /**
  64063. * Gets the world input component
  64064. */
  64065. get world(): NodeMaterialConnectionPoint;
  64066. /**
  64067. * Gets the camera (or eye) position component
  64068. */
  64069. get cameraPosition(): NodeMaterialConnectionPoint;
  64070. /**
  64071. * Gets the view input component
  64072. */
  64073. get view(): NodeMaterialConnectionPoint;
  64074. /**
  64075. * Gets the rgb output component
  64076. */
  64077. get rgb(): NodeMaterialConnectionPoint;
  64078. /**
  64079. * Gets the rgba output component
  64080. */
  64081. get rgba(): NodeMaterialConnectionPoint;
  64082. /**
  64083. * Gets the r output component
  64084. */
  64085. get r(): NodeMaterialConnectionPoint;
  64086. /**
  64087. * Gets the g output component
  64088. */
  64089. get g(): NodeMaterialConnectionPoint;
  64090. /**
  64091. * Gets the b output component
  64092. */
  64093. get b(): NodeMaterialConnectionPoint;
  64094. /**
  64095. * Gets the a output component
  64096. */
  64097. get a(): NodeMaterialConnectionPoint;
  64098. autoConfigure(material: NodeMaterial): void;
  64099. protected _buildBlock(state: NodeMaterialBuildState): this;
  64100. }
  64101. }
  64102. declare module BABYLON {
  64103. /**
  64104. * Block used to add 2 vectors
  64105. */
  64106. export class AddBlock extends NodeMaterialBlock {
  64107. /**
  64108. * Creates a new AddBlock
  64109. * @param name defines the block name
  64110. */
  64111. constructor(name: string);
  64112. /**
  64113. * Gets the current class name
  64114. * @returns the class name
  64115. */
  64116. getClassName(): string;
  64117. /**
  64118. * Gets the left operand input component
  64119. */
  64120. get left(): NodeMaterialConnectionPoint;
  64121. /**
  64122. * Gets the right operand input component
  64123. */
  64124. get right(): NodeMaterialConnectionPoint;
  64125. /**
  64126. * Gets the output component
  64127. */
  64128. get output(): NodeMaterialConnectionPoint;
  64129. protected _buildBlock(state: NodeMaterialBuildState): this;
  64130. }
  64131. }
  64132. declare module BABYLON {
  64133. /**
  64134. * Block used to scale a vector by a float
  64135. */
  64136. export class ScaleBlock extends NodeMaterialBlock {
  64137. /**
  64138. * Creates a new ScaleBlock
  64139. * @param name defines the block name
  64140. */
  64141. constructor(name: string);
  64142. /**
  64143. * Gets the current class name
  64144. * @returns the class name
  64145. */
  64146. getClassName(): string;
  64147. /**
  64148. * Gets the input component
  64149. */
  64150. get input(): NodeMaterialConnectionPoint;
  64151. /**
  64152. * Gets the factor input component
  64153. */
  64154. get factor(): NodeMaterialConnectionPoint;
  64155. /**
  64156. * Gets the output component
  64157. */
  64158. get output(): NodeMaterialConnectionPoint;
  64159. protected _buildBlock(state: NodeMaterialBuildState): this;
  64160. }
  64161. }
  64162. declare module BABYLON {
  64163. /**
  64164. * Block used to clamp a float
  64165. */
  64166. export class ClampBlock extends NodeMaterialBlock {
  64167. /** Gets or sets the minimum range */
  64168. minimum: number;
  64169. /** Gets or sets the maximum range */
  64170. maximum: number;
  64171. /**
  64172. * Creates a new ClampBlock
  64173. * @param name defines the block name
  64174. */
  64175. constructor(name: string);
  64176. /**
  64177. * Gets the current class name
  64178. * @returns the class name
  64179. */
  64180. getClassName(): string;
  64181. /**
  64182. * Gets the value input component
  64183. */
  64184. get value(): NodeMaterialConnectionPoint;
  64185. /**
  64186. * Gets the output component
  64187. */
  64188. get output(): NodeMaterialConnectionPoint;
  64189. protected _buildBlock(state: NodeMaterialBuildState): this;
  64190. protected _dumpPropertiesCode(): string;
  64191. serialize(): any;
  64192. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64193. }
  64194. }
  64195. declare module BABYLON {
  64196. /**
  64197. * Block used to apply a cross product between 2 vectors
  64198. */
  64199. export class CrossBlock extends NodeMaterialBlock {
  64200. /**
  64201. * Creates a new CrossBlock
  64202. * @param name defines the block name
  64203. */
  64204. constructor(name: string);
  64205. /**
  64206. * Gets the current class name
  64207. * @returns the class name
  64208. */
  64209. getClassName(): string;
  64210. /**
  64211. * Gets the left operand input component
  64212. */
  64213. get left(): NodeMaterialConnectionPoint;
  64214. /**
  64215. * Gets the right operand input component
  64216. */
  64217. get right(): NodeMaterialConnectionPoint;
  64218. /**
  64219. * Gets the output component
  64220. */
  64221. get output(): NodeMaterialConnectionPoint;
  64222. protected _buildBlock(state: NodeMaterialBuildState): this;
  64223. }
  64224. }
  64225. declare module BABYLON {
  64226. /**
  64227. * Block used to apply a dot product between 2 vectors
  64228. */
  64229. export class DotBlock extends NodeMaterialBlock {
  64230. /**
  64231. * Creates a new DotBlock
  64232. * @param name defines the block name
  64233. */
  64234. constructor(name: string);
  64235. /**
  64236. * Gets the current class name
  64237. * @returns the class name
  64238. */
  64239. getClassName(): string;
  64240. /**
  64241. * Gets the left operand input component
  64242. */
  64243. get left(): NodeMaterialConnectionPoint;
  64244. /**
  64245. * Gets the right operand input component
  64246. */
  64247. get right(): NodeMaterialConnectionPoint;
  64248. /**
  64249. * Gets the output component
  64250. */
  64251. get output(): NodeMaterialConnectionPoint;
  64252. protected _buildBlock(state: NodeMaterialBuildState): this;
  64253. }
  64254. }
  64255. declare module BABYLON {
  64256. /**
  64257. * Block used to normalize a vector
  64258. */
  64259. export class NormalizeBlock extends NodeMaterialBlock {
  64260. /**
  64261. * Creates a new NormalizeBlock
  64262. * @param name defines the block name
  64263. */
  64264. constructor(name: string);
  64265. /**
  64266. * Gets the current class name
  64267. * @returns the class name
  64268. */
  64269. getClassName(): string;
  64270. /**
  64271. * Gets the input component
  64272. */
  64273. get input(): NodeMaterialConnectionPoint;
  64274. /**
  64275. * Gets the output component
  64276. */
  64277. get output(): NodeMaterialConnectionPoint;
  64278. protected _buildBlock(state: NodeMaterialBuildState): this;
  64279. }
  64280. }
  64281. declare module BABYLON {
  64282. /**
  64283. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64284. */
  64285. export class ColorMergerBlock extends NodeMaterialBlock {
  64286. /**
  64287. * Create a new ColorMergerBlock
  64288. * @param name defines the block name
  64289. */
  64290. constructor(name: string);
  64291. /**
  64292. * Gets the current class name
  64293. * @returns the class name
  64294. */
  64295. getClassName(): string;
  64296. /**
  64297. * Gets the rgb component (input)
  64298. */
  64299. get rgbIn(): NodeMaterialConnectionPoint;
  64300. /**
  64301. * Gets the r component (input)
  64302. */
  64303. get r(): NodeMaterialConnectionPoint;
  64304. /**
  64305. * Gets the g component (input)
  64306. */
  64307. get g(): NodeMaterialConnectionPoint;
  64308. /**
  64309. * Gets the b component (input)
  64310. */
  64311. get b(): NodeMaterialConnectionPoint;
  64312. /**
  64313. * Gets the a component (input)
  64314. */
  64315. get a(): NodeMaterialConnectionPoint;
  64316. /**
  64317. * Gets the rgba component (output)
  64318. */
  64319. get rgba(): NodeMaterialConnectionPoint;
  64320. /**
  64321. * Gets the rgb component (output)
  64322. */
  64323. get rgbOut(): NodeMaterialConnectionPoint;
  64324. /**
  64325. * Gets the rgb component (output)
  64326. * @deprecated Please use rgbOut instead.
  64327. */
  64328. get rgb(): NodeMaterialConnectionPoint;
  64329. protected _buildBlock(state: NodeMaterialBuildState): this;
  64330. }
  64331. }
  64332. declare module BABYLON {
  64333. /**
  64334. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64335. */
  64336. export class VectorSplitterBlock extends NodeMaterialBlock {
  64337. /**
  64338. * Create a new VectorSplitterBlock
  64339. * @param name defines the block name
  64340. */
  64341. constructor(name: string);
  64342. /**
  64343. * Gets the current class name
  64344. * @returns the class name
  64345. */
  64346. getClassName(): string;
  64347. /**
  64348. * Gets the xyzw component (input)
  64349. */
  64350. get xyzw(): NodeMaterialConnectionPoint;
  64351. /**
  64352. * Gets the xyz component (input)
  64353. */
  64354. get xyzIn(): NodeMaterialConnectionPoint;
  64355. /**
  64356. * Gets the xy component (input)
  64357. */
  64358. get xyIn(): NodeMaterialConnectionPoint;
  64359. /**
  64360. * Gets the xyz component (output)
  64361. */
  64362. get xyzOut(): NodeMaterialConnectionPoint;
  64363. /**
  64364. * Gets the xy component (output)
  64365. */
  64366. get xyOut(): NodeMaterialConnectionPoint;
  64367. /**
  64368. * Gets the x component (output)
  64369. */
  64370. get x(): NodeMaterialConnectionPoint;
  64371. /**
  64372. * Gets the y component (output)
  64373. */
  64374. get y(): NodeMaterialConnectionPoint;
  64375. /**
  64376. * Gets the z component (output)
  64377. */
  64378. get z(): NodeMaterialConnectionPoint;
  64379. /**
  64380. * Gets the w component (output)
  64381. */
  64382. get w(): NodeMaterialConnectionPoint;
  64383. protected _inputRename(name: string): string;
  64384. protected _outputRename(name: string): string;
  64385. protected _buildBlock(state: NodeMaterialBuildState): this;
  64386. }
  64387. }
  64388. declare module BABYLON {
  64389. /**
  64390. * Block used to lerp between 2 values
  64391. */
  64392. export class LerpBlock extends NodeMaterialBlock {
  64393. /**
  64394. * Creates a new LerpBlock
  64395. * @param name defines the block name
  64396. */
  64397. constructor(name: string);
  64398. /**
  64399. * Gets the current class name
  64400. * @returns the class name
  64401. */
  64402. getClassName(): string;
  64403. /**
  64404. * Gets the left operand input component
  64405. */
  64406. get left(): NodeMaterialConnectionPoint;
  64407. /**
  64408. * Gets the right operand input component
  64409. */
  64410. get right(): NodeMaterialConnectionPoint;
  64411. /**
  64412. * Gets the gradient operand input component
  64413. */
  64414. get gradient(): NodeMaterialConnectionPoint;
  64415. /**
  64416. * Gets the output component
  64417. */
  64418. get output(): NodeMaterialConnectionPoint;
  64419. protected _buildBlock(state: NodeMaterialBuildState): this;
  64420. }
  64421. }
  64422. declare module BABYLON {
  64423. /**
  64424. * Block used to divide 2 vectors
  64425. */
  64426. export class DivideBlock extends NodeMaterialBlock {
  64427. /**
  64428. * Creates a new DivideBlock
  64429. * @param name defines the block name
  64430. */
  64431. constructor(name: string);
  64432. /**
  64433. * Gets the current class name
  64434. * @returns the class name
  64435. */
  64436. getClassName(): string;
  64437. /**
  64438. * Gets the left operand input component
  64439. */
  64440. get left(): NodeMaterialConnectionPoint;
  64441. /**
  64442. * Gets the right operand input component
  64443. */
  64444. get right(): NodeMaterialConnectionPoint;
  64445. /**
  64446. * Gets the output component
  64447. */
  64448. get output(): NodeMaterialConnectionPoint;
  64449. protected _buildBlock(state: NodeMaterialBuildState): this;
  64450. }
  64451. }
  64452. declare module BABYLON {
  64453. /**
  64454. * Block used to subtract 2 vectors
  64455. */
  64456. export class SubtractBlock extends NodeMaterialBlock {
  64457. /**
  64458. * Creates a new SubtractBlock
  64459. * @param name defines the block name
  64460. */
  64461. constructor(name: string);
  64462. /**
  64463. * Gets the current class name
  64464. * @returns the class name
  64465. */
  64466. getClassName(): string;
  64467. /**
  64468. * Gets the left operand input component
  64469. */
  64470. get left(): NodeMaterialConnectionPoint;
  64471. /**
  64472. * Gets the right operand input component
  64473. */
  64474. get right(): NodeMaterialConnectionPoint;
  64475. /**
  64476. * Gets the output component
  64477. */
  64478. get output(): NodeMaterialConnectionPoint;
  64479. protected _buildBlock(state: NodeMaterialBuildState): this;
  64480. }
  64481. }
  64482. declare module BABYLON {
  64483. /**
  64484. * Block used to step a value
  64485. */
  64486. export class StepBlock extends NodeMaterialBlock {
  64487. /**
  64488. * Creates a new StepBlock
  64489. * @param name defines the block name
  64490. */
  64491. constructor(name: string);
  64492. /**
  64493. * Gets the current class name
  64494. * @returns the class name
  64495. */
  64496. getClassName(): string;
  64497. /**
  64498. * Gets the value operand input component
  64499. */
  64500. get value(): NodeMaterialConnectionPoint;
  64501. /**
  64502. * Gets the edge operand input component
  64503. */
  64504. get edge(): NodeMaterialConnectionPoint;
  64505. /**
  64506. * Gets the output component
  64507. */
  64508. get output(): NodeMaterialConnectionPoint;
  64509. protected _buildBlock(state: NodeMaterialBuildState): this;
  64510. }
  64511. }
  64512. declare module BABYLON {
  64513. /**
  64514. * Block used to get the opposite (1 - x) of a value
  64515. */
  64516. export class OneMinusBlock extends NodeMaterialBlock {
  64517. /**
  64518. * Creates a new OneMinusBlock
  64519. * @param name defines the block name
  64520. */
  64521. constructor(name: string);
  64522. /**
  64523. * Gets the current class name
  64524. * @returns the class name
  64525. */
  64526. getClassName(): string;
  64527. /**
  64528. * Gets the input component
  64529. */
  64530. get input(): NodeMaterialConnectionPoint;
  64531. /**
  64532. * Gets the output component
  64533. */
  64534. get output(): NodeMaterialConnectionPoint;
  64535. protected _buildBlock(state: NodeMaterialBuildState): this;
  64536. }
  64537. }
  64538. declare module BABYLON {
  64539. /**
  64540. * Block used to get the view direction
  64541. */
  64542. export class ViewDirectionBlock extends NodeMaterialBlock {
  64543. /**
  64544. * Creates a new ViewDirectionBlock
  64545. * @param name defines the block name
  64546. */
  64547. constructor(name: string);
  64548. /**
  64549. * Gets the current class name
  64550. * @returns the class name
  64551. */
  64552. getClassName(): string;
  64553. /**
  64554. * Gets the world position component
  64555. */
  64556. get worldPosition(): NodeMaterialConnectionPoint;
  64557. /**
  64558. * Gets the camera position component
  64559. */
  64560. get cameraPosition(): NodeMaterialConnectionPoint;
  64561. /**
  64562. * Gets the output component
  64563. */
  64564. get output(): NodeMaterialConnectionPoint;
  64565. autoConfigure(material: NodeMaterial): void;
  64566. protected _buildBlock(state: NodeMaterialBuildState): this;
  64567. }
  64568. }
  64569. declare module BABYLON {
  64570. /**
  64571. * Block used to compute fresnel value
  64572. */
  64573. export class FresnelBlock extends NodeMaterialBlock {
  64574. /**
  64575. * Create a new FresnelBlock
  64576. * @param name defines the block name
  64577. */
  64578. constructor(name: string);
  64579. /**
  64580. * Gets the current class name
  64581. * @returns the class name
  64582. */
  64583. getClassName(): string;
  64584. /**
  64585. * Gets the world normal input component
  64586. */
  64587. get worldNormal(): NodeMaterialConnectionPoint;
  64588. /**
  64589. * Gets the view direction input component
  64590. */
  64591. get viewDirection(): NodeMaterialConnectionPoint;
  64592. /**
  64593. * Gets the bias input component
  64594. */
  64595. get bias(): NodeMaterialConnectionPoint;
  64596. /**
  64597. * Gets the camera (or eye) position component
  64598. */
  64599. get power(): NodeMaterialConnectionPoint;
  64600. /**
  64601. * Gets the fresnel output component
  64602. */
  64603. get fresnel(): NodeMaterialConnectionPoint;
  64604. autoConfigure(material: NodeMaterial): void;
  64605. protected _buildBlock(state: NodeMaterialBuildState): this;
  64606. }
  64607. }
  64608. declare module BABYLON {
  64609. /**
  64610. * Block used to get the max of 2 values
  64611. */
  64612. export class MaxBlock extends NodeMaterialBlock {
  64613. /**
  64614. * Creates a new MaxBlock
  64615. * @param name defines the block name
  64616. */
  64617. constructor(name: string);
  64618. /**
  64619. * Gets the current class name
  64620. * @returns the class name
  64621. */
  64622. getClassName(): string;
  64623. /**
  64624. * Gets the left operand input component
  64625. */
  64626. get left(): NodeMaterialConnectionPoint;
  64627. /**
  64628. * Gets the right operand input component
  64629. */
  64630. get right(): NodeMaterialConnectionPoint;
  64631. /**
  64632. * Gets the output component
  64633. */
  64634. get output(): NodeMaterialConnectionPoint;
  64635. protected _buildBlock(state: NodeMaterialBuildState): this;
  64636. }
  64637. }
  64638. declare module BABYLON {
  64639. /**
  64640. * Block used to get the min of 2 values
  64641. */
  64642. export class MinBlock extends NodeMaterialBlock {
  64643. /**
  64644. * Creates a new MinBlock
  64645. * @param name defines the block name
  64646. */
  64647. constructor(name: string);
  64648. /**
  64649. * Gets the current class name
  64650. * @returns the class name
  64651. */
  64652. getClassName(): string;
  64653. /**
  64654. * Gets the left operand input component
  64655. */
  64656. get left(): NodeMaterialConnectionPoint;
  64657. /**
  64658. * Gets the right operand input component
  64659. */
  64660. get right(): NodeMaterialConnectionPoint;
  64661. /**
  64662. * Gets the output component
  64663. */
  64664. get output(): NodeMaterialConnectionPoint;
  64665. protected _buildBlock(state: NodeMaterialBuildState): this;
  64666. }
  64667. }
  64668. declare module BABYLON {
  64669. /**
  64670. * Block used to get the distance between 2 values
  64671. */
  64672. export class DistanceBlock extends NodeMaterialBlock {
  64673. /**
  64674. * Creates a new DistanceBlock
  64675. * @param name defines the block name
  64676. */
  64677. constructor(name: string);
  64678. /**
  64679. * Gets the current class name
  64680. * @returns the class name
  64681. */
  64682. getClassName(): string;
  64683. /**
  64684. * Gets the left operand input component
  64685. */
  64686. get left(): NodeMaterialConnectionPoint;
  64687. /**
  64688. * Gets the right operand input component
  64689. */
  64690. get right(): NodeMaterialConnectionPoint;
  64691. /**
  64692. * Gets the output component
  64693. */
  64694. get output(): NodeMaterialConnectionPoint;
  64695. protected _buildBlock(state: NodeMaterialBuildState): this;
  64696. }
  64697. }
  64698. declare module BABYLON {
  64699. /**
  64700. * Block used to get the length of a vector
  64701. */
  64702. export class LengthBlock extends NodeMaterialBlock {
  64703. /**
  64704. * Creates a new LengthBlock
  64705. * @param name defines the block name
  64706. */
  64707. constructor(name: string);
  64708. /**
  64709. * Gets the current class name
  64710. * @returns the class name
  64711. */
  64712. getClassName(): string;
  64713. /**
  64714. * Gets the value input component
  64715. */
  64716. get value(): NodeMaterialConnectionPoint;
  64717. /**
  64718. * Gets the output component
  64719. */
  64720. get output(): NodeMaterialConnectionPoint;
  64721. protected _buildBlock(state: NodeMaterialBuildState): this;
  64722. }
  64723. }
  64724. declare module BABYLON {
  64725. /**
  64726. * Block used to get negative version of a value (i.e. x * -1)
  64727. */
  64728. export class NegateBlock extends NodeMaterialBlock {
  64729. /**
  64730. * Creates a new NegateBlock
  64731. * @param name defines the block name
  64732. */
  64733. constructor(name: string);
  64734. /**
  64735. * Gets the current class name
  64736. * @returns the class name
  64737. */
  64738. getClassName(): string;
  64739. /**
  64740. * Gets the value input component
  64741. */
  64742. get value(): NodeMaterialConnectionPoint;
  64743. /**
  64744. * Gets the output component
  64745. */
  64746. get output(): NodeMaterialConnectionPoint;
  64747. protected _buildBlock(state: NodeMaterialBuildState): this;
  64748. }
  64749. }
  64750. declare module BABYLON {
  64751. /**
  64752. * Block used to get the value of the first parameter raised to the power of the second
  64753. */
  64754. export class PowBlock extends NodeMaterialBlock {
  64755. /**
  64756. * Creates a new PowBlock
  64757. * @param name defines the block name
  64758. */
  64759. constructor(name: string);
  64760. /**
  64761. * Gets the current class name
  64762. * @returns the class name
  64763. */
  64764. getClassName(): string;
  64765. /**
  64766. * Gets the value operand input component
  64767. */
  64768. get value(): NodeMaterialConnectionPoint;
  64769. /**
  64770. * Gets the power operand input component
  64771. */
  64772. get power(): NodeMaterialConnectionPoint;
  64773. /**
  64774. * Gets the output component
  64775. */
  64776. get output(): NodeMaterialConnectionPoint;
  64777. protected _buildBlock(state: NodeMaterialBuildState): this;
  64778. }
  64779. }
  64780. declare module BABYLON {
  64781. /**
  64782. * Block used to get a random number
  64783. */
  64784. export class RandomNumberBlock extends NodeMaterialBlock {
  64785. /**
  64786. * Creates a new RandomNumberBlock
  64787. * @param name defines the block name
  64788. */
  64789. constructor(name: string);
  64790. /**
  64791. * Gets the current class name
  64792. * @returns the class name
  64793. */
  64794. getClassName(): string;
  64795. /**
  64796. * Gets the seed input component
  64797. */
  64798. get seed(): NodeMaterialConnectionPoint;
  64799. /**
  64800. * Gets the output component
  64801. */
  64802. get output(): NodeMaterialConnectionPoint;
  64803. protected _buildBlock(state: NodeMaterialBuildState): this;
  64804. }
  64805. }
  64806. declare module BABYLON {
  64807. /**
  64808. * Block used to compute arc tangent of 2 values
  64809. */
  64810. export class ArcTan2Block extends NodeMaterialBlock {
  64811. /**
  64812. * Creates a new ArcTan2Block
  64813. * @param name defines the block name
  64814. */
  64815. constructor(name: string);
  64816. /**
  64817. * Gets the current class name
  64818. * @returns the class name
  64819. */
  64820. getClassName(): string;
  64821. /**
  64822. * Gets the x operand input component
  64823. */
  64824. get x(): NodeMaterialConnectionPoint;
  64825. /**
  64826. * Gets the y operand input component
  64827. */
  64828. get y(): NodeMaterialConnectionPoint;
  64829. /**
  64830. * Gets the output component
  64831. */
  64832. get output(): NodeMaterialConnectionPoint;
  64833. protected _buildBlock(state: NodeMaterialBuildState): this;
  64834. }
  64835. }
  64836. declare module BABYLON {
  64837. /**
  64838. * Block used to smooth step a value
  64839. */
  64840. export class SmoothStepBlock extends NodeMaterialBlock {
  64841. /**
  64842. * Creates a new SmoothStepBlock
  64843. * @param name defines the block name
  64844. */
  64845. constructor(name: string);
  64846. /**
  64847. * Gets the current class name
  64848. * @returns the class name
  64849. */
  64850. getClassName(): string;
  64851. /**
  64852. * Gets the value operand input component
  64853. */
  64854. get value(): NodeMaterialConnectionPoint;
  64855. /**
  64856. * Gets the first edge operand input component
  64857. */
  64858. get edge0(): NodeMaterialConnectionPoint;
  64859. /**
  64860. * Gets the second edge operand input component
  64861. */
  64862. get edge1(): NodeMaterialConnectionPoint;
  64863. /**
  64864. * Gets the output component
  64865. */
  64866. get output(): NodeMaterialConnectionPoint;
  64867. protected _buildBlock(state: NodeMaterialBuildState): this;
  64868. }
  64869. }
  64870. declare module BABYLON {
  64871. /**
  64872. * Block used to get the reciprocal (1 / x) of a value
  64873. */
  64874. export class ReciprocalBlock extends NodeMaterialBlock {
  64875. /**
  64876. * Creates a new ReciprocalBlock
  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 input component
  64887. */
  64888. get input(): NodeMaterialConnectionPoint;
  64889. /**
  64890. * Gets the output component
  64891. */
  64892. get output(): NodeMaterialConnectionPoint;
  64893. protected _buildBlock(state: NodeMaterialBuildState): this;
  64894. }
  64895. }
  64896. declare module BABYLON {
  64897. /**
  64898. * Block used to replace a color by another one
  64899. */
  64900. export class ReplaceColorBlock extends NodeMaterialBlock {
  64901. /**
  64902. * Creates a new ReplaceColorBlock
  64903. * @param name defines the block name
  64904. */
  64905. constructor(name: string);
  64906. /**
  64907. * Gets the current class name
  64908. * @returns the class name
  64909. */
  64910. getClassName(): string;
  64911. /**
  64912. * Gets the value input component
  64913. */
  64914. get value(): NodeMaterialConnectionPoint;
  64915. /**
  64916. * Gets the reference input component
  64917. */
  64918. get reference(): NodeMaterialConnectionPoint;
  64919. /**
  64920. * Gets the distance input component
  64921. */
  64922. get distance(): NodeMaterialConnectionPoint;
  64923. /**
  64924. * Gets the replacement input component
  64925. */
  64926. get replacement(): NodeMaterialConnectionPoint;
  64927. /**
  64928. * Gets the output component
  64929. */
  64930. get output(): NodeMaterialConnectionPoint;
  64931. protected _buildBlock(state: NodeMaterialBuildState): this;
  64932. }
  64933. }
  64934. declare module BABYLON {
  64935. /**
  64936. * Block used to posterize a value
  64937. * @see https://en.wikipedia.org/wiki/Posterization
  64938. */
  64939. export class PosterizeBlock extends NodeMaterialBlock {
  64940. /**
  64941. * Creates a new PosterizeBlock
  64942. * @param name defines the block name
  64943. */
  64944. constructor(name: string);
  64945. /**
  64946. * Gets the current class name
  64947. * @returns the class name
  64948. */
  64949. getClassName(): string;
  64950. /**
  64951. * Gets the value input component
  64952. */
  64953. get value(): NodeMaterialConnectionPoint;
  64954. /**
  64955. * Gets the steps input component
  64956. */
  64957. get steps(): NodeMaterialConnectionPoint;
  64958. /**
  64959. * Gets the output component
  64960. */
  64961. get output(): NodeMaterialConnectionPoint;
  64962. protected _buildBlock(state: NodeMaterialBuildState): this;
  64963. }
  64964. }
  64965. declare module BABYLON {
  64966. /**
  64967. * Operations supported by the Wave block
  64968. */
  64969. export enum WaveBlockKind {
  64970. /** SawTooth */
  64971. SawTooth = 0,
  64972. /** Square */
  64973. Square = 1,
  64974. /** Triangle */
  64975. Triangle = 2
  64976. }
  64977. /**
  64978. * Block used to apply wave operation to floats
  64979. */
  64980. export class WaveBlock extends NodeMaterialBlock {
  64981. /**
  64982. * Gets or sets the kibnd of wave to be applied by the block
  64983. */
  64984. kind: WaveBlockKind;
  64985. /**
  64986. * Creates a new WaveBlock
  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 input component
  64997. */
  64998. get input(): NodeMaterialConnectionPoint;
  64999. /**
  65000. * Gets the output component
  65001. */
  65002. get output(): NodeMaterialConnectionPoint;
  65003. protected _buildBlock(state: NodeMaterialBuildState): this;
  65004. serialize(): any;
  65005. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65006. }
  65007. }
  65008. declare module BABYLON {
  65009. /**
  65010. * Class used to store a color step for the GradientBlock
  65011. */
  65012. export class GradientBlockColorStep {
  65013. private _step;
  65014. /**
  65015. * Gets value indicating which step this color is associated with (between 0 and 1)
  65016. */
  65017. get step(): number;
  65018. /**
  65019. * Sets a value indicating which step this color is associated with (between 0 and 1)
  65020. */
  65021. set step(val: number);
  65022. private _color;
  65023. /**
  65024. * Gets the color associated with this step
  65025. */
  65026. get color(): Color3;
  65027. /**
  65028. * Sets the color associated with this step
  65029. */
  65030. set color(val: Color3);
  65031. /**
  65032. * Creates a new GradientBlockColorStep
  65033. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65034. * @param color defines the color associated with this step
  65035. */
  65036. constructor(step: number, color: Color3);
  65037. }
  65038. /**
  65039. * Block used to return a color from a gradient based on an input value between 0 and 1
  65040. */
  65041. export class GradientBlock extends NodeMaterialBlock {
  65042. /**
  65043. * Gets or sets the list of color steps
  65044. */
  65045. colorSteps: GradientBlockColorStep[];
  65046. /** Gets an observable raised when the value is changed */
  65047. onValueChangedObservable: Observable<GradientBlock>;
  65048. /** calls observable when the value is changed*/
  65049. colorStepsUpdated(): void;
  65050. /**
  65051. * Creates a new GradientBlock
  65052. * @param name defines the block name
  65053. */
  65054. constructor(name: string);
  65055. /**
  65056. * Gets the current class name
  65057. * @returns the class name
  65058. */
  65059. getClassName(): string;
  65060. /**
  65061. * Gets the gradient input component
  65062. */
  65063. get gradient(): NodeMaterialConnectionPoint;
  65064. /**
  65065. * Gets the output component
  65066. */
  65067. get output(): NodeMaterialConnectionPoint;
  65068. private _writeColorConstant;
  65069. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65070. serialize(): any;
  65071. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65072. protected _dumpPropertiesCode(): string;
  65073. }
  65074. }
  65075. declare module BABYLON {
  65076. /**
  65077. * Block used to normalize lerp between 2 values
  65078. */
  65079. export class NLerpBlock extends NodeMaterialBlock {
  65080. /**
  65081. * Creates a new NLerpBlock
  65082. * @param name defines the block name
  65083. */
  65084. constructor(name: string);
  65085. /**
  65086. * Gets the current class name
  65087. * @returns the class name
  65088. */
  65089. getClassName(): string;
  65090. /**
  65091. * Gets the left operand input component
  65092. */
  65093. get left(): NodeMaterialConnectionPoint;
  65094. /**
  65095. * Gets the right operand input component
  65096. */
  65097. get right(): NodeMaterialConnectionPoint;
  65098. /**
  65099. * Gets the gradient operand input component
  65100. */
  65101. get gradient(): NodeMaterialConnectionPoint;
  65102. /**
  65103. * Gets the output component
  65104. */
  65105. get output(): NodeMaterialConnectionPoint;
  65106. protected _buildBlock(state: NodeMaterialBuildState): this;
  65107. }
  65108. }
  65109. declare module BABYLON {
  65110. /**
  65111. * block used to Generate a Worley Noise 3D Noise Pattern
  65112. */
  65113. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65114. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65115. manhattanDistance: boolean;
  65116. /**
  65117. * Creates a new WorleyNoise3DBlock
  65118. * @param name defines the block name
  65119. */
  65120. constructor(name: string);
  65121. /**
  65122. * Gets the current class name
  65123. * @returns the class name
  65124. */
  65125. getClassName(): string;
  65126. /**
  65127. * Gets the seed input component
  65128. */
  65129. get seed(): NodeMaterialConnectionPoint;
  65130. /**
  65131. * Gets the jitter input component
  65132. */
  65133. get jitter(): NodeMaterialConnectionPoint;
  65134. /**
  65135. * Gets the output component
  65136. */
  65137. get output(): NodeMaterialConnectionPoint;
  65138. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65139. /**
  65140. * Exposes the properties to the UI?
  65141. */
  65142. protected _dumpPropertiesCode(): string;
  65143. /**
  65144. * Exposes the properties to the Seralize?
  65145. */
  65146. serialize(): any;
  65147. /**
  65148. * Exposes the properties to the deseralize?
  65149. */
  65150. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65151. }
  65152. }
  65153. declare module BABYLON {
  65154. /**
  65155. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65156. */
  65157. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65158. /**
  65159. * Creates a new SimplexPerlin3DBlock
  65160. * @param name defines the block name
  65161. */
  65162. constructor(name: string);
  65163. /**
  65164. * Gets the current class name
  65165. * @returns the class name
  65166. */
  65167. getClassName(): string;
  65168. /**
  65169. * Gets the seed operand input component
  65170. */
  65171. get seed(): NodeMaterialConnectionPoint;
  65172. /**
  65173. * Gets the output component
  65174. */
  65175. get output(): NodeMaterialConnectionPoint;
  65176. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65177. }
  65178. }
  65179. declare module BABYLON {
  65180. /**
  65181. * Block used to blend normals
  65182. */
  65183. export class NormalBlendBlock extends NodeMaterialBlock {
  65184. /**
  65185. * Creates a new NormalBlendBlock
  65186. * @param name defines the block name
  65187. */
  65188. constructor(name: string);
  65189. /**
  65190. * Gets the current class name
  65191. * @returns the class name
  65192. */
  65193. getClassName(): string;
  65194. /**
  65195. * Gets the first input component
  65196. */
  65197. get normalMap0(): NodeMaterialConnectionPoint;
  65198. /**
  65199. * Gets the second input component
  65200. */
  65201. get normalMap1(): NodeMaterialConnectionPoint;
  65202. /**
  65203. * Gets the output component
  65204. */
  65205. get output(): NodeMaterialConnectionPoint;
  65206. protected _buildBlock(state: NodeMaterialBuildState): this;
  65207. }
  65208. }
  65209. declare module BABYLON {
  65210. /**
  65211. * Block used to rotate a 2d vector by a given angle
  65212. */
  65213. export class Rotate2dBlock extends NodeMaterialBlock {
  65214. /**
  65215. * Creates a new Rotate2dBlock
  65216. * @param name defines the block name
  65217. */
  65218. constructor(name: string);
  65219. /**
  65220. * Gets the current class name
  65221. * @returns the class name
  65222. */
  65223. getClassName(): string;
  65224. /**
  65225. * Gets the input vector
  65226. */
  65227. get input(): NodeMaterialConnectionPoint;
  65228. /**
  65229. * Gets the input angle
  65230. */
  65231. get angle(): NodeMaterialConnectionPoint;
  65232. /**
  65233. * Gets the output component
  65234. */
  65235. get output(): NodeMaterialConnectionPoint;
  65236. autoConfigure(material: NodeMaterial): void;
  65237. protected _buildBlock(state: NodeMaterialBuildState): this;
  65238. }
  65239. }
  65240. declare module BABYLON {
  65241. /**
  65242. * Block used to get the reflected vector from a direction and a normal
  65243. */
  65244. export class ReflectBlock extends NodeMaterialBlock {
  65245. /**
  65246. * Creates a new ReflectBlock
  65247. * @param name defines the block name
  65248. */
  65249. constructor(name: string);
  65250. /**
  65251. * Gets the current class name
  65252. * @returns the class name
  65253. */
  65254. getClassName(): string;
  65255. /**
  65256. * Gets the incident component
  65257. */
  65258. get incident(): NodeMaterialConnectionPoint;
  65259. /**
  65260. * Gets the normal component
  65261. */
  65262. get normal(): NodeMaterialConnectionPoint;
  65263. /**
  65264. * Gets the output component
  65265. */
  65266. get output(): NodeMaterialConnectionPoint;
  65267. protected _buildBlock(state: NodeMaterialBuildState): this;
  65268. }
  65269. }
  65270. declare module BABYLON {
  65271. /**
  65272. * Block used to get the refracted vector from a direction and a normal
  65273. */
  65274. export class RefractBlock extends NodeMaterialBlock {
  65275. /**
  65276. * Creates a new RefractBlock
  65277. * @param name defines the block name
  65278. */
  65279. constructor(name: string);
  65280. /**
  65281. * Gets the current class name
  65282. * @returns the class name
  65283. */
  65284. getClassName(): string;
  65285. /**
  65286. * Gets the incident component
  65287. */
  65288. get incident(): NodeMaterialConnectionPoint;
  65289. /**
  65290. * Gets the normal component
  65291. */
  65292. get normal(): NodeMaterialConnectionPoint;
  65293. /**
  65294. * Gets the index of refraction component
  65295. */
  65296. get ior(): NodeMaterialConnectionPoint;
  65297. /**
  65298. * Gets the output component
  65299. */
  65300. get output(): NodeMaterialConnectionPoint;
  65301. protected _buildBlock(state: NodeMaterialBuildState): this;
  65302. }
  65303. }
  65304. declare module BABYLON {
  65305. /**
  65306. * Block used to desaturate a color
  65307. */
  65308. export class DesaturateBlock extends NodeMaterialBlock {
  65309. /**
  65310. * Creates a new DesaturateBlock
  65311. * @param name defines the block name
  65312. */
  65313. constructor(name: string);
  65314. /**
  65315. * Gets the current class name
  65316. * @returns the class name
  65317. */
  65318. getClassName(): string;
  65319. /**
  65320. * Gets the color operand input component
  65321. */
  65322. get color(): NodeMaterialConnectionPoint;
  65323. /**
  65324. * Gets the level operand input component
  65325. */
  65326. get level(): NodeMaterialConnectionPoint;
  65327. /**
  65328. * Gets the output component
  65329. */
  65330. get output(): NodeMaterialConnectionPoint;
  65331. protected _buildBlock(state: NodeMaterialBuildState): this;
  65332. }
  65333. }
  65334. declare module BABYLON {
  65335. /**
  65336. * Block used to implement the ambient occlusion module of the PBR material
  65337. */
  65338. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  65339. /**
  65340. * Create a new AmbientOcclusionBlock
  65341. * @param name defines the block name
  65342. */
  65343. constructor(name: string);
  65344. /**
  65345. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  65346. */
  65347. useAmbientInGrayScale: boolean;
  65348. /**
  65349. * Initialize the block and prepare the context for build
  65350. * @param state defines the state that will be used for the build
  65351. */
  65352. initialize(state: NodeMaterialBuildState): void;
  65353. /**
  65354. * Gets the current class name
  65355. * @returns the class name
  65356. */
  65357. getClassName(): string;
  65358. /**
  65359. * Gets the texture input component
  65360. */
  65361. get texture(): NodeMaterialConnectionPoint;
  65362. /**
  65363. * Gets the texture intensity component
  65364. */
  65365. get intensity(): NodeMaterialConnectionPoint;
  65366. /**
  65367. * Gets the direct light intensity input component
  65368. */
  65369. get directLightIntensity(): NodeMaterialConnectionPoint;
  65370. /**
  65371. * Gets the ambient occlusion object output component
  65372. */
  65373. get ambientOcc(): NodeMaterialConnectionPoint;
  65374. /**
  65375. * Gets the main code of the block (fragment side)
  65376. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65377. * @returns the shader code
  65378. */
  65379. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65380. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65381. protected _buildBlock(state: NodeMaterialBuildState): this;
  65382. protected _dumpPropertiesCode(): string;
  65383. serialize(): any;
  65384. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65385. }
  65386. }
  65387. declare module BABYLON {
  65388. /**
  65389. * Block used to implement the reflection module of the PBR material
  65390. */
  65391. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65392. /** @hidden */
  65393. _defineLODReflectionAlpha: string;
  65394. /** @hidden */
  65395. _defineLinearSpecularReflection: string;
  65396. private _vEnvironmentIrradianceName;
  65397. /** @hidden */
  65398. _vReflectionMicrosurfaceInfosName: string;
  65399. /** @hidden */
  65400. _vReflectionInfosName: string;
  65401. /** @hidden */
  65402. _vReflectionFilteringInfoName: string;
  65403. private _scene;
  65404. /**
  65405. * The three properties below are set by the main PBR block prior to calling methods of this class.
  65406. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65407. * It's less burden on the user side in the editor part.
  65408. */
  65409. /** @hidden */
  65410. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65411. /** @hidden */
  65412. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65413. /** @hidden */
  65414. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65415. /**
  65416. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65417. * diffuse part of the IBL.
  65418. */
  65419. useSphericalHarmonics: boolean;
  65420. /**
  65421. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65422. */
  65423. forceIrradianceInFragment: boolean;
  65424. /**
  65425. * Create a new ReflectionBlock
  65426. * @param name defines the block name
  65427. */
  65428. constructor(name: string);
  65429. /**
  65430. * Gets the current class name
  65431. * @returns the class name
  65432. */
  65433. getClassName(): string;
  65434. /**
  65435. * Gets the position input component
  65436. */
  65437. get position(): NodeMaterialConnectionPoint;
  65438. /**
  65439. * Gets the world position input component
  65440. */
  65441. get worldPosition(): NodeMaterialConnectionPoint;
  65442. /**
  65443. * Gets the world normal input component
  65444. */
  65445. get worldNormal(): NodeMaterialConnectionPoint;
  65446. /**
  65447. * Gets the world input component
  65448. */
  65449. get world(): NodeMaterialConnectionPoint;
  65450. /**
  65451. * Gets the camera (or eye) position component
  65452. */
  65453. get cameraPosition(): NodeMaterialConnectionPoint;
  65454. /**
  65455. * Gets the view input component
  65456. */
  65457. get view(): NodeMaterialConnectionPoint;
  65458. /**
  65459. * Gets the color input component
  65460. */
  65461. get color(): NodeMaterialConnectionPoint;
  65462. /**
  65463. * Gets the reflection object output component
  65464. */
  65465. get reflection(): NodeMaterialConnectionPoint;
  65466. /**
  65467. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65468. */
  65469. get hasTexture(): boolean;
  65470. /**
  65471. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65472. */
  65473. get reflectionColor(): string;
  65474. protected _getTexture(): Nullable<BaseTexture>;
  65475. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65476. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65477. /**
  65478. * Gets the code to inject in the vertex shader
  65479. * @param state current state of the node material building
  65480. * @returns the shader code
  65481. */
  65482. handleVertexSide(state: NodeMaterialBuildState): string;
  65483. /**
  65484. * Gets the main code of the block (fragment side)
  65485. * @param state current state of the node material building
  65486. * @param normalVarName name of the existing variable corresponding to the normal
  65487. * @returns the shader code
  65488. */
  65489. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65490. protected _buildBlock(state: NodeMaterialBuildState): this;
  65491. protected _dumpPropertiesCode(): string;
  65492. serialize(): any;
  65493. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65494. }
  65495. }
  65496. declare module BABYLON {
  65497. /**
  65498. * Block used to implement the sheen module of the PBR material
  65499. */
  65500. export class SheenBlock extends NodeMaterialBlock {
  65501. /**
  65502. * Create a new SheenBlock
  65503. * @param name defines the block name
  65504. */
  65505. constructor(name: string);
  65506. /**
  65507. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65508. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65509. * making it easier to setup and tweak the effect
  65510. */
  65511. albedoScaling: boolean;
  65512. /**
  65513. * Defines if the sheen is linked to the sheen color.
  65514. */
  65515. linkSheenWithAlbedo: boolean;
  65516. /**
  65517. * Initialize the block and prepare the context for build
  65518. * @param state defines the state that will be used for the build
  65519. */
  65520. initialize(state: NodeMaterialBuildState): void;
  65521. /**
  65522. * Gets the current class name
  65523. * @returns the class name
  65524. */
  65525. getClassName(): string;
  65526. /**
  65527. * Gets the intensity input component
  65528. */
  65529. get intensity(): NodeMaterialConnectionPoint;
  65530. /**
  65531. * Gets the color input component
  65532. */
  65533. get color(): NodeMaterialConnectionPoint;
  65534. /**
  65535. * Gets the roughness input component
  65536. */
  65537. get roughness(): NodeMaterialConnectionPoint;
  65538. /**
  65539. * Gets the sheen object output component
  65540. */
  65541. get sheen(): NodeMaterialConnectionPoint;
  65542. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65543. /**
  65544. * Gets the main code of the block (fragment side)
  65545. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65546. * @returns the shader code
  65547. */
  65548. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65549. protected _buildBlock(state: NodeMaterialBuildState): this;
  65550. protected _dumpPropertiesCode(): string;
  65551. serialize(): any;
  65552. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65553. }
  65554. }
  65555. declare module BABYLON {
  65556. /**
  65557. * Block used to implement the reflectivity module of the PBR material
  65558. */
  65559. export class ReflectivityBlock extends NodeMaterialBlock {
  65560. private _metallicReflectanceColor;
  65561. private _metallicF0Factor;
  65562. /** @hidden */
  65563. _vMetallicReflectanceFactorsName: string;
  65564. /**
  65565. * The property below is set by the main PBR block prior to calling methods of this class.
  65566. */
  65567. /** @hidden */
  65568. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  65569. /**
  65570. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65571. */
  65572. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65573. /**
  65574. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65575. */
  65576. useMetallnessFromMetallicTextureBlue: boolean;
  65577. /**
  65578. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65579. */
  65580. useRoughnessFromMetallicTextureAlpha: boolean;
  65581. /**
  65582. * Specifies if the metallic texture contains the roughness information in its green channel.
  65583. */
  65584. useRoughnessFromMetallicTextureGreen: boolean;
  65585. /**
  65586. * Create a new ReflectivityBlock
  65587. * @param name defines the block name
  65588. */
  65589. constructor(name: string);
  65590. /**
  65591. * Initialize the block and prepare the context for build
  65592. * @param state defines the state that will be used for the build
  65593. */
  65594. initialize(state: NodeMaterialBuildState): void;
  65595. /**
  65596. * Gets the current class name
  65597. * @returns the class name
  65598. */
  65599. getClassName(): string;
  65600. /**
  65601. * Gets the metallic input component
  65602. */
  65603. get metallic(): NodeMaterialConnectionPoint;
  65604. /**
  65605. * Gets the roughness input component
  65606. */
  65607. get roughness(): NodeMaterialConnectionPoint;
  65608. /**
  65609. * Gets the texture input component
  65610. */
  65611. get texture(): NodeMaterialConnectionPoint;
  65612. /**
  65613. * Gets the reflectivity object output component
  65614. */
  65615. get reflectivity(): NodeMaterialConnectionPoint;
  65616. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65617. /**
  65618. * Gets the main code of the block (fragment side)
  65619. * @param state current state of the node material building
  65620. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65621. * @returns the shader code
  65622. */
  65623. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  65624. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65625. protected _buildBlock(state: NodeMaterialBuildState): this;
  65626. protected _dumpPropertiesCode(): string;
  65627. serialize(): any;
  65628. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65629. }
  65630. }
  65631. declare module BABYLON {
  65632. /**
  65633. * Block used to implement the anisotropy module of the PBR material
  65634. */
  65635. export class AnisotropyBlock extends NodeMaterialBlock {
  65636. /**
  65637. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65638. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65639. * It's less burden on the user side in the editor part.
  65640. */
  65641. /** @hidden */
  65642. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65643. /** @hidden */
  65644. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65645. /**
  65646. * Create a new AnisotropyBlock
  65647. * @param name defines the block name
  65648. */
  65649. constructor(name: string);
  65650. /**
  65651. * Initialize the block and prepare the context for build
  65652. * @param state defines the state that will be used for the build
  65653. */
  65654. initialize(state: NodeMaterialBuildState): void;
  65655. /**
  65656. * Gets the current class name
  65657. * @returns the class name
  65658. */
  65659. getClassName(): string;
  65660. /**
  65661. * Gets the intensity input component
  65662. */
  65663. get intensity(): NodeMaterialConnectionPoint;
  65664. /**
  65665. * Gets the direction input component
  65666. */
  65667. get direction(): NodeMaterialConnectionPoint;
  65668. /**
  65669. * Gets the texture input component
  65670. */
  65671. get texture(): NodeMaterialConnectionPoint;
  65672. /**
  65673. * Gets the uv input component
  65674. */
  65675. get uv(): NodeMaterialConnectionPoint;
  65676. /**
  65677. * Gets the worldTangent input component
  65678. */
  65679. get worldTangent(): NodeMaterialConnectionPoint;
  65680. /**
  65681. * Gets the anisotropy object output component
  65682. */
  65683. get anisotropy(): NodeMaterialConnectionPoint;
  65684. private _generateTBNSpace;
  65685. /**
  65686. * Gets the main code of the block (fragment side)
  65687. * @param state current state of the node material building
  65688. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65689. * @returns the shader code
  65690. */
  65691. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65692. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65693. protected _buildBlock(state: NodeMaterialBuildState): this;
  65694. }
  65695. }
  65696. declare module BABYLON {
  65697. /**
  65698. * Block used to implement the clear coat module of the PBR material
  65699. */
  65700. export class ClearCoatBlock extends NodeMaterialBlock {
  65701. private _scene;
  65702. /**
  65703. * Create a new ClearCoatBlock
  65704. * @param name defines the block name
  65705. */
  65706. constructor(name: string);
  65707. /**
  65708. * Initialize the block and prepare the context for build
  65709. * @param state defines the state that will be used for the build
  65710. */
  65711. initialize(state: NodeMaterialBuildState): void;
  65712. /**
  65713. * Gets the current class name
  65714. * @returns the class name
  65715. */
  65716. getClassName(): string;
  65717. /**
  65718. * Gets the intensity input component
  65719. */
  65720. get intensity(): NodeMaterialConnectionPoint;
  65721. /**
  65722. * Gets the roughness input component
  65723. */
  65724. get roughness(): NodeMaterialConnectionPoint;
  65725. /**
  65726. * Gets the ior input component
  65727. */
  65728. get ior(): NodeMaterialConnectionPoint;
  65729. /**
  65730. * Gets the texture input component
  65731. */
  65732. get texture(): NodeMaterialConnectionPoint;
  65733. /**
  65734. * Gets the bump texture input component
  65735. */
  65736. get bumpTexture(): NodeMaterialConnectionPoint;
  65737. /**
  65738. * Gets the uv input component
  65739. */
  65740. get uv(): NodeMaterialConnectionPoint;
  65741. /**
  65742. * Gets the tint color input component
  65743. */
  65744. get tintColor(): NodeMaterialConnectionPoint;
  65745. /**
  65746. * Gets the tint "at distance" input component
  65747. */
  65748. get tintAtDistance(): NodeMaterialConnectionPoint;
  65749. /**
  65750. * Gets the tint thickness input component
  65751. */
  65752. get tintThickness(): NodeMaterialConnectionPoint;
  65753. /**
  65754. * Gets the world tangent input component
  65755. */
  65756. get worldTangent(): NodeMaterialConnectionPoint;
  65757. /**
  65758. * Gets the clear coat object output component
  65759. */
  65760. get clearcoat(): NodeMaterialConnectionPoint;
  65761. autoConfigure(material: NodeMaterial): void;
  65762. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65763. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65764. private _generateTBNSpace;
  65765. /**
  65766. * Gets the main code of the block (fragment side)
  65767. * @param state current state of the node material building
  65768. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65769. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65770. * @param worldPosVarName name of the variable holding the world position
  65771. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65772. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65773. * @param worldNormalVarName name of the variable holding the world normal
  65774. * @returns the shader code
  65775. */
  65776. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65777. protected _buildBlock(state: NodeMaterialBuildState): this;
  65778. }
  65779. }
  65780. declare module BABYLON {
  65781. /**
  65782. * Block used to implement the sub surface module of the PBR material
  65783. */
  65784. export class SubSurfaceBlock extends NodeMaterialBlock {
  65785. /**
  65786. * Create a new SubSurfaceBlock
  65787. * @param name defines the block name
  65788. */
  65789. constructor(name: string);
  65790. /**
  65791. * Stores the intensity of the different subsurface effects in the thickness texture.
  65792. * * the green channel is the translucency intensity.
  65793. * * the blue channel is the scattering intensity.
  65794. * * the alpha channel is the refraction intensity.
  65795. */
  65796. useMaskFromThicknessTexture: boolean;
  65797. /**
  65798. * Initialize the block and prepare the context for build
  65799. * @param state defines the state that will be used for the build
  65800. */
  65801. initialize(state: NodeMaterialBuildState): void;
  65802. /**
  65803. * Gets the current class name
  65804. * @returns the class name
  65805. */
  65806. getClassName(): string;
  65807. /**
  65808. * Gets the min thickness input component
  65809. */
  65810. get minThickness(): NodeMaterialConnectionPoint;
  65811. /**
  65812. * Gets the max thickness input component
  65813. */
  65814. get maxThickness(): NodeMaterialConnectionPoint;
  65815. /**
  65816. * Gets the thickness texture component
  65817. */
  65818. get thicknessTexture(): NodeMaterialConnectionPoint;
  65819. /**
  65820. * Gets the tint color input component
  65821. */
  65822. get tintColor(): NodeMaterialConnectionPoint;
  65823. /**
  65824. * Gets the translucency intensity input component
  65825. */
  65826. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65827. /**
  65828. * Gets the translucency diffusion distance input component
  65829. */
  65830. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65831. /**
  65832. * Gets the refraction object parameters
  65833. */
  65834. get refraction(): NodeMaterialConnectionPoint;
  65835. /**
  65836. * Gets the sub surface object output component
  65837. */
  65838. get subsurface(): NodeMaterialConnectionPoint;
  65839. autoConfigure(material: NodeMaterial): void;
  65840. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65841. /**
  65842. * Gets the main code of the block (fragment side)
  65843. * @param state current state of the node material building
  65844. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65845. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65846. * @param worldPosVarName name of the variable holding the world position
  65847. * @returns the shader code
  65848. */
  65849. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65850. protected _buildBlock(state: NodeMaterialBuildState): this;
  65851. }
  65852. }
  65853. declare module BABYLON {
  65854. /**
  65855. * Block used to implement the PBR metallic/roughness model
  65856. */
  65857. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65858. /**
  65859. * Gets or sets the light associated with this block
  65860. */
  65861. light: Nullable<Light>;
  65862. private _lightId;
  65863. private _scene;
  65864. private _environmentBRDFTexture;
  65865. private _environmentBrdfSamplerName;
  65866. private _vNormalWName;
  65867. private _invertNormalName;
  65868. /**
  65869. * Create a new ReflectionBlock
  65870. * @param name defines the block name
  65871. */
  65872. constructor(name: string);
  65873. /**
  65874. * Intensity of the direct lights e.g. the four lights available in your scene.
  65875. * This impacts both the direct diffuse and specular highlights.
  65876. */
  65877. directIntensity: number;
  65878. /**
  65879. * Intensity of the environment e.g. how much the environment will light the object
  65880. * either through harmonics for rough material or through the refelction for shiny ones.
  65881. */
  65882. environmentIntensity: number;
  65883. /**
  65884. * This is a special control allowing the reduction of the specular highlights coming from the
  65885. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65886. */
  65887. specularIntensity: number;
  65888. /**
  65889. * Defines the falloff type used in this material.
  65890. * It by default is Physical.
  65891. */
  65892. lightFalloff: number;
  65893. /**
  65894. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65895. */
  65896. useAlphaFromAlbedoTexture: boolean;
  65897. /**
  65898. * Specifies that alpha test should be used
  65899. */
  65900. useAlphaTest: boolean;
  65901. /**
  65902. * Defines the alpha limits in alpha test mode.
  65903. */
  65904. alphaTestCutoff: number;
  65905. /**
  65906. * Specifies that alpha blending should be used
  65907. */
  65908. useAlphaBlending: boolean;
  65909. /**
  65910. * Defines if the alpha value should be determined via the rgb values.
  65911. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65912. */
  65913. opacityRGB: boolean;
  65914. /**
  65915. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65916. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65917. */
  65918. useRadianceOverAlpha: boolean;
  65919. /**
  65920. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65921. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65922. */
  65923. useSpecularOverAlpha: boolean;
  65924. /**
  65925. * Enables specular anti aliasing in the PBR shader.
  65926. * It will both interacts on the Geometry for analytical and IBL lighting.
  65927. * It also prefilter the roughness map based on the bump values.
  65928. */
  65929. enableSpecularAntiAliasing: boolean;
  65930. /**
  65931. * Enables realtime filtering on the texture.
  65932. */
  65933. realTimeFiltering: boolean;
  65934. /**
  65935. * Quality switch for realtime filtering
  65936. */
  65937. realTimeFilteringQuality: number;
  65938. /**
  65939. * Defines if the material uses energy conservation.
  65940. */
  65941. useEnergyConservation: boolean;
  65942. /**
  65943. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65944. * too much the area relying on ambient texture to define their ambient occlusion.
  65945. */
  65946. useRadianceOcclusion: boolean;
  65947. /**
  65948. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65949. * makes the reflect vector face the model (under horizon).
  65950. */
  65951. useHorizonOcclusion: boolean;
  65952. /**
  65953. * If set to true, no lighting calculations will be applied.
  65954. */
  65955. unlit: boolean;
  65956. /**
  65957. * Force normal to face away from face.
  65958. */
  65959. forceNormalForward: boolean;
  65960. /**
  65961. * Defines the material debug mode.
  65962. * It helps seeing only some components of the material while troubleshooting.
  65963. */
  65964. debugMode: number;
  65965. /**
  65966. * Specify from where on screen the debug mode should start.
  65967. * The value goes from -1 (full screen) to 1 (not visible)
  65968. * It helps with side by side comparison against the final render
  65969. * This defaults to 0
  65970. */
  65971. debugLimit: number;
  65972. /**
  65973. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65974. * You can use the factor to better multiply the final value.
  65975. */
  65976. debugFactor: number;
  65977. /**
  65978. * Initialize the block and prepare the context for build
  65979. * @param state defines the state that will be used for the build
  65980. */
  65981. initialize(state: NodeMaterialBuildState): void;
  65982. /**
  65983. * Gets the current class name
  65984. * @returns the class name
  65985. */
  65986. getClassName(): string;
  65987. /**
  65988. * Gets the world position input component
  65989. */
  65990. get worldPosition(): NodeMaterialConnectionPoint;
  65991. /**
  65992. * Gets the world normal input component
  65993. */
  65994. get worldNormal(): NodeMaterialConnectionPoint;
  65995. /**
  65996. * Gets the perturbed normal input component
  65997. */
  65998. get perturbedNormal(): NodeMaterialConnectionPoint;
  65999. /**
  66000. * Gets the camera position input component
  66001. */
  66002. get cameraPosition(): NodeMaterialConnectionPoint;
  66003. /**
  66004. * Gets the base color input component
  66005. */
  66006. get baseColor(): NodeMaterialConnectionPoint;
  66007. /**
  66008. * Gets the opacity texture input component
  66009. */
  66010. get opacityTexture(): NodeMaterialConnectionPoint;
  66011. /**
  66012. * Gets the ambient color input component
  66013. */
  66014. get ambientColor(): NodeMaterialConnectionPoint;
  66015. /**
  66016. * Gets the reflectivity object parameters
  66017. */
  66018. get reflectivity(): NodeMaterialConnectionPoint;
  66019. /**
  66020. * Gets the ambient occlusion object parameters
  66021. */
  66022. get ambientOcc(): NodeMaterialConnectionPoint;
  66023. /**
  66024. * Gets the reflection object parameters
  66025. */
  66026. get reflection(): NodeMaterialConnectionPoint;
  66027. /**
  66028. * Gets the sheen object parameters
  66029. */
  66030. get sheen(): NodeMaterialConnectionPoint;
  66031. /**
  66032. * Gets the clear coat object parameters
  66033. */
  66034. get clearcoat(): NodeMaterialConnectionPoint;
  66035. /**
  66036. * Gets the sub surface object parameters
  66037. */
  66038. get subsurface(): NodeMaterialConnectionPoint;
  66039. /**
  66040. * Gets the anisotropy object parameters
  66041. */
  66042. get anisotropy(): NodeMaterialConnectionPoint;
  66043. /**
  66044. * Gets the view matrix parameter
  66045. */
  66046. get view(): NodeMaterialConnectionPoint;
  66047. /**
  66048. * Gets the ambient output component
  66049. */
  66050. get ambient(): NodeMaterialConnectionPoint;
  66051. /**
  66052. * Gets the diffuse output component
  66053. */
  66054. get diffuse(): NodeMaterialConnectionPoint;
  66055. /**
  66056. * Gets the specular output component
  66057. */
  66058. get specular(): NodeMaterialConnectionPoint;
  66059. /**
  66060. * Gets the sheen output component
  66061. */
  66062. get sheenDir(): NodeMaterialConnectionPoint;
  66063. /**
  66064. * Gets the clear coat output component
  66065. */
  66066. get clearcoatDir(): NodeMaterialConnectionPoint;
  66067. /**
  66068. * Gets the indirect diffuse output component
  66069. */
  66070. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66071. /**
  66072. * Gets the indirect specular output component
  66073. */
  66074. get specularIndirect(): NodeMaterialConnectionPoint;
  66075. /**
  66076. * Gets the indirect sheen output component
  66077. */
  66078. get sheenIndirect(): NodeMaterialConnectionPoint;
  66079. /**
  66080. * Gets the indirect clear coat output component
  66081. */
  66082. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66083. /**
  66084. * Gets the refraction output component
  66085. */
  66086. get refraction(): NodeMaterialConnectionPoint;
  66087. /**
  66088. * Gets the global lighting output component
  66089. */
  66090. get lighting(): NodeMaterialConnectionPoint;
  66091. /**
  66092. * Gets the shadow output component
  66093. */
  66094. get shadow(): NodeMaterialConnectionPoint;
  66095. /**
  66096. * Gets the alpha output component
  66097. */
  66098. get alpha(): NodeMaterialConnectionPoint;
  66099. autoConfigure(material: NodeMaterial): void;
  66100. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66101. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66102. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66103. private _injectVertexCode;
  66104. /**
  66105. * Gets the code corresponding to the albedo/opacity module
  66106. * @returns the shader code
  66107. */
  66108. getAlbedoOpacityCode(): string;
  66109. protected _buildBlock(state: NodeMaterialBuildState): this;
  66110. protected _dumpPropertiesCode(): string;
  66111. serialize(): any;
  66112. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66113. }
  66114. }
  66115. declare module BABYLON {
  66116. /**
  66117. * Block used to compute value of one parameter modulo another
  66118. */
  66119. export class ModBlock extends NodeMaterialBlock {
  66120. /**
  66121. * Creates a new ModBlock
  66122. * @param name defines the block name
  66123. */
  66124. constructor(name: string);
  66125. /**
  66126. * Gets the current class name
  66127. * @returns the class name
  66128. */
  66129. getClassName(): string;
  66130. /**
  66131. * Gets the left operand input component
  66132. */
  66133. get left(): NodeMaterialConnectionPoint;
  66134. /**
  66135. * Gets the right operand input component
  66136. */
  66137. get right(): NodeMaterialConnectionPoint;
  66138. /**
  66139. * Gets the output component
  66140. */
  66141. get output(): NodeMaterialConnectionPoint;
  66142. protected _buildBlock(state: NodeMaterialBuildState): this;
  66143. }
  66144. }
  66145. declare module BABYLON {
  66146. /**
  66147. * Configuration for Draco compression
  66148. */
  66149. export interface IDracoCompressionConfiguration {
  66150. /**
  66151. * Configuration for the decoder.
  66152. */
  66153. decoder: {
  66154. /**
  66155. * The url to the WebAssembly module.
  66156. */
  66157. wasmUrl?: string;
  66158. /**
  66159. * The url to the WebAssembly binary.
  66160. */
  66161. wasmBinaryUrl?: string;
  66162. /**
  66163. * The url to the fallback JavaScript module.
  66164. */
  66165. fallbackUrl?: string;
  66166. };
  66167. }
  66168. /**
  66169. * Draco compression (https://google.github.io/draco/)
  66170. *
  66171. * This class wraps the Draco module.
  66172. *
  66173. * **Encoder**
  66174. *
  66175. * The encoder is not currently implemented.
  66176. *
  66177. * **Decoder**
  66178. *
  66179. * 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.
  66180. *
  66181. * To update the configuration, use the following code:
  66182. * ```javascript
  66183. * DracoCompression.Configuration = {
  66184. * decoder: {
  66185. * wasmUrl: "<url to the WebAssembly library>",
  66186. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66187. * fallbackUrl: "<url to the fallback JavaScript library>",
  66188. * }
  66189. * };
  66190. * ```
  66191. *
  66192. * 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.
  66193. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66194. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66195. *
  66196. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66197. * ```javascript
  66198. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66199. * ```
  66200. *
  66201. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66202. */
  66203. export class DracoCompression implements IDisposable {
  66204. private _workerPoolPromise?;
  66205. private _decoderModulePromise?;
  66206. /**
  66207. * The configuration. Defaults to the following urls:
  66208. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66209. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66210. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66211. */
  66212. static Configuration: IDracoCompressionConfiguration;
  66213. /**
  66214. * Returns true if the decoder configuration is available.
  66215. */
  66216. static get DecoderAvailable(): boolean;
  66217. /**
  66218. * Default number of workers to create when creating the draco compression object.
  66219. */
  66220. static DefaultNumWorkers: number;
  66221. private static GetDefaultNumWorkers;
  66222. private static _Default;
  66223. /**
  66224. * Default instance for the draco compression object.
  66225. */
  66226. static get Default(): DracoCompression;
  66227. /**
  66228. * Constructor
  66229. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66230. */
  66231. constructor(numWorkers?: number);
  66232. /**
  66233. * Stop all async operations and release resources.
  66234. */
  66235. dispose(): void;
  66236. /**
  66237. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66238. * @returns a promise that resolves when ready
  66239. */
  66240. whenReadyAsync(): Promise<void>;
  66241. /**
  66242. * Decode Draco compressed mesh data to vertex data.
  66243. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66244. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66245. * @returns A promise that resolves with the decoded vertex data
  66246. */
  66247. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66248. [kind: string]: number;
  66249. }): Promise<VertexData>;
  66250. }
  66251. }
  66252. declare module BABYLON {
  66253. /**
  66254. * Class for building Constructive Solid Geometry
  66255. */
  66256. export class CSG {
  66257. private polygons;
  66258. /**
  66259. * The world matrix
  66260. */
  66261. matrix: Matrix;
  66262. /**
  66263. * Stores the position
  66264. */
  66265. position: Vector3;
  66266. /**
  66267. * Stores the rotation
  66268. */
  66269. rotation: Vector3;
  66270. /**
  66271. * Stores the rotation quaternion
  66272. */
  66273. rotationQuaternion: Nullable<Quaternion>;
  66274. /**
  66275. * Stores the scaling vector
  66276. */
  66277. scaling: Vector3;
  66278. /**
  66279. * Convert the Mesh to CSG
  66280. * @param mesh The Mesh to convert to CSG
  66281. * @returns A new CSG from the Mesh
  66282. */
  66283. static FromMesh(mesh: Mesh): CSG;
  66284. /**
  66285. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66286. * @param polygons Polygons used to construct a CSG solid
  66287. */
  66288. private static FromPolygons;
  66289. /**
  66290. * Clones, or makes a deep copy, of the CSG
  66291. * @returns A new CSG
  66292. */
  66293. clone(): CSG;
  66294. /**
  66295. * Unions this CSG with another CSG
  66296. * @param csg The CSG to union against this CSG
  66297. * @returns The unioned CSG
  66298. */
  66299. union(csg: CSG): CSG;
  66300. /**
  66301. * Unions this CSG with another CSG in place
  66302. * @param csg The CSG to union against this CSG
  66303. */
  66304. unionInPlace(csg: CSG): void;
  66305. /**
  66306. * Subtracts this CSG with another CSG
  66307. * @param csg The CSG to subtract against this CSG
  66308. * @returns A new CSG
  66309. */
  66310. subtract(csg: CSG): CSG;
  66311. /**
  66312. * Subtracts this CSG with another CSG in place
  66313. * @param csg The CSG to subtact against this CSG
  66314. */
  66315. subtractInPlace(csg: CSG): void;
  66316. /**
  66317. * Intersect this CSG with another CSG
  66318. * @param csg The CSG to intersect against this CSG
  66319. * @returns A new CSG
  66320. */
  66321. intersect(csg: CSG): CSG;
  66322. /**
  66323. * Intersects this CSG with another CSG in place
  66324. * @param csg The CSG to intersect against this CSG
  66325. */
  66326. intersectInPlace(csg: CSG): void;
  66327. /**
  66328. * Return a new CSG solid with solid and empty space switched. This solid is
  66329. * not modified.
  66330. * @returns A new CSG solid with solid and empty space switched
  66331. */
  66332. inverse(): CSG;
  66333. /**
  66334. * Inverses the CSG in place
  66335. */
  66336. inverseInPlace(): void;
  66337. /**
  66338. * This is used to keep meshes transformations so they can be restored
  66339. * when we build back a Babylon Mesh
  66340. * NB : All CSG operations are performed in world coordinates
  66341. * @param csg The CSG to copy the transform attributes from
  66342. * @returns This CSG
  66343. */
  66344. copyTransformAttributes(csg: CSG): CSG;
  66345. /**
  66346. * Build Raw mesh from CSG
  66347. * Coordinates here are in world space
  66348. * @param name The name of the mesh geometry
  66349. * @param scene The Scene
  66350. * @param keepSubMeshes Specifies if the submeshes should be kept
  66351. * @returns A new Mesh
  66352. */
  66353. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66354. /**
  66355. * Build Mesh from CSG taking material and transforms into account
  66356. * @param name The name of the Mesh
  66357. * @param material The material of the Mesh
  66358. * @param scene The Scene
  66359. * @param keepSubMeshes Specifies if submeshes should be kept
  66360. * @returns The new Mesh
  66361. */
  66362. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66363. }
  66364. }
  66365. declare module BABYLON {
  66366. /**
  66367. * Class used to create a trail following a mesh
  66368. */
  66369. export class TrailMesh extends Mesh {
  66370. private _generator;
  66371. private _autoStart;
  66372. private _running;
  66373. private _diameter;
  66374. private _length;
  66375. private _sectionPolygonPointsCount;
  66376. private _sectionVectors;
  66377. private _sectionNormalVectors;
  66378. private _beforeRenderObserver;
  66379. /**
  66380. * @constructor
  66381. * @param name The value used by scene.getMeshByName() to do a lookup.
  66382. * @param generator The mesh or transform node to generate a trail.
  66383. * @param scene The scene to add this mesh to.
  66384. * @param diameter Diameter of trailing mesh. Default is 1.
  66385. * @param length Length of trailing mesh. Default is 60.
  66386. * @param autoStart Automatically start trailing mesh. Default true.
  66387. */
  66388. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66389. /**
  66390. * "TrailMesh"
  66391. * @returns "TrailMesh"
  66392. */
  66393. getClassName(): string;
  66394. private _createMesh;
  66395. /**
  66396. * Start trailing mesh.
  66397. */
  66398. start(): void;
  66399. /**
  66400. * Stop trailing mesh.
  66401. */
  66402. stop(): void;
  66403. /**
  66404. * Update trailing mesh geometry.
  66405. */
  66406. update(): void;
  66407. /**
  66408. * Returns a new TrailMesh object.
  66409. * @param name is a string, the name given to the new mesh
  66410. * @param newGenerator use new generator object for cloned trail mesh
  66411. * @returns a new mesh
  66412. */
  66413. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66414. /**
  66415. * Serializes this trail mesh
  66416. * @param serializationObject object to write serialization to
  66417. */
  66418. serialize(serializationObject: any): void;
  66419. /**
  66420. * Parses a serialized trail mesh
  66421. * @param parsedMesh the serialized mesh
  66422. * @param scene the scene to create the trail mesh in
  66423. * @returns the created trail mesh
  66424. */
  66425. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66426. }
  66427. }
  66428. declare module BABYLON {
  66429. /**
  66430. * Class containing static functions to help procedurally build meshes
  66431. */
  66432. export class TiledBoxBuilder {
  66433. /**
  66434. * Creates a box mesh
  66435. * 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)
  66436. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66438. * * 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
  66439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66440. * @param name defines the name of the mesh
  66441. * @param options defines the options used to create the mesh
  66442. * @param scene defines the hosting scene
  66443. * @returns the box mesh
  66444. */
  66445. static CreateTiledBox(name: string, options: {
  66446. pattern?: number;
  66447. width?: number;
  66448. height?: number;
  66449. depth?: number;
  66450. tileSize?: number;
  66451. tileWidth?: number;
  66452. tileHeight?: number;
  66453. alignHorizontal?: number;
  66454. alignVertical?: number;
  66455. faceUV?: Vector4[];
  66456. faceColors?: Color4[];
  66457. sideOrientation?: number;
  66458. updatable?: boolean;
  66459. }, scene?: Nullable<Scene>): Mesh;
  66460. }
  66461. }
  66462. declare module BABYLON {
  66463. /**
  66464. * Class containing static functions to help procedurally build meshes
  66465. */
  66466. export class TorusKnotBuilder {
  66467. /**
  66468. * Creates a torus knot mesh
  66469. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66470. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66471. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66472. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66474. * * 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
  66475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66476. * @param name defines the name of the mesh
  66477. * @param options defines the options used to create the mesh
  66478. * @param scene defines the hosting scene
  66479. * @returns the torus knot mesh
  66480. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66481. */
  66482. static CreateTorusKnot(name: string, options: {
  66483. radius?: number;
  66484. tube?: number;
  66485. radialSegments?: number;
  66486. tubularSegments?: number;
  66487. p?: number;
  66488. q?: number;
  66489. updatable?: boolean;
  66490. sideOrientation?: number;
  66491. frontUVs?: Vector4;
  66492. backUVs?: Vector4;
  66493. }, scene: any): Mesh;
  66494. }
  66495. }
  66496. declare module BABYLON {
  66497. /**
  66498. * Polygon
  66499. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66500. */
  66501. export class Polygon {
  66502. /**
  66503. * Creates a rectangle
  66504. * @param xmin bottom X coord
  66505. * @param ymin bottom Y coord
  66506. * @param xmax top X coord
  66507. * @param ymax top Y coord
  66508. * @returns points that make the resulting rectation
  66509. */
  66510. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66511. /**
  66512. * Creates a circle
  66513. * @param radius radius of circle
  66514. * @param cx scale in x
  66515. * @param cy scale in y
  66516. * @param numberOfSides number of sides that make up the circle
  66517. * @returns points that make the resulting circle
  66518. */
  66519. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66520. /**
  66521. * Creates a polygon from input string
  66522. * @param input Input polygon data
  66523. * @returns the parsed points
  66524. */
  66525. static Parse(input: string): Vector2[];
  66526. /**
  66527. * Starts building a polygon from x and y coordinates
  66528. * @param x x coordinate
  66529. * @param y y coordinate
  66530. * @returns the started path2
  66531. */
  66532. static StartingAt(x: number, y: number): Path2;
  66533. }
  66534. /**
  66535. * Builds a polygon
  66536. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66537. */
  66538. export class PolygonMeshBuilder {
  66539. private _points;
  66540. private _outlinepoints;
  66541. private _holes;
  66542. private _name;
  66543. private _scene;
  66544. private _epoints;
  66545. private _eholes;
  66546. private _addToepoint;
  66547. /**
  66548. * Babylon reference to the earcut plugin.
  66549. */
  66550. bjsEarcut: any;
  66551. /**
  66552. * Creates a PolygonMeshBuilder
  66553. * @param name name of the builder
  66554. * @param contours Path of the polygon
  66555. * @param scene scene to add to when creating the mesh
  66556. * @param earcutInjection can be used to inject your own earcut reference
  66557. */
  66558. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66559. /**
  66560. * Adds a whole within the polygon
  66561. * @param hole Array of points defining the hole
  66562. * @returns this
  66563. */
  66564. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66565. /**
  66566. * Creates the polygon
  66567. * @param updatable If the mesh should be updatable
  66568. * @param depth The depth of the mesh created
  66569. * @returns the created mesh
  66570. */
  66571. build(updatable?: boolean, depth?: number): Mesh;
  66572. /**
  66573. * Creates the polygon
  66574. * @param depth The depth of the mesh created
  66575. * @returns the created VertexData
  66576. */
  66577. buildVertexData(depth?: number): VertexData;
  66578. /**
  66579. * Adds a side to the polygon
  66580. * @param positions points that make the polygon
  66581. * @param normals normals of the polygon
  66582. * @param uvs uvs of the polygon
  66583. * @param indices indices of the polygon
  66584. * @param bounds bounds of the polygon
  66585. * @param points points of the polygon
  66586. * @param depth depth of the polygon
  66587. * @param flip flip of the polygon
  66588. */
  66589. private addSide;
  66590. }
  66591. }
  66592. declare module BABYLON {
  66593. /**
  66594. * Class containing static functions to help procedurally build meshes
  66595. */
  66596. export class PolygonBuilder {
  66597. /**
  66598. * Creates a polygon mesh
  66599. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66600. * * 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
  66601. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66603. * * 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)
  66604. * * Remember you can only change the shape positions, not their number when updating a polygon
  66605. * @param name defines the name of the mesh
  66606. * @param options defines the options used to create the mesh
  66607. * @param scene defines the hosting scene
  66608. * @param earcutInjection can be used to inject your own earcut reference
  66609. * @returns the polygon mesh
  66610. */
  66611. static CreatePolygon(name: string, options: {
  66612. shape: Vector3[];
  66613. holes?: Vector3[][];
  66614. depth?: number;
  66615. faceUV?: Vector4[];
  66616. faceColors?: Color4[];
  66617. updatable?: boolean;
  66618. sideOrientation?: number;
  66619. frontUVs?: Vector4;
  66620. backUVs?: Vector4;
  66621. wrap?: boolean;
  66622. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66623. /**
  66624. * Creates an extruded polygon mesh, with depth in the Y direction.
  66625. * * 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)
  66626. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66627. * @param name defines the name of the mesh
  66628. * @param options defines the options used to create the mesh
  66629. * @param scene defines the hosting scene
  66630. * @param earcutInjection can be used to inject your own earcut reference
  66631. * @returns the polygon mesh
  66632. */
  66633. static ExtrudePolygon(name: string, options: {
  66634. shape: Vector3[];
  66635. holes?: Vector3[][];
  66636. depth?: number;
  66637. faceUV?: Vector4[];
  66638. faceColors?: Color4[];
  66639. updatable?: boolean;
  66640. sideOrientation?: number;
  66641. frontUVs?: Vector4;
  66642. backUVs?: Vector4;
  66643. wrap?: boolean;
  66644. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66645. }
  66646. }
  66647. declare module BABYLON {
  66648. /**
  66649. * Class containing static functions to help procedurally build meshes
  66650. */
  66651. export class LatheBuilder {
  66652. /**
  66653. * Creates lathe mesh.
  66654. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66655. * * 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
  66656. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66657. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66658. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66659. * * 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
  66660. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66661. * * 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
  66662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66663. * * 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
  66664. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66666. * @param name defines the name of the mesh
  66667. * @param options defines the options used to create the mesh
  66668. * @param scene defines the hosting scene
  66669. * @returns the lathe mesh
  66670. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66671. */
  66672. static CreateLathe(name: string, options: {
  66673. shape: Vector3[];
  66674. radius?: number;
  66675. tessellation?: number;
  66676. clip?: number;
  66677. arc?: number;
  66678. closed?: boolean;
  66679. updatable?: boolean;
  66680. sideOrientation?: number;
  66681. frontUVs?: Vector4;
  66682. backUVs?: Vector4;
  66683. cap?: number;
  66684. invertUV?: boolean;
  66685. }, scene?: Nullable<Scene>): Mesh;
  66686. }
  66687. }
  66688. declare module BABYLON {
  66689. /**
  66690. * Class containing static functions to help procedurally build meshes
  66691. */
  66692. export class TiledPlaneBuilder {
  66693. /**
  66694. * Creates a tiled plane mesh
  66695. * * The parameter `pattern` will, depending on value, do nothing or
  66696. * * * flip (reflect about central vertical) alternate tiles across and up
  66697. * * * flip every tile on alternate rows
  66698. * * * rotate (180 degs) alternate tiles across and up
  66699. * * * rotate every tile on alternate rows
  66700. * * * flip and rotate alternate tiles across and up
  66701. * * * flip and rotate every tile on alternate rows
  66702. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66703. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66704. * * 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
  66705. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66706. * * 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)
  66707. * * 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)
  66708. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66709. * @param name defines the name of the mesh
  66710. * @param options defines the options used to create the mesh
  66711. * @param scene defines the hosting scene
  66712. * @returns the box mesh
  66713. */
  66714. static CreateTiledPlane(name: string, options: {
  66715. pattern?: number;
  66716. tileSize?: number;
  66717. tileWidth?: number;
  66718. tileHeight?: number;
  66719. size?: number;
  66720. width?: number;
  66721. height?: number;
  66722. alignHorizontal?: number;
  66723. alignVertical?: number;
  66724. sideOrientation?: number;
  66725. frontUVs?: Vector4;
  66726. backUVs?: Vector4;
  66727. updatable?: boolean;
  66728. }, scene?: Nullable<Scene>): Mesh;
  66729. }
  66730. }
  66731. declare module BABYLON {
  66732. /**
  66733. * Class containing static functions to help procedurally build meshes
  66734. */
  66735. export class TubeBuilder {
  66736. /**
  66737. * Creates a tube mesh.
  66738. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66739. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66740. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66741. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66742. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66743. * * 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)
  66744. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66745. * * 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
  66746. * * 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
  66747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66748. * * 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
  66749. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66751. * @param name defines the name of the mesh
  66752. * @param options defines the options used to create the mesh
  66753. * @param scene defines the hosting scene
  66754. * @returns the tube mesh
  66755. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66756. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66757. */
  66758. static CreateTube(name: string, options: {
  66759. path: Vector3[];
  66760. radius?: number;
  66761. tessellation?: number;
  66762. radiusFunction?: {
  66763. (i: number, distance: number): number;
  66764. };
  66765. cap?: number;
  66766. arc?: number;
  66767. updatable?: boolean;
  66768. sideOrientation?: number;
  66769. frontUVs?: Vector4;
  66770. backUVs?: Vector4;
  66771. instance?: Mesh;
  66772. invertUV?: boolean;
  66773. }, scene?: Nullable<Scene>): Mesh;
  66774. }
  66775. }
  66776. declare module BABYLON {
  66777. /**
  66778. * Class containing static functions to help procedurally build meshes
  66779. */
  66780. export class IcoSphereBuilder {
  66781. /**
  66782. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66783. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66784. * * 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`)
  66785. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66786. * * 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
  66787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66788. * * 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
  66789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66790. * @param name defines the name of the mesh
  66791. * @param options defines the options used to create the mesh
  66792. * @param scene defines the hosting scene
  66793. * @returns the icosahedron mesh
  66794. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66795. */
  66796. static CreateIcoSphere(name: string, options: {
  66797. radius?: number;
  66798. radiusX?: number;
  66799. radiusY?: number;
  66800. radiusZ?: number;
  66801. flat?: boolean;
  66802. subdivisions?: number;
  66803. sideOrientation?: number;
  66804. frontUVs?: Vector4;
  66805. backUVs?: Vector4;
  66806. updatable?: boolean;
  66807. }, scene?: Nullable<Scene>): Mesh;
  66808. }
  66809. }
  66810. declare module BABYLON {
  66811. /**
  66812. * Class containing static functions to help procedurally build meshes
  66813. */
  66814. export class DecalBuilder {
  66815. /**
  66816. * Creates a decal mesh.
  66817. * 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
  66818. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66819. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66820. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66821. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66822. * @param name defines the name of the mesh
  66823. * @param sourceMesh defines the mesh where the decal must be applied
  66824. * @param options defines the options used to create the mesh
  66825. * @param scene defines the hosting scene
  66826. * @returns the decal mesh
  66827. * @see https://doc.babylonjs.com/how_to/decals
  66828. */
  66829. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66830. position?: Vector3;
  66831. normal?: Vector3;
  66832. size?: Vector3;
  66833. angle?: number;
  66834. }): Mesh;
  66835. }
  66836. }
  66837. declare module BABYLON {
  66838. /**
  66839. * Class containing static functions to help procedurally build meshes
  66840. */
  66841. export class MeshBuilder {
  66842. /**
  66843. * Creates a box mesh
  66844. * * The parameter `size` sets the size (float) of each box side (default 1)
  66845. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66846. * * 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)
  66847. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66849. * * 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
  66850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66851. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66852. * @param name defines the name of the mesh
  66853. * @param options defines the options used to create the mesh
  66854. * @param scene defines the hosting scene
  66855. * @returns the box mesh
  66856. */
  66857. static CreateBox(name: string, options: {
  66858. size?: number;
  66859. width?: number;
  66860. height?: number;
  66861. depth?: number;
  66862. faceUV?: Vector4[];
  66863. faceColors?: Color4[];
  66864. sideOrientation?: number;
  66865. frontUVs?: Vector4;
  66866. backUVs?: Vector4;
  66867. wrap?: boolean;
  66868. topBaseAt?: number;
  66869. bottomBaseAt?: number;
  66870. updatable?: boolean;
  66871. }, scene?: Nullable<Scene>): Mesh;
  66872. /**
  66873. * Creates a tiled box mesh
  66874. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66876. * @param name defines the name of the mesh
  66877. * @param options defines the options used to create the mesh
  66878. * @param scene defines the hosting scene
  66879. * @returns the tiled box mesh
  66880. */
  66881. static CreateTiledBox(name: string, options: {
  66882. pattern?: number;
  66883. size?: number;
  66884. width?: number;
  66885. height?: number;
  66886. depth: number;
  66887. tileSize?: number;
  66888. tileWidth?: number;
  66889. tileHeight?: number;
  66890. faceUV?: Vector4[];
  66891. faceColors?: Color4[];
  66892. alignHorizontal?: number;
  66893. alignVertical?: number;
  66894. sideOrientation?: number;
  66895. updatable?: boolean;
  66896. }, scene?: Nullable<Scene>): Mesh;
  66897. /**
  66898. * Creates a sphere mesh
  66899. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66900. * * 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`)
  66901. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66902. * * 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
  66903. * * 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)
  66904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66905. * * 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
  66906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66907. * @param name defines the name of the mesh
  66908. * @param options defines the options used to create the mesh
  66909. * @param scene defines the hosting scene
  66910. * @returns the sphere mesh
  66911. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66912. */
  66913. static CreateSphere(name: string, options: {
  66914. segments?: number;
  66915. diameter?: number;
  66916. diameterX?: number;
  66917. diameterY?: number;
  66918. diameterZ?: number;
  66919. arc?: number;
  66920. slice?: number;
  66921. sideOrientation?: number;
  66922. frontUVs?: Vector4;
  66923. backUVs?: Vector4;
  66924. updatable?: boolean;
  66925. }, scene?: Nullable<Scene>): Mesh;
  66926. /**
  66927. * Creates a plane polygonal mesh. By default, this is a disc
  66928. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66929. * * 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
  66930. * * 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
  66931. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66932. * * 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
  66933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66934. * @param name defines the name of the mesh
  66935. * @param options defines the options used to create the mesh
  66936. * @param scene defines the hosting scene
  66937. * @returns the plane polygonal mesh
  66938. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66939. */
  66940. static CreateDisc(name: string, options: {
  66941. radius?: number;
  66942. tessellation?: number;
  66943. arc?: number;
  66944. updatable?: boolean;
  66945. sideOrientation?: number;
  66946. frontUVs?: Vector4;
  66947. backUVs?: Vector4;
  66948. }, scene?: Nullable<Scene>): Mesh;
  66949. /**
  66950. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66951. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66952. * * 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`)
  66953. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66954. * * 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
  66955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66956. * * 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
  66957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66958. * @param name defines the name of the mesh
  66959. * @param options defines the options used to create the mesh
  66960. * @param scene defines the hosting scene
  66961. * @returns the icosahedron mesh
  66962. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66963. */
  66964. static CreateIcoSphere(name: string, options: {
  66965. radius?: number;
  66966. radiusX?: number;
  66967. radiusY?: number;
  66968. radiusZ?: number;
  66969. flat?: boolean;
  66970. subdivisions?: number;
  66971. sideOrientation?: number;
  66972. frontUVs?: Vector4;
  66973. backUVs?: Vector4;
  66974. updatable?: boolean;
  66975. }, scene?: Nullable<Scene>): Mesh;
  66976. /**
  66977. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66978. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66979. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66980. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66981. * * 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
  66982. * * 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
  66983. * * 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
  66984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66985. * * 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
  66986. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66987. * * 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
  66988. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66989. * * 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
  66990. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66992. * @param name defines the name of the mesh
  66993. * @param options defines the options used to create the mesh
  66994. * @param scene defines the hosting scene
  66995. * @returns the ribbon mesh
  66996. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66997. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66998. */
  66999. static CreateRibbon(name: string, options: {
  67000. pathArray: Vector3[][];
  67001. closeArray?: boolean;
  67002. closePath?: boolean;
  67003. offset?: number;
  67004. updatable?: boolean;
  67005. sideOrientation?: number;
  67006. frontUVs?: Vector4;
  67007. backUVs?: Vector4;
  67008. instance?: Mesh;
  67009. invertUV?: boolean;
  67010. uvs?: Vector2[];
  67011. colors?: Color4[];
  67012. }, scene?: Nullable<Scene>): Mesh;
  67013. /**
  67014. * Creates a cylinder or a cone mesh
  67015. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67016. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67017. * * 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.
  67018. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67019. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67020. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67021. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67022. * * 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).
  67023. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67024. * * 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).
  67025. * * 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
  67026. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67027. * * 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
  67028. * * 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.
  67029. * * If `enclose` is false, a ring surface is one element.
  67030. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67031. * * 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
  67032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67033. * * 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
  67034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67035. * @param name defines the name of the mesh
  67036. * @param options defines the options used to create the mesh
  67037. * @param scene defines the hosting scene
  67038. * @returns the cylinder mesh
  67039. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67040. */
  67041. static CreateCylinder(name: string, options: {
  67042. height?: number;
  67043. diameterTop?: number;
  67044. diameterBottom?: number;
  67045. diameter?: number;
  67046. tessellation?: number;
  67047. subdivisions?: number;
  67048. arc?: number;
  67049. faceColors?: Color4[];
  67050. faceUV?: Vector4[];
  67051. updatable?: boolean;
  67052. hasRings?: boolean;
  67053. enclose?: boolean;
  67054. cap?: number;
  67055. sideOrientation?: number;
  67056. frontUVs?: Vector4;
  67057. backUVs?: Vector4;
  67058. }, scene?: Nullable<Scene>): Mesh;
  67059. /**
  67060. * Creates a torus mesh
  67061. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67062. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67063. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67065. * * 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
  67066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67067. * @param name defines the name of the mesh
  67068. * @param options defines the options used to create the mesh
  67069. * @param scene defines the hosting scene
  67070. * @returns the torus mesh
  67071. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67072. */
  67073. static CreateTorus(name: string, options: {
  67074. diameter?: number;
  67075. thickness?: number;
  67076. tessellation?: number;
  67077. updatable?: boolean;
  67078. sideOrientation?: number;
  67079. frontUVs?: Vector4;
  67080. backUVs?: Vector4;
  67081. }, scene?: Nullable<Scene>): Mesh;
  67082. /**
  67083. * Creates a torus knot mesh
  67084. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67085. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67086. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67087. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67089. * * 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
  67090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67091. * @param name defines the name of the mesh
  67092. * @param options defines the options used to create the mesh
  67093. * @param scene defines the hosting scene
  67094. * @returns the torus knot mesh
  67095. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67096. */
  67097. static CreateTorusKnot(name: string, options: {
  67098. radius?: number;
  67099. tube?: number;
  67100. radialSegments?: number;
  67101. tubularSegments?: number;
  67102. p?: number;
  67103. q?: number;
  67104. updatable?: boolean;
  67105. sideOrientation?: number;
  67106. frontUVs?: Vector4;
  67107. backUVs?: Vector4;
  67108. }, scene?: Nullable<Scene>): Mesh;
  67109. /**
  67110. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67111. * * 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
  67112. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67113. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67114. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67115. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67116. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67117. * * 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
  67118. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67120. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67121. * @param name defines the name of the new line system
  67122. * @param options defines the options used to create the line system
  67123. * @param scene defines the hosting scene
  67124. * @returns a new line system mesh
  67125. */
  67126. static CreateLineSystem(name: string, options: {
  67127. lines: Vector3[][];
  67128. updatable?: boolean;
  67129. instance?: Nullable<LinesMesh>;
  67130. colors?: Nullable<Color4[][]>;
  67131. useVertexAlpha?: boolean;
  67132. }, scene: Nullable<Scene>): LinesMesh;
  67133. /**
  67134. * Creates a line mesh
  67135. * 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
  67136. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67137. * * The parameter `points` is an array successive Vector3
  67138. * * 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
  67139. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67140. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67141. * * When updating an instance, remember that only point positions can change, not the number of points
  67142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67143. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67144. * @param name defines the name of the new line system
  67145. * @param options defines the options used to create the line system
  67146. * @param scene defines the hosting scene
  67147. * @returns a new line mesh
  67148. */
  67149. static CreateLines(name: string, options: {
  67150. points: Vector3[];
  67151. updatable?: boolean;
  67152. instance?: Nullable<LinesMesh>;
  67153. colors?: Color4[];
  67154. useVertexAlpha?: boolean;
  67155. }, scene?: Nullable<Scene>): LinesMesh;
  67156. /**
  67157. * Creates a dashed line mesh
  67158. * * 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
  67159. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67160. * * The parameter `points` is an array successive Vector3
  67161. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67162. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67163. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67164. * * 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
  67165. * * When updating an instance, remember that only point positions can change, not the number of points
  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 dashed line mesh
  67171. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67172. */
  67173. static CreateDashedLines(name: string, options: {
  67174. points: Vector3[];
  67175. dashSize?: number;
  67176. gapSize?: number;
  67177. dashNb?: number;
  67178. updatable?: boolean;
  67179. instance?: LinesMesh;
  67180. }, scene?: Nullable<Scene>): LinesMesh;
  67181. /**
  67182. * 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.
  67183. * * 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.
  67184. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67185. * * 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.
  67186. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67187. * * 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
  67188. * * 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
  67189. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67191. * * 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
  67192. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67194. * @param name defines the name of the mesh
  67195. * @param options defines the options used to create the mesh
  67196. * @param scene defines the hosting scene
  67197. * @returns the extruded shape mesh
  67198. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67199. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67200. */
  67201. static ExtrudeShape(name: string, options: {
  67202. shape: Vector3[];
  67203. path: Vector3[];
  67204. scale?: number;
  67205. rotation?: number;
  67206. cap?: number;
  67207. updatable?: boolean;
  67208. sideOrientation?: number;
  67209. frontUVs?: Vector4;
  67210. backUVs?: Vector4;
  67211. instance?: Mesh;
  67212. invertUV?: boolean;
  67213. }, scene?: Nullable<Scene>): Mesh;
  67214. /**
  67215. * Creates an custom extruded shape mesh.
  67216. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67217. * * 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.
  67218. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67219. * * 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
  67220. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67221. * * 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
  67222. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67223. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67224. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67225. * * 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
  67226. * * 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
  67227. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67229. * * 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
  67230. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67232. * @param name defines the name of the mesh
  67233. * @param options defines the options used to create the mesh
  67234. * @param scene defines the hosting scene
  67235. * @returns the custom extruded shape mesh
  67236. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67237. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67238. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67239. */
  67240. static ExtrudeShapeCustom(name: string, options: {
  67241. shape: Vector3[];
  67242. path: Vector3[];
  67243. scaleFunction?: any;
  67244. rotationFunction?: any;
  67245. ribbonCloseArray?: boolean;
  67246. ribbonClosePath?: boolean;
  67247. cap?: number;
  67248. updatable?: boolean;
  67249. sideOrientation?: number;
  67250. frontUVs?: Vector4;
  67251. backUVs?: Vector4;
  67252. instance?: Mesh;
  67253. invertUV?: boolean;
  67254. }, scene?: Nullable<Scene>): Mesh;
  67255. /**
  67256. * Creates lathe mesh.
  67257. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67258. * * 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
  67259. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67260. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67261. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67262. * * 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
  67263. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67264. * * 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
  67265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67266. * * 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
  67267. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67269. * @param name defines the name of the mesh
  67270. * @param options defines the options used to create the mesh
  67271. * @param scene defines the hosting scene
  67272. * @returns the lathe mesh
  67273. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67274. */
  67275. static CreateLathe(name: string, options: {
  67276. shape: Vector3[];
  67277. radius?: number;
  67278. tessellation?: number;
  67279. clip?: number;
  67280. arc?: number;
  67281. closed?: boolean;
  67282. updatable?: boolean;
  67283. sideOrientation?: number;
  67284. frontUVs?: Vector4;
  67285. backUVs?: Vector4;
  67286. cap?: number;
  67287. invertUV?: boolean;
  67288. }, scene?: Nullable<Scene>): Mesh;
  67289. /**
  67290. * Creates a tiled plane mesh
  67291. * * You can set a limited pattern arrangement with the tiles
  67292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67293. * * 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
  67294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67295. * @param name defines the name of the mesh
  67296. * @param options defines the options used to create the mesh
  67297. * @param scene defines the hosting scene
  67298. * @returns the plane mesh
  67299. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67300. */
  67301. static CreateTiledPlane(name: string, options: {
  67302. pattern?: number;
  67303. tileSize?: number;
  67304. tileWidth?: number;
  67305. tileHeight?: number;
  67306. size?: number;
  67307. width?: number;
  67308. height?: number;
  67309. alignHorizontal?: number;
  67310. alignVertical?: number;
  67311. sideOrientation?: number;
  67312. frontUVs?: Vector4;
  67313. backUVs?: Vector4;
  67314. updatable?: boolean;
  67315. }, scene?: Nullable<Scene>): Mesh;
  67316. /**
  67317. * Creates a plane mesh
  67318. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67319. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67320. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67322. * * 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
  67323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67324. * @param name defines the name of the mesh
  67325. * @param options defines the options used to create the mesh
  67326. * @param scene defines the hosting scene
  67327. * @returns the plane mesh
  67328. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67329. */
  67330. static CreatePlane(name: string, options: {
  67331. size?: number;
  67332. width?: number;
  67333. height?: number;
  67334. sideOrientation?: number;
  67335. frontUVs?: Vector4;
  67336. backUVs?: Vector4;
  67337. updatable?: boolean;
  67338. sourcePlane?: Plane;
  67339. }, scene?: Nullable<Scene>): Mesh;
  67340. /**
  67341. * Creates a ground mesh
  67342. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67343. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67345. * @param name defines the name of the mesh
  67346. * @param options defines the options used to create the mesh
  67347. * @param scene defines the hosting scene
  67348. * @returns the ground mesh
  67349. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67350. */
  67351. static CreateGround(name: string, options: {
  67352. width?: number;
  67353. height?: number;
  67354. subdivisions?: number;
  67355. subdivisionsX?: number;
  67356. subdivisionsY?: number;
  67357. updatable?: boolean;
  67358. }, scene?: Nullable<Scene>): Mesh;
  67359. /**
  67360. * Creates a tiled ground mesh
  67361. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67362. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67363. * * 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
  67364. * * 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
  67365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67366. * @param name defines the name of the mesh
  67367. * @param options defines the options used to create the mesh
  67368. * @param scene defines the hosting scene
  67369. * @returns the tiled ground mesh
  67370. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67371. */
  67372. static CreateTiledGround(name: string, options: {
  67373. xmin: number;
  67374. zmin: number;
  67375. xmax: number;
  67376. zmax: number;
  67377. subdivisions?: {
  67378. w: number;
  67379. h: number;
  67380. };
  67381. precision?: {
  67382. w: number;
  67383. h: number;
  67384. };
  67385. updatable?: boolean;
  67386. }, scene?: Nullable<Scene>): Mesh;
  67387. /**
  67388. * Creates a ground mesh from a height map
  67389. * * The parameter `url` sets the URL of the height map image resource.
  67390. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67391. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67392. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67393. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67394. * * 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.
  67395. * * 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).
  67396. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67398. * @param name defines the name of the mesh
  67399. * @param url defines the url to the height map
  67400. * @param options defines the options used to create the mesh
  67401. * @param scene defines the hosting scene
  67402. * @returns the ground mesh
  67403. * @see https://doc.babylonjs.com/babylon101/height_map
  67404. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67405. */
  67406. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67407. width?: number;
  67408. height?: number;
  67409. subdivisions?: number;
  67410. minHeight?: number;
  67411. maxHeight?: number;
  67412. colorFilter?: Color3;
  67413. alphaFilter?: number;
  67414. updatable?: boolean;
  67415. onReady?: (mesh: GroundMesh) => void;
  67416. }, scene?: Nullable<Scene>): GroundMesh;
  67417. /**
  67418. * Creates a polygon mesh
  67419. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67420. * * 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
  67421. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67423. * * 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)
  67424. * * Remember you can only change the shape positions, not their number when updating a polygon
  67425. * @param name defines the name of the mesh
  67426. * @param options defines the options used to create the mesh
  67427. * @param scene defines the hosting scene
  67428. * @param earcutInjection can be used to inject your own earcut reference
  67429. * @returns the polygon mesh
  67430. */
  67431. static CreatePolygon(name: string, options: {
  67432. shape: Vector3[];
  67433. holes?: Vector3[][];
  67434. depth?: number;
  67435. faceUV?: Vector4[];
  67436. faceColors?: Color4[];
  67437. updatable?: boolean;
  67438. sideOrientation?: number;
  67439. frontUVs?: Vector4;
  67440. backUVs?: Vector4;
  67441. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67442. /**
  67443. * Creates an extruded polygon mesh, with depth in the Y direction.
  67444. * * 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)
  67445. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67446. * @param name defines the name of the mesh
  67447. * @param options defines the options used to create the mesh
  67448. * @param scene defines the hosting scene
  67449. * @param earcutInjection can be used to inject your own earcut reference
  67450. * @returns the polygon mesh
  67451. */
  67452. static ExtrudePolygon(name: string, options: {
  67453. shape: Vector3[];
  67454. holes?: Vector3[][];
  67455. depth?: number;
  67456. faceUV?: Vector4[];
  67457. faceColors?: Color4[];
  67458. updatable?: boolean;
  67459. sideOrientation?: number;
  67460. frontUVs?: Vector4;
  67461. backUVs?: Vector4;
  67462. wrap?: boolean;
  67463. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67464. /**
  67465. * Creates a tube mesh.
  67466. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67467. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67468. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67469. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67470. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67471. * * 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)
  67472. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67473. * * 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
  67474. * * 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
  67475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67476. * * 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
  67477. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67479. * @param name defines the name of the mesh
  67480. * @param options defines the options used to create the mesh
  67481. * @param scene defines the hosting scene
  67482. * @returns the tube mesh
  67483. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67484. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67485. */
  67486. static CreateTube(name: string, options: {
  67487. path: Vector3[];
  67488. radius?: number;
  67489. tessellation?: number;
  67490. radiusFunction?: {
  67491. (i: number, distance: number): number;
  67492. };
  67493. cap?: number;
  67494. arc?: number;
  67495. updatable?: boolean;
  67496. sideOrientation?: number;
  67497. frontUVs?: Vector4;
  67498. backUVs?: Vector4;
  67499. instance?: Mesh;
  67500. invertUV?: boolean;
  67501. }, scene?: Nullable<Scene>): Mesh;
  67502. /**
  67503. * Creates a polyhedron mesh
  67504. * * 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
  67505. * * The parameter `size` (positive float, default 1) sets the polygon size
  67506. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67507. * * 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`
  67508. * * 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
  67509. * * 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)`)
  67510. * * 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
  67511. * * 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
  67512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67513. * * 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
  67514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67515. * @param name defines the name of the mesh
  67516. * @param options defines the options used to create the mesh
  67517. * @param scene defines the hosting scene
  67518. * @returns the polyhedron mesh
  67519. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67520. */
  67521. static CreatePolyhedron(name: string, options: {
  67522. type?: number;
  67523. size?: number;
  67524. sizeX?: number;
  67525. sizeY?: number;
  67526. sizeZ?: number;
  67527. custom?: any;
  67528. faceUV?: Vector4[];
  67529. faceColors?: Color4[];
  67530. flat?: boolean;
  67531. updatable?: boolean;
  67532. sideOrientation?: number;
  67533. frontUVs?: Vector4;
  67534. backUVs?: Vector4;
  67535. }, scene?: Nullable<Scene>): Mesh;
  67536. /**
  67537. * Creates a decal mesh.
  67538. * 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
  67539. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67540. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67541. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67542. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67543. * @param name defines the name of the mesh
  67544. * @param sourceMesh defines the mesh where the decal must be applied
  67545. * @param options defines the options used to create the mesh
  67546. * @param scene defines the hosting scene
  67547. * @returns the decal mesh
  67548. * @see https://doc.babylonjs.com/how_to/decals
  67549. */
  67550. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67551. position?: Vector3;
  67552. normal?: Vector3;
  67553. size?: Vector3;
  67554. angle?: number;
  67555. }): Mesh;
  67556. /**
  67557. * Creates a Capsule Mesh
  67558. * @param name defines the name of the mesh.
  67559. * @param options the constructors options used to shape the mesh.
  67560. * @param scene defines the scene the mesh is scoped to.
  67561. * @returns the capsule mesh
  67562. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67563. */
  67564. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67565. }
  67566. }
  67567. declare module BABYLON {
  67568. /**
  67569. * A simplifier interface for future simplification implementations
  67570. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67571. */
  67572. export interface ISimplifier {
  67573. /**
  67574. * Simplification of a given mesh according to the given settings.
  67575. * Since this requires computation, it is assumed that the function runs async.
  67576. * @param settings The settings of the simplification, including quality and distance
  67577. * @param successCallback A callback that will be called after the mesh was simplified.
  67578. * @param errorCallback in case of an error, this callback will be called. optional.
  67579. */
  67580. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67581. }
  67582. /**
  67583. * Expected simplification settings.
  67584. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67585. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67586. */
  67587. export interface ISimplificationSettings {
  67588. /**
  67589. * Gets or sets the expected quality
  67590. */
  67591. quality: number;
  67592. /**
  67593. * Gets or sets the distance when this optimized version should be used
  67594. */
  67595. distance: number;
  67596. /**
  67597. * Gets an already optimized mesh
  67598. */
  67599. optimizeMesh?: boolean;
  67600. }
  67601. /**
  67602. * Class used to specify simplification options
  67603. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67604. */
  67605. export class SimplificationSettings implements ISimplificationSettings {
  67606. /** expected quality */
  67607. quality: number;
  67608. /** distance when this optimized version should be used */
  67609. distance: number;
  67610. /** already optimized mesh */
  67611. optimizeMesh?: boolean | undefined;
  67612. /**
  67613. * Creates a SimplificationSettings
  67614. * @param quality expected quality
  67615. * @param distance distance when this optimized version should be used
  67616. * @param optimizeMesh already optimized mesh
  67617. */
  67618. constructor(
  67619. /** expected quality */
  67620. quality: number,
  67621. /** distance when this optimized version should be used */
  67622. distance: number,
  67623. /** already optimized mesh */
  67624. optimizeMesh?: boolean | undefined);
  67625. }
  67626. /**
  67627. * Interface used to define a simplification task
  67628. */
  67629. export interface ISimplificationTask {
  67630. /**
  67631. * Array of settings
  67632. */
  67633. settings: Array<ISimplificationSettings>;
  67634. /**
  67635. * Simplification type
  67636. */
  67637. simplificationType: SimplificationType;
  67638. /**
  67639. * Mesh to simplify
  67640. */
  67641. mesh: Mesh;
  67642. /**
  67643. * Callback called on success
  67644. */
  67645. successCallback?: () => void;
  67646. /**
  67647. * Defines if parallel processing can be used
  67648. */
  67649. parallelProcessing: boolean;
  67650. }
  67651. /**
  67652. * Queue used to order the simplification tasks
  67653. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67654. */
  67655. export class SimplificationQueue {
  67656. private _simplificationArray;
  67657. /**
  67658. * Gets a boolean indicating that the process is still running
  67659. */
  67660. running: boolean;
  67661. /**
  67662. * Creates a new queue
  67663. */
  67664. constructor();
  67665. /**
  67666. * Adds a new simplification task
  67667. * @param task defines a task to add
  67668. */
  67669. addTask(task: ISimplificationTask): void;
  67670. /**
  67671. * Execute next task
  67672. */
  67673. executeNext(): void;
  67674. /**
  67675. * Execute a simplification task
  67676. * @param task defines the task to run
  67677. */
  67678. runSimplification(task: ISimplificationTask): void;
  67679. private getSimplifier;
  67680. }
  67681. /**
  67682. * The implemented types of simplification
  67683. * At the moment only Quadratic Error Decimation is implemented
  67684. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67685. */
  67686. export enum SimplificationType {
  67687. /** Quadratic error decimation */
  67688. QUADRATIC = 0
  67689. }
  67690. /**
  67691. * An implementation of the Quadratic Error simplification algorithm.
  67692. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67693. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67694. * @author RaananW
  67695. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67696. */
  67697. export class QuadraticErrorSimplification implements ISimplifier {
  67698. private _mesh;
  67699. private triangles;
  67700. private vertices;
  67701. private references;
  67702. private _reconstructedMesh;
  67703. /** Gets or sets the number pf sync interations */
  67704. syncIterations: number;
  67705. /** Gets or sets the aggressiveness of the simplifier */
  67706. aggressiveness: number;
  67707. /** Gets or sets the number of allowed iterations for decimation */
  67708. decimationIterations: number;
  67709. /** Gets or sets the espilon to use for bounding box computation */
  67710. boundingBoxEpsilon: number;
  67711. /**
  67712. * Creates a new QuadraticErrorSimplification
  67713. * @param _mesh defines the target mesh
  67714. */
  67715. constructor(_mesh: Mesh);
  67716. /**
  67717. * Simplification of a given mesh according to the given settings.
  67718. * Since this requires computation, it is assumed that the function runs async.
  67719. * @param settings The settings of the simplification, including quality and distance
  67720. * @param successCallback A callback that will be called after the mesh was simplified.
  67721. */
  67722. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67723. private runDecimation;
  67724. private initWithMesh;
  67725. private init;
  67726. private reconstructMesh;
  67727. private initDecimatedMesh;
  67728. private isFlipped;
  67729. private updateTriangles;
  67730. private identifyBorder;
  67731. private updateMesh;
  67732. private vertexError;
  67733. private calculateError;
  67734. }
  67735. }
  67736. declare module BABYLON {
  67737. interface Scene {
  67738. /** @hidden (Backing field) */
  67739. _simplificationQueue: SimplificationQueue;
  67740. /**
  67741. * Gets or sets the simplification queue attached to the scene
  67742. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67743. */
  67744. simplificationQueue: SimplificationQueue;
  67745. }
  67746. interface Mesh {
  67747. /**
  67748. * Simplify the mesh according to the given array of settings.
  67749. * Function will return immediately and will simplify async
  67750. * @param settings a collection of simplification settings
  67751. * @param parallelProcessing should all levels calculate parallel or one after the other
  67752. * @param simplificationType the type of simplification to run
  67753. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67754. * @returns the current mesh
  67755. */
  67756. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67757. }
  67758. /**
  67759. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67760. * created in a scene
  67761. */
  67762. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67763. /**
  67764. * The component name helpfull to identify the component in the list of scene components.
  67765. */
  67766. readonly name: string;
  67767. /**
  67768. * The scene the component belongs to.
  67769. */
  67770. scene: Scene;
  67771. /**
  67772. * Creates a new instance of the component for the given scene
  67773. * @param scene Defines the scene to register the component in
  67774. */
  67775. constructor(scene: Scene);
  67776. /**
  67777. * Registers the component in a given scene
  67778. */
  67779. register(): void;
  67780. /**
  67781. * Rebuilds the elements related to this component in case of
  67782. * context lost for instance.
  67783. */
  67784. rebuild(): void;
  67785. /**
  67786. * Disposes the component and the associated ressources
  67787. */
  67788. dispose(): void;
  67789. private _beforeCameraUpdate;
  67790. }
  67791. }
  67792. declare module BABYLON {
  67793. interface Mesh {
  67794. /**
  67795. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67796. */
  67797. thinInstanceEnablePicking: boolean;
  67798. /**
  67799. * Creates a new thin instance
  67800. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67801. * @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
  67802. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67803. */
  67804. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67805. /**
  67806. * Adds the transformation (matrix) of the current mesh as a thin instance
  67807. * @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
  67808. * @returns the thin instance index number
  67809. */
  67810. thinInstanceAddSelf(refresh: boolean): number;
  67811. /**
  67812. * Registers a custom attribute to be used with thin instances
  67813. * @param kind name of the attribute
  67814. * @param stride size in floats of the attribute
  67815. */
  67816. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67817. /**
  67818. * Sets the matrix of a thin instance
  67819. * @param index index of the thin instance
  67820. * @param matrix matrix to set
  67821. * @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
  67822. */
  67823. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67824. /**
  67825. * Sets the value of a custom attribute for a thin instance
  67826. * @param kind name of the attribute
  67827. * @param index index of the thin instance
  67828. * @param value value to set
  67829. * @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
  67830. */
  67831. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67832. /**
  67833. * 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.
  67834. */
  67835. thinInstanceCount: number;
  67836. /**
  67837. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67838. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67839. * @param buffer buffer to set
  67840. * @param stride size in floats of each value of the buffer
  67841. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67842. */
  67843. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67844. /**
  67845. * Gets the list of world matrices
  67846. * @return an array containing all the world matrices from the thin instances
  67847. */
  67848. thinInstanceGetWorldMatrices(): Matrix[];
  67849. /**
  67850. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67851. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67852. */
  67853. thinInstanceBufferUpdated(kind: string): void;
  67854. /**
  67855. * Applies a partial update to a buffer directly on the GPU
  67856. * 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
  67857. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67858. * @param data the data to set in the GPU buffer
  67859. * @param offset the offset in the GPU buffer where to update the data
  67860. */
  67861. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67862. /**
  67863. * Refreshes the bounding info, taking into account all the thin instances defined
  67864. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  67865. */
  67866. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  67867. /** @hidden */
  67868. _thinInstanceInitializeUserStorage(): void;
  67869. /** @hidden */
  67870. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  67871. /** @hidden */
  67872. _userThinInstanceBuffersStorage: {
  67873. data: {
  67874. [key: string]: Float32Array;
  67875. };
  67876. sizes: {
  67877. [key: string]: number;
  67878. };
  67879. vertexBuffers: {
  67880. [key: string]: Nullable<VertexBuffer>;
  67881. };
  67882. strides: {
  67883. [key: string]: number;
  67884. };
  67885. };
  67886. }
  67887. }
  67888. declare module BABYLON {
  67889. /**
  67890. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67891. */
  67892. export interface INavigationEnginePlugin {
  67893. /**
  67894. * plugin name
  67895. */
  67896. name: string;
  67897. /**
  67898. * Creates a navigation mesh
  67899. * @param meshes array of all the geometry used to compute the navigatio mesh
  67900. * @param parameters bunch of parameters used to filter geometry
  67901. */
  67902. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67903. /**
  67904. * Create a navigation mesh debug mesh
  67905. * @param scene is where the mesh will be added
  67906. * @returns debug display mesh
  67907. */
  67908. createDebugNavMesh(scene: Scene): Mesh;
  67909. /**
  67910. * Get a navigation mesh constrained position, closest to the parameter position
  67911. * @param position world position
  67912. * @returns the closest point to position constrained by the navigation mesh
  67913. */
  67914. getClosestPoint(position: Vector3): Vector3;
  67915. /**
  67916. * Get a navigation mesh constrained position, closest to the parameter position
  67917. * @param position world position
  67918. * @param result output the closest point to position constrained by the navigation mesh
  67919. */
  67920. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67921. /**
  67922. * Get a navigation mesh constrained position, within a particular radius
  67923. * @param position world position
  67924. * @param maxRadius the maximum distance to the constrained world position
  67925. * @returns the closest point to position constrained by the navigation mesh
  67926. */
  67927. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67928. /**
  67929. * Get a navigation mesh constrained position, within a particular radius
  67930. * @param position world position
  67931. * @param maxRadius the maximum distance to the constrained world position
  67932. * @param result output the closest point to position constrained by the navigation mesh
  67933. */
  67934. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67935. /**
  67936. * Compute the final position from a segment made of destination-position
  67937. * @param position world position
  67938. * @param destination world position
  67939. * @returns the resulting point along the navmesh
  67940. */
  67941. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67942. /**
  67943. * Compute the final position from a segment made of destination-position
  67944. * @param position world position
  67945. * @param destination world position
  67946. * @param result output the resulting point along the navmesh
  67947. */
  67948. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67949. /**
  67950. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67951. * @param start world position
  67952. * @param end world position
  67953. * @returns array containing world position composing the path
  67954. */
  67955. computePath(start: Vector3, end: Vector3): Vector3[];
  67956. /**
  67957. * If this plugin is supported
  67958. * @returns true if plugin is supported
  67959. */
  67960. isSupported(): boolean;
  67961. /**
  67962. * Create a new Crowd so you can add agents
  67963. * @param maxAgents the maximum agent count in the crowd
  67964. * @param maxAgentRadius the maximum radius an agent can have
  67965. * @param scene to attach the crowd to
  67966. * @returns the crowd you can add agents to
  67967. */
  67968. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67969. /**
  67970. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67971. * The queries will try to find a solution within those bounds
  67972. * default is (1,1,1)
  67973. * @param extent x,y,z value that define the extent around the queries point of reference
  67974. */
  67975. setDefaultQueryExtent(extent: Vector3): void;
  67976. /**
  67977. * Get the Bounding box extent specified by setDefaultQueryExtent
  67978. * @returns the box extent values
  67979. */
  67980. getDefaultQueryExtent(): Vector3;
  67981. /**
  67982. * build the navmesh from a previously saved state using getNavmeshData
  67983. * @param data the Uint8Array returned by getNavmeshData
  67984. */
  67985. buildFromNavmeshData(data: Uint8Array): void;
  67986. /**
  67987. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67988. * @returns data the Uint8Array that can be saved and reused
  67989. */
  67990. getNavmeshData(): Uint8Array;
  67991. /**
  67992. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67993. * @param result output the box extent values
  67994. */
  67995. getDefaultQueryExtentToRef(result: Vector3): void;
  67996. /**
  67997. * Release all resources
  67998. */
  67999. dispose(): void;
  68000. }
  68001. /**
  68002. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68003. */
  68004. export interface ICrowd {
  68005. /**
  68006. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68007. * You can attach anything to that node. The node position is updated in the scene update tick.
  68008. * @param pos world position that will be constrained by the navigation mesh
  68009. * @param parameters agent parameters
  68010. * @param transform hooked to the agent that will be update by the scene
  68011. * @returns agent index
  68012. */
  68013. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68014. /**
  68015. * Returns the agent position in world space
  68016. * @param index agent index returned by addAgent
  68017. * @returns world space position
  68018. */
  68019. getAgentPosition(index: number): Vector3;
  68020. /**
  68021. * Gets the agent position result in world space
  68022. * @param index agent index returned by addAgent
  68023. * @param result output world space position
  68024. */
  68025. getAgentPositionToRef(index: number, result: Vector3): void;
  68026. /**
  68027. * Gets the agent velocity in world space
  68028. * @param index agent index returned by addAgent
  68029. * @returns world space velocity
  68030. */
  68031. getAgentVelocity(index: number): Vector3;
  68032. /**
  68033. * Gets the agent velocity result in world space
  68034. * @param index agent index returned by addAgent
  68035. * @param result output world space velocity
  68036. */
  68037. getAgentVelocityToRef(index: number, result: Vector3): void;
  68038. /**
  68039. * Gets the agent next target point on the path
  68040. * @param index agent index returned by addAgent
  68041. * @returns world space position
  68042. */
  68043. getAgentNextTargetPath(index: number): Vector3;
  68044. /**
  68045. * Gets the agent state
  68046. * @param index agent index returned by addAgent
  68047. * @returns agent state
  68048. */
  68049. getAgentState(index: number): number;
  68050. /**
  68051. * returns true if the agent in over an off mesh link connection
  68052. * @param index agent index returned by addAgent
  68053. * @returns true if over an off mesh link connection
  68054. */
  68055. overOffmeshConnection(index: number): boolean;
  68056. /**
  68057. * Gets the agent next target point on the path
  68058. * @param index agent index returned by addAgent
  68059. * @param result output world space position
  68060. */
  68061. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68062. /**
  68063. * remove a particular agent previously created
  68064. * @param index agent index returned by addAgent
  68065. */
  68066. removeAgent(index: number): void;
  68067. /**
  68068. * get the list of all agents attached to this crowd
  68069. * @returns list of agent indices
  68070. */
  68071. getAgents(): number[];
  68072. /**
  68073. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68074. * @param deltaTime in seconds
  68075. */
  68076. update(deltaTime: number): void;
  68077. /**
  68078. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68079. * @param index agent index returned by addAgent
  68080. * @param destination targeted world position
  68081. */
  68082. agentGoto(index: number, destination: Vector3): void;
  68083. /**
  68084. * Teleport the agent to a new position
  68085. * @param index agent index returned by addAgent
  68086. * @param destination targeted world position
  68087. */
  68088. agentTeleport(index: number, destination: Vector3): void;
  68089. /**
  68090. * Update agent parameters
  68091. * @param index agent index returned by addAgent
  68092. * @param parameters agent parameters
  68093. */
  68094. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68095. /**
  68096. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68097. * The queries will try to find a solution within those bounds
  68098. * default is (1,1,1)
  68099. * @param extent x,y,z value that define the extent around the queries point of reference
  68100. */
  68101. setDefaultQueryExtent(extent: Vector3): void;
  68102. /**
  68103. * Get the Bounding box extent specified by setDefaultQueryExtent
  68104. * @returns the box extent values
  68105. */
  68106. getDefaultQueryExtent(): Vector3;
  68107. /**
  68108. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68109. * @param result output the box extent values
  68110. */
  68111. getDefaultQueryExtentToRef(result: Vector3): void;
  68112. /**
  68113. * Release all resources
  68114. */
  68115. dispose(): void;
  68116. }
  68117. /**
  68118. * Configures an agent
  68119. */
  68120. export interface IAgentParameters {
  68121. /**
  68122. * Agent radius. [Limit: >= 0]
  68123. */
  68124. radius: number;
  68125. /**
  68126. * Agent height. [Limit: > 0]
  68127. */
  68128. height: number;
  68129. /**
  68130. * Maximum allowed acceleration. [Limit: >= 0]
  68131. */
  68132. maxAcceleration: number;
  68133. /**
  68134. * Maximum allowed speed. [Limit: >= 0]
  68135. */
  68136. maxSpeed: number;
  68137. /**
  68138. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68139. */
  68140. collisionQueryRange: number;
  68141. /**
  68142. * The path visibility optimization range. [Limit: > 0]
  68143. */
  68144. pathOptimizationRange: number;
  68145. /**
  68146. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68147. */
  68148. separationWeight: number;
  68149. }
  68150. /**
  68151. * Configures the navigation mesh creation
  68152. */
  68153. export interface INavMeshParameters {
  68154. /**
  68155. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68156. */
  68157. cs: number;
  68158. /**
  68159. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68160. */
  68161. ch: number;
  68162. /**
  68163. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68164. */
  68165. walkableSlopeAngle: number;
  68166. /**
  68167. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68168. * be considered walkable. [Limit: >= 3] [Units: vx]
  68169. */
  68170. walkableHeight: number;
  68171. /**
  68172. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68173. */
  68174. walkableClimb: number;
  68175. /**
  68176. * The distance to erode/shrink the walkable area of the heightfield away from
  68177. * obstructions. [Limit: >=0] [Units: vx]
  68178. */
  68179. walkableRadius: number;
  68180. /**
  68181. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68182. */
  68183. maxEdgeLen: number;
  68184. /**
  68185. * The maximum distance a simplfied contour's border edges should deviate
  68186. * the original raw contour. [Limit: >=0] [Units: vx]
  68187. */
  68188. maxSimplificationError: number;
  68189. /**
  68190. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68191. */
  68192. minRegionArea: number;
  68193. /**
  68194. * Any regions with a span count smaller than this value will, if possible,
  68195. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68196. */
  68197. mergeRegionArea: number;
  68198. /**
  68199. * The maximum number of vertices allowed for polygons generated during the
  68200. * contour to polygon conversion process. [Limit: >= 3]
  68201. */
  68202. maxVertsPerPoly: number;
  68203. /**
  68204. * Sets the sampling distance to use when generating the detail mesh.
  68205. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68206. */
  68207. detailSampleDist: number;
  68208. /**
  68209. * The maximum distance the detail mesh surface should deviate from heightfield
  68210. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68211. */
  68212. detailSampleMaxError: number;
  68213. }
  68214. }
  68215. declare module BABYLON {
  68216. /**
  68217. * RecastJS navigation plugin
  68218. */
  68219. export class RecastJSPlugin implements INavigationEnginePlugin {
  68220. /**
  68221. * Reference to the Recast library
  68222. */
  68223. bjsRECAST: any;
  68224. /**
  68225. * plugin name
  68226. */
  68227. name: string;
  68228. /**
  68229. * the first navmesh created. We might extend this to support multiple navmeshes
  68230. */
  68231. navMesh: any;
  68232. /**
  68233. * Initializes the recastJS plugin
  68234. * @param recastInjection can be used to inject your own recast reference
  68235. */
  68236. constructor(recastInjection?: any);
  68237. /**
  68238. * Creates a navigation mesh
  68239. * @param meshes array of all the geometry used to compute the navigatio mesh
  68240. * @param parameters bunch of parameters used to filter geometry
  68241. */
  68242. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68243. /**
  68244. * Create a navigation mesh debug mesh
  68245. * @param scene is where the mesh will be added
  68246. * @returns debug display mesh
  68247. */
  68248. createDebugNavMesh(scene: Scene): Mesh;
  68249. /**
  68250. * Get a navigation mesh constrained position, closest to the parameter position
  68251. * @param position world position
  68252. * @returns the closest point to position constrained by the navigation mesh
  68253. */
  68254. getClosestPoint(position: Vector3): Vector3;
  68255. /**
  68256. * Get a navigation mesh constrained position, closest to the parameter position
  68257. * @param position world position
  68258. * @param result output the closest point to position constrained by the navigation mesh
  68259. */
  68260. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68261. /**
  68262. * Get a navigation mesh constrained position, within a particular radius
  68263. * @param position world position
  68264. * @param maxRadius the maximum distance to the constrained world position
  68265. * @returns the closest point to position constrained by the navigation mesh
  68266. */
  68267. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68268. /**
  68269. * Get a navigation mesh constrained position, within a particular radius
  68270. * @param position world position
  68271. * @param maxRadius the maximum distance to the constrained world position
  68272. * @param result output the closest point to position constrained by the navigation mesh
  68273. */
  68274. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68275. /**
  68276. * Compute the final position from a segment made of destination-position
  68277. * @param position world position
  68278. * @param destination world position
  68279. * @returns the resulting point along the navmesh
  68280. */
  68281. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68282. /**
  68283. * Compute the final position from a segment made of destination-position
  68284. * @param position world position
  68285. * @param destination world position
  68286. * @param result output the resulting point along the navmesh
  68287. */
  68288. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68289. /**
  68290. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68291. * @param start world position
  68292. * @param end world position
  68293. * @returns array containing world position composing the path
  68294. */
  68295. computePath(start: Vector3, end: Vector3): Vector3[];
  68296. /**
  68297. * Create a new Crowd so you can add agents
  68298. * @param maxAgents the maximum agent count in the crowd
  68299. * @param maxAgentRadius the maximum radius an agent can have
  68300. * @param scene to attach the crowd to
  68301. * @returns the crowd you can add agents to
  68302. */
  68303. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68304. /**
  68305. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68306. * The queries will try to find a solution within those bounds
  68307. * default is (1,1,1)
  68308. * @param extent x,y,z value that define the extent around the queries point of reference
  68309. */
  68310. setDefaultQueryExtent(extent: Vector3): void;
  68311. /**
  68312. * Get the Bounding box extent specified by setDefaultQueryExtent
  68313. * @returns the box extent values
  68314. */
  68315. getDefaultQueryExtent(): Vector3;
  68316. /**
  68317. * build the navmesh from a previously saved state using getNavmeshData
  68318. * @param data the Uint8Array returned by getNavmeshData
  68319. */
  68320. buildFromNavmeshData(data: Uint8Array): void;
  68321. /**
  68322. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68323. * @returns data the Uint8Array that can be saved and reused
  68324. */
  68325. getNavmeshData(): Uint8Array;
  68326. /**
  68327. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68328. * @param result output the box extent values
  68329. */
  68330. getDefaultQueryExtentToRef(result: Vector3): void;
  68331. /**
  68332. * Disposes
  68333. */
  68334. dispose(): void;
  68335. /**
  68336. * If this plugin is supported
  68337. * @returns true if plugin is supported
  68338. */
  68339. isSupported(): boolean;
  68340. }
  68341. /**
  68342. * Recast detour crowd implementation
  68343. */
  68344. export class RecastJSCrowd implements ICrowd {
  68345. /**
  68346. * Recast/detour plugin
  68347. */
  68348. bjsRECASTPlugin: RecastJSPlugin;
  68349. /**
  68350. * Link to the detour crowd
  68351. */
  68352. recastCrowd: any;
  68353. /**
  68354. * One transform per agent
  68355. */
  68356. transforms: TransformNode[];
  68357. /**
  68358. * All agents created
  68359. */
  68360. agents: number[];
  68361. /**
  68362. * Link to the scene is kept to unregister the crowd from the scene
  68363. */
  68364. private _scene;
  68365. /**
  68366. * Observer for crowd updates
  68367. */
  68368. private _onBeforeAnimationsObserver;
  68369. /**
  68370. * Constructor
  68371. * @param plugin recastJS plugin
  68372. * @param maxAgents the maximum agent count in the crowd
  68373. * @param maxAgentRadius the maximum radius an agent can have
  68374. * @param scene to attach the crowd to
  68375. * @returns the crowd you can add agents to
  68376. */
  68377. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68378. /**
  68379. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68380. * You can attach anything to that node. The node position is updated in the scene update tick.
  68381. * @param pos world position that will be constrained by the navigation mesh
  68382. * @param parameters agent parameters
  68383. * @param transform hooked to the agent that will be update by the scene
  68384. * @returns agent index
  68385. */
  68386. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68387. /**
  68388. * Returns the agent position in world space
  68389. * @param index agent index returned by addAgent
  68390. * @returns world space position
  68391. */
  68392. getAgentPosition(index: number): Vector3;
  68393. /**
  68394. * Returns the agent position result in world space
  68395. * @param index agent index returned by addAgent
  68396. * @param result output world space position
  68397. */
  68398. getAgentPositionToRef(index: number, result: Vector3): void;
  68399. /**
  68400. * Returns the agent velocity in world space
  68401. * @param index agent index returned by addAgent
  68402. * @returns world space velocity
  68403. */
  68404. getAgentVelocity(index: number): Vector3;
  68405. /**
  68406. * Returns the agent velocity result in world space
  68407. * @param index agent index returned by addAgent
  68408. * @param result output world space velocity
  68409. */
  68410. getAgentVelocityToRef(index: number, result: Vector3): void;
  68411. /**
  68412. * Returns the agent next target point on the path
  68413. * @param index agent index returned by addAgent
  68414. * @returns world space position
  68415. */
  68416. getAgentNextTargetPath(index: number): Vector3;
  68417. /**
  68418. * Returns the agent next target point on the path
  68419. * @param index agent index returned by addAgent
  68420. * @param result output world space position
  68421. */
  68422. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68423. /**
  68424. * Gets the agent state
  68425. * @param index agent index returned by addAgent
  68426. * @returns agent state
  68427. */
  68428. getAgentState(index: number): number;
  68429. /**
  68430. * returns true if the agent in over an off mesh link connection
  68431. * @param index agent index returned by addAgent
  68432. * @returns true if over an off mesh link connection
  68433. */
  68434. overOffmeshConnection(index: number): boolean;
  68435. /**
  68436. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68437. * @param index agent index returned by addAgent
  68438. * @param destination targeted world position
  68439. */
  68440. agentGoto(index: number, destination: Vector3): void;
  68441. /**
  68442. * Teleport the agent to a new position
  68443. * @param index agent index returned by addAgent
  68444. * @param destination targeted world position
  68445. */
  68446. agentTeleport(index: number, destination: Vector3): void;
  68447. /**
  68448. * Update agent parameters
  68449. * @param index agent index returned by addAgent
  68450. * @param parameters agent parameters
  68451. */
  68452. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68453. /**
  68454. * remove a particular agent previously created
  68455. * @param index agent index returned by addAgent
  68456. */
  68457. removeAgent(index: number): void;
  68458. /**
  68459. * get the list of all agents attached to this crowd
  68460. * @returns list of agent indices
  68461. */
  68462. getAgents(): number[];
  68463. /**
  68464. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68465. * @param deltaTime in seconds
  68466. */
  68467. update(deltaTime: number): void;
  68468. /**
  68469. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68470. * The queries will try to find a solution within those bounds
  68471. * default is (1,1,1)
  68472. * @param extent x,y,z value that define the extent around the queries point of reference
  68473. */
  68474. setDefaultQueryExtent(extent: Vector3): void;
  68475. /**
  68476. * Get the Bounding box extent specified by setDefaultQueryExtent
  68477. * @returns the box extent values
  68478. */
  68479. getDefaultQueryExtent(): Vector3;
  68480. /**
  68481. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68482. * @param result output the box extent values
  68483. */
  68484. getDefaultQueryExtentToRef(result: Vector3): void;
  68485. /**
  68486. * Release all resources
  68487. */
  68488. dispose(): void;
  68489. }
  68490. }
  68491. declare module BABYLON {
  68492. /**
  68493. * Class used to enable access to IndexedDB
  68494. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68495. */
  68496. export class Database implements IOfflineProvider {
  68497. private _callbackManifestChecked;
  68498. private _currentSceneUrl;
  68499. private _db;
  68500. private _enableSceneOffline;
  68501. private _enableTexturesOffline;
  68502. private _manifestVersionFound;
  68503. private _mustUpdateRessources;
  68504. private _hasReachedQuota;
  68505. private _isSupported;
  68506. private _idbFactory;
  68507. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68508. private static IsUASupportingBlobStorage;
  68509. /**
  68510. * Gets a boolean indicating if Database storate is enabled (off by default)
  68511. */
  68512. static IDBStorageEnabled: boolean;
  68513. /**
  68514. * Gets a boolean indicating if scene must be saved in the database
  68515. */
  68516. get enableSceneOffline(): boolean;
  68517. /**
  68518. * Gets a boolean indicating if textures must be saved in the database
  68519. */
  68520. get enableTexturesOffline(): boolean;
  68521. /**
  68522. * Creates a new Database
  68523. * @param urlToScene defines the url to load the scene
  68524. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68525. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68526. */
  68527. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68528. private static _ParseURL;
  68529. private static _ReturnFullUrlLocation;
  68530. private _checkManifestFile;
  68531. /**
  68532. * Open the database and make it available
  68533. * @param successCallback defines the callback to call on success
  68534. * @param errorCallback defines the callback to call on error
  68535. */
  68536. open(successCallback: () => void, errorCallback: () => void): void;
  68537. /**
  68538. * Loads an image from the database
  68539. * @param url defines the url to load from
  68540. * @param image defines the target DOM image
  68541. */
  68542. loadImage(url: string, image: HTMLImageElement): void;
  68543. private _loadImageFromDBAsync;
  68544. private _saveImageIntoDBAsync;
  68545. private _checkVersionFromDB;
  68546. private _loadVersionFromDBAsync;
  68547. private _saveVersionIntoDBAsync;
  68548. /**
  68549. * Loads a file from database
  68550. * @param url defines the URL to load from
  68551. * @param sceneLoaded defines a callback to call on success
  68552. * @param progressCallBack defines a callback to call when progress changed
  68553. * @param errorCallback defines a callback to call on error
  68554. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68555. */
  68556. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68557. private _loadFileAsync;
  68558. private _saveFileAsync;
  68559. /**
  68560. * Validates if xhr data is correct
  68561. * @param xhr defines the request to validate
  68562. * @param dataType defines the expected data type
  68563. * @returns true if data is correct
  68564. */
  68565. private static _ValidateXHRData;
  68566. }
  68567. }
  68568. declare module BABYLON {
  68569. /** @hidden */
  68570. export var gpuUpdateParticlesPixelShader: {
  68571. name: string;
  68572. shader: string;
  68573. };
  68574. }
  68575. declare module BABYLON {
  68576. /** @hidden */
  68577. export var gpuUpdateParticlesVertexShader: {
  68578. name: string;
  68579. shader: string;
  68580. };
  68581. }
  68582. declare module BABYLON {
  68583. /** @hidden */
  68584. export var clipPlaneFragmentDeclaration2: {
  68585. name: string;
  68586. shader: string;
  68587. };
  68588. }
  68589. declare module BABYLON {
  68590. /** @hidden */
  68591. export var gpuRenderParticlesPixelShader: {
  68592. name: string;
  68593. shader: string;
  68594. };
  68595. }
  68596. declare module BABYLON {
  68597. /** @hidden */
  68598. export var clipPlaneVertexDeclaration2: {
  68599. name: string;
  68600. shader: string;
  68601. };
  68602. }
  68603. declare module BABYLON {
  68604. /** @hidden */
  68605. export var gpuRenderParticlesVertexShader: {
  68606. name: string;
  68607. shader: string;
  68608. };
  68609. }
  68610. declare module BABYLON {
  68611. /**
  68612. * This represents a GPU particle system in Babylon
  68613. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68614. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68615. */
  68616. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68617. /**
  68618. * The layer mask we are rendering the particles through.
  68619. */
  68620. layerMask: number;
  68621. private _capacity;
  68622. private _activeCount;
  68623. private _currentActiveCount;
  68624. private _accumulatedCount;
  68625. private _renderEffect;
  68626. private _updateEffect;
  68627. private _buffer0;
  68628. private _buffer1;
  68629. private _spriteBuffer;
  68630. private _updateVAO;
  68631. private _renderVAO;
  68632. private _targetIndex;
  68633. private _sourceBuffer;
  68634. private _targetBuffer;
  68635. private _currentRenderId;
  68636. private _started;
  68637. private _stopped;
  68638. private _timeDelta;
  68639. private _randomTexture;
  68640. private _randomTexture2;
  68641. private _attributesStrideSize;
  68642. private _updateEffectOptions;
  68643. private _randomTextureSize;
  68644. private _actualFrame;
  68645. private _customEffect;
  68646. private readonly _rawTextureWidth;
  68647. /**
  68648. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68649. */
  68650. static get IsSupported(): boolean;
  68651. /**
  68652. * An event triggered when the system is disposed.
  68653. */
  68654. onDisposeObservable: Observable<IParticleSystem>;
  68655. /**
  68656. * An event triggered when the system is stopped
  68657. */
  68658. onStoppedObservable: Observable<IParticleSystem>;
  68659. /**
  68660. * Gets the maximum number of particles active at the same time.
  68661. * @returns The max number of active particles.
  68662. */
  68663. getCapacity(): number;
  68664. /**
  68665. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68666. * to override the particles.
  68667. */
  68668. forceDepthWrite: boolean;
  68669. /**
  68670. * Gets or set the number of active particles
  68671. */
  68672. get activeParticleCount(): number;
  68673. set activeParticleCount(value: number);
  68674. private _preWarmDone;
  68675. /**
  68676. * Specifies if the particles are updated in emitter local space or world space.
  68677. */
  68678. isLocal: boolean;
  68679. /** Gets or sets a matrix to use to compute projection */
  68680. defaultProjectionMatrix: Matrix;
  68681. /**
  68682. * Is this system ready to be used/rendered
  68683. * @return true if the system is ready
  68684. */
  68685. isReady(): boolean;
  68686. /**
  68687. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68688. * @returns True if it has been started, otherwise false.
  68689. */
  68690. isStarted(): boolean;
  68691. /**
  68692. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68693. * @returns True if it has been stopped, otherwise false.
  68694. */
  68695. isStopped(): boolean;
  68696. /**
  68697. * Gets a boolean indicating that the system is stopping
  68698. * @returns true if the system is currently stopping
  68699. */
  68700. isStopping(): boolean;
  68701. /**
  68702. * Gets the number of particles active at the same time.
  68703. * @returns The number of active particles.
  68704. */
  68705. getActiveCount(): number;
  68706. /**
  68707. * Starts the particle system and begins to emit
  68708. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68709. */
  68710. start(delay?: number): void;
  68711. /**
  68712. * Stops the particle system.
  68713. */
  68714. stop(): void;
  68715. /**
  68716. * Remove all active particles
  68717. */
  68718. reset(): void;
  68719. /**
  68720. * Returns the string "GPUParticleSystem"
  68721. * @returns a string containing the class name
  68722. */
  68723. getClassName(): string;
  68724. /**
  68725. * Gets the custom effect used to render the particles
  68726. * @param blendMode Blend mode for which the effect should be retrieved
  68727. * @returns The effect
  68728. */
  68729. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68730. /**
  68731. * Sets the custom effect used to render the particles
  68732. * @param effect The effect to set
  68733. * @param blendMode Blend mode for which the effect should be set
  68734. */
  68735. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  68736. /** @hidden */
  68737. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  68738. /**
  68739. * Observable that will be called just before the particles are drawn
  68740. */
  68741. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  68742. /**
  68743. * Gets the name of the particle vertex shader
  68744. */
  68745. get vertexShaderName(): string;
  68746. private _colorGradientsTexture;
  68747. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68748. /**
  68749. * Adds a new color gradient
  68750. * @param gradient defines the gradient to use (between 0 and 1)
  68751. * @param color1 defines the color to affect to the specified gradient
  68752. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68753. * @returns the current particle system
  68754. */
  68755. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68756. private _refreshColorGradient;
  68757. /** Force the system to rebuild all gradients that need to be resync */
  68758. forceRefreshGradients(): void;
  68759. /**
  68760. * Remove a specific color gradient
  68761. * @param gradient defines the gradient to remove
  68762. * @returns the current particle system
  68763. */
  68764. removeColorGradient(gradient: number): GPUParticleSystem;
  68765. private _angularSpeedGradientsTexture;
  68766. private _sizeGradientsTexture;
  68767. private _velocityGradientsTexture;
  68768. private _limitVelocityGradientsTexture;
  68769. private _dragGradientsTexture;
  68770. private _addFactorGradient;
  68771. /**
  68772. * Adds a new size gradient
  68773. * @param gradient defines the gradient to use (between 0 and 1)
  68774. * @param factor defines the size factor to affect to the specified gradient
  68775. * @returns the current particle system
  68776. */
  68777. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68778. /**
  68779. * Remove a specific size gradient
  68780. * @param gradient defines the gradient to remove
  68781. * @returns the current particle system
  68782. */
  68783. removeSizeGradient(gradient: number): GPUParticleSystem;
  68784. private _refreshFactorGradient;
  68785. /**
  68786. * Adds a new angular speed gradient
  68787. * @param gradient defines the gradient to use (between 0 and 1)
  68788. * @param factor defines the angular speed to affect to the specified gradient
  68789. * @returns the current particle system
  68790. */
  68791. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68792. /**
  68793. * Remove a specific angular speed gradient
  68794. * @param gradient defines the gradient to remove
  68795. * @returns the current particle system
  68796. */
  68797. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68798. /**
  68799. * Adds a new velocity gradient
  68800. * @param gradient defines the gradient to use (between 0 and 1)
  68801. * @param factor defines the velocity to affect to the specified gradient
  68802. * @returns the current particle system
  68803. */
  68804. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68805. /**
  68806. * Remove a specific velocity gradient
  68807. * @param gradient defines the gradient to remove
  68808. * @returns the current particle system
  68809. */
  68810. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68811. /**
  68812. * Adds a new limit velocity gradient
  68813. * @param gradient defines the gradient to use (between 0 and 1)
  68814. * @param factor defines the limit velocity value to affect to the specified gradient
  68815. * @returns the current particle system
  68816. */
  68817. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68818. /**
  68819. * Remove a specific limit velocity gradient
  68820. * @param gradient defines the gradient to remove
  68821. * @returns the current particle system
  68822. */
  68823. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68824. /**
  68825. * Adds a new drag gradient
  68826. * @param gradient defines the gradient to use (between 0 and 1)
  68827. * @param factor defines the drag value to affect to the specified gradient
  68828. * @returns the current particle system
  68829. */
  68830. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68831. /**
  68832. * Remove a specific drag gradient
  68833. * @param gradient defines the gradient to remove
  68834. * @returns the current particle system
  68835. */
  68836. removeDragGradient(gradient: number): GPUParticleSystem;
  68837. /**
  68838. * Not supported by GPUParticleSystem
  68839. * @param gradient defines the gradient to use (between 0 and 1)
  68840. * @param factor defines the emit rate value to affect to the specified gradient
  68841. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68842. * @returns the current particle system
  68843. */
  68844. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68845. /**
  68846. * Not supported by GPUParticleSystem
  68847. * @param gradient defines the gradient to remove
  68848. * @returns the current particle system
  68849. */
  68850. removeEmitRateGradient(gradient: number): IParticleSystem;
  68851. /**
  68852. * Not supported by GPUParticleSystem
  68853. * @param gradient defines the gradient to use (between 0 and 1)
  68854. * @param factor defines the start size value to affect to the specified gradient
  68855. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68856. * @returns the current particle system
  68857. */
  68858. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68859. /**
  68860. * Not supported by GPUParticleSystem
  68861. * @param gradient defines the gradient to remove
  68862. * @returns the current particle system
  68863. */
  68864. removeStartSizeGradient(gradient: number): IParticleSystem;
  68865. /**
  68866. * Not supported by GPUParticleSystem
  68867. * @param gradient defines the gradient to use (between 0 and 1)
  68868. * @param min defines the color remap minimal range
  68869. * @param max defines the color remap maximal range
  68870. * @returns the current particle system
  68871. */
  68872. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68873. /**
  68874. * Not supported by GPUParticleSystem
  68875. * @param gradient defines the gradient to remove
  68876. * @returns the current particle system
  68877. */
  68878. removeColorRemapGradient(): IParticleSystem;
  68879. /**
  68880. * Not supported by GPUParticleSystem
  68881. * @param gradient defines the gradient to use (between 0 and 1)
  68882. * @param min defines the alpha remap minimal range
  68883. * @param max defines the alpha remap maximal range
  68884. * @returns the current particle system
  68885. */
  68886. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68887. /**
  68888. * Not supported by GPUParticleSystem
  68889. * @param gradient defines the gradient to remove
  68890. * @returns the current particle system
  68891. */
  68892. removeAlphaRemapGradient(): IParticleSystem;
  68893. /**
  68894. * Not supported by GPUParticleSystem
  68895. * @param gradient defines the gradient to use (between 0 and 1)
  68896. * @param color defines the color to affect to the specified gradient
  68897. * @returns the current particle system
  68898. */
  68899. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68900. /**
  68901. * Not supported by GPUParticleSystem
  68902. * @param gradient defines the gradient to remove
  68903. * @returns the current particle system
  68904. */
  68905. removeRampGradient(): IParticleSystem;
  68906. /**
  68907. * Not supported by GPUParticleSystem
  68908. * @returns the list of ramp gradients
  68909. */
  68910. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68911. /**
  68912. * Not supported by GPUParticleSystem
  68913. * Gets or sets a boolean indicating that ramp gradients must be used
  68914. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68915. */
  68916. get useRampGradients(): boolean;
  68917. set useRampGradients(value: boolean);
  68918. /**
  68919. * Not supported by GPUParticleSystem
  68920. * @param gradient defines the gradient to use (between 0 and 1)
  68921. * @param factor defines the life time factor to affect to the specified gradient
  68922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68923. * @returns the current particle system
  68924. */
  68925. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68926. /**
  68927. * Not supported by GPUParticleSystem
  68928. * @param gradient defines the gradient to remove
  68929. * @returns the current particle system
  68930. */
  68931. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68932. /**
  68933. * Instantiates a GPU particle system.
  68934. * 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.
  68935. * @param name The name of the particle system
  68936. * @param options The options used to create the system
  68937. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  68938. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68939. * @param customEffect a custom effect used to change the way particles are rendered by default
  68940. */
  68941. constructor(name: string, options: Partial<{
  68942. capacity: number;
  68943. randomTextureSize: number;
  68944. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  68945. protected _reset(): void;
  68946. private _createUpdateVAO;
  68947. private _createRenderVAO;
  68948. private _initialize;
  68949. /** @hidden */
  68950. _recreateUpdateEffect(): void;
  68951. private _getEffect;
  68952. /**
  68953. * Fill the defines array according to the current settings of the particle system
  68954. * @param defines Array to be updated
  68955. * @param blendMode blend mode to take into account when updating the array
  68956. */
  68957. fillDefines(defines: Array<string>, blendMode?: number): void;
  68958. /**
  68959. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  68960. * @param uniforms Uniforms array to fill
  68961. * @param attributes Attributes array to fill
  68962. * @param samplers Samplers array to fill
  68963. */
  68964. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  68965. /** @hidden */
  68966. _recreateRenderEffect(): Effect;
  68967. /**
  68968. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68969. * @param preWarm defines if we are in the pre-warmimg phase
  68970. */
  68971. animate(preWarm?: boolean): void;
  68972. private _createFactorGradientTexture;
  68973. private _createSizeGradientTexture;
  68974. private _createAngularSpeedGradientTexture;
  68975. private _createVelocityGradientTexture;
  68976. private _createLimitVelocityGradientTexture;
  68977. private _createDragGradientTexture;
  68978. private _createColorGradientTexture;
  68979. /**
  68980. * Renders the particle system in its current state
  68981. * @param preWarm defines if the system should only update the particles but not render them
  68982. * @returns the current number of particles
  68983. */
  68984. render(preWarm?: boolean): number;
  68985. /**
  68986. * Rebuilds the particle system
  68987. */
  68988. rebuild(): void;
  68989. private _releaseBuffers;
  68990. private _releaseVAOs;
  68991. /**
  68992. * Disposes the particle system and free the associated resources
  68993. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68994. */
  68995. dispose(disposeTexture?: boolean): void;
  68996. /**
  68997. * Clones the particle system.
  68998. * @param name The name of the cloned object
  68999. * @param newEmitter The new emitter to use
  69000. * @returns the cloned particle system
  69001. */
  69002. clone(name: string, newEmitter: any): GPUParticleSystem;
  69003. /**
  69004. * Serializes the particle system to a JSON object
  69005. * @param serializeTexture defines if the texture must be serialized as well
  69006. * @returns the JSON object
  69007. */
  69008. serialize(serializeTexture?: boolean): any;
  69009. /**
  69010. * Parses a JSON object to create a GPU particle system.
  69011. * @param parsedParticleSystem The JSON object to parse
  69012. * @param sceneOrEngine The scene or the engine to create the particle system in
  69013. * @param rootUrl The root url to use to load external dependencies like texture
  69014. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69015. * @returns the parsed GPU particle system
  69016. */
  69017. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69018. }
  69019. }
  69020. declare module BABYLON {
  69021. /**
  69022. * Represents a set of particle systems working together to create a specific effect
  69023. */
  69024. export class ParticleSystemSet implements IDisposable {
  69025. /**
  69026. * Gets or sets base Assets URL
  69027. */
  69028. static BaseAssetsUrl: string;
  69029. private _emitterCreationOptions;
  69030. private _emitterNode;
  69031. /**
  69032. * Gets the particle system list
  69033. */
  69034. systems: IParticleSystem[];
  69035. /**
  69036. * Gets the emitter node used with this set
  69037. */
  69038. get emitterNode(): Nullable<TransformNode>;
  69039. /**
  69040. * Creates a new emitter mesh as a sphere
  69041. * @param options defines the options used to create the sphere
  69042. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69043. * @param scene defines the hosting scene
  69044. */
  69045. setEmitterAsSphere(options: {
  69046. diameter: number;
  69047. segments: number;
  69048. color: Color3;
  69049. }, renderingGroupId: number, scene: Scene): void;
  69050. /**
  69051. * Starts all particle systems of the set
  69052. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69053. */
  69054. start(emitter?: AbstractMesh): void;
  69055. /**
  69056. * Release all associated resources
  69057. */
  69058. dispose(): void;
  69059. /**
  69060. * Serialize the set into a JSON compatible object
  69061. * @param serializeTexture defines if the texture must be serialized as well
  69062. * @returns a JSON compatible representation of the set
  69063. */
  69064. serialize(serializeTexture?: boolean): any;
  69065. /**
  69066. * Parse a new ParticleSystemSet from a serialized source
  69067. * @param data defines a JSON compatible representation of the set
  69068. * @param scene defines the hosting scene
  69069. * @param gpu defines if we want GPU particles or CPU particles
  69070. * @returns a new ParticleSystemSet
  69071. */
  69072. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69073. }
  69074. }
  69075. declare module BABYLON {
  69076. /**
  69077. * This class is made for on one-liner static method to help creating particle system set.
  69078. */
  69079. export class ParticleHelper {
  69080. /**
  69081. * Gets or sets base Assets URL
  69082. */
  69083. static BaseAssetsUrl: string;
  69084. /** Define the Url to load snippets */
  69085. static SnippetUrl: string;
  69086. /**
  69087. * Create a default particle system that you can tweak
  69088. * @param emitter defines the emitter to use
  69089. * @param capacity defines the system capacity (default is 500 particles)
  69090. * @param scene defines the hosting scene
  69091. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69092. * @returns the new Particle system
  69093. */
  69094. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69095. /**
  69096. * This is the main static method (one-liner) of this helper to create different particle systems
  69097. * @param type This string represents the type to the particle system to create
  69098. * @param scene The scene where the particle system should live
  69099. * @param gpu If the system will use gpu
  69100. * @returns the ParticleSystemSet created
  69101. */
  69102. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69103. /**
  69104. * Static function used to export a particle system to a ParticleSystemSet variable.
  69105. * Please note that the emitter shape is not exported
  69106. * @param systems defines the particle systems to export
  69107. * @returns the created particle system set
  69108. */
  69109. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69110. /**
  69111. * Creates a particle system from a snippet saved in a remote file
  69112. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69113. * @param url defines the url to load from
  69114. * @param scene defines the hosting scene
  69115. * @param gpu If the system will use gpu
  69116. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69117. * @returns a promise that will resolve to the new particle system
  69118. */
  69119. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69120. /**
  69121. * Creates a particle system from a snippet saved by the particle system editor
  69122. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69123. * @param scene defines the hosting scene
  69124. * @param gpu If the system will use gpu
  69125. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69126. * @returns a promise that will resolve to the new particle system
  69127. */
  69128. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69129. }
  69130. }
  69131. declare module BABYLON {
  69132. interface Engine {
  69133. /**
  69134. * Create an effect to use with particle systems.
  69135. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69136. * the particle system for which you want to create a custom effect in the last parameter
  69137. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69138. * @param uniformsNames defines a list of attribute names
  69139. * @param samplers defines an array of string used to represent textures
  69140. * @param defines defines the string containing the defines to use to compile the shaders
  69141. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69142. * @param onCompiled defines a function to call when the effect creation is successful
  69143. * @param onError defines a function to call when the effect creation has failed
  69144. * @param particleSystem the particle system you want to create the effect for
  69145. * @returns the new Effect
  69146. */
  69147. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69148. }
  69149. interface Mesh {
  69150. /**
  69151. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69152. * @returns an array of IParticleSystem
  69153. */
  69154. getEmittedParticleSystems(): IParticleSystem[];
  69155. /**
  69156. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69157. * @returns an array of IParticleSystem
  69158. */
  69159. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69160. }
  69161. }
  69162. declare module BABYLON {
  69163. /** Defines the 4 color options */
  69164. export enum PointColor {
  69165. /** color value */
  69166. Color = 2,
  69167. /** uv value */
  69168. UV = 1,
  69169. /** random value */
  69170. Random = 0,
  69171. /** stated value */
  69172. Stated = 3
  69173. }
  69174. /**
  69175. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69176. * 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.
  69177. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69178. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69179. *
  69180. * Full documentation here : TO BE ENTERED
  69181. */
  69182. export class PointsCloudSystem implements IDisposable {
  69183. /**
  69184. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69185. * Example : var p = SPS.particles[i];
  69186. */
  69187. particles: CloudPoint[];
  69188. /**
  69189. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69190. */
  69191. nbParticles: number;
  69192. /**
  69193. * This a counter for your own usage. It's not set by any SPS functions.
  69194. */
  69195. counter: number;
  69196. /**
  69197. * The PCS name. This name is also given to the underlying mesh.
  69198. */
  69199. name: string;
  69200. /**
  69201. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69202. */
  69203. mesh: Mesh;
  69204. /**
  69205. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69206. * Please read :
  69207. */
  69208. vars: any;
  69209. /**
  69210. * @hidden
  69211. */
  69212. _size: number;
  69213. private _scene;
  69214. private _promises;
  69215. private _positions;
  69216. private _indices;
  69217. private _normals;
  69218. private _colors;
  69219. private _uvs;
  69220. private _indices32;
  69221. private _positions32;
  69222. private _colors32;
  69223. private _uvs32;
  69224. private _updatable;
  69225. private _isVisibilityBoxLocked;
  69226. private _alwaysVisible;
  69227. private _groups;
  69228. private _groupCounter;
  69229. private _computeParticleColor;
  69230. private _computeParticleTexture;
  69231. private _computeParticleRotation;
  69232. private _computeBoundingBox;
  69233. private _isReady;
  69234. /**
  69235. * Creates a PCS (Points Cloud System) object
  69236. * @param name (String) is the PCS name, this will be the underlying mesh name
  69237. * @param pointSize (number) is the size for each point
  69238. * @param scene (Scene) is the scene in which the PCS is added
  69239. * @param options defines the options of the PCS e.g.
  69240. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69241. */
  69242. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69243. updatable?: boolean;
  69244. });
  69245. /**
  69246. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69247. * If no points were added to the PCS, the returned mesh is just a single point.
  69248. * @returns a promise for the created mesh
  69249. */
  69250. buildMeshAsync(): Promise<Mesh>;
  69251. /**
  69252. * @hidden
  69253. */
  69254. private _buildMesh;
  69255. private _addParticle;
  69256. private _randomUnitVector;
  69257. private _getColorIndicesForCoord;
  69258. private _setPointsColorOrUV;
  69259. private _colorFromTexture;
  69260. private _calculateDensity;
  69261. /**
  69262. * Adds points to the PCS in random positions within a unit sphere
  69263. * @param nb (positive integer) the number of particles to be created from this model
  69264. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69265. * @returns the number of groups in the system
  69266. */
  69267. addPoints(nb: number, pointFunction?: any): number;
  69268. /**
  69269. * Adds points to the PCS from the surface of the model shape
  69270. * @param mesh is any Mesh object that will be used as a surface model for the points
  69271. * @param nb (positive integer) the number of particles to be created from this model
  69272. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69273. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69274. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69275. * @returns the number of groups in the system
  69276. */
  69277. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69278. /**
  69279. * Adds points to the PCS inside the model shape
  69280. * @param mesh is any Mesh object that will be used as a surface model for the points
  69281. * @param nb (positive integer) the number of particles to be created from this model
  69282. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69283. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69284. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69285. * @returns the number of groups in the system
  69286. */
  69287. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69288. /**
  69289. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69290. * This method calls `updateParticle()` for each particle of the SPS.
  69291. * For an animated SPS, it is usually called within the render loop.
  69292. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69293. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69294. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69295. * @returns the PCS.
  69296. */
  69297. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69298. /**
  69299. * Disposes the PCS.
  69300. */
  69301. dispose(): void;
  69302. /**
  69303. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69304. * doc :
  69305. * @returns the PCS.
  69306. */
  69307. refreshVisibleSize(): PointsCloudSystem;
  69308. /**
  69309. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69310. * @param size the size (float) of the visibility box
  69311. * note : this doesn't lock the PCS mesh bounding box.
  69312. * doc :
  69313. */
  69314. setVisibilityBox(size: number): void;
  69315. /**
  69316. * Gets whether the PCS is always visible or not
  69317. * doc :
  69318. */
  69319. get isAlwaysVisible(): boolean;
  69320. /**
  69321. * Sets the PCS as always visible or not
  69322. * doc :
  69323. */
  69324. set isAlwaysVisible(val: boolean);
  69325. /**
  69326. * Tells to `setParticles()` to compute the particle rotations or not
  69327. * Default value : false. The PCS is faster when it's set to false
  69328. * Note : particle rotations are only applied to parent particles
  69329. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69330. */
  69331. set computeParticleRotation(val: boolean);
  69332. /**
  69333. * Tells to `setParticles()` to compute the particle colors or not.
  69334. * Default value : true. The PCS is faster when it's set to false.
  69335. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69336. */
  69337. set computeParticleColor(val: boolean);
  69338. set computeParticleTexture(val: boolean);
  69339. /**
  69340. * Gets if `setParticles()` computes the particle colors or not.
  69341. * Default value : false. The PCS is faster when it's set to false.
  69342. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69343. */
  69344. get computeParticleColor(): boolean;
  69345. /**
  69346. * Gets if `setParticles()` computes the particle textures or not.
  69347. * Default value : false. The PCS is faster when it's set to false.
  69348. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69349. */
  69350. get computeParticleTexture(): boolean;
  69351. /**
  69352. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69353. */
  69354. set computeBoundingBox(val: boolean);
  69355. /**
  69356. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69357. */
  69358. get computeBoundingBox(): boolean;
  69359. /**
  69360. * This function does nothing. It may be overwritten to set all the particle first values.
  69361. * The PCS doesn't call this function, you may have to call it by your own.
  69362. * doc :
  69363. */
  69364. initParticles(): void;
  69365. /**
  69366. * This function does nothing. It may be overwritten to recycle a particle
  69367. * The PCS doesn't call this function, you can to call it
  69368. * doc :
  69369. * @param particle The particle to recycle
  69370. * @returns the recycled particle
  69371. */
  69372. recycleParticle(particle: CloudPoint): CloudPoint;
  69373. /**
  69374. * Updates a particle : this function should be overwritten by the user.
  69375. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69376. * doc :
  69377. * @example : just set a particle position or velocity and recycle conditions
  69378. * @param particle The particle to update
  69379. * @returns the updated particle
  69380. */
  69381. updateParticle(particle: CloudPoint): CloudPoint;
  69382. /**
  69383. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69384. * This does nothing and may be overwritten by the user.
  69385. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69386. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69387. * @param update the boolean update value actually passed to setParticles()
  69388. */
  69389. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69390. /**
  69391. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69392. * This will be passed three parameters.
  69393. * This does nothing and may be overwritten by the user.
  69394. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69395. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69396. * @param update the boolean update value actually passed to setParticles()
  69397. */
  69398. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69399. }
  69400. }
  69401. declare module BABYLON {
  69402. /**
  69403. * Represents one particle of a points cloud system.
  69404. */
  69405. export class CloudPoint {
  69406. /**
  69407. * particle global index
  69408. */
  69409. idx: number;
  69410. /**
  69411. * The color of the particle
  69412. */
  69413. color: Nullable<Color4>;
  69414. /**
  69415. * The world space position of the particle.
  69416. */
  69417. position: Vector3;
  69418. /**
  69419. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69420. */
  69421. rotation: Vector3;
  69422. /**
  69423. * The world space rotation quaternion of the particle.
  69424. */
  69425. rotationQuaternion: Nullable<Quaternion>;
  69426. /**
  69427. * The uv of the particle.
  69428. */
  69429. uv: Nullable<Vector2>;
  69430. /**
  69431. * The current speed of the particle.
  69432. */
  69433. velocity: Vector3;
  69434. /**
  69435. * The pivot point in the particle local space.
  69436. */
  69437. pivot: Vector3;
  69438. /**
  69439. * Must the particle be translated from its pivot point in its local space ?
  69440. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69441. * Default : false
  69442. */
  69443. translateFromPivot: boolean;
  69444. /**
  69445. * Index of this particle in the global "positions" array (Internal use)
  69446. * @hidden
  69447. */
  69448. _pos: number;
  69449. /**
  69450. * @hidden Index of this particle in the global "indices" array (Internal use)
  69451. */
  69452. _ind: number;
  69453. /**
  69454. * Group this particle belongs to
  69455. */
  69456. _group: PointsGroup;
  69457. /**
  69458. * Group id of this particle
  69459. */
  69460. groupId: number;
  69461. /**
  69462. * Index of the particle in its group id (Internal use)
  69463. */
  69464. idxInGroup: number;
  69465. /**
  69466. * @hidden Particle BoundingInfo object (Internal use)
  69467. */
  69468. _boundingInfo: BoundingInfo;
  69469. /**
  69470. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69471. */
  69472. _pcs: PointsCloudSystem;
  69473. /**
  69474. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69475. */
  69476. _stillInvisible: boolean;
  69477. /**
  69478. * @hidden Last computed particle rotation matrix
  69479. */
  69480. _rotationMatrix: number[];
  69481. /**
  69482. * Parent particle Id, if any.
  69483. * Default null.
  69484. */
  69485. parentId: Nullable<number>;
  69486. /**
  69487. * @hidden Internal global position in the PCS.
  69488. */
  69489. _globalPosition: Vector3;
  69490. /**
  69491. * Creates a Point Cloud object.
  69492. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69493. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69494. * @param group (PointsGroup) is the group the particle belongs to
  69495. * @param groupId (integer) is the group identifier in the PCS.
  69496. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69497. * @param pcs defines the PCS it is associated to
  69498. */
  69499. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69500. /**
  69501. * get point size
  69502. */
  69503. get size(): Vector3;
  69504. /**
  69505. * Set point size
  69506. */
  69507. set size(scale: Vector3);
  69508. /**
  69509. * Legacy support, changed quaternion to rotationQuaternion
  69510. */
  69511. get quaternion(): Nullable<Quaternion>;
  69512. /**
  69513. * Legacy support, changed quaternion to rotationQuaternion
  69514. */
  69515. set quaternion(q: Nullable<Quaternion>);
  69516. /**
  69517. * Returns a boolean. True if the particle intersects a mesh, else false
  69518. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69519. * @param target is the object (point or mesh) what the intersection is computed against
  69520. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69521. * @returns true if it intersects
  69522. */
  69523. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69524. /**
  69525. * get the rotation matrix of the particle
  69526. * @hidden
  69527. */
  69528. getRotationMatrix(m: Matrix): void;
  69529. }
  69530. /**
  69531. * Represents a group of points in a points cloud system
  69532. * * PCS internal tool, don't use it manually.
  69533. */
  69534. export class PointsGroup {
  69535. /**
  69536. * The group id
  69537. * @hidden
  69538. */
  69539. groupID: number;
  69540. /**
  69541. * image data for group (internal use)
  69542. * @hidden
  69543. */
  69544. _groupImageData: Nullable<ArrayBufferView>;
  69545. /**
  69546. * Image Width (internal use)
  69547. * @hidden
  69548. */
  69549. _groupImgWidth: number;
  69550. /**
  69551. * Image Height (internal use)
  69552. * @hidden
  69553. */
  69554. _groupImgHeight: number;
  69555. /**
  69556. * Custom position function (internal use)
  69557. * @hidden
  69558. */
  69559. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69560. /**
  69561. * density per facet for surface points
  69562. * @hidden
  69563. */
  69564. _groupDensity: number[];
  69565. /**
  69566. * Only when points are colored by texture carries pointer to texture list array
  69567. * @hidden
  69568. */
  69569. _textureNb: number;
  69570. /**
  69571. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69572. * PCS internal tool, don't use it manually.
  69573. * @hidden
  69574. */
  69575. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69576. }
  69577. }
  69578. declare module BABYLON {
  69579. interface Scene {
  69580. /** @hidden (Backing field) */
  69581. _physicsEngine: Nullable<IPhysicsEngine>;
  69582. /** @hidden */
  69583. _physicsTimeAccumulator: number;
  69584. /**
  69585. * Gets the current physics engine
  69586. * @returns a IPhysicsEngine or null if none attached
  69587. */
  69588. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69589. /**
  69590. * Enables physics to the current scene
  69591. * @param gravity defines the scene's gravity for the physics engine
  69592. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69593. * @return a boolean indicating if the physics engine was initialized
  69594. */
  69595. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69596. /**
  69597. * Disables and disposes the physics engine associated with the scene
  69598. */
  69599. disablePhysicsEngine(): void;
  69600. /**
  69601. * Gets a boolean indicating if there is an active physics engine
  69602. * @returns a boolean indicating if there is an active physics engine
  69603. */
  69604. isPhysicsEnabled(): boolean;
  69605. /**
  69606. * Deletes a physics compound impostor
  69607. * @param compound defines the compound to delete
  69608. */
  69609. deleteCompoundImpostor(compound: any): void;
  69610. /**
  69611. * An event triggered when physic simulation is about to be run
  69612. */
  69613. onBeforePhysicsObservable: Observable<Scene>;
  69614. /**
  69615. * An event triggered when physic simulation has been done
  69616. */
  69617. onAfterPhysicsObservable: Observable<Scene>;
  69618. }
  69619. interface AbstractMesh {
  69620. /** @hidden */
  69621. _physicsImpostor: Nullable<PhysicsImpostor>;
  69622. /**
  69623. * Gets or sets impostor used for physic simulation
  69624. * @see https://doc.babylonjs.com/features/physics_engine
  69625. */
  69626. physicsImpostor: Nullable<PhysicsImpostor>;
  69627. /**
  69628. * Gets the current physics impostor
  69629. * @see https://doc.babylonjs.com/features/physics_engine
  69630. * @returns a physics impostor or null
  69631. */
  69632. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69633. /** Apply a physic impulse to the mesh
  69634. * @param force defines the force to apply
  69635. * @param contactPoint defines where to apply the force
  69636. * @returns the current mesh
  69637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69638. */
  69639. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69640. /**
  69641. * Creates a physic joint between two meshes
  69642. * @param otherMesh defines the other mesh to use
  69643. * @param pivot1 defines the pivot to use on this mesh
  69644. * @param pivot2 defines the pivot to use on the other mesh
  69645. * @param options defines additional options (can be plugin dependent)
  69646. * @returns the current mesh
  69647. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69648. */
  69649. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69650. /** @hidden */
  69651. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69652. }
  69653. /**
  69654. * Defines the physics engine scene component responsible to manage a physics engine
  69655. */
  69656. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69657. /**
  69658. * The component name helpful to identify the component in the list of scene components.
  69659. */
  69660. readonly name: string;
  69661. /**
  69662. * The scene the component belongs to.
  69663. */
  69664. scene: Scene;
  69665. /**
  69666. * Creates a new instance of the component for the given scene
  69667. * @param scene Defines the scene to register the component in
  69668. */
  69669. constructor(scene: Scene);
  69670. /**
  69671. * Registers the component in a given scene
  69672. */
  69673. register(): void;
  69674. /**
  69675. * Rebuilds the elements related to this component in case of
  69676. * context lost for instance.
  69677. */
  69678. rebuild(): void;
  69679. /**
  69680. * Disposes the component and the associated ressources
  69681. */
  69682. dispose(): void;
  69683. }
  69684. }
  69685. declare module BABYLON {
  69686. /**
  69687. * A helper for physics simulations
  69688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69689. */
  69690. export class PhysicsHelper {
  69691. private _scene;
  69692. private _physicsEngine;
  69693. /**
  69694. * Initializes the Physics helper
  69695. * @param scene Babylon.js scene
  69696. */
  69697. constructor(scene: Scene);
  69698. /**
  69699. * Applies a radial explosion impulse
  69700. * @param origin the origin of the explosion
  69701. * @param radiusOrEventOptions the radius or the options of radial explosion
  69702. * @param strength the explosion strength
  69703. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69704. * @returns A physics radial explosion event, or null
  69705. */
  69706. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69707. /**
  69708. * Applies a radial explosion force
  69709. * @param origin the origin of the explosion
  69710. * @param radiusOrEventOptions the radius or the options of radial explosion
  69711. * @param strength the explosion strength
  69712. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69713. * @returns A physics radial explosion event, or null
  69714. */
  69715. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69716. /**
  69717. * Creates a gravitational field
  69718. * @param origin the origin of the explosion
  69719. * @param radiusOrEventOptions the radius or the options of radial explosion
  69720. * @param strength the explosion strength
  69721. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69722. * @returns A physics gravitational field event, or null
  69723. */
  69724. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69725. /**
  69726. * Creates a physics updraft event
  69727. * @param origin the origin of the updraft
  69728. * @param radiusOrEventOptions the radius or the options of the updraft
  69729. * @param strength the strength of the updraft
  69730. * @param height the height of the updraft
  69731. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69732. * @returns A physics updraft event, or null
  69733. */
  69734. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69735. /**
  69736. * Creates a physics vortex event
  69737. * @param origin the of the vortex
  69738. * @param radiusOrEventOptions the radius or the options of the vortex
  69739. * @param strength the strength of the vortex
  69740. * @param height the height of the vortex
  69741. * @returns a Physics vortex event, or null
  69742. * A physics vortex event or null
  69743. */
  69744. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69745. }
  69746. /**
  69747. * Represents a physics radial explosion event
  69748. */
  69749. class PhysicsRadialExplosionEvent {
  69750. private _scene;
  69751. private _options;
  69752. private _sphere;
  69753. private _dataFetched;
  69754. /**
  69755. * Initializes a radial explosioin event
  69756. * @param _scene BabylonJS scene
  69757. * @param _options The options for the vortex event
  69758. */
  69759. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69760. /**
  69761. * Returns the data related to the radial explosion event (sphere).
  69762. * @returns The radial explosion event data
  69763. */
  69764. getData(): PhysicsRadialExplosionEventData;
  69765. /**
  69766. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69767. * @param impostor A physics imposter
  69768. * @param origin the origin of the explosion
  69769. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69770. */
  69771. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69772. /**
  69773. * Triggers affecterd impostors callbacks
  69774. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69775. */
  69776. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69777. /**
  69778. * Disposes the sphere.
  69779. * @param force Specifies if the sphere should be disposed by force
  69780. */
  69781. dispose(force?: boolean): void;
  69782. /*** Helpers ***/
  69783. private _prepareSphere;
  69784. private _intersectsWithSphere;
  69785. }
  69786. /**
  69787. * Represents a gravitational field event
  69788. */
  69789. class PhysicsGravitationalFieldEvent {
  69790. private _physicsHelper;
  69791. private _scene;
  69792. private _origin;
  69793. private _options;
  69794. private _tickCallback;
  69795. private _sphere;
  69796. private _dataFetched;
  69797. /**
  69798. * Initializes the physics gravitational field event
  69799. * @param _physicsHelper A physics helper
  69800. * @param _scene BabylonJS scene
  69801. * @param _origin The origin position of the gravitational field event
  69802. * @param _options The options for the vortex event
  69803. */
  69804. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69805. /**
  69806. * Returns the data related to the gravitational field event (sphere).
  69807. * @returns A gravitational field event
  69808. */
  69809. getData(): PhysicsGravitationalFieldEventData;
  69810. /**
  69811. * Enables the gravitational field.
  69812. */
  69813. enable(): void;
  69814. /**
  69815. * Disables the gravitational field.
  69816. */
  69817. disable(): void;
  69818. /**
  69819. * Disposes the sphere.
  69820. * @param force The force to dispose from the gravitational field event
  69821. */
  69822. dispose(force?: boolean): void;
  69823. private _tick;
  69824. }
  69825. /**
  69826. * Represents a physics updraft event
  69827. */
  69828. class PhysicsUpdraftEvent {
  69829. private _scene;
  69830. private _origin;
  69831. private _options;
  69832. private _physicsEngine;
  69833. private _originTop;
  69834. private _originDirection;
  69835. private _tickCallback;
  69836. private _cylinder;
  69837. private _cylinderPosition;
  69838. private _dataFetched;
  69839. /**
  69840. * Initializes the physics updraft event
  69841. * @param _scene BabylonJS scene
  69842. * @param _origin The origin position of the updraft
  69843. * @param _options The options for the updraft event
  69844. */
  69845. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69846. /**
  69847. * Returns the data related to the updraft event (cylinder).
  69848. * @returns A physics updraft event
  69849. */
  69850. getData(): PhysicsUpdraftEventData;
  69851. /**
  69852. * Enables the updraft.
  69853. */
  69854. enable(): void;
  69855. /**
  69856. * Disables the updraft.
  69857. */
  69858. disable(): void;
  69859. /**
  69860. * Disposes the cylinder.
  69861. * @param force Specifies if the updraft should be disposed by force
  69862. */
  69863. dispose(force?: boolean): void;
  69864. private getImpostorHitData;
  69865. private _tick;
  69866. /*** Helpers ***/
  69867. private _prepareCylinder;
  69868. private _intersectsWithCylinder;
  69869. }
  69870. /**
  69871. * Represents a physics vortex event
  69872. */
  69873. class PhysicsVortexEvent {
  69874. private _scene;
  69875. private _origin;
  69876. private _options;
  69877. private _physicsEngine;
  69878. private _originTop;
  69879. private _tickCallback;
  69880. private _cylinder;
  69881. private _cylinderPosition;
  69882. private _dataFetched;
  69883. /**
  69884. * Initializes the physics vortex event
  69885. * @param _scene The BabylonJS scene
  69886. * @param _origin The origin position of the vortex
  69887. * @param _options The options for the vortex event
  69888. */
  69889. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69890. /**
  69891. * Returns the data related to the vortex event (cylinder).
  69892. * @returns The physics vortex event data
  69893. */
  69894. getData(): PhysicsVortexEventData;
  69895. /**
  69896. * Enables the vortex.
  69897. */
  69898. enable(): void;
  69899. /**
  69900. * Disables the cortex.
  69901. */
  69902. disable(): void;
  69903. /**
  69904. * Disposes the sphere.
  69905. * @param force
  69906. */
  69907. dispose(force?: boolean): void;
  69908. private getImpostorHitData;
  69909. private _tick;
  69910. /*** Helpers ***/
  69911. private _prepareCylinder;
  69912. private _intersectsWithCylinder;
  69913. }
  69914. /**
  69915. * Options fot the radial explosion event
  69916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69917. */
  69918. export class PhysicsRadialExplosionEventOptions {
  69919. /**
  69920. * The radius of the sphere for the radial explosion.
  69921. */
  69922. radius: number;
  69923. /**
  69924. * The strenth of the explosion.
  69925. */
  69926. strength: number;
  69927. /**
  69928. * The strenght of the force in correspondence to the distance of the affected object
  69929. */
  69930. falloff: PhysicsRadialImpulseFalloff;
  69931. /**
  69932. * Sphere options for the radial explosion.
  69933. */
  69934. sphere: {
  69935. segments: number;
  69936. diameter: number;
  69937. };
  69938. /**
  69939. * Sphere options for the radial explosion.
  69940. */
  69941. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69942. }
  69943. /**
  69944. * Options fot the updraft event
  69945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69946. */
  69947. export class PhysicsUpdraftEventOptions {
  69948. /**
  69949. * The radius of the cylinder for the vortex
  69950. */
  69951. radius: number;
  69952. /**
  69953. * The strenth of the updraft.
  69954. */
  69955. strength: number;
  69956. /**
  69957. * The height of the cylinder for the updraft.
  69958. */
  69959. height: number;
  69960. /**
  69961. * The mode for the the updraft.
  69962. */
  69963. updraftMode: PhysicsUpdraftMode;
  69964. }
  69965. /**
  69966. * Options fot the vortex event
  69967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69968. */
  69969. export class PhysicsVortexEventOptions {
  69970. /**
  69971. * The radius of the cylinder for the vortex
  69972. */
  69973. radius: number;
  69974. /**
  69975. * The strenth of the vortex.
  69976. */
  69977. strength: number;
  69978. /**
  69979. * The height of the cylinder for the vortex.
  69980. */
  69981. height: number;
  69982. /**
  69983. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69984. */
  69985. centripetalForceThreshold: number;
  69986. /**
  69987. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69988. */
  69989. centripetalForceMultiplier: number;
  69990. /**
  69991. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69992. */
  69993. centrifugalForceMultiplier: number;
  69994. /**
  69995. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69996. */
  69997. updraftForceMultiplier: number;
  69998. }
  69999. /**
  70000. * The strenght of the force in correspondence to the distance of the affected object
  70001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70002. */
  70003. export enum PhysicsRadialImpulseFalloff {
  70004. /** Defines that impulse is constant in strength across it's whole radius */
  70005. Constant = 0,
  70006. /** Defines that impulse gets weaker if it's further from the origin */
  70007. Linear = 1
  70008. }
  70009. /**
  70010. * The strength of the force in correspondence to the distance of the affected object
  70011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70012. */
  70013. export enum PhysicsUpdraftMode {
  70014. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70015. Center = 0,
  70016. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70017. Perpendicular = 1
  70018. }
  70019. /**
  70020. * Interface for a physics hit data
  70021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70022. */
  70023. export interface PhysicsHitData {
  70024. /**
  70025. * The force applied at the contact point
  70026. */
  70027. force: Vector3;
  70028. /**
  70029. * The contact point
  70030. */
  70031. contactPoint: Vector3;
  70032. /**
  70033. * The distance from the origin to the contact point
  70034. */
  70035. distanceFromOrigin: number;
  70036. }
  70037. /**
  70038. * Interface for radial explosion event data
  70039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70040. */
  70041. export interface PhysicsRadialExplosionEventData {
  70042. /**
  70043. * A sphere used for the radial explosion event
  70044. */
  70045. sphere: Mesh;
  70046. }
  70047. /**
  70048. * Interface for gravitational field event data
  70049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70050. */
  70051. export interface PhysicsGravitationalFieldEventData {
  70052. /**
  70053. * A sphere mesh used for the gravitational field event
  70054. */
  70055. sphere: Mesh;
  70056. }
  70057. /**
  70058. * Interface for updraft event data
  70059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70060. */
  70061. export interface PhysicsUpdraftEventData {
  70062. /**
  70063. * A cylinder used for the updraft event
  70064. */
  70065. cylinder: Mesh;
  70066. }
  70067. /**
  70068. * Interface for vortex event data
  70069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70070. */
  70071. export interface PhysicsVortexEventData {
  70072. /**
  70073. * A cylinder used for the vortex event
  70074. */
  70075. cylinder: Mesh;
  70076. }
  70077. /**
  70078. * Interface for an affected physics impostor
  70079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70080. */
  70081. export interface PhysicsAffectedImpostorWithData {
  70082. /**
  70083. * The impostor affected by the effect
  70084. */
  70085. impostor: PhysicsImpostor;
  70086. /**
  70087. * The data about the hit/horce from the explosion
  70088. */
  70089. hitData: PhysicsHitData;
  70090. }
  70091. }
  70092. declare module BABYLON {
  70093. /** @hidden */
  70094. export var blackAndWhitePixelShader: {
  70095. name: string;
  70096. shader: string;
  70097. };
  70098. }
  70099. declare module BABYLON {
  70100. /**
  70101. * Post process used to render in black and white
  70102. */
  70103. export class BlackAndWhitePostProcess extends PostProcess {
  70104. /**
  70105. * Linear about to convert he result to black and white (default: 1)
  70106. */
  70107. degree: number;
  70108. /**
  70109. * Gets a string identifying the name of the class
  70110. * @returns "BlackAndWhitePostProcess" string
  70111. */
  70112. getClassName(): string;
  70113. /**
  70114. * Creates a black and white post process
  70115. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70116. * @param name The name of the effect.
  70117. * @param options The required width/height ratio to downsize to before computing the render pass.
  70118. * @param camera The camera to apply the render pass to.
  70119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70120. * @param engine The engine which the post process will be applied. (default: current engine)
  70121. * @param reusable If the post process can be reused on the same frame. (default: false)
  70122. */
  70123. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70124. /** @hidden */
  70125. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70126. }
  70127. }
  70128. declare module BABYLON {
  70129. /**
  70130. * This represents a set of one or more post processes in Babylon.
  70131. * A post process can be used to apply a shader to a texture after it is rendered.
  70132. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70133. */
  70134. export class PostProcessRenderEffect {
  70135. private _postProcesses;
  70136. private _getPostProcesses;
  70137. private _singleInstance;
  70138. private _cameras;
  70139. private _indicesForCamera;
  70140. /**
  70141. * Name of the effect
  70142. * @hidden
  70143. */
  70144. _name: string;
  70145. /**
  70146. * Instantiates a post process render effect.
  70147. * A post process can be used to apply a shader to a texture after it is rendered.
  70148. * @param engine The engine the effect is tied to
  70149. * @param name The name of the effect
  70150. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70151. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70152. */
  70153. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70154. /**
  70155. * Checks if all the post processes in the effect are supported.
  70156. */
  70157. get isSupported(): boolean;
  70158. /**
  70159. * Updates the current state of the effect
  70160. * @hidden
  70161. */
  70162. _update(): void;
  70163. /**
  70164. * Attaches the effect on cameras
  70165. * @param cameras The camera to attach to.
  70166. * @hidden
  70167. */
  70168. _attachCameras(cameras: Camera): void;
  70169. /**
  70170. * Attaches the effect on cameras
  70171. * @param cameras The camera to attach to.
  70172. * @hidden
  70173. */
  70174. _attachCameras(cameras: Camera[]): void;
  70175. /**
  70176. * Detaches the effect on cameras
  70177. * @param cameras The camera to detatch from.
  70178. * @hidden
  70179. */
  70180. _detachCameras(cameras: Camera): void;
  70181. /**
  70182. * Detatches the effect on cameras
  70183. * @param cameras The camera to detatch from.
  70184. * @hidden
  70185. */
  70186. _detachCameras(cameras: Camera[]): void;
  70187. /**
  70188. * Enables the effect on given cameras
  70189. * @param cameras The camera to enable.
  70190. * @hidden
  70191. */
  70192. _enable(cameras: Camera): void;
  70193. /**
  70194. * Enables the effect on given cameras
  70195. * @param cameras The camera to enable.
  70196. * @hidden
  70197. */
  70198. _enable(cameras: Nullable<Camera[]>): void;
  70199. /**
  70200. * Disables the effect on the given cameras
  70201. * @param cameras The camera to disable.
  70202. * @hidden
  70203. */
  70204. _disable(cameras: Camera): void;
  70205. /**
  70206. * Disables the effect on the given cameras
  70207. * @param cameras The camera to disable.
  70208. * @hidden
  70209. */
  70210. _disable(cameras: Nullable<Camera[]>): void;
  70211. /**
  70212. * Gets a list of the post processes contained in the effect.
  70213. * @param camera The camera to get the post processes on.
  70214. * @returns The list of the post processes in the effect.
  70215. */
  70216. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70217. }
  70218. }
  70219. declare module BABYLON {
  70220. /** @hidden */
  70221. export var extractHighlightsPixelShader: {
  70222. name: string;
  70223. shader: string;
  70224. };
  70225. }
  70226. declare module BABYLON {
  70227. /**
  70228. * 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.
  70229. */
  70230. export class ExtractHighlightsPostProcess extends PostProcess {
  70231. /**
  70232. * The luminance threshold, pixels below this value will be set to black.
  70233. */
  70234. threshold: number;
  70235. /** @hidden */
  70236. _exposure: number;
  70237. /**
  70238. * Post process which has the input texture to be used when performing highlight extraction
  70239. * @hidden
  70240. */
  70241. _inputPostProcess: Nullable<PostProcess>;
  70242. /**
  70243. * Gets a string identifying the name of the class
  70244. * @returns "ExtractHighlightsPostProcess" string
  70245. */
  70246. getClassName(): string;
  70247. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70248. }
  70249. }
  70250. declare module BABYLON {
  70251. /** @hidden */
  70252. export var bloomMergePixelShader: {
  70253. name: string;
  70254. shader: string;
  70255. };
  70256. }
  70257. declare module BABYLON {
  70258. /**
  70259. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70260. */
  70261. export class BloomMergePostProcess extends PostProcess {
  70262. /** Weight of the bloom to be added to the original input. */
  70263. weight: number;
  70264. /**
  70265. * Gets a string identifying the name of the class
  70266. * @returns "BloomMergePostProcess" string
  70267. */
  70268. getClassName(): string;
  70269. /**
  70270. * Creates a new instance of @see BloomMergePostProcess
  70271. * @param name The name of the effect.
  70272. * @param originalFromInput Post process which's input will be used for the merge.
  70273. * @param blurred Blurred highlights post process which's output will be used.
  70274. * @param weight Weight of the bloom to be added to the original input.
  70275. * @param options The required width/height ratio to downsize to before computing the render pass.
  70276. * @param camera The camera to apply the render pass to.
  70277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70278. * @param engine The engine which the post process will be applied. (default: current engine)
  70279. * @param reusable If the post process can be reused on the same frame. (default: false)
  70280. * @param textureType Type of textures used when performing the post process. (default: 0)
  70281. * @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)
  70282. */
  70283. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70284. /** Weight of the bloom to be added to the original input. */
  70285. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70286. }
  70287. }
  70288. declare module BABYLON {
  70289. /**
  70290. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70291. */
  70292. export class BloomEffect extends PostProcessRenderEffect {
  70293. private bloomScale;
  70294. /**
  70295. * @hidden Internal
  70296. */
  70297. _effects: Array<PostProcess>;
  70298. /**
  70299. * @hidden Internal
  70300. */
  70301. _downscale: ExtractHighlightsPostProcess;
  70302. private _blurX;
  70303. private _blurY;
  70304. private _merge;
  70305. /**
  70306. * The luminance threshold to find bright areas of the image to bloom.
  70307. */
  70308. get threshold(): number;
  70309. set threshold(value: number);
  70310. /**
  70311. * The strength of the bloom.
  70312. */
  70313. get weight(): number;
  70314. set weight(value: number);
  70315. /**
  70316. * Specifies the size of the bloom blur kernel, relative to the final output size
  70317. */
  70318. get kernel(): number;
  70319. set kernel(value: number);
  70320. /**
  70321. * Creates a new instance of @see BloomEffect
  70322. * @param scene The scene the effect belongs to.
  70323. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70324. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70325. * @param bloomWeight The the strength of bloom.
  70326. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70327. * @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)
  70328. */
  70329. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70330. /**
  70331. * Disposes each of the internal effects for a given camera.
  70332. * @param camera The camera to dispose the effect on.
  70333. */
  70334. disposeEffects(camera: Camera): void;
  70335. /**
  70336. * @hidden Internal
  70337. */
  70338. _updateEffects(): void;
  70339. /**
  70340. * Internal
  70341. * @returns if all the contained post processes are ready.
  70342. * @hidden
  70343. */
  70344. _isReady(): boolean;
  70345. }
  70346. }
  70347. declare module BABYLON {
  70348. /** @hidden */
  70349. export var chromaticAberrationPixelShader: {
  70350. name: string;
  70351. shader: string;
  70352. };
  70353. }
  70354. declare module BABYLON {
  70355. /**
  70356. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70357. */
  70358. export class ChromaticAberrationPostProcess extends PostProcess {
  70359. /**
  70360. * The amount of seperation of rgb channels (default: 30)
  70361. */
  70362. aberrationAmount: number;
  70363. /**
  70364. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70365. */
  70366. radialIntensity: number;
  70367. /**
  70368. * 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))
  70369. */
  70370. direction: Vector2;
  70371. /**
  70372. * 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))
  70373. */
  70374. centerPosition: Vector2;
  70375. /** The width of the screen to apply the effect on */
  70376. screenWidth: number;
  70377. /** The height of the screen to apply the effect on */
  70378. screenHeight: number;
  70379. /**
  70380. * Gets a string identifying the name of the class
  70381. * @returns "ChromaticAberrationPostProcess" string
  70382. */
  70383. getClassName(): string;
  70384. /**
  70385. * Creates a new instance ChromaticAberrationPostProcess
  70386. * @param name The name of the effect.
  70387. * @param screenWidth The width of the screen to apply the effect on.
  70388. * @param screenHeight The height of the screen to apply the effect on.
  70389. * @param options The required width/height ratio to downsize to before computing the render pass.
  70390. * @param camera The camera to apply the render pass to.
  70391. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70392. * @param engine The engine which the post process will be applied. (default: current engine)
  70393. * @param reusable If the post process can be reused on the same frame. (default: false)
  70394. * @param textureType Type of textures used when performing the post process. (default: 0)
  70395. * @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)
  70396. */
  70397. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70398. /** @hidden */
  70399. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70400. }
  70401. }
  70402. declare module BABYLON {
  70403. /** @hidden */
  70404. export var circleOfConfusionPixelShader: {
  70405. name: string;
  70406. shader: string;
  70407. };
  70408. }
  70409. declare module BABYLON {
  70410. /**
  70411. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70412. */
  70413. export class CircleOfConfusionPostProcess extends PostProcess {
  70414. /**
  70415. * 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.
  70416. */
  70417. lensSize: number;
  70418. /**
  70419. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70420. */
  70421. fStop: number;
  70422. /**
  70423. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70424. */
  70425. focusDistance: number;
  70426. /**
  70427. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70428. */
  70429. focalLength: number;
  70430. /**
  70431. * Gets a string identifying the name of the class
  70432. * @returns "CircleOfConfusionPostProcess" string
  70433. */
  70434. getClassName(): string;
  70435. private _depthTexture;
  70436. /**
  70437. * Creates a new instance CircleOfConfusionPostProcess
  70438. * @param name The name of the effect.
  70439. * @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.
  70440. * @param options The required width/height ratio to downsize to before computing the render pass.
  70441. * @param camera The camera to apply the render pass to.
  70442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70443. * @param engine The engine which the post process will be applied. (default: current engine)
  70444. * @param reusable If the post process can be reused on the same frame. (default: false)
  70445. * @param textureType Type of textures used when performing the post process. (default: 0)
  70446. * @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)
  70447. */
  70448. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70449. /**
  70450. * 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.
  70451. */
  70452. set depthTexture(value: RenderTargetTexture);
  70453. }
  70454. }
  70455. declare module BABYLON {
  70456. /** @hidden */
  70457. export var colorCorrectionPixelShader: {
  70458. name: string;
  70459. shader: string;
  70460. };
  70461. }
  70462. declare module BABYLON {
  70463. /**
  70464. *
  70465. * This post-process allows the modification of rendered colors by using
  70466. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70467. *
  70468. * The object needs to be provided an url to a texture containing the color
  70469. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70470. * Use an image editing software to tweak the LUT to match your needs.
  70471. *
  70472. * For an example of a color LUT, see here:
  70473. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70474. * For explanations on color grading, see here:
  70475. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70476. *
  70477. */
  70478. export class ColorCorrectionPostProcess extends PostProcess {
  70479. private _colorTableTexture;
  70480. /**
  70481. * Gets the color table url used to create the LUT texture
  70482. */
  70483. colorTableUrl: string;
  70484. /**
  70485. * Gets a string identifying the name of the class
  70486. * @returns "ColorCorrectionPostProcess" string
  70487. */
  70488. getClassName(): string;
  70489. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70490. /** @hidden */
  70491. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70492. }
  70493. }
  70494. declare module BABYLON {
  70495. /** @hidden */
  70496. export var convolutionPixelShader: {
  70497. name: string;
  70498. shader: string;
  70499. };
  70500. }
  70501. declare module BABYLON {
  70502. /**
  70503. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70504. * input texture to perform effects such as edge detection or sharpening
  70505. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70506. */
  70507. export class ConvolutionPostProcess extends PostProcess {
  70508. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70509. kernel: number[];
  70510. /**
  70511. * Gets a string identifying the name of the class
  70512. * @returns "ConvolutionPostProcess" string
  70513. */
  70514. getClassName(): string;
  70515. /**
  70516. * Creates a new instance ConvolutionPostProcess
  70517. * @param name The name of the effect.
  70518. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70519. * @param options The required width/height ratio to downsize to before computing the render pass.
  70520. * @param camera The camera to apply the render pass to.
  70521. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70522. * @param engine The engine which the post process will be applied. (default: current engine)
  70523. * @param reusable If the post process can be reused on the same frame. (default: false)
  70524. * @param textureType Type of textures used when performing the post process. (default: 0)
  70525. */
  70526. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70527. /** @hidden */
  70528. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70529. /**
  70530. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70531. */
  70532. static EdgeDetect0Kernel: number[];
  70533. /**
  70534. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70535. */
  70536. static EdgeDetect1Kernel: number[];
  70537. /**
  70538. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70539. */
  70540. static EdgeDetect2Kernel: number[];
  70541. /**
  70542. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70543. */
  70544. static SharpenKernel: number[];
  70545. /**
  70546. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70547. */
  70548. static EmbossKernel: number[];
  70549. /**
  70550. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70551. */
  70552. static GaussianKernel: number[];
  70553. }
  70554. }
  70555. declare module BABYLON {
  70556. /**
  70557. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70558. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70559. * based on samples that have a large difference in distance than the center pixel.
  70560. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70561. */
  70562. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70563. /**
  70564. * The direction the blur should be applied
  70565. */
  70566. direction: Vector2;
  70567. /**
  70568. * Gets a string identifying the name of the class
  70569. * @returns "DepthOfFieldBlurPostProcess" string
  70570. */
  70571. getClassName(): string;
  70572. /**
  70573. * Creates a new instance CircleOfConfusionPostProcess
  70574. * @param name The name of the effect.
  70575. * @param scene The scene the effect belongs to.
  70576. * @param direction The direction the blur should be applied.
  70577. * @param kernel The size of the kernel used to blur.
  70578. * @param options The required width/height ratio to downsize to before computing the render pass.
  70579. * @param camera The camera to apply the render pass to.
  70580. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70581. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70583. * @param engine The engine which the post process will be applied. (default: current engine)
  70584. * @param reusable If the post process can be reused on the same frame. (default: false)
  70585. * @param textureType Type of textures used when performing the post process. (default: 0)
  70586. * @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)
  70587. */
  70588. 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);
  70589. }
  70590. }
  70591. declare module BABYLON {
  70592. /** @hidden */
  70593. export var depthOfFieldMergePixelShader: {
  70594. name: string;
  70595. shader: string;
  70596. };
  70597. }
  70598. declare module BABYLON {
  70599. /**
  70600. * Options to be set when merging outputs from the default pipeline.
  70601. */
  70602. export class DepthOfFieldMergePostProcessOptions {
  70603. /**
  70604. * The original image to merge on top of
  70605. */
  70606. originalFromInput: PostProcess;
  70607. /**
  70608. * Parameters to perform the merge of the depth of field effect
  70609. */
  70610. depthOfField?: {
  70611. circleOfConfusion: PostProcess;
  70612. blurSteps: Array<PostProcess>;
  70613. };
  70614. /**
  70615. * Parameters to perform the merge of bloom effect
  70616. */
  70617. bloom?: {
  70618. blurred: PostProcess;
  70619. weight: number;
  70620. };
  70621. }
  70622. /**
  70623. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70624. */
  70625. export class DepthOfFieldMergePostProcess extends PostProcess {
  70626. private blurSteps;
  70627. /**
  70628. * Gets a string identifying the name of the class
  70629. * @returns "DepthOfFieldMergePostProcess" string
  70630. */
  70631. getClassName(): string;
  70632. /**
  70633. * Creates a new instance of DepthOfFieldMergePostProcess
  70634. * @param name The name of the effect.
  70635. * @param originalFromInput Post process which's input will be used for the merge.
  70636. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70637. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70638. * @param options The required width/height ratio to downsize to before computing the render pass.
  70639. * @param camera The camera to apply the render pass to.
  70640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70641. * @param engine The engine which the post process will be applied. (default: current engine)
  70642. * @param reusable If the post process can be reused on the same frame. (default: false)
  70643. * @param textureType Type of textures used when performing the post process. (default: 0)
  70644. * @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)
  70645. */
  70646. 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);
  70647. /**
  70648. * Updates the effect with the current post process compile time values and recompiles the shader.
  70649. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70650. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70651. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70652. * @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
  70653. * @param onCompiled Called when the shader has been compiled.
  70654. * @param onError Called if there is an error when compiling a shader.
  70655. */
  70656. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70657. }
  70658. }
  70659. declare module BABYLON {
  70660. /**
  70661. * Specifies the level of max blur that should be applied when using the depth of field effect
  70662. */
  70663. export enum DepthOfFieldEffectBlurLevel {
  70664. /**
  70665. * Subtle blur
  70666. */
  70667. Low = 0,
  70668. /**
  70669. * Medium blur
  70670. */
  70671. Medium = 1,
  70672. /**
  70673. * Large blur
  70674. */
  70675. High = 2
  70676. }
  70677. /**
  70678. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70679. */
  70680. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70681. private _circleOfConfusion;
  70682. /**
  70683. * @hidden Internal, blurs from high to low
  70684. */
  70685. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70686. private _depthOfFieldBlurY;
  70687. private _dofMerge;
  70688. /**
  70689. * @hidden Internal post processes in depth of field effect
  70690. */
  70691. _effects: Array<PostProcess>;
  70692. /**
  70693. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70694. */
  70695. set focalLength(value: number);
  70696. get focalLength(): number;
  70697. /**
  70698. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70699. */
  70700. set fStop(value: number);
  70701. get fStop(): number;
  70702. /**
  70703. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70704. */
  70705. set focusDistance(value: number);
  70706. get focusDistance(): number;
  70707. /**
  70708. * 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.
  70709. */
  70710. set lensSize(value: number);
  70711. get lensSize(): number;
  70712. /**
  70713. * Creates a new instance DepthOfFieldEffect
  70714. * @param scene The scene the effect belongs to.
  70715. * @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.
  70716. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70717. * @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)
  70718. */
  70719. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70720. /**
  70721. * Get the current class name of the current effet
  70722. * @returns "DepthOfFieldEffect"
  70723. */
  70724. getClassName(): string;
  70725. /**
  70726. * 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.
  70727. */
  70728. set depthTexture(value: RenderTargetTexture);
  70729. /**
  70730. * Disposes each of the internal effects for a given camera.
  70731. * @param camera The camera to dispose the effect on.
  70732. */
  70733. disposeEffects(camera: Camera): void;
  70734. /**
  70735. * @hidden Internal
  70736. */
  70737. _updateEffects(): void;
  70738. /**
  70739. * Internal
  70740. * @returns if all the contained post processes are ready.
  70741. * @hidden
  70742. */
  70743. _isReady(): boolean;
  70744. }
  70745. }
  70746. declare module BABYLON {
  70747. /** @hidden */
  70748. export var displayPassPixelShader: {
  70749. name: string;
  70750. shader: string;
  70751. };
  70752. }
  70753. declare module BABYLON {
  70754. /**
  70755. * DisplayPassPostProcess which produces an output the same as it's input
  70756. */
  70757. export class DisplayPassPostProcess extends PostProcess {
  70758. /**
  70759. * Gets a string identifying the name of the class
  70760. * @returns "DisplayPassPostProcess" string
  70761. */
  70762. getClassName(): string;
  70763. /**
  70764. * Creates the DisplayPassPostProcess
  70765. * @param name The name of the effect.
  70766. * @param options The required width/height ratio to downsize to before computing the render pass.
  70767. * @param camera The camera to apply the render pass to.
  70768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70769. * @param engine The engine which the post process will be applied. (default: current engine)
  70770. * @param reusable If the post process can be reused on the same frame. (default: false)
  70771. */
  70772. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70773. /** @hidden */
  70774. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  70775. }
  70776. }
  70777. declare module BABYLON {
  70778. /** @hidden */
  70779. export var filterPixelShader: {
  70780. name: string;
  70781. shader: string;
  70782. };
  70783. }
  70784. declare module BABYLON {
  70785. /**
  70786. * Applies a kernel filter to the image
  70787. */
  70788. export class FilterPostProcess extends PostProcess {
  70789. /** The matrix to be applied to the image */
  70790. kernelMatrix: Matrix;
  70791. /**
  70792. * Gets a string identifying the name of the class
  70793. * @returns "FilterPostProcess" string
  70794. */
  70795. getClassName(): string;
  70796. /**
  70797. *
  70798. * @param name The name of the effect.
  70799. * @param kernelMatrix The matrix to be applied to the image
  70800. * @param options The required width/height ratio to downsize to before computing the render pass.
  70801. * @param camera The camera to apply the render pass to.
  70802. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70803. * @param engine The engine which the post process will be applied. (default: current engine)
  70804. * @param reusable If the post process can be reused on the same frame. (default: false)
  70805. */
  70806. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70807. /** @hidden */
  70808. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  70809. }
  70810. }
  70811. declare module BABYLON {
  70812. /** @hidden */
  70813. export var fxaaPixelShader: {
  70814. name: string;
  70815. shader: string;
  70816. };
  70817. }
  70818. declare module BABYLON {
  70819. /** @hidden */
  70820. export var fxaaVertexShader: {
  70821. name: string;
  70822. shader: string;
  70823. };
  70824. }
  70825. declare module BABYLON {
  70826. /**
  70827. * Fxaa post process
  70828. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70829. */
  70830. export class FxaaPostProcess extends PostProcess {
  70831. /**
  70832. * Gets a string identifying the name of the class
  70833. * @returns "FxaaPostProcess" string
  70834. */
  70835. getClassName(): string;
  70836. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70837. private _getDefines;
  70838. /** @hidden */
  70839. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  70840. }
  70841. }
  70842. declare module BABYLON {
  70843. /** @hidden */
  70844. export var grainPixelShader: {
  70845. name: string;
  70846. shader: string;
  70847. };
  70848. }
  70849. declare module BABYLON {
  70850. /**
  70851. * The GrainPostProcess adds noise to the image at mid luminance levels
  70852. */
  70853. export class GrainPostProcess extends PostProcess {
  70854. /**
  70855. * The intensity of the grain added (default: 30)
  70856. */
  70857. intensity: number;
  70858. /**
  70859. * If the grain should be randomized on every frame
  70860. */
  70861. animated: boolean;
  70862. /**
  70863. * Gets a string identifying the name of the class
  70864. * @returns "GrainPostProcess" string
  70865. */
  70866. getClassName(): string;
  70867. /**
  70868. * Creates a new instance of @see GrainPostProcess
  70869. * @param name The name of the effect.
  70870. * @param options The required width/height ratio to downsize to before computing the render pass.
  70871. * @param camera The camera to apply the render pass to.
  70872. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70873. * @param engine The engine which the post process will be applied. (default: current engine)
  70874. * @param reusable If the post process can be reused on the same frame. (default: false)
  70875. * @param textureType Type of textures used when performing the post process. (default: 0)
  70876. * @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)
  70877. */
  70878. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70879. /** @hidden */
  70880. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  70881. }
  70882. }
  70883. declare module BABYLON {
  70884. /** @hidden */
  70885. export var highlightsPixelShader: {
  70886. name: string;
  70887. shader: string;
  70888. };
  70889. }
  70890. declare module BABYLON {
  70891. /**
  70892. * Extracts highlights from the image
  70893. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70894. */
  70895. export class HighlightsPostProcess extends PostProcess {
  70896. /**
  70897. * Gets a string identifying the name of the class
  70898. * @returns "HighlightsPostProcess" string
  70899. */
  70900. getClassName(): string;
  70901. /**
  70902. * Extracts highlights from the image
  70903. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70904. * @param name The name of the effect.
  70905. * @param options The required width/height ratio to downsize to before computing the render pass.
  70906. * @param camera The camera to apply the render pass to.
  70907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70908. * @param engine The engine which the post process will be applied. (default: current engine)
  70909. * @param reusable If the post process can be reused on the same frame. (default: false)
  70910. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70911. */
  70912. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70913. }
  70914. }
  70915. declare module BABYLON {
  70916. /**
  70917. * Contains all parameters needed for the prepass to perform
  70918. * motion blur
  70919. */
  70920. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  70921. /**
  70922. * Is motion blur enabled
  70923. */
  70924. enabled: boolean;
  70925. /**
  70926. * Name of the configuration
  70927. */
  70928. name: string;
  70929. /**
  70930. * Textures that should be present in the MRT for this effect to work
  70931. */
  70932. readonly texturesRequired: number[];
  70933. }
  70934. }
  70935. declare module BABYLON {
  70936. interface Scene {
  70937. /** @hidden (Backing field) */
  70938. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70939. /**
  70940. * Gets or Sets the current geometry buffer associated to the scene.
  70941. */
  70942. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70943. /**
  70944. * Enables a GeometryBufferRender and associates it with the scene
  70945. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70946. * @returns the GeometryBufferRenderer
  70947. */
  70948. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70949. /**
  70950. * Disables the GeometryBufferRender associated with the scene
  70951. */
  70952. disableGeometryBufferRenderer(): void;
  70953. }
  70954. /**
  70955. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70956. * in several rendering techniques.
  70957. */
  70958. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70959. /**
  70960. * The component name helpful to identify the component in the list of scene components.
  70961. */
  70962. readonly name: string;
  70963. /**
  70964. * The scene the component belongs to.
  70965. */
  70966. scene: Scene;
  70967. /**
  70968. * Creates a new instance of the component for the given scene
  70969. * @param scene Defines the scene to register the component in
  70970. */
  70971. constructor(scene: Scene);
  70972. /**
  70973. * Registers the component in a given scene
  70974. */
  70975. register(): void;
  70976. /**
  70977. * Rebuilds the elements related to this component in case of
  70978. * context lost for instance.
  70979. */
  70980. rebuild(): void;
  70981. /**
  70982. * Disposes the component and the associated ressources
  70983. */
  70984. dispose(): void;
  70985. private _gatherRenderTargets;
  70986. }
  70987. }
  70988. declare module BABYLON {
  70989. /** @hidden */
  70990. export var motionBlurPixelShader: {
  70991. name: string;
  70992. shader: string;
  70993. };
  70994. }
  70995. declare module BABYLON {
  70996. /**
  70997. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70998. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70999. * As an example, all you have to do is to create the post-process:
  71000. * var mb = new BABYLON.MotionBlurPostProcess(
  71001. * 'mb', // The name of the effect.
  71002. * scene, // The scene containing the objects to blur according to their velocity.
  71003. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71004. * camera // The camera to apply the render pass to.
  71005. * );
  71006. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71007. */
  71008. export class MotionBlurPostProcess extends PostProcess {
  71009. /**
  71010. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71011. */
  71012. motionStrength: number;
  71013. /**
  71014. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71015. */
  71016. get motionBlurSamples(): number;
  71017. /**
  71018. * Sets the number of iterations to be used for motion blur quality
  71019. */
  71020. set motionBlurSamples(samples: number);
  71021. private _motionBlurSamples;
  71022. private _forceGeometryBuffer;
  71023. private _geometryBufferRenderer;
  71024. private _prePassRenderer;
  71025. /**
  71026. * Gets a string identifying the name of the class
  71027. * @returns "MotionBlurPostProcess" string
  71028. */
  71029. getClassName(): string;
  71030. /**
  71031. * Creates a new instance MotionBlurPostProcess
  71032. * @param name The name of the effect.
  71033. * @param scene The scene containing the objects to blur according to their velocity.
  71034. * @param options The required width/height ratio to downsize to before computing the render pass.
  71035. * @param camera The camera to apply the render pass to.
  71036. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71037. * @param engine The engine which the post process will be applied. (default: current engine)
  71038. * @param reusable If the post process can be reused on the same frame. (default: false)
  71039. * @param textureType Type of textures used when performing the post process. (default: 0)
  71040. * @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)
  71041. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71042. */
  71043. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71044. /**
  71045. * Excludes the given skinned mesh from computing bones velocities.
  71046. * 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.
  71047. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71048. */
  71049. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71050. /**
  71051. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71052. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71053. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71054. */
  71055. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71056. /**
  71057. * Disposes the post process.
  71058. * @param camera The camera to dispose the post process on.
  71059. */
  71060. dispose(camera?: Camera): void;
  71061. /** @hidden */
  71062. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  71063. }
  71064. }
  71065. declare module BABYLON {
  71066. /** @hidden */
  71067. export var refractionPixelShader: {
  71068. name: string;
  71069. shader: string;
  71070. };
  71071. }
  71072. declare module BABYLON {
  71073. /**
  71074. * Post process which applies a refractin texture
  71075. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71076. */
  71077. export class RefractionPostProcess extends PostProcess {
  71078. private _refTexture;
  71079. private _ownRefractionTexture;
  71080. /** the base color of the refraction (used to taint the rendering) */
  71081. color: Color3;
  71082. /** simulated refraction depth */
  71083. depth: number;
  71084. /** the coefficient of the base color (0 to remove base color tainting) */
  71085. colorLevel: number;
  71086. /** Gets the url used to load the refraction texture */
  71087. refractionTextureUrl: string;
  71088. /**
  71089. * Gets or sets the refraction texture
  71090. * Please note that you are responsible for disposing the texture if you set it manually
  71091. */
  71092. get refractionTexture(): Texture;
  71093. set refractionTexture(value: Texture);
  71094. /**
  71095. * Gets a string identifying the name of the class
  71096. * @returns "RefractionPostProcess" string
  71097. */
  71098. getClassName(): string;
  71099. /**
  71100. * Initializes the RefractionPostProcess
  71101. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71102. * @param name The name of the effect.
  71103. * @param refractionTextureUrl Url of the refraction texture to use
  71104. * @param color the base color of the refraction (used to taint the rendering)
  71105. * @param depth simulated refraction depth
  71106. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71107. * @param camera The camera to apply the render pass to.
  71108. * @param options The required width/height ratio to downsize to before computing the render pass.
  71109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71110. * @param engine The engine which the post process will be applied. (default: current engine)
  71111. * @param reusable If the post process can be reused on the same frame. (default: false)
  71112. */
  71113. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71114. /**
  71115. * Disposes of the post process
  71116. * @param camera Camera to dispose post process on
  71117. */
  71118. dispose(camera: Camera): void;
  71119. /** @hidden */
  71120. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71121. }
  71122. }
  71123. declare module BABYLON {
  71124. /** @hidden */
  71125. export var sharpenPixelShader: {
  71126. name: string;
  71127. shader: string;
  71128. };
  71129. }
  71130. declare module BABYLON {
  71131. /**
  71132. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71133. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71134. */
  71135. export class SharpenPostProcess extends PostProcess {
  71136. /**
  71137. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71138. */
  71139. colorAmount: number;
  71140. /**
  71141. * How much sharpness should be applied (default: 0.3)
  71142. */
  71143. edgeAmount: number;
  71144. /**
  71145. * Gets a string identifying the name of the class
  71146. * @returns "SharpenPostProcess" string
  71147. */
  71148. getClassName(): string;
  71149. /**
  71150. * Creates a new instance ConvolutionPostProcess
  71151. * @param name The name of the effect.
  71152. * @param options The required width/height ratio to downsize to before computing the render pass.
  71153. * @param camera The camera to apply the render pass to.
  71154. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71155. * @param engine The engine which the post process will be applied. (default: current engine)
  71156. * @param reusable If the post process can be reused on the same frame. (default: false)
  71157. * @param textureType Type of textures used when performing the post process. (default: 0)
  71158. * @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)
  71159. */
  71160. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71161. /** @hidden */
  71162. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71163. }
  71164. }
  71165. declare module BABYLON {
  71166. /**
  71167. * PostProcessRenderPipeline
  71168. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71169. */
  71170. export class PostProcessRenderPipeline {
  71171. private engine;
  71172. private _renderEffects;
  71173. private _renderEffectsForIsolatedPass;
  71174. /**
  71175. * List of inspectable custom properties (used by the Inspector)
  71176. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71177. */
  71178. inspectableCustomProperties: IInspectable[];
  71179. /**
  71180. * @hidden
  71181. */
  71182. protected _cameras: Camera[];
  71183. /** @hidden */
  71184. _name: string;
  71185. /**
  71186. * Gets pipeline name
  71187. */
  71188. get name(): string;
  71189. /** Gets the list of attached cameras */
  71190. get cameras(): Camera[];
  71191. /**
  71192. * Initializes a PostProcessRenderPipeline
  71193. * @param engine engine to add the pipeline to
  71194. * @param name name of the pipeline
  71195. */
  71196. constructor(engine: Engine, name: string);
  71197. /**
  71198. * Gets the class name
  71199. * @returns "PostProcessRenderPipeline"
  71200. */
  71201. getClassName(): string;
  71202. /**
  71203. * If all the render effects in the pipeline are supported
  71204. */
  71205. get isSupported(): boolean;
  71206. /**
  71207. * Adds an effect to the pipeline
  71208. * @param renderEffect the effect to add
  71209. */
  71210. addEffect(renderEffect: PostProcessRenderEffect): void;
  71211. /** @hidden */
  71212. _rebuild(): void;
  71213. /** @hidden */
  71214. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71215. /** @hidden */
  71216. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71217. /** @hidden */
  71218. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71219. /** @hidden */
  71220. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71221. /** @hidden */
  71222. _attachCameras(cameras: Camera, unique: boolean): void;
  71223. /** @hidden */
  71224. _attachCameras(cameras: Camera[], unique: boolean): void;
  71225. /** @hidden */
  71226. _detachCameras(cameras: Camera): void;
  71227. /** @hidden */
  71228. _detachCameras(cameras: Nullable<Camera[]>): void;
  71229. /** @hidden */
  71230. _update(): void;
  71231. /** @hidden */
  71232. _reset(): void;
  71233. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71234. /**
  71235. * Sets the required values to the prepass renderer.
  71236. * @param prePassRenderer defines the prepass renderer to setup.
  71237. * @returns true if the pre pass is needed.
  71238. */
  71239. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71240. /**
  71241. * Disposes of the pipeline
  71242. */
  71243. dispose(): void;
  71244. }
  71245. }
  71246. declare module BABYLON {
  71247. /**
  71248. * PostProcessRenderPipelineManager class
  71249. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71250. */
  71251. export class PostProcessRenderPipelineManager {
  71252. private _renderPipelines;
  71253. /**
  71254. * Initializes a PostProcessRenderPipelineManager
  71255. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71256. */
  71257. constructor();
  71258. /**
  71259. * Gets the list of supported render pipelines
  71260. */
  71261. get supportedPipelines(): PostProcessRenderPipeline[];
  71262. /**
  71263. * Adds a pipeline to the manager
  71264. * @param renderPipeline The pipeline to add
  71265. */
  71266. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71267. /**
  71268. * Attaches a camera to the pipeline
  71269. * @param renderPipelineName The name of the pipeline to attach to
  71270. * @param cameras the camera to attach
  71271. * @param unique if the camera can be attached multiple times to the pipeline
  71272. */
  71273. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71274. /**
  71275. * Detaches a camera from the pipeline
  71276. * @param renderPipelineName The name of the pipeline to detach from
  71277. * @param cameras the camera to detach
  71278. */
  71279. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71280. /**
  71281. * Enables an effect by name on a pipeline
  71282. * @param renderPipelineName the name of the pipeline to enable the effect in
  71283. * @param renderEffectName the name of the effect to enable
  71284. * @param cameras the cameras that the effect should be enabled on
  71285. */
  71286. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71287. /**
  71288. * Disables an effect by name on a pipeline
  71289. * @param renderPipelineName the name of the pipeline to disable the effect in
  71290. * @param renderEffectName the name of the effect to disable
  71291. * @param cameras the cameras that the effect should be disabled on
  71292. */
  71293. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71294. /**
  71295. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71296. */
  71297. update(): void;
  71298. /** @hidden */
  71299. _rebuild(): void;
  71300. /**
  71301. * Disposes of the manager and pipelines
  71302. */
  71303. dispose(): void;
  71304. }
  71305. }
  71306. declare module BABYLON {
  71307. interface Scene {
  71308. /** @hidden (Backing field) */
  71309. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71310. /**
  71311. * Gets the postprocess render pipeline manager
  71312. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71313. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71314. */
  71315. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71316. }
  71317. /**
  71318. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71319. */
  71320. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71321. /**
  71322. * The component name helpfull to identify the component in the list of scene components.
  71323. */
  71324. readonly name: string;
  71325. /**
  71326. * The scene the component belongs to.
  71327. */
  71328. scene: Scene;
  71329. /**
  71330. * Creates a new instance of the component for the given scene
  71331. * @param scene Defines the scene to register the component in
  71332. */
  71333. constructor(scene: Scene);
  71334. /**
  71335. * Registers the component in a given scene
  71336. */
  71337. register(): void;
  71338. /**
  71339. * Rebuilds the elements related to this component in case of
  71340. * context lost for instance.
  71341. */
  71342. rebuild(): void;
  71343. /**
  71344. * Disposes the component and the associated ressources
  71345. */
  71346. dispose(): void;
  71347. private _gatherRenderTargets;
  71348. }
  71349. }
  71350. declare module BABYLON {
  71351. /**
  71352. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71353. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71354. */
  71355. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71356. private _scene;
  71357. private _camerasToBeAttached;
  71358. /**
  71359. * ID of the sharpen post process,
  71360. */
  71361. private readonly SharpenPostProcessId;
  71362. /**
  71363. * @ignore
  71364. * ID of the image processing post process;
  71365. */
  71366. readonly ImageProcessingPostProcessId: string;
  71367. /**
  71368. * @ignore
  71369. * ID of the Fast Approximate Anti-Aliasing post process;
  71370. */
  71371. readonly FxaaPostProcessId: string;
  71372. /**
  71373. * ID of the chromatic aberration post process,
  71374. */
  71375. private readonly ChromaticAberrationPostProcessId;
  71376. /**
  71377. * ID of the grain post process
  71378. */
  71379. private readonly GrainPostProcessId;
  71380. /**
  71381. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71382. */
  71383. sharpen: SharpenPostProcess;
  71384. private _sharpenEffect;
  71385. private bloom;
  71386. /**
  71387. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71388. */
  71389. depthOfField: DepthOfFieldEffect;
  71390. /**
  71391. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71392. */
  71393. fxaa: FxaaPostProcess;
  71394. /**
  71395. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71396. */
  71397. imageProcessing: ImageProcessingPostProcess;
  71398. /**
  71399. * Chromatic aberration post process which will shift rgb colors in the image
  71400. */
  71401. chromaticAberration: ChromaticAberrationPostProcess;
  71402. private _chromaticAberrationEffect;
  71403. /**
  71404. * Grain post process which add noise to the image
  71405. */
  71406. grain: GrainPostProcess;
  71407. private _grainEffect;
  71408. /**
  71409. * Glow post process which adds a glow to emissive areas of the image
  71410. */
  71411. private _glowLayer;
  71412. /**
  71413. * Animations which can be used to tweak settings over a period of time
  71414. */
  71415. animations: Animation[];
  71416. private _imageProcessingConfigurationObserver;
  71417. private _sharpenEnabled;
  71418. private _bloomEnabled;
  71419. private _depthOfFieldEnabled;
  71420. private _depthOfFieldBlurLevel;
  71421. private _fxaaEnabled;
  71422. private _imageProcessingEnabled;
  71423. private _defaultPipelineTextureType;
  71424. private _bloomScale;
  71425. private _chromaticAberrationEnabled;
  71426. private _grainEnabled;
  71427. private _buildAllowed;
  71428. /**
  71429. * This is triggered each time the pipeline has been built.
  71430. */
  71431. onBuildObservable: Observable<DefaultRenderingPipeline>;
  71432. /**
  71433. * Gets active scene
  71434. */
  71435. get scene(): Scene;
  71436. /**
  71437. * Enable or disable the sharpen process from the pipeline
  71438. */
  71439. set sharpenEnabled(enabled: boolean);
  71440. get sharpenEnabled(): boolean;
  71441. private _resizeObserver;
  71442. private _hardwareScaleLevel;
  71443. private _bloomKernel;
  71444. /**
  71445. * Specifies the size of the bloom blur kernel, relative to the final output size
  71446. */
  71447. get bloomKernel(): number;
  71448. set bloomKernel(value: number);
  71449. /**
  71450. * Specifies the weight of the bloom in the final rendering
  71451. */
  71452. private _bloomWeight;
  71453. /**
  71454. * Specifies the luma threshold for the area that will be blurred by the bloom
  71455. */
  71456. private _bloomThreshold;
  71457. private _hdr;
  71458. /**
  71459. * The strength of the bloom.
  71460. */
  71461. set bloomWeight(value: number);
  71462. get bloomWeight(): number;
  71463. /**
  71464. * The strength of the bloom.
  71465. */
  71466. set bloomThreshold(value: number);
  71467. get bloomThreshold(): number;
  71468. /**
  71469. * The scale of the bloom, lower value will provide better performance.
  71470. */
  71471. set bloomScale(value: number);
  71472. get bloomScale(): number;
  71473. /**
  71474. * Enable or disable the bloom from the pipeline
  71475. */
  71476. set bloomEnabled(enabled: boolean);
  71477. get bloomEnabled(): boolean;
  71478. private _rebuildBloom;
  71479. /**
  71480. * If the depth of field is enabled.
  71481. */
  71482. get depthOfFieldEnabled(): boolean;
  71483. set depthOfFieldEnabled(enabled: boolean);
  71484. /**
  71485. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71486. */
  71487. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71488. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71489. /**
  71490. * If the anti aliasing is enabled.
  71491. */
  71492. set fxaaEnabled(enabled: boolean);
  71493. get fxaaEnabled(): boolean;
  71494. private _samples;
  71495. /**
  71496. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71497. */
  71498. set samples(sampleCount: number);
  71499. get samples(): number;
  71500. /**
  71501. * If image processing is enabled.
  71502. */
  71503. set imageProcessingEnabled(enabled: boolean);
  71504. get imageProcessingEnabled(): boolean;
  71505. /**
  71506. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71507. */
  71508. set glowLayerEnabled(enabled: boolean);
  71509. get glowLayerEnabled(): boolean;
  71510. /**
  71511. * Gets the glow layer (or null if not defined)
  71512. */
  71513. get glowLayer(): Nullable<GlowLayer>;
  71514. /**
  71515. * Enable or disable the chromaticAberration process from the pipeline
  71516. */
  71517. set chromaticAberrationEnabled(enabled: boolean);
  71518. get chromaticAberrationEnabled(): boolean;
  71519. /**
  71520. * Enable or disable the grain process from the pipeline
  71521. */
  71522. set grainEnabled(enabled: boolean);
  71523. get grainEnabled(): boolean;
  71524. /**
  71525. * @constructor
  71526. * @param name - The rendering pipeline name (default: "")
  71527. * @param hdr - If high dynamic range textures should be used (default: true)
  71528. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71529. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71530. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71531. */
  71532. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71533. /**
  71534. * Get the class name
  71535. * @returns "DefaultRenderingPipeline"
  71536. */
  71537. getClassName(): string;
  71538. /**
  71539. * Force the compilation of the entire pipeline.
  71540. */
  71541. prepare(): void;
  71542. private _hasCleared;
  71543. private _prevPostProcess;
  71544. private _prevPrevPostProcess;
  71545. private _setAutoClearAndTextureSharing;
  71546. private _depthOfFieldSceneObserver;
  71547. private _buildPipeline;
  71548. private _disposePostProcesses;
  71549. /**
  71550. * Adds a camera to the pipeline
  71551. * @param camera the camera to be added
  71552. */
  71553. addCamera(camera: Camera): void;
  71554. /**
  71555. * Removes a camera from the pipeline
  71556. * @param camera the camera to remove
  71557. */
  71558. removeCamera(camera: Camera): void;
  71559. /**
  71560. * Dispose of the pipeline and stop all post processes
  71561. */
  71562. dispose(): void;
  71563. /**
  71564. * Serialize the rendering pipeline (Used when exporting)
  71565. * @returns the serialized object
  71566. */
  71567. serialize(): any;
  71568. /**
  71569. * Parse the serialized pipeline
  71570. * @param source Source pipeline.
  71571. * @param scene The scene to load the pipeline to.
  71572. * @param rootUrl The URL of the serialized pipeline.
  71573. * @returns An instantiated pipeline from the serialized object.
  71574. */
  71575. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71576. }
  71577. }
  71578. declare module BABYLON {
  71579. /** @hidden */
  71580. export var lensHighlightsPixelShader: {
  71581. name: string;
  71582. shader: string;
  71583. };
  71584. }
  71585. declare module BABYLON {
  71586. /** @hidden */
  71587. export var depthOfFieldPixelShader: {
  71588. name: string;
  71589. shader: string;
  71590. };
  71591. }
  71592. declare module BABYLON {
  71593. /**
  71594. * BABYLON.JS Chromatic Aberration GLSL Shader
  71595. * Author: Olivier Guyot
  71596. * Separates very slightly R, G and B colors on the edges of the screen
  71597. * Inspired by Francois Tarlier & Martins Upitis
  71598. */
  71599. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71600. /**
  71601. * @ignore
  71602. * The chromatic aberration PostProcess id in the pipeline
  71603. */
  71604. LensChromaticAberrationEffect: string;
  71605. /**
  71606. * @ignore
  71607. * The highlights enhancing PostProcess id in the pipeline
  71608. */
  71609. HighlightsEnhancingEffect: string;
  71610. /**
  71611. * @ignore
  71612. * The depth-of-field PostProcess id in the pipeline
  71613. */
  71614. LensDepthOfFieldEffect: string;
  71615. private _scene;
  71616. private _depthTexture;
  71617. private _grainTexture;
  71618. private _chromaticAberrationPostProcess;
  71619. private _highlightsPostProcess;
  71620. private _depthOfFieldPostProcess;
  71621. private _edgeBlur;
  71622. private _grainAmount;
  71623. private _chromaticAberration;
  71624. private _distortion;
  71625. private _highlightsGain;
  71626. private _highlightsThreshold;
  71627. private _dofDistance;
  71628. private _dofAperture;
  71629. private _dofDarken;
  71630. private _dofPentagon;
  71631. private _blurNoise;
  71632. /**
  71633. * @constructor
  71634. *
  71635. * Effect parameters are as follow:
  71636. * {
  71637. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71638. * edge_blur: number; // from 0 to x (1 for realism)
  71639. * distortion: number; // from 0 to x (1 for realism)
  71640. * grain_amount: number; // from 0 to 1
  71641. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71642. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71643. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71644. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71645. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71646. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71647. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71648. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71649. * }
  71650. * Note: if an effect parameter is unset, effect is disabled
  71651. *
  71652. * @param name The rendering pipeline name
  71653. * @param parameters - An object containing all parameters (see above)
  71654. * @param scene The scene linked to this pipeline
  71655. * @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)
  71656. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71657. */
  71658. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71659. /**
  71660. * Get the class name
  71661. * @returns "LensRenderingPipeline"
  71662. */
  71663. getClassName(): string;
  71664. /**
  71665. * Gets associated scene
  71666. */
  71667. get scene(): Scene;
  71668. /**
  71669. * Gets or sets the edge blur
  71670. */
  71671. get edgeBlur(): number;
  71672. set edgeBlur(value: number);
  71673. /**
  71674. * Gets or sets the grain amount
  71675. */
  71676. get grainAmount(): number;
  71677. set grainAmount(value: number);
  71678. /**
  71679. * Gets or sets the chromatic aberration amount
  71680. */
  71681. get chromaticAberration(): number;
  71682. set chromaticAberration(value: number);
  71683. /**
  71684. * Gets or sets the depth of field aperture
  71685. */
  71686. get dofAperture(): number;
  71687. set dofAperture(value: number);
  71688. /**
  71689. * Gets or sets the edge distortion
  71690. */
  71691. get edgeDistortion(): number;
  71692. set edgeDistortion(value: number);
  71693. /**
  71694. * Gets or sets the depth of field distortion
  71695. */
  71696. get dofDistortion(): number;
  71697. set dofDistortion(value: number);
  71698. /**
  71699. * Gets or sets the darken out of focus amount
  71700. */
  71701. get darkenOutOfFocus(): number;
  71702. set darkenOutOfFocus(value: number);
  71703. /**
  71704. * Gets or sets a boolean indicating if blur noise is enabled
  71705. */
  71706. get blurNoise(): boolean;
  71707. set blurNoise(value: boolean);
  71708. /**
  71709. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71710. */
  71711. get pentagonBokeh(): boolean;
  71712. set pentagonBokeh(value: boolean);
  71713. /**
  71714. * Gets or sets the highlight grain amount
  71715. */
  71716. get highlightsGain(): number;
  71717. set highlightsGain(value: number);
  71718. /**
  71719. * Gets or sets the highlight threshold
  71720. */
  71721. get highlightsThreshold(): number;
  71722. set highlightsThreshold(value: number);
  71723. /**
  71724. * Sets the amount of blur at the edges
  71725. * @param amount blur amount
  71726. */
  71727. setEdgeBlur(amount: number): void;
  71728. /**
  71729. * Sets edge blur to 0
  71730. */
  71731. disableEdgeBlur(): void;
  71732. /**
  71733. * Sets the amout of grain
  71734. * @param amount Amount of grain
  71735. */
  71736. setGrainAmount(amount: number): void;
  71737. /**
  71738. * Set grain amount to 0
  71739. */
  71740. disableGrain(): void;
  71741. /**
  71742. * Sets the chromatic aberration amount
  71743. * @param amount amount of chromatic aberration
  71744. */
  71745. setChromaticAberration(amount: number): void;
  71746. /**
  71747. * Sets chromatic aberration amount to 0
  71748. */
  71749. disableChromaticAberration(): void;
  71750. /**
  71751. * Sets the EdgeDistortion amount
  71752. * @param amount amount of EdgeDistortion
  71753. */
  71754. setEdgeDistortion(amount: number): void;
  71755. /**
  71756. * Sets edge distortion to 0
  71757. */
  71758. disableEdgeDistortion(): void;
  71759. /**
  71760. * Sets the FocusDistance amount
  71761. * @param amount amount of FocusDistance
  71762. */
  71763. setFocusDistance(amount: number): void;
  71764. /**
  71765. * Disables depth of field
  71766. */
  71767. disableDepthOfField(): void;
  71768. /**
  71769. * Sets the Aperture amount
  71770. * @param amount amount of Aperture
  71771. */
  71772. setAperture(amount: number): void;
  71773. /**
  71774. * Sets the DarkenOutOfFocus amount
  71775. * @param amount amount of DarkenOutOfFocus
  71776. */
  71777. setDarkenOutOfFocus(amount: number): void;
  71778. private _pentagonBokehIsEnabled;
  71779. /**
  71780. * Creates a pentagon bokeh effect
  71781. */
  71782. enablePentagonBokeh(): void;
  71783. /**
  71784. * Disables the pentagon bokeh effect
  71785. */
  71786. disablePentagonBokeh(): void;
  71787. /**
  71788. * Enables noise blur
  71789. */
  71790. enableNoiseBlur(): void;
  71791. /**
  71792. * Disables noise blur
  71793. */
  71794. disableNoiseBlur(): void;
  71795. /**
  71796. * Sets the HighlightsGain amount
  71797. * @param amount amount of HighlightsGain
  71798. */
  71799. setHighlightsGain(amount: number): void;
  71800. /**
  71801. * Sets the HighlightsThreshold amount
  71802. * @param amount amount of HighlightsThreshold
  71803. */
  71804. setHighlightsThreshold(amount: number): void;
  71805. /**
  71806. * Disables highlights
  71807. */
  71808. disableHighlights(): void;
  71809. /**
  71810. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71811. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71812. */
  71813. dispose(disableDepthRender?: boolean): void;
  71814. private _createChromaticAberrationPostProcess;
  71815. private _createHighlightsPostProcess;
  71816. private _createDepthOfFieldPostProcess;
  71817. private _createGrainTexture;
  71818. }
  71819. }
  71820. declare module BABYLON {
  71821. /**
  71822. * Contains all parameters needed for the prepass to perform
  71823. * screen space subsurface scattering
  71824. */
  71825. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71826. /**
  71827. * Is subsurface enabled
  71828. */
  71829. enabled: boolean;
  71830. /**
  71831. * Name of the configuration
  71832. */
  71833. name: string;
  71834. /**
  71835. * Textures that should be present in the MRT for this effect to work
  71836. */
  71837. readonly texturesRequired: number[];
  71838. }
  71839. }
  71840. declare module BABYLON {
  71841. /** @hidden */
  71842. export var ssao2PixelShader: {
  71843. name: string;
  71844. shader: string;
  71845. };
  71846. }
  71847. declare module BABYLON {
  71848. /** @hidden */
  71849. export var ssaoCombinePixelShader: {
  71850. name: string;
  71851. shader: string;
  71852. };
  71853. }
  71854. declare module BABYLON {
  71855. /**
  71856. * Render pipeline to produce ssao effect
  71857. */
  71858. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71859. /**
  71860. * @ignore
  71861. * The PassPostProcess id in the pipeline that contains the original scene color
  71862. */
  71863. SSAOOriginalSceneColorEffect: string;
  71864. /**
  71865. * @ignore
  71866. * The SSAO PostProcess id in the pipeline
  71867. */
  71868. SSAORenderEffect: string;
  71869. /**
  71870. * @ignore
  71871. * The horizontal blur PostProcess id in the pipeline
  71872. */
  71873. SSAOBlurHRenderEffect: string;
  71874. /**
  71875. * @ignore
  71876. * The vertical blur PostProcess id in the pipeline
  71877. */
  71878. SSAOBlurVRenderEffect: string;
  71879. /**
  71880. * @ignore
  71881. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71882. */
  71883. SSAOCombineRenderEffect: string;
  71884. /**
  71885. * The output strength of the SSAO post-process. Default value is 1.0.
  71886. */
  71887. totalStrength: number;
  71888. /**
  71889. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71890. */
  71891. maxZ: number;
  71892. /**
  71893. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71894. */
  71895. minZAspect: number;
  71896. private _samples;
  71897. /**
  71898. * Number of samples used for the SSAO calculations. Default value is 8
  71899. */
  71900. set samples(n: number);
  71901. get samples(): number;
  71902. private _textureSamples;
  71903. /**
  71904. * Number of samples to use for antialiasing
  71905. */
  71906. set textureSamples(n: number);
  71907. get textureSamples(): number;
  71908. /**
  71909. * Force rendering the geometry through geometry buffer
  71910. */
  71911. private _forceGeometryBuffer;
  71912. /**
  71913. * Ratio object used for SSAO ratio and blur ratio
  71914. */
  71915. private _ratio;
  71916. /**
  71917. * Dynamically generated sphere sampler.
  71918. */
  71919. private _sampleSphere;
  71920. /**
  71921. * Blur filter offsets
  71922. */
  71923. private _samplerOffsets;
  71924. private _expensiveBlur;
  71925. /**
  71926. * If bilateral blur should be used
  71927. */
  71928. set expensiveBlur(b: boolean);
  71929. get expensiveBlur(): boolean;
  71930. /**
  71931. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71932. */
  71933. radius: number;
  71934. /**
  71935. * The base color of the SSAO post-process
  71936. * The final result is "base + ssao" between [0, 1]
  71937. */
  71938. base: number;
  71939. /**
  71940. * Support test.
  71941. */
  71942. static get IsSupported(): boolean;
  71943. private _scene;
  71944. private _randomTexture;
  71945. private _originalColorPostProcess;
  71946. private _ssaoPostProcess;
  71947. private _blurHPostProcess;
  71948. private _blurVPostProcess;
  71949. private _ssaoCombinePostProcess;
  71950. private _prePassRenderer;
  71951. /**
  71952. * Gets active scene
  71953. */
  71954. get scene(): Scene;
  71955. /**
  71956. * @constructor
  71957. * @param name The rendering pipeline name
  71958. * @param scene The scene linked to this pipeline
  71959. * @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 }
  71960. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71961. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71962. */
  71963. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71964. /**
  71965. * Get the class name
  71966. * @returns "SSAO2RenderingPipeline"
  71967. */
  71968. getClassName(): string;
  71969. /**
  71970. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71971. */
  71972. dispose(disableGeometryBufferRenderer?: boolean): void;
  71973. private _createBlurPostProcess;
  71974. /** @hidden */
  71975. _rebuild(): void;
  71976. private _bits;
  71977. private _radicalInverse_VdC;
  71978. private _hammersley;
  71979. private _hemisphereSample_uniform;
  71980. private _generateHemisphere;
  71981. private _getDefinesForSSAO;
  71982. private _createSSAOPostProcess;
  71983. private _createSSAOCombinePostProcess;
  71984. private _createRandomTexture;
  71985. /**
  71986. * Serialize the rendering pipeline (Used when exporting)
  71987. * @returns the serialized object
  71988. */
  71989. serialize(): any;
  71990. /**
  71991. * Parse the serialized pipeline
  71992. * @param source Source pipeline.
  71993. * @param scene The scene to load the pipeline to.
  71994. * @param rootUrl The URL of the serialized pipeline.
  71995. * @returns An instantiated pipeline from the serialized object.
  71996. */
  71997. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71998. }
  71999. }
  72000. declare module BABYLON {
  72001. /** @hidden */
  72002. export var ssaoPixelShader: {
  72003. name: string;
  72004. shader: string;
  72005. };
  72006. }
  72007. declare module BABYLON {
  72008. /**
  72009. * Render pipeline to produce ssao effect
  72010. */
  72011. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72012. /**
  72013. * @ignore
  72014. * The PassPostProcess id in the pipeline that contains the original scene color
  72015. */
  72016. SSAOOriginalSceneColorEffect: string;
  72017. /**
  72018. * @ignore
  72019. * The SSAO PostProcess id in the pipeline
  72020. */
  72021. SSAORenderEffect: string;
  72022. /**
  72023. * @ignore
  72024. * The horizontal blur PostProcess id in the pipeline
  72025. */
  72026. SSAOBlurHRenderEffect: string;
  72027. /**
  72028. * @ignore
  72029. * The vertical blur PostProcess id in the pipeline
  72030. */
  72031. SSAOBlurVRenderEffect: string;
  72032. /**
  72033. * @ignore
  72034. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72035. */
  72036. SSAOCombineRenderEffect: string;
  72037. /**
  72038. * The output strength of the SSAO post-process. Default value is 1.0.
  72039. */
  72040. totalStrength: number;
  72041. /**
  72042. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72043. */
  72044. radius: number;
  72045. /**
  72046. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72047. * Must not be equal to fallOff and superior to fallOff.
  72048. * Default value is 0.0075
  72049. */
  72050. area: number;
  72051. /**
  72052. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72053. * Must not be equal to area and inferior to area.
  72054. * Default value is 0.000001
  72055. */
  72056. fallOff: number;
  72057. /**
  72058. * The base color of the SSAO post-process
  72059. * The final result is "base + ssao" between [0, 1]
  72060. */
  72061. base: number;
  72062. private _scene;
  72063. private _depthTexture;
  72064. private _randomTexture;
  72065. private _originalColorPostProcess;
  72066. private _ssaoPostProcess;
  72067. private _blurHPostProcess;
  72068. private _blurVPostProcess;
  72069. private _ssaoCombinePostProcess;
  72070. private _firstUpdate;
  72071. /**
  72072. * Gets active scene
  72073. */
  72074. get scene(): Scene;
  72075. /**
  72076. * @constructor
  72077. * @param name - The rendering pipeline name
  72078. * @param scene - The scene linked to this pipeline
  72079. * @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 }
  72080. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72081. */
  72082. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72083. /**
  72084. * Get the class name
  72085. * @returns "SSAORenderingPipeline"
  72086. */
  72087. getClassName(): string;
  72088. /**
  72089. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72090. */
  72091. dispose(disableDepthRender?: boolean): void;
  72092. private _createBlurPostProcess;
  72093. /** @hidden */
  72094. _rebuild(): void;
  72095. private _createSSAOPostProcess;
  72096. private _createSSAOCombinePostProcess;
  72097. private _createRandomTexture;
  72098. }
  72099. }
  72100. declare module BABYLON {
  72101. /**
  72102. * Contains all parameters needed for the prepass to perform
  72103. * screen space reflections
  72104. */
  72105. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72106. /**
  72107. * Is ssr enabled
  72108. */
  72109. enabled: boolean;
  72110. /**
  72111. * Name of the configuration
  72112. */
  72113. name: string;
  72114. /**
  72115. * Textures that should be present in the MRT for this effect to work
  72116. */
  72117. readonly texturesRequired: number[];
  72118. }
  72119. }
  72120. declare module BABYLON {
  72121. /** @hidden */
  72122. export var screenSpaceReflectionPixelShader: {
  72123. name: string;
  72124. shader: string;
  72125. };
  72126. }
  72127. declare module BABYLON {
  72128. /**
  72129. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72130. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72131. */
  72132. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72133. /**
  72134. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72135. */
  72136. threshold: number;
  72137. /**
  72138. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72139. */
  72140. strength: number;
  72141. /**
  72142. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72143. */
  72144. reflectionSpecularFalloffExponent: number;
  72145. /**
  72146. * 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]
  72147. */
  72148. step: number;
  72149. /**
  72150. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72151. */
  72152. roughnessFactor: number;
  72153. private _forceGeometryBuffer;
  72154. private _geometryBufferRenderer;
  72155. private _prePassRenderer;
  72156. private _enableSmoothReflections;
  72157. private _reflectionSamples;
  72158. private _smoothSteps;
  72159. /**
  72160. * Gets a string identifying the name of the class
  72161. * @returns "ScreenSpaceReflectionPostProcess" string
  72162. */
  72163. getClassName(): string;
  72164. /**
  72165. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72166. * @param name The name of the effect.
  72167. * @param scene The scene containing the objects to calculate reflections.
  72168. * @param options The required width/height ratio to downsize to before computing the render pass.
  72169. * @param camera The camera to apply the render pass to.
  72170. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72171. * @param engine The engine which the post process will be applied. (default: current engine)
  72172. * @param reusable If the post process can be reused on the same frame. (default: false)
  72173. * @param textureType Type of textures used when performing the post process. (default: 0)
  72174. * @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)
  72175. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72176. */
  72177. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72178. /**
  72179. * Gets wether or not smoothing reflections is enabled.
  72180. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72181. */
  72182. get enableSmoothReflections(): boolean;
  72183. /**
  72184. * Sets wether or not smoothing reflections is enabled.
  72185. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72186. */
  72187. set enableSmoothReflections(enabled: boolean);
  72188. /**
  72189. * Gets the number of samples taken while computing reflections. More samples count is high,
  72190. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72191. */
  72192. get reflectionSamples(): number;
  72193. /**
  72194. * Sets the number of samples taken while computing reflections. More samples count is high,
  72195. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72196. */
  72197. set reflectionSamples(samples: number);
  72198. /**
  72199. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72200. * more the post-process will require GPU power and can generate a drop in FPS.
  72201. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72202. */
  72203. get smoothSteps(): number;
  72204. set smoothSteps(steps: number);
  72205. private _updateEffectDefines;
  72206. /** @hidden */
  72207. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72208. }
  72209. }
  72210. declare module BABYLON {
  72211. /** @hidden */
  72212. export var standardPixelShader: {
  72213. name: string;
  72214. shader: string;
  72215. };
  72216. }
  72217. declare module BABYLON {
  72218. /**
  72219. * Standard rendering pipeline
  72220. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72221. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72222. */
  72223. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72224. /**
  72225. * Public members
  72226. */
  72227. /**
  72228. * Post-process which contains the original scene color before the pipeline applies all the effects
  72229. */
  72230. originalPostProcess: Nullable<PostProcess>;
  72231. /**
  72232. * Post-process used to down scale an image x4
  72233. */
  72234. downSampleX4PostProcess: Nullable<PostProcess>;
  72235. /**
  72236. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72237. */
  72238. brightPassPostProcess: Nullable<PostProcess>;
  72239. /**
  72240. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72241. */
  72242. blurHPostProcesses: PostProcess[];
  72243. /**
  72244. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72245. */
  72246. blurVPostProcesses: PostProcess[];
  72247. /**
  72248. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72249. */
  72250. textureAdderPostProcess: Nullable<PostProcess>;
  72251. /**
  72252. * Post-process used to create volumetric lighting effect
  72253. */
  72254. volumetricLightPostProcess: Nullable<PostProcess>;
  72255. /**
  72256. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72257. */
  72258. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72259. /**
  72260. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72261. */
  72262. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72263. /**
  72264. * Post-process used to merge the volumetric light effect and the real scene color
  72265. */
  72266. volumetricLightMergePostProces: Nullable<PostProcess>;
  72267. /**
  72268. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72269. */
  72270. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72271. /**
  72272. * Base post-process used to calculate the average luminance of the final image for HDR
  72273. */
  72274. luminancePostProcess: Nullable<PostProcess>;
  72275. /**
  72276. * Post-processes used to create down sample post-processes in order to get
  72277. * the average luminance of the final image for HDR
  72278. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72279. */
  72280. luminanceDownSamplePostProcesses: PostProcess[];
  72281. /**
  72282. * Post-process used to create a HDR effect (light adaptation)
  72283. */
  72284. hdrPostProcess: Nullable<PostProcess>;
  72285. /**
  72286. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72287. */
  72288. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72289. /**
  72290. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72291. */
  72292. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72293. /**
  72294. * Post-process used to merge the final HDR post-process and the real scene color
  72295. */
  72296. hdrFinalPostProcess: Nullable<PostProcess>;
  72297. /**
  72298. * Post-process used to create a lens flare effect
  72299. */
  72300. lensFlarePostProcess: Nullable<PostProcess>;
  72301. /**
  72302. * Post-process that merges the result of the lens flare post-process and the real scene color
  72303. */
  72304. lensFlareComposePostProcess: Nullable<PostProcess>;
  72305. /**
  72306. * Post-process used to create a motion blur effect
  72307. */
  72308. motionBlurPostProcess: Nullable<PostProcess>;
  72309. /**
  72310. * Post-process used to create a depth of field effect
  72311. */
  72312. depthOfFieldPostProcess: Nullable<PostProcess>;
  72313. /**
  72314. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72315. */
  72316. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72317. /**
  72318. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72319. */
  72320. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72321. /**
  72322. * Represents the brightness threshold in order to configure the illuminated surfaces
  72323. */
  72324. brightThreshold: number;
  72325. /**
  72326. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72327. */
  72328. blurWidth: number;
  72329. /**
  72330. * Sets if the blur for highlighted surfaces must be only horizontal
  72331. */
  72332. horizontalBlur: boolean;
  72333. /**
  72334. * Gets the overall exposure used by the pipeline
  72335. */
  72336. get exposure(): number;
  72337. /**
  72338. * Sets the overall exposure used by the pipeline
  72339. */
  72340. set exposure(value: number);
  72341. /**
  72342. * Texture used typically to simulate "dirty" on camera lens
  72343. */
  72344. lensTexture: Nullable<Texture>;
  72345. /**
  72346. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72347. */
  72348. volumetricLightCoefficient: number;
  72349. /**
  72350. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72351. */
  72352. volumetricLightPower: number;
  72353. /**
  72354. * Used the set the blur intensity to smooth the volumetric lights
  72355. */
  72356. volumetricLightBlurScale: number;
  72357. /**
  72358. * Light (spot or directional) used to generate the volumetric lights rays
  72359. * The source light must have a shadow generate so the pipeline can get its
  72360. * depth map
  72361. */
  72362. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72363. /**
  72364. * For eye adaptation, represents the minimum luminance the eye can see
  72365. */
  72366. hdrMinimumLuminance: number;
  72367. /**
  72368. * For eye adaptation, represents the decrease luminance speed
  72369. */
  72370. hdrDecreaseRate: number;
  72371. /**
  72372. * For eye adaptation, represents the increase luminance speed
  72373. */
  72374. hdrIncreaseRate: number;
  72375. /**
  72376. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72377. */
  72378. get hdrAutoExposure(): boolean;
  72379. /**
  72380. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72381. */
  72382. set hdrAutoExposure(value: boolean);
  72383. /**
  72384. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72385. */
  72386. lensColorTexture: Nullable<Texture>;
  72387. /**
  72388. * The overall strengh for the lens flare effect
  72389. */
  72390. lensFlareStrength: number;
  72391. /**
  72392. * Dispersion coefficient for lens flare ghosts
  72393. */
  72394. lensFlareGhostDispersal: number;
  72395. /**
  72396. * Main lens flare halo width
  72397. */
  72398. lensFlareHaloWidth: number;
  72399. /**
  72400. * Based on the lens distortion effect, defines how much the lens flare result
  72401. * is distorted
  72402. */
  72403. lensFlareDistortionStrength: number;
  72404. /**
  72405. * Configures the blur intensity used for for lens flare (halo)
  72406. */
  72407. lensFlareBlurWidth: number;
  72408. /**
  72409. * Lens star texture must be used to simulate rays on the flares and is available
  72410. * in the documentation
  72411. */
  72412. lensStarTexture: Nullable<Texture>;
  72413. /**
  72414. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72415. * flare effect by taking account of the dirt texture
  72416. */
  72417. lensFlareDirtTexture: Nullable<Texture>;
  72418. /**
  72419. * Represents the focal length for the depth of field effect
  72420. */
  72421. depthOfFieldDistance: number;
  72422. /**
  72423. * Represents the blur intensity for the blurred part of the depth of field effect
  72424. */
  72425. depthOfFieldBlurWidth: number;
  72426. /**
  72427. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72428. */
  72429. get motionStrength(): number;
  72430. /**
  72431. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72432. */
  72433. set motionStrength(strength: number);
  72434. /**
  72435. * Gets wether or not the motion blur post-process is object based or screen based.
  72436. */
  72437. get objectBasedMotionBlur(): boolean;
  72438. /**
  72439. * Sets wether or not the motion blur post-process should be object based or screen based
  72440. */
  72441. set objectBasedMotionBlur(value: boolean);
  72442. /**
  72443. * List of animations for the pipeline (IAnimatable implementation)
  72444. */
  72445. animations: Animation[];
  72446. /**
  72447. * Private members
  72448. */
  72449. private _scene;
  72450. private _currentDepthOfFieldSource;
  72451. private _basePostProcess;
  72452. private _fixedExposure;
  72453. private _currentExposure;
  72454. private _hdrAutoExposure;
  72455. private _hdrCurrentLuminance;
  72456. private _motionStrength;
  72457. private _isObjectBasedMotionBlur;
  72458. private _floatTextureType;
  72459. private _camerasToBeAttached;
  72460. private _ratio;
  72461. private _bloomEnabled;
  72462. private _depthOfFieldEnabled;
  72463. private _vlsEnabled;
  72464. private _lensFlareEnabled;
  72465. private _hdrEnabled;
  72466. private _motionBlurEnabled;
  72467. private _fxaaEnabled;
  72468. private _screenSpaceReflectionsEnabled;
  72469. private _motionBlurSamples;
  72470. private _volumetricLightStepsCount;
  72471. private _samples;
  72472. /**
  72473. * @ignore
  72474. * Specifies if the bloom pipeline is enabled
  72475. */
  72476. get BloomEnabled(): boolean;
  72477. set BloomEnabled(enabled: boolean);
  72478. /**
  72479. * @ignore
  72480. * Specifies if the depth of field pipeline is enabed
  72481. */
  72482. get DepthOfFieldEnabled(): boolean;
  72483. set DepthOfFieldEnabled(enabled: boolean);
  72484. /**
  72485. * @ignore
  72486. * Specifies if the lens flare pipeline is enabed
  72487. */
  72488. get LensFlareEnabled(): boolean;
  72489. set LensFlareEnabled(enabled: boolean);
  72490. /**
  72491. * @ignore
  72492. * Specifies if the HDR pipeline is enabled
  72493. */
  72494. get HDREnabled(): boolean;
  72495. set HDREnabled(enabled: boolean);
  72496. /**
  72497. * @ignore
  72498. * Specifies if the volumetric lights scattering effect is enabled
  72499. */
  72500. get VLSEnabled(): boolean;
  72501. set VLSEnabled(enabled: boolean);
  72502. /**
  72503. * @ignore
  72504. * Specifies if the motion blur effect is enabled
  72505. */
  72506. get MotionBlurEnabled(): boolean;
  72507. set MotionBlurEnabled(enabled: boolean);
  72508. /**
  72509. * Specifies if anti-aliasing is enabled
  72510. */
  72511. get fxaaEnabled(): boolean;
  72512. set fxaaEnabled(enabled: boolean);
  72513. /**
  72514. * Specifies if screen space reflections are enabled.
  72515. */
  72516. get screenSpaceReflectionsEnabled(): boolean;
  72517. set screenSpaceReflectionsEnabled(enabled: boolean);
  72518. /**
  72519. * Specifies the number of steps used to calculate the volumetric lights
  72520. * Typically in interval [50, 200]
  72521. */
  72522. get volumetricLightStepsCount(): number;
  72523. set volumetricLightStepsCount(count: number);
  72524. /**
  72525. * Specifies the number of samples used for the motion blur effect
  72526. * Typically in interval [16, 64]
  72527. */
  72528. get motionBlurSamples(): number;
  72529. set motionBlurSamples(samples: number);
  72530. /**
  72531. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72532. */
  72533. get samples(): number;
  72534. set samples(sampleCount: number);
  72535. /**
  72536. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72537. * @constructor
  72538. * @param name The rendering pipeline name
  72539. * @param scene The scene linked to this pipeline
  72540. * @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)
  72541. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72542. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72543. */
  72544. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72545. private _buildPipeline;
  72546. private _createDownSampleX4PostProcess;
  72547. private _createBrightPassPostProcess;
  72548. private _createBlurPostProcesses;
  72549. private _createTextureAdderPostProcess;
  72550. private _createVolumetricLightPostProcess;
  72551. private _createLuminancePostProcesses;
  72552. private _createHdrPostProcess;
  72553. private _createLensFlarePostProcess;
  72554. private _createDepthOfFieldPostProcess;
  72555. private _createMotionBlurPostProcess;
  72556. private _getDepthTexture;
  72557. private _disposePostProcesses;
  72558. /**
  72559. * Dispose of the pipeline and stop all post processes
  72560. */
  72561. dispose(): void;
  72562. /**
  72563. * Serialize the rendering pipeline (Used when exporting)
  72564. * @returns the serialized object
  72565. */
  72566. serialize(): any;
  72567. /**
  72568. * Parse the serialized pipeline
  72569. * @param source Source pipeline.
  72570. * @param scene The scene to load the pipeline to.
  72571. * @param rootUrl The URL of the serialized pipeline.
  72572. * @returns An instantiated pipeline from the serialized object.
  72573. */
  72574. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72575. /**
  72576. * Luminance steps
  72577. */
  72578. static LuminanceSteps: number;
  72579. }
  72580. }
  72581. declare module BABYLON {
  72582. /** @hidden */
  72583. export var stereoscopicInterlacePixelShader: {
  72584. name: string;
  72585. shader: string;
  72586. };
  72587. }
  72588. declare module BABYLON {
  72589. /**
  72590. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72591. */
  72592. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72593. private _stepSize;
  72594. private _passedProcess;
  72595. /**
  72596. * Gets a string identifying the name of the class
  72597. * @returns "StereoscopicInterlacePostProcessI" string
  72598. */
  72599. getClassName(): string;
  72600. /**
  72601. * Initializes a StereoscopicInterlacePostProcessI
  72602. * @param name The name of the effect.
  72603. * @param rigCameras The rig cameras to be appled to the post process
  72604. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72605. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72606. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72607. * @param engine The engine which the post process will be applied. (default: current engine)
  72608. * @param reusable If the post process can be reused on the same frame. (default: false)
  72609. */
  72610. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72611. }
  72612. /**
  72613. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72614. */
  72615. export class StereoscopicInterlacePostProcess extends PostProcess {
  72616. private _stepSize;
  72617. private _passedProcess;
  72618. /**
  72619. * Gets a string identifying the name of the class
  72620. * @returns "StereoscopicInterlacePostProcess" string
  72621. */
  72622. getClassName(): string;
  72623. /**
  72624. * Initializes a StereoscopicInterlacePostProcess
  72625. * @param name The name of the effect.
  72626. * @param rigCameras The rig cameras to be appled to the post process
  72627. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72629. * @param engine The engine which the post process will be applied. (default: current engine)
  72630. * @param reusable If the post process can be reused on the same frame. (default: false)
  72631. */
  72632. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72633. }
  72634. }
  72635. declare module BABYLON {
  72636. /** @hidden */
  72637. export var tonemapPixelShader: {
  72638. name: string;
  72639. shader: string;
  72640. };
  72641. }
  72642. declare module BABYLON {
  72643. /** Defines operator used for tonemapping */
  72644. export enum TonemappingOperator {
  72645. /** Hable */
  72646. Hable = 0,
  72647. /** Reinhard */
  72648. Reinhard = 1,
  72649. /** HejiDawson */
  72650. HejiDawson = 2,
  72651. /** Photographic */
  72652. Photographic = 3
  72653. }
  72654. /**
  72655. * Defines a post process to apply tone mapping
  72656. */
  72657. export class TonemapPostProcess extends PostProcess {
  72658. private _operator;
  72659. /** Defines the required exposure adjustement */
  72660. exposureAdjustment: number;
  72661. /**
  72662. * Gets a string identifying the name of the class
  72663. * @returns "TonemapPostProcess" string
  72664. */
  72665. getClassName(): string;
  72666. /**
  72667. * Creates a new TonemapPostProcess
  72668. * @param name defines the name of the postprocess
  72669. * @param _operator defines the operator to use
  72670. * @param exposureAdjustment defines the required exposure adjustement
  72671. * @param camera defines the camera to use (can be null)
  72672. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72673. * @param engine defines the hosting engine (can be ignore if camera is set)
  72674. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72675. */
  72676. constructor(name: string, _operator: TonemappingOperator,
  72677. /** Defines the required exposure adjustement */
  72678. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72679. }
  72680. }
  72681. declare module BABYLON {
  72682. /** @hidden */
  72683. export var volumetricLightScatteringPixelShader: {
  72684. name: string;
  72685. shader: string;
  72686. };
  72687. }
  72688. declare module BABYLON {
  72689. /** @hidden */
  72690. export var volumetricLightScatteringPassVertexShader: {
  72691. name: string;
  72692. shader: string;
  72693. };
  72694. }
  72695. declare module BABYLON {
  72696. /** @hidden */
  72697. export var volumetricLightScatteringPassPixelShader: {
  72698. name: string;
  72699. shader: string;
  72700. };
  72701. }
  72702. declare module BABYLON {
  72703. /**
  72704. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72705. */
  72706. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72707. private _volumetricLightScatteringPass;
  72708. private _volumetricLightScatteringRTT;
  72709. private _viewPort;
  72710. private _screenCoordinates;
  72711. private _cachedDefines;
  72712. /**
  72713. * If not undefined, the mesh position is computed from the attached node position
  72714. */
  72715. attachedNode: {
  72716. position: Vector3;
  72717. };
  72718. /**
  72719. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72720. */
  72721. customMeshPosition: Vector3;
  72722. /**
  72723. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72724. */
  72725. useCustomMeshPosition: boolean;
  72726. /**
  72727. * If the post-process should inverse the light scattering direction
  72728. */
  72729. invert: boolean;
  72730. /**
  72731. * The internal mesh used by the post-process
  72732. */
  72733. mesh: Mesh;
  72734. /**
  72735. * @hidden
  72736. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72737. */
  72738. get useDiffuseColor(): boolean;
  72739. set useDiffuseColor(useDiffuseColor: boolean);
  72740. /**
  72741. * Array containing the excluded meshes not rendered in the internal pass
  72742. */
  72743. excludedMeshes: AbstractMesh[];
  72744. /**
  72745. * Controls the overall intensity of the post-process
  72746. */
  72747. exposure: number;
  72748. /**
  72749. * Dissipates each sample's contribution in range [0, 1]
  72750. */
  72751. decay: number;
  72752. /**
  72753. * Controls the overall intensity of each sample
  72754. */
  72755. weight: number;
  72756. /**
  72757. * Controls the density of each sample
  72758. */
  72759. density: number;
  72760. /**
  72761. * @constructor
  72762. * @param name The post-process name
  72763. * @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)
  72764. * @param camera The camera that the post-process will be attached to
  72765. * @param mesh The mesh used to create the light scattering
  72766. * @param samples The post-process quality, default 100
  72767. * @param samplingModeThe post-process filtering mode
  72768. * @param engine The babylon engine
  72769. * @param reusable If the post-process is reusable
  72770. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72771. */
  72772. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72773. /**
  72774. * Returns the string "VolumetricLightScatteringPostProcess"
  72775. * @returns "VolumetricLightScatteringPostProcess"
  72776. */
  72777. getClassName(): string;
  72778. private _isReady;
  72779. /**
  72780. * Sets the new light position for light scattering effect
  72781. * @param position The new custom light position
  72782. */
  72783. setCustomMeshPosition(position: Vector3): void;
  72784. /**
  72785. * Returns the light position for light scattering effect
  72786. * @return Vector3 The custom light position
  72787. */
  72788. getCustomMeshPosition(): Vector3;
  72789. /**
  72790. * Disposes the internal assets and detaches the post-process from the camera
  72791. */
  72792. dispose(camera: Camera): void;
  72793. /**
  72794. * Returns the render target texture used by the post-process
  72795. * @return the render target texture used by the post-process
  72796. */
  72797. getPass(): RenderTargetTexture;
  72798. private _meshExcluded;
  72799. private _createPass;
  72800. private _updateMeshScreenCoordinates;
  72801. /**
  72802. * Creates a default mesh for the Volumeric Light Scattering post-process
  72803. * @param name The mesh name
  72804. * @param scene The scene where to create the mesh
  72805. * @return the default mesh
  72806. */
  72807. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72808. }
  72809. }
  72810. declare module BABYLON {
  72811. /** @hidden */
  72812. export var screenSpaceCurvaturePixelShader: {
  72813. name: string;
  72814. shader: string;
  72815. };
  72816. }
  72817. declare module BABYLON {
  72818. /**
  72819. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72820. */
  72821. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72822. /**
  72823. * Defines how much ridge the curvature effect displays.
  72824. */
  72825. ridge: number;
  72826. /**
  72827. * Defines how much valley the curvature effect displays.
  72828. */
  72829. valley: number;
  72830. private _geometryBufferRenderer;
  72831. /**
  72832. * Gets a string identifying the name of the class
  72833. * @returns "ScreenSpaceCurvaturePostProcess" string
  72834. */
  72835. getClassName(): string;
  72836. /**
  72837. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72838. * @param name The name of the effect.
  72839. * @param scene The scene containing the objects to blur according to their velocity.
  72840. * @param options The required width/height ratio to downsize to before computing the render pass.
  72841. * @param camera The camera to apply the render pass to.
  72842. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72843. * @param engine The engine which the post process will be applied. (default: current engine)
  72844. * @param reusable If the post process can be reused on the same frame. (default: false)
  72845. * @param textureType Type of textures used when performing the post process. (default: 0)
  72846. * @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)
  72847. */
  72848. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72849. /**
  72850. * Support test.
  72851. */
  72852. static get IsSupported(): boolean;
  72853. /** @hidden */
  72854. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72855. }
  72856. }
  72857. declare module BABYLON {
  72858. interface Scene {
  72859. /** @hidden (Backing field) */
  72860. _boundingBoxRenderer: BoundingBoxRenderer;
  72861. /** @hidden (Backing field) */
  72862. _forceShowBoundingBoxes: boolean;
  72863. /**
  72864. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72865. */
  72866. forceShowBoundingBoxes: boolean;
  72867. /**
  72868. * Gets the bounding box renderer associated with the scene
  72869. * @returns a BoundingBoxRenderer
  72870. */
  72871. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72872. }
  72873. interface AbstractMesh {
  72874. /** @hidden (Backing field) */
  72875. _showBoundingBox: boolean;
  72876. /**
  72877. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72878. */
  72879. showBoundingBox: boolean;
  72880. }
  72881. /**
  72882. * Component responsible of rendering the bounding box of the meshes in a scene.
  72883. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72884. */
  72885. export class BoundingBoxRenderer implements ISceneComponent {
  72886. /**
  72887. * The component name helpfull to identify the component in the list of scene components.
  72888. */
  72889. readonly name: string;
  72890. /**
  72891. * The scene the component belongs to.
  72892. */
  72893. scene: Scene;
  72894. /**
  72895. * Color of the bounding box lines placed in front of an object
  72896. */
  72897. frontColor: Color3;
  72898. /**
  72899. * Color of the bounding box lines placed behind an object
  72900. */
  72901. backColor: Color3;
  72902. /**
  72903. * Defines if the renderer should show the back lines or not
  72904. */
  72905. showBackLines: boolean;
  72906. /**
  72907. * Observable raised before rendering a bounding box
  72908. */
  72909. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72910. /**
  72911. * Observable raised after rendering a bounding box
  72912. */
  72913. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72914. /**
  72915. * Observable raised after resources are created
  72916. */
  72917. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  72918. /**
  72919. * When false, no bounding boxes will be rendered
  72920. */
  72921. enabled: boolean;
  72922. /**
  72923. * @hidden
  72924. */
  72925. renderList: SmartArray<BoundingBox>;
  72926. private _colorShader;
  72927. private _vertexBuffers;
  72928. private _indexBuffer;
  72929. private _fillIndexBuffer;
  72930. private _fillIndexData;
  72931. /**
  72932. * Instantiates a new bounding box renderer in a scene.
  72933. * @param scene the scene the renderer renders in
  72934. */
  72935. constructor(scene: Scene);
  72936. /**
  72937. * Registers the component in a given scene
  72938. */
  72939. register(): void;
  72940. private _evaluateSubMesh;
  72941. private _preActiveMesh;
  72942. private _prepareResources;
  72943. private _createIndexBuffer;
  72944. /**
  72945. * Rebuilds the elements related to this component in case of
  72946. * context lost for instance.
  72947. */
  72948. rebuild(): void;
  72949. /**
  72950. * @hidden
  72951. */
  72952. reset(): void;
  72953. /**
  72954. * Render the bounding boxes of a specific rendering group
  72955. * @param renderingGroupId defines the rendering group to render
  72956. */
  72957. render(renderingGroupId: number): void;
  72958. /**
  72959. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72960. * @param mesh Define the mesh to render the occlusion bounding box for
  72961. */
  72962. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72963. /**
  72964. * Dispose and release the resources attached to this renderer.
  72965. */
  72966. dispose(): void;
  72967. }
  72968. }
  72969. declare module BABYLON {
  72970. interface Scene {
  72971. /** @hidden (Backing field) */
  72972. _depthRenderer: {
  72973. [id: string]: DepthRenderer;
  72974. };
  72975. /**
  72976. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72977. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72978. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72979. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72980. * @returns the created depth renderer
  72981. */
  72982. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72983. /**
  72984. * Disables a depth renderer for a given camera
  72985. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72986. */
  72987. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72988. }
  72989. /**
  72990. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72991. * in several rendering techniques.
  72992. */
  72993. export class DepthRendererSceneComponent implements ISceneComponent {
  72994. /**
  72995. * The component name helpfull to identify the component in the list of scene components.
  72996. */
  72997. readonly name: string;
  72998. /**
  72999. * The scene the component belongs to.
  73000. */
  73001. scene: Scene;
  73002. /**
  73003. * Creates a new instance of the component for the given scene
  73004. * @param scene Defines the scene to register the component in
  73005. */
  73006. constructor(scene: Scene);
  73007. /**
  73008. * Registers the component in a given scene
  73009. */
  73010. register(): void;
  73011. /**
  73012. * Rebuilds the elements related to this component in case of
  73013. * context lost for instance.
  73014. */
  73015. rebuild(): void;
  73016. /**
  73017. * Disposes the component and the associated ressources
  73018. */
  73019. dispose(): void;
  73020. private _gatherRenderTargets;
  73021. private _gatherActiveCameraRenderTargets;
  73022. }
  73023. }
  73024. declare module BABYLON {
  73025. interface AbstractScene {
  73026. /** @hidden (Backing field) */
  73027. _prePassRenderer: Nullable<PrePassRenderer>;
  73028. /**
  73029. * Gets or Sets the current prepass renderer associated to the scene.
  73030. */
  73031. prePassRenderer: Nullable<PrePassRenderer>;
  73032. /**
  73033. * Enables the prepass and associates it with the scene
  73034. * @returns the PrePassRenderer
  73035. */
  73036. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  73037. /**
  73038. * Disables the prepass associated with the scene
  73039. */
  73040. disablePrePassRenderer(): void;
  73041. }
  73042. /**
  73043. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73044. * in several rendering techniques.
  73045. */
  73046. export class PrePassRendererSceneComponent implements ISceneComponent {
  73047. /**
  73048. * The component name helpful to identify the component in the list of scene components.
  73049. */
  73050. readonly name: string;
  73051. /**
  73052. * The scene the component belongs to.
  73053. */
  73054. scene: Scene;
  73055. /**
  73056. * Creates a new instance of the component for the given scene
  73057. * @param scene Defines the scene to register the component in
  73058. */
  73059. constructor(scene: Scene);
  73060. /**
  73061. * Registers the component in a given scene
  73062. */
  73063. register(): void;
  73064. private _beforeCameraDraw;
  73065. private _afterCameraDraw;
  73066. private _beforeClearStage;
  73067. /**
  73068. * Rebuilds the elements related to this component in case of
  73069. * context lost for instance.
  73070. */
  73071. rebuild(): void;
  73072. /**
  73073. * Disposes the component and the associated ressources
  73074. */
  73075. dispose(): void;
  73076. }
  73077. }
  73078. declare module BABYLON {
  73079. /** @hidden */
  73080. export var fibonacci: {
  73081. name: string;
  73082. shader: string;
  73083. };
  73084. }
  73085. declare module BABYLON {
  73086. /** @hidden */
  73087. export var diffusionProfile: {
  73088. name: string;
  73089. shader: string;
  73090. };
  73091. }
  73092. declare module BABYLON {
  73093. /** @hidden */
  73094. export var subSurfaceScatteringPixelShader: {
  73095. name: string;
  73096. shader: string;
  73097. };
  73098. }
  73099. declare module BABYLON {
  73100. /**
  73101. * Sub surface scattering post process
  73102. */
  73103. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73104. /**
  73105. * Gets a string identifying the name of the class
  73106. * @returns "SubSurfaceScatteringPostProcess" string
  73107. */
  73108. getClassName(): string;
  73109. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73110. }
  73111. }
  73112. declare module BABYLON {
  73113. /**
  73114. * Contains all parameters needed for the prepass to perform
  73115. * screen space subsurface scattering
  73116. */
  73117. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73118. /** @hidden */
  73119. static _SceneComponentInitialization: (scene: Scene) => void;
  73120. private _ssDiffusionS;
  73121. private _ssFilterRadii;
  73122. private _ssDiffusionD;
  73123. /**
  73124. * Post process to attach for screen space subsurface scattering
  73125. */
  73126. postProcess: SubSurfaceScatteringPostProcess;
  73127. /**
  73128. * Diffusion profile color for subsurface scattering
  73129. */
  73130. get ssDiffusionS(): number[];
  73131. /**
  73132. * Diffusion profile max color channel value for subsurface scattering
  73133. */
  73134. get ssDiffusionD(): number[];
  73135. /**
  73136. * Diffusion profile filter radius for subsurface scattering
  73137. */
  73138. get ssFilterRadii(): number[];
  73139. /**
  73140. * Is subsurface enabled
  73141. */
  73142. enabled: boolean;
  73143. /**
  73144. * Name of the configuration
  73145. */
  73146. name: string;
  73147. /**
  73148. * Diffusion profile colors for subsurface scattering
  73149. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73150. * See ...
  73151. * Note that you can only store up to 5 of them
  73152. */
  73153. ssDiffusionProfileColors: Color3[];
  73154. /**
  73155. * Defines the ratio real world => scene units.
  73156. * Used for subsurface scattering
  73157. */
  73158. metersPerUnit: number;
  73159. /**
  73160. * Textures that should be present in the MRT for this effect to work
  73161. */
  73162. readonly texturesRequired: number[];
  73163. private _scene;
  73164. /**
  73165. * Builds a subsurface configuration object
  73166. * @param scene The scene
  73167. */
  73168. constructor(scene: Scene);
  73169. /**
  73170. * Adds a new diffusion profile.
  73171. * Useful for more realistic subsurface scattering on diverse materials.
  73172. * @param color The color of the diffusion profile. Should be the average color of the material.
  73173. * @return The index of the diffusion profile for the material subsurface configuration
  73174. */
  73175. addDiffusionProfile(color: Color3): number;
  73176. /**
  73177. * Creates the sss post process
  73178. * @return The created post process
  73179. */
  73180. createPostProcess(): SubSurfaceScatteringPostProcess;
  73181. /**
  73182. * Deletes all diffusion profiles.
  73183. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73184. */
  73185. clearAllDiffusionProfiles(): void;
  73186. /**
  73187. * Disposes this object
  73188. */
  73189. dispose(): void;
  73190. /**
  73191. * @hidden
  73192. * https://zero-radiance.github.io/post/sampling-diffusion/
  73193. *
  73194. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73195. * ------------------------------------------------------------------------------------
  73196. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73197. * PDF[r, phi, s] = r * R[r, phi, s]
  73198. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73199. * ------------------------------------------------------------------------------------
  73200. * We importance sample the color channel with the widest scattering distance.
  73201. */
  73202. getDiffusionProfileParameters(color: Color3): number;
  73203. /**
  73204. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73205. * 'u' is the random number (the value of the CDF): [0, 1).
  73206. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73207. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73208. */
  73209. private _sampleBurleyDiffusionProfile;
  73210. }
  73211. }
  73212. declare module BABYLON {
  73213. interface AbstractScene {
  73214. /** @hidden (Backing field) */
  73215. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73216. /**
  73217. * Gets or Sets the current prepass renderer associated to the scene.
  73218. */
  73219. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73220. /**
  73221. * Enables the subsurface effect for prepass
  73222. * @returns the SubSurfaceConfiguration
  73223. */
  73224. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73225. /**
  73226. * Disables the subsurface effect for prepass
  73227. */
  73228. disableSubSurfaceForPrePass(): void;
  73229. }
  73230. /**
  73231. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73232. * in several rendering techniques.
  73233. */
  73234. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73235. /**
  73236. * The component name helpful to identify the component in the list of scene components.
  73237. */
  73238. readonly name: string;
  73239. /**
  73240. * The scene the component belongs to.
  73241. */
  73242. scene: Scene;
  73243. /**
  73244. * Creates a new instance of the component for the given scene
  73245. * @param scene Defines the scene to register the component in
  73246. */
  73247. constructor(scene: Scene);
  73248. /**
  73249. * Registers the component in a given scene
  73250. */
  73251. register(): void;
  73252. /**
  73253. * Serializes the component data to the specified json object
  73254. * @param serializationObject The object to serialize to
  73255. */
  73256. serialize(serializationObject: any): void;
  73257. /**
  73258. * Adds all the elements from the container to the scene
  73259. * @param container the container holding the elements
  73260. */
  73261. addFromContainer(container: AbstractScene): void;
  73262. /**
  73263. * Removes all the elements in the container from the scene
  73264. * @param container contains the elements to remove
  73265. * @param dispose if the removed element should be disposed (default: false)
  73266. */
  73267. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73268. /**
  73269. * Rebuilds the elements related to this component in case of
  73270. * context lost for instance.
  73271. */
  73272. rebuild(): void;
  73273. /**
  73274. * Disposes the component and the associated ressources
  73275. */
  73276. dispose(): void;
  73277. }
  73278. }
  73279. declare module BABYLON {
  73280. /** @hidden */
  73281. export var outlinePixelShader: {
  73282. name: string;
  73283. shader: string;
  73284. };
  73285. }
  73286. declare module BABYLON {
  73287. /** @hidden */
  73288. export var outlineVertexShader: {
  73289. name: string;
  73290. shader: string;
  73291. };
  73292. }
  73293. declare module BABYLON {
  73294. interface Scene {
  73295. /** @hidden */
  73296. _outlineRenderer: OutlineRenderer;
  73297. /**
  73298. * Gets the outline renderer associated with the scene
  73299. * @returns a OutlineRenderer
  73300. */
  73301. getOutlineRenderer(): OutlineRenderer;
  73302. }
  73303. interface AbstractMesh {
  73304. /** @hidden (Backing field) */
  73305. _renderOutline: boolean;
  73306. /**
  73307. * Gets or sets a boolean indicating if the outline must be rendered as well
  73308. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73309. */
  73310. renderOutline: boolean;
  73311. /** @hidden (Backing field) */
  73312. _renderOverlay: boolean;
  73313. /**
  73314. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73315. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73316. */
  73317. renderOverlay: boolean;
  73318. }
  73319. /**
  73320. * This class is responsible to draw bothe outline/overlay of meshes.
  73321. * It should not be used directly but through the available method on mesh.
  73322. */
  73323. export class OutlineRenderer implements ISceneComponent {
  73324. /**
  73325. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73326. */
  73327. private static _StencilReference;
  73328. /**
  73329. * The name of the component. Each component must have a unique name.
  73330. */
  73331. name: string;
  73332. /**
  73333. * The scene the component belongs to.
  73334. */
  73335. scene: Scene;
  73336. /**
  73337. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73338. */
  73339. zOffset: number;
  73340. private _engine;
  73341. private _effect;
  73342. private _cachedDefines;
  73343. private _savedDepthWrite;
  73344. /**
  73345. * Instantiates a new outline renderer. (There could be only one per scene).
  73346. * @param scene Defines the scene it belongs to
  73347. */
  73348. constructor(scene: Scene);
  73349. /**
  73350. * Register the component to one instance of a scene.
  73351. */
  73352. register(): void;
  73353. /**
  73354. * Rebuilds the elements related to this component in case of
  73355. * context lost for instance.
  73356. */
  73357. rebuild(): void;
  73358. /**
  73359. * Disposes the component and the associated ressources.
  73360. */
  73361. dispose(): void;
  73362. /**
  73363. * Renders the outline in the canvas.
  73364. * @param subMesh Defines the sumesh to render
  73365. * @param batch Defines the batch of meshes in case of instances
  73366. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73367. */
  73368. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73369. /**
  73370. * Returns whether or not the outline renderer is ready for a given submesh.
  73371. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73372. * @param subMesh Defines the submesh to check readyness for
  73373. * @param useInstances Defines wheter wee are trying to render instances or not
  73374. * @returns true if ready otherwise false
  73375. */
  73376. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73377. private _beforeRenderingMesh;
  73378. private _afterRenderingMesh;
  73379. }
  73380. }
  73381. declare module BABYLON {
  73382. /**
  73383. * Defines the basic options interface of a Sprite Frame Source Size.
  73384. */
  73385. export interface ISpriteJSONSpriteSourceSize {
  73386. /**
  73387. * number of the original width of the Frame
  73388. */
  73389. w: number;
  73390. /**
  73391. * number of the original height of the Frame
  73392. */
  73393. h: number;
  73394. }
  73395. /**
  73396. * Defines the basic options interface of a Sprite Frame Data.
  73397. */
  73398. export interface ISpriteJSONSpriteFrameData {
  73399. /**
  73400. * number of the x offset of the Frame
  73401. */
  73402. x: number;
  73403. /**
  73404. * number of the y offset of the Frame
  73405. */
  73406. y: number;
  73407. /**
  73408. * number of the width of the Frame
  73409. */
  73410. w: number;
  73411. /**
  73412. * number of the height of the Frame
  73413. */
  73414. h: number;
  73415. }
  73416. /**
  73417. * Defines the basic options interface of a JSON Sprite.
  73418. */
  73419. export interface ISpriteJSONSprite {
  73420. /**
  73421. * string name of the Frame
  73422. */
  73423. filename: string;
  73424. /**
  73425. * ISpriteJSONSpriteFrame basic object of the frame data
  73426. */
  73427. frame: ISpriteJSONSpriteFrameData;
  73428. /**
  73429. * boolean to flag is the frame was rotated.
  73430. */
  73431. rotated: boolean;
  73432. /**
  73433. * boolean to flag is the frame was trimmed.
  73434. */
  73435. trimmed: boolean;
  73436. /**
  73437. * ISpriteJSONSpriteFrame basic object of the source data
  73438. */
  73439. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73440. /**
  73441. * ISpriteJSONSpriteFrame basic object of the source data
  73442. */
  73443. sourceSize: ISpriteJSONSpriteSourceSize;
  73444. }
  73445. /**
  73446. * Defines the basic options interface of a JSON atlas.
  73447. */
  73448. export interface ISpriteJSONAtlas {
  73449. /**
  73450. * Array of objects that contain the frame data.
  73451. */
  73452. frames: Array<ISpriteJSONSprite>;
  73453. /**
  73454. * object basic object containing the sprite meta data.
  73455. */
  73456. meta?: object;
  73457. }
  73458. }
  73459. declare module BABYLON {
  73460. /** @hidden */
  73461. export var spriteMapPixelShader: {
  73462. name: string;
  73463. shader: string;
  73464. };
  73465. }
  73466. declare module BABYLON {
  73467. /** @hidden */
  73468. export var spriteMapVertexShader: {
  73469. name: string;
  73470. shader: string;
  73471. };
  73472. }
  73473. declare module BABYLON {
  73474. /**
  73475. * Defines the basic options interface of a SpriteMap
  73476. */
  73477. export interface ISpriteMapOptions {
  73478. /**
  73479. * Vector2 of the number of cells in the grid.
  73480. */
  73481. stageSize?: Vector2;
  73482. /**
  73483. * Vector2 of the size of the output plane in World Units.
  73484. */
  73485. outputSize?: Vector2;
  73486. /**
  73487. * Vector3 of the position of the output plane in World Units.
  73488. */
  73489. outputPosition?: Vector3;
  73490. /**
  73491. * Vector3 of the rotation of the output plane.
  73492. */
  73493. outputRotation?: Vector3;
  73494. /**
  73495. * number of layers that the system will reserve in resources.
  73496. */
  73497. layerCount?: number;
  73498. /**
  73499. * number of max animation frames a single cell will reserve in resources.
  73500. */
  73501. maxAnimationFrames?: number;
  73502. /**
  73503. * number cell index of the base tile when the system compiles.
  73504. */
  73505. baseTile?: number;
  73506. /**
  73507. * boolean flip the sprite after its been repositioned by the framing data.
  73508. */
  73509. flipU?: boolean;
  73510. /**
  73511. * Vector3 scalar of the global RGB values of the SpriteMap.
  73512. */
  73513. colorMultiply?: Vector3;
  73514. }
  73515. /**
  73516. * Defines the IDisposable interface in order to be cleanable from resources.
  73517. */
  73518. export interface ISpriteMap extends IDisposable {
  73519. /**
  73520. * String name of the SpriteMap.
  73521. */
  73522. name: string;
  73523. /**
  73524. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73525. */
  73526. atlasJSON: ISpriteJSONAtlas;
  73527. /**
  73528. * Texture of the SpriteMap.
  73529. */
  73530. spriteSheet: Texture;
  73531. /**
  73532. * The parameters to initialize the SpriteMap with.
  73533. */
  73534. options: ISpriteMapOptions;
  73535. }
  73536. /**
  73537. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73538. */
  73539. export class SpriteMap implements ISpriteMap {
  73540. /** The Name of the spriteMap */
  73541. name: string;
  73542. /** The JSON file with the frame and meta data */
  73543. atlasJSON: ISpriteJSONAtlas;
  73544. /** The systems Sprite Sheet Texture */
  73545. spriteSheet: Texture;
  73546. /** Arguments passed with the Constructor */
  73547. options: ISpriteMapOptions;
  73548. /** Public Sprite Storage array, parsed from atlasJSON */
  73549. sprites: Array<ISpriteJSONSprite>;
  73550. /** Returns the Number of Sprites in the System */
  73551. get spriteCount(): number;
  73552. /** Returns the Position of Output Plane*/
  73553. get position(): Vector3;
  73554. /** Returns the Position of Output Plane*/
  73555. set position(v: Vector3);
  73556. /** Returns the Rotation of Output Plane*/
  73557. get rotation(): Vector3;
  73558. /** Returns the Rotation of Output Plane*/
  73559. set rotation(v: Vector3);
  73560. /** Sets the AnimationMap*/
  73561. get animationMap(): RawTexture;
  73562. /** Sets the AnimationMap*/
  73563. set animationMap(v: RawTexture);
  73564. /** Scene that the SpriteMap was created in */
  73565. private _scene;
  73566. /** Texture Buffer of Float32 that holds tile frame data*/
  73567. private _frameMap;
  73568. /** Texture Buffers of Float32 that holds tileMap data*/
  73569. private _tileMaps;
  73570. /** Texture Buffer of Float32 that holds Animation Data*/
  73571. private _animationMap;
  73572. /** Custom ShaderMaterial Central to the System*/
  73573. private _material;
  73574. /** Custom ShaderMaterial Central to the System*/
  73575. private _output;
  73576. /** Systems Time Ticker*/
  73577. private _time;
  73578. /**
  73579. * Creates a new SpriteMap
  73580. * @param name defines the SpriteMaps Name
  73581. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73582. * @param spriteSheet is the Texture that the Sprites are on.
  73583. * @param options a basic deployment configuration
  73584. * @param scene The Scene that the map is deployed on
  73585. */
  73586. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73587. /**
  73588. * Returns tileID location
  73589. * @returns Vector2 the cell position ID
  73590. */
  73591. getTileID(): Vector2;
  73592. /**
  73593. * Gets the UV location of the mouse over the SpriteMap.
  73594. * @returns Vector2 the UV position of the mouse interaction
  73595. */
  73596. getMousePosition(): Vector2;
  73597. /**
  73598. * Creates the "frame" texture Buffer
  73599. * -------------------------------------
  73600. * Structure of frames
  73601. * "filename": "Falling-Water-2.png",
  73602. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73603. * "rotated": true,
  73604. * "trimmed": true,
  73605. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73606. * "sourceSize": {"w":32,"h":32}
  73607. * @returns RawTexture of the frameMap
  73608. */
  73609. private _createFrameBuffer;
  73610. /**
  73611. * Creates the tileMap texture Buffer
  73612. * @param buffer normally and array of numbers, or a false to generate from scratch
  73613. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73614. * @returns RawTexture of the tileMap
  73615. */
  73616. private _createTileBuffer;
  73617. /**
  73618. * Modifies the data of the tileMaps
  73619. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73620. * @param pos is the iVector2 Coordinates of the Tile
  73621. * @param tile The SpriteIndex of the new Tile
  73622. */
  73623. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73624. /**
  73625. * Creates the animationMap texture Buffer
  73626. * @param buffer normally and array of numbers, or a false to generate from scratch
  73627. * @returns RawTexture of the animationMap
  73628. */
  73629. private _createTileAnimationBuffer;
  73630. /**
  73631. * Modifies the data of the animationMap
  73632. * @param cellID is the Index of the Sprite
  73633. * @param _frame is the target Animation frame
  73634. * @param toCell is the Target Index of the next frame of the animation
  73635. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73636. * @param speed is a global scalar of the time variable on the map.
  73637. */
  73638. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73639. /**
  73640. * Exports the .tilemaps file
  73641. */
  73642. saveTileMaps(): void;
  73643. /**
  73644. * Imports the .tilemaps file
  73645. * @param url of the .tilemaps file
  73646. */
  73647. loadTileMaps(url: string): void;
  73648. /**
  73649. * Release associated resources
  73650. */
  73651. dispose(): void;
  73652. }
  73653. }
  73654. declare module BABYLON {
  73655. /**
  73656. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73657. * @see https://doc.babylonjs.com/babylon101/sprites
  73658. */
  73659. export class SpritePackedManager extends SpriteManager {
  73660. /** defines the packed manager's name */
  73661. name: string;
  73662. /**
  73663. * Creates a new sprite manager from a packed sprite sheet
  73664. * @param name defines the manager's name
  73665. * @param imgUrl defines the sprite sheet url
  73666. * @param capacity defines the maximum allowed number of sprites
  73667. * @param scene defines the hosting scene
  73668. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73669. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73670. * @param samplingMode defines the smapling mode to use with spritesheet
  73671. * @param fromPacked set to true; do not alter
  73672. */
  73673. constructor(
  73674. /** defines the packed manager's name */
  73675. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73676. }
  73677. }
  73678. declare module BABYLON {
  73679. /**
  73680. * Defines the list of states available for a task inside a AssetsManager
  73681. */
  73682. export enum AssetTaskState {
  73683. /**
  73684. * Initialization
  73685. */
  73686. INIT = 0,
  73687. /**
  73688. * Running
  73689. */
  73690. RUNNING = 1,
  73691. /**
  73692. * Done
  73693. */
  73694. DONE = 2,
  73695. /**
  73696. * Error
  73697. */
  73698. ERROR = 3
  73699. }
  73700. /**
  73701. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73702. */
  73703. export abstract class AbstractAssetTask {
  73704. /**
  73705. * Task name
  73706. */ name: string;
  73707. /**
  73708. * Callback called when the task is successful
  73709. */
  73710. onSuccess: (task: any) => void;
  73711. /**
  73712. * Callback called when the task is not successful
  73713. */
  73714. onError: (task: any, message?: string, exception?: any) => void;
  73715. /**
  73716. * Creates a new AssetsManager
  73717. * @param name defines the name of the task
  73718. */
  73719. constructor(
  73720. /**
  73721. * Task name
  73722. */ name: string);
  73723. private _isCompleted;
  73724. private _taskState;
  73725. private _errorObject;
  73726. /**
  73727. * Get if the task is completed
  73728. */
  73729. get isCompleted(): boolean;
  73730. /**
  73731. * Gets the current state of the task
  73732. */
  73733. get taskState(): AssetTaskState;
  73734. /**
  73735. * Gets the current error object (if task is in error)
  73736. */
  73737. get errorObject(): {
  73738. message?: string;
  73739. exception?: any;
  73740. };
  73741. /**
  73742. * Internal only
  73743. * @hidden
  73744. */
  73745. _setErrorObject(message?: string, exception?: any): void;
  73746. /**
  73747. * Execute the current task
  73748. * @param scene defines the scene where you want your assets to be loaded
  73749. * @param onSuccess is a callback called when the task is successfully executed
  73750. * @param onError is a callback called if an error occurs
  73751. */
  73752. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73753. /**
  73754. * Execute the current task
  73755. * @param scene defines the scene where you want your assets to be loaded
  73756. * @param onSuccess is a callback called when the task is successfully executed
  73757. * @param onError is a callback called if an error occurs
  73758. */
  73759. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73760. /**
  73761. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73762. * This can be used with failed tasks that have the reason for failure fixed.
  73763. */
  73764. reset(): void;
  73765. private onErrorCallback;
  73766. private onDoneCallback;
  73767. }
  73768. /**
  73769. * Define the interface used by progress events raised during assets loading
  73770. */
  73771. export interface IAssetsProgressEvent {
  73772. /**
  73773. * Defines the number of remaining tasks to process
  73774. */
  73775. remainingCount: number;
  73776. /**
  73777. * Defines the total number of tasks
  73778. */
  73779. totalCount: number;
  73780. /**
  73781. * Defines the task that was just processed
  73782. */
  73783. task: AbstractAssetTask;
  73784. }
  73785. /**
  73786. * Class used to share progress information about assets loading
  73787. */
  73788. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73789. /**
  73790. * Defines the number of remaining tasks to process
  73791. */
  73792. remainingCount: number;
  73793. /**
  73794. * Defines the total number of tasks
  73795. */
  73796. totalCount: number;
  73797. /**
  73798. * Defines the task that was just processed
  73799. */
  73800. task: AbstractAssetTask;
  73801. /**
  73802. * Creates a AssetsProgressEvent
  73803. * @param remainingCount defines the number of remaining tasks to process
  73804. * @param totalCount defines the total number of tasks
  73805. * @param task defines the task that was just processed
  73806. */
  73807. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73808. }
  73809. /**
  73810. * Define a task used by AssetsManager to load assets into a container
  73811. */
  73812. export class ContainerAssetTask extends AbstractAssetTask {
  73813. /**
  73814. * Defines the name of the task
  73815. */
  73816. name: string;
  73817. /**
  73818. * Defines the list of mesh's names you want to load
  73819. */
  73820. meshesNames: any;
  73821. /**
  73822. * Defines the root url to use as a base to load your meshes and associated resources
  73823. */
  73824. rootUrl: string;
  73825. /**
  73826. * Defines the filename or File of the scene to load from
  73827. */
  73828. sceneFilename: string | File;
  73829. /**
  73830. * Get the loaded asset container
  73831. */
  73832. loadedContainer: AssetContainer;
  73833. /**
  73834. * Gets the list of loaded meshes
  73835. */
  73836. loadedMeshes: Array<AbstractMesh>;
  73837. /**
  73838. * Gets the list of loaded particle systems
  73839. */
  73840. loadedParticleSystems: Array<IParticleSystem>;
  73841. /**
  73842. * Gets the list of loaded skeletons
  73843. */
  73844. loadedSkeletons: Array<Skeleton>;
  73845. /**
  73846. * Gets the list of loaded animation groups
  73847. */
  73848. loadedAnimationGroups: Array<AnimationGroup>;
  73849. /**
  73850. * Callback called when the task is successful
  73851. */
  73852. onSuccess: (task: ContainerAssetTask) => void;
  73853. /**
  73854. * Callback called when the task is successful
  73855. */
  73856. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73857. /**
  73858. * Creates a new ContainerAssetTask
  73859. * @param name defines the name of the task
  73860. * @param meshesNames defines the list of mesh's names you want to load
  73861. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73862. * @param sceneFilename defines the filename or File of the scene to load from
  73863. */
  73864. constructor(
  73865. /**
  73866. * Defines the name of the task
  73867. */
  73868. name: string,
  73869. /**
  73870. * Defines the list of mesh's names you want to load
  73871. */
  73872. meshesNames: any,
  73873. /**
  73874. * Defines the root url to use as a base to load your meshes and associated resources
  73875. */
  73876. rootUrl: string,
  73877. /**
  73878. * Defines the filename or File of the scene to load from
  73879. */
  73880. sceneFilename: string | File);
  73881. /**
  73882. * Execute the current task
  73883. * @param scene defines the scene where you want your assets to be loaded
  73884. * @param onSuccess is a callback called when the task is successfully executed
  73885. * @param onError is a callback called if an error occurs
  73886. */
  73887. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73888. }
  73889. /**
  73890. * Define a task used by AssetsManager to load meshes
  73891. */
  73892. export class MeshAssetTask extends AbstractAssetTask {
  73893. /**
  73894. * Defines the name of the task
  73895. */
  73896. name: string;
  73897. /**
  73898. * Defines the list of mesh's names you want to load
  73899. */
  73900. meshesNames: any;
  73901. /**
  73902. * Defines the root url to use as a base to load your meshes and associated resources
  73903. */
  73904. rootUrl: string;
  73905. /**
  73906. * Defines the filename or File of the scene to load from
  73907. */
  73908. sceneFilename: string | File;
  73909. /**
  73910. * Gets the list of loaded meshes
  73911. */
  73912. loadedMeshes: Array<AbstractMesh>;
  73913. /**
  73914. * Gets the list of loaded particle systems
  73915. */
  73916. loadedParticleSystems: Array<IParticleSystem>;
  73917. /**
  73918. * Gets the list of loaded skeletons
  73919. */
  73920. loadedSkeletons: Array<Skeleton>;
  73921. /**
  73922. * Gets the list of loaded animation groups
  73923. */
  73924. loadedAnimationGroups: Array<AnimationGroup>;
  73925. /**
  73926. * Callback called when the task is successful
  73927. */
  73928. onSuccess: (task: MeshAssetTask) => void;
  73929. /**
  73930. * Callback called when the task is successful
  73931. */
  73932. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73933. /**
  73934. * Creates a new MeshAssetTask
  73935. * @param name defines the name of the task
  73936. * @param meshesNames defines the list of mesh's names you want to load
  73937. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73938. * @param sceneFilename defines the filename or File of the scene to load from
  73939. */
  73940. constructor(
  73941. /**
  73942. * Defines the name of the task
  73943. */
  73944. name: string,
  73945. /**
  73946. * Defines the list of mesh's names you want to load
  73947. */
  73948. meshesNames: any,
  73949. /**
  73950. * Defines the root url to use as a base to load your meshes and associated resources
  73951. */
  73952. rootUrl: string,
  73953. /**
  73954. * Defines the filename or File of the scene to load from
  73955. */
  73956. sceneFilename: string | File);
  73957. /**
  73958. * Execute the current task
  73959. * @param scene defines the scene where you want your assets to be loaded
  73960. * @param onSuccess is a callback called when the task is successfully executed
  73961. * @param onError is a callback called if an error occurs
  73962. */
  73963. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73964. }
  73965. /**
  73966. * Define a task used by AssetsManager to load text content
  73967. */
  73968. export class TextFileAssetTask extends AbstractAssetTask {
  73969. /**
  73970. * Defines the name of the task
  73971. */
  73972. name: string;
  73973. /**
  73974. * Defines the location of the file to load
  73975. */
  73976. url: string;
  73977. /**
  73978. * Gets the loaded text string
  73979. */
  73980. text: string;
  73981. /**
  73982. * Callback called when the task is successful
  73983. */
  73984. onSuccess: (task: TextFileAssetTask) => void;
  73985. /**
  73986. * Callback called when the task is successful
  73987. */
  73988. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73989. /**
  73990. * Creates a new TextFileAssetTask object
  73991. * @param name defines the name of the task
  73992. * @param url defines the location of the file to load
  73993. */
  73994. constructor(
  73995. /**
  73996. * Defines the name of the task
  73997. */
  73998. name: string,
  73999. /**
  74000. * Defines the location of the file to load
  74001. */
  74002. url: string);
  74003. /**
  74004. * Execute the current task
  74005. * @param scene defines the scene where you want your assets to be loaded
  74006. * @param onSuccess is a callback called when the task is successfully executed
  74007. * @param onError is a callback called if an error occurs
  74008. */
  74009. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74010. }
  74011. /**
  74012. * Define a task used by AssetsManager to load binary data
  74013. */
  74014. export class BinaryFileAssetTask extends AbstractAssetTask {
  74015. /**
  74016. * Defines the name of the task
  74017. */
  74018. name: string;
  74019. /**
  74020. * Defines the location of the file to load
  74021. */
  74022. url: string;
  74023. /**
  74024. * Gets the lodaded data (as an array buffer)
  74025. */
  74026. data: ArrayBuffer;
  74027. /**
  74028. * Callback called when the task is successful
  74029. */
  74030. onSuccess: (task: BinaryFileAssetTask) => void;
  74031. /**
  74032. * Callback called when the task is successful
  74033. */
  74034. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74035. /**
  74036. * Creates a new BinaryFileAssetTask object
  74037. * @param name defines the name of the new task
  74038. * @param url defines the location of the file to load
  74039. */
  74040. constructor(
  74041. /**
  74042. * Defines the name of the task
  74043. */
  74044. name: string,
  74045. /**
  74046. * Defines the location of the file to load
  74047. */
  74048. url: string);
  74049. /**
  74050. * Execute the current task
  74051. * @param scene defines the scene where you want your assets to be loaded
  74052. * @param onSuccess is a callback called when the task is successfully executed
  74053. * @param onError is a callback called if an error occurs
  74054. */
  74055. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74056. }
  74057. /**
  74058. * Define a task used by AssetsManager to load images
  74059. */
  74060. export class ImageAssetTask extends AbstractAssetTask {
  74061. /**
  74062. * Defines the name of the task
  74063. */
  74064. name: string;
  74065. /**
  74066. * Defines the location of the image to load
  74067. */
  74068. url: string;
  74069. /**
  74070. * Gets the loaded images
  74071. */
  74072. image: HTMLImageElement;
  74073. /**
  74074. * Callback called when the task is successful
  74075. */
  74076. onSuccess: (task: ImageAssetTask) => void;
  74077. /**
  74078. * Callback called when the task is successful
  74079. */
  74080. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74081. /**
  74082. * Creates a new ImageAssetTask
  74083. * @param name defines the name of the task
  74084. * @param url defines the location of the image to load
  74085. */
  74086. constructor(
  74087. /**
  74088. * Defines the name of the task
  74089. */
  74090. name: string,
  74091. /**
  74092. * Defines the location of the image to load
  74093. */
  74094. url: string);
  74095. /**
  74096. * Execute the current task
  74097. * @param scene defines the scene where you want your assets to be loaded
  74098. * @param onSuccess is a callback called when the task is successfully executed
  74099. * @param onError is a callback called if an error occurs
  74100. */
  74101. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74102. }
  74103. /**
  74104. * Defines the interface used by texture loading tasks
  74105. */
  74106. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74107. /**
  74108. * Gets the loaded texture
  74109. */
  74110. texture: TEX;
  74111. }
  74112. /**
  74113. * Define a task used by AssetsManager to load 2D textures
  74114. */
  74115. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74116. /**
  74117. * Defines the name of the task
  74118. */
  74119. name: string;
  74120. /**
  74121. * Defines the location of the file to load
  74122. */
  74123. url: string;
  74124. /**
  74125. * Defines if mipmap should not be generated (default is false)
  74126. */
  74127. noMipmap?: boolean | undefined;
  74128. /**
  74129. * Defines if texture must be inverted on Y axis (default is true)
  74130. */
  74131. invertY: boolean;
  74132. /**
  74133. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74134. */
  74135. samplingMode: number;
  74136. /**
  74137. * Gets the loaded texture
  74138. */
  74139. texture: Texture;
  74140. /**
  74141. * Callback called when the task is successful
  74142. */
  74143. onSuccess: (task: TextureAssetTask) => void;
  74144. /**
  74145. * Callback called when the task is successful
  74146. */
  74147. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74148. /**
  74149. * Creates a new TextureAssetTask object
  74150. * @param name defines the name of the task
  74151. * @param url defines the location of the file to load
  74152. * @param noMipmap defines if mipmap should not be generated (default is false)
  74153. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74154. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74155. */
  74156. constructor(
  74157. /**
  74158. * Defines the name of the task
  74159. */
  74160. name: string,
  74161. /**
  74162. * Defines the location of the file to load
  74163. */
  74164. url: string,
  74165. /**
  74166. * Defines if mipmap should not be generated (default is false)
  74167. */
  74168. noMipmap?: boolean | undefined,
  74169. /**
  74170. * Defines if texture must be inverted on Y axis (default is true)
  74171. */
  74172. invertY?: boolean,
  74173. /**
  74174. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74175. */
  74176. samplingMode?: number);
  74177. /**
  74178. * Execute the current task
  74179. * @param scene defines the scene where you want your assets to be loaded
  74180. * @param onSuccess is a callback called when the task is successfully executed
  74181. * @param onError is a callback called if an error occurs
  74182. */
  74183. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74184. }
  74185. /**
  74186. * Define a task used by AssetsManager to load cube textures
  74187. */
  74188. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74189. /**
  74190. * Defines the name of the task
  74191. */
  74192. name: string;
  74193. /**
  74194. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74195. */
  74196. url: string;
  74197. /**
  74198. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74199. */
  74200. extensions?: string[] | undefined;
  74201. /**
  74202. * Defines if mipmaps should not be generated (default is false)
  74203. */
  74204. noMipmap?: boolean | undefined;
  74205. /**
  74206. * Defines the explicit list of files (undefined by default)
  74207. */
  74208. files?: string[] | undefined;
  74209. /**
  74210. * Gets the loaded texture
  74211. */
  74212. texture: CubeTexture;
  74213. /**
  74214. * Callback called when the task is successful
  74215. */
  74216. onSuccess: (task: CubeTextureAssetTask) => void;
  74217. /**
  74218. * Callback called when the task is successful
  74219. */
  74220. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74221. /**
  74222. * Creates a new CubeTextureAssetTask
  74223. * @param name defines the name of the task
  74224. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74225. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74226. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74227. * @param files defines the explicit list of files (undefined by default)
  74228. */
  74229. constructor(
  74230. /**
  74231. * Defines the name of the task
  74232. */
  74233. name: string,
  74234. /**
  74235. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74236. */
  74237. url: string,
  74238. /**
  74239. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74240. */
  74241. extensions?: string[] | undefined,
  74242. /**
  74243. * Defines if mipmaps should not be generated (default is false)
  74244. */
  74245. noMipmap?: boolean | undefined,
  74246. /**
  74247. * Defines the explicit list of files (undefined by default)
  74248. */
  74249. files?: string[] | undefined);
  74250. /**
  74251. * Execute the current task
  74252. * @param scene defines the scene where you want your assets to be loaded
  74253. * @param onSuccess is a callback called when the task is successfully executed
  74254. * @param onError is a callback called if an error occurs
  74255. */
  74256. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74257. }
  74258. /**
  74259. * Define a task used by AssetsManager to load HDR cube textures
  74260. */
  74261. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74262. /**
  74263. * Defines the name of the task
  74264. */
  74265. name: string;
  74266. /**
  74267. * Defines the location of the file to load
  74268. */
  74269. url: string;
  74270. /**
  74271. * Defines the desired size (the more it increases the longer the generation will be)
  74272. */
  74273. size: number;
  74274. /**
  74275. * Defines if mipmaps should not be generated (default is false)
  74276. */
  74277. noMipmap: boolean;
  74278. /**
  74279. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74280. */
  74281. generateHarmonics: boolean;
  74282. /**
  74283. * 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)
  74284. */
  74285. gammaSpace: boolean;
  74286. /**
  74287. * Internal Use Only
  74288. */
  74289. reserved: boolean;
  74290. /**
  74291. * Gets the loaded texture
  74292. */
  74293. texture: HDRCubeTexture;
  74294. /**
  74295. * Callback called when the task is successful
  74296. */
  74297. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74298. /**
  74299. * Callback called when the task is successful
  74300. */
  74301. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74302. /**
  74303. * Creates a new HDRCubeTextureAssetTask object
  74304. * @param name defines the name of the task
  74305. * @param url defines the location of the file to load
  74306. * @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.
  74307. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74308. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74309. * @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)
  74310. * @param reserved Internal use only
  74311. */
  74312. constructor(
  74313. /**
  74314. * Defines the name of the task
  74315. */
  74316. name: string,
  74317. /**
  74318. * Defines the location of the file to load
  74319. */
  74320. url: string,
  74321. /**
  74322. * Defines the desired size (the more it increases the longer the generation will be)
  74323. */
  74324. size: number,
  74325. /**
  74326. * Defines if mipmaps should not be generated (default is false)
  74327. */
  74328. noMipmap?: boolean,
  74329. /**
  74330. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74331. */
  74332. generateHarmonics?: boolean,
  74333. /**
  74334. * 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)
  74335. */
  74336. gammaSpace?: boolean,
  74337. /**
  74338. * Internal Use Only
  74339. */
  74340. reserved?: boolean);
  74341. /**
  74342. * Execute the current task
  74343. * @param scene defines the scene where you want your assets to be loaded
  74344. * @param onSuccess is a callback called when the task is successfully executed
  74345. * @param onError is a callback called if an error occurs
  74346. */
  74347. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74348. }
  74349. /**
  74350. * Define a task used by AssetsManager to load Equirectangular cube textures
  74351. */
  74352. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74353. /**
  74354. * Defines the name of the task
  74355. */
  74356. name: string;
  74357. /**
  74358. * Defines the location of the file to load
  74359. */
  74360. url: string;
  74361. /**
  74362. * Defines the desired size (the more it increases the longer the generation will be)
  74363. */
  74364. size: number;
  74365. /**
  74366. * Defines if mipmaps should not be generated (default is false)
  74367. */
  74368. noMipmap: boolean;
  74369. /**
  74370. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74371. * but the standard material would require them in Gamma space) (default is true)
  74372. */
  74373. gammaSpace: boolean;
  74374. /**
  74375. * Gets the loaded texture
  74376. */
  74377. texture: EquiRectangularCubeTexture;
  74378. /**
  74379. * Callback called when the task is successful
  74380. */
  74381. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74382. /**
  74383. * Callback called when the task is successful
  74384. */
  74385. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74386. /**
  74387. * Creates a new EquiRectangularCubeTextureAssetTask object
  74388. * @param name defines the name of the task
  74389. * @param url defines the location of the file to load
  74390. * @param size defines the desired size (the more it increases the longer the generation will be)
  74391. * If the size is omitted this implies you are using a preprocessed cubemap.
  74392. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74393. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74394. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74395. * (default is true)
  74396. */
  74397. constructor(
  74398. /**
  74399. * Defines the name of the task
  74400. */
  74401. name: string,
  74402. /**
  74403. * Defines the location of the file to load
  74404. */
  74405. url: string,
  74406. /**
  74407. * Defines the desired size (the more it increases the longer the generation will be)
  74408. */
  74409. size: number,
  74410. /**
  74411. * Defines if mipmaps should not be generated (default is false)
  74412. */
  74413. noMipmap?: boolean,
  74414. /**
  74415. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74416. * but the standard material would require them in Gamma space) (default is true)
  74417. */
  74418. gammaSpace?: boolean);
  74419. /**
  74420. * Execute the current task
  74421. * @param scene defines the scene where you want your assets to be loaded
  74422. * @param onSuccess is a callback called when the task is successfully executed
  74423. * @param onError is a callback called if an error occurs
  74424. */
  74425. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74426. }
  74427. /**
  74428. * This class can be used to easily import assets into a scene
  74429. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74430. */
  74431. export class AssetsManager {
  74432. private _scene;
  74433. private _isLoading;
  74434. protected _tasks: AbstractAssetTask[];
  74435. protected _waitingTasksCount: number;
  74436. protected _totalTasksCount: number;
  74437. /**
  74438. * Callback called when all tasks are processed
  74439. */
  74440. onFinish: (tasks: AbstractAssetTask[]) => void;
  74441. /**
  74442. * Callback called when a task is successful
  74443. */
  74444. onTaskSuccess: (task: AbstractAssetTask) => void;
  74445. /**
  74446. * Callback called when a task had an error
  74447. */
  74448. onTaskError: (task: AbstractAssetTask) => void;
  74449. /**
  74450. * Callback called when a task is done (whatever the result is)
  74451. */
  74452. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74453. /**
  74454. * Observable called when all tasks are processed
  74455. */
  74456. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74457. /**
  74458. * Observable called when a task had an error
  74459. */
  74460. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74461. /**
  74462. * Observable called when all tasks were executed
  74463. */
  74464. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74465. /**
  74466. * Observable called when a task is done (whatever the result is)
  74467. */
  74468. onProgressObservable: Observable<IAssetsProgressEvent>;
  74469. /**
  74470. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74471. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74472. */
  74473. useDefaultLoadingScreen: boolean;
  74474. /**
  74475. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74476. * when all assets have been downloaded.
  74477. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74478. */
  74479. autoHideLoadingUI: boolean;
  74480. /**
  74481. * Creates a new AssetsManager
  74482. * @param scene defines the scene to work on
  74483. */
  74484. constructor(scene: Scene);
  74485. /**
  74486. * Add a ContainerAssetTask to the list of active tasks
  74487. * @param taskName defines the name of the new task
  74488. * @param meshesNames defines the name of meshes to load
  74489. * @param rootUrl defines the root url to use to locate files
  74490. * @param sceneFilename defines the filename of the scene file
  74491. * @returns a new ContainerAssetTask object
  74492. */
  74493. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74494. /**
  74495. * Add a MeshAssetTask to the list of active tasks
  74496. * @param taskName defines the name of the new task
  74497. * @param meshesNames defines the name of meshes to load
  74498. * @param rootUrl defines the root url to use to locate files
  74499. * @param sceneFilename defines the filename of the scene file
  74500. * @returns a new MeshAssetTask object
  74501. */
  74502. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74503. /**
  74504. * Add a TextFileAssetTask to the list of active tasks
  74505. * @param taskName defines the name of the new task
  74506. * @param url defines the url of the file to load
  74507. * @returns a new TextFileAssetTask object
  74508. */
  74509. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74510. /**
  74511. * Add a BinaryFileAssetTask to the list of active tasks
  74512. * @param taskName defines the name of the new task
  74513. * @param url defines the url of the file to load
  74514. * @returns a new BinaryFileAssetTask object
  74515. */
  74516. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74517. /**
  74518. * Add a ImageAssetTask to the list of active tasks
  74519. * @param taskName defines the name of the new task
  74520. * @param url defines the url of the file to load
  74521. * @returns a new ImageAssetTask object
  74522. */
  74523. addImageTask(taskName: string, url: string): ImageAssetTask;
  74524. /**
  74525. * Add a TextureAssetTask to the list of active tasks
  74526. * @param taskName defines the name of the new task
  74527. * @param url defines the url of the file to load
  74528. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74529. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74530. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74531. * @returns a new TextureAssetTask object
  74532. */
  74533. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74534. /**
  74535. * Add a CubeTextureAssetTask to the list of active tasks
  74536. * @param taskName defines the name of the new task
  74537. * @param url defines the url of the file to load
  74538. * @param extensions defines the extension to use to load the cube map (can be null)
  74539. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74540. * @param files defines the list of files to load (can be null)
  74541. * @returns a new CubeTextureAssetTask object
  74542. */
  74543. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74544. /**
  74545. *
  74546. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74547. * @param taskName defines the name of the new task
  74548. * @param url defines the url of the file to load
  74549. * @param size defines the size you want for the cubemap (can be null)
  74550. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74551. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74552. * @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)
  74553. * @param reserved Internal use only
  74554. * @returns a new HDRCubeTextureAssetTask object
  74555. */
  74556. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74557. /**
  74558. *
  74559. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74560. * @param taskName defines the name of the new task
  74561. * @param url defines the url of the file to load
  74562. * @param size defines the size you want for the cubemap (can be null)
  74563. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74564. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74565. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74566. * @returns a new EquiRectangularCubeTextureAssetTask object
  74567. */
  74568. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74569. /**
  74570. * Remove a task from the assets manager.
  74571. * @param task the task to remove
  74572. */
  74573. removeTask(task: AbstractAssetTask): void;
  74574. private _decreaseWaitingTasksCount;
  74575. private _runTask;
  74576. /**
  74577. * Reset the AssetsManager and remove all tasks
  74578. * @return the current instance of the AssetsManager
  74579. */
  74580. reset(): AssetsManager;
  74581. /**
  74582. * Start the loading process
  74583. * @return the current instance of the AssetsManager
  74584. */
  74585. load(): AssetsManager;
  74586. /**
  74587. * Start the loading process as an async operation
  74588. * @return a promise returning the list of failed tasks
  74589. */
  74590. loadAsync(): Promise<void>;
  74591. }
  74592. }
  74593. declare module BABYLON {
  74594. /**
  74595. * Wrapper class for promise with external resolve and reject.
  74596. */
  74597. export class Deferred<T> {
  74598. /**
  74599. * The promise associated with this deferred object.
  74600. */
  74601. readonly promise: Promise<T>;
  74602. private _resolve;
  74603. private _reject;
  74604. /**
  74605. * The resolve method of the promise associated with this deferred object.
  74606. */
  74607. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74608. /**
  74609. * The reject method of the promise associated with this deferred object.
  74610. */
  74611. get reject(): (reason?: any) => void;
  74612. /**
  74613. * Constructor for this deferred object.
  74614. */
  74615. constructor();
  74616. }
  74617. }
  74618. declare module BABYLON {
  74619. /**
  74620. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74621. */
  74622. export class MeshExploder {
  74623. private _centerMesh;
  74624. private _meshes;
  74625. private _meshesOrigins;
  74626. private _toCenterVectors;
  74627. private _scaledDirection;
  74628. private _newPosition;
  74629. private _centerPosition;
  74630. /**
  74631. * Explodes meshes from a center mesh.
  74632. * @param meshes The meshes to explode.
  74633. * @param centerMesh The mesh to be center of explosion.
  74634. */
  74635. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74636. private _setCenterMesh;
  74637. /**
  74638. * Get class name
  74639. * @returns "MeshExploder"
  74640. */
  74641. getClassName(): string;
  74642. /**
  74643. * "Exploded meshes"
  74644. * @returns Array of meshes with the centerMesh at index 0.
  74645. */
  74646. getMeshes(): Array<Mesh>;
  74647. /**
  74648. * Explodes meshes giving a specific direction
  74649. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74650. */
  74651. explode(direction?: number): void;
  74652. }
  74653. }
  74654. declare module BABYLON {
  74655. /**
  74656. * Class used to help managing file picking and drag'n'drop
  74657. */
  74658. export class FilesInput {
  74659. /**
  74660. * List of files ready to be loaded
  74661. */
  74662. static get FilesToLoad(): {
  74663. [key: string]: File;
  74664. };
  74665. /**
  74666. * Callback called when a file is processed
  74667. */
  74668. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74669. private _engine;
  74670. private _currentScene;
  74671. private _sceneLoadedCallback;
  74672. private _progressCallback;
  74673. private _additionalRenderLoopLogicCallback;
  74674. private _textureLoadingCallback;
  74675. private _startingProcessingFilesCallback;
  74676. private _onReloadCallback;
  74677. private _errorCallback;
  74678. private _elementToMonitor;
  74679. private _sceneFileToLoad;
  74680. private _filesToLoad;
  74681. /**
  74682. * Creates a new FilesInput
  74683. * @param engine defines the rendering engine
  74684. * @param scene defines the hosting scene
  74685. * @param sceneLoadedCallback callback called when scene is loaded
  74686. * @param progressCallback callback called to track progress
  74687. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74688. * @param textureLoadingCallback callback called when a texture is loading
  74689. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74690. * @param onReloadCallback callback called when a reload is requested
  74691. * @param errorCallback callback call if an error occurs
  74692. */
  74693. 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>);
  74694. private _dragEnterHandler;
  74695. private _dragOverHandler;
  74696. private _dropHandler;
  74697. /**
  74698. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74699. * @param elementToMonitor defines the DOM element to track
  74700. */
  74701. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74702. /** Gets the current list of files to load */
  74703. get filesToLoad(): File[];
  74704. /**
  74705. * Release all associated resources
  74706. */
  74707. dispose(): void;
  74708. private renderFunction;
  74709. private drag;
  74710. private drop;
  74711. private _traverseFolder;
  74712. private _processFiles;
  74713. /**
  74714. * Load files from a drop event
  74715. * @param event defines the drop event to use as source
  74716. */
  74717. loadFiles(event: any): void;
  74718. private _processReload;
  74719. /**
  74720. * Reload the current scene from the loaded files
  74721. */
  74722. reload(): void;
  74723. }
  74724. }
  74725. declare module BABYLON {
  74726. /**
  74727. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74728. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74729. */
  74730. export class SceneOptimization {
  74731. /**
  74732. * Defines the priority of this optimization (0 by default which means first in the list)
  74733. */
  74734. priority: number;
  74735. /**
  74736. * Gets a string describing the action executed by the current optimization
  74737. * @returns description string
  74738. */
  74739. getDescription(): string;
  74740. /**
  74741. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74742. * @param scene defines the current scene where to apply this optimization
  74743. * @param optimizer defines the current optimizer
  74744. * @returns true if everything that can be done was applied
  74745. */
  74746. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74747. /**
  74748. * Creates the SceneOptimization object
  74749. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74750. * @param desc defines the description associated with the optimization
  74751. */
  74752. constructor(
  74753. /**
  74754. * Defines the priority of this optimization (0 by default which means first in the list)
  74755. */
  74756. priority?: number);
  74757. }
  74758. /**
  74759. * Defines an optimization used to reduce the size of render target textures
  74760. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74761. */
  74762. export class TextureOptimization extends SceneOptimization {
  74763. /**
  74764. * Defines the priority of this optimization (0 by default which means first in the list)
  74765. */
  74766. priority: number;
  74767. /**
  74768. * 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
  74769. */
  74770. maximumSize: number;
  74771. /**
  74772. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74773. */
  74774. step: number;
  74775. /**
  74776. * Gets a string describing the action executed by the current optimization
  74777. * @returns description string
  74778. */
  74779. getDescription(): string;
  74780. /**
  74781. * Creates the TextureOptimization object
  74782. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74783. * @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
  74784. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74785. */
  74786. constructor(
  74787. /**
  74788. * Defines the priority of this optimization (0 by default which means first in the list)
  74789. */
  74790. priority?: number,
  74791. /**
  74792. * 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
  74793. */
  74794. maximumSize?: number,
  74795. /**
  74796. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74797. */
  74798. step?: number);
  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 increase or decrease the rendering resolution
  74809. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74810. */
  74811. export class HardwareScalingOptimization extends SceneOptimization {
  74812. /**
  74813. * Defines the priority of this optimization (0 by default which means first in the list)
  74814. */
  74815. priority: number;
  74816. /**
  74817. * Defines the maximum scale to use (2 by default)
  74818. */
  74819. maximumScale: number;
  74820. /**
  74821. * Defines the step to use between two passes (0.5 by default)
  74822. */
  74823. step: number;
  74824. private _currentScale;
  74825. private _directionOffset;
  74826. /**
  74827. * Gets a string describing the action executed by the current optimization
  74828. * @return description string
  74829. */
  74830. getDescription(): string;
  74831. /**
  74832. * Creates the HardwareScalingOptimization object
  74833. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74834. * @param maximumScale defines the maximum scale to use (2 by default)
  74835. * @param step defines the step to use between two passes (0.5 by default)
  74836. */
  74837. constructor(
  74838. /**
  74839. * Defines the priority of this optimization (0 by default which means first in the list)
  74840. */
  74841. priority?: number,
  74842. /**
  74843. * Defines the maximum scale to use (2 by default)
  74844. */
  74845. maximumScale?: number,
  74846. /**
  74847. * Defines the step to use between two passes (0.5 by default)
  74848. */
  74849. step?: number);
  74850. /**
  74851. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74852. * @param scene defines the current scene where to apply this optimization
  74853. * @param optimizer defines the current optimizer
  74854. * @returns true if everything that can be done was applied
  74855. */
  74856. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74857. }
  74858. /**
  74859. * Defines an optimization used to remove shadows
  74860. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74861. */
  74862. export class ShadowsOptimization extends SceneOptimization {
  74863. /**
  74864. * Gets a string describing the action executed by the current optimization
  74865. * @return description string
  74866. */
  74867. getDescription(): string;
  74868. /**
  74869. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74870. * @param scene defines the current scene where to apply this optimization
  74871. * @param optimizer defines the current optimizer
  74872. * @returns true if everything that can be done was applied
  74873. */
  74874. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74875. }
  74876. /**
  74877. * Defines an optimization used to turn post-processes off
  74878. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74879. */
  74880. export class PostProcessesOptimization extends SceneOptimization {
  74881. /**
  74882. * Gets a string describing the action executed by the current optimization
  74883. * @return description string
  74884. */
  74885. getDescription(): string;
  74886. /**
  74887. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74888. * @param scene defines the current scene where to apply this optimization
  74889. * @param optimizer defines the current optimizer
  74890. * @returns true if everything that can be done was applied
  74891. */
  74892. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74893. }
  74894. /**
  74895. * Defines an optimization used to turn lens flares off
  74896. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74897. */
  74898. export class LensFlaresOptimization extends SceneOptimization {
  74899. /**
  74900. * Gets a string describing the action executed by the current optimization
  74901. * @return description string
  74902. */
  74903. getDescription(): string;
  74904. /**
  74905. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74906. * @param scene defines the current scene where to apply this optimization
  74907. * @param optimizer defines the current optimizer
  74908. * @returns true if everything that can be done was applied
  74909. */
  74910. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74911. }
  74912. /**
  74913. * Defines an optimization based on user defined callback.
  74914. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74915. */
  74916. export class CustomOptimization extends SceneOptimization {
  74917. /**
  74918. * Callback called to apply the custom optimization.
  74919. */
  74920. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74921. /**
  74922. * Callback called to get custom description
  74923. */
  74924. onGetDescription: () => string;
  74925. /**
  74926. * Gets a string describing the action executed by the current optimization
  74927. * @returns description string
  74928. */
  74929. getDescription(): string;
  74930. /**
  74931. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74932. * @param scene defines the current scene where to apply this optimization
  74933. * @param optimizer defines the current optimizer
  74934. * @returns true if everything that can be done was applied
  74935. */
  74936. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74937. }
  74938. /**
  74939. * Defines an optimization used to turn particles off
  74940. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74941. */
  74942. export class ParticlesOptimization extends SceneOptimization {
  74943. /**
  74944. * Gets a string describing the action executed by the current optimization
  74945. * @return description string
  74946. */
  74947. getDescription(): string;
  74948. /**
  74949. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74950. * @param scene defines the current scene where to apply this optimization
  74951. * @param optimizer defines the current optimizer
  74952. * @returns true if everything that can be done was applied
  74953. */
  74954. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74955. }
  74956. /**
  74957. * Defines an optimization used to turn render targets off
  74958. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74959. */
  74960. export class RenderTargetsOptimization extends SceneOptimization {
  74961. /**
  74962. * Gets a string describing the action executed by the current optimization
  74963. * @return description string
  74964. */
  74965. getDescription(): string;
  74966. /**
  74967. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74968. * @param scene defines the current scene where to apply this optimization
  74969. * @param optimizer defines the current optimizer
  74970. * @returns true if everything that can be done was applied
  74971. */
  74972. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74973. }
  74974. /**
  74975. * Defines an optimization used to merge meshes with compatible materials
  74976. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74977. */
  74978. export class MergeMeshesOptimization extends SceneOptimization {
  74979. private static _UpdateSelectionTree;
  74980. /**
  74981. * Gets or sets a boolean which defines if optimization octree has to be updated
  74982. */
  74983. static get UpdateSelectionTree(): boolean;
  74984. /**
  74985. * Gets or sets a boolean which defines if optimization octree has to be updated
  74986. */
  74987. static set UpdateSelectionTree(value: boolean);
  74988. /**
  74989. * Gets a string describing the action executed by the current optimization
  74990. * @return description string
  74991. */
  74992. getDescription(): string;
  74993. private _canBeMerged;
  74994. /**
  74995. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74996. * @param scene defines the current scene where to apply this optimization
  74997. * @param optimizer defines the current optimizer
  74998. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74999. * @returns true if everything that can be done was applied
  75000. */
  75001. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75002. }
  75003. /**
  75004. * Defines a list of options used by SceneOptimizer
  75005. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75006. */
  75007. export class SceneOptimizerOptions {
  75008. /**
  75009. * Defines the target frame rate to reach (60 by default)
  75010. */
  75011. targetFrameRate: number;
  75012. /**
  75013. * Defines the interval between two checkes (2000ms by default)
  75014. */
  75015. trackerDuration: number;
  75016. /**
  75017. * Gets the list of optimizations to apply
  75018. */
  75019. optimizations: SceneOptimization[];
  75020. /**
  75021. * Creates a new list of options used by SceneOptimizer
  75022. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75023. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75024. */
  75025. constructor(
  75026. /**
  75027. * Defines the target frame rate to reach (60 by default)
  75028. */
  75029. targetFrameRate?: number,
  75030. /**
  75031. * Defines the interval between two checkes (2000ms by default)
  75032. */
  75033. trackerDuration?: number);
  75034. /**
  75035. * Add a new optimization
  75036. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75037. * @returns the current SceneOptimizerOptions
  75038. */
  75039. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75040. /**
  75041. * Add a new custom optimization
  75042. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75043. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75044. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75045. * @returns the current SceneOptimizerOptions
  75046. */
  75047. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75048. /**
  75049. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75050. * @param targetFrameRate defines the target frame rate (60 by default)
  75051. * @returns a SceneOptimizerOptions object
  75052. */
  75053. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75054. /**
  75055. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75056. * @param targetFrameRate defines the target frame rate (60 by default)
  75057. * @returns a SceneOptimizerOptions object
  75058. */
  75059. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75060. /**
  75061. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75062. * @param targetFrameRate defines the target frame rate (60 by default)
  75063. * @returns a SceneOptimizerOptions object
  75064. */
  75065. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75066. }
  75067. /**
  75068. * Class used to run optimizations in order to reach a target frame rate
  75069. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75070. */
  75071. export class SceneOptimizer implements IDisposable {
  75072. private _isRunning;
  75073. private _options;
  75074. private _scene;
  75075. private _currentPriorityLevel;
  75076. private _targetFrameRate;
  75077. private _trackerDuration;
  75078. private _currentFrameRate;
  75079. private _sceneDisposeObserver;
  75080. private _improvementMode;
  75081. /**
  75082. * Defines an observable called when the optimizer reaches the target frame rate
  75083. */
  75084. onSuccessObservable: Observable<SceneOptimizer>;
  75085. /**
  75086. * Defines an observable called when the optimizer enables an optimization
  75087. */
  75088. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75089. /**
  75090. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75091. */
  75092. onFailureObservable: Observable<SceneOptimizer>;
  75093. /**
  75094. * Gets a boolean indicating if the optimizer is in improvement mode
  75095. */
  75096. get isInImprovementMode(): boolean;
  75097. /**
  75098. * Gets the current priority level (0 at start)
  75099. */
  75100. get currentPriorityLevel(): number;
  75101. /**
  75102. * Gets the current frame rate checked by the SceneOptimizer
  75103. */
  75104. get currentFrameRate(): number;
  75105. /**
  75106. * Gets or sets the current target frame rate (60 by default)
  75107. */
  75108. get targetFrameRate(): number;
  75109. /**
  75110. * Gets or sets the current target frame rate (60 by default)
  75111. */
  75112. set targetFrameRate(value: number);
  75113. /**
  75114. * Gets or sets the current interval between two checks (every 2000ms by default)
  75115. */
  75116. get trackerDuration(): number;
  75117. /**
  75118. * Gets or sets the current interval between two checks (every 2000ms by default)
  75119. */
  75120. set trackerDuration(value: number);
  75121. /**
  75122. * Gets the list of active optimizations
  75123. */
  75124. get optimizations(): SceneOptimization[];
  75125. /**
  75126. * Creates a new SceneOptimizer
  75127. * @param scene defines the scene to work on
  75128. * @param options defines the options to use with the SceneOptimizer
  75129. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75130. * @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)
  75131. */
  75132. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75133. /**
  75134. * Stops the current optimizer
  75135. */
  75136. stop(): void;
  75137. /**
  75138. * Reset the optimizer to initial step (current priority level = 0)
  75139. */
  75140. reset(): void;
  75141. /**
  75142. * Start the optimizer. By default it will try to reach a specific framerate
  75143. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75144. */
  75145. start(): void;
  75146. private _checkCurrentState;
  75147. /**
  75148. * Release all resources
  75149. */
  75150. dispose(): void;
  75151. /**
  75152. * Helper function to create a SceneOptimizer with one single line of code
  75153. * @param scene defines the scene to work on
  75154. * @param options defines the options to use with the SceneOptimizer
  75155. * @param onSuccess defines a callback to call on success
  75156. * @param onFailure defines a callback to call on failure
  75157. * @returns the new SceneOptimizer object
  75158. */
  75159. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75160. }
  75161. }
  75162. declare module BABYLON {
  75163. /**
  75164. * Class used to serialize a scene into a string
  75165. */
  75166. export class SceneSerializer {
  75167. /**
  75168. * Clear cache used by a previous serialization
  75169. */
  75170. static ClearCache(): void;
  75171. /**
  75172. * Serialize a scene into a JSON compatible object
  75173. * @param scene defines the scene to serialize
  75174. * @returns a JSON compatible object
  75175. */
  75176. static Serialize(scene: Scene): any;
  75177. /**
  75178. * Serialize a mesh into a JSON compatible object
  75179. * @param toSerialize defines the mesh to serialize
  75180. * @param withParents defines if parents must be serialized as well
  75181. * @param withChildren defines if children must be serialized as well
  75182. * @returns a JSON compatible object
  75183. */
  75184. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75185. }
  75186. }
  75187. declare module BABYLON {
  75188. /**
  75189. * Class used to host texture specific utilities
  75190. */
  75191. export class TextureTools {
  75192. /**
  75193. * Uses the GPU to create a copy texture rescaled at a given size
  75194. * @param texture Texture to copy from
  75195. * @param width defines the desired width
  75196. * @param height defines the desired height
  75197. * @param useBilinearMode defines if bilinear mode has to be used
  75198. * @return the generated texture
  75199. */
  75200. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75201. }
  75202. }
  75203. declare module BABYLON {
  75204. /**
  75205. * This represents the different options available for the video capture.
  75206. */
  75207. export interface VideoRecorderOptions {
  75208. /** Defines the mime type of the video. */
  75209. mimeType: string;
  75210. /** Defines the FPS the video should be recorded at. */
  75211. fps: number;
  75212. /** Defines the chunk size for the recording data. */
  75213. recordChunckSize: number;
  75214. /** The audio tracks to attach to the recording. */
  75215. audioTracks?: MediaStreamTrack[];
  75216. }
  75217. /**
  75218. * This can help with recording videos from BabylonJS.
  75219. * This is based on the available WebRTC functionalities of the browser.
  75220. *
  75221. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75222. */
  75223. export class VideoRecorder {
  75224. private static readonly _defaultOptions;
  75225. /**
  75226. * Returns whether or not the VideoRecorder is available in your browser.
  75227. * @param engine Defines the Babylon Engine.
  75228. * @returns true if supported otherwise false.
  75229. */
  75230. static IsSupported(engine: Engine): boolean;
  75231. private readonly _options;
  75232. private _canvas;
  75233. private _mediaRecorder;
  75234. private _recordedChunks;
  75235. private _fileName;
  75236. private _resolve;
  75237. private _reject;
  75238. /**
  75239. * True when a recording is already in progress.
  75240. */
  75241. get isRecording(): boolean;
  75242. /**
  75243. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75244. * @param engine Defines the BabylonJS Engine you wish to record.
  75245. * @param options Defines options that can be used to customize the capture.
  75246. */
  75247. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75248. /**
  75249. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75250. */
  75251. stopRecording(): void;
  75252. /**
  75253. * Starts recording the canvas for a max duration specified in parameters.
  75254. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75255. * If null no automatic download will start and you can rely on the promise to get the data back.
  75256. * @param maxDuration Defines the maximum recording time in seconds.
  75257. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75258. * @return A promise callback at the end of the recording with the video data in Blob.
  75259. */
  75260. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75261. /**
  75262. * Releases internal resources used during the recording.
  75263. */
  75264. dispose(): void;
  75265. private _handleDataAvailable;
  75266. private _handleError;
  75267. private _handleStop;
  75268. }
  75269. }
  75270. declare module BABYLON {
  75271. /**
  75272. * Class containing a set of static utilities functions for screenshots
  75273. */
  75274. export class ScreenshotTools {
  75275. /**
  75276. * Captures a screenshot of the current rendering
  75277. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75278. * @param engine defines the rendering engine
  75279. * @param camera defines the source camera
  75280. * @param size This parameter can be set to a single number or to an object with the
  75281. * following (optional) properties: precision, width, height. If a single number is passed,
  75282. * it will be used for both width and height. If an object is passed, the screenshot size
  75283. * will be derived from the parameters. The precision property is a multiplier allowing
  75284. * rendering at a higher or lower resolution
  75285. * @param successCallback defines the callback receives a single parameter which contains the
  75286. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75287. * src parameter of an <img> to display it
  75288. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75289. * Check your browser for supported MIME types
  75290. */
  75291. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75292. /**
  75293. * Captures a screenshot of the current rendering
  75294. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75295. * @param engine defines the rendering engine
  75296. * @param camera defines the source camera
  75297. * @param size This parameter can be set to a single number or to an object with the
  75298. * following (optional) properties: precision, width, height. If a single number is passed,
  75299. * it will be used for both width and height. If an object is passed, the screenshot size
  75300. * will be derived from the parameters. The precision property is a multiplier allowing
  75301. * rendering at a higher or lower resolution
  75302. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75303. * Check your browser for supported MIME types
  75304. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75305. * to the src parameter of an <img> to display it
  75306. */
  75307. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75308. /**
  75309. * Generates an image screenshot from the specified camera.
  75310. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75311. * @param engine The engine to use for rendering
  75312. * @param camera The camera to use for rendering
  75313. * @param size This parameter can be set to a single number or to an object with the
  75314. * following (optional) properties: precision, width, height. If a single number is passed,
  75315. * it will be used for both width and height. If an object is passed, the screenshot size
  75316. * will be derived from the parameters. The precision property is a multiplier allowing
  75317. * rendering at a higher or lower resolution
  75318. * @param successCallback The callback receives a single parameter which contains the
  75319. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75320. * src parameter of an <img> to display it
  75321. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75322. * Check your browser for supported MIME types
  75323. * @param samples Texture samples (default: 1)
  75324. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75325. * @param fileName A name for for the downloaded file.
  75326. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75327. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75328. */
  75329. 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;
  75330. /**
  75331. * Generates an image screenshot from the specified camera.
  75332. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75333. * @param engine The engine to use for rendering
  75334. * @param camera The camera to use for rendering
  75335. * @param size This parameter can be set to a single number or to an object with the
  75336. * following (optional) properties: precision, width, height. If a single number is passed,
  75337. * it will be used for both width and height. If an object is passed, the screenshot size
  75338. * will be derived from the parameters. The precision property is a multiplier allowing
  75339. * rendering at a higher or lower resolution
  75340. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75341. * Check your browser for supported MIME types
  75342. * @param samples Texture samples (default: 1)
  75343. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75344. * @param fileName A name for for the downloaded file.
  75345. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75346. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75347. * to the src parameter of an <img> to display it
  75348. */
  75349. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75350. /**
  75351. * Gets height and width for screenshot size
  75352. * @private
  75353. */
  75354. private static _getScreenshotSize;
  75355. }
  75356. }
  75357. declare module BABYLON {
  75358. /**
  75359. * Interface for a data buffer
  75360. */
  75361. export interface IDataBuffer {
  75362. /**
  75363. * Reads bytes from the data buffer.
  75364. * @param byteOffset The byte offset to read
  75365. * @param byteLength The byte length to read
  75366. * @returns A promise that resolves when the bytes are read
  75367. */
  75368. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75369. /**
  75370. * The byte length of the buffer.
  75371. */
  75372. readonly byteLength: number;
  75373. }
  75374. /**
  75375. * Utility class for reading from a data buffer
  75376. */
  75377. export class DataReader {
  75378. /**
  75379. * The data buffer associated with this data reader.
  75380. */
  75381. readonly buffer: IDataBuffer;
  75382. /**
  75383. * The current byte offset from the beginning of the data buffer.
  75384. */
  75385. byteOffset: number;
  75386. private _dataView;
  75387. private _dataByteOffset;
  75388. /**
  75389. * Constructor
  75390. * @param buffer The buffer to read
  75391. */
  75392. constructor(buffer: IDataBuffer);
  75393. /**
  75394. * Loads the given byte length.
  75395. * @param byteLength The byte length to load
  75396. * @returns A promise that resolves when the load is complete
  75397. */
  75398. loadAsync(byteLength: number): Promise<void>;
  75399. /**
  75400. * Read a unsigned 32-bit integer from the currently loaded data range.
  75401. * @returns The 32-bit integer read
  75402. */
  75403. readUint32(): number;
  75404. /**
  75405. * Read a byte array from the currently loaded data range.
  75406. * @param byteLength The byte length to read
  75407. * @returns The byte array read
  75408. */
  75409. readUint8Array(byteLength: number): Uint8Array;
  75410. /**
  75411. * Read a string from the currently loaded data range.
  75412. * @param byteLength The byte length to read
  75413. * @returns The string read
  75414. */
  75415. readString(byteLength: number): string;
  75416. /**
  75417. * Skips the given byte length the currently loaded data range.
  75418. * @param byteLength The byte length to skip
  75419. */
  75420. skipBytes(byteLength: number): void;
  75421. }
  75422. }
  75423. declare module BABYLON {
  75424. /**
  75425. * Class for storing data to local storage if available or in-memory storage otherwise
  75426. */
  75427. export class DataStorage {
  75428. private static _Storage;
  75429. private static _GetStorage;
  75430. /**
  75431. * Reads a string from the data storage
  75432. * @param key The key to read
  75433. * @param defaultValue The value if the key doesn't exist
  75434. * @returns The string value
  75435. */
  75436. static ReadString(key: string, defaultValue: string): string;
  75437. /**
  75438. * Writes a string to the data storage
  75439. * @param key The key to write
  75440. * @param value The value to write
  75441. */
  75442. static WriteString(key: string, value: string): void;
  75443. /**
  75444. * Reads a boolean from the data storage
  75445. * @param key The key to read
  75446. * @param defaultValue The value if the key doesn't exist
  75447. * @returns The boolean value
  75448. */
  75449. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75450. /**
  75451. * Writes a boolean to the data storage
  75452. * @param key The key to write
  75453. * @param value The value to write
  75454. */
  75455. static WriteBoolean(key: string, value: boolean): void;
  75456. /**
  75457. * Reads a number from the data storage
  75458. * @param key The key to read
  75459. * @param defaultValue The value if the key doesn't exist
  75460. * @returns The number value
  75461. */
  75462. static ReadNumber(key: string, defaultValue: number): number;
  75463. /**
  75464. * Writes a number to the data storage
  75465. * @param key The key to write
  75466. * @param value The value to write
  75467. */
  75468. static WriteNumber(key: string, value: number): void;
  75469. }
  75470. }
  75471. declare module BABYLON {
  75472. /**
  75473. * Class used to record delta files between 2 scene states
  75474. */
  75475. export class SceneRecorder {
  75476. private _trackedScene;
  75477. private _savedJSON;
  75478. /**
  75479. * Track a given scene. This means the current scene state will be considered the original state
  75480. * @param scene defines the scene to track
  75481. */
  75482. track(scene: Scene): void;
  75483. /**
  75484. * Get the delta between current state and original state
  75485. * @returns a string containing the delta
  75486. */
  75487. getDelta(): any;
  75488. private _compareArray;
  75489. private _compareObjects;
  75490. private _compareCollections;
  75491. private static GetShadowGeneratorById;
  75492. /**
  75493. * Apply a given delta to a given scene
  75494. * @param deltaJSON defines the JSON containing the delta
  75495. * @param scene defines the scene to apply the delta to
  75496. */
  75497. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75498. private static _ApplyPropertiesToEntity;
  75499. private static _ApplyDeltaForEntity;
  75500. }
  75501. }
  75502. declare module BABYLON {
  75503. /**
  75504. * A 3D trajectory consisting of an order list of vectors describing a
  75505. * path of motion through 3D space.
  75506. */
  75507. export class Trajectory {
  75508. private _points;
  75509. private readonly _segmentLength;
  75510. /**
  75511. * Serialize to JSON.
  75512. * @returns serialized JSON string
  75513. */
  75514. serialize(): string;
  75515. /**
  75516. * Deserialize from JSON.
  75517. * @param json serialized JSON string
  75518. * @returns deserialized Trajectory
  75519. */
  75520. static Deserialize(json: string): Trajectory;
  75521. /**
  75522. * Create a new empty Trajectory.
  75523. * @param segmentLength radius of discretization for Trajectory points
  75524. */
  75525. constructor(segmentLength?: number);
  75526. /**
  75527. * Get the length of the Trajectory.
  75528. * @returns length of the Trajectory
  75529. */
  75530. getLength(): number;
  75531. /**
  75532. * Append a new point to the Trajectory.
  75533. * NOTE: This implementation has many allocations.
  75534. * @param point point to append to the Trajectory
  75535. */
  75536. add(point: DeepImmutable<Vector3>): void;
  75537. /**
  75538. * Create a new Trajectory with a segment length chosen to make it
  75539. * probable that the new Trajectory will have a specified number of
  75540. * segments. This operation is imprecise.
  75541. * @param targetResolution number of segments desired
  75542. * @returns new Trajectory with approximately the requested number of segments
  75543. */
  75544. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75545. /**
  75546. * Convert Trajectory segments into tokenized representation. This
  75547. * representation is an array of numbers where each nth number is the
  75548. * index of the token which is most similar to the nth segment of the
  75549. * Trajectory.
  75550. * @param tokens list of vectors which serve as discrete tokens
  75551. * @returns list of indices of most similar token per segment
  75552. */
  75553. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75554. private static _forwardDir;
  75555. private static _inverseFromVec;
  75556. private static _upDir;
  75557. private static _fromToVec;
  75558. private static _lookMatrix;
  75559. /**
  75560. * Transform the rotation (i.e., direction) of a segment to isolate
  75561. * the relative transformation represented by the segment. This operation
  75562. * may or may not succeed due to singularities in the equations that define
  75563. * motion relativity in this context.
  75564. * @param priorVec the origin of the prior segment
  75565. * @param fromVec the origin of the current segment
  75566. * @param toVec the destination of the current segment
  75567. * @param result reference to output variable
  75568. * @returns whether or not transformation was successful
  75569. */
  75570. private static _transformSegmentDirToRef;
  75571. private static _bestMatch;
  75572. private static _score;
  75573. private static _bestScore;
  75574. /**
  75575. * Determine which token vector is most similar to the
  75576. * segment vector.
  75577. * @param segment segment vector
  75578. * @param tokens token vector list
  75579. * @returns index of the most similar token to the segment
  75580. */
  75581. private static _tokenizeSegment;
  75582. }
  75583. /**
  75584. * Class representing a set of known, named trajectories to which Trajectories can be
  75585. * added and using which Trajectories can be recognized.
  75586. */
  75587. export class TrajectoryClassifier {
  75588. private _maximumAllowableMatchCost;
  75589. private _vector3Alphabet;
  75590. private _levenshteinAlphabet;
  75591. private _nameToDescribedTrajectory;
  75592. /**
  75593. * Serialize to JSON.
  75594. * @returns JSON serialization
  75595. */
  75596. serialize(): string;
  75597. /**
  75598. * Deserialize from JSON.
  75599. * @param json JSON serialization
  75600. * @returns deserialized TrajectorySet
  75601. */
  75602. static Deserialize(json: string): TrajectoryClassifier;
  75603. /**
  75604. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75605. * VERY naive, need to be generating these things from known
  75606. * sets. Better version later, probably eliminating this one.
  75607. * @returns auto-generated TrajectorySet
  75608. */
  75609. static Generate(): TrajectoryClassifier;
  75610. private constructor();
  75611. /**
  75612. * Add a new Trajectory to the set with a given name.
  75613. * @param trajectory new Trajectory to be added
  75614. * @param classification name to which to add the Trajectory
  75615. */
  75616. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75617. /**
  75618. * Remove a known named trajectory and all Trajectories associated with it.
  75619. * @param classification name to remove
  75620. * @returns whether anything was removed
  75621. */
  75622. deleteClassification(classification: string): boolean;
  75623. /**
  75624. * Attempt to recognize a Trajectory from among all the classifications
  75625. * already known to the classifier.
  75626. * @param trajectory Trajectory to be recognized
  75627. * @returns classification of Trajectory if recognized, null otherwise
  75628. */
  75629. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75630. }
  75631. }
  75632. declare module BABYLON {
  75633. /**
  75634. * An interface for all Hit test features
  75635. */
  75636. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75637. /**
  75638. * Triggered when new babylon (transformed) hit test results are available
  75639. */
  75640. onHitTestResultObservable: Observable<T[]>;
  75641. }
  75642. /**
  75643. * Options used for hit testing
  75644. */
  75645. export interface IWebXRLegacyHitTestOptions {
  75646. /**
  75647. * Only test when user interacted with the scene. Default - hit test every frame
  75648. */
  75649. testOnPointerDownOnly?: boolean;
  75650. /**
  75651. * The node to use to transform the local results to world coordinates
  75652. */
  75653. worldParentNode?: TransformNode;
  75654. }
  75655. /**
  75656. * Interface defining the babylon result of raycasting/hit-test
  75657. */
  75658. export interface IWebXRLegacyHitResult {
  75659. /**
  75660. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75661. */
  75662. transformationMatrix: Matrix;
  75663. /**
  75664. * The native hit test result
  75665. */
  75666. xrHitResult: XRHitResult | XRHitTestResult;
  75667. }
  75668. /**
  75669. * The currently-working hit-test module.
  75670. * Hit test (or Ray-casting) is used to interact with the real world.
  75671. * For further information read here - https://github.com/immersive-web/hit-test
  75672. */
  75673. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75674. /**
  75675. * options to use when constructing this feature
  75676. */
  75677. readonly options: IWebXRLegacyHitTestOptions;
  75678. private _direction;
  75679. private _mat;
  75680. private _onSelectEnabled;
  75681. private _origin;
  75682. /**
  75683. * The module's name
  75684. */
  75685. static readonly Name: string;
  75686. /**
  75687. * The (Babylon) version of this module.
  75688. * This is an integer representing the implementation version.
  75689. * This number does not correspond to the WebXR specs version
  75690. */
  75691. static readonly Version: number;
  75692. /**
  75693. * Populated with the last native XR Hit Results
  75694. */
  75695. lastNativeXRHitResults: XRHitResult[];
  75696. /**
  75697. * Triggered when new babylon (transformed) hit test results are available
  75698. */
  75699. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75700. /**
  75701. * Creates a new instance of the (legacy version) hit test feature
  75702. * @param _xrSessionManager an instance of WebXRSessionManager
  75703. * @param options options to use when constructing this feature
  75704. */
  75705. constructor(_xrSessionManager: WebXRSessionManager,
  75706. /**
  75707. * options to use when constructing this feature
  75708. */
  75709. options?: IWebXRLegacyHitTestOptions);
  75710. /**
  75711. * execute a hit test with an XR Ray
  75712. *
  75713. * @param xrSession a native xrSession that will execute this hit test
  75714. * @param xrRay the ray (position and direction) to use for ray-casting
  75715. * @param referenceSpace native XR reference space to use for the hit-test
  75716. * @param filter filter function that will filter the results
  75717. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75718. */
  75719. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75720. /**
  75721. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75722. * @param event the (select) event to use to select with
  75723. * @param referenceSpace the reference space to use for this hit test
  75724. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75725. */
  75726. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75727. /**
  75728. * attach this feature
  75729. * Will usually be called by the features manager
  75730. *
  75731. * @returns true if successful.
  75732. */
  75733. attach(): boolean;
  75734. /**
  75735. * detach this feature.
  75736. * Will usually be called by the features manager
  75737. *
  75738. * @returns true if successful.
  75739. */
  75740. detach(): boolean;
  75741. /**
  75742. * Dispose this feature and all of the resources attached
  75743. */
  75744. dispose(): void;
  75745. protected _onXRFrame(frame: XRFrame): void;
  75746. private _onHitTestResults;
  75747. private _onSelect;
  75748. }
  75749. }
  75750. declare module BABYLON {
  75751. /**
  75752. * Options used for hit testing (version 2)
  75753. */
  75754. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75755. /**
  75756. * Do not create a permanent hit test. Will usually be used when only
  75757. * transient inputs are needed.
  75758. */
  75759. disablePermanentHitTest?: boolean;
  75760. /**
  75761. * Enable transient (for example touch-based) hit test inspections
  75762. */
  75763. enableTransientHitTest?: boolean;
  75764. /**
  75765. * Offset ray for the permanent hit test
  75766. */
  75767. offsetRay?: Vector3;
  75768. /**
  75769. * Offset ray for the transient hit test
  75770. */
  75771. transientOffsetRay?: Vector3;
  75772. /**
  75773. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75774. */
  75775. useReferenceSpace?: boolean;
  75776. /**
  75777. * Override the default entity type(s) of the hit-test result
  75778. */
  75779. entityTypes?: XRHitTestTrackableType[];
  75780. }
  75781. /**
  75782. * Interface defining the babylon result of hit-test
  75783. */
  75784. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75785. /**
  75786. * The input source that generated this hit test (if transient)
  75787. */
  75788. inputSource?: XRInputSource;
  75789. /**
  75790. * Is this a transient hit test
  75791. */
  75792. isTransient?: boolean;
  75793. /**
  75794. * Position of the hit test result
  75795. */
  75796. position: Vector3;
  75797. /**
  75798. * Rotation of the hit test result
  75799. */
  75800. rotationQuaternion: Quaternion;
  75801. /**
  75802. * The native hit test result
  75803. */
  75804. xrHitResult: XRHitTestResult;
  75805. }
  75806. /**
  75807. * The currently-working hit-test module.
  75808. * Hit test (or Ray-casting) is used to interact with the real world.
  75809. * For further information read here - https://github.com/immersive-web/hit-test
  75810. *
  75811. * Tested on chrome (mobile) 80.
  75812. */
  75813. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75814. /**
  75815. * options to use when constructing this feature
  75816. */
  75817. readonly options: IWebXRHitTestOptions;
  75818. private _tmpMat;
  75819. private _tmpPos;
  75820. private _tmpQuat;
  75821. private _transientXrHitTestSource;
  75822. private _xrHitTestSource;
  75823. private initHitTestSource;
  75824. /**
  75825. * The module's name
  75826. */
  75827. static readonly Name: string;
  75828. /**
  75829. * The (Babylon) version of this module.
  75830. * This is an integer representing the implementation version.
  75831. * This number does not correspond to the WebXR specs version
  75832. */
  75833. static readonly Version: number;
  75834. /**
  75835. * When set to true, each hit test will have its own position/rotation objects
  75836. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75837. * the developers will clone them or copy them as they see fit.
  75838. */
  75839. autoCloneTransformation: boolean;
  75840. /**
  75841. * Triggered when new babylon (transformed) hit test results are available
  75842. * Note - this will be called when results come back from the device. It can be an empty array!!
  75843. */
  75844. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75845. /**
  75846. * Use this to temporarily pause hit test checks.
  75847. */
  75848. paused: boolean;
  75849. /**
  75850. * Creates a new instance of the hit test feature
  75851. * @param _xrSessionManager an instance of WebXRSessionManager
  75852. * @param options options to use when constructing this feature
  75853. */
  75854. constructor(_xrSessionManager: WebXRSessionManager,
  75855. /**
  75856. * options to use when constructing this feature
  75857. */
  75858. options?: IWebXRHitTestOptions);
  75859. /**
  75860. * attach this feature
  75861. * Will usually be called by the features manager
  75862. *
  75863. * @returns true if successful.
  75864. */
  75865. attach(): boolean;
  75866. /**
  75867. * detach this feature.
  75868. * Will usually be called by the features manager
  75869. *
  75870. * @returns true if successful.
  75871. */
  75872. detach(): boolean;
  75873. /**
  75874. * Dispose this feature and all of the resources attached
  75875. */
  75876. dispose(): void;
  75877. protected _onXRFrame(frame: XRFrame): void;
  75878. private _processWebXRHitTestResult;
  75879. }
  75880. }
  75881. declare module BABYLON {
  75882. /**
  75883. * Configuration options of the anchor system
  75884. */
  75885. export interface IWebXRAnchorSystemOptions {
  75886. /**
  75887. * a node that will be used to convert local to world coordinates
  75888. */
  75889. worldParentNode?: TransformNode;
  75890. /**
  75891. * If set to true a reference of the created anchors will be kept until the next session starts
  75892. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75893. */
  75894. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75895. }
  75896. /**
  75897. * A babylon container for an XR Anchor
  75898. */
  75899. export interface IWebXRAnchor {
  75900. /**
  75901. * A babylon-assigned ID for this anchor
  75902. */
  75903. id: number;
  75904. /**
  75905. * Transformation matrix to apply to an object attached to this anchor
  75906. */
  75907. transformationMatrix: Matrix;
  75908. /**
  75909. * The native anchor object
  75910. */
  75911. xrAnchor: XRAnchor;
  75912. /**
  75913. * if defined, this object will be constantly updated by the anchor's position and rotation
  75914. */
  75915. attachedNode?: TransformNode;
  75916. }
  75917. /**
  75918. * An implementation of the anchor system for WebXR.
  75919. * For further information see https://github.com/immersive-web/anchors/
  75920. */
  75921. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75922. private _options;
  75923. private _lastFrameDetected;
  75924. private _trackedAnchors;
  75925. private _referenceSpaceForFrameAnchors;
  75926. private _futureAnchors;
  75927. /**
  75928. * The module's name
  75929. */
  75930. static readonly Name: string;
  75931. /**
  75932. * The (Babylon) version of this module.
  75933. * This is an integer representing the implementation version.
  75934. * This number does not correspond to the WebXR specs version
  75935. */
  75936. static readonly Version: number;
  75937. /**
  75938. * Observers registered here will be executed when a new anchor was added to the session
  75939. */
  75940. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75941. /**
  75942. * Observers registered here will be executed when an anchor was removed from the session
  75943. */
  75944. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75945. /**
  75946. * Observers registered here will be executed when an existing anchor updates
  75947. * This can execute N times every frame
  75948. */
  75949. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75950. /**
  75951. * Set the reference space to use for anchor creation, when not using a hit test.
  75952. * Will default to the session's reference space if not defined
  75953. */
  75954. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75955. /**
  75956. * constructs a new anchor system
  75957. * @param _xrSessionManager an instance of WebXRSessionManager
  75958. * @param _options configuration object for this feature
  75959. */
  75960. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75961. private _tmpVector;
  75962. private _tmpQuaternion;
  75963. private _populateTmpTransformation;
  75964. /**
  75965. * Create a new anchor point using a hit test result at a specific point in the scene
  75966. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75967. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75968. *
  75969. * @param hitTestResult The hit test result to use for this anchor creation
  75970. * @param position an optional position offset for this anchor
  75971. * @param rotationQuaternion an optional rotation offset for this anchor
  75972. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75973. */
  75974. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75975. /**
  75976. * Add a new anchor at a specific position and rotation
  75977. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75978. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75979. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75980. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75981. *
  75982. * @param position the position in which to add an anchor
  75983. * @param rotationQuaternion an optional rotation for the anchor transformation
  75984. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75985. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75986. */
  75987. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75988. /**
  75989. * detach this feature.
  75990. * Will usually be called by the features manager
  75991. *
  75992. * @returns true if successful.
  75993. */
  75994. detach(): boolean;
  75995. /**
  75996. * Dispose this feature and all of the resources attached
  75997. */
  75998. dispose(): void;
  75999. protected _onXRFrame(frame: XRFrame): void;
  76000. /**
  76001. * avoiding using Array.find for global support.
  76002. * @param xrAnchor the plane to find in the array
  76003. */
  76004. private _findIndexInAnchorArray;
  76005. private _updateAnchorWithXRFrame;
  76006. private _createAnchorAtTransformation;
  76007. }
  76008. }
  76009. declare module BABYLON {
  76010. /**
  76011. * Options used in the plane detector module
  76012. */
  76013. export interface IWebXRPlaneDetectorOptions {
  76014. /**
  76015. * The node to use to transform the local results to world coordinates
  76016. */
  76017. worldParentNode?: TransformNode;
  76018. /**
  76019. * If set to true a reference of the created planes will be kept until the next session starts
  76020. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76021. */
  76022. doNotRemovePlanesOnSessionEnded?: boolean;
  76023. }
  76024. /**
  76025. * A babylon interface for a WebXR plane.
  76026. * A Plane is actually a polygon, built from N points in space
  76027. *
  76028. * Supported in chrome 79, not supported in canary 81 ATM
  76029. */
  76030. export interface IWebXRPlane {
  76031. /**
  76032. * a babylon-assigned ID for this polygon
  76033. */
  76034. id: number;
  76035. /**
  76036. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76037. */
  76038. polygonDefinition: Array<Vector3>;
  76039. /**
  76040. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76041. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76042. */
  76043. transformationMatrix: Matrix;
  76044. /**
  76045. * the native xr-plane object
  76046. */
  76047. xrPlane: XRPlane;
  76048. }
  76049. /**
  76050. * The plane detector is used to detect planes in the real world when in AR
  76051. * For more information see https://github.com/immersive-web/real-world-geometry/
  76052. */
  76053. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76054. private _options;
  76055. private _detectedPlanes;
  76056. private _enabled;
  76057. private _lastFrameDetected;
  76058. /**
  76059. * The module's name
  76060. */
  76061. static readonly Name: string;
  76062. /**
  76063. * The (Babylon) version of this module.
  76064. * This is an integer representing the implementation version.
  76065. * This number does not correspond to the WebXR specs version
  76066. */
  76067. static readonly Version: number;
  76068. /**
  76069. * Observers registered here will be executed when a new plane was added to the session
  76070. */
  76071. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76072. /**
  76073. * Observers registered here will be executed when a plane is no longer detected in the session
  76074. */
  76075. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76076. /**
  76077. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76078. * This can execute N times every frame
  76079. */
  76080. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76081. /**
  76082. * construct a new Plane Detector
  76083. * @param _xrSessionManager an instance of xr Session manager
  76084. * @param _options configuration to use when constructing this feature
  76085. */
  76086. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76087. /**
  76088. * detach this feature.
  76089. * Will usually be called by the features manager
  76090. *
  76091. * @returns true if successful.
  76092. */
  76093. detach(): boolean;
  76094. /**
  76095. * Dispose this feature and all of the resources attached
  76096. */
  76097. dispose(): void;
  76098. /**
  76099. * Check if the needed objects are defined.
  76100. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76101. */
  76102. isCompatible(): boolean;
  76103. protected _onXRFrame(frame: XRFrame): void;
  76104. private _init;
  76105. private _updatePlaneWithXRPlane;
  76106. /**
  76107. * avoiding using Array.find for global support.
  76108. * @param xrPlane the plane to find in the array
  76109. */
  76110. private findIndexInPlaneArray;
  76111. }
  76112. }
  76113. declare module BABYLON {
  76114. /**
  76115. * Options interface for the background remover plugin
  76116. */
  76117. export interface IWebXRBackgroundRemoverOptions {
  76118. /**
  76119. * Further background meshes to disable when entering AR
  76120. */
  76121. backgroundMeshes?: AbstractMesh[];
  76122. /**
  76123. * flags to configure the removal of the environment helper.
  76124. * If not set, the entire background will be removed. If set, flags should be set as well.
  76125. */
  76126. environmentHelperRemovalFlags?: {
  76127. /**
  76128. * Should the skybox be removed (default false)
  76129. */
  76130. skyBox?: boolean;
  76131. /**
  76132. * Should the ground be removed (default false)
  76133. */
  76134. ground?: boolean;
  76135. };
  76136. /**
  76137. * don't disable the environment helper
  76138. */
  76139. ignoreEnvironmentHelper?: boolean;
  76140. }
  76141. /**
  76142. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76143. */
  76144. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76145. /**
  76146. * read-only options to be used in this module
  76147. */
  76148. readonly options: IWebXRBackgroundRemoverOptions;
  76149. /**
  76150. * The module's name
  76151. */
  76152. static readonly Name: string;
  76153. /**
  76154. * The (Babylon) version of this module.
  76155. * This is an integer representing the implementation version.
  76156. * This number does not correspond to the WebXR specs version
  76157. */
  76158. static readonly Version: number;
  76159. /**
  76160. * registered observers will be triggered when the background state changes
  76161. */
  76162. onBackgroundStateChangedObservable: Observable<boolean>;
  76163. /**
  76164. * constructs a new background remover module
  76165. * @param _xrSessionManager the session manager for this module
  76166. * @param options read-only options to be used in this module
  76167. */
  76168. constructor(_xrSessionManager: WebXRSessionManager,
  76169. /**
  76170. * read-only options to be used in this module
  76171. */
  76172. options?: IWebXRBackgroundRemoverOptions);
  76173. /**
  76174. * attach this feature
  76175. * Will usually be called by the features manager
  76176. *
  76177. * @returns true if successful.
  76178. */
  76179. attach(): boolean;
  76180. /**
  76181. * detach this feature.
  76182. * Will usually be called by the features manager
  76183. *
  76184. * @returns true if successful.
  76185. */
  76186. detach(): boolean;
  76187. /**
  76188. * Dispose this feature and all of the resources attached
  76189. */
  76190. dispose(): void;
  76191. protected _onXRFrame(_xrFrame: XRFrame): void;
  76192. private _setBackgroundState;
  76193. }
  76194. }
  76195. declare module BABYLON {
  76196. /**
  76197. * Options for the controller physics feature
  76198. */
  76199. export class IWebXRControllerPhysicsOptions {
  76200. /**
  76201. * Should the headset get its own impostor
  76202. */
  76203. enableHeadsetImpostor?: boolean;
  76204. /**
  76205. * Optional parameters for the headset impostor
  76206. */
  76207. headsetImpostorParams?: {
  76208. /**
  76209. * The type of impostor to create. Default is sphere
  76210. */
  76211. impostorType: number;
  76212. /**
  76213. * the size of the impostor. Defaults to 10cm
  76214. */
  76215. impostorSize?: number | {
  76216. width: number;
  76217. height: number;
  76218. depth: number;
  76219. };
  76220. /**
  76221. * Friction definitions
  76222. */
  76223. friction?: number;
  76224. /**
  76225. * Restitution
  76226. */
  76227. restitution?: number;
  76228. };
  76229. /**
  76230. * The physics properties of the future impostors
  76231. */
  76232. physicsProperties?: {
  76233. /**
  76234. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76235. * Note that this requires a physics engine that supports mesh impostors!
  76236. */
  76237. useControllerMesh?: boolean;
  76238. /**
  76239. * The type of impostor to create. Default is sphere
  76240. */
  76241. impostorType?: number;
  76242. /**
  76243. * the size of the impostor. Defaults to 10cm
  76244. */
  76245. impostorSize?: number | {
  76246. width: number;
  76247. height: number;
  76248. depth: number;
  76249. };
  76250. /**
  76251. * Friction definitions
  76252. */
  76253. friction?: number;
  76254. /**
  76255. * Restitution
  76256. */
  76257. restitution?: number;
  76258. };
  76259. /**
  76260. * the xr input to use with this pointer selection
  76261. */
  76262. xrInput: WebXRInput;
  76263. }
  76264. /**
  76265. * Add physics impostor to your webxr controllers,
  76266. * including naive calculation of their linear and angular velocity
  76267. */
  76268. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76269. private readonly _options;
  76270. private _attachController;
  76271. private _controllers;
  76272. private _debugMode;
  76273. private _delta;
  76274. private _headsetImpostor?;
  76275. private _headsetMesh?;
  76276. private _lastTimestamp;
  76277. private _tmpQuaternion;
  76278. private _tmpVector;
  76279. /**
  76280. * The module's name
  76281. */
  76282. static readonly Name: string;
  76283. /**
  76284. * The (Babylon) version of this module.
  76285. * This is an integer representing the implementation version.
  76286. * This number does not correspond to the webxr specs version
  76287. */
  76288. static readonly Version: number;
  76289. /**
  76290. * Construct a new Controller Physics Feature
  76291. * @param _xrSessionManager the corresponding xr session manager
  76292. * @param _options options to create this feature with
  76293. */
  76294. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76295. /**
  76296. * @hidden
  76297. * enable debugging - will show console outputs and the impostor mesh
  76298. */
  76299. _enablePhysicsDebug(): void;
  76300. /**
  76301. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76302. * @param xrController the controller to add
  76303. */
  76304. addController(xrController: WebXRInputSource): void;
  76305. /**
  76306. * attach this feature
  76307. * Will usually be called by the features manager
  76308. *
  76309. * @returns true if successful.
  76310. */
  76311. attach(): boolean;
  76312. /**
  76313. * detach this feature.
  76314. * Will usually be called by the features manager
  76315. *
  76316. * @returns true if successful.
  76317. */
  76318. detach(): boolean;
  76319. /**
  76320. * Get the headset impostor, if enabled
  76321. * @returns the impostor
  76322. */
  76323. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76324. /**
  76325. * Get the physics impostor of a specific controller.
  76326. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76327. * @param controller the controller or the controller id of which to get the impostor
  76328. * @returns the impostor or null
  76329. */
  76330. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76331. /**
  76332. * Update the physics properties provided in the constructor
  76333. * @param newProperties the new properties object
  76334. */
  76335. setPhysicsProperties(newProperties: {
  76336. impostorType?: number;
  76337. impostorSize?: number | {
  76338. width: number;
  76339. height: number;
  76340. depth: number;
  76341. };
  76342. friction?: number;
  76343. restitution?: number;
  76344. }): void;
  76345. protected _onXRFrame(_xrFrame: any): void;
  76346. private _detachController;
  76347. }
  76348. }
  76349. declare module BABYLON {
  76350. /**
  76351. * A babylon interface for a "WebXR" feature point.
  76352. * Represents the position and confidence value of a given feature point.
  76353. */
  76354. export interface IWebXRFeaturePoint {
  76355. /**
  76356. * Represents the position of the feature point in world space.
  76357. */
  76358. position: Vector3;
  76359. /**
  76360. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76361. */
  76362. confidenceValue: number;
  76363. }
  76364. /**
  76365. * The feature point system is used to detect feature points from real world geometry.
  76366. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76367. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76368. */
  76369. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76370. private _enabled;
  76371. private _featurePointCloud;
  76372. /**
  76373. * The module's name
  76374. */
  76375. static readonly Name: string;
  76376. /**
  76377. * The (Babylon) version of this module.
  76378. * This is an integer representing the implementation version.
  76379. * This number does not correspond to the WebXR specs version
  76380. */
  76381. static readonly Version: number;
  76382. /**
  76383. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76384. * Will notify the observers about which feature points have been added.
  76385. */
  76386. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76387. /**
  76388. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76389. * Will notify the observers about which feature points have been updated.
  76390. */
  76391. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76392. /**
  76393. * The current feature point cloud maintained across frames.
  76394. */
  76395. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76396. /**
  76397. * construct the feature point system
  76398. * @param _xrSessionManager an instance of xr Session manager
  76399. */
  76400. constructor(_xrSessionManager: WebXRSessionManager);
  76401. /**
  76402. * Detach this feature.
  76403. * Will usually be called by the features manager
  76404. *
  76405. * @returns true if successful.
  76406. */
  76407. detach(): boolean;
  76408. /**
  76409. * Dispose this feature and all of the resources attached
  76410. */
  76411. dispose(): void;
  76412. /**
  76413. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76414. */
  76415. protected _onXRFrame(frame: XRFrame): void;
  76416. /**
  76417. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76418. */
  76419. private _init;
  76420. }
  76421. }
  76422. declare module BABYLON {
  76423. /**
  76424. * Configuration interface for the hand tracking feature
  76425. */
  76426. export interface IWebXRHandTrackingOptions {
  76427. /**
  76428. * The xrInput that will be used as source for new hands
  76429. */
  76430. xrInput: WebXRInput;
  76431. /**
  76432. * Configuration object for the joint meshes
  76433. */
  76434. jointMeshes?: {
  76435. /**
  76436. * Should the meshes created be invisible (defaults to false)
  76437. */
  76438. invisible?: boolean;
  76439. /**
  76440. * A source mesh to be used to create instances. Defaults to a sphere.
  76441. * This mesh will be the source for all other (25) meshes.
  76442. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76443. */
  76444. sourceMesh?: Mesh;
  76445. /**
  76446. * This function will be called after a mesh was created for a specific joint.
  76447. * Using this function you can either manipulate the instance or return a new mesh.
  76448. * When returning a new mesh the instance created before will be disposed
  76449. */
  76450. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76451. /**
  76452. * Should the source mesh stay visible. Defaults to false
  76453. */
  76454. keepOriginalVisible?: boolean;
  76455. /**
  76456. * Scale factor for all instances (defaults to 2)
  76457. */
  76458. scaleFactor?: number;
  76459. /**
  76460. * Should each instance have its own physics impostor
  76461. */
  76462. enablePhysics?: boolean;
  76463. /**
  76464. * If enabled, override default physics properties
  76465. */
  76466. physicsProps?: {
  76467. friction?: number;
  76468. restitution?: number;
  76469. impostorType?: number;
  76470. };
  76471. /**
  76472. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76473. */
  76474. handMesh?: AbstractMesh;
  76475. };
  76476. }
  76477. /**
  76478. * Parts of the hands divided to writs and finger names
  76479. */
  76480. export const enum HandPart {
  76481. /**
  76482. * HandPart - Wrist
  76483. */
  76484. WRIST = "wrist",
  76485. /**
  76486. * HandPart - The THumb
  76487. */
  76488. THUMB = "thumb",
  76489. /**
  76490. * HandPart - Index finger
  76491. */
  76492. INDEX = "index",
  76493. /**
  76494. * HandPart - Middle finger
  76495. */
  76496. MIDDLE = "middle",
  76497. /**
  76498. * HandPart - Ring finger
  76499. */
  76500. RING = "ring",
  76501. /**
  76502. * HandPart - Little finger
  76503. */
  76504. LITTLE = "little"
  76505. }
  76506. /**
  76507. * Representing a single hand (with its corresponding native XRHand object)
  76508. */
  76509. export class WebXRHand implements IDisposable {
  76510. /** the controller to which the hand correlates */
  76511. readonly xrController: WebXRInputSource;
  76512. /** the meshes to be used to track the hand joints */
  76513. readonly trackedMeshes: AbstractMesh[];
  76514. /**
  76515. * Hand-parts definition (key is HandPart)
  76516. */
  76517. handPartsDefinition: {
  76518. [key: string]: number[];
  76519. };
  76520. /**
  76521. * Populate the HandPartsDefinition object.
  76522. * This is called as a side effect since certain browsers don't have XRHand defined.
  76523. */
  76524. private generateHandPartsDefinition;
  76525. /**
  76526. * Construct a new hand object
  76527. * @param xrController the controller to which the hand correlates
  76528. * @param trackedMeshes the meshes to be used to track the hand joints
  76529. */
  76530. constructor(
  76531. /** the controller to which the hand correlates */
  76532. xrController: WebXRInputSource,
  76533. /** the meshes to be used to track the hand joints */
  76534. trackedMeshes: AbstractMesh[]);
  76535. /**
  76536. * Update this hand from the latest xr frame
  76537. * @param xrFrame xrFrame to update from
  76538. * @param referenceSpace The current viewer reference space
  76539. * @param scaleFactor optional scale factor for the meshes
  76540. */
  76541. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76542. /**
  76543. * Get meshes of part of the hand
  76544. * @param part the part of hand to get
  76545. * @returns An array of meshes that correlate to the hand part requested
  76546. */
  76547. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76548. /**
  76549. * Dispose this Hand object
  76550. */
  76551. dispose(): void;
  76552. }
  76553. /**
  76554. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76555. */
  76556. export class WebXRHandTracking extends WebXRAbstractFeature {
  76557. /**
  76558. * options to use when constructing this feature
  76559. */
  76560. readonly options: IWebXRHandTrackingOptions;
  76561. private static _idCounter;
  76562. /**
  76563. * The module's name
  76564. */
  76565. static readonly Name: string;
  76566. /**
  76567. * The (Babylon) version of this module.
  76568. * This is an integer representing the implementation version.
  76569. * This number does not correspond to the WebXR specs version
  76570. */
  76571. static readonly Version: number;
  76572. /**
  76573. * This observable will notify registered observers when a new hand object was added and initialized
  76574. */
  76575. onHandAddedObservable: Observable<WebXRHand>;
  76576. /**
  76577. * This observable will notify its observers right before the hand object is disposed
  76578. */
  76579. onHandRemovedObservable: Observable<WebXRHand>;
  76580. private _hands;
  76581. /**
  76582. * Creates a new instance of the hit test feature
  76583. * @param _xrSessionManager an instance of WebXRSessionManager
  76584. * @param options options to use when constructing this feature
  76585. */
  76586. constructor(_xrSessionManager: WebXRSessionManager,
  76587. /**
  76588. * options to use when constructing this feature
  76589. */
  76590. options: IWebXRHandTrackingOptions);
  76591. /**
  76592. * Check if the needed objects are defined.
  76593. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76594. */
  76595. isCompatible(): boolean;
  76596. /**
  76597. * attach this feature
  76598. * Will usually be called by the features manager
  76599. *
  76600. * @returns true if successful.
  76601. */
  76602. attach(): boolean;
  76603. /**
  76604. * detach this feature.
  76605. * Will usually be called by the features manager
  76606. *
  76607. * @returns true if successful.
  76608. */
  76609. detach(): boolean;
  76610. /**
  76611. * Dispose this feature and all of the resources attached
  76612. */
  76613. dispose(): void;
  76614. /**
  76615. * Get the hand object according to the controller id
  76616. * @param controllerId the controller id to which we want to get the hand
  76617. * @returns null if not found or the WebXRHand object if found
  76618. */
  76619. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76620. /**
  76621. * Get a hand object according to the requested handedness
  76622. * @param handedness the handedness to request
  76623. * @returns null if not found or the WebXRHand object if found
  76624. */
  76625. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76626. protected _onXRFrame(_xrFrame: XRFrame): void;
  76627. private _attachHand;
  76628. private _detachHand;
  76629. }
  76630. }
  76631. declare module BABYLON {
  76632. /**
  76633. * The motion controller class for all microsoft mixed reality controllers
  76634. */
  76635. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76636. protected readonly _mapping: {
  76637. defaultButton: {
  76638. valueNodeName: string;
  76639. unpressedNodeName: string;
  76640. pressedNodeName: string;
  76641. };
  76642. defaultAxis: {
  76643. valueNodeName: string;
  76644. minNodeName: string;
  76645. maxNodeName: string;
  76646. };
  76647. buttons: {
  76648. "xr-standard-trigger": {
  76649. rootNodeName: string;
  76650. componentProperty: string;
  76651. states: string[];
  76652. };
  76653. "xr-standard-squeeze": {
  76654. rootNodeName: string;
  76655. componentProperty: string;
  76656. states: string[];
  76657. };
  76658. "xr-standard-touchpad": {
  76659. rootNodeName: string;
  76660. labelAnchorNodeName: string;
  76661. touchPointNodeName: string;
  76662. };
  76663. "xr-standard-thumbstick": {
  76664. rootNodeName: string;
  76665. componentProperty: string;
  76666. states: string[];
  76667. };
  76668. };
  76669. axes: {
  76670. "xr-standard-touchpad": {
  76671. "x-axis": {
  76672. rootNodeName: string;
  76673. };
  76674. "y-axis": {
  76675. rootNodeName: string;
  76676. };
  76677. };
  76678. "xr-standard-thumbstick": {
  76679. "x-axis": {
  76680. rootNodeName: string;
  76681. };
  76682. "y-axis": {
  76683. rootNodeName: string;
  76684. };
  76685. };
  76686. };
  76687. };
  76688. /**
  76689. * The base url used to load the left and right controller models
  76690. */
  76691. static MODEL_BASE_URL: string;
  76692. /**
  76693. * The name of the left controller model file
  76694. */
  76695. static MODEL_LEFT_FILENAME: string;
  76696. /**
  76697. * The name of the right controller model file
  76698. */
  76699. static MODEL_RIGHT_FILENAME: string;
  76700. profileId: string;
  76701. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76702. protected _getFilenameAndPath(): {
  76703. filename: string;
  76704. path: string;
  76705. };
  76706. protected _getModelLoadingConstraints(): boolean;
  76707. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76708. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76709. protected _updateModel(): void;
  76710. }
  76711. }
  76712. declare module BABYLON {
  76713. /**
  76714. * The motion controller class for oculus touch (quest, rift).
  76715. * This class supports legacy mapping as well the standard xr mapping
  76716. */
  76717. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76718. private _forceLegacyControllers;
  76719. private _modelRootNode;
  76720. /**
  76721. * The base url used to load the left and right controller models
  76722. */
  76723. static MODEL_BASE_URL: string;
  76724. /**
  76725. * The name of the left controller model file
  76726. */
  76727. static MODEL_LEFT_FILENAME: string;
  76728. /**
  76729. * The name of the right controller model file
  76730. */
  76731. static MODEL_RIGHT_FILENAME: string;
  76732. /**
  76733. * Base Url for the Quest controller model.
  76734. */
  76735. static QUEST_MODEL_BASE_URL: string;
  76736. profileId: string;
  76737. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76738. protected _getFilenameAndPath(): {
  76739. filename: string;
  76740. path: string;
  76741. };
  76742. protected _getModelLoadingConstraints(): boolean;
  76743. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76744. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76745. protected _updateModel(): void;
  76746. /**
  76747. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76748. * between the touch and touch 2.
  76749. */
  76750. private _isQuest;
  76751. }
  76752. }
  76753. declare module BABYLON {
  76754. /**
  76755. * The motion controller class for the standard HTC-Vive controllers
  76756. */
  76757. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76758. private _modelRootNode;
  76759. /**
  76760. * The base url used to load the left and right controller models
  76761. */
  76762. static MODEL_BASE_URL: string;
  76763. /**
  76764. * File name for the controller model.
  76765. */
  76766. static MODEL_FILENAME: string;
  76767. profileId: string;
  76768. /**
  76769. * Create a new Vive motion controller object
  76770. * @param scene the scene to use to create this controller
  76771. * @param gamepadObject the corresponding gamepad object
  76772. * @param handedness the handedness of the controller
  76773. */
  76774. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76775. protected _getFilenameAndPath(): {
  76776. filename: string;
  76777. path: string;
  76778. };
  76779. protected _getModelLoadingConstraints(): boolean;
  76780. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76781. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76782. protected _updateModel(): void;
  76783. }
  76784. }
  76785. declare module BABYLON {
  76786. /**
  76787. * A cursor which tracks a point on a path
  76788. */
  76789. export class PathCursor {
  76790. private path;
  76791. /**
  76792. * Stores path cursor callbacks for when an onchange event is triggered
  76793. */
  76794. private _onchange;
  76795. /**
  76796. * The value of the path cursor
  76797. */
  76798. value: number;
  76799. /**
  76800. * The animation array of the path cursor
  76801. */
  76802. animations: Animation[];
  76803. /**
  76804. * Initializes the path cursor
  76805. * @param path The path to track
  76806. */
  76807. constructor(path: Path2);
  76808. /**
  76809. * Gets the cursor point on the path
  76810. * @returns A point on the path cursor at the cursor location
  76811. */
  76812. getPoint(): Vector3;
  76813. /**
  76814. * Moves the cursor ahead by the step amount
  76815. * @param step The amount to move the cursor forward
  76816. * @returns This path cursor
  76817. */
  76818. moveAhead(step?: number): PathCursor;
  76819. /**
  76820. * Moves the cursor behind by the step amount
  76821. * @param step The amount to move the cursor back
  76822. * @returns This path cursor
  76823. */
  76824. moveBack(step?: number): PathCursor;
  76825. /**
  76826. * Moves the cursor by the step amount
  76827. * If the step amount is greater than one, an exception is thrown
  76828. * @param step The amount to move the cursor
  76829. * @returns This path cursor
  76830. */
  76831. move(step: number): PathCursor;
  76832. /**
  76833. * Ensures that the value is limited between zero and one
  76834. * @returns This path cursor
  76835. */
  76836. private ensureLimits;
  76837. /**
  76838. * Runs onchange callbacks on change (used by the animation engine)
  76839. * @returns This path cursor
  76840. */
  76841. private raiseOnChange;
  76842. /**
  76843. * Executes a function on change
  76844. * @param f A path cursor onchange callback
  76845. * @returns This path cursor
  76846. */
  76847. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76848. }
  76849. }
  76850. declare module BABYLON {
  76851. /** @hidden */
  76852. export var blurPixelShader: {
  76853. name: string;
  76854. shader: string;
  76855. };
  76856. }
  76857. declare module BABYLON {
  76858. /** @hidden */
  76859. export var pointCloudVertexDeclaration: {
  76860. name: string;
  76861. shader: string;
  76862. };
  76863. }
  76864. // Mixins
  76865. interface Window {
  76866. mozIndexedDB: IDBFactory;
  76867. webkitIndexedDB: IDBFactory;
  76868. msIndexedDB: IDBFactory;
  76869. webkitURL: typeof URL;
  76870. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  76871. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  76872. WebGLRenderingContext: WebGLRenderingContext;
  76873. MSGesture: MSGesture;
  76874. CANNON: any;
  76875. AudioContext: AudioContext;
  76876. webkitAudioContext: AudioContext;
  76877. PointerEvent: any;
  76878. Math: Math;
  76879. Uint8Array: Uint8ArrayConstructor;
  76880. Float32Array: Float32ArrayConstructor;
  76881. mozURL: typeof URL;
  76882. msURL: typeof URL;
  76883. VRFrameData: any; // WebVR, from specs 1.1
  76884. DracoDecoderModule: any;
  76885. setImmediate(handler: (...args: any[]) => void): number;
  76886. }
  76887. interface HTMLCanvasElement {
  76888. requestPointerLock(): void;
  76889. msRequestPointerLock?(): void;
  76890. mozRequestPointerLock?(): void;
  76891. webkitRequestPointerLock?(): void;
  76892. /** Track wether a record is in progress */
  76893. isRecording: boolean;
  76894. /** Capture Stream method defined by some browsers */
  76895. captureStream(fps?: number): MediaStream;
  76896. }
  76897. interface CanvasRenderingContext2D {
  76898. msImageSmoothingEnabled: boolean;
  76899. }
  76900. interface MouseEvent {
  76901. mozMovementX: number;
  76902. mozMovementY: number;
  76903. webkitMovementX: number;
  76904. webkitMovementY: number;
  76905. msMovementX: number;
  76906. msMovementY: number;
  76907. }
  76908. interface Navigator {
  76909. mozGetVRDevices: (any: any) => any;
  76910. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76911. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76912. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76913. webkitGetGamepads(): Gamepad[];
  76914. msGetGamepads(): Gamepad[];
  76915. webkitGamepads(): Gamepad[];
  76916. }
  76917. interface HTMLVideoElement {
  76918. mozSrcObject: any;
  76919. }
  76920. interface Math {
  76921. fround(x: number): number;
  76922. imul(a: number, b: number): number;
  76923. }
  76924. interface WebGLRenderingContext {
  76925. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76926. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76927. vertexAttribDivisor(index: number, divisor: number): void;
  76928. createVertexArray(): any;
  76929. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76930. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76931. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76932. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76933. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76934. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76935. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76936. // Queries
  76937. createQuery(): WebGLQuery;
  76938. deleteQuery(query: WebGLQuery): void;
  76939. beginQuery(target: number, query: WebGLQuery): void;
  76940. endQuery(target: number): void;
  76941. getQueryParameter(query: WebGLQuery, pname: number): any;
  76942. getQuery(target: number, pname: number): any;
  76943. MAX_SAMPLES: number;
  76944. RGBA8: number;
  76945. READ_FRAMEBUFFER: number;
  76946. DRAW_FRAMEBUFFER: number;
  76947. UNIFORM_BUFFER: number;
  76948. HALF_FLOAT_OES: number;
  76949. RGBA16F: number;
  76950. RGBA32F: number;
  76951. R32F: number;
  76952. RG32F: number;
  76953. RGB32F: number;
  76954. R16F: number;
  76955. RG16F: number;
  76956. RGB16F: number;
  76957. RED: number;
  76958. RG: number;
  76959. R8: number;
  76960. RG8: number;
  76961. UNSIGNED_INT_24_8: number;
  76962. DEPTH24_STENCIL8: number;
  76963. MIN: number;
  76964. MAX: number;
  76965. /* Multiple Render Targets */
  76966. drawBuffers(buffers: number[]): void;
  76967. readBuffer(src: number): void;
  76968. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76969. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76970. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76971. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76972. // Occlusion Query
  76973. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76974. ANY_SAMPLES_PASSED: number;
  76975. QUERY_RESULT_AVAILABLE: number;
  76976. QUERY_RESULT: number;
  76977. }
  76978. interface WebGLProgram {
  76979. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76980. }
  76981. interface EXT_disjoint_timer_query {
  76982. QUERY_COUNTER_BITS_EXT: number;
  76983. TIME_ELAPSED_EXT: number;
  76984. TIMESTAMP_EXT: number;
  76985. GPU_DISJOINT_EXT: number;
  76986. QUERY_RESULT_EXT: number;
  76987. QUERY_RESULT_AVAILABLE_EXT: number;
  76988. queryCounterEXT(query: WebGLQuery, target: number): void;
  76989. createQueryEXT(): WebGLQuery;
  76990. beginQueryEXT(target: number, query: WebGLQuery): void;
  76991. endQueryEXT(target: number): void;
  76992. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76993. deleteQueryEXT(query: WebGLQuery): void;
  76994. }
  76995. interface WebGLUniformLocation {
  76996. _currentState: any;
  76997. }
  76998. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76999. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  77000. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  77001. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77002. interface WebGLRenderingContext {
  77003. readonly RASTERIZER_DISCARD: number;
  77004. readonly DEPTH_COMPONENT24: number;
  77005. readonly TEXTURE_3D: number;
  77006. readonly TEXTURE_2D_ARRAY: number;
  77007. readonly TEXTURE_COMPARE_FUNC: number;
  77008. readonly TEXTURE_COMPARE_MODE: number;
  77009. readonly COMPARE_REF_TO_TEXTURE: number;
  77010. readonly TEXTURE_WRAP_R: number;
  77011. readonly HALF_FLOAT: number;
  77012. readonly RGB8: number;
  77013. readonly RED_INTEGER: number;
  77014. readonly RG_INTEGER: number;
  77015. readonly RGB_INTEGER: number;
  77016. readonly RGBA_INTEGER: number;
  77017. readonly R8_SNORM: number;
  77018. readonly RG8_SNORM: number;
  77019. readonly RGB8_SNORM: number;
  77020. readonly RGBA8_SNORM: number;
  77021. readonly R8I: number;
  77022. readonly RG8I: number;
  77023. readonly RGB8I: number;
  77024. readonly RGBA8I: number;
  77025. readonly R8UI: number;
  77026. readonly RG8UI: number;
  77027. readonly RGB8UI: number;
  77028. readonly RGBA8UI: number;
  77029. readonly R16I: number;
  77030. readonly RG16I: number;
  77031. readonly RGB16I: number;
  77032. readonly RGBA16I: number;
  77033. readonly R16UI: number;
  77034. readonly RG16UI: number;
  77035. readonly RGB16UI: number;
  77036. readonly RGBA16UI: number;
  77037. readonly R32I: number;
  77038. readonly RG32I: number;
  77039. readonly RGB32I: number;
  77040. readonly RGBA32I: number;
  77041. readonly R32UI: number;
  77042. readonly RG32UI: number;
  77043. readonly RGB32UI: number;
  77044. readonly RGBA32UI: number;
  77045. readonly RGB10_A2UI: number;
  77046. readonly R11F_G11F_B10F: number;
  77047. readonly RGB9_E5: number;
  77048. readonly RGB10_A2: number;
  77049. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  77050. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  77051. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  77052. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77053. readonly DEPTH_COMPONENT32F: number;
  77054. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  77055. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  77056. 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;
  77057. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  77058. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  77059. readonly TRANSFORM_FEEDBACK: number;
  77060. readonly INTERLEAVED_ATTRIBS: number;
  77061. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  77062. createTransformFeedback(): WebGLTransformFeedback;
  77063. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  77064. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  77065. beginTransformFeedback(primitiveMode: number): void;
  77066. endTransformFeedback(): void;
  77067. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  77068. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77069. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77070. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77071. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  77072. }
  77073. interface ImageBitmap {
  77074. readonly width: number;
  77075. readonly height: number;
  77076. close(): void;
  77077. }
  77078. interface WebGLQuery extends WebGLObject {
  77079. }
  77080. declare var WebGLQuery: {
  77081. prototype: WebGLQuery;
  77082. new(): WebGLQuery;
  77083. };
  77084. interface WebGLSampler extends WebGLObject {
  77085. }
  77086. declare var WebGLSampler: {
  77087. prototype: WebGLSampler;
  77088. new(): WebGLSampler;
  77089. };
  77090. interface WebGLSync extends WebGLObject {
  77091. }
  77092. declare var WebGLSync: {
  77093. prototype: WebGLSync;
  77094. new(): WebGLSync;
  77095. };
  77096. interface WebGLTransformFeedback extends WebGLObject {
  77097. }
  77098. declare var WebGLTransformFeedback: {
  77099. prototype: WebGLTransformFeedback;
  77100. new(): WebGLTransformFeedback;
  77101. };
  77102. interface WebGLVertexArrayObject extends WebGLObject {
  77103. }
  77104. declare var WebGLVertexArrayObject: {
  77105. prototype: WebGLVertexArrayObject;
  77106. new(): WebGLVertexArrayObject;
  77107. };
  77108. // Type definitions for WebVR API
  77109. // Project: https://w3c.github.io/webvr/
  77110. // Definitions by: six a <https://github.com/lostfictions>
  77111. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77112. interface VRDisplay extends EventTarget {
  77113. /**
  77114. * Dictionary of capabilities describing the VRDisplay.
  77115. */
  77116. readonly capabilities: VRDisplayCapabilities;
  77117. /**
  77118. * z-depth defining the far plane of the eye view frustum
  77119. * enables mapping of values in the render target depth
  77120. * attachment to scene coordinates. Initially set to 10000.0.
  77121. */
  77122. depthFar: number;
  77123. /**
  77124. * z-depth defining the near plane of the eye view frustum
  77125. * enables mapping of values in the render target depth
  77126. * attachment to scene coordinates. Initially set to 0.01.
  77127. */
  77128. depthNear: number;
  77129. /**
  77130. * An identifier for this distinct VRDisplay. Used as an
  77131. * association point in the Gamepad API.
  77132. */
  77133. readonly displayId: number;
  77134. /**
  77135. * A display name, a user-readable name identifying it.
  77136. */
  77137. readonly displayName: string;
  77138. readonly isConnected: boolean;
  77139. readonly isPresenting: boolean;
  77140. /**
  77141. * If this VRDisplay supports room-scale experiences, the optional
  77142. * stage attribute contains details on the room-scale parameters.
  77143. */
  77144. readonly stageParameters: VRStageParameters | null;
  77145. /**
  77146. * Passing the value returned by `requestAnimationFrame` to
  77147. * `cancelAnimationFrame` will unregister the callback.
  77148. * @param handle Define the hanle of the request to cancel
  77149. */
  77150. cancelAnimationFrame(handle: number): void;
  77151. /**
  77152. * Stops presenting to the VRDisplay.
  77153. * @returns a promise to know when it stopped
  77154. */
  77155. exitPresent(): Promise<void>;
  77156. /**
  77157. * Return the current VREyeParameters for the given eye.
  77158. * @param whichEye Define the eye we want the parameter for
  77159. * @returns the eye parameters
  77160. */
  77161. getEyeParameters(whichEye: string): VREyeParameters;
  77162. /**
  77163. * Populates the passed VRFrameData with the information required to render
  77164. * the current frame.
  77165. * @param frameData Define the data structure to populate
  77166. * @returns true if ok otherwise false
  77167. */
  77168. getFrameData(frameData: VRFrameData): boolean;
  77169. /**
  77170. * Get the layers currently being presented.
  77171. * @returns the list of VR layers
  77172. */
  77173. getLayers(): VRLayer[];
  77174. /**
  77175. * Return a VRPose containing the future predicted pose of the VRDisplay
  77176. * when the current frame will be presented. The value returned will not
  77177. * change until JavaScript has returned control to the browser.
  77178. *
  77179. * The VRPose will contain the position, orientation, velocity,
  77180. * and acceleration of each of these properties.
  77181. * @returns the pose object
  77182. */
  77183. getPose(): VRPose;
  77184. /**
  77185. * Return the current instantaneous pose of the VRDisplay, with no
  77186. * prediction applied.
  77187. * @returns the current instantaneous pose
  77188. */
  77189. getImmediatePose(): VRPose;
  77190. /**
  77191. * The callback passed to `requestAnimationFrame` will be called
  77192. * any time a new frame should be rendered. When the VRDisplay is
  77193. * presenting the callback will be called at the native refresh
  77194. * rate of the HMD. When not presenting this function acts
  77195. * identically to how window.requestAnimationFrame acts. Content should
  77196. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77197. * asynchronously from other displays and at differing refresh rates.
  77198. * @param callback Define the eaction to run next frame
  77199. * @returns the request handle it
  77200. */
  77201. requestAnimationFrame(callback: FrameRequestCallback): number;
  77202. /**
  77203. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77204. * Repeat calls while already presenting will update the VRLayers being displayed.
  77205. * @param layers Define the list of layer to present
  77206. * @returns a promise to know when the request has been fulfilled
  77207. */
  77208. requestPresent(layers: VRLayer[]): Promise<void>;
  77209. /**
  77210. * Reset the pose for this display, treating its current position and
  77211. * orientation as the "origin/zero" values. VRPose.position,
  77212. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77213. * updated when calling resetPose(). This should be called in only
  77214. * sitting-space experiences.
  77215. */
  77216. resetPose(): void;
  77217. /**
  77218. * The VRLayer provided to the VRDisplay will be captured and presented
  77219. * in the HMD. Calling this function has the same effect on the source
  77220. * canvas as any other operation that uses its source image, and canvases
  77221. * created without preserveDrawingBuffer set to true will be cleared.
  77222. * @param pose Define the pose to submit
  77223. */
  77224. submitFrame(pose?: VRPose): void;
  77225. }
  77226. declare var VRDisplay: {
  77227. prototype: VRDisplay;
  77228. new(): VRDisplay;
  77229. };
  77230. interface VRLayer {
  77231. leftBounds?: number[] | Float32Array | null;
  77232. rightBounds?: number[] | Float32Array | null;
  77233. source?: HTMLCanvasElement | null;
  77234. }
  77235. interface VRDisplayCapabilities {
  77236. readonly canPresent: boolean;
  77237. readonly hasExternalDisplay: boolean;
  77238. readonly hasOrientation: boolean;
  77239. readonly hasPosition: boolean;
  77240. readonly maxLayers: number;
  77241. }
  77242. interface VREyeParameters {
  77243. /** @deprecated */
  77244. readonly fieldOfView: VRFieldOfView;
  77245. readonly offset: Float32Array;
  77246. readonly renderHeight: number;
  77247. readonly renderWidth: number;
  77248. }
  77249. interface VRFieldOfView {
  77250. readonly downDegrees: number;
  77251. readonly leftDegrees: number;
  77252. readonly rightDegrees: number;
  77253. readonly upDegrees: number;
  77254. }
  77255. interface VRFrameData {
  77256. readonly leftProjectionMatrix: Float32Array;
  77257. readonly leftViewMatrix: Float32Array;
  77258. readonly pose: VRPose;
  77259. readonly rightProjectionMatrix: Float32Array;
  77260. readonly rightViewMatrix: Float32Array;
  77261. readonly timestamp: number;
  77262. }
  77263. interface VRPose {
  77264. readonly angularAcceleration: Float32Array | null;
  77265. readonly angularVelocity: Float32Array | null;
  77266. readonly linearAcceleration: Float32Array | null;
  77267. readonly linearVelocity: Float32Array | null;
  77268. readonly orientation: Float32Array | null;
  77269. readonly position: Float32Array | null;
  77270. readonly timestamp: number;
  77271. }
  77272. interface VRStageParameters {
  77273. sittingToStandingTransform?: Float32Array;
  77274. sizeX?: number;
  77275. sizeY?: number;
  77276. }
  77277. interface Navigator {
  77278. getVRDisplays(): Promise<VRDisplay[]>;
  77279. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77280. }
  77281. interface Window {
  77282. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77283. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77284. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77285. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77286. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77287. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77288. }
  77289. interface Gamepad {
  77290. readonly displayId: number;
  77291. }
  77292. /**
  77293. * Available session modes
  77294. */
  77295. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77296. /**
  77297. * Reference space types
  77298. */
  77299. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77300. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77301. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77302. /**
  77303. * Handedness types
  77304. */
  77305. type XRHandedness = "none" | "left" | "right";
  77306. /**
  77307. * InputSource target ray modes
  77308. */
  77309. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77310. /**
  77311. * Eye types
  77312. */
  77313. type XREye = "none" | "left" | "right";
  77314. /**
  77315. * Type of XR events available
  77316. */
  77317. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77318. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  77319. type XRPlaneSet = Set<XRPlane>;
  77320. type XRAnchorSet = Set<XRAnchor>;
  77321. type XREventHandler = (callback: any) => void;
  77322. interface XRLayer extends EventTarget {}
  77323. interface XRSessionInit {
  77324. optionalFeatures?: string[];
  77325. requiredFeatures?: string[];
  77326. }
  77327. interface XRSessionEvent extends Event {
  77328. readonly session: XRSession;
  77329. }
  77330. interface XRSystem {
  77331. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  77332. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  77333. }
  77334. interface XRViewport {
  77335. readonly x: number;
  77336. readonly y: number;
  77337. readonly width: number;
  77338. readonly height: number;
  77339. }
  77340. interface XRWebGLLayerInit {
  77341. antialias?: boolean;
  77342. depth?: boolean;
  77343. stencil?: boolean;
  77344. alpha?: boolean;
  77345. multiview?: boolean;
  77346. framebufferScaleFactor?: number;
  77347. }
  77348. declare class XRWebGLLayer {
  77349. static getNativeFramebufferScaleFactor(session: XRSession): number;
  77350. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  77351. readonly antialias: boolean;
  77352. readonly framebuffer: WebGLFramebuffer;
  77353. readonly framebufferWidth: number;
  77354. readonly framebufferHeight: number;
  77355. readonly ignoreDepthValues: boolean;
  77356. getViewport: (view: XRView) => XRViewport;
  77357. }
  77358. // tslint:disable-next-line no-empty-interface
  77359. interface XRSpace extends EventTarget {}
  77360. interface XRRenderState {
  77361. readonly baseLayer?: XRWebGLLayer;
  77362. readonly depthFar: number;
  77363. readonly depthNear: number;
  77364. readonly inlineVerticalFieldOfView?: number;
  77365. }
  77366. interface XRRenderStateInit extends XRRenderState {
  77367. baseLayer: XRWebGLLayer;
  77368. depthFar: number;
  77369. depthNear: number;
  77370. inlineVerticalFieldOfView?: number;
  77371. layers?: XRLayer[];
  77372. }
  77373. interface XRReferenceSpace extends XRSpace {
  77374. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77375. onreset: XREventHandler;
  77376. }
  77377. interface XRBoundedReferenceSpace extends XRSpace {
  77378. readonly boundsGeometry: DOMPointReadOnly[];
  77379. }
  77380. interface XRInputSource {
  77381. readonly handedness: XRHandedness;
  77382. readonly targetRayMode: XRTargetRayMode;
  77383. readonly targetRaySpace: XRSpace;
  77384. readonly gripSpace?: XRSpace;
  77385. readonly gamepad?: Gamepad;
  77386. readonly profiles: Array<string>;
  77387. readonly hand?: XRHand;
  77388. }
  77389. interface XRPose {
  77390. readonly transform: XRRigidTransform;
  77391. readonly emulatedPosition: boolean;
  77392. }
  77393. interface XRFrame {
  77394. readonly session: XRSession;
  77395. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77396. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77397. // AR
  77398. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77399. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77400. // Anchors
  77401. trackedAnchors?: XRAnchorSet;
  77402. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77403. // Planes
  77404. worldInformation?: {
  77405. detectedPlanes?: XRPlaneSet;
  77406. };
  77407. // Hand tracking
  77408. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77409. }
  77410. interface XRInputSourceEvent extends Event {
  77411. readonly frame: XRFrame;
  77412. readonly inputSource: XRInputSource;
  77413. }
  77414. type XRInputSourceArray = XRInputSource[];
  77415. interface XRSession {
  77416. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  77417. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  77418. /**
  77419. * Returns a list of this session's XRInputSources, each representing an input device
  77420. * used to control the camera and/or scene.
  77421. */
  77422. readonly inputSources: Array<XRInputSource>;
  77423. /**
  77424. * object which contains options affecting how the imagery is rendered.
  77425. * This includes things such as the near and far clipping planes
  77426. */
  77427. readonly renderState: XRRenderState;
  77428. readonly visibilityState: XRVisibilityState;
  77429. /**
  77430. * Removes a callback from the animation frame painting callback from
  77431. * XRSession's set of animation frame rendering callbacks, given the
  77432. * identifying handle returned by a previous call to requestAnimationFrame().
  77433. */
  77434. cancelAnimationFrame: (handle: number) => void;
  77435. /**
  77436. * Ends the WebXR session. Returns a promise which resolves when the
  77437. * session has been shut down.
  77438. */
  77439. end(): Promise<void>;
  77440. /**
  77441. * Schedules the specified method to be called the next time the user agent
  77442. * is working on rendering an animation frame for the WebXR device. Returns an
  77443. * integer value which can be used to identify the request for the purposes of
  77444. * canceling the callback using cancelAnimationFrame(). This method is comparable
  77445. * to the Window.requestAnimationFrame() method.
  77446. */
  77447. requestAnimationFrame: XRFrameRequestCallback;
  77448. /**
  77449. * Requests that a new XRReferenceSpace of the specified type be created.
  77450. * Returns a promise which resolves with the XRReferenceSpace or
  77451. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  77452. * the requested space type isn't supported by the device.
  77453. */
  77454. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  77455. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77456. onend: XREventHandler;
  77457. oninputsourceschange: XREventHandler;
  77458. onselect: XREventHandler;
  77459. onselectstart: XREventHandler;
  77460. onselectend: XREventHandler;
  77461. onsqueeze: XREventHandler;
  77462. onsqueezestart: XREventHandler;
  77463. onsqueezeend: XREventHandler;
  77464. onvisibilitychange: XREventHandler;
  77465. // hit test
  77466. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77467. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77468. // legacy AR hit test
  77469. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77470. // legacy plane detection
  77471. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  77472. }
  77473. interface XRViewerPose extends XRPose {
  77474. readonly views: Array<XRView>;
  77475. }
  77476. declare class XRRigidTransform {
  77477. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  77478. position: DOMPointReadOnly;
  77479. orientation: DOMPointReadOnly;
  77480. matrix: Float32Array;
  77481. inverse: XRRigidTransform;
  77482. }
  77483. interface XRView {
  77484. readonly eye: XREye;
  77485. readonly projectionMatrix: Float32Array;
  77486. readonly transform: XRRigidTransform;
  77487. readonly recommendedViewportScale?: number;
  77488. requestViewportScale(scale: number): void;
  77489. }
  77490. interface XRInputSourceChangeEvent extends Event {
  77491. session: XRSession;
  77492. removed: Array<XRInputSource>;
  77493. added: Array<XRInputSource>;
  77494. }
  77495. // Experimental/Draft features
  77496. declare class XRRay {
  77497. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77498. origin: DOMPointReadOnly;
  77499. direction: DOMPointReadOnly;
  77500. matrix: Float32Array;
  77501. }
  77502. declare enum XRHitTestTrackableType {
  77503. "point",
  77504. "plane",
  77505. "mesh",
  77506. }
  77507. interface XRHitResult {
  77508. hitMatrix: Float32Array;
  77509. }
  77510. interface XRTransientInputHitTestResult {
  77511. readonly inputSource: XRInputSource;
  77512. readonly results: Array<XRHitTestResult>;
  77513. }
  77514. interface XRHitTestResult {
  77515. getPose(baseSpace: XRSpace): XRPose | undefined;
  77516. // When anchor system is enabled
  77517. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77518. }
  77519. interface XRHitTestSource {
  77520. cancel(): void;
  77521. }
  77522. interface XRTransientInputHitTestSource {
  77523. cancel(): void;
  77524. }
  77525. interface XRHitTestOptionsInit {
  77526. space: XRSpace;
  77527. entityTypes?: Array<XRHitTestTrackableType>;
  77528. offsetRay?: XRRay;
  77529. }
  77530. interface XRTransientInputHitTestOptionsInit {
  77531. profile: string;
  77532. entityTypes?: Array<XRHitTestTrackableType>;
  77533. offsetRay?: XRRay;
  77534. }
  77535. interface XRAnchor {
  77536. anchorSpace: XRSpace;
  77537. delete(): void;
  77538. }
  77539. interface XRPlane {
  77540. orientation: "Horizontal" | "Vertical";
  77541. planeSpace: XRSpace;
  77542. polygon: Array<DOMPointReadOnly>;
  77543. lastChangedTime: number;
  77544. }
  77545. interface XRJointSpace extends XRSpace {}
  77546. interface XRJointPose extends XRPose {
  77547. radius: number | undefined;
  77548. }
  77549. interface XRHand extends Iterable<XRJointSpace> {
  77550. readonly length: number;
  77551. [index: number]: XRJointSpace;
  77552. readonly WRIST: number;
  77553. readonly THUMB_METACARPAL: number;
  77554. readonly THUMB_PHALANX_PROXIMAL: number;
  77555. readonly THUMB_PHALANX_DISTAL: number;
  77556. readonly THUMB_PHALANX_TIP: number;
  77557. readonly INDEX_METACARPAL: number;
  77558. readonly INDEX_PHALANX_PROXIMAL: number;
  77559. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77560. readonly INDEX_PHALANX_DISTAL: number;
  77561. readonly INDEX_PHALANX_TIP: number;
  77562. readonly MIDDLE_METACARPAL: number;
  77563. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77564. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77565. readonly MIDDLE_PHALANX_DISTAL: number;
  77566. readonly MIDDLE_PHALANX_TIP: number;
  77567. readonly RING_METACARPAL: number;
  77568. readonly RING_PHALANX_PROXIMAL: number;
  77569. readonly RING_PHALANX_INTERMEDIATE: number;
  77570. readonly RING_PHALANX_DISTAL: number;
  77571. readonly RING_PHALANX_TIP: number;
  77572. readonly LITTLE_METACARPAL: number;
  77573. readonly LITTLE_PHALANX_PROXIMAL: number;
  77574. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77575. readonly LITTLE_PHALANX_DISTAL: number;
  77576. readonly LITTLE_PHALANX_TIP: number;
  77577. }
  77578. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77579. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77580. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77581. interface XRSession {
  77582. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77583. }
  77584. interface XRFrame {
  77585. featurePointCloud? : Array<number>;
  77586. }
  77587. /**
  77588. * @ignore
  77589. */
  77590. declare module BABYLON.GLTF2.Exporter {
  77591. }
  77592. /**
  77593. * @ignore
  77594. */
  77595. declare module BABYLON.GLTF1 {
  77596. }
  77597. declare module BABYLON.GUI {
  77598. /**
  77599. * Class used to specific a value and its associated unit
  77600. */
  77601. export class ValueAndUnit {
  77602. /** defines the unit to store */
  77603. unit: number;
  77604. /** defines a boolean indicating if the value can be negative */
  77605. negativeValueAllowed: boolean;
  77606. private _value;
  77607. private _originalUnit;
  77608. /**
  77609. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77610. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77611. */
  77612. ignoreAdaptiveScaling: boolean;
  77613. /**
  77614. * Creates a new ValueAndUnit
  77615. * @param value defines the value to store
  77616. * @param unit defines the unit to store
  77617. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77618. */
  77619. constructor(value: number,
  77620. /** defines the unit to store */
  77621. unit?: number,
  77622. /** defines a boolean indicating if the value can be negative */
  77623. negativeValueAllowed?: boolean);
  77624. /** Gets a boolean indicating if the value is a percentage */
  77625. get isPercentage(): boolean;
  77626. /** Gets a boolean indicating if the value is store as pixel */
  77627. get isPixel(): boolean;
  77628. /** Gets direct internal value */
  77629. get internalValue(): number;
  77630. /**
  77631. * Gets value as pixel
  77632. * @param host defines the root host
  77633. * @param refValue defines the reference value for percentages
  77634. * @returns the value as pixel
  77635. */
  77636. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77637. /**
  77638. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77639. * @param value defines the value to store
  77640. * @param unit defines the unit to store
  77641. * @returns the current ValueAndUnit
  77642. */
  77643. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77644. /**
  77645. * Gets the value accordingly to its unit
  77646. * @param host defines the root host
  77647. * @returns the value
  77648. */
  77649. getValue(host: AdvancedDynamicTexture): number;
  77650. /**
  77651. * Gets a string representation of the value
  77652. * @param host defines the root host
  77653. * @param decimals defines an optional number of decimals to display
  77654. * @returns a string
  77655. */
  77656. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77657. /**
  77658. * Store a value parsed from a string
  77659. * @param source defines the source string
  77660. * @returns true if the value was successfully parsed
  77661. */
  77662. fromString(source: string | number): boolean;
  77663. private static _Regex;
  77664. private static _UNITMODE_PERCENTAGE;
  77665. private static _UNITMODE_PIXEL;
  77666. /** UNITMODE_PERCENTAGE */
  77667. static get UNITMODE_PERCENTAGE(): number;
  77668. /** UNITMODE_PIXEL */
  77669. static get UNITMODE_PIXEL(): number;
  77670. }
  77671. }
  77672. declare module BABYLON.GUI {
  77673. /**
  77674. * Define a style used by control to automatically setup properties based on a template.
  77675. * Only support font related properties so far
  77676. */
  77677. export class Style implements BABYLON.IDisposable {
  77678. private _fontFamily;
  77679. private _fontStyle;
  77680. private _fontWeight;
  77681. /** @hidden */
  77682. _host: AdvancedDynamicTexture;
  77683. /** @hidden */
  77684. _fontSize: ValueAndUnit;
  77685. /**
  77686. * BABYLON.Observable raised when the style values are changed
  77687. */
  77688. onChangedObservable: BABYLON.Observable<Style>;
  77689. /**
  77690. * Creates a new style object
  77691. * @param host defines the AdvancedDynamicTexture which hosts this style
  77692. */
  77693. constructor(host: AdvancedDynamicTexture);
  77694. /**
  77695. * Gets or sets the font size
  77696. */
  77697. get fontSize(): string | number;
  77698. set fontSize(value: string | number);
  77699. /**
  77700. * Gets or sets the font family
  77701. */
  77702. get fontFamily(): string;
  77703. set fontFamily(value: string);
  77704. /**
  77705. * Gets or sets the font style
  77706. */
  77707. get fontStyle(): string;
  77708. set fontStyle(value: string);
  77709. /** Gets or sets font weight */
  77710. get fontWeight(): string;
  77711. set fontWeight(value: string);
  77712. /** Dispose all associated resources */
  77713. dispose(): void;
  77714. }
  77715. }
  77716. declare module BABYLON.GUI {
  77717. /**
  77718. * Class used to transport BABYLON.Vector2 information for pointer events
  77719. */
  77720. export class Vector2WithInfo extends BABYLON.Vector2 {
  77721. /** defines the current mouse button index */
  77722. buttonIndex: number;
  77723. /**
  77724. * Creates a new Vector2WithInfo
  77725. * @param source defines the vector2 data to transport
  77726. * @param buttonIndex defines the current mouse button index
  77727. */
  77728. constructor(source: BABYLON.Vector2,
  77729. /** defines the current mouse button index */
  77730. buttonIndex?: number);
  77731. }
  77732. /** Class used to provide 2D matrix features */
  77733. export class Matrix2D {
  77734. /** Gets the internal array of 6 floats used to store matrix data */
  77735. m: Float32Array;
  77736. /**
  77737. * Creates a new matrix
  77738. * @param m00 defines value for (0, 0)
  77739. * @param m01 defines value for (0, 1)
  77740. * @param m10 defines value for (1, 0)
  77741. * @param m11 defines value for (1, 1)
  77742. * @param m20 defines value for (2, 0)
  77743. * @param m21 defines value for (2, 1)
  77744. */
  77745. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  77746. /**
  77747. * Fills the matrix from direct values
  77748. * @param m00 defines value for (0, 0)
  77749. * @param m01 defines value for (0, 1)
  77750. * @param m10 defines value for (1, 0)
  77751. * @param m11 defines value for (1, 1)
  77752. * @param m20 defines value for (2, 0)
  77753. * @param m21 defines value for (2, 1)
  77754. * @returns the current modified matrix
  77755. */
  77756. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  77757. /**
  77758. * Gets matrix determinant
  77759. * @returns the determinant
  77760. */
  77761. determinant(): number;
  77762. /**
  77763. * Inverses the matrix and stores it in a target matrix
  77764. * @param result defines the target matrix
  77765. * @returns the current matrix
  77766. */
  77767. invertToRef(result: Matrix2D): Matrix2D;
  77768. /**
  77769. * Multiplies the current matrix with another one
  77770. * @param other defines the second operand
  77771. * @param result defines the target matrix
  77772. * @returns the current matrix
  77773. */
  77774. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  77775. /**
  77776. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  77777. * @param x defines the x coordinate to transform
  77778. * @param y defines the x coordinate to transform
  77779. * @param result defines the target vector2
  77780. * @returns the current matrix
  77781. */
  77782. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  77783. /**
  77784. * Creates an identity matrix
  77785. * @returns a new matrix
  77786. */
  77787. static Identity(): Matrix2D;
  77788. /**
  77789. * Creates a translation matrix and stores it in a target matrix
  77790. * @param x defines the x coordinate of the translation
  77791. * @param y defines the y coordinate of the translation
  77792. * @param result defines the target matrix
  77793. */
  77794. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  77795. /**
  77796. * Creates a scaling matrix and stores it in a target matrix
  77797. * @param x defines the x coordinate of the scaling
  77798. * @param y defines the y coordinate of the scaling
  77799. * @param result defines the target matrix
  77800. */
  77801. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  77802. /**
  77803. * Creates a rotation matrix and stores it in a target matrix
  77804. * @param angle defines the rotation angle
  77805. * @param result defines the target matrix
  77806. */
  77807. static RotationToRef(angle: number, result: Matrix2D): void;
  77808. private static _TempPreTranslationMatrix;
  77809. private static _TempPostTranslationMatrix;
  77810. private static _TempRotationMatrix;
  77811. private static _TempScalingMatrix;
  77812. private static _TempCompose0;
  77813. private static _TempCompose1;
  77814. private static _TempCompose2;
  77815. /**
  77816. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77817. * @param tx defines the x coordinate of the translation
  77818. * @param ty defines the y coordinate of the translation
  77819. * @param angle defines the rotation angle
  77820. * @param scaleX defines the x coordinate of the scaling
  77821. * @param scaleY defines the y coordinate of the scaling
  77822. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  77823. * @param result defines the target matrix
  77824. */
  77825. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  77826. }
  77827. }
  77828. declare module BABYLON.GUI {
  77829. /**
  77830. * Class used to store 2D control sizes
  77831. */
  77832. export class Measure {
  77833. /** defines left coordinate */
  77834. left: number;
  77835. /** defines top coordinate */
  77836. top: number;
  77837. /** defines width dimension */
  77838. width: number;
  77839. /** defines height dimension */
  77840. height: number;
  77841. /**
  77842. * Creates a new measure
  77843. * @param left defines left coordinate
  77844. * @param top defines top coordinate
  77845. * @param width defines width dimension
  77846. * @param height defines height dimension
  77847. */
  77848. constructor(
  77849. /** defines left coordinate */
  77850. left: number,
  77851. /** defines top coordinate */
  77852. top: number,
  77853. /** defines width dimension */
  77854. width: number,
  77855. /** defines height dimension */
  77856. height: number);
  77857. /**
  77858. * Copy from another measure
  77859. * @param other defines the other measure to copy from
  77860. */
  77861. copyFrom(other: Measure): void;
  77862. /**
  77863. * Copy from a group of 4 floats
  77864. * @param left defines left coordinate
  77865. * @param top defines top coordinate
  77866. * @param width defines width dimension
  77867. * @param height defines height dimension
  77868. */
  77869. copyFromFloats(left: number, top: number, width: number, height: number): void;
  77870. /**
  77871. * Computes the axis aligned bounding box measure for two given measures
  77872. * @param a Input measure
  77873. * @param b Input measure
  77874. * @param result the resulting bounding measure
  77875. */
  77876. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  77877. /**
  77878. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77879. * @param transform the matrix to transform the measure before computing the AABB
  77880. * @param addX number to add to left
  77881. * @param addY number to add to top
  77882. * @param addWidth number to add to width
  77883. * @param addHeight number to add to height
  77884. * @param result the resulting AABB
  77885. */
  77886. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  77887. /**
  77888. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77889. * @param transform the matrix to transform the measure before computing the AABB
  77890. * @param result the resulting AABB
  77891. */
  77892. transformToRef(transform: Matrix2D, result: Measure): void;
  77893. /**
  77894. * Check equality between this measure and another one
  77895. * @param other defines the other measures
  77896. * @returns true if both measures are equals
  77897. */
  77898. isEqualsTo(other: Measure): boolean;
  77899. /**
  77900. * Creates an empty measure
  77901. * @returns a new measure
  77902. */
  77903. static Empty(): Measure;
  77904. }
  77905. }
  77906. declare module BABYLON.GUI {
  77907. /**
  77908. * Interface used to define a control that can receive focus
  77909. */
  77910. export interface IFocusableControl {
  77911. /**
  77912. * Function called when the control receives the focus
  77913. */
  77914. onFocus(): void;
  77915. /**
  77916. * Function called when the control loses the focus
  77917. */
  77918. onBlur(): void;
  77919. /**
  77920. * Function called to let the control handle keyboard events
  77921. * @param evt defines the current keyboard event
  77922. */
  77923. processKeyboard(evt: KeyboardEvent): void;
  77924. /**
  77925. * Function called to get the list of controls that should not steal the focus from this control
  77926. * @returns an array of controls
  77927. */
  77928. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77929. }
  77930. /**
  77931. * Class used to create texture to support 2D GUI elements
  77932. * @see https://doc.babylonjs.com/how_to/gui
  77933. */
  77934. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  77935. private _isDirty;
  77936. private _renderObserver;
  77937. private _resizeObserver;
  77938. private _preKeyboardObserver;
  77939. private _pointerMoveObserver;
  77940. private _pointerObserver;
  77941. private _canvasPointerOutObserver;
  77942. private _canvasBlurObserver;
  77943. private _background;
  77944. /** @hidden */
  77945. _rootContainer: Container;
  77946. /** @hidden */
  77947. _lastPickedControl: Control;
  77948. /** @hidden */
  77949. _lastControlOver: {
  77950. [pointerId: number]: Control;
  77951. };
  77952. /** @hidden */
  77953. _lastControlDown: {
  77954. [pointerId: number]: Control;
  77955. };
  77956. /** @hidden */
  77957. _capturingControl: {
  77958. [pointerId: number]: Control;
  77959. };
  77960. /** @hidden */
  77961. _shouldBlockPointer: boolean;
  77962. /** @hidden */
  77963. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  77964. /** @hidden */
  77965. _linkedControls: Control[];
  77966. private _isFullscreen;
  77967. private _fullscreenViewport;
  77968. private _idealWidth;
  77969. private _idealHeight;
  77970. private _useSmallestIdeal;
  77971. private _renderAtIdealSize;
  77972. private _focusedControl;
  77973. private _blockNextFocusCheck;
  77974. private _renderScale;
  77975. private _rootElement;
  77976. private _cursorChanged;
  77977. private _defaultMousePointerId;
  77978. /** @hidden */
  77979. _numLayoutCalls: number;
  77980. /** Gets the number of layout calls made the last time the ADT has been rendered */
  77981. get numLayoutCalls(): number;
  77982. /** @hidden */
  77983. _numRenderCalls: number;
  77984. /** Gets the number of render calls made the last time the ADT has been rendered */
  77985. get numRenderCalls(): number;
  77986. /**
  77987. * Define type to string to ensure compatibility across browsers
  77988. * Safari doesn't support DataTransfer constructor
  77989. */
  77990. private _clipboardData;
  77991. /**
  77992. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77993. */
  77994. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77995. /**
  77996. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77997. */
  77998. onControlPickedObservable: BABYLON.Observable<Control>;
  77999. /**
  78000. * BABYLON.Observable event triggered before layout is evaluated
  78001. */
  78002. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78003. /**
  78004. * BABYLON.Observable event triggered after the layout was evaluated
  78005. */
  78006. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78007. /**
  78008. * BABYLON.Observable event triggered before the texture is rendered
  78009. */
  78010. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78011. /**
  78012. * BABYLON.Observable event triggered after the texture was rendered
  78013. */
  78014. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78015. /**
  78016. * Gets or sets a boolean defining if alpha is stored as premultiplied
  78017. */
  78018. premulAlpha: boolean;
  78019. /**
  78020. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  78021. * Useful when you want more antialiasing
  78022. */
  78023. get renderScale(): number;
  78024. set renderScale(value: number);
  78025. /** Gets or sets the background color */
  78026. get background(): string;
  78027. set background(value: string);
  78028. /**
  78029. * Gets or sets the ideal width used to design controls.
  78030. * The GUI will then rescale everything accordingly
  78031. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78032. */
  78033. get idealWidth(): number;
  78034. set idealWidth(value: number);
  78035. /**
  78036. * Gets or sets the ideal height used to design controls.
  78037. * The GUI will then rescale everything accordingly
  78038. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78039. */
  78040. get idealHeight(): number;
  78041. set idealHeight(value: number);
  78042. /**
  78043. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  78044. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78045. */
  78046. get useSmallestIdeal(): boolean;
  78047. set useSmallestIdeal(value: boolean);
  78048. /**
  78049. * Gets or sets a boolean indicating if adaptive scaling must be used
  78050. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78051. */
  78052. get renderAtIdealSize(): boolean;
  78053. set renderAtIdealSize(value: boolean);
  78054. /**
  78055. * Gets the ratio used when in "ideal mode"
  78056. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78057. * */
  78058. get idealRatio(): number;
  78059. /**
  78060. * Gets the underlying layer used to render the texture when in fullscreen mode
  78061. */
  78062. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  78063. /**
  78064. * Gets the root container control
  78065. */
  78066. get rootContainer(): Container;
  78067. /**
  78068. * Returns an array containing the root container.
  78069. * This is mostly used to let the Inspector introspects the ADT
  78070. * @returns an array containing the rootContainer
  78071. */
  78072. getChildren(): Array<Container>;
  78073. /**
  78074. * Will return all controls that are inside this texture
  78075. * @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
  78076. * @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
  78077. * @return all child controls
  78078. */
  78079. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78080. /**
  78081. * Gets or sets the current focused control
  78082. */
  78083. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  78084. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  78085. /**
  78086. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  78087. */
  78088. get isForeground(): boolean;
  78089. set isForeground(value: boolean);
  78090. /**
  78091. * Gets or set information about clipboardData
  78092. */
  78093. get clipboardData(): string;
  78094. set clipboardData(value: string);
  78095. /**
  78096. * Creates a new AdvancedDynamicTexture
  78097. * @param name defines the name of the texture
  78098. * @param width defines the width of the texture
  78099. * @param height defines the height of the texture
  78100. * @param scene defines the hosting scene
  78101. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  78102. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78103. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78104. */
  78105. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  78106. /**
  78107. * Get the current class name of the texture useful for serialization or dynamic coding.
  78108. * @returns "AdvancedDynamicTexture"
  78109. */
  78110. getClassName(): string;
  78111. /**
  78112. * Function used to execute a function on all controls
  78113. * @param func defines the function to execute
  78114. * @param container defines the container where controls belong. If null the root container will be used
  78115. */
  78116. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  78117. private _useInvalidateRectOptimization;
  78118. /**
  78119. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  78120. */
  78121. get useInvalidateRectOptimization(): boolean;
  78122. set useInvalidateRectOptimization(value: boolean);
  78123. private _invalidatedRectangle;
  78124. /**
  78125. * Invalidates a rectangle area on the gui texture
  78126. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  78127. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  78128. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  78129. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  78130. */
  78131. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  78132. /**
  78133. * Marks the texture as dirty forcing a complete update
  78134. */
  78135. markAsDirty(): void;
  78136. /**
  78137. * Helper function used to create a new style
  78138. * @returns a new style
  78139. * @see https://doc.babylonjs.com/how_to/gui#styles
  78140. */
  78141. createStyle(): Style;
  78142. /**
  78143. * Adds a new control to the root container
  78144. * @param control defines the control to add
  78145. * @returns the current texture
  78146. */
  78147. addControl(control: Control): AdvancedDynamicTexture;
  78148. /**
  78149. * Removes a control from the root container
  78150. * @param control defines the control to remove
  78151. * @returns the current texture
  78152. */
  78153. removeControl(control: Control): AdvancedDynamicTexture;
  78154. /**
  78155. * Release all resources
  78156. */
  78157. dispose(): void;
  78158. private _onResize;
  78159. /** @hidden */
  78160. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  78161. /**
  78162. * Get screen coordinates for a vector3
  78163. * @param position defines the position to project
  78164. * @param worldMatrix defines the world matrix to use
  78165. * @returns the projected position
  78166. */
  78167. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  78168. private _checkUpdate;
  78169. private _clearMeasure;
  78170. private _render;
  78171. /** @hidden */
  78172. _changeCursor(cursor: string): void;
  78173. /** @hidden */
  78174. _registerLastControlDown(control: Control, pointerId: number): void;
  78175. private _doPicking;
  78176. /** @hidden */
  78177. _cleanControlAfterRemovalFromList(list: {
  78178. [pointerId: number]: Control;
  78179. }, control: Control): void;
  78180. /** @hidden */
  78181. _cleanControlAfterRemoval(control: Control): void;
  78182. /** Attach to all scene events required to support pointer events */
  78183. attach(): void;
  78184. /** @hidden */
  78185. private onClipboardCopy;
  78186. /** @hidden */
  78187. private onClipboardCut;
  78188. /** @hidden */
  78189. private onClipboardPaste;
  78190. /**
  78191. * Register the clipboard Events onto the canvas
  78192. */
  78193. registerClipboardEvents(): void;
  78194. /**
  78195. * Unregister the clipboard Events from the canvas
  78196. */
  78197. unRegisterClipboardEvents(): void;
  78198. /**
  78199. * Connect the texture to a hosting mesh to enable interactions
  78200. * @param mesh defines the mesh to attach to
  78201. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78202. */
  78203. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78204. /**
  78205. * Move the focus to a specific control
  78206. * @param control defines the control which will receive the focus
  78207. */
  78208. moveFocusToControl(control: IFocusableControl): void;
  78209. private _manageFocus;
  78210. private _attachToOnPointerOut;
  78211. private _attachToOnBlur;
  78212. /**
  78213. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78214. * @param mesh defines the mesh which will receive the texture
  78215. * @param width defines the texture width (1024 by default)
  78216. * @param height defines the texture height (1024 by default)
  78217. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78218. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78219. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78220. * @returns a new AdvancedDynamicTexture
  78221. */
  78222. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78223. /**
  78224. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78225. * In this mode the texture will rely on a layer for its rendering.
  78226. * This allows it to be treated like any other layer.
  78227. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78228. * LayerMask is set through advancedTexture.layer.layerMask
  78229. * @param name defines name for the texture
  78230. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78231. * @param scene defines the hsoting scene
  78232. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78233. * @returns a new AdvancedDynamicTexture
  78234. */
  78235. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78236. }
  78237. }
  78238. declare module BABYLON.GUI {
  78239. /**
  78240. * Root class used for all 2D controls
  78241. * @see https://doc.babylonjs.com/how_to/gui#controls
  78242. */
  78243. export class Control {
  78244. /** defines the name of the control */
  78245. name?: string | undefined;
  78246. /**
  78247. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78248. */
  78249. static AllowAlphaInheritance: boolean;
  78250. private _alpha;
  78251. private _alphaSet;
  78252. private _zIndex;
  78253. /** @hidden */
  78254. _host: AdvancedDynamicTexture;
  78255. /** Gets or sets the control parent */
  78256. parent: BABYLON.Nullable<Container>;
  78257. /** @hidden */
  78258. _currentMeasure: Measure;
  78259. private _fontFamily;
  78260. private _fontStyle;
  78261. private _fontWeight;
  78262. private _fontSize;
  78263. private _font;
  78264. /** @hidden */
  78265. _width: ValueAndUnit;
  78266. /** @hidden */
  78267. _height: ValueAndUnit;
  78268. /** @hidden */
  78269. protected _fontOffset: {
  78270. ascent: number;
  78271. height: number;
  78272. descent: number;
  78273. };
  78274. private _color;
  78275. private _style;
  78276. private _styleObserver;
  78277. /** @hidden */
  78278. protected _horizontalAlignment: number;
  78279. /** @hidden */
  78280. protected _verticalAlignment: number;
  78281. /** @hidden */
  78282. protected _isDirty: boolean;
  78283. /** @hidden */
  78284. protected _wasDirty: boolean;
  78285. /** @hidden */
  78286. _tempParentMeasure: Measure;
  78287. /** @hidden */
  78288. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78289. /** @hidden */
  78290. protected _cachedParentMeasure: Measure;
  78291. private _paddingLeft;
  78292. private _paddingRight;
  78293. private _paddingTop;
  78294. private _paddingBottom;
  78295. /** @hidden */
  78296. _left: ValueAndUnit;
  78297. /** @hidden */
  78298. _top: ValueAndUnit;
  78299. private _scaleX;
  78300. private _scaleY;
  78301. private _rotation;
  78302. private _transformCenterX;
  78303. private _transformCenterY;
  78304. /** @hidden */
  78305. _transformMatrix: Matrix2D;
  78306. /** @hidden */
  78307. protected _invertTransformMatrix: Matrix2D;
  78308. /** @hidden */
  78309. protected _transformedPosition: BABYLON.Vector2;
  78310. private _isMatrixDirty;
  78311. private _cachedOffsetX;
  78312. private _cachedOffsetY;
  78313. private _isVisible;
  78314. private _isHighlighted;
  78315. /** @hidden */
  78316. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78317. private _fontSet;
  78318. private _dummyVector2;
  78319. private _downCount;
  78320. private _enterCount;
  78321. private _doNotRender;
  78322. private _downPointerIds;
  78323. protected _isEnabled: boolean;
  78324. protected _disabledColor: string;
  78325. protected _disabledColorItem: string;
  78326. /** @hidden */
  78327. protected _rebuildLayout: boolean;
  78328. /** @hidden */
  78329. _customData: any;
  78330. /** @hidden */
  78331. _isClipped: boolean;
  78332. /** @hidden */
  78333. _automaticSize: boolean;
  78334. /** @hidden */
  78335. _tag: any;
  78336. /**
  78337. * 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
  78338. */
  78339. uniqueId: number;
  78340. /**
  78341. * Gets or sets an object used to store user defined information for the node
  78342. */
  78343. metadata: any;
  78344. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78345. isHitTestVisible: boolean;
  78346. /** Gets or sets a boolean indicating if the control can block pointer events */
  78347. isPointerBlocker: boolean;
  78348. /** Gets or sets a boolean indicating if the control can be focusable */
  78349. isFocusInvisible: boolean;
  78350. /**
  78351. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78352. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  78353. */
  78354. clipChildren: boolean;
  78355. /**
  78356. * Gets or sets a boolean indicating that control content must be clipped
  78357. * 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
  78358. */
  78359. clipContent: boolean;
  78360. /**
  78361. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78362. */
  78363. useBitmapCache: boolean;
  78364. private _cacheData;
  78365. private _shadowOffsetX;
  78366. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78367. get shadowOffsetX(): number;
  78368. set shadowOffsetX(value: number);
  78369. private _shadowOffsetY;
  78370. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78371. get shadowOffsetY(): number;
  78372. set shadowOffsetY(value: number);
  78373. private _shadowBlur;
  78374. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78375. get shadowBlur(): number;
  78376. set shadowBlur(value: number);
  78377. private _shadowColor;
  78378. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78379. get shadowColor(): string;
  78380. set shadowColor(value: string);
  78381. /** Gets or sets the cursor to use when the control is hovered */
  78382. hoverCursor: string;
  78383. /** @hidden */
  78384. protected _linkOffsetX: ValueAndUnit;
  78385. /** @hidden */
  78386. protected _linkOffsetY: ValueAndUnit;
  78387. /** Gets the control type name */
  78388. get typeName(): string;
  78389. /**
  78390. * Get the current class name of the control.
  78391. * @returns current class name
  78392. */
  78393. getClassName(): string;
  78394. /**
  78395. * An event triggered when pointer wheel is scrolled
  78396. */
  78397. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78398. /**
  78399. * An event triggered when the pointer move over the control.
  78400. */
  78401. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78402. /**
  78403. * An event triggered when the pointer move out of the control.
  78404. */
  78405. onPointerOutObservable: BABYLON.Observable<Control>;
  78406. /**
  78407. * An event triggered when the pointer taps the control
  78408. */
  78409. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78410. /**
  78411. * An event triggered when pointer up
  78412. */
  78413. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78414. /**
  78415. * An event triggered when a control is clicked on
  78416. */
  78417. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78418. /**
  78419. * An event triggered when pointer enters the control
  78420. */
  78421. onPointerEnterObservable: BABYLON.Observable<Control>;
  78422. /**
  78423. * An event triggered when the control is marked as dirty
  78424. */
  78425. onDirtyObservable: BABYLON.Observable<Control>;
  78426. /**
  78427. * An event triggered before drawing the control
  78428. */
  78429. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78430. /**
  78431. * An event triggered after the control was drawn
  78432. */
  78433. onAfterDrawObservable: BABYLON.Observable<Control>;
  78434. /**
  78435. * An event triggered when the control has been disposed
  78436. */
  78437. onDisposeObservable: BABYLON.Observable<Control>;
  78438. /**
  78439. * Get the hosting AdvancedDynamicTexture
  78440. */
  78441. get host(): AdvancedDynamicTexture;
  78442. /** Gets or set information about font offsets (used to render and align text) */
  78443. get fontOffset(): {
  78444. ascent: number;
  78445. height: number;
  78446. descent: number;
  78447. };
  78448. set fontOffset(offset: {
  78449. ascent: number;
  78450. height: number;
  78451. descent: number;
  78452. });
  78453. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78454. get alpha(): number;
  78455. set alpha(value: number);
  78456. /**
  78457. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78458. */
  78459. get isHighlighted(): boolean;
  78460. set isHighlighted(value: boolean);
  78461. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78462. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78463. */
  78464. get scaleX(): number;
  78465. set scaleX(value: number);
  78466. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78467. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78468. */
  78469. get scaleY(): number;
  78470. set scaleY(value: number);
  78471. /** Gets or sets the rotation angle (0 by default)
  78472. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78473. */
  78474. get rotation(): number;
  78475. set rotation(value: number);
  78476. /** Gets or sets the transformation center on Y axis (0 by default)
  78477. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78478. */
  78479. get transformCenterY(): number;
  78480. set transformCenterY(value: number);
  78481. /** Gets or sets the transformation center on X axis (0 by default)
  78482. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78483. */
  78484. get transformCenterX(): number;
  78485. set transformCenterX(value: number);
  78486. /**
  78487. * Gets or sets the horizontal alignment
  78488. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78489. */
  78490. get horizontalAlignment(): number;
  78491. set horizontalAlignment(value: number);
  78492. /**
  78493. * Gets or sets the vertical alignment
  78494. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78495. */
  78496. get verticalAlignment(): number;
  78497. set verticalAlignment(value: number);
  78498. /**
  78499. * Gets or sets a fixed ratio for this control.
  78500. * When different from 0, the ratio is used to compute the "second" dimension.
  78501. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78502. * second dimension is computed as first dimension * fixedRatio
  78503. */
  78504. fixedRatio: number;
  78505. private _fixedRatioMasterIsWidth;
  78506. /**
  78507. * Gets or sets control width
  78508. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78509. */
  78510. get width(): string | number;
  78511. set width(value: string | number);
  78512. /**
  78513. * Gets or sets the control width in pixel
  78514. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78515. */
  78516. get widthInPixels(): number;
  78517. set widthInPixels(value: number);
  78518. /**
  78519. * Gets or sets control height
  78520. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78521. */
  78522. get height(): string | number;
  78523. set height(value: string | number);
  78524. /**
  78525. * Gets or sets control height in pixel
  78526. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78527. */
  78528. get heightInPixels(): number;
  78529. set heightInPixels(value: number);
  78530. /** Gets or set font family */
  78531. get fontFamily(): string;
  78532. set fontFamily(value: string);
  78533. /** Gets or sets font style */
  78534. get fontStyle(): string;
  78535. set fontStyle(value: string);
  78536. /** Gets or sets font weight */
  78537. get fontWeight(): string;
  78538. set fontWeight(value: string);
  78539. /**
  78540. * Gets or sets style
  78541. * @see https://doc.babylonjs.com/how_to/gui#styles
  78542. */
  78543. get style(): BABYLON.Nullable<Style>;
  78544. set style(value: BABYLON.Nullable<Style>);
  78545. /** @hidden */
  78546. get _isFontSizeInPercentage(): boolean;
  78547. /** Gets or sets font size in pixels */
  78548. get fontSizeInPixels(): number;
  78549. set fontSizeInPixels(value: number);
  78550. /** Gets or sets font size */
  78551. get fontSize(): string | number;
  78552. set fontSize(value: string | number);
  78553. /** Gets or sets foreground color */
  78554. get color(): string;
  78555. set color(value: string);
  78556. /** Gets or sets z index which is used to reorder controls on the z axis */
  78557. get zIndex(): number;
  78558. set zIndex(value: number);
  78559. /** Gets or sets a boolean indicating if the control can be rendered */
  78560. get notRenderable(): boolean;
  78561. set notRenderable(value: boolean);
  78562. /** Gets or sets a boolean indicating if the control is visible */
  78563. get isVisible(): boolean;
  78564. set isVisible(value: boolean);
  78565. /** Gets a boolean indicating that the control needs to update its rendering */
  78566. get isDirty(): boolean;
  78567. /**
  78568. * Gets the current linked mesh (or null if none)
  78569. */
  78570. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  78571. /**
  78572. * Gets or sets a value indicating the padding to use on the left of the control
  78573. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78574. */
  78575. get paddingLeft(): string | number;
  78576. set paddingLeft(value: string | number);
  78577. /**
  78578. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78579. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78580. */
  78581. get paddingLeftInPixels(): number;
  78582. set paddingLeftInPixels(value: number);
  78583. /**
  78584. * Gets or sets a value indicating the padding to use on the right of the control
  78585. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78586. */
  78587. get paddingRight(): string | number;
  78588. set paddingRight(value: string | number);
  78589. /**
  78590. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78591. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78592. */
  78593. get paddingRightInPixels(): number;
  78594. set paddingRightInPixels(value: number);
  78595. /**
  78596. * Gets or sets a value indicating the padding to use on the top of the control
  78597. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78598. */
  78599. get paddingTop(): string | number;
  78600. set paddingTop(value: string | number);
  78601. /**
  78602. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78603. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78604. */
  78605. get paddingTopInPixels(): number;
  78606. set paddingTopInPixels(value: number);
  78607. /**
  78608. * Gets or sets a value indicating the padding to use on the bottom of the control
  78609. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78610. */
  78611. get paddingBottom(): string | number;
  78612. set paddingBottom(value: string | number);
  78613. /**
  78614. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78615. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78616. */
  78617. get paddingBottomInPixels(): number;
  78618. set paddingBottomInPixels(value: number);
  78619. /**
  78620. * Gets or sets a value indicating the left coordinate of the control
  78621. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78622. */
  78623. get left(): string | number;
  78624. set left(value: string | number);
  78625. /**
  78626. * Gets or sets a value indicating the left coordinate in pixels of the control
  78627. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78628. */
  78629. get leftInPixels(): number;
  78630. set leftInPixels(value: number);
  78631. /**
  78632. * Gets or sets a value indicating the top coordinate of the control
  78633. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78634. */
  78635. get top(): string | number;
  78636. set top(value: string | number);
  78637. /**
  78638. * Gets or sets a value indicating the top coordinate in pixels of the control
  78639. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78640. */
  78641. get topInPixels(): number;
  78642. set topInPixels(value: number);
  78643. /**
  78644. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78645. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78646. */
  78647. get linkOffsetX(): string | number;
  78648. set linkOffsetX(value: string | number);
  78649. /**
  78650. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78651. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78652. */
  78653. get linkOffsetXInPixels(): number;
  78654. set linkOffsetXInPixels(value: number);
  78655. /**
  78656. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78657. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78658. */
  78659. get linkOffsetY(): string | number;
  78660. set linkOffsetY(value: string | number);
  78661. /**
  78662. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78663. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78664. */
  78665. get linkOffsetYInPixels(): number;
  78666. set linkOffsetYInPixels(value: number);
  78667. /** Gets the center coordinate on X axis */
  78668. get centerX(): number;
  78669. /** Gets the center coordinate on Y axis */
  78670. get centerY(): number;
  78671. /** Gets or sets if control is Enabled*/
  78672. get isEnabled(): boolean;
  78673. set isEnabled(value: boolean);
  78674. /** Gets or sets background color of control if it's disabled*/
  78675. get disabledColor(): string;
  78676. set disabledColor(value: string);
  78677. /** Gets or sets front color of control if it's disabled*/
  78678. get disabledColorItem(): string;
  78679. set disabledColorItem(value: string);
  78680. /**
  78681. * Creates a new control
  78682. * @param name defines the name of the control
  78683. */
  78684. constructor(
  78685. /** defines the name of the control */
  78686. name?: string | undefined);
  78687. /** @hidden */
  78688. protected _getTypeName(): string;
  78689. /**
  78690. * Gets the first ascendant in the hierarchy of the given type
  78691. * @param className defines the required type
  78692. * @returns the ascendant or null if not found
  78693. */
  78694. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78695. /** @hidden */
  78696. _resetFontCache(): void;
  78697. /**
  78698. * Determines if a container is an ascendant of the current control
  78699. * @param container defines the container to look for
  78700. * @returns true if the container is one of the ascendant of the control
  78701. */
  78702. isAscendant(container: Control): boolean;
  78703. /**
  78704. * Gets coordinates in local control space
  78705. * @param globalCoordinates defines the coordinates to transform
  78706. * @returns the new coordinates in local space
  78707. */
  78708. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78709. /**
  78710. * Gets coordinates in local control space
  78711. * @param globalCoordinates defines the coordinates to transform
  78712. * @param result defines the target vector2 where to store the result
  78713. * @returns the current control
  78714. */
  78715. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  78716. /**
  78717. * Gets coordinates in parent local control space
  78718. * @param globalCoordinates defines the coordinates to transform
  78719. * @returns the new coordinates in parent local space
  78720. */
  78721. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78722. /**
  78723. * Move the current control to a vector3 position projected onto the screen.
  78724. * @param position defines the target position
  78725. * @param scene defines the hosting scene
  78726. */
  78727. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  78728. /**
  78729. * Will store all controls that have this control as ascendant in a given array
  78730. * @param results defines the array where to store the descendants
  78731. * @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
  78732. * @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
  78733. */
  78734. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78735. /**
  78736. * Will return all controls that have this control as ascendant
  78737. * @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
  78738. * @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
  78739. * @return all child controls
  78740. */
  78741. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78742. /**
  78743. * Link current control with a target mesh
  78744. * @param mesh defines the mesh to link with
  78745. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78746. */
  78747. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  78748. /** @hidden */
  78749. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  78750. /** @hidden */
  78751. _offsetLeft(offset: number): void;
  78752. /** @hidden */
  78753. _offsetTop(offset: number): void;
  78754. /** @hidden */
  78755. _markMatrixAsDirty(): void;
  78756. /** @hidden */
  78757. _flagDescendantsAsMatrixDirty(): void;
  78758. /** @hidden */
  78759. _intersectsRect(rect: Measure): boolean;
  78760. /** @hidden */
  78761. protected invalidateRect(): void;
  78762. /** @hidden */
  78763. _markAsDirty(force?: boolean): void;
  78764. /** @hidden */
  78765. _markAllAsDirty(): void;
  78766. /** @hidden */
  78767. _link(host: AdvancedDynamicTexture): void;
  78768. /** @hidden */
  78769. protected _transform(context?: CanvasRenderingContext2D): void;
  78770. /** @hidden */
  78771. _renderHighlight(context: CanvasRenderingContext2D): void;
  78772. /** @hidden */
  78773. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78774. /** @hidden */
  78775. protected _applyStates(context: CanvasRenderingContext2D): void;
  78776. /** @hidden */
  78777. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78778. /** @hidden */
  78779. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78780. protected _evaluateClippingState(parentMeasure: Measure): void;
  78781. /** @hidden */
  78782. _measure(): void;
  78783. /** @hidden */
  78784. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78785. /** @hidden */
  78786. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78787. /** @hidden */
  78788. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78789. /** @hidden */
  78790. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78791. private static _ClipMeasure;
  78792. private _tmpMeasureA;
  78793. private _clip;
  78794. /** @hidden */
  78795. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  78796. /** @hidden */
  78797. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78798. /**
  78799. * Tests if a given coordinates belong to the current control
  78800. * @param x defines x coordinate to test
  78801. * @param y defines y coordinate to test
  78802. * @returns true if the coordinates are inside the control
  78803. */
  78804. contains(x: number, y: number): boolean;
  78805. /** @hidden */
  78806. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78807. /** @hidden */
  78808. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  78809. /** @hidden */
  78810. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78811. /** @hidden */
  78812. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  78813. /** @hidden */
  78814. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78815. /** @hidden */
  78816. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  78817. /** @hidden */
  78818. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78819. /** @hidden */
  78820. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  78821. /** @hidden */
  78822. _onCanvasBlur(): void;
  78823. /** @hidden */
  78824. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78825. private _prepareFont;
  78826. /** Releases associated resources */
  78827. dispose(): void;
  78828. private static _HORIZONTAL_ALIGNMENT_LEFT;
  78829. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  78830. private static _HORIZONTAL_ALIGNMENT_CENTER;
  78831. private static _VERTICAL_ALIGNMENT_TOP;
  78832. private static _VERTICAL_ALIGNMENT_BOTTOM;
  78833. private static _VERTICAL_ALIGNMENT_CENTER;
  78834. /** HORIZONTAL_ALIGNMENT_LEFT */
  78835. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  78836. /** HORIZONTAL_ALIGNMENT_RIGHT */
  78837. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  78838. /** HORIZONTAL_ALIGNMENT_CENTER */
  78839. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  78840. /** VERTICAL_ALIGNMENT_TOP */
  78841. static get VERTICAL_ALIGNMENT_TOP(): number;
  78842. /** VERTICAL_ALIGNMENT_BOTTOM */
  78843. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  78844. /** VERTICAL_ALIGNMENT_CENTER */
  78845. static get VERTICAL_ALIGNMENT_CENTER(): number;
  78846. private static _FontHeightSizes;
  78847. /** @hidden */
  78848. static _GetFontOffset(font: string): {
  78849. ascent: number;
  78850. height: number;
  78851. descent: number;
  78852. };
  78853. /**
  78854. * Creates a stack panel that can be used to render headers
  78855. * @param control defines the control to associate with the header
  78856. * @param text defines the text of the header
  78857. * @param size defines the size of the header
  78858. * @param options defines options used to configure the header
  78859. * @returns a new StackPanel
  78860. * @ignore
  78861. * @hidden
  78862. */
  78863. static AddHeader: (control: Control, text: string, size: string | number, options: {
  78864. isHorizontal: boolean;
  78865. controlFirst: boolean;
  78866. }) => any;
  78867. /** @hidden */
  78868. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  78869. }
  78870. }
  78871. declare module BABYLON.GUI {
  78872. /**
  78873. * Root class for 2D containers
  78874. * @see https://doc.babylonjs.com/how_to/gui#containers
  78875. */
  78876. export class Container extends Control {
  78877. name?: string | undefined;
  78878. /** @hidden */
  78879. _children: Control[];
  78880. /** @hidden */
  78881. protected _measureForChildren: Measure;
  78882. /** @hidden */
  78883. protected _background: string;
  78884. /** @hidden */
  78885. protected _adaptWidthToChildren: boolean;
  78886. /** @hidden */
  78887. protected _adaptHeightToChildren: boolean;
  78888. /**
  78889. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  78890. */
  78891. logLayoutCycleErrors: boolean;
  78892. /**
  78893. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  78894. */
  78895. maxLayoutCycle: number;
  78896. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  78897. get adaptHeightToChildren(): boolean;
  78898. set adaptHeightToChildren(value: boolean);
  78899. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  78900. get adaptWidthToChildren(): boolean;
  78901. set adaptWidthToChildren(value: boolean);
  78902. /** Gets or sets background color */
  78903. get background(): string;
  78904. set background(value: string);
  78905. /** Gets the list of children */
  78906. get children(): Control[];
  78907. /**
  78908. * Creates a new Container
  78909. * @param name defines the name of the container
  78910. */
  78911. constructor(name?: string | undefined);
  78912. protected _getTypeName(): string;
  78913. _flagDescendantsAsMatrixDirty(): void;
  78914. /**
  78915. * Gets a child using its name
  78916. * @param name defines the child name to look for
  78917. * @returns the child control if found
  78918. */
  78919. getChildByName(name: string): BABYLON.Nullable<Control>;
  78920. /**
  78921. * Gets a child using its type and its name
  78922. * @param name defines the child name to look for
  78923. * @param type defines the child type to look for
  78924. * @returns the child control if found
  78925. */
  78926. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  78927. /**
  78928. * Search for a specific control in children
  78929. * @param control defines the control to look for
  78930. * @returns true if the control is in child list
  78931. */
  78932. containsControl(control: Control): boolean;
  78933. /**
  78934. * Adds a new control to the current container
  78935. * @param control defines the control to add
  78936. * @returns the current container
  78937. */
  78938. addControl(control: BABYLON.Nullable<Control>): Container;
  78939. /**
  78940. * Removes all controls from the current container
  78941. * @returns the current container
  78942. */
  78943. clearControls(): Container;
  78944. /**
  78945. * Removes a control from the current container
  78946. * @param control defines the control to remove
  78947. * @returns the current container
  78948. */
  78949. removeControl(control: Control): Container;
  78950. /** @hidden */
  78951. _reOrderControl(control: Control): void;
  78952. /** @hidden */
  78953. _offsetLeft(offset: number): void;
  78954. /** @hidden */
  78955. _offsetTop(offset: number): void;
  78956. /** @hidden */
  78957. _markAllAsDirty(): void;
  78958. /** @hidden */
  78959. protected _localDraw(context: CanvasRenderingContext2D): void;
  78960. /** @hidden */
  78961. _link(host: AdvancedDynamicTexture): void;
  78962. /** @hidden */
  78963. protected _beforeLayout(): void;
  78964. /** @hidden */
  78965. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78966. /** @hidden */
  78967. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78968. protected _postMeasure(): void;
  78969. /** @hidden */
  78970. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78971. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78972. /** @hidden */
  78973. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78974. /** @hidden */
  78975. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78976. /** Releases associated resources */
  78977. dispose(): void;
  78978. }
  78979. }
  78980. declare module BABYLON.GUI {
  78981. /** Class used to create rectangle container */
  78982. export class Rectangle extends Container {
  78983. name?: string | undefined;
  78984. private _thickness;
  78985. private _cornerRadius;
  78986. /** Gets or sets border thickness */
  78987. get thickness(): number;
  78988. set thickness(value: number);
  78989. /** Gets or sets the corner radius angle */
  78990. get cornerRadius(): number;
  78991. set cornerRadius(value: number);
  78992. /**
  78993. * Creates a new Rectangle
  78994. * @param name defines the control name
  78995. */
  78996. constructor(name?: string | undefined);
  78997. protected _getTypeName(): string;
  78998. protected _localDraw(context: CanvasRenderingContext2D): void;
  78999. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79000. private _drawRoundedRect;
  79001. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79002. }
  79003. }
  79004. declare module BABYLON.GUI {
  79005. /**
  79006. * Enum that determines the text-wrapping mode to use.
  79007. */
  79008. export enum TextWrapping {
  79009. /**
  79010. * Clip the text when it's larger than Control.width; this is the default mode.
  79011. */
  79012. Clip = 0,
  79013. /**
  79014. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  79015. */
  79016. WordWrap = 1,
  79017. /**
  79018. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  79019. */
  79020. Ellipsis = 2
  79021. }
  79022. /**
  79023. * Class used to create text block control
  79024. */
  79025. export class TextBlock extends Control {
  79026. /**
  79027. * Defines the name of the control
  79028. */
  79029. name?: string | undefined;
  79030. private _text;
  79031. private _textWrapping;
  79032. private _textHorizontalAlignment;
  79033. private _textVerticalAlignment;
  79034. private _lines;
  79035. private _resizeToFit;
  79036. private _lineSpacing;
  79037. private _outlineWidth;
  79038. private _outlineColor;
  79039. private _underline;
  79040. private _lineThrough;
  79041. /**
  79042. * An event triggered after the text is changed
  79043. */
  79044. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  79045. /**
  79046. * An event triggered after the text was broken up into lines
  79047. */
  79048. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  79049. /**
  79050. * Function used to split a string into words. By default, a string is split at each space character found
  79051. */
  79052. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  79053. /**
  79054. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  79055. */
  79056. get lines(): any[];
  79057. /**
  79058. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79059. */
  79060. get resizeToFit(): boolean;
  79061. /**
  79062. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79063. */
  79064. set resizeToFit(value: boolean);
  79065. /**
  79066. * Gets or sets a boolean indicating if text must be wrapped
  79067. */
  79068. get textWrapping(): TextWrapping | boolean;
  79069. /**
  79070. * Gets or sets a boolean indicating if text must be wrapped
  79071. */
  79072. set textWrapping(value: TextWrapping | boolean);
  79073. /**
  79074. * Gets or sets text to display
  79075. */
  79076. get text(): string;
  79077. /**
  79078. * Gets or sets text to display
  79079. */
  79080. set text(value: string);
  79081. /**
  79082. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79083. */
  79084. get textHorizontalAlignment(): number;
  79085. /**
  79086. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79087. */
  79088. set textHorizontalAlignment(value: number);
  79089. /**
  79090. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79091. */
  79092. get textVerticalAlignment(): number;
  79093. /**
  79094. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79095. */
  79096. set textVerticalAlignment(value: number);
  79097. /**
  79098. * Gets or sets line spacing value
  79099. */
  79100. set lineSpacing(value: string | number);
  79101. /**
  79102. * Gets or sets line spacing value
  79103. */
  79104. get lineSpacing(): string | number;
  79105. /**
  79106. * Gets or sets outlineWidth of the text to display
  79107. */
  79108. get outlineWidth(): number;
  79109. /**
  79110. * Gets or sets outlineWidth of the text to display
  79111. */
  79112. set outlineWidth(value: number);
  79113. /**
  79114. * Gets or sets a boolean indicating that text must have underline
  79115. */
  79116. get underline(): boolean;
  79117. /**
  79118. * Gets or sets a boolean indicating that text must have underline
  79119. */
  79120. set underline(value: boolean);
  79121. /**
  79122. * Gets or sets an boolean indicating that text must be crossed out
  79123. */
  79124. get lineThrough(): boolean;
  79125. /**
  79126. * Gets or sets an boolean indicating that text must be crossed out
  79127. */
  79128. set lineThrough(value: boolean);
  79129. /**
  79130. * Gets or sets outlineColor of the text to display
  79131. */
  79132. get outlineColor(): string;
  79133. /**
  79134. * Gets or sets outlineColor of the text to display
  79135. */
  79136. set outlineColor(value: string);
  79137. /**
  79138. * Creates a new TextBlock object
  79139. * @param name defines the name of the control
  79140. * @param text defines the text to display (emptry string by default)
  79141. */
  79142. constructor(
  79143. /**
  79144. * Defines the name of the control
  79145. */
  79146. name?: string | undefined, text?: string);
  79147. protected _getTypeName(): string;
  79148. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79149. private _drawText;
  79150. /** @hidden */
  79151. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79152. protected _applyStates(context: CanvasRenderingContext2D): void;
  79153. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  79154. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  79155. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  79156. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  79157. protected _renderLines(context: CanvasRenderingContext2D): void;
  79158. /**
  79159. * Given a width constraint applied on the text block, find the expected height
  79160. * @returns expected height
  79161. */
  79162. computeExpectedHeight(): number;
  79163. dispose(): void;
  79164. }
  79165. }
  79166. declare module BABYLON.GUI {
  79167. /**
  79168. * Class used to create 2D images
  79169. */
  79170. export class Image extends Control {
  79171. name?: string | undefined;
  79172. private _workingCanvas;
  79173. private _domImage;
  79174. private _imageWidth;
  79175. private _imageHeight;
  79176. private _loaded;
  79177. private _stretch;
  79178. private _source;
  79179. private _autoScale;
  79180. private _sourceLeft;
  79181. private _sourceTop;
  79182. private _sourceWidth;
  79183. private _sourceHeight;
  79184. private _svgAttributesComputationCompleted;
  79185. private _isSVG;
  79186. private _cellWidth;
  79187. private _cellHeight;
  79188. private _cellId;
  79189. private _populateNinePatchSlicesFromImage;
  79190. private _sliceLeft;
  79191. private _sliceRight;
  79192. private _sliceTop;
  79193. private _sliceBottom;
  79194. private _detectPointerOnOpaqueOnly;
  79195. private _imageDataCache;
  79196. /**
  79197. * BABYLON.Observable notified when the content is loaded
  79198. */
  79199. onImageLoadedObservable: BABYLON.Observable<Image>;
  79200. /**
  79201. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79202. */
  79203. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79204. /**
  79205. * Gets a boolean indicating that the content is loaded
  79206. */
  79207. get isLoaded(): boolean;
  79208. /**
  79209. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79210. */
  79211. get populateNinePatchSlicesFromImage(): boolean;
  79212. set populateNinePatchSlicesFromImage(value: boolean);
  79213. /**
  79214. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79215. * Beware using this as this will comsume more memory as the image has to be stored twice
  79216. */
  79217. get detectPointerOnOpaqueOnly(): boolean;
  79218. set detectPointerOnOpaqueOnly(value: boolean);
  79219. /**
  79220. * Gets or sets the left value for slicing (9-patch)
  79221. */
  79222. get sliceLeft(): number;
  79223. set sliceLeft(value: number);
  79224. /**
  79225. * Gets or sets the right value for slicing (9-patch)
  79226. */
  79227. get sliceRight(): number;
  79228. set sliceRight(value: number);
  79229. /**
  79230. * Gets or sets the top value for slicing (9-patch)
  79231. */
  79232. get sliceTop(): number;
  79233. set sliceTop(value: number);
  79234. /**
  79235. * Gets or sets the bottom value for slicing (9-patch)
  79236. */
  79237. get sliceBottom(): number;
  79238. set sliceBottom(value: number);
  79239. /**
  79240. * Gets or sets the left coordinate in the source image
  79241. */
  79242. get sourceLeft(): number;
  79243. set sourceLeft(value: number);
  79244. /**
  79245. * Gets or sets the top coordinate in the source image
  79246. */
  79247. get sourceTop(): number;
  79248. set sourceTop(value: number);
  79249. /**
  79250. * Gets or sets the width to capture in the source image
  79251. */
  79252. get sourceWidth(): number;
  79253. set sourceWidth(value: number);
  79254. /**
  79255. * Gets or sets the height to capture in the source image
  79256. */
  79257. get sourceHeight(): number;
  79258. set sourceHeight(value: number);
  79259. /** Indicates if the format of the image is SVG */
  79260. get isSVG(): boolean;
  79261. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79262. get svgAttributesComputationCompleted(): boolean;
  79263. /**
  79264. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79265. * @see https://doc.babylonjs.com/how_to/gui#image
  79266. */
  79267. get autoScale(): boolean;
  79268. set autoScale(value: boolean);
  79269. /** Gets or sets the streching mode used by the image */
  79270. get stretch(): number;
  79271. set stretch(value: number);
  79272. /** @hidden */
  79273. _rotate90(n: number, preserveProperties?: boolean): Image;
  79274. private _handleRotationForSVGImage;
  79275. private _rotate90SourceProperties;
  79276. /**
  79277. * Gets or sets the internal DOM image used to render the control
  79278. */
  79279. set domImage(value: HTMLImageElement);
  79280. get domImage(): HTMLImageElement;
  79281. private _onImageLoaded;
  79282. private _extractNinePatchSliceDataFromImage;
  79283. /**
  79284. * Gets or sets image source url
  79285. */
  79286. set source(value: BABYLON.Nullable<string>);
  79287. /**
  79288. * Checks for svg document with icon id present
  79289. */
  79290. private _svgCheck;
  79291. /**
  79292. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79293. * given external svg file and icon id
  79294. */
  79295. private _getSVGAttribs;
  79296. /**
  79297. * Gets or sets the cell width to use when animation sheet is enabled
  79298. * @see https://doc.babylonjs.com/how_to/gui#image
  79299. */
  79300. get cellWidth(): number;
  79301. set cellWidth(value: number);
  79302. /**
  79303. * Gets or sets the cell height to use when animation sheet is enabled
  79304. * @see https://doc.babylonjs.com/how_to/gui#image
  79305. */
  79306. get cellHeight(): number;
  79307. set cellHeight(value: number);
  79308. /**
  79309. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79310. * @see https://doc.babylonjs.com/how_to/gui#image
  79311. */
  79312. get cellId(): number;
  79313. set cellId(value: number);
  79314. /**
  79315. * Creates a new Image
  79316. * @param name defines the control name
  79317. * @param url defines the image url
  79318. */
  79319. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79320. /**
  79321. * Tests if a given coordinates belong to the current control
  79322. * @param x defines x coordinate to test
  79323. * @param y defines y coordinate to test
  79324. * @returns true if the coordinates are inside the control
  79325. */
  79326. contains(x: number, y: number): boolean;
  79327. protected _getTypeName(): string;
  79328. /** Force the control to synchronize with its content */
  79329. synchronizeSizeWithContent(): void;
  79330. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79331. private _prepareWorkingCanvasForOpaqueDetection;
  79332. private _drawImage;
  79333. _draw(context: CanvasRenderingContext2D): void;
  79334. private _renderCornerPatch;
  79335. private _renderNinePatch;
  79336. dispose(): void;
  79337. /** STRETCH_NONE */
  79338. static readonly STRETCH_NONE: number;
  79339. /** STRETCH_FILL */
  79340. static readonly STRETCH_FILL: number;
  79341. /** STRETCH_UNIFORM */
  79342. static readonly STRETCH_UNIFORM: number;
  79343. /** STRETCH_EXTEND */
  79344. static readonly STRETCH_EXTEND: number;
  79345. /** NINE_PATCH */
  79346. static readonly STRETCH_NINE_PATCH: number;
  79347. }
  79348. }
  79349. declare module BABYLON.GUI {
  79350. /**
  79351. * Class used to create 2D buttons
  79352. */
  79353. export class Button extends Rectangle {
  79354. name?: string | undefined;
  79355. /**
  79356. * Function called to generate a pointer enter animation
  79357. */
  79358. pointerEnterAnimation: () => void;
  79359. /**
  79360. * Function called to generate a pointer out animation
  79361. */
  79362. pointerOutAnimation: () => void;
  79363. /**
  79364. * Function called to generate a pointer down animation
  79365. */
  79366. pointerDownAnimation: () => void;
  79367. /**
  79368. * Function called to generate a pointer up animation
  79369. */
  79370. pointerUpAnimation: () => void;
  79371. /**
  79372. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79373. */
  79374. delegatePickingToChildren: boolean;
  79375. private _image;
  79376. /**
  79377. * Returns the image part of the button (if any)
  79378. */
  79379. get image(): BABYLON.Nullable<Image>;
  79380. private _textBlock;
  79381. /**
  79382. * Returns the image part of the button (if any)
  79383. */
  79384. get textBlock(): BABYLON.Nullable<TextBlock>;
  79385. /**
  79386. * Creates a new Button
  79387. * @param name defines the name of the button
  79388. */
  79389. constructor(name?: string | undefined);
  79390. protected _getTypeName(): string;
  79391. /** @hidden */
  79392. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79393. /** @hidden */
  79394. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79395. /** @hidden */
  79396. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79397. /** @hidden */
  79398. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79399. /** @hidden */
  79400. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79401. /**
  79402. * Creates a new button made with an image and a text
  79403. * @param name defines the name of the button
  79404. * @param text defines the text of the button
  79405. * @param imageUrl defines the url of the image
  79406. * @returns a new Button
  79407. */
  79408. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79409. /**
  79410. * Creates a new button made with an image
  79411. * @param name defines the name of the button
  79412. * @param imageUrl defines the url of the image
  79413. * @returns a new Button
  79414. */
  79415. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79416. /**
  79417. * Creates a new button made with a text
  79418. * @param name defines the name of the button
  79419. * @param text defines the text of the button
  79420. * @returns a new Button
  79421. */
  79422. static CreateSimpleButton(name: string, text: string): Button;
  79423. /**
  79424. * Creates a new button made with an image and a centered text
  79425. * @param name defines the name of the button
  79426. * @param text defines the text of the button
  79427. * @param imageUrl defines the url of the image
  79428. * @returns a new Button
  79429. */
  79430. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79431. }
  79432. }
  79433. declare module BABYLON.GUI {
  79434. /**
  79435. * Class used to create a 2D stack panel container
  79436. */
  79437. export class StackPanel extends Container {
  79438. name?: string | undefined;
  79439. private _isVertical;
  79440. private _manualWidth;
  79441. private _manualHeight;
  79442. private _doNotTrackManualChanges;
  79443. /**
  79444. * Gets or sets a boolean indicating that layou warnings should be ignored
  79445. */
  79446. ignoreLayoutWarnings: boolean;
  79447. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79448. get isVertical(): boolean;
  79449. set isVertical(value: boolean);
  79450. /**
  79451. * Gets or sets panel width.
  79452. * This value should not be set when in horizontal mode as it will be computed automatically
  79453. */
  79454. set width(value: string | number);
  79455. get width(): string | number;
  79456. /**
  79457. * Gets or sets panel height.
  79458. * This value should not be set when in vertical mode as it will be computed automatically
  79459. */
  79460. set height(value: string | number);
  79461. get height(): string | number;
  79462. /**
  79463. * Creates a new StackPanel
  79464. * @param name defines control name
  79465. */
  79466. constructor(name?: string | undefined);
  79467. protected _getTypeName(): string;
  79468. /** @hidden */
  79469. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79470. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79471. protected _postMeasure(): void;
  79472. }
  79473. }
  79474. declare module BABYLON.GUI {
  79475. /**
  79476. * Class used to represent a 2D checkbox
  79477. */
  79478. export class Checkbox extends Control {
  79479. name?: string | undefined;
  79480. private _isChecked;
  79481. private _background;
  79482. private _checkSizeRatio;
  79483. private _thickness;
  79484. /** Gets or sets border thickness */
  79485. get thickness(): number;
  79486. set thickness(value: number);
  79487. /**
  79488. * BABYLON.Observable raised when isChecked property changes
  79489. */
  79490. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79491. /** Gets or sets a value indicating the ratio between overall size and check size */
  79492. get checkSizeRatio(): number;
  79493. set checkSizeRatio(value: number);
  79494. /** Gets or sets background color */
  79495. get background(): string;
  79496. set background(value: string);
  79497. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79498. get isChecked(): boolean;
  79499. set isChecked(value: boolean);
  79500. /**
  79501. * Creates a new CheckBox
  79502. * @param name defines the control name
  79503. */
  79504. constructor(name?: string | undefined);
  79505. protected _getTypeName(): string;
  79506. /** @hidden */
  79507. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79508. /** @hidden */
  79509. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79510. /**
  79511. * Utility function to easily create a checkbox with a header
  79512. * @param title defines the label to use for the header
  79513. * @param onValueChanged defines the callback to call when value changes
  79514. * @returns a StackPanel containing the checkbox and a textBlock
  79515. */
  79516. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79517. }
  79518. }
  79519. declare module BABYLON.GUI {
  79520. /**
  79521. * Class used to store key control properties
  79522. */
  79523. export class KeyPropertySet {
  79524. /** Width */
  79525. width?: string;
  79526. /** Height */
  79527. height?: string;
  79528. /** Left padding */
  79529. paddingLeft?: string;
  79530. /** Right padding */
  79531. paddingRight?: string;
  79532. /** Top padding */
  79533. paddingTop?: string;
  79534. /** Bottom padding */
  79535. paddingBottom?: string;
  79536. /** Foreground color */
  79537. color?: string;
  79538. /** Background color */
  79539. background?: string;
  79540. }
  79541. /**
  79542. * Class used to create virtual keyboard
  79543. */
  79544. export class VirtualKeyboard extends StackPanel {
  79545. /** BABYLON.Observable raised when a key is pressed */
  79546. onKeyPressObservable: BABYLON.Observable<string>;
  79547. /** Gets or sets default key button width */
  79548. defaultButtonWidth: string;
  79549. /** Gets or sets default key button height */
  79550. defaultButtonHeight: string;
  79551. /** Gets or sets default key button left padding */
  79552. defaultButtonPaddingLeft: string;
  79553. /** Gets or sets default key button right padding */
  79554. defaultButtonPaddingRight: string;
  79555. /** Gets or sets default key button top padding */
  79556. defaultButtonPaddingTop: string;
  79557. /** Gets or sets default key button bottom padding */
  79558. defaultButtonPaddingBottom: string;
  79559. /** Gets or sets default key button foreground color */
  79560. defaultButtonColor: string;
  79561. /** Gets or sets default key button background color */
  79562. defaultButtonBackground: string;
  79563. /** Gets or sets shift button foreground color */
  79564. shiftButtonColor: string;
  79565. /** Gets or sets shift button thickness*/
  79566. selectedShiftThickness: number;
  79567. /** Gets shift key state */
  79568. shiftState: number;
  79569. protected _getTypeName(): string;
  79570. private _createKey;
  79571. /**
  79572. * Adds a new row of keys
  79573. * @param keys defines the list of keys to add
  79574. * @param propertySets defines the associated property sets
  79575. */
  79576. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79577. /**
  79578. * Set the shift key to a specific state
  79579. * @param shiftState defines the new shift state
  79580. */
  79581. applyShiftState(shiftState: number): void;
  79582. private _currentlyConnectedInputText;
  79583. private _connectedInputTexts;
  79584. private _onKeyPressObserver;
  79585. /** Gets the input text control currently attached to the keyboard */
  79586. get connectedInputText(): BABYLON.Nullable<InputText>;
  79587. /**
  79588. * Connects the keyboard with an input text control
  79589. *
  79590. * @param input defines the target control
  79591. */
  79592. connect(input: InputText): void;
  79593. /**
  79594. * Disconnects the keyboard from connected InputText controls
  79595. *
  79596. * @param input optionally defines a target control, otherwise all are disconnected
  79597. */
  79598. disconnect(input?: InputText): void;
  79599. private _removeConnectedInputObservables;
  79600. /**
  79601. * Release all resources
  79602. */
  79603. dispose(): void;
  79604. /**
  79605. * Creates a new keyboard using a default layout
  79606. *
  79607. * @param name defines control name
  79608. * @returns a new VirtualKeyboard
  79609. */
  79610. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79611. }
  79612. }
  79613. declare module BABYLON.GUI {
  79614. /**
  79615. * Class used to create input text control
  79616. */
  79617. export class InputText extends Control implements IFocusableControl {
  79618. name?: string | undefined;
  79619. private _text;
  79620. private _placeholderText;
  79621. private _background;
  79622. private _focusedBackground;
  79623. private _focusedColor;
  79624. private _placeholderColor;
  79625. private _thickness;
  79626. private _margin;
  79627. private _autoStretchWidth;
  79628. private _maxWidth;
  79629. private _isFocused;
  79630. private _blinkTimeout;
  79631. private _blinkIsEven;
  79632. private _cursorOffset;
  79633. private _scrollLeft;
  79634. private _textWidth;
  79635. private _clickedCoordinate;
  79636. private _deadKey;
  79637. private _addKey;
  79638. private _currentKey;
  79639. private _isTextHighlightOn;
  79640. private _textHighlightColor;
  79641. private _highligherOpacity;
  79642. private _highlightedText;
  79643. private _startHighlightIndex;
  79644. private _endHighlightIndex;
  79645. private _cursorIndex;
  79646. private _onFocusSelectAll;
  79647. private _isPointerDown;
  79648. private _onClipboardObserver;
  79649. private _onPointerDblTapObserver;
  79650. /** @hidden */
  79651. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  79652. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  79653. promptMessage: string;
  79654. /** Force disable prompt on mobile device */
  79655. disableMobilePrompt: boolean;
  79656. /** BABYLON.Observable raised when the text changes */
  79657. onTextChangedObservable: BABYLON.Observable<InputText>;
  79658. /** BABYLON.Observable raised just before an entered character is to be added */
  79659. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79660. /** BABYLON.Observable raised when the control gets the focus */
  79661. onFocusObservable: BABYLON.Observable<InputText>;
  79662. /** BABYLON.Observable raised when the control loses the focus */
  79663. onBlurObservable: BABYLON.Observable<InputText>;
  79664. /**Observable raised when the text is highlighted */
  79665. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79666. /**Observable raised when copy event is triggered */
  79667. onTextCopyObservable: BABYLON.Observable<InputText>;
  79668. /** BABYLON.Observable raised when cut event is triggered */
  79669. onTextCutObservable: BABYLON.Observable<InputText>;
  79670. /** BABYLON.Observable raised when paste event is triggered */
  79671. onTextPasteObservable: BABYLON.Observable<InputText>;
  79672. /** BABYLON.Observable raised when a key event was processed */
  79673. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79674. /** Gets or sets the maximum width allowed by the control */
  79675. get maxWidth(): string | number;
  79676. /** Gets the maximum width allowed by the control in pixels */
  79677. get maxWidthInPixels(): number;
  79678. set maxWidth(value: string | number);
  79679. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79680. get highligherOpacity(): number;
  79681. set highligherOpacity(value: number);
  79682. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79683. get onFocusSelectAll(): boolean;
  79684. set onFocusSelectAll(value: boolean);
  79685. /** Gets or sets the text hightlight color */
  79686. get textHighlightColor(): string;
  79687. set textHighlightColor(value: string);
  79688. /** Gets or sets control margin */
  79689. get margin(): string;
  79690. /** Gets control margin in pixels */
  79691. get marginInPixels(): number;
  79692. set margin(value: string);
  79693. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  79694. get autoStretchWidth(): boolean;
  79695. set autoStretchWidth(value: boolean);
  79696. /** Gets or sets border thickness */
  79697. get thickness(): number;
  79698. set thickness(value: number);
  79699. /** Gets or sets the background color when focused */
  79700. get focusedBackground(): string;
  79701. set focusedBackground(value: string);
  79702. /** Gets or sets the background color when focused */
  79703. get focusedColor(): string;
  79704. set focusedColor(value: string);
  79705. /** Gets or sets the background color */
  79706. get background(): string;
  79707. set background(value: string);
  79708. /** Gets or sets the placeholder color */
  79709. get placeholderColor(): string;
  79710. set placeholderColor(value: string);
  79711. /** Gets or sets the text displayed when the control is empty */
  79712. get placeholderText(): string;
  79713. set placeholderText(value: string);
  79714. /** Gets or sets the dead key flag */
  79715. get deadKey(): boolean;
  79716. set deadKey(flag: boolean);
  79717. /** Gets or sets the highlight text */
  79718. get highlightedText(): string;
  79719. set highlightedText(text: string);
  79720. /** Gets or sets if the current key should be added */
  79721. get addKey(): boolean;
  79722. set addKey(flag: boolean);
  79723. /** Gets or sets the value of the current key being entered */
  79724. get currentKey(): string;
  79725. set currentKey(key: string);
  79726. /** Gets or sets the text displayed in the control */
  79727. get text(): string;
  79728. set text(value: string);
  79729. /** Gets or sets control width */
  79730. get width(): string | number;
  79731. set width(value: string | number);
  79732. /**
  79733. * Creates a new InputText
  79734. * @param name defines the control name
  79735. * @param text defines the text of the control
  79736. */
  79737. constructor(name?: string | undefined, text?: string);
  79738. /** @hidden */
  79739. onBlur(): void;
  79740. /** @hidden */
  79741. onFocus(): void;
  79742. protected _getTypeName(): string;
  79743. /**
  79744. * Function called to get the list of controls that should not steal the focus from this control
  79745. * @returns an array of controls
  79746. */
  79747. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  79748. /** @hidden */
  79749. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  79750. /** @hidden */
  79751. private _updateValueFromCursorIndex;
  79752. /** @hidden */
  79753. private _processDblClick;
  79754. /** @hidden */
  79755. private _selectAllText;
  79756. /**
  79757. * Handles the keyboard event
  79758. * @param evt Defines the KeyboardEvent
  79759. */
  79760. processKeyboard(evt: KeyboardEvent): void;
  79761. /** @hidden */
  79762. private _onCopyText;
  79763. /** @hidden */
  79764. private _onCutText;
  79765. /** @hidden */
  79766. private _onPasteText;
  79767. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79768. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79769. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79770. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79771. protected _beforeRenderText(text: string): string;
  79772. dispose(): void;
  79773. }
  79774. }
  79775. declare module BABYLON.GUI {
  79776. /**
  79777. * Class used to create a 2D grid container
  79778. */
  79779. export class Grid extends Container {
  79780. name?: string | undefined;
  79781. private _rowDefinitions;
  79782. private _columnDefinitions;
  79783. private _cells;
  79784. private _childControls;
  79785. /**
  79786. * Gets the number of columns
  79787. */
  79788. get columnCount(): number;
  79789. /**
  79790. * Gets the number of rows
  79791. */
  79792. get rowCount(): number;
  79793. /** Gets the list of children */
  79794. get children(): Control[];
  79795. /** Gets the list of cells (e.g. the containers) */
  79796. get cells(): {
  79797. [key: string]: Container;
  79798. };
  79799. /**
  79800. * Gets the definition of a specific row
  79801. * @param index defines the index of the row
  79802. * @returns the row definition
  79803. */
  79804. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79805. /**
  79806. * Gets the definition of a specific column
  79807. * @param index defines the index of the column
  79808. * @returns the column definition
  79809. */
  79810. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79811. /**
  79812. * Adds a new row to the grid
  79813. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79814. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  79815. * @returns the current grid
  79816. */
  79817. addRowDefinition(height: number, isPixel?: boolean): Grid;
  79818. /**
  79819. * Adds a new column to the grid
  79820. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79821. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79822. * @returns the current grid
  79823. */
  79824. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  79825. /**
  79826. * Update a row definition
  79827. * @param index defines the index of the row to update
  79828. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79829. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  79830. * @returns the current grid
  79831. */
  79832. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  79833. /**
  79834. * Update a column definition
  79835. * @param index defines the index of the column to update
  79836. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79837. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79838. * @returns the current grid
  79839. */
  79840. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  79841. /**
  79842. * Gets the list of children stored in a specific cell
  79843. * @param row defines the row to check
  79844. * @param column defines the column to check
  79845. * @returns the list of controls
  79846. */
  79847. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  79848. /**
  79849. * Gets a string representing the child cell info (row x column)
  79850. * @param child defines the control to get info from
  79851. * @returns a string containing the child cell info (row x column)
  79852. */
  79853. getChildCellInfo(child: Control): string;
  79854. private _removeCell;
  79855. private _offsetCell;
  79856. /**
  79857. * Remove a column definition at specified index
  79858. * @param index defines the index of the column to remove
  79859. * @returns the current grid
  79860. */
  79861. removeColumnDefinition(index: number): Grid;
  79862. /**
  79863. * Remove a row definition at specified index
  79864. * @param index defines the index of the row to remove
  79865. * @returns the current grid
  79866. */
  79867. removeRowDefinition(index: number): Grid;
  79868. /**
  79869. * Adds a new control to the current grid
  79870. * @param control defines the control to add
  79871. * @param row defines the row where to add the control (0 by default)
  79872. * @param column defines the column where to add the control (0 by default)
  79873. * @returns the current grid
  79874. */
  79875. addControl(control: Control, row?: number, column?: number): Grid;
  79876. /**
  79877. * Removes a control from the current container
  79878. * @param control defines the control to remove
  79879. * @returns the current container
  79880. */
  79881. removeControl(control: Control): Container;
  79882. /**
  79883. * Creates a new Grid
  79884. * @param name defines control name
  79885. */
  79886. constructor(name?: string | undefined);
  79887. protected _getTypeName(): string;
  79888. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  79889. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79890. _flagDescendantsAsMatrixDirty(): void;
  79891. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79892. /** Releases associated resources */
  79893. dispose(): void;
  79894. }
  79895. }
  79896. declare module BABYLON.GUI {
  79897. /** Class used to create color pickers */
  79898. export class ColorPicker extends Control {
  79899. name?: string | undefined;
  79900. private static _Epsilon;
  79901. private _colorWheelCanvas;
  79902. private _value;
  79903. private _tmpColor;
  79904. private _pointerStartedOnSquare;
  79905. private _pointerStartedOnWheel;
  79906. private _squareLeft;
  79907. private _squareTop;
  79908. private _squareSize;
  79909. private _h;
  79910. private _s;
  79911. private _v;
  79912. private _lastPointerDownID;
  79913. /**
  79914. * BABYLON.Observable raised when the value changes
  79915. */
  79916. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  79917. /** Gets or sets the color of the color picker */
  79918. get value(): BABYLON.Color3;
  79919. set value(value: BABYLON.Color3);
  79920. /**
  79921. * Gets or sets control width
  79922. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79923. */
  79924. get width(): string | number;
  79925. set width(value: string | number);
  79926. /**
  79927. * Gets or sets control height
  79928. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79929. */
  79930. get height(): string | number;
  79931. /** Gets or sets control height */
  79932. set height(value: string | number);
  79933. /** Gets or sets control size */
  79934. get size(): string | number;
  79935. set size(value: string | number);
  79936. /**
  79937. * Creates a new ColorPicker
  79938. * @param name defines the control name
  79939. */
  79940. constructor(name?: string | undefined);
  79941. protected _getTypeName(): string;
  79942. /** @hidden */
  79943. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79944. private _updateSquareProps;
  79945. private _drawGradientSquare;
  79946. private _drawCircle;
  79947. private _createColorWheelCanvas;
  79948. /** @hidden */
  79949. _draw(context: CanvasRenderingContext2D): void;
  79950. private _pointerIsDown;
  79951. private _updateValueFromPointer;
  79952. private _isPointOnSquare;
  79953. private _isPointOnWheel;
  79954. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79955. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79956. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79957. _onCanvasBlur(): void;
  79958. /**
  79959. * This function expands the color picker by creating a color picker dialog with manual
  79960. * color value input and the ability to save colors into an array to be used later in
  79961. * subsequent launches of the dialogue.
  79962. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  79963. * @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.
  79964. * @returns picked color as a hex string and the saved colors array as hex strings.
  79965. */
  79966. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  79967. pickerWidth?: string;
  79968. pickerHeight?: string;
  79969. headerHeight?: string;
  79970. lastColor?: string;
  79971. swatchLimit?: number;
  79972. numSwatchesPerLine?: number;
  79973. savedColors?: Array<string>;
  79974. }): Promise<{
  79975. savedColors?: string[];
  79976. pickedColor: string;
  79977. }>;
  79978. }
  79979. }
  79980. declare module BABYLON.GUI {
  79981. /** Class used to create 2D ellipse containers */
  79982. export class Ellipse extends Container {
  79983. name?: string | undefined;
  79984. private _thickness;
  79985. /** Gets or sets border thickness */
  79986. get thickness(): number;
  79987. set thickness(value: number);
  79988. /**
  79989. * Creates a new Ellipse
  79990. * @param name defines the control name
  79991. */
  79992. constructor(name?: string | undefined);
  79993. protected _getTypeName(): string;
  79994. protected _localDraw(context: CanvasRenderingContext2D): void;
  79995. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79996. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79997. }
  79998. }
  79999. declare module BABYLON.GUI {
  80000. /**
  80001. * Class used to create a password control
  80002. */
  80003. export class InputPassword extends InputText {
  80004. protected _beforeRenderText(text: string): string;
  80005. }
  80006. }
  80007. declare module BABYLON.GUI {
  80008. /** Class used to render 2D lines */
  80009. export class Line extends Control {
  80010. name?: string | undefined;
  80011. private _lineWidth;
  80012. private _x1;
  80013. private _y1;
  80014. private _x2;
  80015. private _y2;
  80016. private _dash;
  80017. private _connectedControl;
  80018. private _connectedControlDirtyObserver;
  80019. /** Gets or sets the dash pattern */
  80020. get dash(): Array<number>;
  80021. set dash(value: Array<number>);
  80022. /** Gets or sets the control connected with the line end */
  80023. get connectedControl(): Control;
  80024. set connectedControl(value: Control);
  80025. /** Gets or sets start coordinates on X axis */
  80026. get x1(): string | number;
  80027. set x1(value: string | number);
  80028. /** Gets or sets start coordinates on Y axis */
  80029. get y1(): string | number;
  80030. set y1(value: string | number);
  80031. /** Gets or sets end coordinates on X axis */
  80032. get x2(): string | number;
  80033. set x2(value: string | number);
  80034. /** Gets or sets end coordinates on Y axis */
  80035. get y2(): string | number;
  80036. set y2(value: string | number);
  80037. /** Gets or sets line width */
  80038. get lineWidth(): number;
  80039. set lineWidth(value: number);
  80040. /** Gets or sets horizontal alignment */
  80041. set horizontalAlignment(value: number);
  80042. /** Gets or sets vertical alignment */
  80043. set verticalAlignment(value: number);
  80044. private get _effectiveX2();
  80045. private get _effectiveY2();
  80046. /**
  80047. * Creates a new Line
  80048. * @param name defines the control name
  80049. */
  80050. constructor(name?: string | undefined);
  80051. protected _getTypeName(): string;
  80052. _draw(context: CanvasRenderingContext2D): void;
  80053. _measure(): void;
  80054. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80055. /**
  80056. * Move one end of the line given 3D cartesian coordinates.
  80057. * @param position Targeted world position
  80058. * @param scene BABYLON.Scene
  80059. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80060. */
  80061. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  80062. /**
  80063. * Move one end of the line to a position in screen absolute space.
  80064. * @param projectedPosition Position in screen absolute space (X, Y)
  80065. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80066. */
  80067. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  80068. }
  80069. }
  80070. declare module BABYLON.GUI {
  80071. /**
  80072. * Class used to store a point for a MultiLine object.
  80073. * The point can be pure 2D coordinates, a mesh or a control
  80074. */
  80075. export class MultiLinePoint {
  80076. private _multiLine;
  80077. private _x;
  80078. private _y;
  80079. private _control;
  80080. private _mesh;
  80081. private _controlObserver;
  80082. private _meshObserver;
  80083. /** @hidden */
  80084. _point: BABYLON.Vector2;
  80085. /**
  80086. * Creates a new MultiLinePoint
  80087. * @param multiLine defines the source MultiLine object
  80088. */
  80089. constructor(multiLine: MultiLine);
  80090. /** Gets or sets x coordinate */
  80091. get x(): string | number;
  80092. set x(value: string | number);
  80093. /** Gets or sets y coordinate */
  80094. get y(): string | number;
  80095. set y(value: string | number);
  80096. /** Gets or sets the control associated with this point */
  80097. get control(): BABYLON.Nullable<Control>;
  80098. set control(value: BABYLON.Nullable<Control>);
  80099. /** Gets or sets the mesh associated with this point */
  80100. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80101. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  80102. /** Resets links */
  80103. resetLinks(): void;
  80104. /**
  80105. * Gets a translation vector
  80106. * @returns the translation vector
  80107. */
  80108. translate(): BABYLON.Vector2;
  80109. private _translatePoint;
  80110. /** Release associated resources */
  80111. dispose(): void;
  80112. }
  80113. }
  80114. declare module BABYLON.GUI {
  80115. /**
  80116. * Class used to create multi line control
  80117. */
  80118. export class MultiLine extends Control {
  80119. name?: string | undefined;
  80120. private _lineWidth;
  80121. private _dash;
  80122. private _points;
  80123. private _minX;
  80124. private _minY;
  80125. private _maxX;
  80126. private _maxY;
  80127. /**
  80128. * Creates a new MultiLine
  80129. * @param name defines the control name
  80130. */
  80131. constructor(name?: string | undefined);
  80132. /** Gets or sets dash pattern */
  80133. get dash(): Array<number>;
  80134. set dash(value: Array<number>);
  80135. /**
  80136. * Gets point stored at specified index
  80137. * @param index defines the index to look for
  80138. * @returns the requested point if found
  80139. */
  80140. getAt(index: number): MultiLinePoint;
  80141. /** Function called when a point is updated */
  80142. onPointUpdate: () => void;
  80143. /**
  80144. * Adds new points to the point collection
  80145. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  80146. * @returns the list of created MultiLinePoint
  80147. */
  80148. add(...items: (AbstractMesh | Control | {
  80149. x: string | number;
  80150. y: string | number;
  80151. })[]): MultiLinePoint[];
  80152. /**
  80153. * Adds a new point to the point collection
  80154. * @param item defines the item (mesh, control or 2d coordiantes) to add
  80155. * @returns the created MultiLinePoint
  80156. */
  80157. push(item?: (AbstractMesh | Control | {
  80158. x: string | number;
  80159. y: string | number;
  80160. })): MultiLinePoint;
  80161. /**
  80162. * Remove a specific value or point from the active point collection
  80163. * @param value defines the value or point to remove
  80164. */
  80165. remove(value: number | MultiLinePoint): void;
  80166. /**
  80167. * Resets this object to initial state (no point)
  80168. */
  80169. reset(): void;
  80170. /**
  80171. * Resets all links
  80172. */
  80173. resetLinks(): void;
  80174. /** Gets or sets line width */
  80175. get lineWidth(): number;
  80176. set lineWidth(value: number);
  80177. set horizontalAlignment(value: number);
  80178. set verticalAlignment(value: number);
  80179. protected _getTypeName(): string;
  80180. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80181. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80182. _measure(): void;
  80183. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80184. dispose(): void;
  80185. }
  80186. }
  80187. declare module BABYLON.GUI {
  80188. /**
  80189. * Class used to create radio button controls
  80190. */
  80191. export class RadioButton extends Control {
  80192. name?: string | undefined;
  80193. private _isChecked;
  80194. private _background;
  80195. private _checkSizeRatio;
  80196. private _thickness;
  80197. /** Gets or sets border thickness */
  80198. get thickness(): number;
  80199. set thickness(value: number);
  80200. /** Gets or sets group name */
  80201. group: string;
  80202. /** BABYLON.Observable raised when isChecked is changed */
  80203. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80204. /** Gets or sets a value indicating the ratio between overall size and check size */
  80205. get checkSizeRatio(): number;
  80206. set checkSizeRatio(value: number);
  80207. /** Gets or sets background color */
  80208. get background(): string;
  80209. set background(value: string);
  80210. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80211. get isChecked(): boolean;
  80212. set isChecked(value: boolean);
  80213. /**
  80214. * Creates a new RadioButton
  80215. * @param name defines the control name
  80216. */
  80217. constructor(name?: string | undefined);
  80218. protected _getTypeName(): string;
  80219. _draw(context: CanvasRenderingContext2D): void;
  80220. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80221. /**
  80222. * Utility function to easily create a radio button with a header
  80223. * @param title defines the label to use for the header
  80224. * @param group defines the group to use for the radio button
  80225. * @param isChecked defines the initial state of the radio button
  80226. * @param onValueChanged defines the callback to call when value changes
  80227. * @returns a StackPanel containing the radio button and a textBlock
  80228. */
  80229. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80230. }
  80231. }
  80232. declare module BABYLON.GUI {
  80233. /**
  80234. * Class used to create slider controls
  80235. */
  80236. export class BaseSlider extends Control {
  80237. name?: string | undefined;
  80238. protected _thumbWidth: ValueAndUnit;
  80239. private _minimum;
  80240. private _maximum;
  80241. private _value;
  80242. private _isVertical;
  80243. protected _barOffset: ValueAndUnit;
  80244. private _isThumbClamped;
  80245. protected _displayThumb: boolean;
  80246. private _step;
  80247. private _lastPointerDownID;
  80248. protected _effectiveBarOffset: number;
  80249. protected _renderLeft: number;
  80250. protected _renderTop: number;
  80251. protected _renderWidth: number;
  80252. protected _renderHeight: number;
  80253. protected _backgroundBoxLength: number;
  80254. protected _backgroundBoxThickness: number;
  80255. protected _effectiveThumbThickness: number;
  80256. /** BABYLON.Observable raised when the sldier value changes */
  80257. onValueChangedObservable: BABYLON.Observable<number>;
  80258. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80259. get displayThumb(): boolean;
  80260. set displayThumb(value: boolean);
  80261. /** Gets or sets a step to apply to values (0 by default) */
  80262. get step(): number;
  80263. set step(value: number);
  80264. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80265. get barOffset(): string | number;
  80266. /** Gets main bar offset in pixels*/
  80267. get barOffsetInPixels(): number;
  80268. set barOffset(value: string | number);
  80269. /** Gets or sets thumb width */
  80270. get thumbWidth(): string | number;
  80271. /** Gets thumb width in pixels */
  80272. get thumbWidthInPixels(): number;
  80273. set thumbWidth(value: string | number);
  80274. /** Gets or sets minimum value */
  80275. get minimum(): number;
  80276. set minimum(value: number);
  80277. /** Gets or sets maximum value */
  80278. get maximum(): number;
  80279. set maximum(value: number);
  80280. /** Gets or sets current value */
  80281. get value(): number;
  80282. set value(value: number);
  80283. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80284. get isVertical(): boolean;
  80285. set isVertical(value: boolean);
  80286. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80287. get isThumbClamped(): boolean;
  80288. set isThumbClamped(value: boolean);
  80289. /**
  80290. * Creates a new BaseSlider
  80291. * @param name defines the control name
  80292. */
  80293. constructor(name?: string | undefined);
  80294. protected _getTypeName(): string;
  80295. protected _getThumbPosition(): number;
  80296. protected _getThumbThickness(type: string): number;
  80297. protected _prepareRenderingData(type: string): void;
  80298. private _pointerIsDown;
  80299. /** @hidden */
  80300. protected _updateValueFromPointer(x: number, y: number): void;
  80301. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80302. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80303. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80304. _onCanvasBlur(): void;
  80305. }
  80306. }
  80307. declare module BABYLON.GUI {
  80308. /**
  80309. * Class used to create slider controls
  80310. */
  80311. export class Slider extends BaseSlider {
  80312. name?: string | undefined;
  80313. private _background;
  80314. private _borderColor;
  80315. private _thumbColor;
  80316. private _isThumbCircle;
  80317. protected _displayValueBar: boolean;
  80318. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80319. get displayValueBar(): boolean;
  80320. set displayValueBar(value: boolean);
  80321. /** Gets or sets border color */
  80322. get borderColor(): string;
  80323. set borderColor(value: string);
  80324. /** Gets or sets background color */
  80325. get background(): string;
  80326. set background(value: string);
  80327. /** Gets or sets thumb's color */
  80328. get thumbColor(): string;
  80329. set thumbColor(value: string);
  80330. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80331. get isThumbCircle(): boolean;
  80332. set isThumbCircle(value: boolean);
  80333. /**
  80334. * Creates a new Slider
  80335. * @param name defines the control name
  80336. */
  80337. constructor(name?: string | undefined);
  80338. protected _getTypeName(): string;
  80339. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80340. }
  80341. }
  80342. declare module BABYLON.GUI {
  80343. /** Class used to create a RadioGroup
  80344. * which contains groups of radio buttons
  80345. */
  80346. export class SelectorGroup {
  80347. /** name of SelectorGroup */
  80348. name: string;
  80349. private _groupPanel;
  80350. private _selectors;
  80351. private _groupHeader;
  80352. /**
  80353. * Creates a new SelectorGroup
  80354. * @param name of group, used as a group heading
  80355. */
  80356. constructor(
  80357. /** name of SelectorGroup */
  80358. name: string);
  80359. /** Gets the groupPanel of the SelectorGroup */
  80360. get groupPanel(): StackPanel;
  80361. /** Gets the selectors array */
  80362. get selectors(): StackPanel[];
  80363. /** Gets and sets the group header */
  80364. get header(): string;
  80365. set header(label: string);
  80366. /** @hidden */
  80367. private _addGroupHeader;
  80368. /** @hidden*/
  80369. _getSelector(selectorNb: number): StackPanel | undefined;
  80370. /** Removes the selector at the given position
  80371. * @param selectorNb the position of the selector within the group
  80372. */
  80373. removeSelector(selectorNb: number): void;
  80374. }
  80375. /** Class used to create a CheckboxGroup
  80376. * which contains groups of checkbox buttons
  80377. */
  80378. export class CheckboxGroup extends SelectorGroup {
  80379. /** Adds a checkbox as a control
  80380. * @param text is the label for the selector
  80381. * @param func is the function called when the Selector is checked
  80382. * @param checked is true when Selector is checked
  80383. */
  80384. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80385. /** @hidden */
  80386. _setSelectorLabel(selectorNb: number, label: string): void;
  80387. /** @hidden */
  80388. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80389. /** @hidden */
  80390. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80391. /** @hidden */
  80392. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80393. }
  80394. /** Class used to create a RadioGroup
  80395. * which contains groups of radio buttons
  80396. */
  80397. export class RadioGroup extends SelectorGroup {
  80398. private _selectNb;
  80399. /** Adds a radio button as a control
  80400. * @param label is the label for the selector
  80401. * @param func is the function called when the Selector is checked
  80402. * @param checked is true when Selector is checked
  80403. */
  80404. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80405. /** @hidden */
  80406. _setSelectorLabel(selectorNb: number, label: string): void;
  80407. /** @hidden */
  80408. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80409. /** @hidden */
  80410. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80411. /** @hidden */
  80412. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80413. }
  80414. /** Class used to create a SliderGroup
  80415. * which contains groups of slider buttons
  80416. */
  80417. export class SliderGroup extends SelectorGroup {
  80418. /**
  80419. * Adds a slider to the SelectorGroup
  80420. * @param label is the label for the SliderBar
  80421. * @param func is the function called when the Slider moves
  80422. * @param unit is a string describing the units used, eg degrees or metres
  80423. * @param min is the minimum value for the Slider
  80424. * @param max is the maximum value for the Slider
  80425. * @param value is the start value for the Slider between min and max
  80426. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80427. */
  80428. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80429. /** @hidden */
  80430. _setSelectorLabel(selectorNb: number, label: string): void;
  80431. /** @hidden */
  80432. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80433. /** @hidden */
  80434. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80435. /** @hidden */
  80436. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80437. }
  80438. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80439. * @see https://doc.babylonjs.com/how_to/selector
  80440. */
  80441. export class SelectionPanel extends Rectangle {
  80442. /** name of SelectionPanel */
  80443. name: string;
  80444. /** an array of SelectionGroups */
  80445. groups: SelectorGroup[];
  80446. private _panel;
  80447. private _buttonColor;
  80448. private _buttonBackground;
  80449. private _headerColor;
  80450. private _barColor;
  80451. private _barHeight;
  80452. private _spacerHeight;
  80453. private _labelColor;
  80454. private _groups;
  80455. private _bars;
  80456. /**
  80457. * Creates a new SelectionPanel
  80458. * @param name of SelectionPanel
  80459. * @param groups is an array of SelectionGroups
  80460. */
  80461. constructor(
  80462. /** name of SelectionPanel */
  80463. name: string,
  80464. /** an array of SelectionGroups */
  80465. groups?: SelectorGroup[]);
  80466. protected _getTypeName(): string;
  80467. /** Gets the (stack) panel of the SelectionPanel */
  80468. get panel(): StackPanel;
  80469. /** Gets or sets the headerColor */
  80470. get headerColor(): string;
  80471. set headerColor(color: string);
  80472. private _setHeaderColor;
  80473. /** Gets or sets the button color */
  80474. get buttonColor(): string;
  80475. set buttonColor(color: string);
  80476. private _setbuttonColor;
  80477. /** Gets or sets the label color */
  80478. get labelColor(): string;
  80479. set labelColor(color: string);
  80480. private _setLabelColor;
  80481. /** Gets or sets the button background */
  80482. get buttonBackground(): string;
  80483. set buttonBackground(color: string);
  80484. private _setButtonBackground;
  80485. /** Gets or sets the color of separator bar */
  80486. get barColor(): string;
  80487. set barColor(color: string);
  80488. private _setBarColor;
  80489. /** Gets or sets the height of separator bar */
  80490. get barHeight(): string;
  80491. set barHeight(value: string);
  80492. private _setBarHeight;
  80493. /** Gets or sets the height of spacers*/
  80494. get spacerHeight(): string;
  80495. set spacerHeight(value: string);
  80496. private _setSpacerHeight;
  80497. /** Adds a bar between groups */
  80498. private _addSpacer;
  80499. /** Add a group to the selection panel
  80500. * @param group is the selector group to add
  80501. */
  80502. addGroup(group: SelectorGroup): void;
  80503. /** Remove the group from the given position
  80504. * @param groupNb is the position of the group in the list
  80505. */
  80506. removeGroup(groupNb: number): void;
  80507. /** Change a group header label
  80508. * @param label is the new group header label
  80509. * @param groupNb is the number of the group to relabel
  80510. * */
  80511. setHeaderName(label: string, groupNb: number): void;
  80512. /** Change selector label to the one given
  80513. * @param label is the new selector label
  80514. * @param groupNb is the number of the groupcontaining the selector
  80515. * @param selectorNb is the number of the selector within a group to relabel
  80516. * */
  80517. relabel(label: string, groupNb: number, selectorNb: number): void;
  80518. /** For a given group position remove the selector at the given position
  80519. * @param groupNb is the number of the group to remove the selector from
  80520. * @param selectorNb is the number of the selector within the group
  80521. */
  80522. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80523. /** For a given group position of correct type add a checkbox button
  80524. * @param groupNb is the number of the group to remove the selector from
  80525. * @param label is the label for the selector
  80526. * @param func is the function called when the Selector is checked
  80527. * @param checked is true when Selector is checked
  80528. */
  80529. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80530. /** For a given group position of correct type add a radio button
  80531. * @param groupNb is the number of the group to remove the selector from
  80532. * @param label is the label for the selector
  80533. * @param func is the function called when the Selector is checked
  80534. * @param checked is true when Selector is checked
  80535. */
  80536. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80537. /**
  80538. * For a given slider group add a slider
  80539. * @param groupNb is the number of the group to add the slider to
  80540. * @param label is the label for the Slider
  80541. * @param func is the function called when the Slider moves
  80542. * @param unit is a string describing the units used, eg degrees or metres
  80543. * @param min is the minimum value for the Slider
  80544. * @param max is the maximum value for the Slider
  80545. * @param value is the start value for the Slider between min and max
  80546. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80547. */
  80548. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80549. }
  80550. }
  80551. declare module BABYLON.GUI {
  80552. /**
  80553. * Class used to hold a the container for ScrollViewer
  80554. * @hidden
  80555. */
  80556. export class _ScrollViewerWindow extends Container {
  80557. parentClientWidth: number;
  80558. parentClientHeight: number;
  80559. private _freezeControls;
  80560. private _parentMeasure;
  80561. private _oldLeft;
  80562. private _oldTop;
  80563. get freezeControls(): boolean;
  80564. set freezeControls(value: boolean);
  80565. private _bucketWidth;
  80566. private _bucketHeight;
  80567. private _buckets;
  80568. private _bucketLen;
  80569. get bucketWidth(): number;
  80570. get bucketHeight(): number;
  80571. setBucketSizes(width: number, height: number): void;
  80572. private _useBuckets;
  80573. private _makeBuckets;
  80574. private _dispatchInBuckets;
  80575. private _updateMeasures;
  80576. private _updateChildrenMeasures;
  80577. private _restoreMeasures;
  80578. /**
  80579. * Creates a new ScrollViewerWindow
  80580. * @param name of ScrollViewerWindow
  80581. */
  80582. constructor(name?: string);
  80583. protected _getTypeName(): string;
  80584. /** @hidden */
  80585. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80586. /** @hidden */
  80587. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  80588. private _scrollChildren;
  80589. private _scrollChildrenWithBuckets;
  80590. /** @hidden */
  80591. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  80592. protected _postMeasure(): void;
  80593. }
  80594. }
  80595. declare module BABYLON.GUI {
  80596. /**
  80597. * Class used to create slider controls
  80598. */
  80599. export class ScrollBar extends BaseSlider {
  80600. name?: string | undefined;
  80601. private _background;
  80602. private _borderColor;
  80603. private _tempMeasure;
  80604. /** Gets or sets border color */
  80605. get borderColor(): string;
  80606. set borderColor(value: string);
  80607. /** Gets or sets background color */
  80608. get background(): string;
  80609. set background(value: string);
  80610. /**
  80611. * Creates a new Slider
  80612. * @param name defines the control name
  80613. */
  80614. constructor(name?: string | undefined);
  80615. protected _getTypeName(): string;
  80616. protected _getThumbThickness(): number;
  80617. _draw(context: CanvasRenderingContext2D): void;
  80618. private _first;
  80619. private _originX;
  80620. private _originY;
  80621. /** @hidden */
  80622. protected _updateValueFromPointer(x: number, y: number): void;
  80623. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80624. }
  80625. }
  80626. declare module BABYLON.GUI {
  80627. /**
  80628. * Class used to create slider controls
  80629. */
  80630. export class ImageScrollBar extends BaseSlider {
  80631. name?: string | undefined;
  80632. private _backgroundBaseImage;
  80633. private _backgroundImage;
  80634. private _thumbImage;
  80635. private _thumbBaseImage;
  80636. private _thumbLength;
  80637. private _thumbHeight;
  80638. private _barImageHeight;
  80639. private _tempMeasure;
  80640. /** Number of 90° rotation to apply on the images when in vertical mode */
  80641. num90RotationInVerticalMode: number;
  80642. /**
  80643. * Gets or sets the image used to render the background for horizontal bar
  80644. */
  80645. get backgroundImage(): Image;
  80646. set backgroundImage(value: Image);
  80647. /**
  80648. * Gets or sets the image used to render the thumb
  80649. */
  80650. get thumbImage(): Image;
  80651. set thumbImage(value: Image);
  80652. /**
  80653. * Gets or sets the length of the thumb
  80654. */
  80655. get thumbLength(): number;
  80656. set thumbLength(value: number);
  80657. /**
  80658. * Gets or sets the height of the thumb
  80659. */
  80660. get thumbHeight(): number;
  80661. set thumbHeight(value: number);
  80662. /**
  80663. * Gets or sets the height of the bar image
  80664. */
  80665. get barImageHeight(): number;
  80666. set barImageHeight(value: number);
  80667. /**
  80668. * Creates a new ImageScrollBar
  80669. * @param name defines the control name
  80670. */
  80671. constructor(name?: string | undefined);
  80672. protected _getTypeName(): string;
  80673. protected _getThumbThickness(): number;
  80674. _draw(context: CanvasRenderingContext2D): void;
  80675. private _first;
  80676. private _originX;
  80677. private _originY;
  80678. /** @hidden */
  80679. protected _updateValueFromPointer(x: number, y: number): void;
  80680. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80681. }
  80682. }
  80683. declare module BABYLON.GUI {
  80684. /**
  80685. * Class used to hold a viewer window and sliders in a grid
  80686. */
  80687. export class ScrollViewer extends Rectangle {
  80688. private _grid;
  80689. private _horizontalBarSpace;
  80690. private _verticalBarSpace;
  80691. private _dragSpace;
  80692. private _horizontalBar;
  80693. private _verticalBar;
  80694. private _barColor;
  80695. private _barBackground;
  80696. private _barImage;
  80697. private _horizontalBarImage;
  80698. private _verticalBarImage;
  80699. private _barBackgroundImage;
  80700. private _horizontalBarBackgroundImage;
  80701. private _verticalBarBackgroundImage;
  80702. private _barSize;
  80703. private _window;
  80704. private _pointerIsOver;
  80705. private _wheelPrecision;
  80706. private _onWheelObserver;
  80707. private _clientWidth;
  80708. private _clientHeight;
  80709. private _useImageBar;
  80710. private _thumbLength;
  80711. private _thumbHeight;
  80712. private _barImageHeight;
  80713. private _horizontalBarImageHeight;
  80714. private _verticalBarImageHeight;
  80715. private _oldWindowContentsWidth;
  80716. private _oldWindowContentsHeight;
  80717. /**
  80718. * Gets the horizontal scrollbar
  80719. */
  80720. get horizontalBar(): ScrollBar | ImageScrollBar;
  80721. /**
  80722. * Gets the vertical scrollbar
  80723. */
  80724. get verticalBar(): ScrollBar | ImageScrollBar;
  80725. /**
  80726. * Adds a new control to the current container
  80727. * @param control defines the control to add
  80728. * @returns the current container
  80729. */
  80730. addControl(control: BABYLON.Nullable<Control>): Container;
  80731. /**
  80732. * Removes a control from the current container
  80733. * @param control defines the control to remove
  80734. * @returns the current container
  80735. */
  80736. removeControl(control: Control): Container;
  80737. /** Gets the list of children */
  80738. get children(): Control[];
  80739. _flagDescendantsAsMatrixDirty(): void;
  80740. /**
  80741. * Freezes or unfreezes the controls in the window.
  80742. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  80743. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  80744. */
  80745. get freezeControls(): boolean;
  80746. set freezeControls(value: boolean);
  80747. /** Gets the bucket width */
  80748. get bucketWidth(): number;
  80749. /** Gets the bucket height */
  80750. get bucketHeight(): number;
  80751. /**
  80752. * Sets the bucket sizes.
  80753. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  80754. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  80755. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  80756. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  80757. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  80758. * used), that's why it is not enabled by default.
  80759. * @param width width of the bucket
  80760. * @param height height of the bucket
  80761. */
  80762. setBucketSizes(width: number, height: number): void;
  80763. private _forceHorizontalBar;
  80764. private _forceVerticalBar;
  80765. /**
  80766. * Forces the horizontal scroll bar to be displayed
  80767. */
  80768. get forceHorizontalBar(): boolean;
  80769. set forceHorizontalBar(value: boolean);
  80770. /**
  80771. * Forces the vertical scroll bar to be displayed
  80772. */
  80773. get forceVerticalBar(): boolean;
  80774. set forceVerticalBar(value: boolean);
  80775. /**
  80776. * Creates a new ScrollViewer
  80777. * @param name of ScrollViewer
  80778. */
  80779. constructor(name?: string, isImageBased?: boolean);
  80780. /** Reset the scroll viewer window to initial size */
  80781. resetWindow(): void;
  80782. protected _getTypeName(): string;
  80783. private _buildClientSizes;
  80784. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80785. protected _postMeasure(): void;
  80786. /**
  80787. * Gets or sets the mouse wheel precision
  80788. * from 0 to 1 with a default value of 0.05
  80789. * */
  80790. get wheelPrecision(): number;
  80791. set wheelPrecision(value: number);
  80792. /** Gets or sets the scroll bar container background color */
  80793. get scrollBackground(): string;
  80794. set scrollBackground(color: string);
  80795. /** Gets or sets the bar color */
  80796. get barColor(): string;
  80797. set barColor(color: string);
  80798. /** Gets or sets the bar image */
  80799. get thumbImage(): Image;
  80800. set thumbImage(value: Image);
  80801. /** Gets or sets the horizontal bar image */
  80802. get horizontalThumbImage(): Image;
  80803. set horizontalThumbImage(value: Image);
  80804. /** Gets or sets the vertical bar image */
  80805. get verticalThumbImage(): Image;
  80806. set verticalThumbImage(value: Image);
  80807. /** Gets or sets the size of the bar */
  80808. get barSize(): number;
  80809. set barSize(value: number);
  80810. /** Gets or sets the length of the thumb */
  80811. get thumbLength(): number;
  80812. set thumbLength(value: number);
  80813. /** Gets or sets the height of the thumb */
  80814. get thumbHeight(): number;
  80815. set thumbHeight(value: number);
  80816. /** Gets or sets the height of the bar image */
  80817. get barImageHeight(): number;
  80818. set barImageHeight(value: number);
  80819. /** Gets or sets the height of the horizontal bar image */
  80820. get horizontalBarImageHeight(): number;
  80821. set horizontalBarImageHeight(value: number);
  80822. /** Gets or sets the height of the vertical bar image */
  80823. get verticalBarImageHeight(): number;
  80824. set verticalBarImageHeight(value: number);
  80825. /** Gets or sets the bar background */
  80826. get barBackground(): string;
  80827. set barBackground(color: string);
  80828. /** Gets or sets the bar background image */
  80829. get barImage(): Image;
  80830. set barImage(value: Image);
  80831. /** Gets or sets the horizontal bar background image */
  80832. get horizontalBarImage(): Image;
  80833. set horizontalBarImage(value: Image);
  80834. /** Gets or sets the vertical bar background image */
  80835. get verticalBarImage(): Image;
  80836. set verticalBarImage(value: Image);
  80837. private _setWindowPosition;
  80838. /** @hidden */
  80839. private _updateScroller;
  80840. _link(host: AdvancedDynamicTexture): void;
  80841. /** @hidden */
  80842. private _addBar;
  80843. /** @hidden */
  80844. private _attachWheel;
  80845. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80846. /** Releases associated resources */
  80847. dispose(): void;
  80848. }
  80849. }
  80850. declare module BABYLON.GUI {
  80851. /** Class used to render a grid */
  80852. export class DisplayGrid extends Control {
  80853. name?: string | undefined;
  80854. private _cellWidth;
  80855. private _cellHeight;
  80856. private _minorLineTickness;
  80857. private _minorLineColor;
  80858. private _majorLineTickness;
  80859. private _majorLineColor;
  80860. private _majorLineFrequency;
  80861. private _background;
  80862. private _displayMajorLines;
  80863. private _displayMinorLines;
  80864. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  80865. get displayMinorLines(): boolean;
  80866. set displayMinorLines(value: boolean);
  80867. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  80868. get displayMajorLines(): boolean;
  80869. set displayMajorLines(value: boolean);
  80870. /** Gets or sets background color (Black by default) */
  80871. get background(): string;
  80872. set background(value: string);
  80873. /** Gets or sets the width of each cell (20 by default) */
  80874. get cellWidth(): number;
  80875. set cellWidth(value: number);
  80876. /** Gets or sets the height of each cell (20 by default) */
  80877. get cellHeight(): number;
  80878. set cellHeight(value: number);
  80879. /** Gets or sets the tickness of minor lines (1 by default) */
  80880. get minorLineTickness(): number;
  80881. set minorLineTickness(value: number);
  80882. /** Gets or sets the color of minor lines (DarkGray by default) */
  80883. get minorLineColor(): string;
  80884. set minorLineColor(value: string);
  80885. /** Gets or sets the tickness of major lines (2 by default) */
  80886. get majorLineTickness(): number;
  80887. set majorLineTickness(value: number);
  80888. /** Gets or sets the color of major lines (White by default) */
  80889. get majorLineColor(): string;
  80890. set majorLineColor(value: string);
  80891. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  80892. get majorLineFrequency(): number;
  80893. set majorLineFrequency(value: number);
  80894. /**
  80895. * Creates a new GridDisplayRectangle
  80896. * @param name defines the control name
  80897. */
  80898. constructor(name?: string | undefined);
  80899. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80900. protected _getTypeName(): string;
  80901. }
  80902. }
  80903. declare module BABYLON.GUI {
  80904. /**
  80905. * Class used to create slider controls based on images
  80906. */
  80907. export class ImageBasedSlider extends BaseSlider {
  80908. name?: string | undefined;
  80909. private _backgroundImage;
  80910. private _thumbImage;
  80911. private _valueBarImage;
  80912. private _tempMeasure;
  80913. get displayThumb(): boolean;
  80914. set displayThumb(value: boolean);
  80915. /**
  80916. * Gets or sets the image used to render the background
  80917. */
  80918. get backgroundImage(): Image;
  80919. set backgroundImage(value: Image);
  80920. /**
  80921. * Gets or sets the image used to render the value bar
  80922. */
  80923. get valueBarImage(): Image;
  80924. set valueBarImage(value: Image);
  80925. /**
  80926. * Gets or sets the image used to render the thumb
  80927. */
  80928. get thumbImage(): Image;
  80929. set thumbImage(value: Image);
  80930. /**
  80931. * Creates a new ImageBasedSlider
  80932. * @param name defines the control name
  80933. */
  80934. constructor(name?: string | undefined);
  80935. protected _getTypeName(): string;
  80936. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80937. }
  80938. }
  80939. declare module BABYLON.GUI {
  80940. /**
  80941. * Forcing an export so that this code will execute
  80942. * @hidden
  80943. */
  80944. const name = "Statics";
  80945. }
  80946. declare module BABYLON.GUI {
  80947. /**
  80948. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  80949. */
  80950. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  80951. /**
  80952. * Define the instrumented AdvancedDynamicTexture.
  80953. */
  80954. texture: AdvancedDynamicTexture;
  80955. private _captureRenderTime;
  80956. private _renderTime;
  80957. private _captureLayoutTime;
  80958. private _layoutTime;
  80959. private _onBeginRenderObserver;
  80960. private _onEndRenderObserver;
  80961. private _onBeginLayoutObserver;
  80962. private _onEndLayoutObserver;
  80963. /**
  80964. * Gets the perf counter used to capture render time
  80965. */
  80966. get renderTimeCounter(): BABYLON.PerfCounter;
  80967. /**
  80968. * Gets the perf counter used to capture layout time
  80969. */
  80970. get layoutTimeCounter(): BABYLON.PerfCounter;
  80971. /**
  80972. * Enable or disable the render time capture
  80973. */
  80974. get captureRenderTime(): boolean;
  80975. set captureRenderTime(value: boolean);
  80976. /**
  80977. * Enable or disable the layout time capture
  80978. */
  80979. get captureLayoutTime(): boolean;
  80980. set captureLayoutTime(value: boolean);
  80981. /**
  80982. * Instantiates a new advanced dynamic texture instrumentation.
  80983. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  80984. * @param texture Defines the AdvancedDynamicTexture to instrument
  80985. */
  80986. constructor(
  80987. /**
  80988. * Define the instrumented AdvancedDynamicTexture.
  80989. */
  80990. texture: AdvancedDynamicTexture);
  80991. /**
  80992. * Dispose and release associated resources.
  80993. */
  80994. dispose(): void;
  80995. }
  80996. }
  80997. declare module BABYLON.GUI {
  80998. /**
  80999. * Class used to load GUI via XML.
  81000. */
  81001. export class XmlLoader {
  81002. private _nodes;
  81003. private _nodeTypes;
  81004. private _isLoaded;
  81005. private _objectAttributes;
  81006. private _parentClass;
  81007. /**
  81008. * Create a new xml loader
  81009. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  81010. */
  81011. constructor(parentClass?: null);
  81012. private _getChainElement;
  81013. private _getClassAttribute;
  81014. private _createGuiElement;
  81015. private _parseGrid;
  81016. private _parseElement;
  81017. private _prepareSourceElement;
  81018. private _parseElementsFromSource;
  81019. private _parseXml;
  81020. /**
  81021. * Gets if the loading has finished.
  81022. * @returns whether the loading has finished or not
  81023. */
  81024. isLoaded(): boolean;
  81025. /**
  81026. * Gets a loaded node / control by id.
  81027. * @param id the Controls id set in the xml
  81028. * @returns element of type Control
  81029. */
  81030. getNodeById(id: string): any;
  81031. /**
  81032. * Gets all loaded nodes / controls
  81033. * @returns Array of controls
  81034. */
  81035. getNodes(): any;
  81036. /**
  81037. * Initiates the xml layout loading
  81038. * @param xmlFile defines the xml layout to load
  81039. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  81040. * @param callback defines the callback called on layout load.
  81041. */
  81042. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  81043. }
  81044. }
  81045. declare module BABYLON.GUI {
  81046. /**
  81047. * Class used to create containers for controls
  81048. */
  81049. export class Container3D extends Control3D {
  81050. private _blockLayout;
  81051. /**
  81052. * Gets the list of child controls
  81053. */
  81054. protected _children: Control3D[];
  81055. /**
  81056. * Gets the list of child controls
  81057. */
  81058. get children(): Array<Control3D>;
  81059. /**
  81060. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  81061. * This is helpful to optimize layout operation when adding multiple children in a row
  81062. */
  81063. get blockLayout(): boolean;
  81064. set blockLayout(value: boolean);
  81065. /**
  81066. * Creates a new container
  81067. * @param name defines the container name
  81068. */
  81069. constructor(name?: string);
  81070. /**
  81071. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  81072. * @returns the current container
  81073. */
  81074. updateLayout(): Container3D;
  81075. /**
  81076. * Gets a boolean indicating if the given control is in the children of this control
  81077. * @param control defines the control to check
  81078. * @returns true if the control is in the child list
  81079. */
  81080. containsControl(control: Control3D): boolean;
  81081. /**
  81082. * Adds a control to the children of this control
  81083. * @param control defines the control to add
  81084. * @returns the current container
  81085. */
  81086. addControl(control: Control3D): Container3D;
  81087. /**
  81088. * This function will be called everytime a new control is added
  81089. */
  81090. protected _arrangeChildren(): void;
  81091. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81092. /**
  81093. * Removes a control from the children of this control
  81094. * @param control defines the control to remove
  81095. * @returns the current container
  81096. */
  81097. removeControl(control: Control3D): Container3D;
  81098. protected _getTypeName(): string;
  81099. /**
  81100. * Releases all associated resources
  81101. */
  81102. dispose(): void;
  81103. /** Control rotation will remain unchanged */
  81104. static readonly UNSET_ORIENTATION: number;
  81105. /** Control will rotate to make it look at sphere central axis */
  81106. static readonly FACEORIGIN_ORIENTATION: number;
  81107. /** Control will rotate to make it look back at sphere central axis */
  81108. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  81109. /** Control will rotate to look at z axis (0, 0, 1) */
  81110. static readonly FACEFORWARD_ORIENTATION: number;
  81111. /** Control will rotate to look at negative z axis (0, 0, -1) */
  81112. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  81113. }
  81114. }
  81115. declare module BABYLON.GUI {
  81116. /**
  81117. * Class used to manage 3D user interface
  81118. * @see https://doc.babylonjs.com/how_to/gui3d
  81119. */
  81120. export class GUI3DManager implements BABYLON.IDisposable {
  81121. private _scene;
  81122. private _sceneDisposeObserver;
  81123. private _utilityLayer;
  81124. private _rootContainer;
  81125. private _pointerObserver;
  81126. private _pointerOutObserver;
  81127. /** @hidden */
  81128. _lastPickedControl: Control3D;
  81129. /** @hidden */
  81130. _lastControlOver: {
  81131. [pointerId: number]: Control3D;
  81132. };
  81133. /** @hidden */
  81134. _lastControlDown: {
  81135. [pointerId: number]: Control3D;
  81136. };
  81137. /**
  81138. * BABYLON.Observable raised when the point picked by the pointer events changed
  81139. */
  81140. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  81141. /** @hidden */
  81142. _sharedMaterials: {
  81143. [key: string]: BABYLON.Material;
  81144. };
  81145. /** Gets the hosting scene */
  81146. get scene(): BABYLON.Scene;
  81147. /** Gets associated utility layer */
  81148. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  81149. /**
  81150. * Creates a new GUI3DManager
  81151. * @param scene
  81152. */
  81153. constructor(scene?: BABYLON.Scene);
  81154. private _handlePointerOut;
  81155. private _doPicking;
  81156. /**
  81157. * Gets the root container
  81158. */
  81159. get rootContainer(): Container3D;
  81160. /**
  81161. * Gets a boolean indicating if the given control is in the root child list
  81162. * @param control defines the control to check
  81163. * @returns true if the control is in the root child list
  81164. */
  81165. containsControl(control: Control3D): boolean;
  81166. /**
  81167. * Adds a control to the root child list
  81168. * @param control defines the control to add
  81169. * @returns the current manager
  81170. */
  81171. addControl(control: Control3D): GUI3DManager;
  81172. /**
  81173. * Removes a control from the root child list
  81174. * @param control defines the control to remove
  81175. * @returns the current container
  81176. */
  81177. removeControl(control: Control3D): GUI3DManager;
  81178. /**
  81179. * Releases all associated resources
  81180. */
  81181. dispose(): void;
  81182. }
  81183. }
  81184. declare module BABYLON.GUI {
  81185. /**
  81186. * Class used to transport BABYLON.Vector3 information for pointer events
  81187. */
  81188. export class Vector3WithInfo extends BABYLON.Vector3 {
  81189. /** defines the current mouse button index */
  81190. buttonIndex: number;
  81191. /**
  81192. * Creates a new Vector3WithInfo
  81193. * @param source defines the vector3 data to transport
  81194. * @param buttonIndex defines the current mouse button index
  81195. */
  81196. constructor(source: BABYLON.Vector3,
  81197. /** defines the current mouse button index */
  81198. buttonIndex?: number);
  81199. }
  81200. }
  81201. declare module BABYLON.GUI {
  81202. /**
  81203. * Class used as base class for controls
  81204. */
  81205. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81206. /** Defines the control name */
  81207. name?: string | undefined;
  81208. /** @hidden */
  81209. _host: GUI3DManager;
  81210. private _node;
  81211. private _downCount;
  81212. private _enterCount;
  81213. private _downPointerIds;
  81214. private _isVisible;
  81215. /** Gets or sets the control position in world space */
  81216. get position(): BABYLON.Vector3;
  81217. set position(value: BABYLON.Vector3);
  81218. /** Gets or sets the control scaling in world space */
  81219. get scaling(): BABYLON.Vector3;
  81220. set scaling(value: BABYLON.Vector3);
  81221. /** Callback used to start pointer enter animation */
  81222. pointerEnterAnimation: () => void;
  81223. /** Callback used to start pointer out animation */
  81224. pointerOutAnimation: () => void;
  81225. /** Callback used to start pointer down animation */
  81226. pointerDownAnimation: () => void;
  81227. /** Callback used to start pointer up animation */
  81228. pointerUpAnimation: () => void;
  81229. /**
  81230. * An event triggered when the pointer move over the control
  81231. */
  81232. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81233. /**
  81234. * An event triggered when the pointer move out of the control
  81235. */
  81236. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81237. /**
  81238. * An event triggered when the pointer taps the control
  81239. */
  81240. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81241. /**
  81242. * An event triggered when pointer is up
  81243. */
  81244. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81245. /**
  81246. * An event triggered when a control is clicked on (with a mouse)
  81247. */
  81248. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81249. /**
  81250. * An event triggered when pointer enters the control
  81251. */
  81252. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81253. /**
  81254. * Gets or sets the parent container
  81255. */
  81256. parent: BABYLON.Nullable<Container3D>;
  81257. private _behaviors;
  81258. /**
  81259. * Gets the list of attached behaviors
  81260. * @see https://doc.babylonjs.com/features/behaviour
  81261. */
  81262. get behaviors(): BABYLON.Behavior<Control3D>[];
  81263. /**
  81264. * Attach a behavior to the control
  81265. * @see https://doc.babylonjs.com/features/behaviour
  81266. * @param behavior defines the behavior to attach
  81267. * @returns the current control
  81268. */
  81269. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81270. /**
  81271. * Remove an attached behavior
  81272. * @see https://doc.babylonjs.com/features/behaviour
  81273. * @param behavior defines the behavior to attach
  81274. * @returns the current control
  81275. */
  81276. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81277. /**
  81278. * Gets an attached behavior by name
  81279. * @param name defines the name of the behavior to look for
  81280. * @see https://doc.babylonjs.com/features/behaviour
  81281. * @returns null if behavior was not found else the requested behavior
  81282. */
  81283. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81284. /** Gets or sets a boolean indicating if the control is visible */
  81285. get isVisible(): boolean;
  81286. set isVisible(value: boolean);
  81287. /**
  81288. * Creates a new control
  81289. * @param name defines the control name
  81290. */
  81291. constructor(
  81292. /** Defines the control name */
  81293. name?: string | undefined);
  81294. /**
  81295. * Gets a string representing the class name
  81296. */
  81297. get typeName(): string;
  81298. /**
  81299. * Get the current class name of the control.
  81300. * @returns current class name
  81301. */
  81302. getClassName(): string;
  81303. protected _getTypeName(): string;
  81304. /**
  81305. * Gets the transform node used by this control
  81306. */
  81307. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81308. /**
  81309. * Gets the mesh used to render this control
  81310. */
  81311. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81312. /**
  81313. * Link the control as child of the given node
  81314. * @param node defines the node to link to. Use null to unlink the control
  81315. * @returns the current control
  81316. */
  81317. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81318. /** @hidden **/
  81319. _prepareNode(scene: BABYLON.Scene): void;
  81320. /**
  81321. * Node creation.
  81322. * Can be overriden by children
  81323. * @param scene defines the scene where the node must be attached
  81324. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81325. */
  81326. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81327. /**
  81328. * Affect a material to the given mesh
  81329. * @param mesh defines the mesh which will represent the control
  81330. */
  81331. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81332. /** @hidden */
  81333. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81334. /** @hidden */
  81335. _onPointerEnter(target: Control3D): boolean;
  81336. /** @hidden */
  81337. _onPointerOut(target: Control3D): void;
  81338. /** @hidden */
  81339. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81340. /** @hidden */
  81341. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81342. /** @hidden */
  81343. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81344. /** @hidden */
  81345. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81346. /** @hidden */
  81347. _disposeNode(): void;
  81348. /**
  81349. * Releases all associated resources
  81350. */
  81351. dispose(): void;
  81352. }
  81353. }
  81354. declare module BABYLON.GUI {
  81355. /**
  81356. * Class used as a root to all buttons
  81357. */
  81358. export class AbstractButton3D extends Control3D {
  81359. /**
  81360. * Creates a new button
  81361. * @param name defines the control name
  81362. */
  81363. constructor(name?: string);
  81364. protected _getTypeName(): string;
  81365. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81366. }
  81367. }
  81368. declare module BABYLON.GUI {
  81369. /**
  81370. * Class used to create a button in 3D
  81371. */
  81372. export class Button3D extends AbstractButton3D {
  81373. /** @hidden */
  81374. protected _currentMaterial: BABYLON.Material;
  81375. private _facadeTexture;
  81376. private _content;
  81377. private _contentResolution;
  81378. private _contentScaleRatio;
  81379. /**
  81380. * Gets or sets the texture resolution used to render content (512 by default)
  81381. */
  81382. get contentResolution(): BABYLON.int;
  81383. set contentResolution(value: BABYLON.int);
  81384. /**
  81385. * Gets or sets the texture scale ratio used to render content (2 by default)
  81386. */
  81387. get contentScaleRatio(): number;
  81388. set contentScaleRatio(value: number);
  81389. protected _disposeFacadeTexture(): void;
  81390. protected _resetContent(): void;
  81391. /**
  81392. * Creates a new button
  81393. * @param name defines the control name
  81394. */
  81395. constructor(name?: string);
  81396. /**
  81397. * Gets or sets the GUI 2D content used to display the button's facade
  81398. */
  81399. get content(): Control;
  81400. set content(value: Control);
  81401. /**
  81402. * Apply the facade texture (created from the content property).
  81403. * This function can be overloaded by child classes
  81404. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81405. */
  81406. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81407. protected _getTypeName(): string;
  81408. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81409. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81410. /**
  81411. * Releases all associated resources
  81412. */
  81413. dispose(): void;
  81414. }
  81415. }
  81416. declare module BABYLON.GUI {
  81417. /**
  81418. * Abstract class used to create a container panel deployed on the surface of a volume
  81419. */
  81420. export abstract class VolumeBasedPanel extends Container3D {
  81421. private _columns;
  81422. private _rows;
  81423. private _rowThenColum;
  81424. private _orientation;
  81425. protected _cellWidth: number;
  81426. protected _cellHeight: number;
  81427. /**
  81428. * Gets or sets the distance between elements
  81429. */
  81430. margin: number;
  81431. /**
  81432. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81433. * | Value | Type | Description |
  81434. * | ----- | ----------------------------------- | ----------- |
  81435. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81436. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81437. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81438. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81439. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  81440. */
  81441. get orientation(): number;
  81442. set orientation(value: number);
  81443. /**
  81444. * Gets or sets the number of columns requested (10 by default).
  81445. * The panel will automatically compute the number of rows based on number of child controls.
  81446. */
  81447. get columns(): BABYLON.int;
  81448. set columns(value: BABYLON.int);
  81449. /**
  81450. * Gets or sets a the number of rows requested.
  81451. * The panel will automatically compute the number of columns based on number of child controls.
  81452. */
  81453. get rows(): BABYLON.int;
  81454. set rows(value: BABYLON.int);
  81455. /**
  81456. * Creates new VolumeBasedPanel
  81457. */
  81458. constructor();
  81459. protected _arrangeChildren(): void;
  81460. /** Child classes must implement this function to provide correct control positioning */
  81461. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81462. /** Child classes can implement this function to provide additional processing */
  81463. protected _finalProcessing(): void;
  81464. }
  81465. }
  81466. declare module BABYLON.GUI {
  81467. /**
  81468. * Class used to create a container panel deployed on the surface of a cylinder
  81469. */
  81470. export class CylinderPanel extends VolumeBasedPanel {
  81471. private _radius;
  81472. /**
  81473. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  81474. */
  81475. get radius(): BABYLON.float;
  81476. set radius(value: BABYLON.float);
  81477. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81478. private _cylindricalMapping;
  81479. }
  81480. }
  81481. declare module BABYLON.GUI {
  81482. /** @hidden */
  81483. export var fluentVertexShader: {
  81484. name: string;
  81485. shader: string;
  81486. };
  81487. }
  81488. declare module BABYLON.GUI {
  81489. /** @hidden */
  81490. export var fluentPixelShader: {
  81491. name: string;
  81492. shader: string;
  81493. };
  81494. }
  81495. declare module BABYLON.GUI {
  81496. /** @hidden */
  81497. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81498. INNERGLOW: boolean;
  81499. BORDER: boolean;
  81500. HOVERLIGHT: boolean;
  81501. TEXTURE: boolean;
  81502. constructor();
  81503. }
  81504. /**
  81505. * Class used to render controls with fluent desgin
  81506. */
  81507. export class FluentMaterial extends BABYLON.PushMaterial {
  81508. /**
  81509. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81510. */
  81511. innerGlowColorIntensity: number;
  81512. /**
  81513. * Gets or sets the inner glow color (white by default)
  81514. */
  81515. innerGlowColor: BABYLON.Color3;
  81516. /**
  81517. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81518. */
  81519. albedoColor: BABYLON.Color3;
  81520. /**
  81521. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81522. */
  81523. renderBorders: boolean;
  81524. /**
  81525. * Gets or sets border width (default is 0.5)
  81526. */
  81527. borderWidth: number;
  81528. /**
  81529. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  81530. */
  81531. edgeSmoothingValue: number;
  81532. /**
  81533. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81534. */
  81535. borderMinValue: number;
  81536. /**
  81537. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81538. */
  81539. renderHoverLight: boolean;
  81540. /**
  81541. * Gets or sets the radius used to render the hover light (default is 1.0)
  81542. */
  81543. hoverRadius: number;
  81544. /**
  81545. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81546. */
  81547. hoverColor: BABYLON.Color4;
  81548. /**
  81549. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81550. */
  81551. hoverPosition: BABYLON.Vector3;
  81552. private _albedoTexture;
  81553. /** Gets or sets the texture to use for albedo color */
  81554. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81555. /**
  81556. * Creates a new Fluent material
  81557. * @param name defines the name of the material
  81558. * @param scene defines the hosting scene
  81559. */
  81560. constructor(name: string, scene: BABYLON.Scene);
  81561. needAlphaBlending(): boolean;
  81562. needAlphaTesting(): boolean;
  81563. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81564. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81565. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81566. getActiveTextures(): BABYLON.BaseTexture[];
  81567. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81568. dispose(forceDisposeEffect?: boolean): void;
  81569. clone(name: string): FluentMaterial;
  81570. serialize(): any;
  81571. getClassName(): string;
  81572. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81573. }
  81574. }
  81575. declare module BABYLON.GUI {
  81576. /**
  81577. * Class used to create a holographic button in 3D
  81578. */
  81579. export class HolographicButton extends Button3D {
  81580. private _backPlate;
  81581. private _textPlate;
  81582. private _frontPlate;
  81583. private _text;
  81584. private _imageUrl;
  81585. private _shareMaterials;
  81586. private _frontMaterial;
  81587. private _backMaterial;
  81588. private _plateMaterial;
  81589. private _pickedPointObserver;
  81590. private _tooltipFade;
  81591. private _tooltipTextBlock;
  81592. private _tooltipTexture;
  81593. private _tooltipMesh;
  81594. private _tooltipHoverObserver;
  81595. private _tooltipOutObserver;
  81596. private _disposeTooltip;
  81597. /**
  81598. * Rendering ground id of all the mesh in the button
  81599. */
  81600. set renderingGroupId(id: number);
  81601. get renderingGroupId(): number;
  81602. /**
  81603. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81604. */
  81605. set tooltipText(text: BABYLON.Nullable<string>);
  81606. get tooltipText(): BABYLON.Nullable<string>;
  81607. /**
  81608. * Gets or sets text for the button
  81609. */
  81610. get text(): string;
  81611. set text(value: string);
  81612. /**
  81613. * Gets or sets the image url for the button
  81614. */
  81615. get imageUrl(): string;
  81616. set imageUrl(value: string);
  81617. /**
  81618. * Gets the back material used by this button
  81619. */
  81620. get backMaterial(): FluentMaterial;
  81621. /**
  81622. * Gets the front material used by this button
  81623. */
  81624. get frontMaterial(): FluentMaterial;
  81625. /**
  81626. * Gets the plate material used by this button
  81627. */
  81628. get plateMaterial(): BABYLON.StandardMaterial;
  81629. /**
  81630. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81631. */
  81632. get shareMaterials(): boolean;
  81633. /**
  81634. * Creates a new button
  81635. * @param name defines the control name
  81636. */
  81637. constructor(name?: string, shareMaterials?: boolean);
  81638. protected _getTypeName(): string;
  81639. private _rebuildContent;
  81640. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81641. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81642. private _createBackMaterial;
  81643. private _createFrontMaterial;
  81644. private _createPlateMaterial;
  81645. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  81646. /**
  81647. * Releases all associated resources
  81648. */
  81649. dispose(): void;
  81650. }
  81651. }
  81652. declare module BABYLON.GUI {
  81653. /**
  81654. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  81655. */
  81656. export class MeshButton3D extends Button3D {
  81657. /** @hidden */
  81658. protected _currentMesh: BABYLON.Mesh;
  81659. /**
  81660. * Creates a new 3D button based on a mesh
  81661. * @param mesh mesh to become a 3D button
  81662. * @param name defines the control name
  81663. */
  81664. constructor(mesh: BABYLON.Mesh, name?: string);
  81665. protected _getTypeName(): string;
  81666. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81667. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81668. }
  81669. }
  81670. declare module BABYLON.GUI {
  81671. /**
  81672. * Class used to create a container panel deployed on the surface of a plane
  81673. */
  81674. export class PlanePanel extends VolumeBasedPanel {
  81675. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81676. }
  81677. }
  81678. declare module BABYLON.GUI {
  81679. /**
  81680. * Class used to create a container panel where items get randomized planar mapping
  81681. */
  81682. export class ScatterPanel extends VolumeBasedPanel {
  81683. private _iteration;
  81684. /**
  81685. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81686. */
  81687. get iteration(): BABYLON.float;
  81688. set iteration(value: BABYLON.float);
  81689. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81690. private _scatterMapping;
  81691. protected _finalProcessing(): void;
  81692. }
  81693. }
  81694. declare module BABYLON.GUI {
  81695. /**
  81696. * Class used to create a container panel deployed on the surface of a sphere
  81697. */
  81698. export class SpherePanel extends VolumeBasedPanel {
  81699. private _radius;
  81700. /**
  81701. * Gets or sets the radius of the sphere where to project controls (5 by default)
  81702. */
  81703. get radius(): BABYLON.float;
  81704. set radius(value: BABYLON.float);
  81705. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81706. private _sphericalMapping;
  81707. }
  81708. }
  81709. declare module BABYLON.GUI {
  81710. /**
  81711. * Class used to create a stack panel in 3D on XY plane
  81712. */
  81713. export class StackPanel3D extends Container3D {
  81714. private _isVertical;
  81715. /**
  81716. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  81717. */
  81718. get isVertical(): boolean;
  81719. set isVertical(value: boolean);
  81720. /**
  81721. * Gets or sets the distance between elements
  81722. */
  81723. margin: number;
  81724. /**
  81725. * Creates new StackPanel
  81726. * @param isVertical
  81727. */
  81728. constructor(isVertical?: boolean);
  81729. protected _arrangeChildren(): void;
  81730. }
  81731. }
  81732. declare module BABYLON {
  81733. /**
  81734. * Configuration for glTF validation
  81735. */
  81736. export interface IGLTFValidationConfiguration {
  81737. /**
  81738. * The url of the glTF validator.
  81739. */
  81740. url: string;
  81741. }
  81742. /**
  81743. * glTF validation
  81744. */
  81745. export class GLTFValidation {
  81746. /**
  81747. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  81748. */
  81749. static Configuration: IGLTFValidationConfiguration;
  81750. private static _LoadScriptPromise;
  81751. /**
  81752. * Validate a glTF asset using the glTF-Validator.
  81753. * @param data The JSON of a glTF or the array buffer of a binary glTF
  81754. * @param rootUrl The root url for the glTF
  81755. * @param fileName The file name for the glTF
  81756. * @param getExternalResource The callback to get external resources for the glTF validator
  81757. * @returns A promise that resolves with the glTF validation results once complete
  81758. */
  81759. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  81760. }
  81761. }
  81762. declare module BABYLON {
  81763. /**
  81764. * Mode that determines the coordinate system to use.
  81765. */
  81766. export enum GLTFLoaderCoordinateSystemMode {
  81767. /**
  81768. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  81769. */
  81770. AUTO = 0,
  81771. /**
  81772. * Sets the useRightHandedSystem flag on the scene.
  81773. */
  81774. FORCE_RIGHT_HANDED = 1
  81775. }
  81776. /**
  81777. * Mode that determines what animations will start.
  81778. */
  81779. export enum GLTFLoaderAnimationStartMode {
  81780. /**
  81781. * No animation will start.
  81782. */
  81783. NONE = 0,
  81784. /**
  81785. * The first animation will start.
  81786. */
  81787. FIRST = 1,
  81788. /**
  81789. * All animations will start.
  81790. */
  81791. ALL = 2
  81792. }
  81793. /**
  81794. * Interface that contains the data for the glTF asset.
  81795. */
  81796. export interface IGLTFLoaderData {
  81797. /**
  81798. * The object that represents the glTF JSON.
  81799. */
  81800. json: Object;
  81801. /**
  81802. * The BIN chunk of a binary glTF.
  81803. */
  81804. bin: Nullable<IDataBuffer>;
  81805. }
  81806. /**
  81807. * Interface for extending the loader.
  81808. */
  81809. export interface IGLTFLoaderExtension {
  81810. /**
  81811. * The name of this extension.
  81812. */
  81813. readonly name: string;
  81814. /**
  81815. * Defines whether this extension is enabled.
  81816. */
  81817. enabled: boolean;
  81818. /**
  81819. * Defines the order of this extension.
  81820. * The loader sorts the extensions using these values when loading.
  81821. */
  81822. order?: number;
  81823. }
  81824. /**
  81825. * Loader state.
  81826. */
  81827. export enum GLTFLoaderState {
  81828. /**
  81829. * The asset is loading.
  81830. */
  81831. LOADING = 0,
  81832. /**
  81833. * The asset is ready for rendering.
  81834. */
  81835. READY = 1,
  81836. /**
  81837. * The asset is completely loaded.
  81838. */
  81839. COMPLETE = 2
  81840. }
  81841. /** @hidden */
  81842. export interface IImportMeshAsyncOutput {
  81843. meshes: AbstractMesh[];
  81844. geometries: Geometry[];
  81845. particleSystems: IParticleSystem[];
  81846. skeletons: Skeleton[];
  81847. animationGroups: AnimationGroup[];
  81848. lights: Light[];
  81849. transformNodes: TransformNode[];
  81850. }
  81851. /** @hidden */
  81852. export interface IGLTFLoader extends IDisposable {
  81853. readonly state: Nullable<GLTFLoaderState>;
  81854. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  81855. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  81856. }
  81857. /**
  81858. * File loader for loading glTF files into a scene.
  81859. */
  81860. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81861. /** @hidden */
  81862. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81863. /** @hidden */
  81864. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81865. /**
  81866. * Raised when the asset has been parsed
  81867. */
  81868. onParsedObservable: Observable<IGLTFLoaderData>;
  81869. private _onParsedObserver;
  81870. /**
  81871. * Raised when the asset has been parsed
  81872. */
  81873. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  81874. /**
  81875. * 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.
  81876. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  81877. * Defaults to true.
  81878. * @hidden
  81879. */
  81880. static IncrementalLoading: boolean;
  81881. /**
  81882. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  81883. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  81884. * @hidden
  81885. */
  81886. static HomogeneousCoordinates: boolean;
  81887. /**
  81888. * The coordinate system mode. Defaults to AUTO.
  81889. */
  81890. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  81891. /**
  81892. * The animation start mode. Defaults to FIRST.
  81893. */
  81894. animationStartMode: GLTFLoaderAnimationStartMode;
  81895. /**
  81896. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  81897. */
  81898. compileMaterials: boolean;
  81899. /**
  81900. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  81901. */
  81902. useClipPlane: boolean;
  81903. /**
  81904. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  81905. */
  81906. compileShadowGenerators: boolean;
  81907. /**
  81908. * Defines if the Alpha blended materials are only applied as coverage.
  81909. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  81910. * If true, no extra effects are applied to transparent pixels.
  81911. */
  81912. transparencyAsCoverage: boolean;
  81913. /**
  81914. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  81915. * Enabling will disable offline support and glTF validator.
  81916. * Defaults to false.
  81917. */
  81918. useRangeRequests: boolean;
  81919. /**
  81920. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  81921. */
  81922. createInstances: boolean;
  81923. /**
  81924. * 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.
  81925. */
  81926. alwaysComputeBoundingBox: boolean;
  81927. /**
  81928. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  81929. */
  81930. loadAllMaterials: boolean;
  81931. /**
  81932. * Function called before loading a url referenced by the asset.
  81933. */
  81934. preprocessUrlAsync: (url: string) => Promise<string>;
  81935. /**
  81936. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81937. * 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, ...)
  81938. */
  81939. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  81940. private _onMeshLoadedObserver;
  81941. /**
  81942. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81943. * 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, ...)
  81944. */
  81945. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  81946. /**
  81947. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  81948. */
  81949. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  81950. private _onTextureLoadedObserver;
  81951. /**
  81952. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  81953. */
  81954. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  81955. /**
  81956. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  81957. */
  81958. readonly onMaterialLoadedObservable: Observable<Material>;
  81959. private _onMaterialLoadedObserver;
  81960. /**
  81961. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  81962. */
  81963. set onMaterialLoaded(callback: (material: Material) => void);
  81964. /**
  81965. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  81966. */
  81967. readonly onCameraLoadedObservable: Observable<Camera>;
  81968. private _onCameraLoadedObserver;
  81969. /**
  81970. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  81971. */
  81972. set onCameraLoaded(callback: (camera: Camera) => void);
  81973. /**
  81974. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  81975. * For assets with LODs, raised when all of the LODs are complete.
  81976. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81977. */
  81978. readonly onCompleteObservable: Observable<void>;
  81979. private _onCompleteObserver;
  81980. /**
  81981. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  81982. * For assets with LODs, raised when all of the LODs are complete.
  81983. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81984. */
  81985. set onComplete(callback: () => void);
  81986. /**
  81987. * Observable raised when an error occurs.
  81988. */
  81989. readonly onErrorObservable: Observable<any>;
  81990. private _onErrorObserver;
  81991. /**
  81992. * Callback raised when an error occurs.
  81993. */
  81994. set onError(callback: (reason: any) => void);
  81995. /**
  81996. * Observable raised after the loader is disposed.
  81997. */
  81998. readonly onDisposeObservable: Observable<void>;
  81999. private _onDisposeObserver;
  82000. /**
  82001. * Callback raised after the loader is disposed.
  82002. */
  82003. set onDispose(callback: () => void);
  82004. /**
  82005. * Observable raised after a loader extension is created.
  82006. * Set additional options for a loader extension in this event.
  82007. */
  82008. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  82009. private _onExtensionLoadedObserver;
  82010. /**
  82011. * Callback raised after a loader extension is created.
  82012. */
  82013. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  82014. /**
  82015. * Defines if the loader logging is enabled.
  82016. */
  82017. get loggingEnabled(): boolean;
  82018. set loggingEnabled(value: boolean);
  82019. /**
  82020. * Defines if the loader should capture performance counters.
  82021. */
  82022. get capturePerformanceCounters(): boolean;
  82023. set capturePerformanceCounters(value: boolean);
  82024. /**
  82025. * Defines if the loader should validate the asset.
  82026. */
  82027. validate: boolean;
  82028. /**
  82029. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  82030. */
  82031. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  82032. private _onValidatedObserver;
  82033. /**
  82034. * Callback raised after a loader extension is created.
  82035. */
  82036. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  82037. private _loader;
  82038. private _progressCallback?;
  82039. private _requests;
  82040. private static magicBase64Encoded;
  82041. /**
  82042. * Name of the loader ("gltf")
  82043. */
  82044. name: string;
  82045. /** @hidden */
  82046. extensions: ISceneLoaderPluginExtensions;
  82047. /**
  82048. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  82049. */
  82050. dispose(): void;
  82051. /** @hidden */
  82052. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82053. /** @hidden */
  82054. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82055. /** @hidden */
  82056. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82057. meshes: AbstractMesh[];
  82058. particleSystems: IParticleSystem[];
  82059. skeletons: Skeleton[];
  82060. animationGroups: AnimationGroup[];
  82061. }>;
  82062. /** @hidden */
  82063. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82064. /** @hidden */
  82065. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82066. /** @hidden */
  82067. canDirectLoad(data: string): boolean;
  82068. /** @hidden */
  82069. directLoad(scene: Scene, data: string): Promise<any>;
  82070. /**
  82071. * The callback that allows custom handling of the root url based on the response url.
  82072. * @param rootUrl the original root url
  82073. * @param responseURL the response url if available
  82074. * @returns the new root url
  82075. */
  82076. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  82077. /** @hidden */
  82078. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  82079. /**
  82080. * The loader state or null if the loader is not active.
  82081. */
  82082. get loaderState(): Nullable<GLTFLoaderState>;
  82083. /**
  82084. * Returns a promise that resolves when the asset is completely loaded.
  82085. * @returns a promise that resolves when the asset is completely loaded.
  82086. */
  82087. whenCompleteAsync(): Promise<void>;
  82088. /** @hidden */
  82089. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  82090. /** @hidden */
  82091. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  82092. private _onProgress;
  82093. private _validate;
  82094. private _getLoader;
  82095. private _parseJson;
  82096. private _unpackBinaryAsync;
  82097. private _unpackBinaryV1Async;
  82098. private _unpackBinaryV2Async;
  82099. private static _parseVersion;
  82100. private static _compareVersion;
  82101. private static readonly _logSpaces;
  82102. private _logIndentLevel;
  82103. private _loggingEnabled;
  82104. /** @hidden */
  82105. _log: (message: string) => void;
  82106. /** @hidden */
  82107. _logOpen(message: string): void;
  82108. /** @hidden */
  82109. _logClose(): void;
  82110. private _logEnabled;
  82111. private _logDisabled;
  82112. private _capturePerformanceCounters;
  82113. /** @hidden */
  82114. _startPerformanceCounter: (counterName: string) => void;
  82115. /** @hidden */
  82116. _endPerformanceCounter: (counterName: string) => void;
  82117. private _startPerformanceCounterEnabled;
  82118. private _startPerformanceCounterDisabled;
  82119. private _endPerformanceCounterEnabled;
  82120. private _endPerformanceCounterDisabled;
  82121. }
  82122. }
  82123. declare module BABYLON.GLTF1 {
  82124. /**
  82125. * Enums
  82126. * @hidden
  82127. */
  82128. export enum EComponentType {
  82129. BYTE = 5120,
  82130. UNSIGNED_BYTE = 5121,
  82131. SHORT = 5122,
  82132. UNSIGNED_SHORT = 5123,
  82133. FLOAT = 5126
  82134. }
  82135. /** @hidden */
  82136. export enum EShaderType {
  82137. FRAGMENT = 35632,
  82138. VERTEX = 35633
  82139. }
  82140. /** @hidden */
  82141. export enum EParameterType {
  82142. BYTE = 5120,
  82143. UNSIGNED_BYTE = 5121,
  82144. SHORT = 5122,
  82145. UNSIGNED_SHORT = 5123,
  82146. INT = 5124,
  82147. UNSIGNED_INT = 5125,
  82148. FLOAT = 5126,
  82149. FLOAT_VEC2 = 35664,
  82150. FLOAT_VEC3 = 35665,
  82151. FLOAT_VEC4 = 35666,
  82152. INT_VEC2 = 35667,
  82153. INT_VEC3 = 35668,
  82154. INT_VEC4 = 35669,
  82155. BOOL = 35670,
  82156. BOOL_VEC2 = 35671,
  82157. BOOL_VEC3 = 35672,
  82158. BOOL_VEC4 = 35673,
  82159. FLOAT_MAT2 = 35674,
  82160. FLOAT_MAT3 = 35675,
  82161. FLOAT_MAT4 = 35676,
  82162. SAMPLER_2D = 35678
  82163. }
  82164. /** @hidden */
  82165. export enum ETextureWrapMode {
  82166. CLAMP_TO_EDGE = 33071,
  82167. MIRRORED_REPEAT = 33648,
  82168. REPEAT = 10497
  82169. }
  82170. /** @hidden */
  82171. export enum ETextureFilterType {
  82172. NEAREST = 9728,
  82173. LINEAR = 9728,
  82174. NEAREST_MIPMAP_NEAREST = 9984,
  82175. LINEAR_MIPMAP_NEAREST = 9985,
  82176. NEAREST_MIPMAP_LINEAR = 9986,
  82177. LINEAR_MIPMAP_LINEAR = 9987
  82178. }
  82179. /** @hidden */
  82180. export enum ETextureFormat {
  82181. ALPHA = 6406,
  82182. RGB = 6407,
  82183. RGBA = 6408,
  82184. LUMINANCE = 6409,
  82185. LUMINANCE_ALPHA = 6410
  82186. }
  82187. /** @hidden */
  82188. export enum ECullingType {
  82189. FRONT = 1028,
  82190. BACK = 1029,
  82191. FRONT_AND_BACK = 1032
  82192. }
  82193. /** @hidden */
  82194. export enum EBlendingFunction {
  82195. ZERO = 0,
  82196. ONE = 1,
  82197. SRC_COLOR = 768,
  82198. ONE_MINUS_SRC_COLOR = 769,
  82199. DST_COLOR = 774,
  82200. ONE_MINUS_DST_COLOR = 775,
  82201. SRC_ALPHA = 770,
  82202. ONE_MINUS_SRC_ALPHA = 771,
  82203. DST_ALPHA = 772,
  82204. ONE_MINUS_DST_ALPHA = 773,
  82205. CONSTANT_COLOR = 32769,
  82206. ONE_MINUS_CONSTANT_COLOR = 32770,
  82207. CONSTANT_ALPHA = 32771,
  82208. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82209. SRC_ALPHA_SATURATE = 776
  82210. }
  82211. /** @hidden */
  82212. export interface IGLTFProperty {
  82213. extensions?: {
  82214. [key: string]: any;
  82215. };
  82216. extras?: Object;
  82217. }
  82218. /** @hidden */
  82219. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82220. name?: string;
  82221. }
  82222. /** @hidden */
  82223. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82224. bufferView: string;
  82225. byteOffset: number;
  82226. byteStride: number;
  82227. count: number;
  82228. type: string;
  82229. componentType: EComponentType;
  82230. max?: number[];
  82231. min?: number[];
  82232. name?: string;
  82233. }
  82234. /** @hidden */
  82235. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82236. buffer: string;
  82237. byteOffset: number;
  82238. byteLength: number;
  82239. byteStride: number;
  82240. target?: number;
  82241. }
  82242. /** @hidden */
  82243. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82244. uri: string;
  82245. byteLength?: number;
  82246. type?: string;
  82247. }
  82248. /** @hidden */
  82249. export interface IGLTFShader extends IGLTFChildRootProperty {
  82250. uri: string;
  82251. type: EShaderType;
  82252. }
  82253. /** @hidden */
  82254. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82255. attributes: string[];
  82256. fragmentShader: string;
  82257. vertexShader: string;
  82258. }
  82259. /** @hidden */
  82260. export interface IGLTFTechniqueParameter {
  82261. type: number;
  82262. count?: number;
  82263. semantic?: string;
  82264. node?: string;
  82265. value?: number | boolean | string | Array<any>;
  82266. source?: string;
  82267. babylonValue?: any;
  82268. }
  82269. /** @hidden */
  82270. export interface IGLTFTechniqueCommonProfile {
  82271. lightingModel: string;
  82272. texcoordBindings: Object;
  82273. parameters?: Array<any>;
  82274. }
  82275. /** @hidden */
  82276. export interface IGLTFTechniqueStatesFunctions {
  82277. blendColor?: number[];
  82278. blendEquationSeparate?: number[];
  82279. blendFuncSeparate?: number[];
  82280. colorMask: boolean[];
  82281. cullFace: number[];
  82282. }
  82283. /** @hidden */
  82284. export interface IGLTFTechniqueStates {
  82285. enable: number[];
  82286. functions: IGLTFTechniqueStatesFunctions;
  82287. }
  82288. /** @hidden */
  82289. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82290. parameters: {
  82291. [key: string]: IGLTFTechniqueParameter;
  82292. };
  82293. program: string;
  82294. attributes: {
  82295. [key: string]: string;
  82296. };
  82297. uniforms: {
  82298. [key: string]: string;
  82299. };
  82300. states: IGLTFTechniqueStates;
  82301. }
  82302. /** @hidden */
  82303. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82304. technique?: string;
  82305. values: string[];
  82306. }
  82307. /** @hidden */
  82308. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82309. attributes: {
  82310. [key: string]: string;
  82311. };
  82312. indices: string;
  82313. material: string;
  82314. mode?: number;
  82315. }
  82316. /** @hidden */
  82317. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82318. primitives: IGLTFMeshPrimitive[];
  82319. }
  82320. /** @hidden */
  82321. export interface IGLTFImage extends IGLTFChildRootProperty {
  82322. uri: string;
  82323. }
  82324. /** @hidden */
  82325. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82326. magFilter?: number;
  82327. minFilter?: number;
  82328. wrapS?: number;
  82329. wrapT?: number;
  82330. }
  82331. /** @hidden */
  82332. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82333. sampler: string;
  82334. source: string;
  82335. format?: ETextureFormat;
  82336. internalFormat?: ETextureFormat;
  82337. target?: number;
  82338. type?: number;
  82339. babylonTexture?: Texture;
  82340. }
  82341. /** @hidden */
  82342. export interface IGLTFAmbienLight {
  82343. color?: number[];
  82344. }
  82345. /** @hidden */
  82346. export interface IGLTFDirectionalLight {
  82347. color?: number[];
  82348. }
  82349. /** @hidden */
  82350. export interface IGLTFPointLight {
  82351. color?: number[];
  82352. constantAttenuation?: number;
  82353. linearAttenuation?: number;
  82354. quadraticAttenuation?: number;
  82355. }
  82356. /** @hidden */
  82357. export interface IGLTFSpotLight {
  82358. color?: number[];
  82359. constantAttenuation?: number;
  82360. fallOfAngle?: number;
  82361. fallOffExponent?: number;
  82362. linearAttenuation?: number;
  82363. quadraticAttenuation?: number;
  82364. }
  82365. /** @hidden */
  82366. export interface IGLTFLight extends IGLTFChildRootProperty {
  82367. type: string;
  82368. }
  82369. /** @hidden */
  82370. export interface IGLTFCameraOrthographic {
  82371. xmag: number;
  82372. ymag: number;
  82373. zfar: number;
  82374. znear: number;
  82375. }
  82376. /** @hidden */
  82377. export interface IGLTFCameraPerspective {
  82378. aspectRatio: number;
  82379. yfov: number;
  82380. zfar: number;
  82381. znear: number;
  82382. }
  82383. /** @hidden */
  82384. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82385. type: string;
  82386. }
  82387. /** @hidden */
  82388. export interface IGLTFAnimationChannelTarget {
  82389. id: string;
  82390. path: string;
  82391. }
  82392. /** @hidden */
  82393. export interface IGLTFAnimationChannel {
  82394. sampler: string;
  82395. target: IGLTFAnimationChannelTarget;
  82396. }
  82397. /** @hidden */
  82398. export interface IGLTFAnimationSampler {
  82399. input: string;
  82400. output: string;
  82401. interpolation?: string;
  82402. }
  82403. /** @hidden */
  82404. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82405. channels?: IGLTFAnimationChannel[];
  82406. parameters?: {
  82407. [key: string]: string;
  82408. };
  82409. samplers?: {
  82410. [key: string]: IGLTFAnimationSampler;
  82411. };
  82412. }
  82413. /** @hidden */
  82414. export interface IGLTFNodeInstanceSkin {
  82415. skeletons: string[];
  82416. skin: string;
  82417. meshes: string[];
  82418. }
  82419. /** @hidden */
  82420. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82421. bindShapeMatrix: number[];
  82422. inverseBindMatrices: string;
  82423. jointNames: string[];
  82424. babylonSkeleton?: Skeleton;
  82425. }
  82426. /** @hidden */
  82427. export interface IGLTFNode extends IGLTFChildRootProperty {
  82428. camera?: string;
  82429. children: string[];
  82430. skin?: string;
  82431. jointName?: string;
  82432. light?: string;
  82433. matrix: number[];
  82434. mesh?: string;
  82435. meshes?: string[];
  82436. rotation?: number[];
  82437. scale?: number[];
  82438. translation?: number[];
  82439. babylonNode?: Node;
  82440. }
  82441. /** @hidden */
  82442. export interface IGLTFScene extends IGLTFChildRootProperty {
  82443. nodes: string[];
  82444. }
  82445. /** @hidden */
  82446. export interface IGLTFRuntime {
  82447. extensions: {
  82448. [key: string]: any;
  82449. };
  82450. accessors: {
  82451. [key: string]: IGLTFAccessor;
  82452. };
  82453. buffers: {
  82454. [key: string]: IGLTFBuffer;
  82455. };
  82456. bufferViews: {
  82457. [key: string]: IGLTFBufferView;
  82458. };
  82459. meshes: {
  82460. [key: string]: IGLTFMesh;
  82461. };
  82462. lights: {
  82463. [key: string]: IGLTFLight;
  82464. };
  82465. cameras: {
  82466. [key: string]: IGLTFCamera;
  82467. };
  82468. nodes: {
  82469. [key: string]: IGLTFNode;
  82470. };
  82471. images: {
  82472. [key: string]: IGLTFImage;
  82473. };
  82474. textures: {
  82475. [key: string]: IGLTFTexture;
  82476. };
  82477. shaders: {
  82478. [key: string]: IGLTFShader;
  82479. };
  82480. programs: {
  82481. [key: string]: IGLTFProgram;
  82482. };
  82483. samplers: {
  82484. [key: string]: IGLTFSampler;
  82485. };
  82486. techniques: {
  82487. [key: string]: IGLTFTechnique;
  82488. };
  82489. materials: {
  82490. [key: string]: IGLTFMaterial;
  82491. };
  82492. animations: {
  82493. [key: string]: IGLTFAnimation;
  82494. };
  82495. skins: {
  82496. [key: string]: IGLTFSkins;
  82497. };
  82498. currentScene?: Object;
  82499. scenes: {
  82500. [key: string]: IGLTFScene;
  82501. };
  82502. extensionsUsed: string[];
  82503. extensionsRequired?: string[];
  82504. buffersCount: number;
  82505. shaderscount: number;
  82506. scene: Scene;
  82507. rootUrl: string;
  82508. loadedBufferCount: number;
  82509. loadedBufferViews: {
  82510. [name: string]: ArrayBufferView;
  82511. };
  82512. loadedShaderCount: number;
  82513. importOnlyMeshes: boolean;
  82514. importMeshesNames?: string[];
  82515. dummyNodes: Node[];
  82516. forAssetContainer: boolean;
  82517. }
  82518. /** @hidden */
  82519. export interface INodeToRoot {
  82520. bone: Bone;
  82521. node: IGLTFNode;
  82522. id: string;
  82523. }
  82524. /** @hidden */
  82525. export interface IJointNode {
  82526. node: IGLTFNode;
  82527. id: string;
  82528. }
  82529. }
  82530. declare module BABYLON.GLTF1 {
  82531. /**
  82532. * Utils functions for GLTF
  82533. * @hidden
  82534. */
  82535. export class GLTFUtils {
  82536. /**
  82537. * Sets the given "parameter" matrix
  82538. * @param scene: the Scene object
  82539. * @param source: the source node where to pick the matrix
  82540. * @param parameter: the GLTF technique parameter
  82541. * @param uniformName: the name of the shader's uniform
  82542. * @param shaderMaterial: the shader material
  82543. */
  82544. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82545. /**
  82546. * Sets the given "parameter" matrix
  82547. * @param shaderMaterial: the shader material
  82548. * @param uniform: the name of the shader's uniform
  82549. * @param value: the value of the uniform
  82550. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82551. */
  82552. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82553. /**
  82554. * Returns the wrap mode of the texture
  82555. * @param mode: the mode value
  82556. */
  82557. static GetWrapMode(mode: number): number;
  82558. /**
  82559. * Returns the byte stride giving an accessor
  82560. * @param accessor: the GLTF accessor objet
  82561. */
  82562. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82563. /**
  82564. * Returns the texture filter mode giving a mode value
  82565. * @param mode: the filter mode value
  82566. */
  82567. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82568. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82569. /**
  82570. * Returns a buffer from its accessor
  82571. * @param gltfRuntime: the GLTF runtime
  82572. * @param accessor: the GLTF accessor
  82573. */
  82574. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82575. /**
  82576. * Decodes a buffer view into a string
  82577. * @param view: the buffer view
  82578. */
  82579. static DecodeBufferToText(view: ArrayBufferView): string;
  82580. /**
  82581. * Returns the default material of gltf. Related to
  82582. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82583. * @param scene: the Babylon.js scene
  82584. */
  82585. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82586. private static _DefaultMaterial;
  82587. }
  82588. }
  82589. declare module BABYLON.GLTF1 {
  82590. /**
  82591. * Implementation of the base glTF spec
  82592. * @hidden
  82593. */
  82594. export class GLTFLoaderBase {
  82595. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82596. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82597. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82598. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82599. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82600. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82601. }
  82602. /**
  82603. * glTF V1 Loader
  82604. * @hidden
  82605. */
  82606. export class GLTFLoader implements IGLTFLoader {
  82607. static Extensions: {
  82608. [name: string]: GLTFLoaderExtension;
  82609. };
  82610. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82611. state: Nullable<GLTFLoaderState>;
  82612. dispose(): void;
  82613. private _importMeshAsync;
  82614. /**
  82615. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82616. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82617. * @param scene the scene the meshes should be added to
  82618. * @param forAssetContainer defines if the entities must be stored in the scene
  82619. * @param data gltf data containing information of the meshes in a loaded file
  82620. * @param rootUrl root url to load from
  82621. * @param onProgress event that fires when loading progress has occured
  82622. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82623. */
  82624. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  82625. private _loadAsync;
  82626. /**
  82627. * Imports all objects from a loaded gltf file and adds them to the scene
  82628. * @param scene the scene the objects should be added to
  82629. * @param data gltf data containing information of the meshes in a loaded file
  82630. * @param rootUrl root url to load from
  82631. * @param onProgress event that fires when loading progress has occured
  82632. * @returns a promise which completes when objects have been loaded to the scene
  82633. */
  82634. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82635. private _loadShadersAsync;
  82636. private _loadBuffersAsync;
  82637. private _createNodes;
  82638. }
  82639. /** @hidden */
  82640. export abstract class GLTFLoaderExtension {
  82641. private _name;
  82642. constructor(name: string);
  82643. get name(): string;
  82644. /**
  82645. * Defines an override for loading the runtime
  82646. * Return true to stop further extensions from loading the runtime
  82647. */
  82648. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82649. /**
  82650. * Defines an onverride for creating gltf runtime
  82651. * Return true to stop further extensions from creating the runtime
  82652. */
  82653. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  82654. /**
  82655. * Defines an override for loading buffers
  82656. * Return true to stop further extensions from loading this buffer
  82657. */
  82658. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82659. /**
  82660. * Defines an override for loading texture buffers
  82661. * Return true to stop further extensions from loading this texture data
  82662. */
  82663. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82664. /**
  82665. * Defines an override for creating textures
  82666. * Return true to stop further extensions from loading this texture
  82667. */
  82668. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82669. /**
  82670. * Defines an override for loading shader strings
  82671. * Return true to stop further extensions from loading this shader data
  82672. */
  82673. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82674. /**
  82675. * Defines an override for loading materials
  82676. * Return true to stop further extensions from loading this material
  82677. */
  82678. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82679. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82680. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82681. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82682. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82683. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82684. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82685. private static LoadTextureBufferAsync;
  82686. private static CreateTextureAsync;
  82687. private static ApplyExtensions;
  82688. }
  82689. }
  82690. declare module BABYLON.GLTF1 {
  82691. /** @hidden */
  82692. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82693. private _bin;
  82694. constructor();
  82695. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82696. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82697. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82698. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82699. }
  82700. }
  82701. declare module BABYLON.GLTF1 {
  82702. /** @hidden */
  82703. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  82704. constructor();
  82705. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  82706. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82707. private _loadTexture;
  82708. }
  82709. }
  82710. declare module BABYLON.GLTF2.Loader {
  82711. /**
  82712. * Loader interface with an index field.
  82713. */
  82714. export interface IArrayItem {
  82715. /**
  82716. * The index of this item in the array.
  82717. */
  82718. index: number;
  82719. }
  82720. /**
  82721. * Loader interface with additional members.
  82722. */
  82723. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  82724. /** @hidden */
  82725. _data?: Promise<ArrayBufferView>;
  82726. /** @hidden */
  82727. _babylonVertexBuffer?: Promise<VertexBuffer>;
  82728. }
  82729. /**
  82730. * Loader interface with additional members.
  82731. */
  82732. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  82733. }
  82734. /** @hidden */
  82735. export interface _IAnimationSamplerData {
  82736. input: Float32Array;
  82737. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  82738. output: Float32Array;
  82739. }
  82740. /**
  82741. * Loader interface with additional members.
  82742. */
  82743. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  82744. /** @hidden */
  82745. _data?: Promise<_IAnimationSamplerData>;
  82746. }
  82747. /**
  82748. * Loader interface with additional members.
  82749. */
  82750. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  82751. channels: IAnimationChannel[];
  82752. samplers: IAnimationSampler[];
  82753. /** @hidden */
  82754. _babylonAnimationGroup?: AnimationGroup;
  82755. }
  82756. /**
  82757. * Loader interface with additional members.
  82758. */
  82759. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  82760. /** @hidden */
  82761. _data?: Promise<ArrayBufferView>;
  82762. }
  82763. /**
  82764. * Loader interface with additional members.
  82765. */
  82766. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  82767. /** @hidden */
  82768. _data?: Promise<ArrayBufferView>;
  82769. /** @hidden */
  82770. _babylonBuffer?: Promise<Buffer>;
  82771. }
  82772. /**
  82773. * Loader interface with additional members.
  82774. */
  82775. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  82776. }
  82777. /**
  82778. * Loader interface with additional members.
  82779. */
  82780. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  82781. /** @hidden */
  82782. _data?: Promise<ArrayBufferView>;
  82783. }
  82784. /**
  82785. * Loader interface with additional members.
  82786. */
  82787. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  82788. }
  82789. /**
  82790. * Loader interface with additional members.
  82791. */
  82792. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  82793. }
  82794. /**
  82795. * Loader interface with additional members.
  82796. */
  82797. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  82798. baseColorTexture?: ITextureInfo;
  82799. metallicRoughnessTexture?: ITextureInfo;
  82800. }
  82801. /**
  82802. * Loader interface with additional members.
  82803. */
  82804. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  82805. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82806. normalTexture?: IMaterialNormalTextureInfo;
  82807. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82808. emissiveTexture?: ITextureInfo;
  82809. /** @hidden */
  82810. _data?: {
  82811. [babylonDrawMode: number]: {
  82812. babylonMaterial: Material;
  82813. babylonMeshes: AbstractMesh[];
  82814. promise: Promise<void>;
  82815. };
  82816. };
  82817. }
  82818. /**
  82819. * Loader interface with additional members.
  82820. */
  82821. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  82822. primitives: IMeshPrimitive[];
  82823. }
  82824. /**
  82825. * Loader interface with additional members.
  82826. */
  82827. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  82828. /** @hidden */
  82829. _instanceData?: {
  82830. babylonSourceMesh: Mesh;
  82831. promise: Promise<any>;
  82832. };
  82833. }
  82834. /**
  82835. * Loader interface with additional members.
  82836. */
  82837. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  82838. /**
  82839. * The parent glTF node.
  82840. */
  82841. parent?: INode;
  82842. /** @hidden */
  82843. _babylonTransformNode?: TransformNode;
  82844. /** @hidden */
  82845. _primitiveBabylonMeshes?: AbstractMesh[];
  82846. /** @hidden */
  82847. _babylonBones?: Bone[];
  82848. /** @hidden */
  82849. _numMorphTargets?: number;
  82850. }
  82851. /** @hidden */
  82852. export interface _ISamplerData {
  82853. noMipMaps: boolean;
  82854. samplingMode: number;
  82855. wrapU: number;
  82856. wrapV: number;
  82857. }
  82858. /**
  82859. * Loader interface with additional members.
  82860. */
  82861. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  82862. /** @hidden */
  82863. _data?: _ISamplerData;
  82864. }
  82865. /**
  82866. * Loader interface with additional members.
  82867. */
  82868. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  82869. }
  82870. /**
  82871. * Loader interface with additional members.
  82872. */
  82873. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  82874. /** @hidden */
  82875. _data?: {
  82876. babylonSkeleton: Skeleton;
  82877. promise: Promise<void>;
  82878. };
  82879. }
  82880. /**
  82881. * Loader interface with additional members.
  82882. */
  82883. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  82884. /** @hidden */
  82885. _textureInfo: ITextureInfo;
  82886. }
  82887. /**
  82888. * Loader interface with additional members.
  82889. */
  82890. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  82891. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  82892. nonColorData?: boolean;
  82893. }
  82894. /**
  82895. * Loader interface with additional members.
  82896. */
  82897. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  82898. accessors?: IAccessor[];
  82899. animations?: IAnimation[];
  82900. buffers?: IBuffer[];
  82901. bufferViews?: IBufferView[];
  82902. cameras?: ICamera[];
  82903. images?: IImage[];
  82904. materials?: IMaterial[];
  82905. meshes?: IMesh[];
  82906. nodes?: INode[];
  82907. samplers?: ISampler[];
  82908. scenes?: IScene[];
  82909. skins?: ISkin[];
  82910. textures?: ITexture[];
  82911. }
  82912. }
  82913. declare module BABYLON.GLTF2 {
  82914. /**
  82915. * Interface for a glTF loader extension.
  82916. */
  82917. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  82918. /**
  82919. * Called after the loader state changes to LOADING.
  82920. */
  82921. onLoading?(): void;
  82922. /**
  82923. * Called after the loader state changes to READY.
  82924. */
  82925. onReady?(): void;
  82926. /**
  82927. * Define this method to modify the default behavior when loading scenes.
  82928. * @param context The context when loading the asset
  82929. * @param scene The glTF scene property
  82930. * @returns A promise that resolves when the load is complete or null if not handled
  82931. */
  82932. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  82933. /**
  82934. * Define this method to modify the default behavior when loading nodes.
  82935. * @param context The context when loading the asset
  82936. * @param node The glTF node property
  82937. * @param assign A function called synchronously after parsing the glTF properties
  82938. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  82939. */
  82940. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82941. /**
  82942. * Define this method to modify the default behavior when loading cameras.
  82943. * @param context The context when loading the asset
  82944. * @param camera The glTF camera property
  82945. * @param assign A function called synchronously after parsing the glTF properties
  82946. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  82947. */
  82948. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82949. /**
  82950. * @hidden
  82951. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  82952. * @param context The context when loading the asset
  82953. * @param primitive The glTF mesh primitive property
  82954. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  82955. */
  82956. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82957. /**
  82958. * @hidden
  82959. * Define this method to modify the default behavior when loading data for mesh primitives.
  82960. * @param context The context when loading the asset
  82961. * @param name The mesh name when loading the asset
  82962. * @param node The glTF node when loading the asset
  82963. * @param mesh The glTF mesh when loading the asset
  82964. * @param primitive The glTF mesh primitive property
  82965. * @param assign A function called synchronously after parsing the glTF properties
  82966. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82967. */
  82968. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82969. /**
  82970. * @hidden
  82971. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  82972. * @param context The context when loading the asset
  82973. * @param material The glTF material property
  82974. * @param assign A function called synchronously after parsing the glTF properties
  82975. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  82976. */
  82977. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82978. /**
  82979. * Define this method to modify the default behavior when creating materials.
  82980. * @param context The context when loading the asset
  82981. * @param material The glTF material property
  82982. * @param babylonDrawMode The draw mode for the Babylon material
  82983. * @returns The Babylon material or null if not handled
  82984. */
  82985. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82986. /**
  82987. * Define this method to modify the default behavior when loading material properties.
  82988. * @param context The context when loading the asset
  82989. * @param material The glTF material property
  82990. * @param babylonMaterial The Babylon material
  82991. * @returns A promise that resolves when the load is complete or null if not handled
  82992. */
  82993. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82994. /**
  82995. * Define this method to modify the default behavior when loading texture infos.
  82996. * @param context The context when loading the asset
  82997. * @param textureInfo The glTF texture info property
  82998. * @param assign A function called synchronously after parsing the glTF properties
  82999. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83000. */
  83001. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83002. /**
  83003. * @hidden
  83004. * Define this method to modify the default behavior when loading textures.
  83005. * @param context The context when loading the asset
  83006. * @param texture The glTF texture property
  83007. * @param assign A function called synchronously after parsing the glTF properties
  83008. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83009. */
  83010. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83011. /**
  83012. * Define this method to modify the default behavior when loading animations.
  83013. * @param context The context when loading the asset
  83014. * @param animation The glTF animation property
  83015. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  83016. */
  83017. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83018. /**
  83019. * @hidden
  83020. * Define this method to modify the default behavior when loading skins.
  83021. * @param context The context when loading the asset
  83022. * @param node The glTF node property
  83023. * @param skin The glTF skin property
  83024. * @returns A promise that resolves when the load is complete or null if not handled
  83025. */
  83026. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  83027. /**
  83028. * @hidden
  83029. * Define this method to modify the default behavior when loading uris.
  83030. * @param context The context when loading the asset
  83031. * @param property The glTF property associated with the uri
  83032. * @param uri The uri to load
  83033. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83034. */
  83035. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83036. /**
  83037. * Define this method to modify the default behavior when loading buffer views.
  83038. * @param context The context when loading the asset
  83039. * @param bufferView The glTF buffer view property
  83040. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83041. */
  83042. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  83043. /**
  83044. * Define this method to modify the default behavior when loading buffers.
  83045. * @param context The context when loading the asset
  83046. * @param buffer The glTF buffer property
  83047. * @param byteOffset The byte offset to load
  83048. * @param byteLength The byte length to load
  83049. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83050. */
  83051. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83052. }
  83053. }
  83054. declare module BABYLON.GLTF2 {
  83055. /**
  83056. * Helper class for working with arrays when loading the glTF asset
  83057. */
  83058. export class ArrayItem {
  83059. /**
  83060. * Gets an item from the given array.
  83061. * @param context The context when loading the asset
  83062. * @param array The array to get the item from
  83063. * @param index The index to the array
  83064. * @returns The array item
  83065. */
  83066. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  83067. /**
  83068. * Assign an `index` field to each item of the given array.
  83069. * @param array The array of items
  83070. */
  83071. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  83072. }
  83073. /**
  83074. * The glTF 2.0 loader
  83075. */
  83076. export class GLTFLoader implements IGLTFLoader {
  83077. /** @hidden */
  83078. _completePromises: Promise<any>[];
  83079. /** @hidden */
  83080. _forAssetContainer: boolean;
  83081. /** Storage */
  83082. _babylonLights: Light[];
  83083. /** @hidden */
  83084. _disableInstancedMesh: number;
  83085. private _disposed;
  83086. private _parent;
  83087. private _state;
  83088. private _extensions;
  83089. private _rootUrl;
  83090. private _fileName;
  83091. private _uniqueRootUrl;
  83092. private _gltf;
  83093. private _bin;
  83094. private _babylonScene;
  83095. private _rootBabylonMesh;
  83096. private _defaultBabylonMaterialData;
  83097. private static _RegisteredExtensions;
  83098. /**
  83099. * The default glTF sampler.
  83100. */
  83101. static readonly DefaultSampler: ISampler;
  83102. /**
  83103. * Registers a loader extension.
  83104. * @param name The name of the loader extension.
  83105. * @param factory The factory function that creates the loader extension.
  83106. */
  83107. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  83108. /**
  83109. * Unregisters a loader extension.
  83110. * @param name The name of the loader extension.
  83111. * @returns A boolean indicating whether the extension has been unregistered
  83112. */
  83113. static UnregisterExtension(name: string): boolean;
  83114. /**
  83115. * The loader state.
  83116. */
  83117. get state(): Nullable<GLTFLoaderState>;
  83118. /**
  83119. * The object that represents the glTF JSON.
  83120. */
  83121. get gltf(): IGLTF;
  83122. /**
  83123. * The BIN chunk of a binary glTF.
  83124. */
  83125. get bin(): Nullable<IDataBuffer>;
  83126. /**
  83127. * The parent file loader.
  83128. */
  83129. get parent(): GLTFFileLoader;
  83130. /**
  83131. * The Babylon scene when loading the asset.
  83132. */
  83133. get babylonScene(): Scene;
  83134. /**
  83135. * The root Babylon mesh when loading the asset.
  83136. */
  83137. get rootBabylonMesh(): Mesh;
  83138. /** @hidden */
  83139. constructor(parent: GLTFFileLoader);
  83140. /** @hidden */
  83141. dispose(): void;
  83142. /** @hidden */
  83143. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  83144. /** @hidden */
  83145. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83146. private _loadAsync;
  83147. private _loadData;
  83148. private _setupData;
  83149. private _loadExtensions;
  83150. private _checkExtensions;
  83151. private _setState;
  83152. private _createRootNode;
  83153. /**
  83154. * Loads a glTF scene.
  83155. * @param context The context when loading the asset
  83156. * @param scene The glTF scene property
  83157. * @returns A promise that resolves when the load is complete
  83158. */
  83159. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  83160. private _forEachPrimitive;
  83161. private _getGeometries;
  83162. private _getMeshes;
  83163. private _getTransformNodes;
  83164. private _getSkeletons;
  83165. private _getAnimationGroups;
  83166. private _startAnimations;
  83167. /**
  83168. * Loads a glTF node.
  83169. * @param context The context when loading the asset
  83170. * @param node The glTF node property
  83171. * @param assign A function called synchronously after parsing the glTF properties
  83172. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  83173. */
  83174. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  83175. private _loadMeshAsync;
  83176. /**
  83177. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83178. * @param context The context when loading the asset
  83179. * @param name The mesh name when loading the asset
  83180. * @param node The glTF node when loading the asset
  83181. * @param mesh The glTF mesh when loading the asset
  83182. * @param primitive The glTF mesh primitive property
  83183. * @param assign A function called synchronously after parsing the glTF properties
  83184. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83185. */
  83186. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83187. private _loadVertexDataAsync;
  83188. private _createMorphTargets;
  83189. private _loadMorphTargetsAsync;
  83190. private _loadMorphTargetVertexDataAsync;
  83191. private static _LoadTransform;
  83192. private _loadSkinAsync;
  83193. private _loadBones;
  83194. private _loadBone;
  83195. private _loadSkinInverseBindMatricesDataAsync;
  83196. private _updateBoneMatrices;
  83197. private _getNodeMatrix;
  83198. /**
  83199. * Loads a glTF camera.
  83200. * @param context The context when loading the asset
  83201. * @param camera The glTF camera property
  83202. * @param assign A function called synchronously after parsing the glTF properties
  83203. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83204. */
  83205. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83206. private _loadAnimationsAsync;
  83207. /**
  83208. * Loads a glTF animation.
  83209. * @param context The context when loading the asset
  83210. * @param animation The glTF animation property
  83211. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83212. */
  83213. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83214. /**
  83215. * @hidden Loads a glTF animation channel.
  83216. * @param context The context when loading the asset
  83217. * @param animationContext The context of the animation when loading the asset
  83218. * @param animation The glTF animation property
  83219. * @param channel The glTF animation channel property
  83220. * @param babylonAnimationGroup The babylon animation group property
  83221. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83222. * @returns A void promise when the channel load is complete
  83223. */
  83224. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83225. private _loadAnimationSamplerAsync;
  83226. private _loadBufferAsync;
  83227. /**
  83228. * Loads a glTF buffer view.
  83229. * @param context The context when loading the asset
  83230. * @param bufferView The glTF buffer view property
  83231. * @returns A promise that resolves with the loaded data when the load is complete
  83232. */
  83233. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83234. private _loadAccessorAsync;
  83235. /** @hidden */
  83236. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83237. private _loadIndicesAccessorAsync;
  83238. private _loadVertexBufferViewAsync;
  83239. private _loadVertexAccessorAsync;
  83240. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83241. /** @hidden */
  83242. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83243. private _createDefaultMaterial;
  83244. /**
  83245. * Creates a Babylon material from a glTF material.
  83246. * @param context The context when loading the asset
  83247. * @param material The glTF material property
  83248. * @param babylonDrawMode The draw mode for the Babylon material
  83249. * @returns The Babylon material
  83250. */
  83251. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83252. /**
  83253. * Loads properties from a glTF material into a Babylon material.
  83254. * @param context The context when loading the asset
  83255. * @param material The glTF material property
  83256. * @param babylonMaterial The Babylon material
  83257. * @returns A promise that resolves when the load is complete
  83258. */
  83259. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83260. /**
  83261. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  83262. * @param context The context when loading the asset
  83263. * @param material The glTF material property
  83264. * @param babylonMaterial The Babylon material
  83265. * @returns A promise that resolves when the load is complete
  83266. */
  83267. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83268. /**
  83269. * Loads the alpha properties from a glTF material into a Babylon material.
  83270. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83271. * @param context The context when loading the asset
  83272. * @param material The glTF material property
  83273. * @param babylonMaterial The Babylon material
  83274. */
  83275. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83276. /**
  83277. * Loads a glTF texture info.
  83278. * @param context The context when loading the asset
  83279. * @param textureInfo The glTF texture info property
  83280. * @param assign A function called synchronously after parsing the glTF properties
  83281. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83282. */
  83283. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83284. /** @hidden */
  83285. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83286. /** @hidden */
  83287. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83288. private _loadSampler;
  83289. /**
  83290. * Loads a glTF image.
  83291. * @param context The context when loading the asset
  83292. * @param image The glTF image property
  83293. * @returns A promise that resolves with the loaded data when the load is complete
  83294. */
  83295. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83296. /**
  83297. * Loads a glTF uri.
  83298. * @param context The context when loading the asset
  83299. * @param property The glTF property associated with the uri
  83300. * @param uri The base64 or relative uri
  83301. * @returns A promise that resolves with the loaded data when the load is complete
  83302. */
  83303. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83304. /**
  83305. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83306. * @param babylonObject the Babylon object with metadata
  83307. * @param pointer the JSON pointer
  83308. */
  83309. static AddPointerMetadata(babylonObject: {
  83310. metadata: any;
  83311. }, pointer: string): void;
  83312. private static _GetTextureWrapMode;
  83313. private static _GetTextureSamplingMode;
  83314. private static _GetTypedArrayConstructor;
  83315. private static _GetTypedArray;
  83316. private static _GetNumComponents;
  83317. private static _ValidateUri;
  83318. /** @hidden */
  83319. static _GetDrawMode(context: string, mode: number | undefined): number;
  83320. private _compileMaterialsAsync;
  83321. private _compileShadowGeneratorsAsync;
  83322. private _forEachExtensions;
  83323. private _applyExtensions;
  83324. private _extensionsOnLoading;
  83325. private _extensionsOnReady;
  83326. private _extensionsLoadSceneAsync;
  83327. private _extensionsLoadNodeAsync;
  83328. private _extensionsLoadCameraAsync;
  83329. private _extensionsLoadVertexDataAsync;
  83330. private _extensionsLoadMeshPrimitiveAsync;
  83331. private _extensionsLoadMaterialAsync;
  83332. private _extensionsCreateMaterial;
  83333. private _extensionsLoadMaterialPropertiesAsync;
  83334. private _extensionsLoadTextureInfoAsync;
  83335. private _extensionsLoadTextureAsync;
  83336. private _extensionsLoadAnimationAsync;
  83337. private _extensionsLoadSkinAsync;
  83338. private _extensionsLoadUriAsync;
  83339. private _extensionsLoadBufferViewAsync;
  83340. private _extensionsLoadBufferAsync;
  83341. /**
  83342. * Helper method called by a loader extension to load an glTF extension.
  83343. * @param context The context when loading the asset
  83344. * @param property The glTF property to load the extension from
  83345. * @param extensionName The name of the extension to load
  83346. * @param actionAsync The action to run
  83347. * @returns The promise returned by actionAsync or null if the extension does not exist
  83348. */
  83349. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83350. /**
  83351. * Helper method called by a loader extension to load a glTF extra.
  83352. * @param context The context when loading the asset
  83353. * @param property The glTF property to load the extra from
  83354. * @param extensionName The name of the extension to load
  83355. * @param actionAsync The action to run
  83356. * @returns The promise returned by actionAsync or null if the extra does not exist
  83357. */
  83358. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83359. /**
  83360. * Checks for presence of an extension.
  83361. * @param name The name of the extension to check
  83362. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83363. */
  83364. isExtensionUsed(name: string): boolean;
  83365. /**
  83366. * Increments the indentation level and logs a message.
  83367. * @param message The message to log
  83368. */
  83369. logOpen(message: string): void;
  83370. /**
  83371. * Decrements the indentation level.
  83372. */
  83373. logClose(): void;
  83374. /**
  83375. * Logs a message
  83376. * @param message The message to log
  83377. */
  83378. log(message: string): void;
  83379. /**
  83380. * Starts a performance counter.
  83381. * @param counterName The name of the performance counter
  83382. */
  83383. startPerformanceCounter(counterName: string): void;
  83384. /**
  83385. * Ends a performance counter.
  83386. * @param counterName The name of the performance counter
  83387. */
  83388. endPerformanceCounter(counterName: string): void;
  83389. }
  83390. }
  83391. declare module BABYLON.GLTF2.Loader.Extensions {
  83392. /** @hidden */
  83393. interface IEXTLightsImageBased_LightImageBased {
  83394. _babylonTexture?: BaseTexture;
  83395. _loaded?: Promise<void>;
  83396. }
  83397. /**
  83398. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83399. */
  83400. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83401. /**
  83402. * The name of this extension.
  83403. */
  83404. readonly name: string;
  83405. /**
  83406. * Defines whether this extension is enabled.
  83407. */
  83408. enabled: boolean;
  83409. private _loader;
  83410. private _lights?;
  83411. /** @hidden */
  83412. constructor(loader: GLTFLoader);
  83413. /** @hidden */
  83414. dispose(): void;
  83415. /** @hidden */
  83416. onLoading(): void;
  83417. /** @hidden */
  83418. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83419. private _loadLightAsync;
  83420. }
  83421. }
  83422. declare module BABYLON.GLTF2.Loader.Extensions {
  83423. /**
  83424. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83425. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83426. * !!! Experimental Extension Subject to Changes !!!
  83427. */
  83428. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83429. /**
  83430. * The name of this extension.
  83431. */
  83432. readonly name: string;
  83433. /**
  83434. * Defines whether this extension is enabled.
  83435. */
  83436. enabled: boolean;
  83437. private _loader;
  83438. /** @hidden */
  83439. constructor(loader: GLTFLoader);
  83440. /** @hidden */
  83441. dispose(): 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/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  83449. */
  83450. export class EXT_texture_webp implements IGLTFLoaderExtension {
  83451. /** The name of this extension. */
  83452. readonly name: string;
  83453. /** Defines whether this extension is enabled. */
  83454. enabled: boolean;
  83455. private _loader;
  83456. /** @hidden */
  83457. constructor(loader: GLTFLoader);
  83458. /** @hidden */
  83459. dispose(): void;
  83460. /** @hidden */
  83461. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83462. }
  83463. }
  83464. declare module BABYLON.GLTF2.Loader.Extensions {
  83465. /**
  83466. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  83467. */
  83468. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  83469. /**
  83470. * The name of this extension.
  83471. */
  83472. readonly name: string;
  83473. /**
  83474. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83475. */
  83476. dracoCompression?: DracoCompression;
  83477. /**
  83478. * Defines whether this extension is enabled.
  83479. */
  83480. enabled: boolean;
  83481. private _loader;
  83482. /** @hidden */
  83483. constructor(loader: GLTFLoader);
  83484. /** @hidden */
  83485. dispose(): void;
  83486. /** @hidden */
  83487. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83488. }
  83489. }
  83490. declare module BABYLON.GLTF2.Loader.Extensions {
  83491. /**
  83492. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83493. */
  83494. export class KHR_lights implements IGLTFLoaderExtension {
  83495. /**
  83496. * The name of this extension.
  83497. */
  83498. readonly name: string;
  83499. /**
  83500. * Defines whether this extension is enabled.
  83501. */
  83502. enabled: boolean;
  83503. private _loader;
  83504. private _lights?;
  83505. /** @hidden */
  83506. constructor(loader: GLTFLoader);
  83507. /** @hidden */
  83508. dispose(): void;
  83509. /** @hidden */
  83510. onLoading(): void;
  83511. /** @hidden */
  83512. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83513. }
  83514. }
  83515. declare module BABYLON.GLTF2.Loader.Extensions {
  83516. /**
  83517. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83518. */
  83519. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  83520. /**
  83521. * The name of this extension.
  83522. */
  83523. readonly name: string;
  83524. /**
  83525. * Defines whether this extension is enabled.
  83526. */
  83527. enabled: boolean;
  83528. /**
  83529. * Defines a number that determines the order the extensions are applied.
  83530. */
  83531. order: number;
  83532. private _loader;
  83533. /** @hidden */
  83534. constructor(loader: GLTFLoader);
  83535. /** @hidden */
  83536. dispose(): void;
  83537. /** @hidden */
  83538. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83539. private _loadSpecularGlossinessPropertiesAsync;
  83540. }
  83541. }
  83542. declare module BABYLON.GLTF2.Loader.Extensions {
  83543. /**
  83544. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83545. */
  83546. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  83547. /**
  83548. * The name of this extension.
  83549. */
  83550. readonly name: string;
  83551. /**
  83552. * Defines whether this extension is enabled.
  83553. */
  83554. enabled: boolean;
  83555. /**
  83556. * Defines a number that determines the order the extensions are applied.
  83557. */
  83558. order: number;
  83559. private _loader;
  83560. /** @hidden */
  83561. constructor(loader: GLTFLoader);
  83562. /** @hidden */
  83563. dispose(): void;
  83564. /** @hidden */
  83565. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83566. private _loadUnlitPropertiesAsync;
  83567. }
  83568. }
  83569. declare module BABYLON.GLTF2.Loader.Extensions {
  83570. /**
  83571. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  83572. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83573. */
  83574. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83575. /**
  83576. * The name of this extension.
  83577. */
  83578. readonly name: string;
  83579. /**
  83580. * Defines whether this extension is enabled.
  83581. */
  83582. enabled: boolean;
  83583. /**
  83584. * Defines a number that determines the order the extensions are applied.
  83585. */
  83586. order: number;
  83587. private _loader;
  83588. /** @hidden */
  83589. constructor(loader: GLTFLoader);
  83590. /** @hidden */
  83591. dispose(): void;
  83592. /** @hidden */
  83593. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83594. private _loadClearCoatPropertiesAsync;
  83595. }
  83596. }
  83597. declare module BABYLON.GLTF2.Loader.Extensions {
  83598. /**
  83599. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  83600. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  83601. * !!! Experimental Extension Subject to Changes !!!
  83602. */
  83603. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83604. /**
  83605. * The name of this extension.
  83606. */
  83607. readonly name: string;
  83608. /**
  83609. * Defines whether this extension is enabled.
  83610. */
  83611. enabled: boolean;
  83612. /**
  83613. * Defines a number that determines the order the extensions are applied.
  83614. */
  83615. order: number;
  83616. private _loader;
  83617. /** @hidden */
  83618. constructor(loader: GLTFLoader);
  83619. /** @hidden */
  83620. dispose(): void;
  83621. /** @hidden */
  83622. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83623. private _loadSheenPropertiesAsync;
  83624. }
  83625. }
  83626. declare module BABYLON.GLTF2.Loader.Extensions {
  83627. /**
  83628. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83629. * !!! Experimental Extension Subject to Changes !!!
  83630. */
  83631. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83632. /**
  83633. * The name of this extension.
  83634. */
  83635. readonly name: string;
  83636. /**
  83637. * Defines whether this extension is enabled.
  83638. */
  83639. enabled: boolean;
  83640. /**
  83641. * Defines a number that determines the order the extensions are applied.
  83642. */
  83643. order: number;
  83644. private _loader;
  83645. /** @hidden */
  83646. constructor(loader: GLTFLoader);
  83647. /** @hidden */
  83648. dispose(): void;
  83649. /** @hidden */
  83650. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83651. private _loadSpecularPropertiesAsync;
  83652. }
  83653. }
  83654. declare module BABYLON.GLTF2.Loader.Extensions {
  83655. /**
  83656. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  83657. * !!! Experimental Extension Subject to Changes !!!
  83658. */
  83659. export class KHR_materials_ior implements IGLTFLoaderExtension {
  83660. /**
  83661. * Default ior Value from the spec.
  83662. */
  83663. private static readonly _DEFAULT_IOR;
  83664. /**
  83665. * The name of this extension.
  83666. */
  83667. readonly name: string;
  83668. /**
  83669. * Defines whether this extension is enabled.
  83670. */
  83671. enabled: boolean;
  83672. /**
  83673. * Defines a number that determines the order the extensions are applied.
  83674. */
  83675. order: number;
  83676. private _loader;
  83677. /** @hidden */
  83678. constructor(loader: GLTFLoader);
  83679. /** @hidden */
  83680. dispose(): void;
  83681. /** @hidden */
  83682. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83683. private _loadIorPropertiesAsync;
  83684. }
  83685. }
  83686. declare module BABYLON.GLTF2.Loader.Extensions {
  83687. /**
  83688. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83689. * !!! Experimental Extension Subject to Changes !!!
  83690. */
  83691. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83692. /**
  83693. * The name of this extension.
  83694. */
  83695. readonly name: string;
  83696. /**
  83697. * Defines whether this extension is enabled.
  83698. */
  83699. enabled: boolean;
  83700. private _loader;
  83701. private _variants?;
  83702. /** @hidden */
  83703. constructor(loader: GLTFLoader);
  83704. /** @hidden */
  83705. dispose(): void;
  83706. /**
  83707. * Gets the list of available variant names for this asset.
  83708. * @param rootMesh The glTF root mesh
  83709. * @returns the list of all the variant names for this model
  83710. */
  83711. static GetAvailableVariants(rootMesh: Mesh): string[];
  83712. /**
  83713. * Gets the list of available variant names for this asset.
  83714. * @param rootMesh The glTF root mesh
  83715. * @returns the list of all the variant names for this model
  83716. */
  83717. getAvailableVariants(rootMesh: Mesh): string[];
  83718. /**
  83719. * Select a variant given a variant name or a list of variant names.
  83720. * @param rootMesh The glTF root mesh
  83721. * @param variantName The variant name(s) to select.
  83722. */
  83723. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83724. /**
  83725. * Select a variant given a variant name or a list of variant names.
  83726. * @param rootMesh The glTF root mesh
  83727. * @param variantName The variant name(s) to select.
  83728. */
  83729. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83730. /**
  83731. * Reset back to the original before selecting a variant.
  83732. * @param rootMesh The glTF root mesh
  83733. */
  83734. static Reset(rootMesh: Mesh): void;
  83735. /**
  83736. * Reset back to the original before selecting a variant.
  83737. * @param rootMesh The glTF root mesh
  83738. */
  83739. reset(rootMesh: Mesh): void;
  83740. /**
  83741. * Gets the last selected variant name(s) or null if original.
  83742. * @param rootMesh The glTF root mesh
  83743. * @returns The selected variant name(s).
  83744. */
  83745. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83746. /**
  83747. * Gets the last selected variant name(s) or null if original.
  83748. * @param rootMesh The glTF root mesh
  83749. * @returns The selected variant name(s).
  83750. */
  83751. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83752. private static _GetExtensionMetadata;
  83753. /** @hidden */
  83754. onLoading(): void;
  83755. /** @hidden */
  83756. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83757. }
  83758. }
  83759. declare module BABYLON.GLTF2.Loader.Extensions {
  83760. /**
  83761. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  83762. * !!! Experimental Extension Subject to Changes !!!
  83763. */
  83764. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  83765. /**
  83766. * The name of this extension.
  83767. */
  83768. readonly name: string;
  83769. /**
  83770. * Defines whether this extension is enabled.
  83771. */
  83772. enabled: boolean;
  83773. /**
  83774. * Defines a number that determines the order the extensions are applied.
  83775. */
  83776. order: number;
  83777. private _loader;
  83778. /** @hidden */
  83779. constructor(loader: GLTFLoader);
  83780. /** @hidden */
  83781. dispose(): void;
  83782. /** @hidden */
  83783. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83784. private _loadTransparentPropertiesAsync;
  83785. }
  83786. }
  83787. declare module BABYLON.GLTF2.Loader.Extensions {
  83788. /**
  83789. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  83790. */
  83791. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  83792. /**
  83793. * The name of this extension.
  83794. */
  83795. readonly name: string;
  83796. /**
  83797. * Defines whether this extension is enabled.
  83798. */
  83799. enabled: boolean;
  83800. /** @hidden */
  83801. constructor(loader: GLTFLoader);
  83802. /** @hidden */
  83803. dispose(): void;
  83804. }
  83805. }
  83806. declare module BABYLON.GLTF2.Loader.Extensions {
  83807. /**
  83808. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  83809. * !!! Experimental Extension Subject to Changes !!!
  83810. */
  83811. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  83812. /** The name of this extension. */
  83813. readonly name: string;
  83814. /** Defines whether this extension is enabled. */
  83815. enabled: boolean;
  83816. private _loader;
  83817. /** @hidden */
  83818. constructor(loader: GLTFLoader);
  83819. /** @hidden */
  83820. dispose(): void;
  83821. /** @hidden */
  83822. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83823. }
  83824. }
  83825. declare module BABYLON.GLTF2.Loader.Extensions {
  83826. /**
  83827. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  83828. */
  83829. export class KHR_texture_transform implements IGLTFLoaderExtension {
  83830. /**
  83831. * The name of this extension.
  83832. */
  83833. readonly name: string;
  83834. /**
  83835. * Defines whether this extension is enabled.
  83836. */
  83837. enabled: boolean;
  83838. private _loader;
  83839. /** @hidden */
  83840. constructor(loader: GLTFLoader);
  83841. /** @hidden */
  83842. dispose(): void;
  83843. /** @hidden */
  83844. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83845. }
  83846. }
  83847. declare module BABYLON.GLTF2.Loader.Extensions {
  83848. /**
  83849. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  83850. * !!! Experimental Extension Subject to Changes !!!
  83851. */
  83852. export class KHR_xmp implements IGLTFLoaderExtension {
  83853. /**
  83854. * The name of this extension.
  83855. */
  83856. readonly name: string;
  83857. /**
  83858. * Defines whether this extension is enabled.
  83859. */
  83860. enabled: boolean;
  83861. /**
  83862. * Defines a number that determines the order the extensions are applied.
  83863. */
  83864. order: number;
  83865. private _loader;
  83866. /** @hidden */
  83867. constructor(loader: GLTFLoader);
  83868. /** @hidden */
  83869. dispose(): void;
  83870. /**
  83871. * Called after the loader state changes to LOADING.
  83872. */
  83873. onLoading(): void;
  83874. }
  83875. }
  83876. declare module BABYLON.GLTF2.Loader.Extensions {
  83877. /**
  83878. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  83879. */
  83880. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  83881. /**
  83882. * The name of this extension.
  83883. */
  83884. readonly name: string;
  83885. /**
  83886. * Defines whether this extension is enabled.
  83887. */
  83888. enabled: boolean;
  83889. private _loader;
  83890. private _clips;
  83891. private _emitters;
  83892. /** @hidden */
  83893. constructor(loader: GLTFLoader);
  83894. /** @hidden */
  83895. dispose(): void;
  83896. /** @hidden */
  83897. onLoading(): void;
  83898. /** @hidden */
  83899. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83900. /** @hidden */
  83901. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83902. /** @hidden */
  83903. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83904. private _loadClipAsync;
  83905. private _loadEmitterAsync;
  83906. private _getEventAction;
  83907. private _loadAnimationEventAsync;
  83908. }
  83909. }
  83910. declare module BABYLON.GLTF2.Loader.Extensions {
  83911. /**
  83912. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  83913. */
  83914. export class MSFT_lod implements IGLTFLoaderExtension {
  83915. /**
  83916. * The name of this extension.
  83917. */
  83918. readonly name: string;
  83919. /**
  83920. * Defines whether this extension is enabled.
  83921. */
  83922. enabled: boolean;
  83923. /**
  83924. * Defines a number that determines the order the extensions are applied.
  83925. */
  83926. order: number;
  83927. /**
  83928. * Maximum number of LODs to load, starting from the lowest LOD.
  83929. */
  83930. maxLODsToLoad: number;
  83931. /**
  83932. * Observable raised when all node LODs of one level are loaded.
  83933. * The event data is the index of the loaded LOD starting from zero.
  83934. * Dispose the loader to cancel the loading of the next level of LODs.
  83935. */
  83936. onNodeLODsLoadedObservable: Observable<number>;
  83937. /**
  83938. * Observable raised when all material LODs of one level are loaded.
  83939. * The event data is the index of the loaded LOD starting from zero.
  83940. * Dispose the loader to cancel the loading of the next level of LODs.
  83941. */
  83942. onMaterialLODsLoadedObservable: Observable<number>;
  83943. private _loader;
  83944. private _bufferLODs;
  83945. private _nodeIndexLOD;
  83946. private _nodeSignalLODs;
  83947. private _nodePromiseLODs;
  83948. private _nodeBufferLODs;
  83949. private _materialIndexLOD;
  83950. private _materialSignalLODs;
  83951. private _materialPromiseLODs;
  83952. private _materialBufferLODs;
  83953. /** @hidden */
  83954. constructor(loader: GLTFLoader);
  83955. /** @hidden */
  83956. dispose(): void;
  83957. /** @hidden */
  83958. onReady(): void;
  83959. /** @hidden */
  83960. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83961. /** @hidden */
  83962. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83963. /** @hidden */
  83964. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83965. /** @hidden */
  83966. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83967. /** @hidden */
  83968. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83969. private _loadBufferLOD;
  83970. /**
  83971. * Gets an array of LOD properties from lowest to highest.
  83972. */
  83973. private _getLODs;
  83974. private _disposeTransformNode;
  83975. private _disposeMaterials;
  83976. }
  83977. }
  83978. declare module BABYLON.GLTF2.Loader.Extensions {
  83979. /** @hidden */
  83980. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  83981. readonly name: string;
  83982. enabled: boolean;
  83983. private _loader;
  83984. constructor(loader: GLTFLoader);
  83985. dispose(): void;
  83986. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83987. }
  83988. }
  83989. declare module BABYLON.GLTF2.Loader.Extensions {
  83990. /** @hidden */
  83991. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  83992. readonly name: string;
  83993. enabled: boolean;
  83994. private _loader;
  83995. constructor(loader: GLTFLoader);
  83996. dispose(): void;
  83997. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83998. }
  83999. }
  84000. declare module BABYLON.GLTF2.Loader.Extensions {
  84001. /**
  84002. * Store glTF extras (if present) in BJS objects' metadata
  84003. */
  84004. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  84005. /**
  84006. * The name of this extension.
  84007. */
  84008. readonly name: string;
  84009. /**
  84010. * Defines whether this extension is enabled.
  84011. */
  84012. enabled: boolean;
  84013. private _loader;
  84014. private _assignExtras;
  84015. /** @hidden */
  84016. constructor(loader: GLTFLoader);
  84017. /** @hidden */
  84018. dispose(): void;
  84019. /** @hidden */
  84020. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84021. /** @hidden */
  84022. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  84023. /** @hidden */
  84024. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  84025. }
  84026. }
  84027. declare module BABYLON {
  84028. /**
  84029. * Class reading and parsing the MTL file bundled with the obj file.
  84030. */
  84031. export class MTLFileLoader {
  84032. /**
  84033. * Invert Y-Axis of referenced textures on load
  84034. */
  84035. static INVERT_TEXTURE_Y: boolean;
  84036. /**
  84037. * All material loaded from the mtl will be set here
  84038. */
  84039. materials: StandardMaterial[];
  84040. /**
  84041. * This function will read the mtl file and create each material described inside
  84042. * This function could be improve by adding :
  84043. * -some component missing (Ni, Tf...)
  84044. * -including the specific options available
  84045. *
  84046. * @param scene defines the scene the material will be created in
  84047. * @param data defines the mtl data to parse
  84048. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  84049. * @param forAssetContainer defines if the material should be registered in the scene
  84050. */
  84051. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  84052. /**
  84053. * Gets the texture for the material.
  84054. *
  84055. * If the material is imported from input file,
  84056. * We sanitize the url to ensure it takes the textre from aside the material.
  84057. *
  84058. * @param rootUrl The root url to load from
  84059. * @param value The value stored in the mtl
  84060. * @return The Texture
  84061. */
  84062. private static _getTexture;
  84063. }
  84064. }
  84065. declare module BABYLON {
  84066. /**
  84067. * Options for loading OBJ/MTL files
  84068. */
  84069. type MeshLoadOptions = {
  84070. /**
  84071. * Defines if UVs are optimized by default during load.
  84072. */
  84073. OptimizeWithUV: boolean;
  84074. /**
  84075. * Defines custom scaling of UV coordinates of loaded meshes.
  84076. */
  84077. UVScaling: Vector2;
  84078. /**
  84079. * Invert model on y-axis (does a model scaling inversion)
  84080. */
  84081. InvertY: boolean;
  84082. /**
  84083. * Invert Y-Axis of referenced textures on load
  84084. */
  84085. InvertTextureY: boolean;
  84086. /**
  84087. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84088. */
  84089. ImportVertexColors: boolean;
  84090. /**
  84091. * Compute the normals for the model, even if normals are present in the file.
  84092. */
  84093. ComputeNormals: boolean;
  84094. /**
  84095. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84096. */
  84097. SkipMaterials: boolean;
  84098. /**
  84099. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84100. */
  84101. MaterialLoadingFailsSilently: boolean;
  84102. };
  84103. /**
  84104. * OBJ file type loader.
  84105. * This is a babylon scene loader plugin.
  84106. */
  84107. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  84108. /**
  84109. * Defines if UVs are optimized by default during load.
  84110. */
  84111. static OPTIMIZE_WITH_UV: boolean;
  84112. /**
  84113. * Invert model on y-axis (does a model scaling inversion)
  84114. */
  84115. static INVERT_Y: boolean;
  84116. /**
  84117. * Invert Y-Axis of referenced textures on load
  84118. */
  84119. static get INVERT_TEXTURE_Y(): boolean;
  84120. static set INVERT_TEXTURE_Y(value: boolean);
  84121. /**
  84122. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84123. */
  84124. static IMPORT_VERTEX_COLORS: boolean;
  84125. /**
  84126. * Compute the normals for the model, even if normals are present in the file.
  84127. */
  84128. static COMPUTE_NORMALS: boolean;
  84129. /**
  84130. * Defines custom scaling of UV coordinates of loaded meshes.
  84131. */
  84132. static UV_SCALING: Vector2;
  84133. /**
  84134. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84135. */
  84136. static SKIP_MATERIALS: boolean;
  84137. /**
  84138. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84139. *
  84140. * Defaults to true for backwards compatibility.
  84141. */
  84142. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  84143. /**
  84144. * Defines the name of the plugin.
  84145. */
  84146. name: string;
  84147. /**
  84148. * Defines the extension the plugin is able to load.
  84149. */
  84150. extensions: string;
  84151. /** @hidden */
  84152. obj: RegExp;
  84153. /** @hidden */
  84154. group: RegExp;
  84155. /** @hidden */
  84156. mtllib: RegExp;
  84157. /** @hidden */
  84158. usemtl: RegExp;
  84159. /** @hidden */
  84160. smooth: RegExp;
  84161. /** @hidden */
  84162. vertexPattern: RegExp;
  84163. /** @hidden */
  84164. normalPattern: RegExp;
  84165. /** @hidden */
  84166. uvPattern: RegExp;
  84167. /** @hidden */
  84168. facePattern1: RegExp;
  84169. /** @hidden */
  84170. facePattern2: RegExp;
  84171. /** @hidden */
  84172. facePattern3: RegExp;
  84173. /** @hidden */
  84174. facePattern4: RegExp;
  84175. /** @hidden */
  84176. facePattern5: RegExp;
  84177. private _forAssetContainer;
  84178. private _meshLoadOptions;
  84179. /**
  84180. * Creates loader for .OBJ files
  84181. *
  84182. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84183. */
  84184. constructor(meshLoadOptions?: MeshLoadOptions);
  84185. private static get currentMeshLoadOptions();
  84186. /**
  84187. * Calls synchronously the MTL file attached to this obj.
  84188. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84189. * Without this function materials are not displayed in the first frame (but displayed after).
  84190. * In consequence it is impossible to get material information in your HTML file
  84191. *
  84192. * @param url The URL of the MTL file
  84193. * @param rootUrl
  84194. * @param onSuccess Callback function to be called when the MTL file is loaded
  84195. * @private
  84196. */
  84197. private _loadMTL;
  84198. /**
  84199. * Instantiates a OBJ file loader plugin.
  84200. * @returns the created plugin
  84201. */
  84202. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84203. /**
  84204. * If the data string can be loaded directly.
  84205. *
  84206. * @param data string containing the file data
  84207. * @returns if the data can be loaded directly
  84208. */
  84209. canDirectLoad(data: string): boolean;
  84210. /**
  84211. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84212. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84213. * @param scene the scene the meshes should be added to
  84214. * @param data the OBJ data to load
  84215. * @param rootUrl root url to load from
  84216. * @param onProgress event that fires when loading progress has occured
  84217. * @param fileName Defines the name of the file to load
  84218. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84219. */
  84220. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  84221. meshes: AbstractMesh[];
  84222. particleSystems: IParticleSystem[];
  84223. skeletons: Skeleton[];
  84224. animationGroups: AnimationGroup[];
  84225. }>;
  84226. /**
  84227. * Imports all objects from the loaded OBJ data and adds them to the scene
  84228. * @param scene the scene the objects should be added to
  84229. * @param data the OBJ data to load
  84230. * @param rootUrl root url to load from
  84231. * @param onProgress event that fires when loading progress has occured
  84232. * @param fileName Defines the name of the file to load
  84233. * @returns a promise which completes when objects have been loaded to the scene
  84234. */
  84235. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84236. /**
  84237. * Load into an asset container.
  84238. * @param scene The scene to load into
  84239. * @param data The data to import
  84240. * @param rootUrl The root url for scene and resources
  84241. * @param onProgress The callback when the load progresses
  84242. * @param fileName Defines the name of the file to load
  84243. * @returns The loaded asset container
  84244. */
  84245. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84246. /**
  84247. * Read the OBJ file and create an Array of meshes.
  84248. * Each mesh contains all information given by the OBJ and the MTL file.
  84249. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84250. *
  84251. * @param meshesNames
  84252. * @param scene Scene The scene where are displayed the data
  84253. * @param data String The content of the obj file
  84254. * @param rootUrl String The path to the folder
  84255. * @returns Array<AbstractMesh>
  84256. * @private
  84257. */
  84258. private _parseSolid;
  84259. }
  84260. }
  84261. declare module BABYLON {
  84262. /**
  84263. * STL file type loader.
  84264. * This is a babylon scene loader plugin.
  84265. */
  84266. export class STLFileLoader implements ISceneLoaderPlugin {
  84267. /** @hidden */
  84268. solidPattern: RegExp;
  84269. /** @hidden */
  84270. facetsPattern: RegExp;
  84271. /** @hidden */
  84272. normalPattern: RegExp;
  84273. /** @hidden */
  84274. vertexPattern: RegExp;
  84275. /**
  84276. * Defines the name of the plugin.
  84277. */
  84278. name: string;
  84279. /**
  84280. * Defines the extensions the stl loader is able to load.
  84281. * force data to come in as an ArrayBuffer
  84282. * we'll convert to string if it looks like it's an ASCII .stl
  84283. */
  84284. extensions: ISceneLoaderPluginExtensions;
  84285. /**
  84286. * Import meshes into a scene.
  84287. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84288. * @param scene The scene to import into
  84289. * @param data The data to import
  84290. * @param rootUrl The root url for scene and resources
  84291. * @param meshes The meshes array to import into
  84292. * @param particleSystems The particle systems array to import into
  84293. * @param skeletons The skeletons array to import into
  84294. * @param onError The callback when import fails
  84295. * @returns True if successful or false otherwise
  84296. */
  84297. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84298. /**
  84299. * Load into a scene.
  84300. * @param scene The scene to load into
  84301. * @param data The data to import
  84302. * @param rootUrl The root url for scene and resources
  84303. * @param onError The callback when import fails
  84304. * @returns true if successful or false otherwise
  84305. */
  84306. load(scene: Scene, data: any, rootUrl: string): boolean;
  84307. /**
  84308. * Load into an asset container.
  84309. * @param scene The scene to load into
  84310. * @param data The data to import
  84311. * @param rootUrl The root url for scene and resources
  84312. * @param onError The callback when import fails
  84313. * @returns The loaded asset container
  84314. */
  84315. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84316. private _isBinary;
  84317. private _parseBinary;
  84318. private _parseASCII;
  84319. }
  84320. }
  84321. declare module BABYLON {
  84322. /**
  84323. * Class for generating OBJ data from a Babylon scene.
  84324. */
  84325. export class OBJExport {
  84326. /**
  84327. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84328. * @param mesh defines the list of meshes to serialize
  84329. * @param materials defines if materials should be exported
  84330. * @param matlibname defines the name of the associated mtl file
  84331. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84332. * @returns the OBJ content
  84333. */
  84334. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84335. /**
  84336. * Exports the material(s) of a mesh in .MTL file format (text)
  84337. * @param mesh defines the mesh to extract the material from
  84338. * @returns the mtl content
  84339. */
  84340. static MTL(mesh: Mesh): string;
  84341. }
  84342. }
  84343. declare module BABYLON {
  84344. /** @hidden */
  84345. export var __IGLTFExporterExtension: number;
  84346. /**
  84347. * Interface for extending the exporter
  84348. * @hidden
  84349. */
  84350. export interface IGLTFExporterExtension {
  84351. /**
  84352. * The name of this extension
  84353. */
  84354. readonly name: string;
  84355. /**
  84356. * Defines whether this extension is enabled
  84357. */
  84358. enabled: boolean;
  84359. /**
  84360. * Defines whether this extension is required
  84361. */
  84362. required: boolean;
  84363. }
  84364. }
  84365. declare module BABYLON.GLTF2.Exporter {
  84366. /** @hidden */
  84367. export var __IGLTFExporterExtensionV2: number;
  84368. /**
  84369. * Interface for a glTF exporter extension
  84370. * @hidden
  84371. */
  84372. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84373. /**
  84374. * Define this method to modify the default behavior before exporting a texture
  84375. * @param context The context when loading the asset
  84376. * @param babylonTexture The Babylon.js texture
  84377. * @param mimeType The mime-type of the generated image
  84378. * @returns A promise that resolves with the exported texture
  84379. */
  84380. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84381. /**
  84382. * Define this method to get notified when a texture info is created
  84383. * @param context The context when loading the asset
  84384. * @param textureInfo The glTF texture info
  84385. * @param babylonTexture The Babylon.js texture
  84386. */
  84387. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84388. /**
  84389. * Define this method to modify the default behavior when exporting texture info
  84390. * @param context The context when loading the asset
  84391. * @param meshPrimitive glTF mesh primitive
  84392. * @param babylonSubMesh Babylon submesh
  84393. * @param binaryWriter glTF serializer binary writer instance
  84394. * @returns nullable IMeshPrimitive promise
  84395. */
  84396. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84397. /**
  84398. * Define this method to modify the default behavior when exporting a node
  84399. * @param context The context when exporting the node
  84400. * @param node glTF node
  84401. * @param babylonNode BabylonJS node
  84402. * @returns nullable INode promise
  84403. */
  84404. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84405. [key: number]: number;
  84406. }): Promise<Nullable<INode>>;
  84407. /**
  84408. * Define this method to modify the default behavior when exporting a material
  84409. * @param material glTF material
  84410. * @param babylonMaterial BabylonJS material
  84411. * @returns nullable IMaterial promise
  84412. */
  84413. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84414. /**
  84415. * Define this method to return additional textures to export from a material
  84416. * @param material glTF material
  84417. * @param babylonMaterial BabylonJS material
  84418. * @returns List of textures
  84419. */
  84420. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84421. /** Gets a boolean indicating that this extension was used */
  84422. wasUsed: boolean;
  84423. /** Gets a boolean indicating that this extension is required for the file to work */
  84424. required: boolean;
  84425. /**
  84426. * Called after the exporter state changes to EXPORTING
  84427. */
  84428. onExporting?(): void;
  84429. }
  84430. }
  84431. declare module BABYLON.GLTF2.Exporter {
  84432. /**
  84433. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  84434. * @hidden
  84435. */
  84436. export class _GLTFMaterialExporter {
  84437. /**
  84438. * Represents the dielectric specular values for R, G and B
  84439. */
  84440. private static readonly _DielectricSpecular;
  84441. /**
  84442. * Allows the maximum specular power to be defined for material calculations
  84443. */
  84444. private static readonly _MaxSpecularPower;
  84445. /**
  84446. * Mapping to store textures
  84447. */
  84448. private _textureMap;
  84449. /**
  84450. * Numeric tolerance value
  84451. */
  84452. private static readonly _Epsilon;
  84453. /**
  84454. * Reference to the glTF Exporter
  84455. */
  84456. private _exporter;
  84457. constructor(exporter: _Exporter);
  84458. /**
  84459. * Specifies if two colors are approximately equal in value
  84460. * @param color1 first color to compare to
  84461. * @param color2 second color to compare to
  84462. * @param epsilon threshold value
  84463. */
  84464. private static FuzzyEquals;
  84465. /**
  84466. * Gets the materials from a Babylon scene and converts them to glTF materials
  84467. * @param scene babylonjs scene
  84468. * @param mimeType texture mime type
  84469. * @param images array of images
  84470. * @param textures array of textures
  84471. * @param materials array of materials
  84472. * @param imageData mapping of texture names to base64 textures
  84473. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84474. */
  84475. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84476. /**
  84477. * Makes a copy of the glTF material without the texture parameters
  84478. * @param originalMaterial original glTF material
  84479. * @returns glTF material without texture parameters
  84480. */
  84481. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84482. /**
  84483. * Specifies if the material has any texture parameters present
  84484. * @param material glTF Material
  84485. * @returns boolean specifying if texture parameters are present
  84486. */
  84487. _hasTexturesPresent(material: IMaterial): boolean;
  84488. /**
  84489. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84490. * @param babylonStandardMaterial
  84491. * @returns glTF Metallic Roughness Material representation
  84492. */
  84493. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84494. /**
  84495. * Computes the metallic factor
  84496. * @param diffuse diffused value
  84497. * @param specular specular value
  84498. * @param oneMinusSpecularStrength one minus the specular strength
  84499. * @returns metallic value
  84500. */
  84501. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84502. /**
  84503. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84504. * @param glTFMaterial glTF material
  84505. * @param babylonMaterial Babylon material
  84506. */
  84507. private static _SetAlphaMode;
  84508. /**
  84509. * Converts a Babylon Standard Material to a glTF Material
  84510. * @param babylonStandardMaterial BJS Standard Material
  84511. * @param mimeType mime type to use for the textures
  84512. * @param images array of glTF image interfaces
  84513. * @param textures array of glTF texture interfaces
  84514. * @param materials array of glTF material interfaces
  84515. * @param imageData map of image file name to data
  84516. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84517. */
  84518. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84519. private _finishMaterial;
  84520. /**
  84521. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84522. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84523. * @param mimeType mime type to use for the textures
  84524. * @param images array of glTF image interfaces
  84525. * @param textures array of glTF texture interfaces
  84526. * @param materials array of glTF material interfaces
  84527. * @param imageData map of image file name to data
  84528. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84529. */
  84530. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84531. /**
  84532. * Converts an image typed array buffer to a base64 image
  84533. * @param buffer typed array buffer
  84534. * @param width width of the image
  84535. * @param height height of the image
  84536. * @param mimeType mimetype of the image
  84537. * @returns base64 image string
  84538. */
  84539. private _createBase64FromCanvasAsync;
  84540. /**
  84541. * Generates a white texture based on the specified width and height
  84542. * @param width width of the texture in pixels
  84543. * @param height height of the texture in pixels
  84544. * @param scene babylonjs scene
  84545. * @returns white texture
  84546. */
  84547. private _createWhiteTexture;
  84548. /**
  84549. * 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
  84550. * @param texture1 first texture to resize
  84551. * @param texture2 second texture to resize
  84552. * @param scene babylonjs scene
  84553. * @returns resized textures or null
  84554. */
  84555. private _resizeTexturesToSameDimensions;
  84556. /**
  84557. * Converts an array of pixels to a Float32Array
  84558. * Throws an error if the pixel format is not supported
  84559. * @param pixels - array buffer containing pixel values
  84560. * @returns Float32 of pixels
  84561. */
  84562. private _convertPixelArrayToFloat32;
  84563. /**
  84564. * Convert Specular Glossiness Textures to Metallic Roughness
  84565. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84566. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84567. * @param diffuseTexture texture used to store diffuse information
  84568. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84569. * @param factors specular glossiness material factors
  84570. * @param mimeType the mime type to use for the texture
  84571. * @returns pbr metallic roughness interface or null
  84572. */
  84573. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84574. /**
  84575. * Converts specular glossiness material properties to metallic roughness
  84576. * @param specularGlossiness interface with specular glossiness material properties
  84577. * @returns interface with metallic roughness material properties
  84578. */
  84579. private _convertSpecularGlossinessToMetallicRoughness;
  84580. /**
  84581. * Calculates the surface reflectance, independent of lighting conditions
  84582. * @param color Color source to calculate brightness from
  84583. * @returns number representing the perceived brightness, or zero if color is undefined
  84584. */
  84585. private _getPerceivedBrightness;
  84586. /**
  84587. * Returns the maximum color component value
  84588. * @param color
  84589. * @returns maximum color component value, or zero if color is null or undefined
  84590. */
  84591. private _getMaxComponent;
  84592. /**
  84593. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84594. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84595. * @param mimeType mime type to use for the textures
  84596. * @param images array of glTF image interfaces
  84597. * @param textures array of glTF texture interfaces
  84598. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84599. * @param imageData map of image file name to data
  84600. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84601. * @returns glTF PBR Metallic Roughness factors
  84602. */
  84603. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84604. private _getGLTFTextureSampler;
  84605. private _getGLTFTextureWrapMode;
  84606. private _getGLTFTextureWrapModesSampler;
  84607. /**
  84608. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84609. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84610. * @param mimeType mime type to use for the textures
  84611. * @param images array of glTF image interfaces
  84612. * @param textures array of glTF texture interfaces
  84613. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84614. * @param imageData map of image file name to data
  84615. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84616. * @returns glTF PBR Metallic Roughness factors
  84617. */
  84618. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84619. /**
  84620. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84621. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84622. * @param mimeType mime type to use for the textures
  84623. * @param images array of glTF image interfaces
  84624. * @param textures array of glTF texture interfaces
  84625. * @param materials array of glTF material interfaces
  84626. * @param imageData map of image file name to data
  84627. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84628. */
  84629. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84630. private setMetallicRoughnessPbrMaterial;
  84631. private getPixelsFromTexture;
  84632. /**
  84633. * Extracts a texture from a Babylon texture into file data and glTF data
  84634. * @param babylonTexture Babylon texture to extract
  84635. * @param mimeType Mime Type of the babylonTexture
  84636. * @return glTF texture info, or null if the texture format is not supported
  84637. */
  84638. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84639. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84640. /**
  84641. * Builds a texture from base64 string
  84642. * @param base64Texture base64 texture string
  84643. * @param baseTextureName Name to use for the texture
  84644. * @param mimeType image mime type for the texture
  84645. * @param images array of images
  84646. * @param textures array of textures
  84647. * @param imageData map of image data
  84648. * @returns glTF texture info, or null if the texture format is not supported
  84649. */
  84650. private _getTextureInfoFromBase64;
  84651. }
  84652. }
  84653. declare module BABYLON {
  84654. /**
  84655. * Class for holding and downloading glTF file data
  84656. */
  84657. export class GLTFData {
  84658. /**
  84659. * Object which contains the file name as the key and its data as the value
  84660. */
  84661. glTFFiles: {
  84662. [fileName: string]: string | Blob;
  84663. };
  84664. /**
  84665. * Initializes the glTF file object
  84666. */
  84667. constructor();
  84668. /**
  84669. * Downloads the glTF data as files based on their names and data
  84670. */
  84671. downloadFiles(): void;
  84672. }
  84673. }
  84674. declare module BABYLON {
  84675. /**
  84676. * Holds a collection of exporter options and parameters
  84677. */
  84678. export interface IExportOptions {
  84679. /**
  84680. * Function which indicates whether a babylon node should be exported or not
  84681. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84682. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84683. */
  84684. shouldExportNode?(node: Node): boolean;
  84685. /**
  84686. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84687. * @param metadata source metadata to read from
  84688. * @returns the data to store to glTF node extras
  84689. */
  84690. metadataSelector?(metadata: any): any;
  84691. /**
  84692. * The sample rate to bake animation curves
  84693. */
  84694. animationSampleRate?: number;
  84695. /**
  84696. * Begin serialization without waiting for the scene to be ready
  84697. */
  84698. exportWithoutWaitingForScene?: boolean;
  84699. /**
  84700. * Indicates if coordinate system swapping root nodes should be included in export
  84701. */
  84702. includeCoordinateSystemConversionNodes?: boolean;
  84703. }
  84704. /**
  84705. * Class for generating glTF data from a Babylon scene.
  84706. */
  84707. export class GLTF2Export {
  84708. /**
  84709. * Exports the geometry of the scene to .gltf file format asynchronously
  84710. * @param scene Babylon scene with scene hierarchy information
  84711. * @param filePrefix File prefix to use when generating the glTF file
  84712. * @param options Exporter options
  84713. * @returns Returns an object with a .gltf file and associates texture names
  84714. * as keys and their data and paths as values
  84715. */
  84716. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84717. private static _PreExportAsync;
  84718. private static _PostExportAsync;
  84719. /**
  84720. * Exports the geometry of the scene to .glb file format asychronously
  84721. * @param scene Babylon scene with scene hierarchy information
  84722. * @param filePrefix File prefix to use when generating glb file
  84723. * @param options Exporter options
  84724. * @returns Returns an object with a .glb filename as key and data as value
  84725. */
  84726. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84727. }
  84728. }
  84729. declare module BABYLON.GLTF2.Exporter {
  84730. /**
  84731. * @hidden
  84732. */
  84733. export class _GLTFUtilities {
  84734. /**
  84735. * Creates a buffer view based on the supplied arguments
  84736. * @param bufferIndex index value of the specified buffer
  84737. * @param byteOffset byte offset value
  84738. * @param byteLength byte length of the bufferView
  84739. * @param byteStride byte distance between conequential elements
  84740. * @param name name of the buffer view
  84741. * @returns bufferView for glTF
  84742. */
  84743. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  84744. /**
  84745. * Creates an accessor based on the supplied arguments
  84746. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  84747. * @param name The name of the accessor
  84748. * @param type The type of the accessor
  84749. * @param componentType The datatype of components in the attribute
  84750. * @param count The number of attributes referenced by this accessor
  84751. * @param byteOffset The offset relative to the start of the bufferView in bytes
  84752. * @param min Minimum value of each component in this attribute
  84753. * @param max Maximum value of each component in this attribute
  84754. * @returns accessor for glTF
  84755. */
  84756. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  84757. /**
  84758. * Calculates the minimum and maximum values of an array of position floats
  84759. * @param positions Positions array of a mesh
  84760. * @param vertexStart Starting vertex offset to calculate min and max values
  84761. * @param vertexCount Number of vertices to check for min and max values
  84762. * @returns min number array and max number array
  84763. */
  84764. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  84765. min: number[];
  84766. max: number[];
  84767. };
  84768. /**
  84769. * Converts a new right-handed Vector3
  84770. * @param vector vector3 array
  84771. * @returns right-handed Vector3
  84772. */
  84773. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  84774. /**
  84775. * Converts a Vector3 to right-handed
  84776. * @param vector Vector3 to convert to right-handed
  84777. */
  84778. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  84779. /**
  84780. * Converts a three element number array to right-handed
  84781. * @param vector number array to convert to right-handed
  84782. */
  84783. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  84784. /**
  84785. * Converts a new right-handed Vector3
  84786. * @param vector vector3 array
  84787. * @returns right-handed Vector3
  84788. */
  84789. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  84790. /**
  84791. * Converts a Vector3 to right-handed
  84792. * @param vector Vector3 to convert to right-handed
  84793. */
  84794. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  84795. /**
  84796. * Converts a three element number array to right-handed
  84797. * @param vector number array to convert to right-handed
  84798. */
  84799. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  84800. /**
  84801. * Converts a Vector4 to right-handed
  84802. * @param vector Vector4 to convert to right-handed
  84803. */
  84804. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  84805. /**
  84806. * Converts a Vector4 to right-handed
  84807. * @param vector Vector4 to convert to right-handed
  84808. */
  84809. static _GetRightHandedArray4FromRef(vector: number[]): void;
  84810. /**
  84811. * Converts a Quaternion to right-handed
  84812. * @param quaternion Source quaternion to convert to right-handed
  84813. */
  84814. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  84815. /**
  84816. * Converts a Quaternion to right-handed
  84817. * @param quaternion Source quaternion to convert to right-handed
  84818. */
  84819. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  84820. static _NormalizeTangentFromRef(tangent: Vector4): void;
  84821. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  84822. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  84823. }
  84824. }
  84825. declare module BABYLON.GLTF2.Exporter {
  84826. /**
  84827. * Converts Babylon Scene into glTF 2.0.
  84828. * @hidden
  84829. */
  84830. export class _Exporter {
  84831. /**
  84832. * Stores the glTF to export
  84833. */
  84834. _glTF: IGLTF;
  84835. /**
  84836. * Stores all generated buffer views, which represents views into the main glTF buffer data
  84837. */
  84838. _bufferViews: IBufferView[];
  84839. /**
  84840. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  84841. */
  84842. _accessors: IAccessor[];
  84843. /**
  84844. * Stores all the generated nodes, which contains transform and/or mesh information per node
  84845. */
  84846. _nodes: INode[];
  84847. /**
  84848. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  84849. */
  84850. private _scenes;
  84851. /**
  84852. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  84853. */
  84854. private _meshes;
  84855. /**
  84856. * Stores all the generated material information, which represents the appearance of each primitive
  84857. */
  84858. _materials: IMaterial[];
  84859. _materialMap: {
  84860. [materialID: number]: number;
  84861. };
  84862. /**
  84863. * Stores all the generated texture information, which is referenced by glTF materials
  84864. */
  84865. _textures: ITexture[];
  84866. /**
  84867. * Stores all the generated image information, which is referenced by glTF textures
  84868. */
  84869. _images: IImage[];
  84870. /**
  84871. * Stores all the texture samplers
  84872. */
  84873. _samplers: ISampler[];
  84874. /**
  84875. * Stores all the generated glTF skins
  84876. */
  84877. _skins: ISkin[];
  84878. /**
  84879. * Stores all the generated animation samplers, which is referenced by glTF animations
  84880. */
  84881. /**
  84882. * Stores the animations for glTF models
  84883. */
  84884. private _animations;
  84885. /**
  84886. * Stores the total amount of bytes stored in the glTF buffer
  84887. */
  84888. private _totalByteLength;
  84889. /**
  84890. * Stores a reference to the Babylon scene containing the source geometry and material information
  84891. */
  84892. _babylonScene: Scene;
  84893. /**
  84894. * Stores a map of the image data, where the key is the file name and the value
  84895. * is the image data
  84896. */
  84897. _imageData: {
  84898. [fileName: string]: {
  84899. data: Uint8Array;
  84900. mimeType: ImageMimeType;
  84901. };
  84902. };
  84903. protected _orderedImageData: Array<{
  84904. data: Uint8Array;
  84905. mimeType: ImageMimeType;
  84906. }>;
  84907. /**
  84908. * Stores a map of the unique id of a node to its index in the node array
  84909. */
  84910. _nodeMap: {
  84911. [key: number]: number;
  84912. };
  84913. /**
  84914. * Specifies if the source Babylon scene was left handed, and needed conversion.
  84915. */
  84916. _convertToRightHandedSystem: boolean;
  84917. /**
  84918. * Specifies if a Babylon node should be converted to right-handed on export
  84919. */
  84920. _convertToRightHandedSystemMap: {
  84921. [nodeId: number]: boolean;
  84922. };
  84923. _includeCoordinateSystemConversionNodes: boolean;
  84924. /**
  84925. * Baked animation sample rate
  84926. */
  84927. private _animationSampleRate;
  84928. private _options;
  84929. private _localEngine;
  84930. _glTFMaterialExporter: _GLTFMaterialExporter;
  84931. private _extensions;
  84932. private static _ExtensionNames;
  84933. private static _ExtensionFactories;
  84934. private _applyExtension;
  84935. private _applyExtensions;
  84936. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  84937. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  84938. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84939. [key: number]: number;
  84940. }): Promise<Nullable<INode>>;
  84941. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  84942. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  84943. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84944. private _forEachExtensions;
  84945. private _extensionsOnExporting;
  84946. /**
  84947. * Load glTF serializer extensions
  84948. */
  84949. private _loadExtensions;
  84950. /**
  84951. * Creates a glTF Exporter instance, which can accept optional exporter options
  84952. * @param babylonScene Babylon scene object
  84953. * @param options Options to modify the behavior of the exporter
  84954. */
  84955. constructor(babylonScene: Scene, options?: IExportOptions);
  84956. dispose(): void;
  84957. /**
  84958. * Registers a glTF exporter extension
  84959. * @param name Name of the extension to export
  84960. * @param factory The factory function that creates the exporter extension
  84961. */
  84962. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  84963. /**
  84964. * Un-registers an exporter extension
  84965. * @param name The name fo the exporter extension
  84966. * @returns A boolean indicating whether the extension has been un-registered
  84967. */
  84968. static UnregisterExtension(name: string): boolean;
  84969. /**
  84970. * Lazy load a local engine
  84971. */
  84972. _getLocalEngine(): Engine;
  84973. private reorderIndicesBasedOnPrimitiveMode;
  84974. /**
  84975. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  84976. * clock-wise during export to glTF
  84977. * @param submesh BabylonJS submesh
  84978. * @param primitiveMode Primitive mode of the mesh
  84979. * @param sideOrientation the winding order of the submesh
  84980. * @param vertexBufferKind The type of vertex attribute
  84981. * @param meshAttributeArray The vertex attribute data
  84982. * @param byteOffset The offset to the binary data
  84983. * @param binaryWriter The binary data for the glTF file
  84984. * @param convertToRightHandedSystem Converts the values to right-handed
  84985. */
  84986. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  84987. /**
  84988. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  84989. * clock-wise during export to glTF
  84990. * @param submesh BabylonJS submesh
  84991. * @param primitiveMode Primitive mode of the mesh
  84992. * @param sideOrientation the winding order of the submesh
  84993. * @param vertexBufferKind The type of vertex attribute
  84994. * @param meshAttributeArray The vertex attribute data
  84995. * @param byteOffset The offset to the binary data
  84996. * @param binaryWriter The binary data for the glTF file
  84997. * @param convertToRightHandedSystem Converts the values to right-handed
  84998. */
  84999. private reorderTriangleFillMode;
  85000. /**
  85001. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  85002. * clock-wise during export to glTF
  85003. * @param submesh BabylonJS submesh
  85004. * @param primitiveMode Primitive mode of the mesh
  85005. * @param sideOrientation the winding order of the submesh
  85006. * @param vertexBufferKind The type of vertex attribute
  85007. * @param meshAttributeArray The vertex attribute data
  85008. * @param byteOffset The offset to the binary data
  85009. * @param binaryWriter The binary data for the glTF file
  85010. * @param convertToRightHandedSystem Converts the values to right-handed
  85011. */
  85012. private reorderTriangleStripDrawMode;
  85013. /**
  85014. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  85015. * clock-wise during export to glTF
  85016. * @param submesh BabylonJS submesh
  85017. * @param primitiveMode Primitive mode of the mesh
  85018. * @param sideOrientation the winding order of the submesh
  85019. * @param vertexBufferKind The type of vertex attribute
  85020. * @param meshAttributeArray The vertex attribute data
  85021. * @param byteOffset The offset to the binary data
  85022. * @param binaryWriter The binary data for the glTF file
  85023. * @param convertToRightHandedSystem Converts the values to right-handed
  85024. */
  85025. private reorderTriangleFanMode;
  85026. /**
  85027. * Writes the vertex attribute data to binary
  85028. * @param vertices The vertices to write to the binary writer
  85029. * @param byteOffset The offset into the binary writer to overwrite binary data
  85030. * @param vertexAttributeKind The vertex attribute type
  85031. * @param meshAttributeArray The vertex attribute data
  85032. * @param binaryWriter The writer containing the binary data
  85033. * @param convertToRightHandedSystem Converts the values to right-handed
  85034. */
  85035. private writeVertexAttributeData;
  85036. /**
  85037. * Writes mesh attribute data to a data buffer
  85038. * Returns the bytelength of the data
  85039. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85040. * @param meshAttributeArray Array containing the attribute data
  85041. * @param byteStride Specifies the space between data
  85042. * @param binaryWriter The buffer to write the binary data to
  85043. * @param convertToRightHandedSystem Converts the values to right-handed
  85044. */
  85045. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  85046. /**
  85047. * Writes mesh attribute data to a data buffer
  85048. * Returns the bytelength of the data
  85049. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85050. * @param meshAttributeArray Array containing the attribute data
  85051. * @param byteStride Specifies the space between data
  85052. * @param binaryWriter The buffer to write the binary data to
  85053. * @param convertToRightHandedSystem Converts the values to right-handed
  85054. */
  85055. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  85056. /**
  85057. * Generates glTF json data
  85058. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  85059. * @param glTFPrefix Text to use when prefixing a glTF file
  85060. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  85061. * @returns json data as string
  85062. */
  85063. private generateJSON;
  85064. /**
  85065. * Generates data for .gltf and .bin files based on the glTF prefix string
  85066. * @param glTFPrefix Text to use when prefixing a glTF file
  85067. * @param dispose Dispose the exporter
  85068. * @returns GLTFData with glTF file data
  85069. */
  85070. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85071. /**
  85072. * Creates a binary buffer for glTF
  85073. * @returns array buffer for binary data
  85074. */
  85075. private _generateBinaryAsync;
  85076. /**
  85077. * Pads the number to a multiple of 4
  85078. * @param num number to pad
  85079. * @returns padded number
  85080. */
  85081. private _getPadding;
  85082. /**
  85083. * @hidden
  85084. */
  85085. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85086. /**
  85087. * Sets the TRS for each node
  85088. * @param node glTF Node for storing the transformation data
  85089. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  85090. * @param convertToRightHandedSystem Converts the values to right-handed
  85091. */
  85092. private setNodeTransformation;
  85093. private getVertexBufferFromMesh;
  85094. /**
  85095. * Creates a bufferview based on the vertices type for the Babylon mesh
  85096. * @param kind Indicates the type of vertices data
  85097. * @param componentType Indicates the numerical type used to store the data
  85098. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  85099. * @param binaryWriter The buffer to write the bufferview data to
  85100. * @param convertToRightHandedSystem Converts the values to right-handed
  85101. */
  85102. private createBufferViewKind;
  85103. /**
  85104. * Creates a bufferview based on the vertices type for the Babylon mesh
  85105. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  85106. * @param babylonMorphTarget the morph target to be exported
  85107. * @param binaryWriter The buffer to write the bufferview data to
  85108. * @param convertToRightHandedSystem Converts the values to right-handed
  85109. */
  85110. private setMorphTargetAttributes;
  85111. /**
  85112. * The primitive mode of the Babylon mesh
  85113. * @param babylonMesh The BabylonJS mesh
  85114. */
  85115. private getMeshPrimitiveMode;
  85116. /**
  85117. * Sets the primitive mode of the glTF mesh primitive
  85118. * @param meshPrimitive glTF mesh primitive
  85119. * @param primitiveMode The primitive mode
  85120. */
  85121. private setPrimitiveMode;
  85122. /**
  85123. * Sets the vertex attribute accessor based of the glTF mesh primitive
  85124. * @param meshPrimitive glTF mesh primitive
  85125. * @param attributeKind vertex attribute
  85126. * @returns boolean specifying if uv coordinates are present
  85127. */
  85128. private setAttributeKind;
  85129. /**
  85130. * Sets data for the primitive attributes of each submesh
  85131. * @param mesh glTF Mesh object to store the primitive attribute information
  85132. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  85133. * @param binaryWriter Buffer to write the attribute data to
  85134. * @param convertToRightHandedSystem Converts the values to right-handed
  85135. */
  85136. private setPrimitiveAttributesAsync;
  85137. /**
  85138. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  85139. * @param node The node to check
  85140. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  85141. */
  85142. private isBabylonCoordinateSystemConvertingNode;
  85143. /**
  85144. * Creates a glTF scene based on the array of meshes
  85145. * Returns the the total byte offset
  85146. * @param babylonScene Babylon scene to get the mesh data from
  85147. * @param binaryWriter Buffer to write binary data to
  85148. */
  85149. private createSceneAsync;
  85150. /**
  85151. * Creates a mapping of Node unique id to node index and handles animations
  85152. * @param babylonScene Babylon Scene
  85153. * @param nodes Babylon transform nodes
  85154. * @param binaryWriter Buffer to write binary data to
  85155. * @returns Node mapping of unique id to index
  85156. */
  85157. private createNodeMapAndAnimationsAsync;
  85158. /**
  85159. * Creates a glTF node from a Babylon mesh
  85160. * @param babylonMesh Source Babylon mesh
  85161. * @param binaryWriter Buffer for storing geometry data
  85162. * @param convertToRightHandedSystem Converts the values to right-handed
  85163. * @param nodeMap Node mapping of unique id to glTF node index
  85164. * @returns glTF node
  85165. */
  85166. private createNodeAsync;
  85167. /**
  85168. * Creates a glTF skin from a Babylon skeleton
  85169. * @param babylonScene Babylon Scene
  85170. * @param nodes Babylon transform nodes
  85171. * @param binaryWriter Buffer to write binary data to
  85172. * @returns Node mapping of unique id to index
  85173. */
  85174. private createSkinsAsync;
  85175. }
  85176. /**
  85177. * @hidden
  85178. *
  85179. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85180. */
  85181. export class _BinaryWriter {
  85182. /**
  85183. * Array buffer which stores all binary data
  85184. */
  85185. private _arrayBuffer;
  85186. /**
  85187. * View of the array buffer
  85188. */
  85189. private _dataView;
  85190. /**
  85191. * byte offset of data in array buffer
  85192. */
  85193. private _byteOffset;
  85194. /**
  85195. * Initialize binary writer with an initial byte length
  85196. * @param byteLength Initial byte length of the array buffer
  85197. */
  85198. constructor(byteLength: number);
  85199. /**
  85200. * Resize the array buffer to the specified byte length
  85201. * @param byteLength
  85202. */
  85203. private resizeBuffer;
  85204. /**
  85205. * Get an array buffer with the length of the byte offset
  85206. * @returns ArrayBuffer resized to the byte offset
  85207. */
  85208. getArrayBuffer(): ArrayBuffer;
  85209. /**
  85210. * Get the byte offset of the array buffer
  85211. * @returns byte offset
  85212. */
  85213. getByteOffset(): number;
  85214. /**
  85215. * Stores an UInt8 in the array buffer
  85216. * @param entry
  85217. * @param byteOffset If defined, specifies where to set the value as an offset.
  85218. */
  85219. setUInt8(entry: number, byteOffset?: number): void;
  85220. /**
  85221. * Stores an UInt16 in the array buffer
  85222. * @param entry
  85223. * @param byteOffset If defined, specifies where to set the value as an offset.
  85224. */
  85225. setUInt16(entry: number, byteOffset?: number): void;
  85226. /**
  85227. * Gets an UInt32 in the array buffer
  85228. * @param entry
  85229. * @param byteOffset If defined, specifies where to set the value as an offset.
  85230. */
  85231. getUInt32(byteOffset: number): number;
  85232. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85233. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85234. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85235. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85236. /**
  85237. * Stores a Float32 in the array buffer
  85238. * @param entry
  85239. */
  85240. setFloat32(entry: number, byteOffset?: number): void;
  85241. /**
  85242. * Stores an UInt32 in the array buffer
  85243. * @param entry
  85244. * @param byteOffset If defined, specifies where to set the value as an offset.
  85245. */
  85246. setUInt32(entry: number, byteOffset?: number): void;
  85247. }
  85248. }
  85249. declare module BABYLON.GLTF2.Exporter {
  85250. /**
  85251. * @hidden
  85252. * Interface to store animation data.
  85253. */
  85254. export interface _IAnimationData {
  85255. /**
  85256. * Keyframe data.
  85257. */
  85258. inputs: number[];
  85259. /**
  85260. * Value data.
  85261. */
  85262. outputs: number[][];
  85263. /**
  85264. * Animation interpolation data.
  85265. */
  85266. samplerInterpolation: AnimationSamplerInterpolation;
  85267. /**
  85268. * Minimum keyframe value.
  85269. */
  85270. inputsMin: number;
  85271. /**
  85272. * Maximum keyframe value.
  85273. */
  85274. inputsMax: number;
  85275. }
  85276. /**
  85277. * @hidden
  85278. */
  85279. export interface _IAnimationInfo {
  85280. /**
  85281. * The target channel for the animation
  85282. */
  85283. animationChannelTargetPath: AnimationChannelTargetPath;
  85284. /**
  85285. * The glTF accessor type for the data.
  85286. */
  85287. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85288. /**
  85289. * Specifies if quaternions should be used.
  85290. */
  85291. useQuaternion: boolean;
  85292. }
  85293. /**
  85294. * @hidden
  85295. * Utility class for generating glTF animation data from BabylonJS.
  85296. */
  85297. export class _GLTFAnimation {
  85298. /**
  85299. * @ignore
  85300. *
  85301. * Creates glTF channel animation from BabylonJS animation.
  85302. * @param babylonTransformNode - BabylonJS mesh.
  85303. * @param animation - animation.
  85304. * @param animationChannelTargetPath - The target animation channel.
  85305. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85306. * @param useQuaternion - Specifies if quaternions are used.
  85307. * @returns nullable IAnimationData
  85308. */
  85309. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85310. private static _DeduceAnimationInfo;
  85311. /**
  85312. * @ignore
  85313. * Create node animations from the transform node animations
  85314. * @param babylonNode
  85315. * @param runtimeGLTFAnimation
  85316. * @param idleGLTFAnimations
  85317. * @param nodeMap
  85318. * @param nodes
  85319. * @param binaryWriter
  85320. * @param bufferViews
  85321. * @param accessors
  85322. * @param convertToRightHandedSystem
  85323. * @param animationSampleRate
  85324. */
  85325. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85326. [key: number]: number;
  85327. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85328. /**
  85329. * @ignore
  85330. * Create individual morph animations from the mesh's morph target animation tracks
  85331. * @param babylonNode
  85332. * @param runtimeGLTFAnimation
  85333. * @param idleGLTFAnimations
  85334. * @param nodeMap
  85335. * @param nodes
  85336. * @param binaryWriter
  85337. * @param bufferViews
  85338. * @param accessors
  85339. * @param convertToRightHandedSystem
  85340. * @param animationSampleRate
  85341. */
  85342. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85343. [key: number]: number;
  85344. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85345. /**
  85346. * @ignore
  85347. * Create node and morph animations from the animation groups
  85348. * @param babylonScene
  85349. * @param glTFAnimations
  85350. * @param nodeMap
  85351. * @param nodes
  85352. * @param binaryWriter
  85353. * @param bufferViews
  85354. * @param accessors
  85355. * @param convertToRightHandedSystemMap
  85356. * @param animationSampleRate
  85357. */
  85358. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85359. [key: number]: number;
  85360. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85361. [nodeId: number]: boolean;
  85362. }, animationSampleRate: number): void;
  85363. private static AddAnimation;
  85364. /**
  85365. * Create a baked animation
  85366. * @param babylonTransformNode BabylonJS mesh
  85367. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85368. * @param animationChannelTargetPath animation target channel
  85369. * @param minFrame minimum animation frame
  85370. * @param maxFrame maximum animation frame
  85371. * @param fps frames per second of the animation
  85372. * @param inputs input key frames of the animation
  85373. * @param outputs output key frame data of the animation
  85374. * @param convertToRightHandedSystem converts the values to right-handed
  85375. * @param useQuaternion specifies if quaternions should be used
  85376. */
  85377. private static _CreateBakedAnimation;
  85378. private static _ConvertFactorToVector3OrQuaternion;
  85379. private static _SetInterpolatedValue;
  85380. /**
  85381. * Creates linear animation from the animation key frames
  85382. * @param babylonTransformNode BabylonJS mesh
  85383. * @param animation BabylonJS animation
  85384. * @param animationChannelTargetPath The target animation channel
  85385. * @param frameDelta The difference between the last and first frame of the animation
  85386. * @param inputs Array to store the key frame times
  85387. * @param outputs Array to store the key frame data
  85388. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85389. * @param useQuaternion Specifies if quaternions are used in the animation
  85390. */
  85391. private static _CreateLinearOrStepAnimation;
  85392. /**
  85393. * Creates cubic spline animation from the animation key frames
  85394. * @param babylonTransformNode BabylonJS mesh
  85395. * @param animation BabylonJS animation
  85396. * @param animationChannelTargetPath The target animation channel
  85397. * @param frameDelta The difference between the last and first frame of the animation
  85398. * @param inputs Array to store the key frame times
  85399. * @param outputs Array to store the key frame data
  85400. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85401. * @param useQuaternion Specifies if quaternions are used in the animation
  85402. */
  85403. private static _CreateCubicSplineAnimation;
  85404. private static _GetBasePositionRotationOrScale;
  85405. /**
  85406. * Adds a key frame value
  85407. * @param keyFrame
  85408. * @param animation
  85409. * @param outputs
  85410. * @param animationChannelTargetPath
  85411. * @param basePositionRotationOrScale
  85412. * @param convertToRightHandedSystem
  85413. * @param useQuaternion
  85414. */
  85415. private static _AddKeyframeValue;
  85416. /**
  85417. * Determine the interpolation based on the key frames
  85418. * @param keyFrames
  85419. * @param animationChannelTargetPath
  85420. * @param useQuaternion
  85421. */
  85422. private static _DeduceInterpolation;
  85423. /**
  85424. * Adds an input tangent or output tangent to the output data
  85425. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85426. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85427. * @param outputs The animation data by keyframe
  85428. * @param animationChannelTargetPath The target animation channel
  85429. * @param interpolation The interpolation type
  85430. * @param keyFrame The key frame with the animation data
  85431. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85432. * @param useQuaternion Specifies if quaternions are used
  85433. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  85434. */
  85435. private static AddSplineTangent;
  85436. /**
  85437. * Get the minimum and maximum key frames' frame values
  85438. * @param keyFrames animation key frames
  85439. * @returns the minimum and maximum key frame value
  85440. */
  85441. private static calculateMinMaxKeyFrames;
  85442. }
  85443. }
  85444. declare module BABYLON.GLTF2.Exporter {
  85445. /** @hidden */
  85446. export var textureTransformPixelShader: {
  85447. name: string;
  85448. shader: string;
  85449. };
  85450. }
  85451. declare module BABYLON.GLTF2.Exporter.Extensions {
  85452. /**
  85453. * @hidden
  85454. */
  85455. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  85456. private _recordedTextures;
  85457. /** Name of this extension */
  85458. readonly name: string;
  85459. /** Defines whether this extension is enabled */
  85460. enabled: boolean;
  85461. /** Defines whether this extension is required */
  85462. required: boolean;
  85463. /** Reference to the glTF exporter */
  85464. private _wasUsed;
  85465. constructor(exporter: _Exporter);
  85466. dispose(): void;
  85467. /** @hidden */
  85468. get wasUsed(): boolean;
  85469. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85470. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85471. /**
  85472. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85473. * @param babylonTexture
  85474. * @param offset
  85475. * @param rotation
  85476. * @param scale
  85477. * @param scene
  85478. */
  85479. private _textureTransformTextureAsync;
  85480. }
  85481. }
  85482. declare module BABYLON.GLTF2.Exporter.Extensions {
  85483. /**
  85484. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85485. */
  85486. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85487. /** The name of this extension. */
  85488. readonly name: string;
  85489. /** Defines whether this extension is enabled. */
  85490. enabled: boolean;
  85491. /** Defines whether this extension is required */
  85492. required: boolean;
  85493. /** Reference to the glTF exporter */
  85494. private _exporter;
  85495. private _lights;
  85496. /** @hidden */
  85497. constructor(exporter: _Exporter);
  85498. /** @hidden */
  85499. dispose(): void;
  85500. /** @hidden */
  85501. get wasUsed(): boolean;
  85502. /** @hidden */
  85503. onExporting(): void;
  85504. /**
  85505. * Define this method to modify the default behavior when exporting a node
  85506. * @param context The context when exporting the node
  85507. * @param node glTF node
  85508. * @param babylonNode BabylonJS node
  85509. * @param nodeMap Node mapping of unique id to glTF node index
  85510. * @returns nullable INode promise
  85511. */
  85512. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85513. [key: number]: number;
  85514. }): Promise<Nullable<INode>>;
  85515. }
  85516. }
  85517. declare module BABYLON.GLTF2.Exporter.Extensions {
  85518. /**
  85519. * @hidden
  85520. */
  85521. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85522. /** Name of this extension */
  85523. readonly name: string;
  85524. /** Defines whether this extension is enabled */
  85525. enabled: boolean;
  85526. /** Defines whether this extension is required */
  85527. required: boolean;
  85528. /** Reference to the glTF exporter */
  85529. private _textureInfos;
  85530. private _exportedTextures;
  85531. private _wasUsed;
  85532. constructor(exporter: _Exporter);
  85533. dispose(): void;
  85534. /** @hidden */
  85535. get wasUsed(): boolean;
  85536. private _getTextureIndex;
  85537. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85538. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85539. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85540. }
  85541. }
  85542. declare module BABYLON.GLTF2.Exporter.Extensions {
  85543. /**
  85544. * @hidden
  85545. */
  85546. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85547. /** Name of this extension */
  85548. readonly name: string;
  85549. /** Defines whether this extension is enabled */
  85550. enabled: boolean;
  85551. /** Defines whether this extension is required */
  85552. required: boolean;
  85553. private _wasUsed;
  85554. constructor(exporter: _Exporter);
  85555. /** @hidden */
  85556. get wasUsed(): boolean;
  85557. dispose(): void;
  85558. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85559. }
  85560. }
  85561. declare module BABYLON {
  85562. /**
  85563. * Class for generating STL data from a Babylon scene.
  85564. */
  85565. export class STLExport {
  85566. /**
  85567. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85568. * @param meshes list defines the mesh to serialize
  85569. * @param download triggers the automatic download of the file.
  85570. * @param fileName changes the downloads fileName.
  85571. * @param binary changes the STL to a binary type.
  85572. * @param isLittleEndian toggle for binary type exporter.
  85573. * @returns the STL as UTF8 string
  85574. */
  85575. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  85576. }
  85577. }
  85578. declare module "babylonjs-gltf2interface" {
  85579. export = BABYLON.GLTF2;
  85580. }
  85581. /**
  85582. * Module for glTF 2.0 Interface
  85583. */
  85584. declare module BABYLON.GLTF2 {
  85585. /**
  85586. * The datatype of the components in the attribute
  85587. */
  85588. const enum AccessorComponentType {
  85589. /**
  85590. * Byte
  85591. */
  85592. BYTE = 5120,
  85593. /**
  85594. * Unsigned Byte
  85595. */
  85596. UNSIGNED_BYTE = 5121,
  85597. /**
  85598. * Short
  85599. */
  85600. SHORT = 5122,
  85601. /**
  85602. * Unsigned Short
  85603. */
  85604. UNSIGNED_SHORT = 5123,
  85605. /**
  85606. * Unsigned Int
  85607. */
  85608. UNSIGNED_INT = 5125,
  85609. /**
  85610. * Float
  85611. */
  85612. FLOAT = 5126,
  85613. }
  85614. /**
  85615. * Specifies if the attirbute is a scalar, vector, or matrix
  85616. */
  85617. const enum AccessorType {
  85618. /**
  85619. * Scalar
  85620. */
  85621. SCALAR = "SCALAR",
  85622. /**
  85623. * Vector2
  85624. */
  85625. VEC2 = "VEC2",
  85626. /**
  85627. * Vector3
  85628. */
  85629. VEC3 = "VEC3",
  85630. /**
  85631. * Vector4
  85632. */
  85633. VEC4 = "VEC4",
  85634. /**
  85635. * Matrix2x2
  85636. */
  85637. MAT2 = "MAT2",
  85638. /**
  85639. * Matrix3x3
  85640. */
  85641. MAT3 = "MAT3",
  85642. /**
  85643. * Matrix4x4
  85644. */
  85645. MAT4 = "MAT4",
  85646. }
  85647. /**
  85648. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85649. */
  85650. const enum AnimationChannelTargetPath {
  85651. /**
  85652. * Translation
  85653. */
  85654. TRANSLATION = "translation",
  85655. /**
  85656. * Rotation
  85657. */
  85658. ROTATION = "rotation",
  85659. /**
  85660. * Scale
  85661. */
  85662. SCALE = "scale",
  85663. /**
  85664. * Weights
  85665. */
  85666. WEIGHTS = "weights",
  85667. }
  85668. /**
  85669. * Interpolation algorithm
  85670. */
  85671. const enum AnimationSamplerInterpolation {
  85672. /**
  85673. * The animated values are linearly interpolated between keyframes
  85674. */
  85675. LINEAR = "LINEAR",
  85676. /**
  85677. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85678. */
  85679. STEP = "STEP",
  85680. /**
  85681. * The animation's interpolation is computed using a cubic spline with specified tangents
  85682. */
  85683. CUBICSPLINE = "CUBICSPLINE",
  85684. }
  85685. /**
  85686. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85687. */
  85688. const enum CameraType {
  85689. /**
  85690. * A perspective camera containing properties to create a perspective projection matrix
  85691. */
  85692. PERSPECTIVE = "perspective",
  85693. /**
  85694. * An orthographic camera containing properties to create an orthographic projection matrix
  85695. */
  85696. ORTHOGRAPHIC = "orthographic",
  85697. }
  85698. /**
  85699. * The mime-type of the image
  85700. */
  85701. const enum ImageMimeType {
  85702. /**
  85703. * JPEG Mime-type
  85704. */
  85705. JPEG = "image/jpeg",
  85706. /**
  85707. * PNG Mime-type
  85708. */
  85709. PNG = "image/png",
  85710. }
  85711. /**
  85712. * The alpha rendering mode of the material
  85713. */
  85714. const enum MaterialAlphaMode {
  85715. /**
  85716. * The alpha value is ignored and the rendered output is fully opaque
  85717. */
  85718. OPAQUE = "OPAQUE",
  85719. /**
  85720. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  85721. */
  85722. MASK = "MASK",
  85723. /**
  85724. * 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)
  85725. */
  85726. BLEND = "BLEND",
  85727. }
  85728. /**
  85729. * The type of the primitives to render
  85730. */
  85731. const enum MeshPrimitiveMode {
  85732. /**
  85733. * Points
  85734. */
  85735. POINTS = 0,
  85736. /**
  85737. * Lines
  85738. */
  85739. LINES = 1,
  85740. /**
  85741. * Line Loop
  85742. */
  85743. LINE_LOOP = 2,
  85744. /**
  85745. * Line Strip
  85746. */
  85747. LINE_STRIP = 3,
  85748. /**
  85749. * Triangles
  85750. */
  85751. TRIANGLES = 4,
  85752. /**
  85753. * Triangle Strip
  85754. */
  85755. TRIANGLE_STRIP = 5,
  85756. /**
  85757. * Triangle Fan
  85758. */
  85759. TRIANGLE_FAN = 6,
  85760. }
  85761. /**
  85762. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85763. */
  85764. const enum TextureMagFilter {
  85765. /**
  85766. * Nearest
  85767. */
  85768. NEAREST = 9728,
  85769. /**
  85770. * Linear
  85771. */
  85772. LINEAR = 9729,
  85773. }
  85774. /**
  85775. * Minification filter. All valid values correspond to WebGL enums
  85776. */
  85777. const enum TextureMinFilter {
  85778. /**
  85779. * Nearest
  85780. */
  85781. NEAREST = 9728,
  85782. /**
  85783. * Linear
  85784. */
  85785. LINEAR = 9729,
  85786. /**
  85787. * Nearest Mip-Map Nearest
  85788. */
  85789. NEAREST_MIPMAP_NEAREST = 9984,
  85790. /**
  85791. * Linear Mipmap Nearest
  85792. */
  85793. LINEAR_MIPMAP_NEAREST = 9985,
  85794. /**
  85795. * Nearest Mipmap Linear
  85796. */
  85797. NEAREST_MIPMAP_LINEAR = 9986,
  85798. /**
  85799. * Linear Mipmap Linear
  85800. */
  85801. LINEAR_MIPMAP_LINEAR = 9987,
  85802. }
  85803. /**
  85804. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85805. */
  85806. const enum TextureWrapMode {
  85807. /**
  85808. * Clamp to Edge
  85809. */
  85810. CLAMP_TO_EDGE = 33071,
  85811. /**
  85812. * Mirrored Repeat
  85813. */
  85814. MIRRORED_REPEAT = 33648,
  85815. /**
  85816. * Repeat
  85817. */
  85818. REPEAT = 10497,
  85819. }
  85820. /**
  85821. * glTF Property
  85822. */
  85823. interface IProperty {
  85824. /**
  85825. * Dictionary object with extension-specific objects
  85826. */
  85827. extensions?: {
  85828. [key: string]: any;
  85829. };
  85830. /**
  85831. * Application-Specific data
  85832. */
  85833. extras?: any;
  85834. }
  85835. /**
  85836. * glTF Child of Root Property
  85837. */
  85838. interface IChildRootProperty extends IProperty {
  85839. /**
  85840. * The user-defined name of this object
  85841. */
  85842. name?: string;
  85843. }
  85844. /**
  85845. * Indices of those attributes that deviate from their initialization value
  85846. */
  85847. interface IAccessorSparseIndices extends IProperty {
  85848. /**
  85849. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85850. */
  85851. bufferView: number;
  85852. /**
  85853. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85854. */
  85855. byteOffset?: number;
  85856. /**
  85857. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  85858. */
  85859. componentType: AccessorComponentType;
  85860. }
  85861. /**
  85862. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  85863. */
  85864. interface IAccessorSparseValues extends IProperty {
  85865. /**
  85866. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85867. */
  85868. bufferView: number;
  85869. /**
  85870. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85871. */
  85872. byteOffset?: number;
  85873. }
  85874. /**
  85875. * Sparse storage of attributes that deviate from their initialization value
  85876. */
  85877. interface IAccessorSparse extends IProperty {
  85878. /**
  85879. * The number of attributes encoded in this sparse accessor
  85880. */
  85881. count: number;
  85882. /**
  85883. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  85884. */
  85885. indices: IAccessorSparseIndices;
  85886. /**
  85887. * 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
  85888. */
  85889. values: IAccessorSparseValues;
  85890. }
  85891. /**
  85892. * 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
  85893. */
  85894. interface IAccessor extends IChildRootProperty {
  85895. /**
  85896. * The index of the bufferview
  85897. */
  85898. bufferView?: number;
  85899. /**
  85900. * The offset relative to the start of the bufferView in bytes
  85901. */
  85902. byteOffset?: number;
  85903. /**
  85904. * The datatype of components in the attribute
  85905. */
  85906. componentType: AccessorComponentType;
  85907. /**
  85908. * Specifies whether integer data values should be normalized
  85909. */
  85910. normalized?: boolean;
  85911. /**
  85912. * The number of attributes referenced by this accessor
  85913. */
  85914. count: number;
  85915. /**
  85916. * Specifies if the attribute is a scalar, vector, or matrix
  85917. */
  85918. type: AccessorType;
  85919. /**
  85920. * Maximum value of each component in this attribute
  85921. */
  85922. max?: number[];
  85923. /**
  85924. * Minimum value of each component in this attribute
  85925. */
  85926. min?: number[];
  85927. /**
  85928. * Sparse storage of attributes that deviate from their initialization value
  85929. */
  85930. sparse?: IAccessorSparse;
  85931. }
  85932. /**
  85933. * Targets an animation's sampler at a node's property
  85934. */
  85935. interface IAnimationChannel extends IProperty {
  85936. /**
  85937. * The index of a sampler in this animation used to compute the value for the target
  85938. */
  85939. sampler: number;
  85940. /**
  85941. * The index of the node and TRS property to target
  85942. */
  85943. target: IAnimationChannelTarget;
  85944. }
  85945. /**
  85946. * The index of the node and TRS property that an animation channel targets
  85947. */
  85948. interface IAnimationChannelTarget extends IProperty {
  85949. /**
  85950. * The index of the node to target
  85951. */
  85952. node: number;
  85953. /**
  85954. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85955. */
  85956. path: AnimationChannelTargetPath;
  85957. }
  85958. /**
  85959. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85960. */
  85961. interface IAnimationSampler extends IProperty {
  85962. /**
  85963. * The index of an accessor containing keyframe input values, e.g., time
  85964. */
  85965. input: number;
  85966. /**
  85967. * Interpolation algorithm
  85968. */
  85969. interpolation?: AnimationSamplerInterpolation;
  85970. /**
  85971. * The index of an accessor, containing keyframe output values
  85972. */
  85973. output: number;
  85974. }
  85975. /**
  85976. * A keyframe animation
  85977. */
  85978. interface IAnimation extends IChildRootProperty {
  85979. /**
  85980. * An array of channels, each of which targets an animation's sampler at a node's property
  85981. */
  85982. channels: IAnimationChannel[];
  85983. /**
  85984. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85985. */
  85986. samplers: IAnimationSampler[];
  85987. }
  85988. /**
  85989. * Metadata about the glTF asset
  85990. */
  85991. interface IAsset extends IChildRootProperty {
  85992. /**
  85993. * A copyright message suitable for display to credit the content creator
  85994. */
  85995. copyright?: string;
  85996. /**
  85997. * Tool that generated this glTF model. Useful for debugging
  85998. */
  85999. generator?: string;
  86000. /**
  86001. * The glTF version that this asset targets
  86002. */
  86003. version: string;
  86004. /**
  86005. * The minimum glTF version that this asset targets
  86006. */
  86007. minVersion?: string;
  86008. }
  86009. /**
  86010. * A buffer points to binary geometry, animation, or skins
  86011. */
  86012. interface IBuffer extends IChildRootProperty {
  86013. /**
  86014. * 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
  86015. */
  86016. uri?: string;
  86017. /**
  86018. * The length of the buffer in bytes
  86019. */
  86020. byteLength: number;
  86021. }
  86022. /**
  86023. * A view into a buffer generally representing a subset of the buffer
  86024. */
  86025. interface IBufferView extends IChildRootProperty {
  86026. /**
  86027. * The index of the buffer
  86028. */
  86029. buffer: number;
  86030. /**
  86031. * The offset into the buffer in bytes
  86032. */
  86033. byteOffset?: number;
  86034. /**
  86035. * The lenth of the bufferView in bytes
  86036. */
  86037. byteLength: number;
  86038. /**
  86039. * The stride, in bytes
  86040. */
  86041. byteStride?: number;
  86042. }
  86043. /**
  86044. * An orthographic camera containing properties to create an orthographic projection matrix
  86045. */
  86046. interface ICameraOrthographic extends IProperty {
  86047. /**
  86048. * The floating-point horizontal magnification of the view. Must not be zero
  86049. */
  86050. xmag: number;
  86051. /**
  86052. * The floating-point vertical magnification of the view. Must not be zero
  86053. */
  86054. ymag: number;
  86055. /**
  86056. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  86057. */
  86058. zfar: number;
  86059. /**
  86060. * The floating-point distance to the near clipping plane
  86061. */
  86062. znear: number;
  86063. }
  86064. /**
  86065. * A perspective camera containing properties to create a perspective projection matrix
  86066. */
  86067. interface ICameraPerspective extends IProperty {
  86068. /**
  86069. * The floating-point aspect ratio of the field of view
  86070. */
  86071. aspectRatio?: number;
  86072. /**
  86073. * The floating-point vertical field of view in radians
  86074. */
  86075. yfov: number;
  86076. /**
  86077. * The floating-point distance to the far clipping plane
  86078. */
  86079. zfar?: number;
  86080. /**
  86081. * The floating-point distance to the near clipping plane
  86082. */
  86083. znear: number;
  86084. }
  86085. /**
  86086. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86087. */
  86088. interface ICamera extends IChildRootProperty {
  86089. /**
  86090. * An orthographic camera containing properties to create an orthographic projection matrix
  86091. */
  86092. orthographic?: ICameraOrthographic;
  86093. /**
  86094. * A perspective camera containing properties to create a perspective projection matrix
  86095. */
  86096. perspective?: ICameraPerspective;
  86097. /**
  86098. * Specifies if the camera uses a perspective or orthographic projection
  86099. */
  86100. type: CameraType;
  86101. }
  86102. /**
  86103. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  86104. */
  86105. interface IImage extends IChildRootProperty {
  86106. /**
  86107. * 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
  86108. */
  86109. uri?: string;
  86110. /**
  86111. * The image's MIME type
  86112. */
  86113. mimeType?: ImageMimeType;
  86114. /**
  86115. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  86116. */
  86117. bufferView?: number;
  86118. }
  86119. /**
  86120. * Material Normal Texture Info
  86121. */
  86122. interface IMaterialNormalTextureInfo extends ITextureInfo {
  86123. /**
  86124. * The scalar multiplier applied to each normal vector of the normal texture
  86125. */
  86126. scale?: number;
  86127. }
  86128. /**
  86129. * Material Occlusion Texture Info
  86130. */
  86131. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  86132. /**
  86133. * A scalar multiplier controlling the amount of occlusion applied
  86134. */
  86135. strength?: number;
  86136. }
  86137. /**
  86138. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  86139. */
  86140. interface IMaterialPbrMetallicRoughness {
  86141. /**
  86142. * The material's base color factor
  86143. */
  86144. baseColorFactor?: number[];
  86145. /**
  86146. * The base color texture
  86147. */
  86148. baseColorTexture?: ITextureInfo;
  86149. /**
  86150. * The metalness of the material
  86151. */
  86152. metallicFactor?: number;
  86153. /**
  86154. * The roughness of the material
  86155. */
  86156. roughnessFactor?: number;
  86157. /**
  86158. * The metallic-roughness texture
  86159. */
  86160. metallicRoughnessTexture?: ITextureInfo;
  86161. }
  86162. /**
  86163. * The material appearance of a primitive
  86164. */
  86165. interface IMaterial extends IChildRootProperty {
  86166. /**
  86167. * 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
  86168. */
  86169. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86170. /**
  86171. * The normal map texture
  86172. */
  86173. normalTexture?: IMaterialNormalTextureInfo;
  86174. /**
  86175. * The occlusion map texture
  86176. */
  86177. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86178. /**
  86179. * The emissive map texture
  86180. */
  86181. emissiveTexture?: ITextureInfo;
  86182. /**
  86183. * 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
  86184. */
  86185. emissiveFactor?: number[];
  86186. /**
  86187. * The alpha rendering mode of the material
  86188. */
  86189. alphaMode?: MaterialAlphaMode;
  86190. /**
  86191. * The alpha cutoff value of the material
  86192. */
  86193. alphaCutoff?: number;
  86194. /**
  86195. * Specifies whether the material is double sided
  86196. */
  86197. doubleSided?: boolean;
  86198. }
  86199. /**
  86200. * Geometry to be rendered with the given material
  86201. */
  86202. interface IMeshPrimitive extends IProperty {
  86203. /**
  86204. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86205. */
  86206. attributes: {
  86207. [name: string]: number;
  86208. };
  86209. /**
  86210. * The index of the accessor that contains the indices
  86211. */
  86212. indices?: number;
  86213. /**
  86214. * The index of the material to apply to this primitive when rendering
  86215. */
  86216. material?: number;
  86217. /**
  86218. * The type of primitives to render. All valid values correspond to WebGL enums
  86219. */
  86220. mode?: MeshPrimitiveMode;
  86221. /**
  86222. * 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
  86223. */
  86224. targets?: {
  86225. [name: string]: number;
  86226. }[];
  86227. }
  86228. /**
  86229. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86230. */
  86231. interface IMesh extends IChildRootProperty {
  86232. /**
  86233. * An array of primitives, each defining geometry to be rendered with a material
  86234. */
  86235. primitives: IMeshPrimitive[];
  86236. /**
  86237. * Array of weights to be applied to the Morph Targets
  86238. */
  86239. weights?: number[];
  86240. }
  86241. /**
  86242. * A node in the node hierarchy
  86243. */
  86244. interface INode extends IChildRootProperty {
  86245. /**
  86246. * The index of the camera referenced by this node
  86247. */
  86248. camera?: number;
  86249. /**
  86250. * The indices of this node's children
  86251. */
  86252. children?: number[];
  86253. /**
  86254. * The index of the skin referenced by this node
  86255. */
  86256. skin?: number;
  86257. /**
  86258. * A floating-point 4x4 transformation matrix stored in column-major order
  86259. */
  86260. matrix?: number[];
  86261. /**
  86262. * The index of the mesh in this node
  86263. */
  86264. mesh?: number;
  86265. /**
  86266. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86267. */
  86268. rotation?: number[];
  86269. /**
  86270. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86271. */
  86272. scale?: number[];
  86273. /**
  86274. * The node's translation along the x, y, and z axes
  86275. */
  86276. translation?: number[];
  86277. /**
  86278. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86279. */
  86280. weights?: number[];
  86281. }
  86282. /**
  86283. * Texture sampler properties for filtering and wrapping modes
  86284. */
  86285. interface ISampler extends IChildRootProperty {
  86286. /**
  86287. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86288. */
  86289. magFilter?: TextureMagFilter;
  86290. /**
  86291. * Minification filter. All valid values correspond to WebGL enums
  86292. */
  86293. minFilter?: TextureMinFilter;
  86294. /**
  86295. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86296. */
  86297. wrapS?: TextureWrapMode;
  86298. /**
  86299. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86300. */
  86301. wrapT?: TextureWrapMode;
  86302. }
  86303. /**
  86304. * The root nodes of a scene
  86305. */
  86306. interface IScene extends IChildRootProperty {
  86307. /**
  86308. * The indices of each root node
  86309. */
  86310. nodes: number[];
  86311. }
  86312. /**
  86313. * Joints and matrices defining a skin
  86314. */
  86315. interface ISkin extends IChildRootProperty {
  86316. /**
  86317. * 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
  86318. */
  86319. inverseBindMatrices?: number;
  86320. /**
  86321. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86322. */
  86323. skeleton?: number;
  86324. /**
  86325. * 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)
  86326. */
  86327. joints: number[];
  86328. }
  86329. /**
  86330. * A texture and its sampler
  86331. */
  86332. interface ITexture extends IChildRootProperty {
  86333. /**
  86334. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86335. */
  86336. sampler?: number;
  86337. /**
  86338. * The index of the image used by this texture
  86339. */
  86340. source: number;
  86341. }
  86342. /**
  86343. * Reference to a texture
  86344. */
  86345. interface ITextureInfo extends IProperty {
  86346. /**
  86347. * The index of the texture
  86348. */
  86349. index: number;
  86350. /**
  86351. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86352. */
  86353. texCoord?: number;
  86354. }
  86355. /**
  86356. * The root object for a glTF asset
  86357. */
  86358. interface IGLTF extends IProperty {
  86359. /**
  86360. * An array of accessors. An accessor is a typed view into a bufferView
  86361. */
  86362. accessors?: IAccessor[];
  86363. /**
  86364. * An array of keyframe animations
  86365. */
  86366. animations?: IAnimation[];
  86367. /**
  86368. * Metadata about the glTF asset
  86369. */
  86370. asset: IAsset;
  86371. /**
  86372. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86373. */
  86374. buffers?: IBuffer[];
  86375. /**
  86376. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86377. */
  86378. bufferViews?: IBufferView[];
  86379. /**
  86380. * An array of cameras
  86381. */
  86382. cameras?: ICamera[];
  86383. /**
  86384. * Names of glTF extensions used somewhere in this asset
  86385. */
  86386. extensionsUsed?: string[];
  86387. /**
  86388. * Names of glTF extensions required to properly load this asset
  86389. */
  86390. extensionsRequired?: string[];
  86391. /**
  86392. * An array of images. An image defines data used to create a texture
  86393. */
  86394. images?: IImage[];
  86395. /**
  86396. * An array of materials. A material defines the appearance of a primitive
  86397. */
  86398. materials?: IMaterial[];
  86399. /**
  86400. * An array of meshes. A mesh is a set of primitives to be rendered
  86401. */
  86402. meshes?: IMesh[];
  86403. /**
  86404. * An array of nodes
  86405. */
  86406. nodes?: INode[];
  86407. /**
  86408. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86409. */
  86410. samplers?: ISampler[];
  86411. /**
  86412. * The index of the default scene
  86413. */
  86414. scene?: number;
  86415. /**
  86416. * An array of scenes
  86417. */
  86418. scenes?: IScene[];
  86419. /**
  86420. * An array of skins. A skin is defined by joints and matrices
  86421. */
  86422. skins?: ISkin[];
  86423. /**
  86424. * An array of textures
  86425. */
  86426. textures?: ITexture[];
  86427. }
  86428. /**
  86429. * The glTF validation results
  86430. * @ignore
  86431. */
  86432. interface IGLTFValidationResults {
  86433. info: {
  86434. generator: string;
  86435. hasAnimations: boolean;
  86436. hasDefaultScene: boolean;
  86437. hasMaterials: boolean;
  86438. hasMorphTargets: boolean;
  86439. hasSkins: boolean;
  86440. hasTextures: boolean;
  86441. maxAttributesUsed: number;
  86442. primitivesCount: number
  86443. };
  86444. issues: {
  86445. messages: Array<string>;
  86446. numErrors: number;
  86447. numHints: number;
  86448. numInfos: number;
  86449. numWarnings: number;
  86450. truncated: boolean
  86451. };
  86452. mimeType: string;
  86453. uri: string;
  86454. validatedAt: string;
  86455. validatorVersion: string;
  86456. }
  86457. /**
  86458. * The glTF validation options
  86459. */
  86460. interface IGLTFValidationOptions {
  86461. /** Uri to use */
  86462. uri?: string;
  86463. /** Function used to load external resources */
  86464. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  86465. /** Boolean indicating that we need to validate accessor data */
  86466. validateAccessorData?: boolean;
  86467. /** max number of issues allowed */
  86468. maxIssues?: number;
  86469. /** Ignored issues */
  86470. ignoredIssues?: Array<string>;
  86471. /** Value to override severy settings */
  86472. severityOverrides?: Object;
  86473. }
  86474. /**
  86475. * The glTF validator object
  86476. * @ignore
  86477. */
  86478. interface IGLTFValidator {
  86479. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86480. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86481. }
  86482. /**
  86483. * Interfaces from the EXT_lights_image_based extension
  86484. */
  86485. /** @hidden */
  86486. interface IEXTLightsImageBased_LightReferenceImageBased {
  86487. light: number;
  86488. }
  86489. /** @hidden */
  86490. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86491. intensity: number;
  86492. rotation: number[];
  86493. specularImageSize: number;
  86494. specularImages: number[][];
  86495. irradianceCoefficients: number[][];
  86496. }
  86497. /** @hidden */
  86498. interface IEXTLightsImageBased {
  86499. lights: IEXTLightsImageBased_LightImageBased[];
  86500. }
  86501. /**
  86502. * Interfaces from the EXT_mesh_gpu_instancing extension
  86503. * !!! Experimental Extension Subject to Changes !!!
  86504. */
  86505. /** @hidden */
  86506. interface IEXTMeshGpuInstancing {
  86507. mesh?: number;
  86508. attributes: { [name: string]: number };
  86509. }
  86510. /**
  86511. * Interfaces from the KHR_draco_mesh_compression extension
  86512. */
  86513. /** @hidden */
  86514. interface IKHRDracoMeshCompression {
  86515. bufferView: number;
  86516. attributes: { [name: string]: number };
  86517. }
  86518. /**
  86519. * Interfaces from the KHR_lights_punctual extension
  86520. */
  86521. /** @hidden */
  86522. const enum IKHRLightsPunctual_LightType {
  86523. DIRECTIONAL = "directional",
  86524. POINT = "point",
  86525. SPOT = "spot"
  86526. }
  86527. /** @hidden */
  86528. interface IKHRLightsPunctual_LightReference {
  86529. light: number;
  86530. }
  86531. /** @hidden */
  86532. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86533. type: IKHRLightsPunctual_LightType;
  86534. color?: number[];
  86535. intensity?: number;
  86536. range?: number;
  86537. spot?: {
  86538. innerConeAngle?: number;
  86539. outerConeAngle?: number;
  86540. };
  86541. }
  86542. /** @hidden */
  86543. interface IKHRLightsPunctual {
  86544. lights: IKHRLightsPunctual_Light[];
  86545. }
  86546. /**
  86547. * Interfaces from the KHR_materials_clearcoat extension
  86548. * !!! Experimental Extension Subject to Changes !!!
  86549. */
  86550. /** @hidden */
  86551. interface IKHRMaterialsClearcoat {
  86552. clearcoatFactor: number;
  86553. clearcoatTexture: ITextureInfo;
  86554. clearcoatRoughnessFactor: number;
  86555. clearcoatRoughnessTexture: ITextureInfo;
  86556. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86557. }
  86558. /**
  86559. * Interfaces from the KHR_materials_ior extension
  86560. * !!! Experimental Extension Subject to Changes !!!
  86561. */
  86562. /** @hidden */
  86563. interface IKHRMaterialsIor {
  86564. ior: number;
  86565. }
  86566. /**
  86567. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86568. */
  86569. /** @hidden */
  86570. interface IKHRMaterialsPbrSpecularGlossiness {
  86571. diffuseFactor: number[];
  86572. diffuseTexture: ITextureInfo;
  86573. specularFactor: number[];
  86574. glossinessFactor: number;
  86575. specularGlossinessTexture: ITextureInfo;
  86576. }
  86577. /**
  86578. * Interfaces from the KHR_materials_sheen extension
  86579. * !!! Experimental Extension Subject to Changes !!!
  86580. */
  86581. /** @hidden */
  86582. interface IKHRMaterialsSheen {
  86583. sheenColorFactor?: number[];
  86584. sheenColorTexture?: ITextureInfo;
  86585. sheenRoughnessFactor?: number;
  86586. sheenRoughnessTexture?: ITextureInfo;
  86587. }
  86588. /**
  86589. * Interfaces from the KHR_materials_specular extension
  86590. * !!! Experimental Extension Subject to Changes !!!
  86591. */
  86592. /** @hidden */
  86593. interface IKHRMaterialsSpecular {
  86594. specularFactor: number;
  86595. specularColorFactor: number[];
  86596. specularTexture: ITextureInfo;
  86597. }
  86598. /**
  86599. * Interfaces from the KHR_materials_transmission extension
  86600. * !!! Experimental Extension Subject to Changes !!!
  86601. */
  86602. /** @hidden */
  86603. interface IKHRMaterialsTransmission {
  86604. transmissionFactor?: number;
  86605. transmissionTexture?: ITextureInfo;
  86606. }
  86607. /**
  86608. * Interfaces from the KHR_materials_variants extension
  86609. * !!! Experimental Extension Subject to Changes !!!
  86610. */
  86611. /** @hidden */
  86612. interface IKHRMaterialVariants_Mapping extends IProperty {
  86613. mappings: Array<{
  86614. variants: number[];
  86615. material: number;
  86616. }>;
  86617. }
  86618. /** @hidden */
  86619. interface IKHRMaterialVariants_Variant extends IProperty {
  86620. name: string;
  86621. }
  86622. /** @hidden */
  86623. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86624. variants: Array<IKHRMaterialVariants_Variant>;
  86625. }
  86626. /**
  86627. * Interfaces from the KHR_texture_basisu extension
  86628. * !!! Experimental Extension Subject to Changes !!!
  86629. */
  86630. /** @hidden */
  86631. interface IKHRTextureBasisU {
  86632. source: number;
  86633. }
  86634. /**
  86635. * Interfaces from the EXT_texture_webp extension
  86636. */
  86637. /** @hidden */
  86638. interface IEXTTextureWebP {
  86639. source: number;
  86640. }
  86641. /**
  86642. * Interfaces from the KHR_texture_transform extension
  86643. */
  86644. /** @hidden */
  86645. interface IKHRTextureTransform {
  86646. offset?: number[];
  86647. rotation?: number;
  86648. scale?: number[];
  86649. texCoord?: number;
  86650. }
  86651. /**
  86652. * Interfaces from the KHR_xmp extension
  86653. * !!! Experimental Extension Subject to Changes !!!
  86654. */
  86655. /** @hidden */
  86656. interface IKHRXmp_Data {
  86657. [key: string]: unknown;
  86658. }
  86659. /** @hidden */
  86660. interface IKHRXmp_Gltf {
  86661. packets: IKHRXmp_Data[];
  86662. }
  86663. /** @hidden */
  86664. interface IKHRXmp_Node {
  86665. packet: number;
  86666. }
  86667. /**
  86668. * Interfaces from the MSFT_audio_emitter extension
  86669. */
  86670. /** @hidden */
  86671. interface IMSFTAudioEmitter_ClipReference {
  86672. clip: number;
  86673. weight?: number;
  86674. }
  86675. /** @hidden */
  86676. interface IMSFTAudioEmitter_EmittersReference {
  86677. emitters: number[];
  86678. }
  86679. /** @hidden */
  86680. const enum IMSFTAudioEmitter_DistanceModel {
  86681. linear = "linear",
  86682. inverse = "inverse",
  86683. exponential = "exponential",
  86684. }
  86685. /** @hidden */
  86686. interface IMSFTAudioEmitter_Emitter {
  86687. name?: string;
  86688. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86689. refDistance?: number;
  86690. maxDistance?: number;
  86691. rolloffFactor?: number;
  86692. innerAngle?: number;
  86693. outerAngle?: number;
  86694. loop?: boolean;
  86695. volume?: number;
  86696. clips: IMSFTAudioEmitter_ClipReference[];
  86697. }
  86698. /** @hidden */
  86699. const enum IMSFTAudioEmitter_AudioMimeType {
  86700. WAV = "audio/wav",
  86701. }
  86702. /** @hidden */
  86703. interface IMSFTAudioEmitter_Clip extends IProperty {
  86704. uri?: string;
  86705. bufferView?: number;
  86706. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  86707. }
  86708. /** @hidden */
  86709. const enum IMSFTAudioEmitter_AnimationEventAction {
  86710. play = "play",
  86711. pause = "pause",
  86712. stop = "stop",
  86713. }
  86714. /** @hidden */
  86715. interface IMSFTAudioEmitter_AnimationEvent {
  86716. action: IMSFTAudioEmitter_AnimationEventAction;
  86717. emitter: number;
  86718. time: number;
  86719. startOffset?: number;
  86720. }
  86721. /**
  86722. * Interfaces from the MSFT_lod extension
  86723. */
  86724. /** @hidden */
  86725. interface IMSFTLOD {
  86726. ids: number[];
  86727. }
  86728. }
  86729. declare module BABYLON {
  86730. /** @hidden */
  86731. export var cellPixelShader: {
  86732. name: string;
  86733. shader: string;
  86734. };
  86735. }
  86736. declare module BABYLON {
  86737. /** @hidden */
  86738. export var cellVertexShader: {
  86739. name: string;
  86740. shader: string;
  86741. };
  86742. }
  86743. declare module BABYLON {
  86744. export class CellMaterial extends BABYLON.PushMaterial {
  86745. private _diffuseTexture;
  86746. diffuseTexture: BABYLON.BaseTexture;
  86747. diffuseColor: BABYLON.Color3;
  86748. _computeHighLevel: boolean;
  86749. computeHighLevel: boolean;
  86750. private _disableLighting;
  86751. disableLighting: boolean;
  86752. private _maxSimultaneousLights;
  86753. maxSimultaneousLights: number;
  86754. constructor(name: string, scene: BABYLON.Scene);
  86755. needAlphaBlending(): boolean;
  86756. needAlphaTesting(): boolean;
  86757. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86758. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86759. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86760. getAnimatables(): BABYLON.IAnimatable[];
  86761. getActiveTextures(): BABYLON.BaseTexture[];
  86762. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86763. dispose(forceDisposeEffect?: boolean): void;
  86764. getClassName(): string;
  86765. clone(name: string): CellMaterial;
  86766. serialize(): any;
  86767. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  86768. }
  86769. }
  86770. declare module BABYLON {
  86771. export class CustomShaderStructure {
  86772. FragmentStore: string;
  86773. VertexStore: string;
  86774. constructor();
  86775. }
  86776. export class ShaderSpecialParts {
  86777. constructor();
  86778. Fragment_Begin: string;
  86779. Fragment_Definitions: string;
  86780. Fragment_MainBegin: string;
  86781. Fragment_Custom_Diffuse: string;
  86782. Fragment_Before_Lights: string;
  86783. Fragment_Before_Fog: string;
  86784. Fragment_Custom_Alpha: string;
  86785. Fragment_Before_FragColor: string;
  86786. Vertex_Begin: string;
  86787. Vertex_Definitions: string;
  86788. Vertex_MainBegin: string;
  86789. Vertex_Before_PositionUpdated: string;
  86790. Vertex_Before_NormalUpdated: string;
  86791. Vertex_After_WorldPosComputed: string;
  86792. Vertex_MainEnd: string;
  86793. }
  86794. export class CustomMaterial extends BABYLON.StandardMaterial {
  86795. static ShaderIndexer: number;
  86796. CustomParts: ShaderSpecialParts;
  86797. _isCreatedShader: boolean;
  86798. _createdShaderName: string;
  86799. _customUniform: string[];
  86800. _newUniforms: string[];
  86801. _newUniformInstances: {
  86802. [name: string]: any;
  86803. };
  86804. _newSamplerInstances: {
  86805. [name: string]: BABYLON.Texture;
  86806. };
  86807. _customAttributes: string[];
  86808. FragmentShader: string;
  86809. VertexShader: string;
  86810. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86811. ReviewUniform(name: string, arr: string[]): string[];
  86812. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86813. constructor(name: string, scene: BABYLON.Scene);
  86814. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  86815. AddAttribute(name: string): CustomMaterial;
  86816. Fragment_Begin(shaderPart: string): CustomMaterial;
  86817. Fragment_Definitions(shaderPart: string): CustomMaterial;
  86818. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  86819. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  86820. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  86821. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  86822. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  86823. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  86824. Vertex_Begin(shaderPart: string): CustomMaterial;
  86825. Vertex_Definitions(shaderPart: string): CustomMaterial;
  86826. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  86827. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  86828. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  86829. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  86830. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  86831. }
  86832. }
  86833. declare module BABYLON {
  86834. export class ShaderAlebdoParts {
  86835. constructor();
  86836. Fragment_Begin: string;
  86837. Fragment_Definitions: string;
  86838. Fragment_MainBegin: string;
  86839. Fragment_Custom_Albedo: string;
  86840. Fragment_Before_Lights: string;
  86841. Fragment_Custom_MetallicRoughness: string;
  86842. Fragment_Custom_MicroSurface: string;
  86843. Fragment_Before_Fog: string;
  86844. Fragment_Custom_Alpha: string;
  86845. Fragment_Before_FragColor: string;
  86846. Vertex_Begin: string;
  86847. Vertex_Definitions: string;
  86848. Vertex_MainBegin: string;
  86849. Vertex_Before_PositionUpdated: string;
  86850. Vertex_Before_NormalUpdated: string;
  86851. Vertex_After_WorldPosComputed: string;
  86852. Vertex_MainEnd: string;
  86853. }
  86854. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  86855. static ShaderIndexer: number;
  86856. CustomParts: ShaderAlebdoParts;
  86857. _isCreatedShader: boolean;
  86858. _createdShaderName: string;
  86859. _customUniform: string[];
  86860. _newUniforms: string[];
  86861. _newUniformInstances: {
  86862. [name: string]: any;
  86863. };
  86864. _newSamplerInstances: {
  86865. [name: string]: BABYLON.Texture;
  86866. };
  86867. _customAttributes: string[];
  86868. FragmentShader: string;
  86869. VertexShader: string;
  86870. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86871. ReviewUniform(name: string, arr: string[]): string[];
  86872. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86873. constructor(name: string, scene: BABYLON.Scene);
  86874. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  86875. AddAttribute(name: string): PBRCustomMaterial;
  86876. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  86877. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  86878. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  86879. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  86880. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  86881. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  86882. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  86883. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  86884. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  86885. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  86886. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  86887. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  86888. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  86889. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  86890. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  86891. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  86892. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  86893. }
  86894. }
  86895. declare module BABYLON {
  86896. /** @hidden */
  86897. export var firePixelShader: {
  86898. name: string;
  86899. shader: string;
  86900. };
  86901. }
  86902. declare module BABYLON {
  86903. /** @hidden */
  86904. export var fireVertexShader: {
  86905. name: string;
  86906. shader: string;
  86907. };
  86908. }
  86909. declare module BABYLON {
  86910. export class FireMaterial extends BABYLON.PushMaterial {
  86911. private _diffuseTexture;
  86912. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86913. private _distortionTexture;
  86914. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86915. private _opacityTexture;
  86916. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86917. diffuseColor: BABYLON.Color3;
  86918. speed: number;
  86919. private _scaledDiffuse;
  86920. private _lastTime;
  86921. constructor(name: string, scene: BABYLON.Scene);
  86922. needAlphaBlending(): boolean;
  86923. needAlphaTesting(): boolean;
  86924. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86925. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86926. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86927. getAnimatables(): BABYLON.IAnimatable[];
  86928. getActiveTextures(): BABYLON.BaseTexture[];
  86929. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86930. getClassName(): string;
  86931. dispose(forceDisposeEffect?: boolean): void;
  86932. clone(name: string): FireMaterial;
  86933. serialize(): any;
  86934. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  86935. }
  86936. }
  86937. declare module BABYLON {
  86938. /** @hidden */
  86939. export var furPixelShader: {
  86940. name: string;
  86941. shader: string;
  86942. };
  86943. }
  86944. declare module BABYLON {
  86945. /** @hidden */
  86946. export var furVertexShader: {
  86947. name: string;
  86948. shader: string;
  86949. };
  86950. }
  86951. declare module BABYLON {
  86952. export class FurMaterial extends BABYLON.PushMaterial {
  86953. private _diffuseTexture;
  86954. diffuseTexture: BABYLON.BaseTexture;
  86955. private _heightTexture;
  86956. heightTexture: BABYLON.BaseTexture;
  86957. diffuseColor: BABYLON.Color3;
  86958. furLength: number;
  86959. furAngle: number;
  86960. furColor: BABYLON.Color3;
  86961. furOffset: number;
  86962. furSpacing: number;
  86963. furGravity: BABYLON.Vector3;
  86964. furSpeed: number;
  86965. furDensity: number;
  86966. furOcclusion: number;
  86967. furTexture: BABYLON.DynamicTexture;
  86968. private _disableLighting;
  86969. disableLighting: boolean;
  86970. private _maxSimultaneousLights;
  86971. maxSimultaneousLights: number;
  86972. highLevelFur: boolean;
  86973. _meshes: BABYLON.AbstractMesh[];
  86974. private _furTime;
  86975. constructor(name: string, scene: BABYLON.Scene);
  86976. get furTime(): number;
  86977. set furTime(furTime: number);
  86978. needAlphaBlending(): boolean;
  86979. needAlphaTesting(): boolean;
  86980. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86981. updateFur(): void;
  86982. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86983. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86984. getAnimatables(): BABYLON.IAnimatable[];
  86985. getActiveTextures(): BABYLON.BaseTexture[];
  86986. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86987. dispose(forceDisposeEffect?: boolean): void;
  86988. clone(name: string): FurMaterial;
  86989. serialize(): any;
  86990. getClassName(): string;
  86991. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  86992. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  86993. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  86994. }
  86995. }
  86996. declare module BABYLON {
  86997. /** @hidden */
  86998. export var gradientPixelShader: {
  86999. name: string;
  87000. shader: string;
  87001. };
  87002. }
  87003. declare module BABYLON {
  87004. /** @hidden */
  87005. export var gradientVertexShader: {
  87006. name: string;
  87007. shader: string;
  87008. };
  87009. }
  87010. declare module BABYLON {
  87011. export class GradientMaterial extends BABYLON.PushMaterial {
  87012. private _maxSimultaneousLights;
  87013. maxSimultaneousLights: number;
  87014. topColor: BABYLON.Color3;
  87015. topColorAlpha: number;
  87016. bottomColor: BABYLON.Color3;
  87017. bottomColorAlpha: number;
  87018. offset: number;
  87019. scale: number;
  87020. smoothness: number;
  87021. private _disableLighting;
  87022. disableLighting: boolean;
  87023. constructor(name: string, scene: BABYLON.Scene);
  87024. needAlphaBlending(): boolean;
  87025. needAlphaTesting(): boolean;
  87026. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87027. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87028. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87029. getAnimatables(): BABYLON.IAnimatable[];
  87030. dispose(forceDisposeEffect?: boolean): void;
  87031. clone(name: string): GradientMaterial;
  87032. serialize(): any;
  87033. getClassName(): string;
  87034. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  87035. }
  87036. }
  87037. declare module BABYLON {
  87038. /** @hidden */
  87039. export var gridPixelShader: {
  87040. name: string;
  87041. shader: string;
  87042. };
  87043. }
  87044. declare module BABYLON {
  87045. /** @hidden */
  87046. export var gridVertexShader: {
  87047. name: string;
  87048. shader: string;
  87049. };
  87050. }
  87051. declare module BABYLON {
  87052. /**
  87053. * The grid materials allows you to wrap any shape with a grid.
  87054. * Colors are customizable.
  87055. */
  87056. export class GridMaterial extends BABYLON.PushMaterial {
  87057. /**
  87058. * Main color of the grid (e.g. between lines)
  87059. */
  87060. mainColor: BABYLON.Color3;
  87061. /**
  87062. * Color of the grid lines.
  87063. */
  87064. lineColor: BABYLON.Color3;
  87065. /**
  87066. * The scale of the grid compared to unit.
  87067. */
  87068. gridRatio: number;
  87069. /**
  87070. * Allows setting an offset for the grid lines.
  87071. */
  87072. gridOffset: BABYLON.Vector3;
  87073. /**
  87074. * The frequency of thicker lines.
  87075. */
  87076. majorUnitFrequency: number;
  87077. /**
  87078. * The visibility of minor units in the grid.
  87079. */
  87080. minorUnitVisibility: number;
  87081. /**
  87082. * The grid opacity outside of the lines.
  87083. */
  87084. opacity: number;
  87085. /**
  87086. * Determine RBG output is premultiplied by alpha value.
  87087. */
  87088. preMultiplyAlpha: boolean;
  87089. private _opacityTexture;
  87090. opacityTexture: BABYLON.BaseTexture;
  87091. private _gridControl;
  87092. /**
  87093. * constructor
  87094. * @param name The name given to the material in order to identify it afterwards.
  87095. * @param scene The scene the material is used in.
  87096. */
  87097. constructor(name: string, scene: BABYLON.Scene);
  87098. /**
  87099. * Returns wehter or not the grid requires alpha blending.
  87100. */
  87101. needAlphaBlending(): boolean;
  87102. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87103. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87104. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87105. /**
  87106. * Dispose the material and its associated resources.
  87107. * @param forceDisposeEffect will also dispose the used effect when true
  87108. */
  87109. dispose(forceDisposeEffect?: boolean): void;
  87110. clone(name: string): GridMaterial;
  87111. serialize(): any;
  87112. getClassName(): string;
  87113. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  87114. }
  87115. }
  87116. declare module BABYLON {
  87117. /** @hidden */
  87118. export var lavaPixelShader: {
  87119. name: string;
  87120. shader: string;
  87121. };
  87122. }
  87123. declare module BABYLON {
  87124. /** @hidden */
  87125. export var lavaVertexShader: {
  87126. name: string;
  87127. shader: string;
  87128. };
  87129. }
  87130. declare module BABYLON {
  87131. export class LavaMaterial extends BABYLON.PushMaterial {
  87132. private _diffuseTexture;
  87133. diffuseTexture: BABYLON.BaseTexture;
  87134. noiseTexture: BABYLON.BaseTexture;
  87135. fogColor: BABYLON.Color3;
  87136. speed: number;
  87137. movingSpeed: number;
  87138. lowFrequencySpeed: number;
  87139. fogDensity: number;
  87140. private _lastTime;
  87141. diffuseColor: BABYLON.Color3;
  87142. private _disableLighting;
  87143. disableLighting: boolean;
  87144. private _unlit;
  87145. unlit: boolean;
  87146. private _maxSimultaneousLights;
  87147. maxSimultaneousLights: number;
  87148. private _scaledDiffuse;
  87149. constructor(name: string, scene: BABYLON.Scene);
  87150. needAlphaBlending(): boolean;
  87151. needAlphaTesting(): boolean;
  87152. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87153. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87154. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87155. getAnimatables(): BABYLON.IAnimatable[];
  87156. getActiveTextures(): BABYLON.BaseTexture[];
  87157. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87158. dispose(forceDisposeEffect?: boolean): void;
  87159. clone(name: string): LavaMaterial;
  87160. serialize(): any;
  87161. getClassName(): string;
  87162. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  87163. }
  87164. }
  87165. declare module BABYLON {
  87166. /** @hidden */
  87167. export var mixPixelShader: {
  87168. name: string;
  87169. shader: string;
  87170. };
  87171. }
  87172. declare module BABYLON {
  87173. /** @hidden */
  87174. export var mixVertexShader: {
  87175. name: string;
  87176. shader: string;
  87177. };
  87178. }
  87179. declare module BABYLON {
  87180. export class MixMaterial extends BABYLON.PushMaterial {
  87181. /**
  87182. * Mix textures
  87183. */
  87184. private _mixTexture1;
  87185. mixTexture1: BABYLON.BaseTexture;
  87186. private _mixTexture2;
  87187. mixTexture2: BABYLON.BaseTexture;
  87188. /**
  87189. * Diffuse textures
  87190. */
  87191. private _diffuseTexture1;
  87192. diffuseTexture1: BABYLON.Texture;
  87193. private _diffuseTexture2;
  87194. diffuseTexture2: BABYLON.Texture;
  87195. private _diffuseTexture3;
  87196. diffuseTexture3: BABYLON.Texture;
  87197. private _diffuseTexture4;
  87198. diffuseTexture4: BABYLON.Texture;
  87199. private _diffuseTexture5;
  87200. diffuseTexture5: BABYLON.Texture;
  87201. private _diffuseTexture6;
  87202. diffuseTexture6: BABYLON.Texture;
  87203. private _diffuseTexture7;
  87204. diffuseTexture7: BABYLON.Texture;
  87205. private _diffuseTexture8;
  87206. diffuseTexture8: BABYLON.Texture;
  87207. /**
  87208. * Uniforms
  87209. */
  87210. diffuseColor: BABYLON.Color3;
  87211. specularColor: BABYLON.Color3;
  87212. specularPower: number;
  87213. private _disableLighting;
  87214. disableLighting: boolean;
  87215. private _maxSimultaneousLights;
  87216. maxSimultaneousLights: number;
  87217. constructor(name: string, scene: BABYLON.Scene);
  87218. needAlphaBlending(): boolean;
  87219. needAlphaTesting(): boolean;
  87220. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87221. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87222. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87223. getAnimatables(): BABYLON.IAnimatable[];
  87224. getActiveTextures(): BABYLON.BaseTexture[];
  87225. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87226. dispose(forceDisposeEffect?: boolean): void;
  87227. clone(name: string): MixMaterial;
  87228. serialize(): any;
  87229. getClassName(): string;
  87230. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87231. }
  87232. }
  87233. declare module BABYLON {
  87234. /** @hidden */
  87235. export var normalPixelShader: {
  87236. name: string;
  87237. shader: string;
  87238. };
  87239. }
  87240. declare module BABYLON {
  87241. /** @hidden */
  87242. export var normalVertexShader: {
  87243. name: string;
  87244. shader: string;
  87245. };
  87246. }
  87247. declare module BABYLON {
  87248. export class NormalMaterial extends BABYLON.PushMaterial {
  87249. private _diffuseTexture;
  87250. diffuseTexture: BABYLON.BaseTexture;
  87251. diffuseColor: BABYLON.Color3;
  87252. private _disableLighting;
  87253. disableLighting: boolean;
  87254. private _maxSimultaneousLights;
  87255. maxSimultaneousLights: number;
  87256. constructor(name: string, scene: BABYLON.Scene);
  87257. needAlphaBlending(): boolean;
  87258. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87259. needAlphaTesting(): boolean;
  87260. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87261. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87262. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87263. getAnimatables(): BABYLON.IAnimatable[];
  87264. getActiveTextures(): BABYLON.BaseTexture[];
  87265. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87266. dispose(forceDisposeEffect?: boolean): void;
  87267. clone(name: string): NormalMaterial;
  87268. serialize(): any;
  87269. getClassName(): string;
  87270. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87271. }
  87272. }
  87273. declare module BABYLON {
  87274. /** @hidden */
  87275. export var shadowOnlyPixelShader: {
  87276. name: string;
  87277. shader: string;
  87278. };
  87279. }
  87280. declare module BABYLON {
  87281. /** @hidden */
  87282. export var shadowOnlyVertexShader: {
  87283. name: string;
  87284. shader: string;
  87285. };
  87286. }
  87287. declare module BABYLON {
  87288. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87289. private _activeLight;
  87290. private _needAlphaBlending;
  87291. constructor(name: string, scene: BABYLON.Scene);
  87292. shadowColor: BABYLON.Color3;
  87293. needAlphaBlending(): boolean;
  87294. needAlphaTesting(): boolean;
  87295. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87296. get activeLight(): BABYLON.IShadowLight;
  87297. set activeLight(light: BABYLON.IShadowLight);
  87298. private _getFirstShadowLightForMesh;
  87299. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87300. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87301. clone(name: string): ShadowOnlyMaterial;
  87302. serialize(): any;
  87303. getClassName(): string;
  87304. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87305. }
  87306. }
  87307. declare module BABYLON {
  87308. /** @hidden */
  87309. export var simplePixelShader: {
  87310. name: string;
  87311. shader: string;
  87312. };
  87313. }
  87314. declare module BABYLON {
  87315. /** @hidden */
  87316. export var simpleVertexShader: {
  87317. name: string;
  87318. shader: string;
  87319. };
  87320. }
  87321. declare module BABYLON {
  87322. export class SimpleMaterial extends BABYLON.PushMaterial {
  87323. private _diffuseTexture;
  87324. diffuseTexture: BABYLON.BaseTexture;
  87325. diffuseColor: BABYLON.Color3;
  87326. private _disableLighting;
  87327. disableLighting: boolean;
  87328. private _maxSimultaneousLights;
  87329. maxSimultaneousLights: number;
  87330. constructor(name: string, scene: BABYLON.Scene);
  87331. needAlphaBlending(): boolean;
  87332. needAlphaTesting(): boolean;
  87333. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87334. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87335. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87336. getAnimatables(): BABYLON.IAnimatable[];
  87337. getActiveTextures(): BABYLON.BaseTexture[];
  87338. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87339. dispose(forceDisposeEffect?: boolean): void;
  87340. clone(name: string): SimpleMaterial;
  87341. serialize(): any;
  87342. getClassName(): string;
  87343. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87344. }
  87345. }
  87346. declare module BABYLON {
  87347. /** @hidden */
  87348. export var skyPixelShader: {
  87349. name: string;
  87350. shader: string;
  87351. };
  87352. }
  87353. declare module BABYLON {
  87354. /** @hidden */
  87355. export var skyVertexShader: {
  87356. name: string;
  87357. shader: string;
  87358. };
  87359. }
  87360. declare module BABYLON {
  87361. /**
  87362. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87363. * @see https://doc.babylonjs.com/extensions/sky
  87364. */
  87365. export class SkyMaterial extends BABYLON.PushMaterial {
  87366. /**
  87367. * Defines the overall luminance of sky in interval ]0, 1[.
  87368. */
  87369. luminance: number;
  87370. /**
  87371. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87372. */
  87373. turbidity: number;
  87374. /**
  87375. * Defines the sky appearance (light intensity).
  87376. */
  87377. rayleigh: number;
  87378. /**
  87379. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87380. */
  87381. mieCoefficient: number;
  87382. /**
  87383. * Defines the amount of haze particles following the Mie scattering theory.
  87384. */
  87385. mieDirectionalG: number;
  87386. /**
  87387. * Defines the distance of the sun according to the active scene camera.
  87388. */
  87389. distance: number;
  87390. /**
  87391. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87392. * "inclined".
  87393. */
  87394. inclination: number;
  87395. /**
  87396. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87397. * an object direction and a reference direction.
  87398. */
  87399. azimuth: number;
  87400. /**
  87401. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87402. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87403. */
  87404. sunPosition: BABYLON.Vector3;
  87405. /**
  87406. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87407. * .sunPosition property.
  87408. */
  87409. useSunPosition: boolean;
  87410. /**
  87411. * Defines an offset vector used to get a horizon offset.
  87412. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87413. */
  87414. cameraOffset: BABYLON.Vector3;
  87415. private _cameraPosition;
  87416. /**
  87417. * Instantiates a new sky material.
  87418. * This material allows to create dynamic and texture free
  87419. * effects for skyboxes by taking care of the atmosphere state.
  87420. * @see https://doc.babylonjs.com/extensions/sky
  87421. * @param name Define the name of the material in the scene
  87422. * @param scene Define the scene the material belong to
  87423. */
  87424. constructor(name: string, scene: BABYLON.Scene);
  87425. /**
  87426. * Specifies if the material will require alpha blending
  87427. * @returns a boolean specifying if alpha blending is needed
  87428. */
  87429. needAlphaBlending(): boolean;
  87430. /**
  87431. * Specifies if this material should be rendered in alpha test mode
  87432. * @returns false as the sky material doesn't need alpha testing.
  87433. */
  87434. needAlphaTesting(): boolean;
  87435. /**
  87436. * Get the texture used for alpha test purpose.
  87437. * @returns null as the sky material has no texture.
  87438. */
  87439. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87440. /**
  87441. * Get if the submesh is ready to be used and all its information available.
  87442. * Child classes can use it to update shaders
  87443. * @param mesh defines the mesh to check
  87444. * @param subMesh defines which submesh to check
  87445. * @param useInstances specifies that instances should be used
  87446. * @returns a boolean indicating that the submesh is ready or not
  87447. */
  87448. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87449. /**
  87450. * Binds the submesh to this material by preparing the effect and shader to draw
  87451. * @param world defines the world transformation matrix
  87452. * @param mesh defines the mesh containing the submesh
  87453. * @param subMesh defines the submesh to bind the material to
  87454. */
  87455. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87456. /**
  87457. * Get the list of animatables in the material.
  87458. * @returns the list of animatables object used in the material
  87459. */
  87460. getAnimatables(): BABYLON.IAnimatable[];
  87461. /**
  87462. * Disposes the material
  87463. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87464. */
  87465. dispose(forceDisposeEffect?: boolean): void;
  87466. /**
  87467. * Makes a duplicate of the material, and gives it a new name
  87468. * @param name defines the new name for the duplicated material
  87469. * @returns the cloned material
  87470. */
  87471. clone(name: string): SkyMaterial;
  87472. /**
  87473. * Serializes this material in a JSON representation
  87474. * @returns the serialized material object
  87475. */
  87476. serialize(): any;
  87477. /**
  87478. * Gets the current class name of the material e.g. "SkyMaterial"
  87479. * Mainly use in serialization.
  87480. * @returns the class name
  87481. */
  87482. getClassName(): string;
  87483. /**
  87484. * Creates a sky material from parsed material data
  87485. * @param source defines the JSON representation of the material
  87486. * @param scene defines the hosting scene
  87487. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87488. * @returns a new sky material
  87489. */
  87490. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87491. }
  87492. }
  87493. declare module BABYLON {
  87494. /** @hidden */
  87495. export var terrainPixelShader: {
  87496. name: string;
  87497. shader: string;
  87498. };
  87499. }
  87500. declare module BABYLON {
  87501. /** @hidden */
  87502. export var terrainVertexShader: {
  87503. name: string;
  87504. shader: string;
  87505. };
  87506. }
  87507. declare module BABYLON {
  87508. export class TerrainMaterial extends BABYLON.PushMaterial {
  87509. private _mixTexture;
  87510. mixTexture: BABYLON.BaseTexture;
  87511. private _diffuseTexture1;
  87512. diffuseTexture1: BABYLON.Texture;
  87513. private _diffuseTexture2;
  87514. diffuseTexture2: BABYLON.Texture;
  87515. private _diffuseTexture3;
  87516. diffuseTexture3: BABYLON.Texture;
  87517. private _bumpTexture1;
  87518. bumpTexture1: BABYLON.Texture;
  87519. private _bumpTexture2;
  87520. bumpTexture2: BABYLON.Texture;
  87521. private _bumpTexture3;
  87522. bumpTexture3: BABYLON.Texture;
  87523. diffuseColor: BABYLON.Color3;
  87524. specularColor: BABYLON.Color3;
  87525. specularPower: number;
  87526. private _disableLighting;
  87527. disableLighting: boolean;
  87528. private _maxSimultaneousLights;
  87529. maxSimultaneousLights: number;
  87530. constructor(name: string, scene: BABYLON.Scene);
  87531. needAlphaBlending(): boolean;
  87532. needAlphaTesting(): boolean;
  87533. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87534. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87535. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87536. getAnimatables(): BABYLON.IAnimatable[];
  87537. getActiveTextures(): BABYLON.BaseTexture[];
  87538. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87539. dispose(forceDisposeEffect?: boolean): void;
  87540. clone(name: string): TerrainMaterial;
  87541. serialize(): any;
  87542. getClassName(): string;
  87543. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87544. }
  87545. }
  87546. declare module BABYLON {
  87547. /** @hidden */
  87548. export var triplanarPixelShader: {
  87549. name: string;
  87550. shader: string;
  87551. };
  87552. }
  87553. declare module BABYLON {
  87554. /** @hidden */
  87555. export var triplanarVertexShader: {
  87556. name: string;
  87557. shader: string;
  87558. };
  87559. }
  87560. declare module BABYLON {
  87561. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87562. mixTexture: BABYLON.BaseTexture;
  87563. private _diffuseTextureX;
  87564. diffuseTextureX: BABYLON.BaseTexture;
  87565. private _diffuseTextureY;
  87566. diffuseTextureY: BABYLON.BaseTexture;
  87567. private _diffuseTextureZ;
  87568. diffuseTextureZ: BABYLON.BaseTexture;
  87569. private _normalTextureX;
  87570. normalTextureX: BABYLON.BaseTexture;
  87571. private _normalTextureY;
  87572. normalTextureY: BABYLON.BaseTexture;
  87573. private _normalTextureZ;
  87574. normalTextureZ: BABYLON.BaseTexture;
  87575. tileSize: number;
  87576. diffuseColor: BABYLON.Color3;
  87577. specularColor: BABYLON.Color3;
  87578. specularPower: number;
  87579. private _disableLighting;
  87580. disableLighting: boolean;
  87581. private _maxSimultaneousLights;
  87582. maxSimultaneousLights: number;
  87583. constructor(name: string, scene: BABYLON.Scene);
  87584. needAlphaBlending(): boolean;
  87585. needAlphaTesting(): boolean;
  87586. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87587. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87588. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87589. getAnimatables(): BABYLON.IAnimatable[];
  87590. getActiveTextures(): BABYLON.BaseTexture[];
  87591. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87592. dispose(forceDisposeEffect?: boolean): void;
  87593. clone(name: string): TriPlanarMaterial;
  87594. serialize(): any;
  87595. getClassName(): string;
  87596. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  87597. }
  87598. }
  87599. declare module BABYLON {
  87600. /** @hidden */
  87601. export var waterPixelShader: {
  87602. name: string;
  87603. shader: string;
  87604. };
  87605. }
  87606. declare module BABYLON {
  87607. /** @hidden */
  87608. export var waterVertexShader: {
  87609. name: string;
  87610. shader: string;
  87611. };
  87612. }
  87613. declare module BABYLON {
  87614. export class WaterMaterial extends BABYLON.PushMaterial {
  87615. renderTargetSize: BABYLON.Vector2;
  87616. private _bumpTexture;
  87617. bumpTexture: BABYLON.BaseTexture;
  87618. diffuseColor: BABYLON.Color3;
  87619. specularColor: BABYLON.Color3;
  87620. specularPower: number;
  87621. private _disableLighting;
  87622. disableLighting: boolean;
  87623. private _maxSimultaneousLights;
  87624. maxSimultaneousLights: number;
  87625. /**
  87626. * Defines the wind force.
  87627. */
  87628. windForce: number;
  87629. /**
  87630. * Defines the direction of the wind in the plane (X, Z).
  87631. */
  87632. windDirection: BABYLON.Vector2;
  87633. /**
  87634. * Defines the height of the waves.
  87635. */
  87636. waveHeight: number;
  87637. /**
  87638. * Defines the bump height related to the bump map.
  87639. */
  87640. bumpHeight: number;
  87641. /**
  87642. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87643. */
  87644. private _bumpSuperimpose;
  87645. bumpSuperimpose: boolean;
  87646. /**
  87647. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87648. */
  87649. private _fresnelSeparate;
  87650. fresnelSeparate: boolean;
  87651. /**
  87652. * Defines wether or not bump Wwves modify the reflection.
  87653. */
  87654. private _bumpAffectsReflection;
  87655. bumpAffectsReflection: boolean;
  87656. /**
  87657. * Defines the water color blended with the refraction (near).
  87658. */
  87659. waterColor: BABYLON.Color3;
  87660. /**
  87661. * Defines the blend factor related to the water color.
  87662. */
  87663. colorBlendFactor: number;
  87664. /**
  87665. * Defines the water color blended with the reflection (far).
  87666. */
  87667. waterColor2: BABYLON.Color3;
  87668. /**
  87669. * Defines the blend factor related to the water color (reflection, far).
  87670. */
  87671. colorBlendFactor2: number;
  87672. /**
  87673. * Defines the maximum length of a wave.
  87674. */
  87675. waveLength: number;
  87676. /**
  87677. * Defines the waves speed.
  87678. */
  87679. waveSpeed: number;
  87680. /**
  87681. * 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.
  87682. */
  87683. waveCount: number;
  87684. /**
  87685. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87686. * will avoid calculating useless pixels in the pixel shader of the water material.
  87687. */
  87688. disableClipPlane: boolean;
  87689. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87690. private _mesh;
  87691. private _refractionRTT;
  87692. private _reflectionRTT;
  87693. private _reflectionTransform;
  87694. private _lastTime;
  87695. private _lastDeltaTime;
  87696. private _useLogarithmicDepth;
  87697. private _waitingRenderList;
  87698. private _imageProcessingConfiguration;
  87699. private _imageProcessingObserver;
  87700. /**
  87701. * Gets a boolean indicating that current material needs to register RTT
  87702. */
  87703. get hasRenderTargetTextures(): boolean;
  87704. /**
  87705. * Constructor
  87706. */
  87707. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  87708. get useLogarithmicDepth(): boolean;
  87709. set useLogarithmicDepth(value: boolean);
  87710. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87711. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87712. addToRenderList(node: any): void;
  87713. enableRenderTargets(enable: boolean): void;
  87714. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  87715. get renderTargetsEnabled(): boolean;
  87716. needAlphaBlending(): boolean;
  87717. needAlphaTesting(): boolean;
  87718. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87719. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87720. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87721. private _createRenderTargets;
  87722. getAnimatables(): BABYLON.IAnimatable[];
  87723. getActiveTextures(): BABYLON.BaseTexture[];
  87724. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87725. dispose(forceDisposeEffect?: boolean): void;
  87726. clone(name: string): WaterMaterial;
  87727. serialize(): any;
  87728. getClassName(): string;
  87729. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  87730. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  87731. }
  87732. }
  87733. declare module BABYLON {
  87734. /** @hidden */
  87735. export var asciiartPixelShader: {
  87736. name: string;
  87737. shader: string;
  87738. };
  87739. }
  87740. declare module BABYLON {
  87741. /**
  87742. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  87743. *
  87744. * It basically takes care rendering the font front the given font size to a texture.
  87745. * This is used later on in the postprocess.
  87746. */
  87747. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  87748. private _font;
  87749. private _text;
  87750. private _charSize;
  87751. /**
  87752. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87753. */
  87754. get charSize(): number;
  87755. /**
  87756. * Create a new instance of the Ascii Art FontTexture class
  87757. * @param name the name of the texture
  87758. * @param font the font to use, use the W3C CSS notation
  87759. * @param text the caracter set to use in the rendering.
  87760. * @param scene the scene that owns the texture
  87761. */
  87762. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87763. /**
  87764. * Gets the max char width of a font.
  87765. * @param font the font to use, use the W3C CSS notation
  87766. * @return the max char width
  87767. */
  87768. private getFontWidth;
  87769. /**
  87770. * Gets the max char height of a font.
  87771. * @param font the font to use, use the W3C CSS notation
  87772. * @return the max char height
  87773. */
  87774. private getFontHeight;
  87775. /**
  87776. * Clones the current AsciiArtTexture.
  87777. * @return the clone of the texture.
  87778. */
  87779. clone(): AsciiArtFontTexture;
  87780. /**
  87781. * Parses a json object representing the texture and returns an instance of it.
  87782. * @param source the source JSON representation
  87783. * @param scene the scene to create the texture for
  87784. * @return the parsed texture
  87785. */
  87786. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  87787. }
  87788. /**
  87789. * Option available in the Ascii Art Post Process.
  87790. */
  87791. export interface IAsciiArtPostProcessOptions {
  87792. /**
  87793. * The font to use following the w3c font definition.
  87794. */
  87795. font?: string;
  87796. /**
  87797. * The character set to use in the postprocess.
  87798. */
  87799. characterSet?: string;
  87800. /**
  87801. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87802. * This number is defined between 0 and 1;
  87803. */
  87804. mixToTile?: number;
  87805. /**
  87806. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87807. * This number is defined between 0 and 1;
  87808. */
  87809. mixToNormal?: number;
  87810. }
  87811. /**
  87812. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  87813. *
  87814. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87815. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  87816. */
  87817. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  87818. /**
  87819. * The font texture used to render the char in the post process.
  87820. */
  87821. private _asciiArtFontTexture;
  87822. /**
  87823. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87824. * This number is defined between 0 and 1;
  87825. */
  87826. mixToTile: number;
  87827. /**
  87828. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87829. * This number is defined between 0 and 1;
  87830. */
  87831. mixToNormal: number;
  87832. /**
  87833. * Instantiates a new Ascii Art Post Process.
  87834. * @param name the name to give to the postprocess
  87835. * @camera the camera to apply the post process to.
  87836. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  87837. */
  87838. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  87839. }
  87840. }
  87841. declare module BABYLON {
  87842. /** @hidden */
  87843. export var digitalrainPixelShader: {
  87844. name: string;
  87845. shader: string;
  87846. };
  87847. }
  87848. declare module BABYLON {
  87849. /**
  87850. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  87851. *
  87852. * It basically takes care rendering the font front the given font size to a texture.
  87853. * This is used later on in the postprocess.
  87854. */
  87855. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  87856. private _font;
  87857. private _text;
  87858. private _charSize;
  87859. /**
  87860. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87861. */
  87862. get charSize(): number;
  87863. /**
  87864. * Create a new instance of the Digital Rain FontTexture class
  87865. * @param name the name of the texture
  87866. * @param font the font to use, use the W3C CSS notation
  87867. * @param text the caracter set to use in the rendering.
  87868. * @param scene the scene that owns the texture
  87869. */
  87870. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87871. /**
  87872. * Gets the max char width of a font.
  87873. * @param font the font to use, use the W3C CSS notation
  87874. * @return the max char width
  87875. */
  87876. private getFontWidth;
  87877. /**
  87878. * Gets the max char height of a font.
  87879. * @param font the font to use, use the W3C CSS notation
  87880. * @return the max char height
  87881. */
  87882. private getFontHeight;
  87883. /**
  87884. * Clones the current DigitalRainFontTexture.
  87885. * @return the clone of the texture.
  87886. */
  87887. clone(): DigitalRainFontTexture;
  87888. /**
  87889. * Parses a json object representing the texture and returns an instance of it.
  87890. * @param source the source JSON representation
  87891. * @param scene the scene to create the texture for
  87892. * @return the parsed texture
  87893. */
  87894. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  87895. }
  87896. /**
  87897. * Option available in the Digital Rain Post Process.
  87898. */
  87899. export interface IDigitalRainPostProcessOptions {
  87900. /**
  87901. * The font to use following the w3c font definition.
  87902. */
  87903. font?: string;
  87904. /**
  87905. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87906. * This number is defined between 0 and 1;
  87907. */
  87908. mixToTile?: number;
  87909. /**
  87910. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87911. * This number is defined between 0 and 1;
  87912. */
  87913. mixToNormal?: number;
  87914. }
  87915. /**
  87916. * DigitalRainPostProcess helps rendering everithing in digital rain.
  87917. *
  87918. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87919. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  87920. */
  87921. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  87922. /**
  87923. * The font texture used to render the char in the post process.
  87924. */
  87925. private _digitalRainFontTexture;
  87926. /**
  87927. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87928. * This number is defined between 0 and 1;
  87929. */
  87930. mixToTile: number;
  87931. /**
  87932. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87933. * This number is defined between 0 and 1;
  87934. */
  87935. mixToNormal: number;
  87936. /**
  87937. * Instantiates a new Digital Rain Post Process.
  87938. * @param name the name to give to the postprocess
  87939. * @camera the camera to apply the post process to.
  87940. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  87941. */
  87942. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  87943. }
  87944. }
  87945. declare module BABYLON {
  87946. /** @hidden */
  87947. export var brickProceduralTexturePixelShader: {
  87948. name: string;
  87949. shader: string;
  87950. };
  87951. }
  87952. declare module BABYLON {
  87953. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  87954. private _numberOfBricksHeight;
  87955. private _numberOfBricksWidth;
  87956. private _jointColor;
  87957. private _brickColor;
  87958. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87959. updateShaderUniforms(): void;
  87960. get numberOfBricksHeight(): number;
  87961. set numberOfBricksHeight(value: number);
  87962. get numberOfBricksWidth(): number;
  87963. set numberOfBricksWidth(value: number);
  87964. get jointColor(): BABYLON.Color3;
  87965. set jointColor(value: BABYLON.Color3);
  87966. get brickColor(): BABYLON.Color3;
  87967. set brickColor(value: BABYLON.Color3);
  87968. /**
  87969. * Serializes this brick procedural texture
  87970. * @returns a serialized brick procedural texture object
  87971. */
  87972. serialize(): any;
  87973. /**
  87974. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  87975. * @param parsedTexture defines parsed texture data
  87976. * @param scene defines the current scene
  87977. * @param rootUrl defines the root URL containing brick procedural texture information
  87978. * @returns a parsed Brick Procedural BABYLON.Texture
  87979. */
  87980. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  87981. }
  87982. }
  87983. declare module BABYLON {
  87984. /** @hidden */
  87985. export var cloudProceduralTexturePixelShader: {
  87986. name: string;
  87987. shader: string;
  87988. };
  87989. }
  87990. declare module BABYLON {
  87991. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  87992. private _skyColor;
  87993. private _cloudColor;
  87994. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87995. updateShaderUniforms(): void;
  87996. get skyColor(): BABYLON.Color4;
  87997. set skyColor(value: BABYLON.Color4);
  87998. get cloudColor(): BABYLON.Color4;
  87999. set cloudColor(value: BABYLON.Color4);
  88000. /**
  88001. * Serializes this cloud procedural texture
  88002. * @returns a serialized cloud procedural texture object
  88003. */
  88004. serialize(): any;
  88005. /**
  88006. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  88007. * @param parsedTexture defines parsed texture data
  88008. * @param scene defines the current scene
  88009. * @param rootUrl defines the root URL containing cloud procedural texture information
  88010. * @returns a parsed Cloud Procedural BABYLON.Texture
  88011. */
  88012. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  88013. }
  88014. }
  88015. declare module BABYLON {
  88016. /** @hidden */
  88017. export var fireProceduralTexturePixelShader: {
  88018. name: string;
  88019. shader: string;
  88020. };
  88021. }
  88022. declare module BABYLON {
  88023. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  88024. private _time;
  88025. private _speed;
  88026. private _autoGenerateTime;
  88027. private _fireColors;
  88028. private _alphaThreshold;
  88029. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88030. updateShaderUniforms(): void;
  88031. render(useCameraPostProcess?: boolean): void;
  88032. static get PurpleFireColors(): BABYLON.Color3[];
  88033. static get GreenFireColors(): BABYLON.Color3[];
  88034. static get RedFireColors(): BABYLON.Color3[];
  88035. static get BlueFireColors(): BABYLON.Color3[];
  88036. get autoGenerateTime(): boolean;
  88037. set autoGenerateTime(value: boolean);
  88038. get fireColors(): BABYLON.Color3[];
  88039. set fireColors(value: BABYLON.Color3[]);
  88040. get time(): number;
  88041. set time(value: number);
  88042. get speed(): BABYLON.Vector2;
  88043. set speed(value: BABYLON.Vector2);
  88044. get alphaThreshold(): number;
  88045. set alphaThreshold(value: number);
  88046. /**
  88047. * Serializes this fire procedural texture
  88048. * @returns a serialized fire procedural texture object
  88049. */
  88050. serialize(): any;
  88051. /**
  88052. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  88053. * @param parsedTexture defines parsed texture data
  88054. * @param scene defines the current scene
  88055. * @param rootUrl defines the root URL containing fire procedural texture information
  88056. * @returns a parsed Fire Procedural BABYLON.Texture
  88057. */
  88058. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  88059. }
  88060. }
  88061. declare module BABYLON {
  88062. /** @hidden */
  88063. export var grassProceduralTexturePixelShader: {
  88064. name: string;
  88065. shader: string;
  88066. };
  88067. }
  88068. declare module BABYLON {
  88069. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  88070. private _grassColors;
  88071. private _groundColor;
  88072. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88073. updateShaderUniforms(): void;
  88074. get grassColors(): BABYLON.Color3[];
  88075. set grassColors(value: BABYLON.Color3[]);
  88076. get groundColor(): BABYLON.Color3;
  88077. set groundColor(value: BABYLON.Color3);
  88078. /**
  88079. * Serializes this grass procedural texture
  88080. * @returns a serialized grass procedural texture object
  88081. */
  88082. serialize(): any;
  88083. /**
  88084. * Creates a Grass Procedural BABYLON.Texture from parsed grass 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 grass procedural texture information
  88088. * @returns a parsed Grass Procedural BABYLON.Texture
  88089. */
  88090. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  88091. }
  88092. }
  88093. declare module BABYLON {
  88094. /** @hidden */
  88095. export var marbleProceduralTexturePixelShader: {
  88096. name: string;
  88097. shader: string;
  88098. };
  88099. }
  88100. declare module BABYLON {
  88101. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  88102. private _numberOfTilesHeight;
  88103. private _numberOfTilesWidth;
  88104. private _amplitude;
  88105. private _jointColor;
  88106. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88107. updateShaderUniforms(): void;
  88108. get numberOfTilesHeight(): number;
  88109. set numberOfTilesHeight(value: number);
  88110. get amplitude(): number;
  88111. set amplitude(value: number);
  88112. get numberOfTilesWidth(): number;
  88113. set numberOfTilesWidth(value: number);
  88114. get jointColor(): BABYLON.Color3;
  88115. set jointColor(value: BABYLON.Color3);
  88116. /**
  88117. * Serializes this marble procedural texture
  88118. * @returns a serialized marble procedural texture object
  88119. */
  88120. serialize(): any;
  88121. /**
  88122. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  88123. * @param parsedTexture defines parsed texture data
  88124. * @param scene defines the current scene
  88125. * @param rootUrl defines the root URL containing marble procedural texture information
  88126. * @returns a parsed Marble Procedural BABYLON.Texture
  88127. */
  88128. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  88129. }
  88130. }
  88131. declare module BABYLON {
  88132. /** @hidden */
  88133. export var normalMapProceduralTexturePixelShader: {
  88134. name: string;
  88135. shader: string;
  88136. };
  88137. }
  88138. declare module BABYLON {
  88139. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  88140. private _baseTexture;
  88141. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88142. updateShaderUniforms(): void;
  88143. render(useCameraPostProcess?: boolean): void;
  88144. resize(size: any, generateMipMaps: any): void;
  88145. get baseTexture(): BABYLON.Texture;
  88146. set baseTexture(texture: BABYLON.Texture);
  88147. /**
  88148. * Serializes this normal map procedural texture
  88149. * @returns a serialized normal map procedural texture object
  88150. */
  88151. serialize(): any;
  88152. /**
  88153. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  88154. * @param parsedTexture defines parsed texture data
  88155. * @param scene defines the current scene
  88156. * @param rootUrl defines the root URL containing normal map procedural texture information
  88157. * @returns a parsed Normal Map Procedural BABYLON.Texture
  88158. */
  88159. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  88160. }
  88161. }
  88162. declare module BABYLON {
  88163. /** @hidden */
  88164. export var perlinNoiseProceduralTexturePixelShader: {
  88165. name: string;
  88166. shader: string;
  88167. };
  88168. }
  88169. declare module BABYLON {
  88170. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  88171. time: number;
  88172. timeScale: number;
  88173. translationSpeed: number;
  88174. private _currentTranslation;
  88175. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88176. updateShaderUniforms(): void;
  88177. render(useCameraPostProcess?: boolean): void;
  88178. resize(size: any, generateMipMaps: any): void;
  88179. /**
  88180. * Serializes this perlin noise procedural texture
  88181. * @returns a serialized perlin noise procedural texture object
  88182. */
  88183. serialize(): any;
  88184. /**
  88185. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88186. * @param parsedTexture defines parsed texture data
  88187. * @param scene defines the current scene
  88188. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88189. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88190. */
  88191. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88192. }
  88193. }
  88194. declare module BABYLON {
  88195. /** @hidden */
  88196. export var roadProceduralTexturePixelShader: {
  88197. name: string;
  88198. shader: string;
  88199. };
  88200. }
  88201. declare module BABYLON {
  88202. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88203. private _roadColor;
  88204. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88205. updateShaderUniforms(): void;
  88206. get roadColor(): BABYLON.Color3;
  88207. set roadColor(value: BABYLON.Color3);
  88208. /**
  88209. * Serializes this road procedural texture
  88210. * @returns a serialized road procedural texture object
  88211. */
  88212. serialize(): any;
  88213. /**
  88214. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88215. * @param parsedTexture defines parsed texture data
  88216. * @param scene defines the current scene
  88217. * @param rootUrl defines the root URL containing road procedural texture information
  88218. * @returns a parsed Road Procedural BABYLON.Texture
  88219. */
  88220. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88221. }
  88222. }
  88223. declare module BABYLON {
  88224. /** @hidden */
  88225. export var starfieldProceduralTexturePixelShader: {
  88226. name: string;
  88227. shader: string;
  88228. };
  88229. }
  88230. declare module BABYLON {
  88231. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88232. private _time;
  88233. private _alpha;
  88234. private _beta;
  88235. private _zoom;
  88236. private _formuparam;
  88237. private _stepsize;
  88238. private _tile;
  88239. private _brightness;
  88240. private _darkmatter;
  88241. private _distfading;
  88242. private _saturation;
  88243. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88244. updateShaderUniforms(): void;
  88245. get time(): number;
  88246. set time(value: number);
  88247. get alpha(): number;
  88248. set alpha(value: number);
  88249. get beta(): number;
  88250. set beta(value: number);
  88251. get formuparam(): number;
  88252. set formuparam(value: number);
  88253. get stepsize(): number;
  88254. set stepsize(value: number);
  88255. get zoom(): number;
  88256. set zoom(value: number);
  88257. get tile(): number;
  88258. set tile(value: number);
  88259. get brightness(): number;
  88260. set brightness(value: number);
  88261. get darkmatter(): number;
  88262. set darkmatter(value: number);
  88263. get distfading(): number;
  88264. set distfading(value: number);
  88265. get saturation(): number;
  88266. set saturation(value: number);
  88267. /**
  88268. * Serializes this starfield procedural texture
  88269. * @returns a serialized starfield procedural texture object
  88270. */
  88271. serialize(): any;
  88272. /**
  88273. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88274. * @param parsedTexture defines parsed texture data
  88275. * @param scene defines the current scene
  88276. * @param rootUrl defines the root URL containing startfield procedural texture information
  88277. * @returns a parsed Starfield Procedural BABYLON.Texture
  88278. */
  88279. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88280. }
  88281. }
  88282. declare module BABYLON {
  88283. /** @hidden */
  88284. export var woodProceduralTexturePixelShader: {
  88285. name: string;
  88286. shader: string;
  88287. };
  88288. }
  88289. declare module BABYLON {
  88290. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88291. private _ampScale;
  88292. private _woodColor;
  88293. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88294. updateShaderUniforms(): void;
  88295. get ampScale(): number;
  88296. set ampScale(value: number);
  88297. get woodColor(): BABYLON.Color3;
  88298. set woodColor(value: BABYLON.Color3);
  88299. /**
  88300. * Serializes this wood procedural texture
  88301. * @returns a serialized wood procedural texture object
  88302. */
  88303. serialize(): any;
  88304. /**
  88305. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88306. * @param parsedTexture defines parsed texture data
  88307. * @param scene defines the current scene
  88308. * @param rootUrl defines the root URL containing wood procedural texture information
  88309. * @returns a parsed Wood Procedural BABYLON.Texture
  88310. */
  88311. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88312. }
  88313. }